π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
refactor: replace all NComponets to NcComponents
DarkPhoenix2704c078d5731e1c
diff --git a/packages/nc-gui/components/n/Select/Aggregation.vue b/packages/nc-gui/components/n/Select/Aggregation.vuedeleted file mode 100644index 714b09e27e..0000000000--- a/packages/nc-gui/components/n/Select/Aggregation.vue+++ /dev/null@@ -1,90 +0,0 @@-<script setup lang="ts">-import { CommonAggregations, UITypes, getAvailableAggregations } from 'nocodb-sdk'-import type { ColumnType } from 'nocodb-sdk'-import type { NSelectProps } from './types'-const props = withDefaults(- defineProps<NSelectProps & { tableId?: string; columnId?: string; filterOption?: (t: string) => boolean }>(),- {- placeholder: '- select aggregation -',- },-)--const emit = defineEmits<{- 'update:modelValue': [value: string]- 'change': [value: string]-}>()--const { getMeta } = useMetas()--const column = ref<ColumnType | null>(null)-const availableAggregations = ref<string[]>([])-const isLoading = ref(false)--const selectedAggregation = computed({- get: () => props.modelValue || CommonAggregations.None,- set: (value) => {- emit('update:modelValue', value)- emit('change', value)- },-})--async function fetchColumnMetadata() {- if (!props.tableId || !props.columnId) return-- try {- isLoading.value = true-- const tableMeta = await getMeta(props.tableId)- if (!tableMeta) {- console.error('Failed to fetch table metadata')- return- }-- const columnMeta = tableMeta.columns?.find((col) => col.id === props.columnId)- if (!columnMeta) {- return- }-- column.value = columnMeta-- if (columnMeta.uidt === UITypes.Formula && columnMeta.colOptions?.parsed_tree) {- availableAggregations.value = getAvailableAggregations(columnMeta.uidt, columnMeta.colOptions.parsed_tree)- } else {- availableAggregations.value = getAvailableAggregations(columnMeta.uidt)- }- } catch (error) {- console.error('Error fetching column metadata:', error)- } finally {- isLoading.value = false- availableAggregations.value = availableAggregations.value.filter((agg) => agg !== CommonAggregations.None)- if (props.filterOption) {- availableAggregations.value = availableAggregations.value.filter(props.filterOption)- }- }-}--watchEffect(() => {- fetchColumnMetadata()-})--defineExpose({- availableAggregations,-})-</script>--<template>- <a-select- v-model:value="selectedAggregation"- class="nc-select-shadow"- :loading="isLoading"- :disabled="isLoading || !availableAggregations.length"- :placeholder="props.placeholder || '- select aggregation -'"- >- <template #suffixIcon>- <GeneralIcon icon="arrowDown" class="text-gray-700" />- </template>- <a-select-option v-for="agg in availableAggregations" :key="agg" :value="agg">- {{ $t(`aggregation_type.${agg}`) }}- </a-select-option>- </a-select>-</template>diff --git a/packages/nc-gui/components/n/Select/Field.vue b/packages/nc-gui/components/n/Select/Field.vuedeleted file mode 100644index c2712ab3ec..0000000000--- a/packages/nc-gui/components/n/Select/Field.vue+++ /dev/null@@ -1,59 +0,0 @@-<script setup lang="ts">-import { type ColumnType, isSystemColumn } from 'nocodb-sdk'-import type { NSelectProps } from './types'-const props = withDefaults(- defineProps<NSelectProps & { tableId?: string; forceLoadTableFields?: boolean; filterColumn?: (t: ColumnType) => boolean }>(),- {- placeholder: '- select field -',- forceLoadTableFields: false,- },-)-const modelValue = useVModel(props, 'modelValue')-const tableStore = useTablesStore()-const { loadTableMeta } = useTablesStore()-const { activeTable } = storeToRefs(tableStore)--const fieldsRef = computedAsync<ColumnType[]>(async () => {- let fields: ColumnType[]- if (props.tableId) {- fields = (await loadTableMeta(props.tableId))?.columns || []- } else {- fields = activeTable.value.columns- }- if (props.filterColumn) {- return fields.filter(props.filterColumn)- }-- fields = fields.filter((f) => !isSystemColumn(f) || f.pk)-- return fields-})-defineExpose({- fieldsRef,-})-</script>--<template>- <a-select v-bind="props" v-model="modelValue" class="nc-select-shadow">- <template #suffixIcon>- <GeneralIcon icon="arrowDown" class="text-gray-700" />- </template>- <a-select-option v-for="field of fieldsRef" :key="field.id" :value="field.id">- <div class="w-full flex items-center gap-2">- <div class="min-w-5 flex items-center justify-center">- <NIconField :field="field" class="text-gray-500" />- </div>- <NcTooltip class="flex-1 truncate" show-on-truncate-only>- <template #title>{{ field.title }}</template>- <span>{{ field.title }}</span>- </NcTooltip>- <component- :is="iconMap.check"- v-if="modelValue === field.id"- id="nc-selected-item-icon"- class="flex-none text-primary w-4 h-4"- />- </div>- </a-select-option>- </a-select>-</template>diff --git a/packages/nc-gui/components/n/Select/Table.vue b/packages/nc-gui/components/n/Select/Table.vuedeleted file mode 100644index f79bd51bff..0000000000--- a/packages/nc-gui/components/n/Select/Table.vue+++ /dev/null@@ -1,55 +0,0 @@-<script setup lang="ts">-import type { TableType } from 'nocodb-sdk'-import type { NSelectProps } from './types'-const props = withDefaults(- defineProps<NSelectProps & { baseId?: string; forceLoadBaseTables?: boolean; filterTable?: (t: TableType) => boolean }>(),- {- placeholder: '- select table -',- forceLoadBaseTables: false,- },-)-const modelValue = useVModel(props, 'modelValue')-const tableStore = useTablesStore()-const { activeTables, baseTables } = storeToRefs(tableStore)-const tablesRef = computedAsync<TableType[]>(async () => {- let tables: TableType[]- if (props.baseId) {- await tableStore.loadProjectTables(props.baseId, props.forceLoadBaseTables)- tables = baseTables.value.get(props.baseId)- } else {- tables = activeTables.value- }- if (props.filterTable) {- tables = tables.filter(props.filterTable)- }- return tables-})-defineExpose({- tablesRef,-})-</script>--<template>- <a-select v-bind="props" v-model="modelValue" class="nc-select-shadow">- <template #suffixIcon>- <GeneralIcon icon="arrowDown" class="text-gray-700" />- </template>- <a-select-option v-for="table of tablesRef" :key="table.id" :value="table.id">- <div class="w-full flex items-center gap-2">- <div class="min-w-5 flex items-center justify-center">- <NIconTable :table="table" class="text-gray-500" />- </div>- <NcTooltip class="flex-1 truncate" show-on-truncate-only>- <template #title>{{ table.title }}</template>- <span>{{ table.title }}</span>- </NcTooltip>- <component- :is="iconMap.check"- v-if="modelValue === table.id"- id="nc-selected-item-icon"- class="flex-none text-primary w-4 h-4"- />- </div>- </a-select-option>- </a-select>-</template>diff --git a/packages/nc-gui/components/n/Select/View.vue b/packages/nc-gui/components/n/Select/View.vuedeleted file mode 100644index f36db31288..0000000000--- a/packages/nc-gui/components/n/Select/View.vue+++ /dev/null@@ -1,74 +0,0 @@-<script setup lang="ts">-import type { ViewType } from 'nocodb-sdk'-import type { NSelectProps } from './types'-const props = withDefaults(- defineProps<- NSelectProps & {- tableId?: string- ignoreLoading?: boolean- forceFetchViews?: boolean- filterView?: (v: ViewType) => boolean- labelDefaultViewAsDefault?: boolean- }- >(),- {- placeholder: '- select view -',- ignoreLoading: false,- forceLoadBaseTables: false,- labelDefaultViewAsDefault: false,- },-)-const NSelectComponent = ref()-const modelValue = useVModel(props, 'modelValue')-const viewsStore = useViewsStore()-const { viewsByTable } = storeToRefs(viewsStore)-const viewsRef = shallowRef<ViewType[]>([])-watch(- () => [props.tableId, props.ignoreLoading, props.forceFetchViews],- async () => {- try {- await viewsStore.loadViews({ tableId: props.tableId, ignoreLoading: props.ignoreLoading, force: props.forceFetchViews })- } catch (e) {- console.error(e)- }-- let viewsList: ViewType[] = viewsByTable.value.get(props.tableId) || []- if (props.labelDefaultViewAsDefault) {- viewsList = viewsList.map((v) => ({ ...v, title: v.is_default ? 'Default View' : v.title }))- }- if (props.filterView) {- viewsList = viewsList.filter(props.filterView)- }- viewsRef.value = viewsList- },- { immediate: true },-)-defineExpose({- viewsRef,-})-</script>--<template>- <a-select v-bind="props" ref="NSelectComponent" v-model="modelValue" class="nc-select-shadow">- <template #suffixIcon>- <GeneralIcon icon="arrowDown" class="text-gray-700" />- </template>- <a-select-option v-for="view of viewsRef" :key="view.id" :value="view.id">- <div class="w-full flex items-center gap-2">- <div class="min-w-5 flex items-center justify-center">- <NIconView :view="view" class="text-gray-500" />- </div>- <NcTooltip class="flex-1 truncate" show-on-truncate-only>- <template #title>{{ view.title }}</template>- <span>{{ view.title }}</span>- </NcTooltip>- <component- :is="iconMap.check"- v-if="modelValue === view.id"- id="nc-selected-item-icon"- class="flex-none text-primary w-4 h-4"- />- </div>- </a-select-option>- </a-select>-</template>diff --git a/packages/nc-gui/components/n/Select/index.vue b/packages/nc-gui/components/n/Select/index.vuedeleted file mode 100644index d9648742dd..0000000000--- a/packages/nc-gui/components/n/Select/index.vue+++ /dev/null@@ -1,132 +0,0 @@-<script lang="ts" setup>-import type { SelectValue } from 'ant-design-vue/lib/select'-import type { NSelectProps } from './types'-const props = withDefaults(defineProps<NSelectProps>(), {- placeholder: '- select -',- showSearch: false,- suffixIcon: 'arrowDown',- disabled: false,-})-const emits = defineEmits<{- 'update:modelValue': [string | string[]]- 'change': [SelectValue]-}>()-const selectedValue = useVModel(props, 'modelValue', emits)-const { showSearch, dropdownMatchSelectWidth, loading, mode, placeholder } = toRefs(props)-const onChange = (value: SelectValue) => {- emits('change', value)-}-const selectValue = (value: SelectValue) => {- selectedValue.value = value- onChange(value)-}-defineExpose({- selectValue,-})-</script>--<template>- <a-select- v-model:value="selectedValue"- :size="size"- :allow-clear="allowClear"- :disabled="disabled || loading"- :dropdown-class-name="`nc-select-dropdown ${dropdownClassOverride}`"- :dropdown-match-select-width="dropdownMatchSelectWidth"- :filter-option="filterOption"- :loading="loading"- :mode="mode"- :placeholder="placeholder"- :show-search="showSearch"- :options="options"- class="nc-select"- @change="onChange"- >- <template #suffixIcon>- <GeneralLoader v-if="loading" />- <GeneralIcon v-else class="text-gray-800 nc-select-expand-btn" :icon="suffixIcon" />- </template>-- <template v-if="$slots.dropdownRender" #dropdownRender="options">- <slot name="dropdownRender" v-bind="options" />- </template>-- <template v-if="$slots.option" #option="option">- <slot name="option" v-bind="option" />- </template>-- <slot />- </a-select>-</template>--<style lang="scss">-.ant-select-item {- @apply !xs:h-13 !min-h-[2.375rem] !p-2;-}-.ant-select-item-option-content {- @apply !xs:mt-2.5;-}-.ant-select-item-option-state {- @apply !xs:mt-1.75;-}-.ant-select-item-option {- @apply !rounded-md;-}-.nc-select.ant-select {- height: fit-content;- .ant-select-selector {- box-shadow: 0px 5px 3px -2px rgba(0, 0, 0, 0.02), 0px 3px 1px -2px rgba(0, 0, 0, 0.06);- @apply border-1 border-gray-200 rounded-lg shadow-default;- }- .ant-select-selection-item {- @apply font-medium pr-3 rounded-md flex items-center;- }- .ant-select-selection-placeholder {- @apply text-gray-600;- }- .ant-select-selection-item-remove {- @apply text-gray-800 !pb-1;- }- .ant-select-clear {- @apply flex;- svg {- @apply flex-none;- }- }-}-.nc-select.ant-select-focused:not(.ant-select-disabled).ant-select:not(.ant-select-customize-input) .ant-select-selector {- box-shadow: none;- @apply border-brand-500;-}-.nc-select.ant-select.ant-select-disabled .nc-select-expand-btn {- @apply text-gray-300;-}-.nc-select-dropdown {- @apply !rounded-lg py-1.5;- .rc-virtual-list-holder {- overflow-y: auto;- overflow-x: hidden;- font-weight: 500;- .ant-select-item-option-content {- font-weight: 500;- }- &::-webkit-scrollbar {- width: 4px;- height: 4px;- }- &::-webkit-scrollbar-track-piece {- width: 0px;- }- &::-webkit-scrollbar {- @apply bg-transparent;- }- &::-webkit-scrollbar-thumb {- width: 4px;- @apply bg-gray-300 rounded-md;- }- &::-webkit-scrollbar-thumb:hover {- @apply bg-gray-400;- }- }-}-</style>diff --git a/packages/nc-gui/components/n/Select/types.d.ts b/packages/nc-gui/components/n/Select/types.d.tsdeleted file mode 100644index a9f57ea20b..0000000000--- a/packages/nc-gui/components/n/Select/types.d.ts+++ /dev/null@@ -1,27 +0,0 @@-import type { DefaultOptionType } from 'ant-design-vue/lib/vc-select/Select'-import type { SelectValue } from 'ant-design-vue/lib/select'--export type NSelectMode = 'multiple' | 'tags'-export type NSelectSize = 'small' | 'middle' | 'large'-export type NSelectOption = DefaultOptionType--export interface NSelectProps {- modelValue?: SelectValue- placeholder?: string- mode?: NSelectMode- size?: NSelectSize-- options?: NSelectOption[]-- showSearch?: boolean- allowClear?: boolean- loading?: boolean- disabled?: boolean- suffixIcon?: IconMapKey-- filterOption?: (input: string, option: any) => boolean-- /** Dropdown Params */- dropdownClassOverride?: string- dropdownMatchSelectWidth?: boolean-}diff --git a/packages/nc-gui/components/n/Icon/Field.vue b/packages/nc-gui/components/nc/Icon/Field.vuesimilarity index 100%rename from packages/nc-gui/components/n/Icon/Field.vuerename to packages/nc-gui/components/nc/Icon/Field.vuediff --git a/packages/nc-gui/components/n/Icon/Table.vue b/packages/nc-gui/components/nc/Icon/Table.vuesimilarity index 100%rename from packages/nc-gui/components/n/Icon/Table.vuerename to packages/nc-gui/components/nc/Icon/Table.vuediff --git a/packages/nc-gui/components/n/Icon/View.vue b/packages/nc-gui/components/nc/Icon/View.vuesimilarity index 100%rename from packages/nc-gui/components/n/Icon/View.vuerename to packages/nc-gui/components/nc/Icon/View.vuediff --git a/packages/nc-gui/components/nc/List/AggregationSelector.vue b/packages/nc-gui/components/nc/List/AggregationSelector.vueindex 48d71e3275..154d734ccc 100644--- a/packages/nc-gui/components/nc/List/AggregationSelector.vue+++ b/packages/nc-gui/components/nc/List/AggregationSelector.vue@@ -198,7 +198,7 @@ defineExpose({:value="modelValue || selectedAggregation?.value || ''":list="aggregationList"variant="medium"- class="!w-auto !max-w-xs"+ class="!w-auto"wrapper-class-name="!h-auto"@update:value="handleValueUpdate"@escape="onEsc"diff --git a/packages/nc-gui/components/nc/List/ColumnSelector.vue b/packages/nc-gui/components/nc/List/ColumnSelector.vueindex 2586f5273e..2ed3def283 100644--- a/packages/nc-gui/components/nc/List/ColumnSelector.vue+++ b/packages/nc-gui/components/nc/List/ColumnSelector.vue@@ -151,7 +151,7 @@ defineExpose({><div class="flex-1 flex items-center gap-2 min-w-0"><div v-if="selectedColumn" class="min-w-5 flex items-center justify-center">- <NIconField :field="selectedColumn" class="text-gray-500" />+ <NcIconField :field="selectedColumn" class="text-gray-500" /></div><NcTooltip hide-on-click class="flex-1 truncate" show-on-truncate-only><span v-if="selectedColumn" class="text-sm flex-1 truncate text-nc-content-gray-default">@@ -176,7 +176,7 @@ defineExpose({:value="modelValue || selectedColumn?.value || ''":list="columnList"variant="medium"- class="!w-auto !max-w-xs"+ class="!w-auto"wrapper-class-name="!h-auto"@update:value="handleValueUpdate"@escape="onEsc"@@ -184,7 +184,7 @@ defineExpose({<template #item="{ item }"><div class="w-full flex items-center gap-2"><div class="min-w-5 flex items-center justify-center">- <NIconField :field="item" class="text-gray-500" />+ <NcIconField :field="item" class="text-gray-500" /></div><NcTooltip class="flex-1 truncate" show-on-truncate-only><template #title>{{ item.label }}</template>diff --git a/packages/nc-gui/components/nc/List/TableSelector.vue b/packages/nc-gui/components/nc/List/TableSelector.vueindex 61a3a20bb7..9ca430ac8c 100644--- a/packages/nc-gui/components/nc/List/TableSelector.vue+++ b/packages/nc-gui/components/nc/List/TableSelector.vue@@ -145,7 +145,7 @@ defineExpose({><div class="flex-1 flex items-center gap-2 min-w-0"><div v-if="selectedTable" class="min-w-5 flex items-center justify-center">- <NIconTable :table="selectedTable || { title: '', table_name: '' }" class="text-gray-500" />+ <NcIconTable :table="selectedTable || { title: '', table_name: '' }" class="text-gray-500" /></div><NcTooltip hide-on-click class="flex-1 truncate" show-on-truncate-only><span@@ -175,7 +175,7 @@ defineExpose({:value="modelValue || selectedTable?.value || ''":list="tableList"variant="medium"- class="!w-auto !max-w-xs"+ class="!w-auto"wrapper-class-name="!h-auto"@update:value="handleValueUpdate"@escape="onEsc"@@ -183,7 +183,7 @@ defineExpose({<template #item="{ item }"><div class="w-full flex items-center gap-2"><div class="min-w-5 flex items-center justify-center">- <NIconTable :table="item" class="text-gray-500" />+ <NcIconTable :table="item" class="text-gray-500" /></div><NcTooltip class="flex-1 truncate" show-on-truncate-only><template #title>{{ item.label }}</template>diff --git a/packages/nc-gui/components/nc/List/ViewSelector.vue b/packages/nc-gui/components/nc/List/ViewSelector.vueindex 091ba289af..7d2e668955 100644--- a/packages/nc-gui/components/nc/List/ViewSelector.vue+++ b/packages/nc-gui/components/nc/List/ViewSelector.vue@@ -87,7 +87,9 @@ const viewListMap = computed(() => {const selectedView = computed(() => {if (!viewListMap.value || viewListMap.value.size === 0) return undefined- return viewListMap.value.get(modelValue.value) || viewList.value?.[0]+ if (!modelValue.value) return undefined++ return viewListMap.value.get(modelValue.value)})watch(@@ -158,7 +160,7 @@ defineExpose({><div class="flex-1 flex items-center gap-2 min-w-0"><div v-if="selectedView" class="min-w-5 flex items-center justify-center">- <NIconView :view="selectedView" class="text-gray-500" />+ <NcIconView :view="selectedView" class="text-gray-500" /></div><NcTooltip hide-on-click class="flex-1 truncate" show-on-truncate-only><span@@ -188,7 +190,7 @@ defineExpose({:value="modelValue || selectedView?.value || ''":list="viewList"variant="medium"- class="!w-auto !max-w-xs"+ class="!w-auto"wrapper-class-name="!h-auto"@update:value="handleValueUpdate"@escape="onEsc"@@ -196,7 +198,7 @@ defineExpose({<template #item="{ item }"><div class="w-full flex items-center gap-2"><div class="min-w-5 flex items-center justify-center">- <NIconView :view="item" class="text-gray-500" />+ <NcIconView :view="item" class="text-gray-500" /></div><NcTooltip class="flex-1 overflow-hidden whitespace-nowrap text-ellipsis" show-on-truncate-only><template #title>{{ item.label }}</template>