π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
feat: text widget
DarkPhoenix27046505e2170331
diff --git a/packages/nc-gui/components/nc/NonNullableNumberInput.vue b/packages/nc-gui/components/nc/NonNullableNumberInput.vuenew file mode 100644index 0000000000..10f770d99e--- /dev/null+++ b/packages/nc-gui/components/nc/NonNullableNumberInput.vue@@ -0,0 +1,38 @@+<script setup lang="ts">+const { min = 0, resetTo } = defineProps<{+ min?: number+ resetTo?: number+ placeholder?: string+}>()+const vModel = defineModel<string | number>({ required: true })++const inputRef = ref<{ input: HTMLInputElement }>()++function onBlur() {+ if (vModel.value === '') {+ vModel.value = resetTo ?? min+ return+ }+ if (+vModel.value < min) vModel.value = min+}++function selectText() {+ if (!inputRef.value) return+ const input = inputRef.value.input+ if (!input) return+ input.select()+}+</script>++<template>+ <a-input+ ref="inputRef"+ v-model:value="vModel"+ class="nc-input-sm nc-input-shadow"+ type="number"+ :min="min"+ :placeholder="placeholder ?? min"+ @blur="onBlur"+ @click="selectText"+ ></a-input>+</template>diff --git a/packages/nocodb-sdk/src/lib/dashboard/index.ts b/packages/nocodb-sdk/src/lib/dashboard/index.tsindex 5f2849fdc7..171541771c 100644--- a/packages/nocodb-sdk/src/lib/dashboard/index.ts+++ b/packages/nocodb-sdk/src/lib/dashboard/index.ts@@ -20,9 +20,9 @@ export interface DashboardType {export enum WidgetTypes {CHART = 'chart',- TABLE = 'table',METRIC = 'metric',TEXT = 'text',+ TABLE = 'table',IFRAME = 'iframe',}@@ -71,9 +71,35 @@ export interface MetricWidgetConfig {};}+export enum TextWidgetTypes {+ H1 = 'H1',+ H2 = 'H2',+ H3 = 'H3',+ H4 = 'H4',+ H5 = 'H5',+ H6 = 'H6',+}+export interface TextWidgetConfig {content: string;- format: 'markdown' | 'html' | 'plain';+ type: TextWidgetTypes;+ formatting: {+ horizontalAlign: 'flex-start' | 'center' | 'flex-end';+ verticalAlign: 'flex-start' | 'center' | 'flex-end';+ bold: boolean;+ italic: boolean;+ underline: boolean;+ strikethrough: boolean;+ };+ appearance: {+ font: {+ family: string;+ weight: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;+ size: number;+ lineHeight: number;+ };+ color: string;+ };}export interface IframeWidgetConfig {diff --git a/packages/nocodb-sdk/src/lib/dashboard/widgetUtils.ts b/packages/nocodb-sdk/src/lib/dashboard/widgetUtils.tsindex 5d1cde7fa1..d8ed922e7a 100644--- a/packages/nocodb-sdk/src/lib/dashboard/widgetUtils.ts+++ b/packages/nocodb-sdk/src/lib/dashboard/widgetUtils.ts@@ -1,4 +1,10 @@-import { ChartTypes, WidgetDataSourceTypes, WidgetType, WidgetTypes } from '.';+import {+ ChartTypes,+ TextWidgetTypes,+ WidgetDataSourceTypes,+ WidgetType,+ WidgetTypes,+} from '.';import { ColumnType, UITypes } from '~/lib';export const calculateNextPosition = (@@ -86,6 +92,28 @@ const getDefaultConfig = (case WidgetTypes.CHART:return getDefaultChartConfig(chartType, columns);+ case WidgetTypes.TEXT:+ return {+ content: 'Enter text here',+ type: TextWidgetTypes.H1,+ formatting: {+ horizontalAlign: 'flex-start',+ verticalAlign: 'flex-start',+ bold: false,+ italic: false,+ underline: false,+ strikethrough: false,+ },+ appearance: {+ font: {+ family: 'Arial',+ weight: 400,+ size: 16,+ lineHeight: 1,+ },+ color: '#000000',+ },+ };default:return {};