Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

refactor: replace select components with new list-based selectors for tables, views, columns and aggregations

DarkPhoenix2704d6016a02521e
diff --git a/packages/nc-gui/components/nc/List/AggregationSelector.vue b/packages/nc-gui/components/nc/List/AggregationSelector.vue
new file mode 100644
index 0000000000..ad64f89fd4
--- /dev/null
+++ b/packages/nc-gui/components/nc/List/AggregationSelector.vue
@@ -0,0 +1,218 @@
+<script setup lang="ts">
+import { CommonAggregations, UITypes, getAvailableAggregations } from 'nocodb-sdk'
+import type { ColumnType } from 'nocodb-sdk'
+
+interface Props {
+ tableId?: string
+ columnId?: string
+ value?: string
+ showAggregationSelector?: boolean
+ forceLayout?: 'vertical' | 'horizontal'
+ filterAggregation?: (aggregation: string) => boolean
+ forceLoadColumnMeta?: boolean
+ disableLabel?: boolean
+}
+
+const props = withDefaults(defineProps<Props>(), {
+ showAggregationSelector: true,
+ forceLoadColumnMeta: false,
+ disableLabel: false,
+})
+
+const emit = defineEmits<{
+ 'update:value': [value: string | undefined]
+}>()
+
+const { t } = useI18n()
+
+const { getMeta } = useMetas()
+
+const modelValue = useVModel(props, 'value', emit)
+
+const isOpenAggregationSelectDropdown = ref(false)
+
+const handleValueUpdate = (value: any) => {
+ const stringValue = String(value)
+ modelValue.value = stringValue
+ emit('update:value', stringValue)
+}
+
+const column = ref<ColumnType | null>(null)
+const isLoading = ref(false)
+
+const aggregationList = computedAsync(async () => {
+ 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
+
+ let availableAggregations: string[]
+ if (columnMeta.uidt === UITypes.Formula && columnMeta.colOptions?.parsed_tree) {
+ availableAggregations = getAvailableAggregations(columnMeta.uidt, columnMeta.colOptions.parsed_tree)
+ } else {
+ availableAggregations = getAvailableAggregations(columnMeta.uidt)
+ }
+
+ // Filter out None aggregation
+ availableAggregations = availableAggregations.filter((agg) => agg !== CommonAggregations.None)
+
+ // Apply custom filter if provided
+ if (props.filterAggregation) {
+ availableAggregations = availableAggregations.filter(props.filterAggregation)
+ }
+
+ return availableAggregations.map((agg) => {
+ return {
+ label: t(`aggregation_type.${agg}`),
+ value: agg,
+ ncItemDisabled: false,
+ ncItemTooltip: '',
+ }
+ })
+ } catch (error) {
+ console.error('Error fetching column metadata:', error)
+ return []
+ } finally {
+ isLoading.value = false
+ }
+}, [])
+
+const selectedAggregation = computed(() => {
+ if (!aggregationList.value || aggregationList.value.length === 0) return undefined
+
+ return aggregationList.value.find((agg) => agg.value === modelValue.value) || aggregationList.value[0]
+})
+
+watch(aggregationList, (newAggregationList) => {
+ if (!modelValue.value && newAggregationList && newAggregationList.length > 0) {
+ const newAggregationValue = newAggregationList[0]?.value
+
+ modelValue.value = newAggregationValue
+ }
+}, { immediate: true })
+
+defineExpose({
+ modelValue,
+ selectedAggregation,
+ isOpenAggregationSelectDropdown,
+ aggregationList,
+})
+</script>
+
+<template>
+ <a-form-item
+ name="aggregationId"
+ class="!mb-0 nc-aggregation-selector"
+ :class="`nc-force-layout-${forceLayout}`"
+ :validate-status="selectedAggregation?.ncItemDisabled ? 'error' : ''"
+ :help="selectedAggregation?.ncItemDisabled ? [selectedAggregation.ncItemTooltip] : []"
+ @click.stop
+ @dblclick.stop
+ >
+ <template v-if="!disableLabel" #label>
+ <div>{{ t('general.aggregation') }}</div>
+ </template>
+ <NcListDropdown
+ v-model:is-open="isOpenAggregationSelectDropdown"
+ :disabled="!showAggregationSelector || isLoading"
+ :default-slot-wrapper-class="
+ !showAggregationSelector || isLoading
+ ? 'text-nc-content-gray-muted cursor-not-allowed bg-nc-bg-gray-light children:opacity-60'
+ : 'text-nc-content-gray'
+ "
+ :has-error="!!selectedAggregation?.ncItemDisabled"
+ >
+ <div class="flex-1 flex items-center gap-2 min-w-0">
+ <span :key="selectedAggregation?.value" class="text-sm flex-1 truncate">{{ selectedAggregation?.label || t('general.aggregation') }}</span>
+
+ <GeneralIcon
+ icon="ncChevronDown"
+ class="flex-none h-4 w-4 transition-transform opacity-70"
+ :class="{ 'transform rotate-180': isOpenAggregationSelectDropdown }"
+ />
+ </div>
+ <template #overlay="{ onEsc }">
+ <NcList
+ v-model:open="isOpenAggregationSelectDropdown"
+ :value="modelValue || selectedAggregation?.value || ''"
+ :list="aggregationList"
+ variant="medium"
+ class="!w-auto !max-w-xs"
+ wrapper-class-name="!h-auto"
+ @update:value="handleValueUpdate"
+ @escape="onEsc"
+ >
+ <template #item="{ item }">
+ <div class="w-full flex items-center gap-2">
+ <NcTooltip class="flex-1 truncate" show-on-truncate-only>
+ <template #title>{{ item.label }}</template>
+ <span>{{ item.label }}</span>
+ </NcTooltip>
+ <component
+ :is="iconMap.check"
+ v-if="modelValue === item.value"
+ id="nc-selected-item-icon"
+ class="flex-none text-primary w-4 h-4"
+ />
+ </div>
+ </template>
+ </NcList>
+ </template>
+ </NcListDropdown>
+ </a-form-item>
+</template>
+
+<style lang="scss">
+.nc-aggregation-selector.ant-form-item {
+ &.nc-force-layout-vertical {
+ @apply !flex-col;
+
+ & > .ant-form-item-label {
+ @apply pb-2 text-left;
+
+ &::after {
+ @apply hidden;
+ }
+
+ & > label {
+ @apply !h-auto;
+ &::after {
+ @apply !hidden;
+ }
+ }
+ }
+ }
+
+ &.nc-force-layout-horizontal {
+ @apply !flex-row;
+
+ & > .ant-form-item-label {
+ @apply !w-auto !min-w-20 !flex-none;
+
+ &::after {
+ @apply hidden;
+ }
+
+ & > label {
+ @apply !h-auto;
+ &::after {
+ @apply !hidden;
+ }
+ }
+ }
+ }
+}
+</style>
diff --git a/packages/nc-gui/components/nc/List/ColumnSelector.vue b/packages/nc-gui/components/nc/List/ColumnSelector.vue
new file mode 100644
index 0000000000..4f41a8675e
--- /dev/null
+++ b/packages/nc-gui/components/nc/List/ColumnSelector.vue
@@ -0,0 +1,207 @@
+<script lang="ts" setup>
+import { type ColumnType, isSystemColumn } from 'nocodb-sdk'
+
+interface Props {
+ tableId?: string
+ columnId?: string
+ value?: string
+ showColumnSelector?: boolean
+ forceLayout?: 'vertical' | 'horizontal'
+ filterColumn?: (column: ColumnType) => boolean
+ forceLoadTableFields?: boolean
+ disableLabel?: boolean
+}
+
+const props = withDefaults(defineProps<Props>(), {
+ showColumnSelector: true,
+ forceLoadTableFields: false,
+ disableLabel: false,
+})
+
+const emit = defineEmits<{
+ 'update:value': [value: string | undefined]
+}>()
+
+const { t } = useI18n()
+
+const tableStore = useTablesStore()
+const { loadTableMeta } = useTablesStore()
+const { activeTable } = storeToRefs(tableStore)
+
+const modelValue = useVModel(props, 'value', emit)
+
+const isOpenColumnSelectDropdown = ref(false)
+
+const handleValueUpdate = (value: any) => {
+ const stringValue = String(value)
+ modelValue.value = stringValue
+ emit('update:value', stringValue)
+}
+
+const columnList = computedAsync(async () => {
+ let fields: ColumnType[]
+
+ if (props.tableId) {
+ const tableMeta = await loadTableMeta(props.tableId)
+ fields = tableMeta?.columns || []
+ } else {
+ fields = activeTable.value?.columns || []
+ }
+
+ if (props.filterColumn) {
+ fields = fields.filter(props.filterColumn)
+ } else {
+ fields = fields.filter((f) => !isSystemColumn(f) || f.pk)
+ }
+
+ return fields.map((column) => {
+ const isDisabled = Boolean(column.system && !column.pk)
+
+ const ncItemTooltip = isDisabled
+ ? t('tooltip.systemColumnNotEditable')
+ : ''
+
+ return {
+ label: column.title || column.column_name,
+ value: column.id,
+ ncItemDisabled: isDisabled,
+ ncItemTooltip,
+ ...column,
+ }
+ })
+})
+
+const selectedColumn = computed(() => {
+ if (!columnList.value || columnList.value.length === 0) return undefined
+
+ return columnList.value.find((column) => column.value === modelValue.value) || columnList.value[0]
+})
+
+// Watch for columnList changes and set initial value
+watch(columnList, (newColumnList) => {
+ if (!modelValue.value && newColumnList && newColumnList.length > 0) {
+ const newColumnId = props.columnId || newColumnList[0]?.value
+
+ const columnObj = newColumnList.find((column) => column.value === newColumnId)
+
+ // Change column id only if it is default column selected initially and its not enabled
+ if (columnObj && columnObj.ncItemDisabled && columnObj.value === newColumnList[0]?.value) {
+ modelValue.value = newColumnList.find((column) => !column.ncItemDisabled)?.value || newColumnList[0]?.value
+ } else {
+ modelValue.value = newColumnId
+ }
+ }
+}, { immediate: true })
+
+defineExpose({
+ modelValue,
+ selectedColumn,
+ isOpenColumnSelectDropdown,
+ columnList,
+})
+</script>
+
+<template>
+ <a-form-item
+ v-if="selectedColumn"
+ name="columnId"
+ class="!mb-0 nc-column-selector"
+ :class="`nc-force-layout-${forceLayout}`"
+ :validate-status="selectedColumn?.ncItemDisabled ? 'error' : ''"
+ :help="selectedColumn?.ncItemDisabled ? [selectedColumn.ncItemTooltip] : []"
+ @click.stop
+ @dblclick.stop
+ >
+ <template v-if="!disableLabel" #label>
+ <div>{{ t('general.column') }}</div>
+ </template>
+ <NcListDropdown
+ v-model:is-open="isOpenColumnSelectDropdown"
+ :disabled="!showColumnSelector"
+ :default-slot-wrapper-class="
+ !showColumnSelector
+ ? 'text-nc-content-gray-muted cursor-not-allowed bg-nc-bg-gray-light children:opacity-60'
+ : 'text-nc-content-gray'
+ "
+ :has-error="!!selectedColumn?.ncItemDisabled"
+ >
+ <div class="flex-1 flex items-center gap-2 min-w-0">
+ <div class="min-w-5 flex items-center justify-center">
+ <NIconField :field="selectedColumn" class="text-gray-500" />
+ </div>
+ <span class="text-sm flex-1 truncate">{{ selectedColumn?.label || t('general.column') }}</span>
+
+ <GeneralIcon
+ icon="ncChevronDown"
+ class="flex-none h-4 w-4 transition-transform opacity-70"
+ :class="{ 'transform rotate-180': isOpenColumnSelectDropdown }"
+ />
+ </div>
+ <template #overlay="{ onEsc }">
+ <NcList
+ v-model:open="isOpenColumnSelectDropdown"
+ :value="modelValue || selectedColumn?.value || ''"
+ :list="columnList"
+ variant="medium"
+ class="!w-auto !max-w-xs"
+ wrapper-class-name="!h-auto"
+ @update:value="handleValueUpdate"
+ @escape="onEsc"
+ >
+ <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" />
+ </div>
+ <NcTooltip class="flex-1 truncate" show-on-truncate-only>
+ <template #title>{{ item.label }}</template>
+ <span>{{ item.label }}</span>
+ </NcTooltip>
+ <component
+ :is="iconMap.check"
+ v-if="modelValue === item.value"
+ id="nc-selected-item-icon"
+ class="flex-none text-primary w-4 h-4"
+ />
+ </div>
+ </template>
+ </NcList>
+ </template>
+ </NcListDropdown>
+ </a-form-item>
+</template>
+
+<style lang="scss">
+.nc-column-selector.ant-form-item {
+ &.nc-force-layout-vertical {
+ @apply !flex-col;
+
+ & > .ant-form-item-label {
+ @apply pb-2 text-left;
+
+ &::after {
+ @apply hidden;
+ }
+
+ & > label {
+ @apply !h-auto;
+ &::after {
+ @apply !hidden;
+ }
+ }
+ }
+ }
+
+ &.nc-force-layout-horizontal {
+ @apply !flex-row !items-center;
+
+ & > .ant-form-item-label {
+ @apply pb-0 items-center;
+
+ &::after {
+ @apply content-[':'] !mr-2 !ml-0.5 relative top-[0.5px];
+ }
+ }
+ }
+}
+</style>
diff --git a/packages/nc-gui/components/nc/List/TableSelector.vue b/packages/nc-gui/components/nc/List/TableSelector.vue
new file mode 100644
index 0000000000..4c28c9ecba
--- /dev/null
+++ b/packages/nc-gui/components/nc/List/TableSelector.vue
@@ -0,0 +1,199 @@
+<script lang="ts" setup>
+import type { TableType } from 'nocodb-sdk'
+
+interface Props {
+ baseId?: string
+ tableId?: string
+ value?: string
+ showTableSelector?: boolean
+ forceLayout?: 'vertical' | 'horizontal'
+ filterTable?: (table: TableType) => boolean
+ forceLoadBaseTables?: boolean
+ disableLabel?: boolean
+}
+
+const props = withDefaults(defineProps<Props>(), {
+ showTableSelector: true,
+ forceLoadBaseTables: false,
+ disableLabel: false,
+})
+
+const emit = defineEmits<{
+ 'update:value': [value: string | undefined]
+}>()
+
+const { t } = useI18n()
+
+const tableStore = useTablesStore()
+
+const { activeTables, baseTables } = storeToRefs(tableStore)
+
+const modelValue = useVModel(props, 'value', emit)
+
+const isOpenTableSelectDropdown = ref(false)
+
+const handleValueUpdate = (value: any) => {
+ const stringValue = String(value)
+ modelValue.value = stringValue
+ emit('update:value', stringValue)
+}
+
+const tableList = computedAsync(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.map((table) => {
+ const ncItemTooltip = ''
+
+ return {
+ label: table.title || table.table_name,
+ value: table.id,
+ ncItemDisabled: false,
+ ncItemTooltip,
+ ...table,
+ }
+ })
+})
+
+const selectedTable = computed(() => {
+ if (!tableList.value || tableList.value.length === 0) return undefined
+
+ return tableList.value.find((table) => table.value === modelValue.value) || tableList.value[0]
+})
+
+watch(tableList, (newTableList) => {
+ if (!modelValue.value && newTableList && newTableList.length > 0) {
+ const newTableId = props.tableId || newTableList[0]?.value
+
+ const tableObj = newTableList.find((table) => table.value === newTableId)
+
+ if (tableObj && tableObj.ncItemDisabled && tableObj.value === newTableList[0]?.value) {
+ modelValue.value = newTableList.find((table) => !table.ncItemDisabled)?.value || newTableList[0]?.value
+ } else {
+ modelValue.value = newTableId
+ }
+ }
+}, { immediate: true })
+
+defineExpose({
+ modelValue,
+ selectedTable,
+ isOpenTableSelectDropdown,
+ tableList,
+})
+</script>
+
+<template>
+ <a-form-item
+ v-if="selectedTable"
+ name="tableId"
+ class="!mb-0 nc-table-selector"
+ :class="`nc-force-layout-${forceLayout}`"
+ :validate-status="selectedTable?.ncItemDisabled ? 'error' : ''"
+ :help="selectedTable?.ncItemDisabled ? [selectedTable.ncItemTooltip] : []"
+ @click.stop
+ @dblclick.stop
+ >
+ <template v-if="!disableLabel" #label>
+ <div>{{ t('general.table') }}</div>
+ </template>
+ <NcListDropdown
+ v-model:is-open="isOpenTableSelectDropdown"
+ :disabled="!showTableSelector"
+ :default-slot-wrapper-class="
+ !showTableSelector
+ ? 'text-nc-content-gray-muted cursor-not-allowed bg-nc-bg-gray-light children:opacity-60'
+ : 'text-nc-content-gray'
+ "
+ :has-error="!!selectedTable?.ncItemDisabled"
+ >
+ <div class="flex-1 flex items-center gap-2 min-w-0">
+ <div class="min-w-5 flex items-center justify-center">
+ <NIconTable :table="selectedTable" class="text-gray-500" />
+ </div>
+ <span :key="selectedTable?.value" class="text-sm flex-1 truncate">{{ selectedTable?.label || t('general.table') }}</span>
+
+ <GeneralIcon
+ icon="ncChevronDown"
+ class="flex-none h-4 w-4 transition-transform opacity-70"
+ :class="{ 'transform rotate-180': isOpenTableSelectDropdown }"
+ />
+ </div>
+ <template #overlay="{ onEsc }">
+ <NcList
+ v-model:open="isOpenTableSelectDropdown"
+ :value="modelValue || selectedTable?.value || ''"
+ :list="tableList"
+ variant="medium"
+ class="!w-auto !max-w-xs"
+ wrapper-class-name="!h-auto"
+ @update:value="handleValueUpdate"
+ @escape="onEsc"
+ >
+ <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" />
+ </div>
+ <NcTooltip class="flex-1 truncate" show-on-truncate-only>
+ <template #title>{{ item.label }}</template>
+ <span>{{ item.label }}</span>
+ </NcTooltip>
+ <component
+ :is="iconMap.check"
+ v-if="modelValue === item.value"
+ id="nc-selected-item-icon"
+ class="flex-none text-primary w-4 h-4"
+ />
+ </div>
+ </template>
+ </NcList>
+ </template>
+ </NcListDropdown>
+ </a-form-item>
+</template>
+
+<style lang="scss">
+.nc-table-selector.ant-form-item {
+ &.nc-force-layout-vertical {
+ @apply !flex-col;
+
+ & > .ant-form-item-label {
+ @apply pb-2 text-left;
+
+ &::after {
+ @apply hidden;
+ }
+
+ & > label {
+ @apply !h-auto;
+ &::after {
+ @apply !hidden;
+ }
+ }
+ }
+ }
+
+ &.nc-force-layout-horizontal {
+ @apply !flex-row !items-center;
+
+ & > .ant-form-item-label {
+ @apply pb-0 items-center;
+
+ &::after {
+ @apply content-[':'] !mr-2 !ml-0.5 relative top-[0.5px];
+ }
+ }
+ }
+}
+</style>
diff --git a/packages/nc-gui/components/nc/List/ViewSelector.vue b/packages/nc-gui/components/nc/List/ViewSelector.vue
new file mode 100644
index 0000000000..ea4e02f31f
--- /dev/null
+++ b/packages/nc-gui/components/nc/List/ViewSelector.vue
@@ -0,0 +1,212 @@
+<script lang="ts" setup>
+import type { ViewType } from 'nocodb-sdk'
+
+interface Props {
+ tableId?: string
+ viewId?: string
+ value?: string
+ showViewSelector?: boolean
+ forceLayout?: 'vertical' | 'horizontal'
+ filterView?: (view: ViewType) => boolean
+ ignoreLoading?: boolean
+ forceFetchViews?: boolean
+ labelDefaultViewAsDefault?: boolean
+ disableLabel?: boolean
+}
+
+const props = withDefaults(defineProps<Props>(), {
+ showViewSelector: true,
+ ignoreLoading: false,
+ forceFetchViews: false,
+ labelDefaultViewAsDefault: false,
+ disableLabel: false,
+})
+
+const emit = defineEmits<{
+ 'update:value': [value: string | undefined]
+}>()
+
+const { t } = useI18n()
+
+const viewsStore = useViewsStore()
+const { viewsByTable } = storeToRefs(viewsStore)
+
+const modelValue = useVModel(props, 'value', emit)
+
+const isOpenViewSelectDropdown = ref(false)
+
+const handleValueUpdate = (value: any) => {
+ const stringValue = String(value)
+ modelValue.value = stringValue
+ emit('update:value', stringValue)
+}
+
+const viewList = computedAsync(async () => {
+ if (!props.tableId) return []
+
+ try {
+ await viewsStore.loadViews({
+ tableId: props.tableId,
+ ignoreLoading: props.ignoreLoading,
+ force: props.forceFetchViews
+ })
+ } catch (e) {
+ console.error(e)
+ return []
+ }
+
+ 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)
+ }
+ return viewsList.map((view) => {
+ const ncItemTooltip = ''
+
+ return {
+ label: view.title || view.id,
+ value: view.id,
+ ncItemDisabled: false,
+ ncItemTooltip,
+ ...view,
+ }
+ })
+})
+
+const selectedView = computed(() => {
+ if (!viewList.value || viewList.value.length === 0) return undefined
+
+ return viewList.value.find((view) => view.value === modelValue.value) || viewList.value[0]
+})
+
+watch(viewList, (newViewList) => {
+ if (!modelValue.value && newViewList && newViewList.length > 0) {
+ const newViewId = props.viewId || newViewList[0]?.value
+
+ const viewObj = newViewList.find((view) => view.value === newViewId)
+
+ // Change view id only if it is default view selected initially and its not enabled
+ if (viewObj && viewObj.ncItemDisabled && viewObj.value === newViewList[0]?.value) {
+ modelValue.value = newViewList.find((view) => !view.ncItemDisabled)?.value || newViewList[0]?.value
+ } else {
+ modelValue.value = newViewId
+ }
+ }
+}, { immediate: true })
+
+defineExpose({
+ modelValue,
+ selectedView,
+ isOpenViewSelectDropdown,
+ viewList,
+})
+</script>
+
+<template>
+ <a-form-item
+ v-if="selectedView"
+ name="viewId"
+ class="!mb-0 nc-view-selector"
+ :class="`nc-force-layout-${forceLayout}`"
+ :validate-status="selectedView?.ncItemDisabled ? 'error' : ''"
+ :help="selectedView?.ncItemDisabled ? [selectedView.ncItemTooltip] : []"
+ @click.stop
+ @dblclick.stop
+ >
+ <template v-if="!disableLabel" #label>
+ <div>{{ t('general.view') }}</div>
+ </template>
+ <NcListDropdown
+ v-model:is-open="isOpenViewSelectDropdown"
+ :disabled="!showViewSelector"
+ :default-slot-wrapper-class="
+ !showViewSelector
+ ? 'text-nc-content-gray-muted cursor-not-allowed bg-nc-bg-gray-light children:opacity-60'
+ : 'text-nc-content-gray'
+ "
+ :has-error="!!selectedView?.ncItemDisabled"
+ >
+ <div class="flex-1 flex items-center gap-2 min-w-0">
+ <div class="min-w-5 flex items-center justify-center">
+ <NIconView :view="selectedView" class="text-gray-500" />
+ </div>
+ <span class="text-sm flex-1 truncate">{{ selectedView?.label || t('general.view') }}</span>
+
+ <GeneralIcon
+ icon="ncChevronDown"
+ class="flex-none h-4 w-4 transition-transform opacity-70"
+ :class="{ 'transform rotate-180': isOpenViewSelectDropdown }"
+ />
+ </div>
+ <template #overlay="{ onEsc }">
+ <NcList
+ v-model:open="isOpenViewSelectDropdown"
+ :value="modelValue || selectedView?.value || ''"
+ :list="viewList"
+ variant="medium"
+ class="!w-auto !max-w-xs"
+ wrapper-class-name="!h-auto"
+ @update:value="handleValueUpdate"
+ @escape="onEsc"
+ >
+ <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" />
+ </div>
+ <NcTooltip class="flex-1 overflow-hidden whitespace-nowrap text-ellipsis" show-on-truncate-only>
+ <template #title>{{ item.label }}</template>
+ <span>{{ item.label }}</span>
+ </NcTooltip>
+ <component
+ :is="iconMap.check"
+ v-if="modelValue === item.value"
+ id="nc-selected-item-icon"
+ class="flex-none text-primary w-4 h-4"
+ />
+ </div>
+ </template>
+ </NcList>
+ </template>
+ </NcListDropdown>
+ </a-form-item>
+</template>
+
+<style lang="scss">
+.nc-view-selector.ant-form-item {
+ &.nc-force-layout-vertical {
+ @apply !flex-col;
+
+ & > .ant-form-item-label {
+ @apply pb-2 text-left;
+
+ &::after {
+ @apply hidden;
+ }
+
+ & > label {
+ @apply !h-auto;
+ &::after {
+ @apply !hidden;
+ }
+ }
+ }
+ }
+
+ &.nc-force-layout-horizontal {
+ @apply !flex-row !items-center;
+
+ & > .ant-form-item-label {
+ @apply pb-0 items-center;
+
+ &::after {
+ @apply content-[':'] !mr-2 !ml-0.5 relative top-[0.5px];
+ }
+ }
+ }
+}
+</style>