nuxt-ui-tools 1.0.1 → 1.2.0
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.
- package/dist/module.d.mts +3 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +37 -0
- package/dist/runtime/dashboard/components/block/dashboard-block-state.d.vue.ts +12 -0
- package/dist/runtime/dashboard/components/block/dashboard-block-state.vue +59 -0
- package/dist/runtime/dashboard/components/block/dashboard-block-state.vue.d.ts +12 -0
- package/dist/runtime/dashboard/components/block/dashboard-data-table.d.vue.ts +9 -0
- package/dist/runtime/dashboard/components/block/dashboard-data-table.vue +47 -0
- package/dist/runtime/dashboard/components/block/dashboard-data-table.vue.d.ts +9 -0
- package/dist/runtime/dashboard/components/block/dashboard-ring.d.vue.ts +34 -0
- package/dist/runtime/dashboard/components/block/dashboard-ring.vue +91 -0
- package/dist/runtime/dashboard/components/block/dashboard-ring.vue.d.ts +34 -0
- package/dist/runtime/dashboard/components/block/dashboard-row-actions.d.vue.ts +13 -0
- package/dist/runtime/dashboard/components/block/dashboard-row-actions.vue +49 -0
- package/dist/runtime/dashboard/components/block/dashboard-row-actions.vue.d.ts +13 -0
- package/dist/runtime/dashboard/components/block/dashboard-skeleton.d.vue.ts +34 -0
- package/dist/runtime/dashboard/components/block/dashboard-skeleton.vue +315 -0
- package/dist/runtime/dashboard/components/block/dashboard-skeleton.vue.d.ts +34 -0
- package/dist/runtime/dashboard/components/charts/renderer.d.ts +43 -0
- package/dist/runtime/dashboard/components/charts/renderer.js +34 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-donut-chart.d.vue.ts +18 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-donut-chart.vue +45 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-donut-chart.vue.d.ts +18 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-chart.d.vue.ts +14 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-chart.vue +190 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-chart.vue.d.ts +14 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-marks.d.vue.ts +13 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-marks.vue +72 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-marks.vue.d.ts +13 -0
- package/dist/runtime/dashboard/components/charts/unovis/xy-layers.d.ts +43 -0
- package/dist/runtime/dashboard/components/charts/unovis/xy-layers.js +60 -0
- package/dist/runtime/dashboard/components/dashboard-alerts.d.vue.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-alerts.vue +226 -0
- package/dist/runtime/dashboard/components/dashboard-alerts.vue.d.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-bar-chart.d.vue.ts +53 -0
- package/dist/runtime/dashboard/components/dashboard-bar-chart.vue +131 -0
- package/dist/runtime/dashboard/components/dashboard-bar-chart.vue.d.ts +53 -0
- package/dist/runtime/dashboard/components/dashboard-bars.d.vue.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-bars.vue +187 -0
- package/dist/runtime/dashboard/components/dashboard-bars.vue.d.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-card.d.vue.ts +47 -0
- package/dist/runtime/dashboard/components/dashboard-card.vue +316 -0
- package/dist/runtime/dashboard/components/dashboard-card.vue.d.ts +47 -0
- package/dist/runtime/dashboard/components/dashboard-combo-chart.d.vue.ts +52 -0
- package/dist/runtime/dashboard/components/dashboard-combo-chart.vue +128 -0
- package/dist/runtime/dashboard/components/dashboard-combo-chart.vue.d.ts +52 -0
- package/dist/runtime/dashboard/components/dashboard-donut-chart.d.vue.ts +48 -0
- package/dist/runtime/dashboard/components/dashboard-donut-chart.vue +216 -0
- package/dist/runtime/dashboard/components/dashboard-donut-chart.vue.d.ts +48 -0
- package/dist/runtime/dashboard/components/dashboard-feed.d.vue.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-feed.vue +239 -0
- package/dist/runtime/dashboard/components/dashboard-feed.vue.d.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-funnel.d.vue.ts +34 -0
- package/dist/runtime/dashboard/components/dashboard-funnel.vue +157 -0
- package/dist/runtime/dashboard/components/dashboard-funnel.vue.d.ts +34 -0
- package/dist/runtime/dashboard/components/dashboard-gauge.d.vue.ts +55 -0
- package/dist/runtime/dashboard/components/dashboard-gauge.vue +177 -0
- package/dist/runtime/dashboard/components/dashboard-gauge.vue.d.ts +55 -0
- package/dist/runtime/dashboard/components/dashboard-grid.d.vue.ts +38 -0
- package/dist/runtime/dashboard/components/dashboard-grid.vue +49 -0
- package/dist/runtime/dashboard/components/dashboard-grid.vue.d.ts +38 -0
- package/dist/runtime/dashboard/components/dashboard-legend.d.vue.ts +8 -0
- package/dist/runtime/dashboard/components/dashboard-legend.vue +37 -0
- package/dist/runtime/dashboard/components/dashboard-legend.vue.d.ts +8 -0
- package/dist/runtime/dashboard/components/dashboard-line-chart.d.vue.ts +46 -0
- package/dist/runtime/dashboard/components/dashboard-line-chart.vue +129 -0
- package/dist/runtime/dashboard/components/dashboard-line-chart.vue.d.ts +46 -0
- package/dist/runtime/dashboard/components/dashboard-list.d.vue.ts +63 -0
- package/dist/runtime/dashboard/components/dashboard-list.vue +239 -0
- package/dist/runtime/dashboard/components/dashboard-list.vue.d.ts +63 -0
- package/dist/runtime/dashboard/components/dashboard-paired-bars.d.vue.ts +43 -0
- package/dist/runtime/dashboard/components/dashboard-paired-bars.vue +194 -0
- package/dist/runtime/dashboard/components/dashboard-paired-bars.vue.d.ts +43 -0
- package/dist/runtime/dashboard/components/dashboard-refresh.d.vue.ts +29 -0
- package/dist/runtime/dashboard/components/dashboard-refresh.vue +86 -0
- package/dist/runtime/dashboard/components/dashboard-refresh.vue.d.ts +29 -0
- package/dist/runtime/dashboard/components/dashboard-relative-time.d.vue.ts +12 -0
- package/dist/runtime/dashboard/components/dashboard-relative-time.vue +23 -0
- package/dist/runtime/dashboard/components/dashboard-relative-time.vue.d.ts +12 -0
- package/dist/runtime/dashboard/components/dashboard-stack-bar.d.vue.ts +36 -0
- package/dist/runtime/dashboard/components/dashboard-stack-bar.vue +162 -0
- package/dist/runtime/dashboard/components/dashboard-stack-bar.vue.d.ts +36 -0
- package/dist/runtime/dashboard/components/dashboard-stat.d.vue.ts +69 -0
- package/dist/runtime/dashboard/components/dashboard-stat.vue +279 -0
- package/dist/runtime/dashboard/components/dashboard-stat.vue.d.ts +69 -0
- package/dist/runtime/dashboard/components/dashboard-stats.d.vue.ts +38 -0
- package/dist/runtime/dashboard/components/dashboard-stats.vue +202 -0
- package/dist/runtime/dashboard/components/dashboard-stats.vue.d.ts +38 -0
- package/dist/runtime/dashboard/components/dashboard-table.d.vue.ts +52 -0
- package/dist/runtime/dashboard/components/dashboard-table.vue +305 -0
- package/dist/runtime/dashboard/components/dashboard-table.vue.d.ts +52 -0
- package/dist/runtime/dashboard/components/dashboard-tabs.d.vue.ts +35 -0
- package/dist/runtime/dashboard/components/dashboard-tabs.vue +55 -0
- package/dist/runtime/dashboard/components/dashboard-tabs.vue.d.ts +35 -0
- package/dist/runtime/dashboard/components/dashboard-total.d.vue.ts +10 -0
- package/dist/runtime/dashboard/components/dashboard-total.vue +32 -0
- package/dist/runtime/dashboard/components/dashboard-total.vue.d.ts +10 -0
- package/dist/runtime/dashboard/components/dashboard-widget.d.vue.ts +46 -0
- package/dist/runtime/dashboard/components/dashboard-widget.vue +84 -0
- package/dist/runtime/dashboard/components/dashboard-widget.vue.d.ts +46 -0
- package/dist/runtime/dashboard/composables/use-dashboard-api.d.ts +15 -0
- package/dist/runtime/dashboard/composables/use-dashboard-api.js +91 -0
- package/dist/runtime/dashboard/composables/use-dashboard-block.d.ts +22 -0
- package/dist/runtime/dashboard/composables/use-dashboard-block.js +35 -0
- package/dist/runtime/dashboard/composables/use-dashboard-chart.d.ts +36 -0
- package/dist/runtime/dashboard/composables/use-dashboard-chart.js +118 -0
- package/dist/runtime/dashboard/composables/use-dashboard-derived.d.ts +12 -0
- package/dist/runtime/dashboard/composables/use-dashboard-derived.js +47 -0
- package/dist/runtime/dashboard/composables/use-dashboard-format.d.ts +6 -0
- package/dist/runtime/dashboard/composables/use-dashboard-format.js +12 -0
- package/dist/runtime/dashboard/composables/use-dashboard-options.d.ts +8 -0
- package/dist/runtime/dashboard/composables/use-dashboard-options.js +63 -0
- package/dist/runtime/dashboard/composables/use-dashboard-param-scope.d.ts +30 -0
- package/dist/runtime/dashboard/composables/use-dashboard-param-scope.js +71 -0
- package/dist/runtime/dashboard/composables/use-dashboard-remote-options.d.ts +12 -0
- package/dist/runtime/dashboard/composables/use-dashboard-remote-options.js +117 -0
- package/dist/runtime/dashboard/composables/use-dashboard-resource.d.ts +35 -0
- package/dist/runtime/dashboard/composables/use-dashboard-resource.js +80 -0
- package/dist/runtime/dashboard/composables/use-dashboard-scope.d.ts +46 -0
- package/dist/runtime/dashboard/composables/use-dashboard-scope.js +127 -0
- package/dist/runtime/dashboard/composables/use-dashboard-time.d.ts +13 -0
- package/dist/runtime/dashboard/composables/use-dashboard-time.js +40 -0
- package/dist/runtime/dashboard/composables/use-dashboard-ui.d.ts +22 -0
- package/dist/runtime/dashboard/composables/use-dashboard-ui.js +19 -0
- package/dist/runtime/dashboard/composables/use-dashboard-views.d.ts +46 -0
- package/dist/runtime/dashboard/composables/use-dashboard-views.js +49 -0
- package/dist/runtime/dashboard/composables/use-dashboard.d.ts +24 -0
- package/dist/runtime/dashboard/composables/use-dashboard.js +42 -0
- package/dist/runtime/dashboard/constants/query.d.ts +16 -0
- package/dist/runtime/dashboard/constants/query.js +15 -0
- package/dist/runtime/dashboard/index.d.ts +4 -0
- package/dist/runtime/dashboard/index.js +3 -0
- package/dist/runtime/dashboard/schema/index.d.ts +57 -0
- package/dist/runtime/dashboard/schema/index.js +3 -0
- package/dist/runtime/dashboard/types/blocks.d.ts +251 -0
- package/dist/runtime/dashboard/types/blocks.js +0 -0
- package/dist/runtime/dashboard/types/charts.d.ts +60 -0
- package/dist/runtime/dashboard/types/charts.js +0 -0
- package/dist/runtime/dashboard/types/index.d.ts +7 -0
- package/dist/runtime/dashboard/types/index.js +0 -0
- package/dist/runtime/dashboard/types/options.d.ts +46 -0
- package/dist/runtime/dashboard/types/options.js +0 -0
- package/dist/runtime/dashboard/types/params.d.ts +115 -0
- package/dist/runtime/dashboard/types/params.js +0 -0
- package/dist/runtime/dashboard/types/resource.d.ts +106 -0
- package/dist/runtime/dashboard/types/resource.js +0 -0
- package/dist/runtime/dashboard/types/runtime.d.ts +44 -0
- package/dist/runtime/dashboard/types/runtime.js +0 -0
- package/dist/runtime/dashboard/types/schema.d.ts +171 -0
- package/dist/runtime/dashboard/types/schema.js +0 -0
- package/dist/runtime/dashboard/types/ui.d.ts +201 -0
- package/dist/runtime/dashboard/types/ui.js +0 -0
- package/dist/runtime/dashboard/utils/builders/dashboard-params.d.ts +85 -0
- package/dist/runtime/dashboard/utils/builders/dashboard-params.js +87 -0
- package/dist/runtime/dashboard/utils/chart-frame.d.ts +5 -0
- package/dist/runtime/dashboard/utils/chart-frame.js +27 -0
- package/dist/runtime/dashboard/utils/charts.d.ts +61 -0
- package/dist/runtime/dashboard/utils/charts.js +142 -0
- package/dist/runtime/dashboard/utils/comparison.d.ts +15 -0
- package/dist/runtime/dashboard/utils/comparison.js +19 -0
- package/dist/runtime/dashboard/utils/export.d.ts +13 -0
- package/dist/runtime/dashboard/utils/export.js +45 -0
- package/dist/runtime/dashboard/utils/options.d.ts +5 -0
- package/dist/runtime/dashboard/utils/options.js +18 -0
- package/dist/runtime/dashboard/utils/params/codecs.d.ts +14 -0
- package/dist/runtime/dashboard/utils/params/codecs.js +69 -0
- package/dist/runtime/dashboard/utils/resource.d.ts +16 -0
- package/dist/runtime/dashboard/utils/resource.js +39 -0
- package/dist/runtime/dashboard/utils/schema.d.ts +9 -0
- package/dist/runtime/dashboard/utils/schema.js +31 -0
- package/dist/runtime/dashboard/utils/sparkline.d.ts +21 -0
- package/dist/runtime/dashboard/utils/sparkline.js +53 -0
- package/dist/runtime/dashboard/utils/state.d.ts +28 -0
- package/dist/runtime/dashboard/utils/state.js +32 -0
- package/dist/runtime/dashboard/utils/time.d.ts +17 -0
- package/dist/runtime/dashboard/utils/time.js +60 -0
- package/dist/runtime/dashboard/utils/tracker.d.ts +12 -0
- package/dist/runtime/dashboard/utils/tracker.js +31 -0
- package/dist/runtime/dashboard/utils/ui.d.ts +38 -0
- package/dist/runtime/dashboard/utils/ui.js +24 -0
- package/dist/runtime/dashboard/utils/visibility.d.ts +2 -0
- package/dist/runtime/dashboard/utils/visibility.js +25 -0
- package/dist/runtime/form/types/options.d.ts +15 -36
- package/dist/runtime/i18n/locales/en.js +65 -1
- package/dist/runtime/i18n/locales/fr.js +65 -1
- package/dist/runtime/i18n/types.d.ts +70 -0
- package/dist/runtime/shared/index.d.ts +2 -0
- package/dist/runtime/shared/styles/scrollbars.css +1 -1
- package/dist/runtime/shared/styles/tokens.css +1 -1
- package/dist/runtime/shared/types/query.d.ts +10 -0
- package/dist/runtime/shared/types/query.js +0 -0
- package/dist/runtime/shared/types/remote-options.d.ts +37 -0
- package/dist/runtime/shared/types/remote-options.js +0 -0
- package/dist/runtime/shared/utils/remote-options.d.ts +10 -0
- package/dist/runtime/shared/utils/remote-options.js +6 -0
- package/dist/runtime/spreadsheet/components/layout/spreadsheet-import-footer.d.vue.ts +2 -2
- package/dist/runtime/spreadsheet/components/layout/spreadsheet-import-footer.vue.d.ts +2 -2
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-internals.d.ts +15 -15
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-resolutions.d.ts +2 -2
- package/dist/runtime/spreadsheet/schema/normalize.d.ts +1 -1
- package/dist/runtime/spreadsheet/utils/references/sources.d.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-content.d.vue.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-content.vue.d.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-infinite-loader.d.vue.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-infinite-loader.vue.d.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-layout-switch.d.vue.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-layout-switch.vue.d.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-pagination.d.vue.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-pagination.vue.d.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-sort-menu.d.vue.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-sort-menu.vue.d.ts +1 -1
- package/dist/runtime/table/components/data-list/sort-menu-panel.d.vue.ts +2 -2
- package/dist/runtime/table/components/data-list/sort-menu-panel.vue.d.ts +2 -2
- package/dist/runtime/table/components/filters/shared/filter-match-mode-button.d.vue.ts +1 -1
- package/dist/runtime/table/components/filters/shared/filter-match-mode-button.vue.d.ts +1 -1
- package/dist/runtime/table/components/filters/shared/filter-option-list-end.d.vue.ts +11 -0
- package/dist/runtime/table/components/filters/shared/filter-option-list-end.vue +76 -0
- package/dist/runtime/table/components/filters/shared/filter-option-list-end.vue.d.ts +11 -0
- package/dist/runtime/table/components/filters/shared/filter-option-loading-list.d.vue.ts +3 -0
- package/dist/runtime/table/components/filters/shared/filter-option-loading-list.vue +2 -1
- package/dist/runtime/table/components/filters/shared/filter-option-loading-list.vue.d.ts +3 -0
- package/dist/runtime/table/components/filters/shared/filter-option-multiple-list.vue +1 -1
- package/dist/runtime/table/components/filters/shared/filter-option-picker-content.vue +13 -0
- package/dist/runtime/table/components/filters/shared/filter-option-single-list.d.vue.ts +2 -0
- package/dist/runtime/table/components/filters/shared/filter-option-single-list.vue +1 -1
- package/dist/runtime/table/components/filters/shared/filter-option-single-list.vue.d.ts +2 -0
- package/dist/runtime/table/components/filters/shared/filter-option-tree-content.d.vue.ts +3 -0
- package/dist/runtime/table/components/filters/shared/filter-option-tree-content.vue +2 -2
- package/dist/runtime/table/components/filters/shared/filter-option-tree-content.vue.d.ts +3 -0
- package/dist/runtime/table/components/filters/shared/filter-searchable-panel.vue +1 -0
- package/dist/runtime/table/components/layout/table-footer.d.vue.ts +1 -1
- package/dist/runtime/table/components/layout/table-footer.vue.d.ts +1 -1
- package/dist/runtime/table/components/table/table-cell-ellipsis.d.ts +1 -1
- package/dist/runtime/table/composables/use-option-filter-editor-state.d.ts +13 -1
- package/dist/runtime/table/composables/use-option-filter-editor-state.js +6 -2
- package/dist/runtime/table/composables/use-query-state.d.ts +3 -3
- package/dist/runtime/table/composables/use-table-columns.d.ts +3 -3
- package/dist/runtime/table/composables/use-table-filter-options.d.ts +11 -1
- package/dist/runtime/table/composables/use-table-filter-options.js +128 -17
- package/dist/runtime/table/composables/use-table-filter-selected-options.d.ts +20 -0
- package/dist/runtime/table/composables/use-table-filter-selected-options.js +99 -0
- package/dist/runtime/table/composables/use-table-filters.d.ts +5 -0
- package/dist/runtime/table/composables/use-table-filters.js +20 -1
- package/dist/runtime/table/composables/use-table-internals.d.ts +42 -27
- package/dist/runtime/table/composables/use-table-pagination.d.ts +2 -2
- package/dist/runtime/table/composables/use-table-remote-filter-options.d.ts +42 -0
- package/dist/runtime/table/composables/use-table-remote-filter-options.js +102 -0
- package/dist/runtime/table/composables/use-table-selection.d.ts +1 -1
- package/dist/runtime/table/composables/use-table-state.d.ts +3 -3
- package/dist/runtime/table/types/filters.d.ts +42 -0
- package/dist/runtime/table/types/source.d.ts +9 -5
- package/dist/runtime/table/utils/columns/menu.d.ts +1 -1
- package/dist/runtime/table/utils/columns/state.d.ts +1 -1
- package/dist/runtime/table/utils/data-list-ui.d.ts +1 -1
- package/dist/runtime/table/utils/filters/options.d.ts +2 -0
- package/dist/runtime/table/utils/filters/options.js +1 -1
- package/dist/runtime/table/utils/prefetch.js +21 -1
- package/package.json +28 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useQuery, useQueryClient } from "@tanstack/vue-query";
|
|
2
|
+
import { computed, shallowRef, watch } from "vue";
|
|
3
|
+
import { isBoolean, isNullish, isNumber, isString } from "../../shared/utils/predicate.js";
|
|
4
|
+
import { QUERY_DEFAULTS } from "../constants/query-state.js";
|
|
5
|
+
export function useTableFilterSelectedOptions(params) {
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
const known = shallowRef(/* @__PURE__ */ new Map());
|
|
8
|
+
const remoteDefinitions = computed(
|
|
9
|
+
() => params.definitions.value.flatMap((definition) => {
|
|
10
|
+
const remote = definition.kind === "option" ? definition.source?.remote : void 0;
|
|
11
|
+
return remote ? [{ key: definition.key, remote }] : [];
|
|
12
|
+
})
|
|
13
|
+
);
|
|
14
|
+
function selectedValues(key) {
|
|
15
|
+
const rule = params.rules.value.find((entry) => entry.key === key);
|
|
16
|
+
const values = Array.isArray(rule?.value) ? rule.value : isNullish(rule?.value) ? [] : [rule.value];
|
|
17
|
+
return values.filter(isPrimitiveValue);
|
|
18
|
+
}
|
|
19
|
+
const requests = computed(
|
|
20
|
+
() => remoteDefinitions.value.flatMap(({ key, remote }) => {
|
|
21
|
+
const cached = known.value.get(key);
|
|
22
|
+
const missing = selectedValues(key).filter((value) => !cached?.has(String(value)));
|
|
23
|
+
const query = missing.length ? resolveSelectedQuery(remote, missing) : void 0;
|
|
24
|
+
return query ? [{ key, query }] : [];
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
const hydration = useQuery(
|
|
28
|
+
computed(() => {
|
|
29
|
+
const snapshot = requests.value;
|
|
30
|
+
return {
|
|
31
|
+
enabled: snapshot.length > 0,
|
|
32
|
+
queryFn: () => Promise.all(
|
|
33
|
+
snapshot.map(async ({ key, query }) => ({
|
|
34
|
+
key,
|
|
35
|
+
options: await queryClient.fetchQuery({
|
|
36
|
+
queryFn: (context) => {
|
|
37
|
+
if (!query.queryFn) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
"resolveSelected must return a query definition with a queryFn."
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return query.queryFn({ ...context, direction: "forward", pageParam: null });
|
|
43
|
+
},
|
|
44
|
+
queryKey: query.queryKey,
|
|
45
|
+
staleTime: QUERY_DEFAULTS.staleTime.filterOptions
|
|
46
|
+
})
|
|
47
|
+
}))
|
|
48
|
+
),
|
|
49
|
+
queryKey: [
|
|
50
|
+
"table-filter-selected-options",
|
|
51
|
+
snapshot.map(({ key, query }) => [key, query.queryKey])
|
|
52
|
+
],
|
|
53
|
+
refetchOnWindowFocus: QUERY_DEFAULTS.refetchOnWindowFocus,
|
|
54
|
+
staleTime: QUERY_DEFAULTS.staleTime.filterOptions
|
|
55
|
+
};
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
watch(
|
|
59
|
+
() => hydration.data.value,
|
|
60
|
+
(results) => {
|
|
61
|
+
for (const result of results ?? []) remember(result.key, result.options);
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
function remember(key, options) {
|
|
65
|
+
const entries = flattenValueEntries(options);
|
|
66
|
+
if (!entries.length) return;
|
|
67
|
+
const current = known.value.get(key);
|
|
68
|
+
if (entries.every((entry) => current?.get(String(entry.value))?.label === entry.label)) return;
|
|
69
|
+
const next = new Map(current);
|
|
70
|
+
for (const entry of entries) next.set(String(entry.value), entry);
|
|
71
|
+
known.value = new Map(known.value).set(key, next);
|
|
72
|
+
}
|
|
73
|
+
function getSelectedOptions(key) {
|
|
74
|
+
const cached = known.value.get(key);
|
|
75
|
+
if (!cached) return [];
|
|
76
|
+
return selectedValues(key).flatMap((value) => {
|
|
77
|
+
const entry = cached.get(String(value));
|
|
78
|
+
return entry ? [entry] : [];
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
getSelectedOptions,
|
|
83
|
+
/** Options of committed values are resolving for this filter. */
|
|
84
|
+
isResolving: (key) => hydration.isFetching.value && requests.value.some((request) => request.key === key),
|
|
85
|
+
remember
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function resolveSelectedQuery(remote, values) {
|
|
89
|
+
return remote.resolveSelected?.({ values });
|
|
90
|
+
}
|
|
91
|
+
function flattenValueEntries(options) {
|
|
92
|
+
return options.flatMap((option) => [
|
|
93
|
+
...isNullish(option.value) ? [] : [{ ...option, value: option.value }],
|
|
94
|
+
...flattenValueEntries(option.children ?? [])
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
function isPrimitiveValue(value) {
|
|
98
|
+
return isString(value) || isNumber(value) || isBoolean(value);
|
|
99
|
+
}
|
|
@@ -71,6 +71,11 @@ export declare function useTableFilters(params: UseTableFiltersParams): {
|
|
|
71
71
|
}) => void;
|
|
72
72
|
searchPlaceholder: ComputedRef<string>;
|
|
73
73
|
searchQuery: import("vue").WritableComputedRef<string, string>;
|
|
74
|
+
selectedOptions: {
|
|
75
|
+
getSelectedOptions: (key: string) => import("../types/index.js").TableFilterOptionValueEntry[];
|
|
76
|
+
isResolving: (key: string) => boolean;
|
|
77
|
+
remember: (key: string, options: readonly TableFilterOptionEntry[]) => void;
|
|
78
|
+
};
|
|
74
79
|
setFilterOperator: (input: {
|
|
75
80
|
key: string;
|
|
76
81
|
operator: TableFilterOperator;
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
resolveTableFilterDefaultRules,
|
|
12
12
|
resolveFilterOptionEntries
|
|
13
13
|
} from "../utils/index.js";
|
|
14
|
+
import { useTableFilterSelectedOptions } from "./use-table-filter-selected-options.js";
|
|
14
15
|
import { useTableSearch } from "./use-table-search.js";
|
|
15
16
|
export function useTableFilters(params) {
|
|
16
17
|
const { t } = useUiToolsLocale();
|
|
@@ -34,6 +35,10 @@ export function useTableFilters(params) {
|
|
|
34
35
|
})
|
|
35
36
|
);
|
|
36
37
|
const hasActiveUiFilters = computed(() => activeUiFilters.value.length > 0);
|
|
38
|
+
const selectedOptions = useTableFilterSelectedOptions({
|
|
39
|
+
definitions,
|
|
40
|
+
rules: effectiveUiFilters
|
|
41
|
+
});
|
|
37
42
|
function getDefinition(input) {
|
|
38
43
|
return definitions.value.find(
|
|
39
44
|
(definition) => definition.key === input.key
|
|
@@ -87,7 +92,7 @@ export function useTableFilters(params) {
|
|
|
87
92
|
}
|
|
88
93
|
const preview = buildFilterPreview({
|
|
89
94
|
definition,
|
|
90
|
-
optionEntries: input.entries,
|
|
95
|
+
optionEntries: withSelectedOptions(input.key, input.entries),
|
|
91
96
|
rule: getFilterState({ key: input.key })
|
|
92
97
|
});
|
|
93
98
|
const rule = getFilterState({ key: input.key });
|
|
@@ -98,6 +103,19 @@ export function useTableFilters(params) {
|
|
|
98
103
|
dirty: !isNullish(getActiveFilterState({ key: input.key }))
|
|
99
104
|
};
|
|
100
105
|
}
|
|
106
|
+
function withSelectedOptions(key, entries = []) {
|
|
107
|
+
const listed = new Set(entries.map((entry) => String(entry.value)));
|
|
108
|
+
const missing = selectedOptions.getSelectedOptions(key).filter((entry) => !listed.has(String(entry.value)));
|
|
109
|
+
return missing.length ? [
|
|
110
|
+
...entries,
|
|
111
|
+
...missing.map((entry) => ({
|
|
112
|
+
color: entry.color,
|
|
113
|
+
icon: entry.icon,
|
|
114
|
+
label: getFilterLabelText({ label: entry.label }),
|
|
115
|
+
value: entry.value
|
|
116
|
+
}))
|
|
117
|
+
] : entries;
|
|
118
|
+
}
|
|
101
119
|
function getFilterOperator(input) {
|
|
102
120
|
const definition = getDefinition({ key: input.key });
|
|
103
121
|
const rule = getFilterState({ key: input.key });
|
|
@@ -253,6 +271,7 @@ export function useTableFilters(params) {
|
|
|
253
271
|
replaceFilters,
|
|
254
272
|
searchPlaceholder: search.searchPlaceholder,
|
|
255
273
|
searchQuery: search.searchQuery,
|
|
274
|
+
selectedOptions,
|
|
256
275
|
setFilterOperator,
|
|
257
276
|
setOptionFilterValues,
|
|
258
277
|
setScalarFilterValue,
|
|
@@ -191,6 +191,11 @@ declare function createTableInternals<TSchema>(options: {
|
|
|
191
191
|
}) => void;
|
|
192
192
|
searchPlaceholder: import("vue").ComputedRef<string>;
|
|
193
193
|
searchQuery: import("vue").WritableComputedRef<string, string>;
|
|
194
|
+
selectedOptions: {
|
|
195
|
+
getSelectedOptions: (key: string) => import("../types/index.js").TableFilterOptionValueEntry[];
|
|
196
|
+
isResolving: (key: string) => boolean;
|
|
197
|
+
remember: (key: string, options: readonly import("../types/index.js").TableFilterOptionEntry[]) => void;
|
|
198
|
+
};
|
|
194
199
|
setFilterOperator: (input: {
|
|
195
200
|
key: string;
|
|
196
201
|
operator: import("../types/index.js").TableFilterOperator;
|
|
@@ -240,7 +245,7 @@ declare function createTableInternals<TSchema>(options: {
|
|
|
240
245
|
loadMore: () => Promise<import("@tanstack/vue-query").InfiniteQueryObserverRefetchErrorResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverSuccessResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverLoadingErrorResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverPendingResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverPlaceholderResult<unknown, unknown> | undefined>;
|
|
241
246
|
loadMoreError: import("vue").ComputedRef<unknown>;
|
|
242
247
|
loadedCount: import("vue").ComputedRef<number>;
|
|
243
|
-
mode: import("vue").ComputedRef<"
|
|
248
|
+
mode: import("vue").ComputedRef<"cursor" | "none" | "offset">;
|
|
244
249
|
next: () => void;
|
|
245
250
|
noneState: import("vue").ComputedRef<{
|
|
246
251
|
loadedCount: number;
|
|
@@ -270,7 +275,7 @@ declare function createTableInternals<TSchema>(options: {
|
|
|
270
275
|
isLoadingMore: boolean;
|
|
271
276
|
loadMoreError: unknown;
|
|
272
277
|
loadedCount: number;
|
|
273
|
-
mode: "
|
|
278
|
+
mode: "cursor" | "none" | "offset";
|
|
274
279
|
pageCount: number;
|
|
275
280
|
pageIndex: number;
|
|
276
281
|
pageSize: number;
|
|
@@ -294,7 +299,7 @@ declare function createTableInternals<TSchema>(options: {
|
|
|
294
299
|
readonly pageSize?: undefined;
|
|
295
300
|
readonly pageIndex?: undefined;
|
|
296
301
|
} | {
|
|
297
|
-
readonly count: "
|
|
302
|
+
readonly count: "none" | "exact";
|
|
298
303
|
readonly cursor: null;
|
|
299
304
|
readonly mode: "cursor";
|
|
300
305
|
readonly pageSize: number;
|
|
@@ -306,7 +311,7 @@ declare function createTableInternals<TSchema>(options: {
|
|
|
306
311
|
readonly pageSize: number;
|
|
307
312
|
readonly cursor?: undefined;
|
|
308
313
|
}>;
|
|
309
|
-
paginationMode: "
|
|
314
|
+
paginationMode: "cursor" | "none" | "offset";
|
|
310
315
|
paginationRevision: import("vue").Ref<number, number>;
|
|
311
316
|
resetPagination: () => void;
|
|
312
317
|
setOffsetPagination: (value: {
|
|
@@ -314,7 +319,7 @@ declare function createTableInternals<TSchema>(options: {
|
|
|
314
319
|
pageSize: number;
|
|
315
320
|
}) => void;
|
|
316
321
|
sorting: import("vue").WritableComputedRef<{
|
|
317
|
-
dir: "
|
|
322
|
+
dir: "asc" | "desc";
|
|
318
323
|
key: string;
|
|
319
324
|
} | null, {
|
|
320
325
|
key: string;
|
|
@@ -325,7 +330,7 @@ declare function createTableInternals<TSchema>(options: {
|
|
|
325
330
|
schema: import("vue").ComputedRef<TableSchemaView>;
|
|
326
331
|
selection: {
|
|
327
332
|
allSelected: import("vue").ComputedRef<boolean>;
|
|
328
|
-
bulkScope: import("vue").Ref<"
|
|
333
|
+
bulkScope: import("vue").Ref<"all" | "selection", "all" | "selection">;
|
|
329
334
|
clearSelection: () => void;
|
|
330
335
|
getRowId: (params: {
|
|
331
336
|
row: import("../types/index.js").GenericObject;
|
|
@@ -394,10 +399,10 @@ declare function createTableInternals<TSchema>(options: {
|
|
|
394
399
|
}) => import("@nuxt/ui/runtime/components/DropdownMenu.d.vue.js").DropdownMenuItem[][];
|
|
395
400
|
getPinnedState: (options: {
|
|
396
401
|
columnId: string;
|
|
397
|
-
}) => "
|
|
402
|
+
}) => "left" | "right" | null;
|
|
398
403
|
getSortState: (options: {
|
|
399
404
|
columnId: string;
|
|
400
|
-
}) => "
|
|
405
|
+
}) => "asc" | "desc" | null;
|
|
401
406
|
orderedColumns: import("vue").ComputedRef<import("../utils/index.js").TableRuntimeColumn[]>;
|
|
402
407
|
reset: () => void;
|
|
403
408
|
runtimeColumns: import("vue").ComputedRef<import("../utils/index.js").TableRuntimeColumn[]>;
|
|
@@ -421,7 +426,7 @@ declare function createTableInternals<TSchema>(options: {
|
|
|
421
426
|
sortKeys: import("vue").ComputedRef<string[]>;
|
|
422
427
|
sortingState: import("vue").ComputedRef<{
|
|
423
428
|
active: boolean;
|
|
424
|
-
dir: "
|
|
429
|
+
dir: "asc" | "desc" | undefined;
|
|
425
430
|
key: string | undefined;
|
|
426
431
|
}>;
|
|
427
432
|
tableColumns: import("vue").ComputedRef<({
|
|
@@ -782,6 +787,11 @@ declare function useProvideTableInternals<TSchema>(options: {
|
|
|
782
787
|
}) => void;
|
|
783
788
|
searchPlaceholder: import("vue").ComputedRef<string>;
|
|
784
789
|
searchQuery: import("vue").WritableComputedRef<string, string>;
|
|
790
|
+
selectedOptions: {
|
|
791
|
+
getSelectedOptions: (key: string) => import("../types/index.js").TableFilterOptionValueEntry[];
|
|
792
|
+
isResolving: (key: string) => boolean;
|
|
793
|
+
remember: (key: string, options: readonly import("../types/index.js").TableFilterOptionEntry[]) => void;
|
|
794
|
+
};
|
|
785
795
|
setFilterOperator: (input: {
|
|
786
796
|
key: string;
|
|
787
797
|
operator: import("../types/index.js").TableFilterOperator;
|
|
@@ -831,7 +841,7 @@ declare function useProvideTableInternals<TSchema>(options: {
|
|
|
831
841
|
loadMore: () => Promise<import("@tanstack/vue-query").InfiniteQueryObserverRefetchErrorResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverSuccessResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverLoadingErrorResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverPendingResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverPlaceholderResult<unknown, unknown> | undefined>;
|
|
832
842
|
loadMoreError: import("vue").ComputedRef<unknown>;
|
|
833
843
|
loadedCount: import("vue").ComputedRef<number>;
|
|
834
|
-
mode: import("vue").ComputedRef<"
|
|
844
|
+
mode: import("vue").ComputedRef<"cursor" | "none" | "offset">;
|
|
835
845
|
next: () => void;
|
|
836
846
|
noneState: import("vue").ComputedRef<{
|
|
837
847
|
loadedCount: number;
|
|
@@ -861,7 +871,7 @@ declare function useProvideTableInternals<TSchema>(options: {
|
|
|
861
871
|
isLoadingMore: boolean;
|
|
862
872
|
loadMoreError: unknown;
|
|
863
873
|
loadedCount: number;
|
|
864
|
-
mode: "
|
|
874
|
+
mode: "cursor" | "none" | "offset";
|
|
865
875
|
pageCount: number;
|
|
866
876
|
pageIndex: number;
|
|
867
877
|
pageSize: number;
|
|
@@ -885,7 +895,7 @@ declare function useProvideTableInternals<TSchema>(options: {
|
|
|
885
895
|
readonly pageSize?: undefined;
|
|
886
896
|
readonly pageIndex?: undefined;
|
|
887
897
|
} | {
|
|
888
|
-
readonly count: "
|
|
898
|
+
readonly count: "none" | "exact";
|
|
889
899
|
readonly cursor: null;
|
|
890
900
|
readonly mode: "cursor";
|
|
891
901
|
readonly pageSize: number;
|
|
@@ -897,7 +907,7 @@ declare function useProvideTableInternals<TSchema>(options: {
|
|
|
897
907
|
readonly pageSize: number;
|
|
898
908
|
readonly cursor?: undefined;
|
|
899
909
|
}>;
|
|
900
|
-
paginationMode: "
|
|
910
|
+
paginationMode: "cursor" | "none" | "offset";
|
|
901
911
|
paginationRevision: import("vue").Ref<number, number>;
|
|
902
912
|
resetPagination: () => void;
|
|
903
913
|
setOffsetPagination: (value: {
|
|
@@ -905,7 +915,7 @@ declare function useProvideTableInternals<TSchema>(options: {
|
|
|
905
915
|
pageSize: number;
|
|
906
916
|
}) => void;
|
|
907
917
|
sorting: import("vue").WritableComputedRef<{
|
|
908
|
-
dir: "
|
|
918
|
+
dir: "asc" | "desc";
|
|
909
919
|
key: string;
|
|
910
920
|
} | null, {
|
|
911
921
|
key: string;
|
|
@@ -916,7 +926,7 @@ declare function useProvideTableInternals<TSchema>(options: {
|
|
|
916
926
|
schema: import("vue").ComputedRef<TableSchemaView>;
|
|
917
927
|
selection: {
|
|
918
928
|
allSelected: import("vue").ComputedRef<boolean>;
|
|
919
|
-
bulkScope: import("vue").Ref<"
|
|
929
|
+
bulkScope: import("vue").Ref<"all" | "selection", "all" | "selection">;
|
|
920
930
|
clearSelection: () => void;
|
|
921
931
|
getRowId: (params: {
|
|
922
932
|
row: import("../types/index.js").GenericObject;
|
|
@@ -985,10 +995,10 @@ declare function useProvideTableInternals<TSchema>(options: {
|
|
|
985
995
|
}) => import("@nuxt/ui/runtime/components/DropdownMenu.d.vue.js").DropdownMenuItem[][];
|
|
986
996
|
getPinnedState: (options: {
|
|
987
997
|
columnId: string;
|
|
988
|
-
}) => "
|
|
998
|
+
}) => "left" | "right" | null;
|
|
989
999
|
getSortState: (options: {
|
|
990
1000
|
columnId: string;
|
|
991
|
-
}) => "
|
|
1001
|
+
}) => "asc" | "desc" | null;
|
|
992
1002
|
orderedColumns: import("vue").ComputedRef<import("../utils/index.js").TableRuntimeColumn[]>;
|
|
993
1003
|
reset: () => void;
|
|
994
1004
|
runtimeColumns: import("vue").ComputedRef<import("../utils/index.js").TableRuntimeColumn[]>;
|
|
@@ -1012,7 +1022,7 @@ declare function useProvideTableInternals<TSchema>(options: {
|
|
|
1012
1022
|
sortKeys: import("vue").ComputedRef<string[]>;
|
|
1013
1023
|
sortingState: import("vue").ComputedRef<{
|
|
1014
1024
|
active: boolean;
|
|
1015
|
-
dir: "
|
|
1025
|
+
dir: "asc" | "desc" | undefined;
|
|
1016
1026
|
key: string | undefined;
|
|
1017
1027
|
}>;
|
|
1018
1028
|
tableColumns: import("vue").ComputedRef<({
|
|
@@ -1370,6 +1380,11 @@ declare function useTableInternals(): {
|
|
|
1370
1380
|
}) => void;
|
|
1371
1381
|
searchPlaceholder: import("vue").ComputedRef<string>;
|
|
1372
1382
|
searchQuery: import("vue").WritableComputedRef<string, string>;
|
|
1383
|
+
selectedOptions: {
|
|
1384
|
+
getSelectedOptions: (key: string) => import("../types/index.js").TableFilterOptionValueEntry[];
|
|
1385
|
+
isResolving: (key: string) => boolean;
|
|
1386
|
+
remember: (key: string, options: readonly import("../types/index.js").TableFilterOptionEntry[]) => void;
|
|
1387
|
+
};
|
|
1373
1388
|
setFilterOperator: (input: {
|
|
1374
1389
|
key: string;
|
|
1375
1390
|
operator: import("../types/index.js").TableFilterOperator;
|
|
@@ -1419,7 +1434,7 @@ declare function useTableInternals(): {
|
|
|
1419
1434
|
loadMore: () => Promise<import("@tanstack/vue-query").InfiniteQueryObserverRefetchErrorResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverSuccessResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverLoadingErrorResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverPendingResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverPlaceholderResult<unknown, unknown> | undefined>;
|
|
1420
1435
|
loadMoreError: import("vue").ComputedRef<unknown>;
|
|
1421
1436
|
loadedCount: import("vue").ComputedRef<number>;
|
|
1422
|
-
mode: import("vue").ComputedRef<"
|
|
1437
|
+
mode: import("vue").ComputedRef<"cursor" | "none" | "offset">;
|
|
1423
1438
|
next: () => void;
|
|
1424
1439
|
noneState: import("vue").ComputedRef<{
|
|
1425
1440
|
loadedCount: number;
|
|
@@ -1449,7 +1464,7 @@ declare function useTableInternals(): {
|
|
|
1449
1464
|
isLoadingMore: boolean;
|
|
1450
1465
|
loadMoreError: unknown;
|
|
1451
1466
|
loadedCount: number;
|
|
1452
|
-
mode: "
|
|
1467
|
+
mode: "cursor" | "none" | "offset";
|
|
1453
1468
|
pageCount: number;
|
|
1454
1469
|
pageIndex: number;
|
|
1455
1470
|
pageSize: number;
|
|
@@ -1473,7 +1488,7 @@ declare function useTableInternals(): {
|
|
|
1473
1488
|
readonly pageSize?: undefined;
|
|
1474
1489
|
readonly pageIndex?: undefined;
|
|
1475
1490
|
} | {
|
|
1476
|
-
readonly count: "
|
|
1491
|
+
readonly count: "none" | "exact";
|
|
1477
1492
|
readonly cursor: null;
|
|
1478
1493
|
readonly mode: "cursor";
|
|
1479
1494
|
readonly pageSize: number;
|
|
@@ -1485,7 +1500,7 @@ declare function useTableInternals(): {
|
|
|
1485
1500
|
readonly pageSize: number;
|
|
1486
1501
|
readonly cursor?: undefined;
|
|
1487
1502
|
}>;
|
|
1488
|
-
paginationMode: "
|
|
1503
|
+
paginationMode: "cursor" | "none" | "offset";
|
|
1489
1504
|
paginationRevision: import("vue").Ref<number, number>;
|
|
1490
1505
|
resetPagination: () => void;
|
|
1491
1506
|
setOffsetPagination: (value: {
|
|
@@ -1493,7 +1508,7 @@ declare function useTableInternals(): {
|
|
|
1493
1508
|
pageSize: number;
|
|
1494
1509
|
}) => void;
|
|
1495
1510
|
sorting: import("vue").WritableComputedRef<{
|
|
1496
|
-
dir: "
|
|
1511
|
+
dir: "asc" | "desc";
|
|
1497
1512
|
key: string;
|
|
1498
1513
|
} | null, {
|
|
1499
1514
|
key: string;
|
|
@@ -1504,7 +1519,7 @@ declare function useTableInternals(): {
|
|
|
1504
1519
|
schema: import("vue").ComputedRef<TableSchemaView>;
|
|
1505
1520
|
selection: {
|
|
1506
1521
|
allSelected: import("vue").ComputedRef<boolean>;
|
|
1507
|
-
bulkScope: import("vue").Ref<"
|
|
1522
|
+
bulkScope: import("vue").Ref<"all" | "selection", "all" | "selection">;
|
|
1508
1523
|
clearSelection: () => void;
|
|
1509
1524
|
getRowId: (params: {
|
|
1510
1525
|
row: import("../types/index.js").GenericObject;
|
|
@@ -1573,10 +1588,10 @@ declare function useTableInternals(): {
|
|
|
1573
1588
|
}) => import("@nuxt/ui/runtime/components/DropdownMenu.d.vue.js").DropdownMenuItem[][];
|
|
1574
1589
|
getPinnedState: (options: {
|
|
1575
1590
|
columnId: string;
|
|
1576
|
-
}) => "
|
|
1591
|
+
}) => "left" | "right" | null;
|
|
1577
1592
|
getSortState: (options: {
|
|
1578
1593
|
columnId: string;
|
|
1579
|
-
}) => "
|
|
1594
|
+
}) => "asc" | "desc" | null;
|
|
1580
1595
|
orderedColumns: import("vue").ComputedRef<import("../utils/index.js").TableRuntimeColumn[]>;
|
|
1581
1596
|
reset: () => void;
|
|
1582
1597
|
runtimeColumns: import("vue").ComputedRef<import("../utils/index.js").TableRuntimeColumn[]>;
|
|
@@ -1600,7 +1615,7 @@ declare function useTableInternals(): {
|
|
|
1600
1615
|
sortKeys: import("vue").ComputedRef<string[]>;
|
|
1601
1616
|
sortingState: import("vue").ComputedRef<{
|
|
1602
1617
|
active: boolean;
|
|
1603
|
-
dir: "
|
|
1618
|
+
dir: "asc" | "desc" | undefined;
|
|
1604
1619
|
key: string | undefined;
|
|
1605
1620
|
}>;
|
|
1606
1621
|
tableColumns: import("vue").ComputedRef<({
|
|
@@ -25,7 +25,7 @@ export declare function useTablePagination(options: UseTablePaginationParams): {
|
|
|
25
25
|
loadMore: () => Promise<import("@tanstack/vue-query").InfiniteQueryObserverRefetchErrorResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverSuccessResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverLoadingErrorResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverPendingResult<unknown, unknown> | import("@tanstack/vue-query").InfiniteQueryObserverPlaceholderResult<unknown, unknown> | undefined>;
|
|
26
26
|
loadMoreError: ComputedRef<unknown>;
|
|
27
27
|
loadedCount: ComputedRef<number>;
|
|
28
|
-
mode: ComputedRef<"
|
|
28
|
+
mode: ComputedRef<"cursor" | "none" | "offset">;
|
|
29
29
|
next: () => void;
|
|
30
30
|
noneState: ComputedRef<{
|
|
31
31
|
loadedCount: number;
|
|
@@ -55,7 +55,7 @@ export declare function useTablePagination(options: UseTablePaginationParams): {
|
|
|
55
55
|
isLoadingMore: boolean;
|
|
56
56
|
loadMoreError: unknown;
|
|
57
57
|
loadedCount: number;
|
|
58
|
-
mode: "
|
|
58
|
+
mode: "cursor" | "none" | "offset";
|
|
59
59
|
pageCount: number;
|
|
60
60
|
pageIndex: number;
|
|
61
61
|
pageSize: number;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { InfiniteData } from '@tanstack/vue-query';
|
|
2
|
+
import type { ComputedRef } from 'vue';
|
|
3
|
+
import type { RemoteOptionsResult } from '../../shared/types/remote-options.js';
|
|
4
|
+
import type { RemoteOptionsPageParam } from '../../shared/utils/remote-options.js';
|
|
5
|
+
import type { TableFilterOptionEntry, TableFilterRemoteOptions } from '../types/index.js';
|
|
6
|
+
type RemotePage = RemoteOptionsResult<TableFilterOptionEntry>;
|
|
7
|
+
/** Defaults of `source.remote` on option filters, matching the form engine's remote options. */
|
|
8
|
+
export declare const TABLE_REMOTE_FILTER_OPTIONS_DEFAULTS: {
|
|
9
|
+
readonly pageSize: 25;
|
|
10
|
+
readonly searchDebounce: 250;
|
|
11
|
+
};
|
|
12
|
+
export interface UseTableRemoteFilterOptionsParams {
|
|
13
|
+
config: ComputedRef<TableFilterRemoteOptions | undefined>;
|
|
14
|
+
/** Raw search input; it is trimmed and debounced before it reaches the source. */
|
|
15
|
+
search: ComputedRef<string>;
|
|
16
|
+
/** Pages load only while an editor shows the list. */
|
|
17
|
+
enabled: ComputedRef<boolean>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Pages of a remote option filter. Nothing loads until an editor shows the list; each search term
|
|
21
|
+
* keeps its own pages in the TanStack Query cache, and the previous term's pages stay on screen
|
|
22
|
+
* while the next term loads.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useTableRemoteFilterOptions(params: UseTableRemoteFilterOptionsParams): {
|
|
25
|
+
entries: ComputedRef<readonly TableFilterOptionEntry[]>;
|
|
26
|
+
error: import("vue").Ref<null, null> | import("vue").Ref<Error, Error>;
|
|
27
|
+
/** More pages exist after the loaded ones. */
|
|
28
|
+
hasMore: ComputedRef<boolean>;
|
|
29
|
+
/** The first page of the current term has not arrived yet. */
|
|
30
|
+
isLoading: ComputedRef<boolean>;
|
|
31
|
+
/** A new term, or a refetch, is loading while earlier options stay on screen. */
|
|
32
|
+
isRefreshing: ComputedRef<boolean>;
|
|
33
|
+
/** The next page is loading at the end of the list. */
|
|
34
|
+
loadingMore: ComputedRef<boolean>;
|
|
35
|
+
/** The last request failed: the next page (or the first) can be retried. */
|
|
36
|
+
failed: ComputedRef<boolean>;
|
|
37
|
+
loadMore: () => void;
|
|
38
|
+
pageValues: ComputedRef<(string | number | boolean)[][]>;
|
|
39
|
+
prefetchDistance: ComputedRef<number | "viewport">;
|
|
40
|
+
retry: () => Promise<import("@tanstack/vue-query").QueryObserverResult<InfiniteData<RemotePage, RemoteOptionsPageParam>, Error>>;
|
|
41
|
+
};
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useInfiniteQuery } from "@tanstack/vue-query";
|
|
2
|
+
import { refDebounced } from "@vueuse/core";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import {
|
|
5
|
+
REMOTE_OPTIONS_FIRST_PAGE,
|
|
6
|
+
resolveRemoteOptionsNextPage
|
|
7
|
+
} from "../../shared/utils/remote-options.js";
|
|
8
|
+
import { QUERY_DEFAULTS } from "../constants/query-state.js";
|
|
9
|
+
export const TABLE_REMOTE_FILTER_OPTIONS_DEFAULTS = {
|
|
10
|
+
pageSize: 25,
|
|
11
|
+
searchDebounce: 250
|
|
12
|
+
};
|
|
13
|
+
export function useTableRemoteFilterOptions(params) {
|
|
14
|
+
const pageSize = computed(
|
|
15
|
+
() => Math.max(
|
|
16
|
+
1,
|
|
17
|
+
params.config.value?.pagination?.size ?? TABLE_REMOTE_FILTER_OPTIONS_DEFAULTS.pageSize
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
const minLength = computed(() => Math.max(0, params.config.value?.search?.minLength ?? 0));
|
|
21
|
+
const search = refDebounced(
|
|
22
|
+
computed(() => params.search.value.trim()),
|
|
23
|
+
() => params.config.value?.search?.debounce ?? TABLE_REMOTE_FILTER_OPTIONS_DEFAULTS.searchDebounce
|
|
24
|
+
);
|
|
25
|
+
const canFetch = computed(
|
|
26
|
+
() => search.value.length === 0 || search.value.length >= minLength.value
|
|
27
|
+
);
|
|
28
|
+
const pages = useInfiniteQuery(
|
|
29
|
+
computed(() => {
|
|
30
|
+
const config = params.config.value;
|
|
31
|
+
const term = search.value;
|
|
32
|
+
const size = pageSize.value;
|
|
33
|
+
const firstPage = config?.load({ page: { ...REMOTE_OPTIONS_FIRST_PAGE, size }, search: term });
|
|
34
|
+
return {
|
|
35
|
+
enabled: Boolean(config) && params.enabled.value && canFetch.value,
|
|
36
|
+
getNextPageParam: (lastPage, allPages) => resolveRemoteOptionsNextPage(lastPage, allPages.length),
|
|
37
|
+
initialPageParam: REMOTE_OPTIONS_FIRST_PAGE,
|
|
38
|
+
// Keeps the previous term's options on screen while the next term loads.
|
|
39
|
+
placeholderData: (previous) => previous,
|
|
40
|
+
async queryFn(queryContext) {
|
|
41
|
+
const definition = config?.load({
|
|
42
|
+
page: { ...queryContext.pageParam, size },
|
|
43
|
+
search: term
|
|
44
|
+
});
|
|
45
|
+
if (!definition?.queryFn) {
|
|
46
|
+
throw new Error("Remote option filters must return a query definition with a queryFn.");
|
|
47
|
+
}
|
|
48
|
+
return definition.queryFn({
|
|
49
|
+
...queryContext,
|
|
50
|
+
direction: "forward",
|
|
51
|
+
pageParam: null,
|
|
52
|
+
queryKey: definition.queryKey
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
queryKey: [
|
|
56
|
+
...firstPage?.queryKey ?? ["table-filter-remote-options", "disabled"],
|
|
57
|
+
{ tableFilterOptionPages: size }
|
|
58
|
+
],
|
|
59
|
+
refetchOnWindowFocus: QUERY_DEFAULTS.refetchOnWindowFocus,
|
|
60
|
+
staleTime: QUERY_DEFAULTS.staleTime.filterOptions
|
|
61
|
+
};
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
const entries = computed(
|
|
65
|
+
() => pages.data.value?.pages.flatMap((page) => page.options) ?? []
|
|
66
|
+
);
|
|
67
|
+
const pageValues = computed(
|
|
68
|
+
() => pages.data.value?.pages.map((page) => collectOptionValues(page.options)) ?? []
|
|
69
|
+
);
|
|
70
|
+
function loadMore() {
|
|
71
|
+
if (!pages.hasNextPage.value || pages.isFetchingNextPage.value || pages.isFetching.value) return;
|
|
72
|
+
void pages.fetchNextPage();
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
entries,
|
|
76
|
+
error: pages.error,
|
|
77
|
+
/** More pages exist after the loaded ones. */
|
|
78
|
+
hasMore: computed(() => pages.hasNextPage.value),
|
|
79
|
+
/** The first page of the current term has not arrived yet. */
|
|
80
|
+
isLoading: computed(() => pages.isLoading.value && !pages.isPlaceholderData.value),
|
|
81
|
+
/** A new term, or a refetch, is loading while earlier options stay on screen. */
|
|
82
|
+
isRefreshing: computed(
|
|
83
|
+
() => pages.isFetching.value && !pages.isFetchingNextPage.value && !pages.isLoading.value
|
|
84
|
+
),
|
|
85
|
+
/** The next page is loading at the end of the list. */
|
|
86
|
+
loadingMore: computed(() => pages.isFetchingNextPage.value),
|
|
87
|
+
/** The last request failed: the next page (or the first) can be retried. */
|
|
88
|
+
failed: computed(() => pages.isError.value || pages.isFetchNextPageError.value),
|
|
89
|
+
loadMore,
|
|
90
|
+
pageValues,
|
|
91
|
+
prefetchDistance: computed(
|
|
92
|
+
() => params.config.value?.pagination?.prefetchDistance ?? "viewport"
|
|
93
|
+
),
|
|
94
|
+
retry: () => pages.isFetchNextPageError.value ? pages.fetchNextPage() : pages.refetch()
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function collectOptionValues(options) {
|
|
98
|
+
return options.flatMap((option) => [
|
|
99
|
+
...option.value === void 0 ? [] : [option.value],
|
|
100
|
+
...collectOptionValues(option.children ?? [])
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
@@ -7,7 +7,7 @@ export interface UseTableSelectionParams {
|
|
|
7
7
|
}
|
|
8
8
|
export declare function useTableSelection(options: UseTableSelectionParams): {
|
|
9
9
|
allSelected: ComputedRef<boolean>;
|
|
10
|
-
bulkScope: import("vue").Ref<"
|
|
10
|
+
bulkScope: import("vue").Ref<"all" | "selection", "all" | "selection">;
|
|
11
11
|
clearSelection: () => void;
|
|
12
12
|
getRowId: (params: {
|
|
13
13
|
row: GenericObject;
|
|
@@ -21,7 +21,7 @@ export declare function useTableState(params: UseTableStateParams): {
|
|
|
21
21
|
readonly pageSize?: undefined;
|
|
22
22
|
readonly pageIndex?: undefined;
|
|
23
23
|
} | {
|
|
24
|
-
readonly count: "
|
|
24
|
+
readonly count: "none" | "exact";
|
|
25
25
|
readonly cursor: null;
|
|
26
26
|
readonly mode: "cursor";
|
|
27
27
|
readonly pageSize: number;
|
|
@@ -33,7 +33,7 @@ export declare function useTableState(params: UseTableStateParams): {
|
|
|
33
33
|
readonly pageSize: number;
|
|
34
34
|
readonly cursor?: undefined;
|
|
35
35
|
}>;
|
|
36
|
-
paginationMode: "
|
|
36
|
+
paginationMode: "cursor" | "none" | "offset";
|
|
37
37
|
paginationRevision: import("vue").Ref<number, number>;
|
|
38
38
|
resetPagination: () => void;
|
|
39
39
|
setOffsetPagination: (value: {
|
|
@@ -41,7 +41,7 @@ export declare function useTableState(params: UseTableStateParams): {
|
|
|
41
41
|
pageSize: number;
|
|
42
42
|
}) => void;
|
|
43
43
|
sorting: import("vue").WritableComputedRef<{
|
|
44
|
-
dir: "
|
|
44
|
+
dir: "asc" | "desc";
|
|
45
45
|
key: string;
|
|
46
46
|
} | null, {
|
|
47
47
|
key: string;
|