nuxt-ui-tools 1.1.0 → 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.json +1 -1
- package/dist/runtime/dashboard/components/block/dashboard-skeleton.vue +6 -3
- package/dist/runtime/dashboard/components/dashboard-feed.vue +7 -6
- package/dist/runtime/dashboard/composables/use-dashboard-remote-options.js +7 -7
- package/dist/runtime/dashboard/utils/options.d.ts +0 -7
- package/dist/runtime/dashboard/utils/options.js +0 -5
- package/dist/runtime/i18n/locales/en.js +3 -1
- package/dist/runtime/i18n/locales/fr.js +3 -1
- package/dist/runtime/i18n/types.d.ts +3 -0
- package/dist/runtime/shared/styles/scrollbars.css +1 -1
- package/dist/runtime/shared/utils/remote-options.d.ts +10 -0
- package/dist/runtime/shared/utils/remote-options.js +6 -0
- 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/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-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 +15 -0
- 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/types/filters.d.ts +42 -0
- package/dist/runtime/table/types/source.d.ts +5 -0
- 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 +1 -1
|
@@ -62,6 +62,11 @@ export interface TableFacetRequestDescriptor<TKey extends string = string> {
|
|
|
62
62
|
search?: string;
|
|
63
63
|
limit?: number;
|
|
64
64
|
cursor?: string | null;
|
|
65
|
+
/**
|
|
66
|
+
* Values to count, and only these. Filters loading options page by page (`source.remote`) send
|
|
67
|
+
* the values of one loaded page, since no single request can know every value.
|
|
68
|
+
*/
|
|
69
|
+
values?: readonly (string | number | boolean)[];
|
|
65
70
|
}
|
|
66
71
|
export interface TableFacetOptionResult<TValue = unknown> {
|
|
67
72
|
value: TValue;
|
|
@@ -10,6 +10,8 @@ export declare function resolveFilterOptionEntries(options: {
|
|
|
10
10
|
count: number;
|
|
11
11
|
}[];
|
|
12
12
|
missingCountFallback?: number;
|
|
13
|
+
/** `options` is the complete answer (remote pages): an empty list stays empty instead of listing facet values. */
|
|
14
|
+
authoritative?: boolean;
|
|
13
15
|
}): TableResolvedFilterOptionEntry<import("../../types/index.js").TableFilterPrimitiveValue>[] | {
|
|
14
16
|
children: never[];
|
|
15
17
|
count: number | undefined;
|
|
@@ -21,7 +21,7 @@ export function resolveFilterOptionEntries(options) {
|
|
|
21
21
|
return [];
|
|
22
22
|
}
|
|
23
23
|
const configuredOptions = options.options ?? options.definition.source?.options ?? [];
|
|
24
|
-
const sourceOptions = configuredOptions.length ? configuredOptions : (options.facetCounts ?? []).map((entry) => ({
|
|
24
|
+
const sourceOptions = configuredOptions.length || options.authoritative ? configuredOptions : (options.facetCounts ?? []).map((entry) => ({
|
|
25
25
|
count: entry.count,
|
|
26
26
|
label: String(entry.value),
|
|
27
27
|
value: entry.value
|
|
@@ -40,7 +40,11 @@ export function prefetchTable(params) {
|
|
|
40
40
|
route: params.route,
|
|
41
41
|
schema
|
|
42
42
|
});
|
|
43
|
-
return resolveTableQueries({
|
|
43
|
+
return resolveTableQueries({
|
|
44
|
+
request,
|
|
45
|
+
rules: resolveFilterState(params.route, schema).ui,
|
|
46
|
+
schema
|
|
47
|
+
});
|
|
44
48
|
}).stage((stageContext) => {
|
|
45
49
|
const rows = resolvePrefetchedRows(stageContext.source);
|
|
46
50
|
const context = resolveContextData(schema, stageContext);
|
|
@@ -93,6 +97,13 @@ function resolveTableQueries(options) {
|
|
|
93
97
|
]);
|
|
94
98
|
}
|
|
95
99
|
for (const definition of definitions) {
|
|
100
|
+
const selectedOptions = resolveRemoteSelectedQuery(definition, options.rules);
|
|
101
|
+
if (selectedOptions) {
|
|
102
|
+
entries.push([
|
|
103
|
+
`filter-selected-options:${definition.key}`,
|
|
104
|
+
withQueryDefaults(selectedOptions, QUERY_DEFAULTS.staleTime.filterOptions)
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
96
107
|
if (definition.kind === "option" && isOptionQueryResolver(definition.source?.query)) {
|
|
97
108
|
entries.push([
|
|
98
109
|
`filter-options:${definition.key}`,
|
|
@@ -130,6 +141,15 @@ function resolveTableQueries(options) {
|
|
|
130
141
|
}
|
|
131
142
|
return Object.fromEntries(entries);
|
|
132
143
|
}
|
|
144
|
+
function resolveRemoteSelectedQuery(definition, rules) {
|
|
145
|
+
const resolve = definition.kind === "option" ? definition.source?.remote?.resolveSelected : void 0;
|
|
146
|
+
if (!resolve) return;
|
|
147
|
+
const rule = rules.find((entry) => entry.key === definition.key);
|
|
148
|
+
const values = (Array.isArray(rule?.value) ? rule.value : isNullish(rule?.value) ? [] : [rule.value]).filter(
|
|
149
|
+
(value) => isString(value) || isNumber(value) || isBoolean(value)
|
|
150
|
+
);
|
|
151
|
+
return values.length ? resolve({ values }) : void 0;
|
|
152
|
+
}
|
|
133
153
|
function resolveSourcePrefetchQuery(options) {
|
|
134
154
|
const definition = options.schema.source.mode === "remote" ? options.schema.source.query(
|
|
135
155
|
toTableRemoteSourceRequest(options.request),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-ui-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Nuxt module and runtime toolkit for UI-heavy Nuxt applications",
|
|
5
5
|
"homepage": "https://github.com/ChronicStone/nuxt-ui-tools#readme",
|
|
6
6
|
"bugs": "https://github.com/ChronicStone/nuxt-ui-tools/issues",
|