nuxt-ui-tools 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/module.d.mts +4 -0
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +30 -15
  4. package/dist/runtime/form/components/actions/FormActions.d.vue.ts +0 -2
  5. package/dist/runtime/form/components/actions/FormActions.vue +5 -8
  6. package/dist/runtime/form/components/actions/FormActions.vue.d.ts +0 -2
  7. package/dist/runtime/form/components/layout/DrawerLayout.vue +5 -1
  8. package/dist/runtime/form/components/layout/ModalLayout.vue +5 -1
  9. package/dist/runtime/form/components/renderer/FormCompositeControl.d.vue.ts +15 -0
  10. package/dist/runtime/form/components/renderer/FormCompositeControl.vue +13 -0
  11. package/dist/runtime/form/components/renderer/FormCompositeControl.vue.d.ts +15 -0
  12. package/dist/runtime/form/components/renderer/FormFieldRenderer.d.vue.ts +1 -0
  13. package/dist/runtime/form/components/renderer/FormFieldRenderer.vue +19 -3
  14. package/dist/runtime/form/components/renderer/FormFieldRenderer.vue.d.ts +1 -0
  15. package/dist/runtime/form/components/renderer/FormFieldShell.d.vue.ts +4 -4
  16. package/dist/runtime/form/components/renderer/FormFieldShell.vue +15 -1
  17. package/dist/runtime/form/components/renderer/FormFieldShell.vue.d.ts +4 -4
  18. package/dist/runtime/form/components/root/Form.vue +5 -3
  19. package/dist/runtime/form/composables/use-field-control.d.ts +1 -1
  20. package/dist/runtime/form/composables/use-field-control.js +4 -0
  21. package/dist/runtime/form/composables/use-field-options.d.ts +1 -1
  22. package/dist/runtime/form/composables/use-field-options.js +75 -31
  23. package/dist/runtime/form/composables/use-form-field-chrome.d.ts +3 -0
  24. package/dist/runtime/form/composables/use-form-field-chrome.js +9 -0
  25. package/dist/runtime/form/composables/use-form-runtime.js +17 -5
  26. package/dist/runtime/form/fields/array-list/component.vue +4 -1
  27. package/dist/runtime/form/fields/auto-complete/component.vue +23 -16
  28. package/dist/runtime/form/fields/checkbox-card/component.vue +28 -29
  29. package/dist/runtime/form/fields/checkbox-group/component.vue +28 -29
  30. package/dist/runtime/form/fields/color-picker/component.vue +4 -2
  31. package/dist/runtime/form/fields/date-family/component.vue +9 -4
  32. package/dist/runtime/form/fields/hierarchy/SelectionCheckbox.d.vue.ts +13 -0
  33. package/dist/runtime/form/fields/hierarchy/SelectionCheckbox.vue +24 -0
  34. package/dist/runtime/form/fields/hierarchy/SelectionCheckbox.vue.d.ts +13 -0
  35. package/dist/runtime/form/fields/hierarchy/SelectionRadio.d.vue.ts +14 -0
  36. package/dist/runtime/form/fields/hierarchy/SelectionRadio.vue +27 -0
  37. package/dist/runtime/form/fields/hierarchy/SelectionRadio.vue.d.ts +14 -0
  38. package/dist/runtime/form/fields/hierarchy/component.vue +257 -142
  39. package/dist/runtime/form/fields/hierarchy/utils.d.ts +9 -0
  40. package/dist/runtime/form/fields/hierarchy/utils.js +32 -0
  41. package/dist/runtime/form/fields/input-group/component.vue +7 -30
  42. package/dist/runtime/form/fields/matrix/component.vue +9 -3
  43. package/dist/runtime/form/fields/phone-number/component.vue +7 -2
  44. package/dist/runtime/form/fields/rating/component.vue +25 -2
  45. package/dist/runtime/form/fields/select/component.vue +29 -21
  46. package/dist/runtime/form/fields/switch-group/component.vue +8 -3
  47. package/dist/runtime/form/fields/time/component.vue +7 -5
  48. package/dist/runtime/form/fields/upload/component.vue +5 -3
  49. package/dist/runtime/form/types/api.d.ts +9 -3
  50. package/dist/runtime/form/types/field-base.d.ts +3 -1
  51. package/dist/runtime/form/types/runtime.d.ts +2 -0
  52. package/dist/runtime/form/types/ui.d.ts +1 -0
  53. package/dist/runtime/form/utils/api.js +3 -0
  54. package/dist/runtime/form/utils/options.d.ts +11 -2
  55. package/dist/runtime/form/utils/options.js +57 -9
  56. package/dist/runtime/form/utils/state.js +10 -2
  57. package/dist/runtime/i18n/locales/en.js +38 -0
  58. package/dist/runtime/i18n/locales/fr.js +38 -0
  59. package/dist/runtime/i18n/types.d.ts +38 -0
  60. package/dist/runtime/i18n/use-locale.d.ts +2 -2
  61. package/dist/runtime/i18n/use-locale.js +3 -3
  62. package/dist/runtime/table/components/DataList.d.vue.ts +2 -0
  63. package/dist/runtime/table/components/DataList.vue.d.ts +2 -0
  64. package/dist/runtime/table/components/actions/RowActions.d.vue.ts +4 -2
  65. package/dist/runtime/table/components/actions/RowActions.vue +2 -0
  66. package/dist/runtime/table/components/actions/RowActions.vue.d.ts +4 -2
  67. package/dist/runtime/table/components/data-list/DataListAddFilter.d.vue.ts +5 -3
  68. package/dist/runtime/table/components/data-list/DataListAddFilter.vue +6 -1
  69. package/dist/runtime/table/components/data-list/DataListAddFilter.vue.d.ts +5 -3
  70. package/dist/runtime/table/components/data-list/DataListContent.d.vue.ts +24 -17
  71. package/dist/runtime/table/components/data-list/DataListContent.vue +70 -17
  72. package/dist/runtime/table/components/data-list/DataListContent.vue.d.ts +24 -17
  73. package/dist/runtime/table/components/data-list/DataListDefault.d.vue.ts +2 -0
  74. package/dist/runtime/table/components/data-list/DataListDefault.vue.d.ts +2 -0
  75. package/dist/runtime/table/components/data-list/DataListFilterTags.d.vue.ts +2 -0
  76. package/dist/runtime/table/components/data-list/DataListFilterTags.vue.d.ts +2 -0
  77. package/dist/runtime/table/components/data-list/DataListLayoutSwitch.vue +17 -11
  78. package/dist/runtime/table/components/data-list/DataListRoot.vue +2 -46
  79. package/dist/runtime/table/components/data-list/DataListSortMenu.vue +6 -0
  80. package/dist/runtime/table/components/filters/shared/DynamicFilterPicker.d.vue.ts +5 -0
  81. package/dist/runtime/table/components/filters/shared/DynamicFilterPicker.vue +182 -59
  82. package/dist/runtime/table/components/filters/shared/DynamicFilterPicker.vue.d.ts +5 -0
  83. package/dist/runtime/table/components/filters/shared/FilterMatchModeButton.d.vue.ts +3 -1
  84. package/dist/runtime/table/components/filters/shared/FilterMatchModeButton.vue +29 -5
  85. package/dist/runtime/table/components/filters/shared/FilterMatchModeButton.vue.d.ts +3 -1
  86. package/dist/runtime/table/components/filters/shared/FilterMatchModePanel.d.vue.ts +17 -0
  87. package/dist/runtime/table/components/filters/shared/FilterMatchModePanel.vue +47 -0
  88. package/dist/runtime/table/components/filters/shared/FilterMatchModePanel.vue.d.ts +17 -0
  89. package/dist/runtime/table/components/filters/shared/FilterOptionMultipleList.d.vue.ts +3 -1
  90. package/dist/runtime/table/components/filters/shared/FilterOptionMultipleList.vue +12 -3
  91. package/dist/runtime/table/components/filters/shared/FilterOptionMultipleList.vue.d.ts +3 -1
  92. package/dist/runtime/table/components/filters/shared/FilterOptionPickerContent.d.vue.ts +3 -0
  93. package/dist/runtime/table/components/filters/shared/FilterOptionPickerContent.vue +11 -1
  94. package/dist/runtime/table/components/filters/shared/FilterOptionPickerContent.vue.d.ts +3 -0
  95. package/dist/runtime/table/components/filters/shared/FilterOptionRow.d.vue.ts +3 -0
  96. package/dist/runtime/table/components/filters/shared/FilterOptionRow.vue +48 -9
  97. package/dist/runtime/table/components/filters/shared/FilterOptionRow.vue.d.ts +3 -0
  98. package/dist/runtime/table/components/filters/shared/FilterOptionSingleList.d.vue.ts +3 -0
  99. package/dist/runtime/table/components/filters/shared/FilterOptionSingleList.vue +35 -9
  100. package/dist/runtime/table/components/filters/shared/FilterOptionSingleList.vue.d.ts +3 -0
  101. package/dist/runtime/table/components/filters/shared/FilterOptionTreeContent.d.vue.ts +3 -0
  102. package/dist/runtime/table/components/filters/shared/FilterOptionTreeContent.vue +77 -20
  103. package/dist/runtime/table/components/filters/shared/FilterOptionTreeContent.vue.d.ts +3 -0
  104. package/dist/runtime/table/components/filters/shared/FilterPopoverShell.d.vue.ts +27 -0
  105. package/dist/runtime/table/components/filters/shared/FilterPopoverShell.vue +36 -0
  106. package/dist/runtime/table/components/filters/shared/FilterPopoverShell.vue.d.ts +27 -0
  107. package/dist/runtime/table/components/filters/shared/FilterSearchablePanel.d.vue.ts +3 -0
  108. package/dist/runtime/table/components/filters/shared/FilterSearchablePanel.vue +40 -10
  109. package/dist/runtime/table/components/filters/shared/FilterSearchablePanel.vue.d.ts +3 -0
  110. package/dist/runtime/table/components/filters/shared/FilterStageTransition.d.vue.ts +23 -0
  111. package/dist/runtime/table/components/filters/shared/FilterStageTransition.vue +21 -0
  112. package/dist/runtime/table/components/filters/shared/FilterStageTransition.vue.d.ts +23 -0
  113. package/dist/runtime/table/components/filters/shared/FilterTriggerTag.d.vue.ts +3 -2
  114. package/dist/runtime/table/components/filters/shared/FilterTriggerTag.vue +26 -25
  115. package/dist/runtime/table/components/filters/shared/FilterTriggerTag.vue.d.ts +3 -2
  116. package/dist/runtime/table/components/filters/tags/BooleanFilterTag.d.vue.ts +1 -1
  117. package/dist/runtime/table/components/filters/tags/BooleanFilterTag.vue +75 -22
  118. package/dist/runtime/table/components/filters/tags/BooleanFilterTag.vue.d.ts +1 -1
  119. package/dist/runtime/table/components/filters/tags/DateFilterTag.d.vue.ts +3 -1
  120. package/dist/runtime/table/components/filters/tags/DateFilterTag.vue +254 -160
  121. package/dist/runtime/table/components/filters/tags/DateFilterTag.vue.d.ts +3 -1
  122. package/dist/runtime/table/components/filters/tags/FilterTagsBar.d.vue.ts +7 -6
  123. package/dist/runtime/table/components/filters/tags/FilterTagsBar.vue +12 -27
  124. package/dist/runtime/table/components/filters/tags/FilterTagsBar.vue.d.ts +7 -6
  125. package/dist/runtime/table/components/filters/tags/NumberFilterTag.d.vue.ts +3 -2
  126. package/dist/runtime/table/components/filters/tags/NumberFilterTag.vue +192 -106
  127. package/dist/runtime/table/components/filters/tags/NumberFilterTag.vue.d.ts +3 -2
  128. package/dist/runtime/table/components/filters/tags/OptionFilterTag.d.vue.ts +3 -2
  129. package/dist/runtime/table/components/filters/tags/OptionFilterTag.vue +110 -48
  130. package/dist/runtime/table/components/filters/tags/OptionFilterTag.vue.d.ts +3 -2
  131. package/dist/runtime/table/components/filters/tags/TextFilterTag.d.vue.ts +3 -2
  132. package/dist/runtime/table/components/filters/tags/TextFilterTag.vue +120 -57
  133. package/dist/runtime/table/components/filters/tags/TextFilterTag.vue.d.ts +3 -2
  134. package/dist/runtime/table/components/grid/GridRenderer.vue +1 -1
  135. package/dist/runtime/table/components/layout/TableFooter.vue +1 -0
  136. package/dist/runtime/table/components/table/TableRenderer.vue +18 -9
  137. package/dist/runtime/table/composables/use-filter-tag-session.d.ts +3 -4
  138. package/dist/runtime/table/composables/use-filter-tag-session.js +12 -32
  139. package/dist/runtime/table/composables/use-query-state.d.ts +3 -3
  140. package/dist/runtime/table/composables/use-query-state.js +7 -32
  141. package/dist/runtime/table/composables/use-table-api.js +2 -2
  142. package/dist/runtime/table/composables/use-table-columns.d.ts +1 -11
  143. package/dist/runtime/table/composables/use-table-filter-presentation.d.ts +0 -3
  144. package/dist/runtime/table/composables/use-table-filter-presentation.js +0 -9
  145. package/dist/runtime/table/composables/use-table-filters.js +18 -7
  146. package/dist/runtime/table/composables/use-table-internals.d.ts +3 -42
  147. package/dist/runtime/table/types/actions.d.ts +1 -1
  148. package/dist/runtime/table/types/data-list.d.ts +41 -8
  149. package/dist/runtime/table/types/filters.d.ts +4 -0
  150. package/dist/runtime/table/utils/actions.d.ts +1 -1
  151. package/dist/runtime/table/utils/columns/menu.d.ts +2 -11
  152. package/dist/runtime/table/utils/columns/render.d.ts +2 -9
  153. package/dist/runtime/table/utils/columns/render.js +4 -4
  154. package/dist/runtime/table/utils/data-list-ui.d.ts +3 -1
  155. package/dist/runtime/table/utils/data-list-ui.js +45 -0
  156. package/dist/runtime/table/utils/filters/editor-size.d.ts +11 -0
  157. package/dist/runtime/table/utils/filters/editor-size.js +45 -0
  158. package/dist/runtime/table/utils/filters/index.d.ts +1 -1
  159. package/dist/runtime/table/utils/filters/index.js +1 -1
  160. package/dist/runtime/table/utils/query-state.d.ts +18 -1
  161. package/dist/runtime/table/utils/query-state.js +109 -0
  162. package/package.json +4 -2
  163. package/dist/runtime/table/utils/filters/operators.d.ts +0 -4
  164. package/dist/runtime/table/utils/filters/operators.js +0 -6
@@ -1,8 +1,7 @@
1
- import { ref, watch } from "vue";
1
+ import { ref } from "vue";
2
2
  export function useFilterTagSession(options) {
3
3
  const isOpen = options.isOpen ?? ref(false);
4
- const lastActivationToken = ref(null);
5
- let dismissLocked = false;
4
+ if (options.embedded) isOpen.value = true;
6
5
  function runCloseEffects() {
7
6
  options.onClose();
8
7
  if (options.session) {
@@ -11,22 +10,15 @@ export function useFilterTagSession(options) {
11
10
  }
12
11
  if (options.dynamic && !options.hasCommittedState()) options.onDismiss();
13
12
  }
14
- function openWithLock() {
15
- dismissLocked = true;
16
- setTimeout(() => {
17
- isOpen.value = true;
18
- requestAnimationFrame(() => {
19
- requestAnimationFrame(() => {
20
- dismissLocked = false;
21
- });
22
- });
23
- });
13
+ function open() {
14
+ if (isOpen.value) return;
15
+ isOpen.value = true;
16
+ options.onOpen();
24
17
  }
25
- function handleOpenChange(open) {
26
- if (!open && dismissLocked) return;
27
- if (!open && !isOpen.value) return;
28
- isOpen.value = open;
29
- if (open) {
18
+ function handleOpenChange(nextOpen) {
19
+ if (!nextOpen && !isOpen.value) return;
20
+ isOpen.value = nextOpen;
21
+ if (nextOpen) {
30
22
  options.onOpen();
31
23
  return;
32
24
  }
@@ -37,22 +29,10 @@ export function useFilterTagSession(options) {
37
29
  isOpen.value = false;
38
30
  runCloseEffects();
39
31
  }
40
- if (options.activationToken) {
41
- queueMicrotask(() => {
42
- watch(
43
- options.activationToken,
44
- (value) => {
45
- if (value == null || value === lastActivationToken.value) return;
46
- lastActivationToken.value = value;
47
- options.onActivated();
48
- },
49
- { immediate: true }
50
- );
51
- });
52
- }
32
+ if (options.embedded) queueMicrotask(options.onOpen);
53
33
  return {
54
34
  isOpen,
55
- openWithLock,
35
+ open,
56
36
  handleOpenChange,
57
37
  close
58
38
  };
@@ -1,5 +1,5 @@
1
1
  import { type ComputedRef } from 'vue';
2
- import type { TableFilterOperator, TableLayout, TableQueryStateFilterRule, TableQueryStateFilterValue, TableSchemaView } from '../types/index.js';
2
+ import type { TableLayout, TableQueryStateFilterRule, TableSchemaView } from '../types/index.js';
3
3
  export interface UseQueryStateParams {
4
4
  schema: ComputedRef<TableSchemaView>;
5
5
  activeLayout: ComputedRef<TableLayout>;
@@ -40,9 +40,9 @@ export declare function useQueryState(params: UseQueryStateParams): {
40
40
  } | null>;
41
41
  filters: import("vue").WritableComputedRef<{
42
42
  search: string;
43
- ui: TableQueryStateFilterRule<string, TableFilterOperator, TableQueryStateFilterValue>[];
43
+ ui: TableQueryStateFilterRule<string, import("../types/index.js").TableFilterOperator, import("../types/index.js").TableQueryStateFilterValue>[];
44
44
  }, {
45
45
  search: string;
46
- ui: TableQueryStateFilterRule<string, TableFilterOperator, TableQueryStateFilterValue>[];
46
+ ui: TableQueryStateFilterRule<string, import("../types/index.js").TableFilterOperator, import("../types/index.js").TableQueryStateFilterValue>[];
47
47
  }>;
48
48
  };
@@ -12,8 +12,11 @@ import {
12
12
  getDefaultSort,
13
13
  getPaginationMode,
14
14
  normalizeFilterDefinition,
15
+ parseTableFilterQueryState,
16
+ resolveTableFilterDefaultRules,
15
17
  resolveFilterDefaultOperator,
16
- resolveFilterSupportedOperators
18
+ resolveFilterSupportedOperators,
19
+ serializeTableFilterQueryState
17
20
  } from "../utils/index.js";
18
21
  export function useQueryState(params) {
19
22
  const defaultPageSize = getDefaultPageSize({
@@ -90,7 +93,7 @@ export function useQueryState(params) {
90
93
  ui: dynamicQueryState({
91
94
  urlPrefix: "ui",
92
95
  definitions: () => params.schema.value.filters?.ui ?? [],
93
- defaultValue: [],
96
+ defaultValue: resolveTableFilterDefaultRules(params.schema.value.filters?.ui ?? []),
94
97
  resolve(filter) {
95
98
  const definition = normalizeFilterDefinition(filter);
96
99
  const operators = resolveFilterSupportedOperators(definition);
@@ -102,38 +105,10 @@ export function useQueryState(params) {
102
105
  }));
103
106
  },
104
107
  parse(entries, definitions) {
105
- const rules = [];
106
- for (const filter of definitions) {
107
- const definition = normalizeFilterDefinition(filter);
108
- const operators = resolveFilterSupportedOperators(definition);
109
- const defaultOp = resolveFilterDefaultOperator(definition);
110
- for (const op of operators) {
111
- const urlKey = op === defaultOp ? definition.key : `${definition.key}~${op}`;
112
- const value = entries.get(urlKey);
113
- if (value != null) {
114
- rules.push({
115
- key: definition.key,
116
- operator: op,
117
- value
118
- });
119
- break;
120
- }
121
- }
122
- }
123
- return rules;
108
+ return parseTableFilterQueryState({ entries, definitions });
124
109
  },
125
110
  serialize(rules, definitions) {
126
- const result = /* @__PURE__ */ new Map();
127
- for (const rule of rules) {
128
- const filter = definitions.find((f) => f.key === rule.key);
129
- if (!filter) continue;
130
- const definition = normalizeFilterDefinition(filter);
131
- const operator = rule.operator ?? resolveFilterDefaultOperator(definition);
132
- const defaultOp = resolveFilterDefaultOperator(definition);
133
- const urlKey = operator === defaultOp ? definition.key : `${definition.key}~${operator}`;
134
- result.set(urlKey, rule.value);
135
- }
136
- return result;
111
+ return serializeTableFilterQueryState({ rules, definitions });
137
112
  }
138
113
  })
139
114
  },
@@ -1,5 +1,5 @@
1
1
  import { computed } from "vue";
2
- import { getDefaultSort, mapPublicQueryState } from "../utils/index.js";
2
+ import { getDefaultSort, mapPublicQueryState, resolveTableFilterDefaultRules } from "../utils/index.js";
3
3
  export function useTableApi(params) {
4
4
  const state = {
5
5
  layout: params.layout.activeLayout,
@@ -84,7 +84,7 @@ export function useTableApi(params) {
84
84
  params.columns.setSorting(defaultSort);
85
85
  params.state.queryState.filters.value = {
86
86
  search: "",
87
- ui: []
87
+ ui: resolveTableFilterDefaultRules(params.runtimeSchema.value.filters?.ui ?? [])
88
88
  };
89
89
  },
90
90
  all() {
@@ -180,17 +180,7 @@ export declare function useTableColumns(params: UseTableColumnsParams): {
180
180
  }) => "right" | "left" | null;
181
181
  getMenuItems: (options: {
182
182
  columnId: string;
183
- }) => ({
184
- label: string;
185
- icon: string;
186
- color: string;
187
- onSelect: () => void;
188
- } | {
189
- label: string;
190
- icon: string;
191
- onSelect: () => void;
192
- color?: undefined;
193
- })[][];
183
+ }) => import("@nuxt/ui/runtime/components/DropdownMenu.d.vue.js").DropdownMenuItem[][];
194
184
  sortingState: import("vue").ComputedRef<{
195
185
  key: string | undefined;
196
186
  dir: "desc" | "asc" | undefined;
@@ -23,9 +23,6 @@ export declare function useTableFilterPresentation(options: UseTableFilterPresen
23
23
  releaseDynamicSession: (input: {
24
24
  key: string;
25
25
  }) => void;
26
- getDynamicActivationToken: (input: {
27
- key: string;
28
- }) => number;
29
26
  openPanel: () => void;
30
27
  closePanel: () => void;
31
28
  resetPanelDraft: () => void;
@@ -2,7 +2,6 @@ import { computed, ref } from "vue";
2
2
  import { resolveFilterDisplayLocation, resolveFilterDisplayOrder } from "../utils/index.js";
3
3
  export function useTableFilterPresentation(options) {
4
4
  const dynamicSessionKey = ref(null);
5
- const dynamicActivationToken = ref({});
6
5
  const panelOpen = ref(false);
7
6
  const panelDraftFilters = ref([]);
8
7
  const definitions = computed(
@@ -76,10 +75,6 @@ export function useTableFilterPresentation(options) {
76
75
  });
77
76
  function activateDynamicFilter(input) {
78
77
  dynamicSessionKey.value = input.key;
79
- dynamicActivationToken.value = {
80
- ...dynamicActivationToken.value,
81
- [input.key]: (dynamicActivationToken.value[input.key] ?? 0) + 1
82
- };
83
78
  }
84
79
  function releaseDynamicSession(input) {
85
80
  if (dynamicSessionKey.value !== input.key) return;
@@ -167,9 +162,6 @@ export function useTableFilterPresentation(options) {
167
162
  function clearPanelFilter(input) {
168
163
  panelDraftFilters.value = panelDraftFilters.value.filter((rule) => rule.key !== input.key);
169
164
  }
170
- function getDynamicActivationToken(input) {
171
- return dynamicActivationToken.value[input.key] ?? 0;
172
- }
173
165
  function isPanelKey(key) {
174
166
  return panelDefinitions.value.some((definition) => definition.key === key);
175
167
  }
@@ -192,7 +184,6 @@ export function useTableFilterPresentation(options) {
192
184
  panelOpen,
193
185
  activateDynamicFilter,
194
186
  releaseDynamicSession,
195
- getDynamicActivationToken,
196
187
  openPanel,
197
188
  closePanel,
198
189
  resetPanelDraft,
@@ -1,14 +1,17 @@
1
1
  import { computed } from "vue";
2
+ import { useUiToolsLocale } from "#ui-tools/i18n";
2
3
  import {
3
4
  buildFilterPreview,
4
5
  createFilterValueForOperator,
5
6
  flattenFilterOptionEntries,
6
7
  getFilterLabelText,
7
- getFilterOperatorLabel,
8
+ mergeTableFilterDefaultRules,
9
+ resolveTableFilterDefaultRules,
8
10
  resolveFilterOptionEntries
9
11
  } from "../utils/index.js";
10
12
  import { useTableSearch } from "./use-table-search.js";
11
13
  export function useTableFilters(params) {
14
+ const { t } = useUiToolsLocale();
12
15
  const search = useTableSearch({
13
16
  schema: params.schema,
14
17
  queryState: params.state.queryState
@@ -19,6 +22,9 @@ export function useTableFilters(params) {
19
22
  const activeUiFilters = computed(
20
23
  () => params.state.queryState.filters.value.ui ?? []
21
24
  );
25
+ const defaultUiFilters = computed(
26
+ () => resolveTableFilterDefaultRules(definitions.value)
27
+ );
22
28
  const hasActiveUiFilters = computed(() => activeUiFilters.value.length > 0);
23
29
  function getDefinition(input) {
24
30
  return definitions.value.find(
@@ -79,9 +85,7 @@ export function useTableFilters(params) {
79
85
  function getFilterOperatorOptions(input) {
80
86
  return getFilterOperators(input.key).map((operator) => ({
81
87
  value: operator,
82
- label: getFilterOperatorLabel({
83
- operator
84
- })
88
+ label: t(`table.filters.operators.${operator}`)
85
89
  }));
86
90
  }
87
91
  function setFilterOperator(input) {
@@ -175,24 +179,31 @@ export function useTableFilters(params) {
175
179
  });
176
180
  }
177
181
  function removeFilter(key) {
182
+ const defaultRule = defaultUiFilters.value.find((filter) => filter.key === key);
178
183
  params.state.queryState.resetPagination();
179
184
  params.state.queryState.filters.value = {
180
185
  ...params.state.queryState.filters.value,
181
- ui: params.state.queryState.filters.value.ui.filter((filter) => filter.key !== key)
186
+ ui: [
187
+ ...params.state.queryState.filters.value.ui.filter((filter) => filter.key !== key),
188
+ ...defaultRule ? [defaultRule] : []
189
+ ]
182
190
  };
183
191
  }
184
192
  function clearAllFilters() {
185
193
  params.state.queryState.resetPagination();
186
194
  params.state.queryState.filters.value = {
187
195
  ...params.state.queryState.filters.value,
188
- ui: []
196
+ ui: defaultUiFilters.value
189
197
  };
190
198
  }
191
199
  function replaceFilters(input) {
192
200
  params.state.queryState.resetPagination();
193
201
  params.state.queryState.filters.value = {
194
202
  ...params.state.queryState.filters.value,
195
- ui: [...input.rules]
203
+ ui: mergeTableFilterDefaultRules({
204
+ rules: input.rules,
205
+ definitions: definitions.value
206
+ })
196
207
  };
197
208
  }
198
209
  return {
@@ -190,9 +190,6 @@ declare function createTableInternals<TSchema>(options: {
190
190
  releaseDynamicSession: (input: {
191
191
  key: string;
192
192
  }) => void;
193
- getDynamicActivationToken: (input: {
194
- key: string;
195
- }) => number;
196
193
  openPanel: () => void;
197
194
  closePanel: () => void;
198
195
  resetPanelDraft: () => void;
@@ -432,17 +429,7 @@ declare function createTableInternals<TSchema>(options: {
432
429
  }) => "right" | "left" | null;
433
430
  getMenuItems: (options: {
434
431
  columnId: string;
435
- }) => ({
436
- label: string;
437
- icon: string;
438
- color: string;
439
- onSelect: () => void;
440
- } | {
441
- label: string;
442
- icon: string;
443
- onSelect: () => void;
444
- color?: undefined;
445
- })[][];
432
+ }) => import("@nuxt/ui/runtime/components/DropdownMenu.d.vue.js").DropdownMenuItem[][];
446
433
  sortingState: import("vue").ComputedRef<{
447
434
  key: string | undefined;
448
435
  dir: "desc" | "asc" | undefined;
@@ -682,9 +669,6 @@ declare function useProvideTableInternals<TSchema>(options: {
682
669
  releaseDynamicSession: (input: {
683
670
  key: string;
684
671
  }) => void;
685
- getDynamicActivationToken: (input: {
686
- key: string;
687
- }) => number;
688
672
  openPanel: () => void;
689
673
  closePanel: () => void;
690
674
  resetPanelDraft: () => void;
@@ -924,17 +908,7 @@ declare function useProvideTableInternals<TSchema>(options: {
924
908
  }) => "right" | "left" | null;
925
909
  getMenuItems: (options: {
926
910
  columnId: string;
927
- }) => ({
928
- label: string;
929
- icon: string;
930
- color: string;
931
- onSelect: () => void;
932
- } | {
933
- label: string;
934
- icon: string;
935
- onSelect: () => void;
936
- color?: undefined;
937
- })[][];
911
+ }) => import("@nuxt/ui/runtime/components/DropdownMenu.d.vue.js").DropdownMenuItem[][];
938
912
  sortingState: import("vue").ComputedRef<{
939
913
  key: string | undefined;
940
914
  dir: "desc" | "asc" | undefined;
@@ -1171,9 +1145,6 @@ declare function useTableInternals(): {
1171
1145
  releaseDynamicSession: (input: {
1172
1146
  key: string;
1173
1147
  }) => void;
1174
- getDynamicActivationToken: (input: {
1175
- key: string;
1176
- }) => number;
1177
1148
  openPanel: () => void;
1178
1149
  closePanel: () => void;
1179
1150
  resetPanelDraft: () => void;
@@ -1413,17 +1384,7 @@ declare function useTableInternals(): {
1413
1384
  }) => "right" | "left" | null;
1414
1385
  getMenuItems: (options: {
1415
1386
  columnId: string;
1416
- }) => ({
1417
- label: string;
1418
- icon: string;
1419
- color: string;
1420
- onSelect: () => void;
1421
- } | {
1422
- label: string;
1423
- icon: string;
1424
- onSelect: () => void;
1425
- color?: undefined;
1426
- })[][];
1387
+ }) => import("@nuxt/ui/runtime/components/DropdownMenu.d.vue.js").DropdownMenuItem[][];
1427
1388
  sortingState: import("vue").ComputedRef<{
1428
1389
  key: string | undefined;
1429
1390
  dir: "desc" | "asc" | undefined;
@@ -1,4 +1,4 @@
1
- import type { DropdownMenuItem } from '@nuxt/ui';
1
+ import type { DropdownMenuItem } from '@nuxt/ui/components/DropdownMenu.vue';
2
2
  import type { TableSourceRequestContext } from './source.js';
3
3
  import type { GenericObject, MaybePromise, TableLayout, TableRowRenderParams, TableTextValue } from './utils.js';
4
4
  export interface TableActionContext<TRow extends GenericObject = GenericObject, TContext extends GenericObject = GenericObject, TPageContext extends GenericObject = GenericObject> {
@@ -26,8 +26,40 @@ export interface DataListSearchUi {
26
26
  trailing?: DataListUiClass;
27
27
  trailingIcon?: DataListUiClass;
28
28
  }
29
- /** UI slots rendered by filter tags and their adjacent actions. */
30
- export interface DataListFilterTagsUi {
29
+ /** Shared UI slots rendered by a progressive filter editor popover. */
30
+ export interface DataListFilterEditorUi {
31
+ popoverContent?: DataListUiClass;
32
+ operatorContent?: DataListUiClass;
33
+ operatorItem?: DataListUiClass;
34
+ operatorLabel?: DataListUiClass;
35
+ operatorTrigger?: DataListUiClass;
36
+ editor?: DataListUiClass;
37
+ searchHeader?: DataListUiClass;
38
+ search?: DataListUiClass;
39
+ searchInput?: DataListUiClass;
40
+ scrollArea?: DataListUiClass;
41
+ scrollViewport?: DataListUiClass;
42
+ list?: DataListUiClass;
43
+ listDivider?: DataListUiClass;
44
+ option?: DataListUiClass;
45
+ optionCheckbox?: DataListUiClass;
46
+ optionExpander?: DataListUiClass;
47
+ optionSpacer?: DataListUiClass;
48
+ optionIcon?: DataListUiClass;
49
+ optionLabel?: DataListUiClass;
50
+ optionCount?: DataListUiClass;
51
+ empty?: DataListUiClass;
52
+ footer?: DataListUiClass;
53
+ clear?: DataListUiClass;
54
+ apply?: DataListUiClass;
55
+ inputs?: DataListUiClass;
56
+ presets?: DataListUiClass;
57
+ preset?: DataListUiClass;
58
+ calendar?: DataListUiClass;
59
+ slider?: DataListUiClass;
60
+ }
61
+ /** UI slots rendered by filter tags, their editors, and adjacent actions. */
62
+ export interface DataListFilterTagsUi extends DataListFilterEditorUi {
31
63
  root?: DataListUiClass;
32
64
  trigger?: DataListUiClass;
33
65
  label?: DataListUiClass;
@@ -36,14 +68,10 @@ export interface DataListFilterTagsUi {
36
68
  addTrigger?: DataListUiClass;
37
69
  clearTrigger?: DataListUiClass;
38
70
  }
39
- /** UI slots rendered by the add-filter picker. */
40
- export interface DataListAddFilterUi {
71
+ /** UI slots rendered by the progressive add-filter picker. */
72
+ export interface DataListAddFilterUi extends DataListFilterEditorUi {
41
73
  trigger?: DataListUiClass;
42
- popoverContent?: DataListUiClass;
43
74
  panel?: DataListUiClass;
44
- option?: DataListUiClass;
45
- optionIcon?: DataListUiClass;
46
- optionLabel?: DataListUiClass;
47
75
  optionTrailingIcon?: DataListUiClass;
48
76
  }
49
77
  /** UI slots rendered by the filter slideover. */
@@ -130,11 +158,15 @@ export interface DataListContentUi {
130
158
  root?: DataListUiClass;
131
159
  error?: DataListUiClass;
132
160
  errorBody?: DataListUiClass;
161
+ errorIcon?: DataListUiClass;
162
+ errorCopy?: DataListUiClass;
133
163
  errorTitle?: DataListUiClass;
164
+ errorDescription?: DataListUiClass;
134
165
  retry?: DataListUiClass;
135
166
  }
136
167
  /** UI slots rendered by the table mode. Nuxt UI table slots are forwarded unchanged. */
137
168
  export interface DataListTableUi {
169
+ wrapper?: DataListUiClass;
138
170
  root?: DataListUiClass;
139
171
  base?: DataListUiClass;
140
172
  caption?: DataListUiClass;
@@ -157,6 +189,7 @@ export interface DataListGridUi {
157
189
  canvas?: DataListUiClass;
158
190
  row?: DataListUiClass;
159
191
  item?: DataListUiClass;
192
+ flowRoot?: DataListUiClass;
160
193
  flow?: DataListUiClass;
161
194
  loading?: DataListUiClass;
162
195
  error?: DataListUiClass;
@@ -17,6 +17,10 @@ export type TableFilterPreviewMode = 'auto' | 'summary' | 'tags';
17
17
  export type TableFilterDisplayLocation = 'tag' | 'panel' | 'tag-dynamic';
18
18
  export type TableFilterDisplayLocationValue = TableFilterDisplayLocation | string;
19
19
  export interface TableFilterBehaviorCommon<TOperator extends TableFilterOperator = TableFilterOperator> {
20
+ /**
21
+ * Effective filter value when the URL has no override for this definition.
22
+ * The default stays active but is omitted from the URL; clearing the filter restores it.
23
+ */
20
24
  defaultValue?: TableQueryStateFilterValue;
21
25
  operators?: TOperator[];
22
26
  defaultOperator?: TOperator;
@@ -1,4 +1,4 @@
1
- import type { DropdownMenuItem } from '@nuxt/ui';
1
+ import type { DropdownMenuItem } from '@nuxt/ui/components/DropdownMenu.vue';
2
2
  import type { TableInjectedRowActionScope } from '../composables/use-table-row-actions.js';
3
3
  import type { GenericObject, TableRowAction, TableSchemaView } from '../types/index.js';
4
4
  type RowActionSchemaSource = {
@@ -1,3 +1,4 @@
1
+ import type { DropdownMenuItem } from '@nuxt/ui/components/DropdownMenu.vue';
1
2
  import type { TableSchemaView } from '../../types/index.js';
2
3
  export declare function createColumnMenuItems(options: {
3
4
  columnId: string;
@@ -24,17 +25,7 @@ export declare function createColumnMenuItems(options: {
24
25
  key: string;
25
26
  dir: 'asc' | 'desc';
26
27
  } | null) => void;
27
- }): ({
28
- label: string;
29
- icon: string;
30
- color: string;
31
- onSelect: () => void;
32
- } | {
33
- label: string;
34
- icon: string;
35
- onSelect: () => void;
36
- color?: undefined;
37
- })[][];
28
+ }): DropdownMenuItem[][];
38
29
  export declare function getColumnHeaderIcon(options: {
39
30
  columnId: string;
40
31
  getSortState: (options: {
@@ -1,14 +1,8 @@
1
1
  /** @jsxImportSource vue */
2
+ import type { DropdownMenuItem } from '@nuxt/ui/components/DropdownMenu.vue';
2
3
  import type { VNodeChild } from 'vue';
3
4
  import type { GenericObject } from '../../types/index.js';
4
5
  import { type SchemaTableColumn, type TableColumnRenderParams, type TableRuntimeColumn, type UseTableColumnsParams } from './types.js';
5
- type ColumnMenuItem = {
6
- label?: string;
7
- icon?: string;
8
- color?: string;
9
- class?: string;
10
- onSelect?: () => void;
11
- };
12
6
  export declare function createSelectionColumn(options: {
13
7
  params: UseTableColumnsParams;
14
8
  }): {
@@ -48,7 +42,7 @@ export declare function createDataColumns(options: {
48
42
  visibleOrderedColumns: TableRuntimeColumn[];
49
43
  getMenuItems: (options: {
50
44
  columnId: string;
51
- }) => ColumnMenuItem[][];
45
+ }) => DropdownMenuItem[][];
52
46
  getPinnedState: (options: {
53
47
  columnId: string;
54
48
  }) => 'left' | 'right' | null;
@@ -155,4 +149,3 @@ export declare function getColumnCellClass(options: {
155
149
  export declare function normalizeColumnSize(options: {
156
150
  size?: number | string;
157
151
  }): number | undefined;
158
- export {};
@@ -34,8 +34,7 @@ export function createSelectionColumn(options) {
34
34
  UCheckbox,
35
35
  {
36
36
  modelValue: options.params.selection.allSelected.value ? true : options.params.selection.partiallySelected.value ? "indeterminate" : false,
37
- color: "neutral",
38
- ui: { base: "!rounded-md", indicator: "!rounded-none" }
37
+ color: "neutral"
39
38
  }
40
39
  )
41
40
  }
@@ -59,8 +58,7 @@ export function createSelectionColumn(options) {
59
58
  UCheckbox,
60
59
  {
61
60
  modelValue: options.params.selection.isRowSelected({ rowId: String(row.id) }),
62
- color: "neutral",
63
- ui: { base: "!rounded-md", indicator: "!rounded-none" }
61
+ color: "neutral"
64
62
  }
65
63
  )
66
64
  }
@@ -114,6 +112,7 @@ export function createDataColumns(options) {
114
112
  /* @__PURE__ */ jsx(
115
113
  UDropdownMenu,
116
114
  {
115
+ size: "sm",
117
116
  items: options.getMenuItems({ columnId: runtimeColumn.id }),
118
117
  content: { align: "start", side: "bottom", sideOffset: 10 },
119
118
  modal: false,
@@ -324,6 +323,7 @@ function createRowActionsColumn(options) {
324
323
  return /* @__PURE__ */ jsx(TableRowScopeProvider, { scope, children: /* @__PURE__ */ jsx("div", { class: "flex justify-end", children: /* @__PURE__ */ jsx(
325
324
  RowActions,
326
325
  {
326
+ size: "sm",
327
327
  content: { align: "end", side: "bottom", sideOffset: 8 },
328
328
  modal: false,
329
329
  portal: true,
@@ -1,3 +1,5 @@
1
- import type { DataListUiClass } from '../types/index.js';
1
+ import type { DataListDensity, DataListUiClass, DataListUiConfig } from '../types/index.js';
2
2
  /** Merges DataList slot classes with the same conflict resolution used by Nuxt UI. */
3
3
  export declare function mergeDataListUiClass(defaults?: DataListUiClass, root?: DataListUiClass, local?: DataListUiClass): string;
4
+ /** Merges application and root DataList defaults without losing nested UI slots. */
5
+ export declare function mergeDataListUiConfig(appUi: DataListUiConfig | undefined, componentUi: DataListUiConfig | undefined, density: DataListDensity | undefined): DataListUiConfig;
@@ -2,3 +2,48 @@ import { twMerge } from "tailwind-merge";
2
2
  export function mergeDataListUiClass(defaults, root, local) {
3
3
  return twMerge(defaults, root, local);
4
4
  }
5
+ export function mergeDataListUiConfig(appUi, componentUi, density) {
6
+ return {
7
+ ...appUi,
8
+ ...componentUi,
9
+ density: density ?? componentUi?.density ?? appUi?.density,
10
+ control: { ...appUi?.control, ...componentUi?.control },
11
+ default: mergeUiConfig(appUi?.default, componentUi?.default),
12
+ search: mergeSearchConfig(appUi?.search, componentUi?.search),
13
+ filterTags: mergePartConfig(appUi?.filterTags, componentUi?.filterTags),
14
+ addFilter: mergePartConfig(appUi?.addFilter, componentUi?.addFilter),
15
+ filterPanel: mergePartConfig(appUi?.filterPanel, componentUi?.filterPanel),
16
+ clearFilters: mergePartConfig(appUi?.clearFilters, componentUi?.clearFilters),
17
+ resultCount: mergeUiConfig(appUi?.resultCount, componentUi?.resultCount),
18
+ columnPanel: mergePartConfig(appUi?.columnPanel, componentUi?.columnPanel),
19
+ sortMenu: mergePartConfig(appUi?.sortMenu, componentUi?.sortMenu),
20
+ layoutSwitch: mergePartConfig(appUi?.layoutSwitch, componentUi?.layoutSwitch),
21
+ refresh: mergePartConfig(appUi?.refresh, componentUi?.refresh),
22
+ content: mergeUiConfig(appUi?.content, componentUi?.content),
23
+ table: mergeUiConfig(appUi?.table, componentUi?.table),
24
+ grid: mergeUiConfig(appUi?.grid, componentUi?.grid),
25
+ pagination: mergePartConfig(appUi?.pagination, componentUi?.pagination),
26
+ infiniteLoader: mergePartConfig(appUi?.infiniteLoader, componentUi?.infiniteLoader)
27
+ };
28
+ }
29
+ function mergeUiConfig(appDefaults, componentConfig) {
30
+ return {
31
+ ...appDefaults,
32
+ ...componentConfig,
33
+ ui: { ...appDefaults?.ui, ...componentConfig?.ui }
34
+ };
35
+ }
36
+ function mergePartConfig(appDefaults, componentConfig) {
37
+ return {
38
+ ...appDefaults,
39
+ ...componentConfig,
40
+ ui: { ...appDefaults?.ui, ...componentConfig?.ui }
41
+ };
42
+ }
43
+ function mergeSearchConfig(appDefaults, componentConfig) {
44
+ return {
45
+ ...appDefaults,
46
+ ...componentConfig,
47
+ ui: { ...appDefaults?.ui, ...componentConfig?.ui }
48
+ };
49
+ }
@@ -0,0 +1,11 @@
1
+ import type { DataListControlSize } from '../../types/index.js';
2
+ export declare function resolveFilterEditorSizeClasses(size: DataListControlSize | undefined): {
3
+ editor: string;
4
+ searchHeader: string;
5
+ scrollArea: string;
6
+ option: string;
7
+ optionIcon: string;
8
+ optionLabel: string;
9
+ footer: string;
10
+ empty: string;
11
+ };