nuxt-ui-tools 1.0.0 → 1.0.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.
- package/dist/module.json +1 -1
- package/dist/runtime/form/components/root/form.vue +1 -1
- package/dist/runtime/form/composables/use-form-validation.d.ts +2 -3
- package/dist/runtime/form/composables/use-form-validation.js +24 -112
- package/dist/runtime/form/composables/use-form.js +1 -1
- package/dist/runtime/form/fields/password/component.vue +132 -28
- package/dist/runtime/form/fields/password/types.d.ts +6 -0
- package/dist/runtime/form/fields/text/component.vue +7 -2
- package/dist/runtime/form/types/field.d.ts +1 -1
- package/dist/runtime/form/types/validation.d.ts +3 -20
- package/dist/runtime/form/utils/state.d.ts +1 -14
- package/dist/runtime/form/utils/state.js +0 -199
- package/dist/runtime/i18n/locales/en.js +1 -0
- package/dist/runtime/i18n/locales/fr.js +1 -0
- package/dist/runtime/i18n/types.d.ts +1 -0
- package/dist/runtime/table/components/data-list/data-list-content.d.vue.ts +19 -17
- package/dist/runtime/table/components/data-list/data-list-content.vue +14 -87
- package/dist/runtime/table/components/data-list/data-list-content.vue.d.ts +19 -17
- package/dist/runtime/table/components/data-list/data-list-default.d.vue.ts +1 -4
- package/dist/runtime/table/components/data-list/data-list-default.vue.d.ts +1 -4
- package/dist/runtime/table/components/data-list/data-list-error-state.d.vue.ts +13 -0
- package/dist/runtime/table/components/data-list/data-list-error-state.vue +91 -0
- package/dist/runtime/table/components/data-list/data-list-error-state.vue.d.ts +13 -0
- package/dist/runtime/table/components/data-list/data-list-layout-switch.vue +1 -1
- package/dist/runtime/table/components/data-list/data-list-refresh.vue +42 -4
- package/dist/runtime/table/components/data-list/data-list-root.d.vue.ts +1 -9
- package/dist/runtime/table/components/data-list/data-list-root.vue.d.ts +1 -9
- package/dist/runtime/table/components/data-list/data-list-sort-menu.vue +11 -5
- package/dist/runtime/table/components/data-list.d.vue.ts +2 -13
- package/dist/runtime/table/components/data-list.vue.d.ts +2 -13
- package/dist/runtime/table/components/drawers/column-panel.vue +7 -2
- package/dist/runtime/table/components/filters/panel/filter-panel-chips.vue +2 -5
- package/dist/runtime/table/components/filters/panel/option-filter-panel-field.vue +1 -1
- package/dist/runtime/table/components/filters/shared/dynamic-filter-picker.d.vue.ts +2 -2
- package/dist/runtime/table/components/filters/shared/dynamic-filter-picker.vue +103 -101
- package/dist/runtime/table/components/filters/shared/dynamic-filter-picker.vue.d.ts +2 -2
- package/dist/runtime/table/components/filters/shared/filter-option-multiple-list.vue +2 -2
- package/dist/runtime/table/components/filters/shared/filter-option-picker-content.vue +3 -3
- package/dist/runtime/table/components/filters/shared/filter-option-single-list.vue +1 -1
- package/dist/runtime/table/components/filters/shared/filter-popover-shell.d.vue.ts +3 -3
- package/dist/runtime/table/components/filters/shared/filter-popover-shell.vue +17 -15
- package/dist/runtime/table/components/filters/shared/filter-popover-shell.vue.d.ts +3 -3
- package/dist/runtime/table/components/filters/shared/filter-searchable-panel.vue +10 -2
- package/dist/runtime/table/components/filters/sheet/filter-sheet.vue +4 -3
- package/dist/runtime/table/components/filters/tags/filter-tags-bar.vue +1 -1
- package/dist/runtime/table/components/grid/grid-renderer.vue +2 -4
- package/dist/runtime/table/components/table/table-renderer.d.vue.ts +8 -2
- package/dist/runtime/table/components/table/table-renderer.vue +24 -6
- package/dist/runtime/table/components/table/table-renderer.vue.d.ts +8 -2
- package/dist/runtime/table/composables/use-option-filter-editor-state.d.ts +1 -0
- package/dist/runtime/table/composables/use-option-filter-editor-state.js +2 -2
- package/dist/runtime/table/composables/use-table-actions.js +10 -5
- package/dist/runtime/table/composables/use-table-api.js +4 -1
- package/dist/runtime/table/composables/use-table-columns.d.ts +6 -2
- package/dist/runtime/table/composables/use-table-data.d.ts +2 -1
- package/dist/runtime/table/composables/use-table-data.js +19 -2
- package/dist/runtime/table/composables/use-table-filter-options.d.ts +1 -0
- package/dist/runtime/table/composables/use-table-filter-options.js +2 -1
- package/dist/runtime/table/composables/use-table-internals.d.ts +18 -6
- package/dist/runtime/table/types/actions.d.ts +3 -2
- package/dist/runtime/table/types/data-list.d.ts +8 -0
- package/dist/runtime/table/types/source.d.ts +10 -1
- package/dist/runtime/table/utils/builders/table-source.d.ts +14 -15
- package/dist/runtime/table/utils/client-query.d.ts +1 -1
- package/dist/runtime/table/utils/columns/render.d.ts +13 -5
- package/dist/runtime/table/utils/columns/render.js +3 -2
- package/dist/runtime/table/utils/filters/editor-size.js +9 -9
- package/dist/runtime/table/utils/filters/options.js +6 -1
- package/dist/runtime/table/utils/index.d.ts +1 -0
- package/dist/runtime/table/utils/index.js +1 -0
- package/dist/runtime/table/utils/prefetch.js +5 -1
- package/dist/runtime/table/utils/source-request.d.ts +2 -0
- package/dist/runtime/table/utils/source-request.js +9 -0
- package/package.json +1 -1
|
@@ -149,28 +149,6 @@ export function buildFormOutput(schema, state, ctx, apiFactory) {
|
|
|
149
149
|
}
|
|
150
150
|
return buildFieldsOutput(getSchemaFields(schema), state, ctx, apiFactory, []);
|
|
151
151
|
}
|
|
152
|
-
export async function validateFormState(schema, state, ctx, apiFactory, mode = true) {
|
|
153
|
-
if (mode === false) {
|
|
154
|
-
return [];
|
|
155
|
-
}
|
|
156
|
-
const errors = [];
|
|
157
|
-
if (isSteppedSchema(schema)) {
|
|
158
|
-
for (const step of getSchemaSteps(schema)) {
|
|
159
|
-
errors.push(
|
|
160
|
-
...await validateFields(
|
|
161
|
-
step.fields,
|
|
162
|
-
state,
|
|
163
|
-
ctx,
|
|
164
|
-
apiFactory,
|
|
165
|
-
step.root ? [step.root] : [],
|
|
166
|
-
mode
|
|
167
|
-
)
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
return errors;
|
|
171
|
-
}
|
|
172
|
-
return validateFields(getSchemaFields(schema), state, ctx, apiFactory, [], mode);
|
|
173
|
-
}
|
|
174
152
|
export function collectFormFieldPaths(schema) {
|
|
175
153
|
if (isSteppedSchema(schema)) {
|
|
176
154
|
return getSchemaSteps(schema).flatMap(
|
|
@@ -182,19 +160,6 @@ export function collectFormFieldPaths(schema) {
|
|
|
182
160
|
export function collectFormFieldsPaths(fields, parentPath) {
|
|
183
161
|
return collectFieldPaths(fields, parentPath);
|
|
184
162
|
}
|
|
185
|
-
export async function validateFormFields(params) {
|
|
186
|
-
if (params.mode === false) {
|
|
187
|
-
return [];
|
|
188
|
-
}
|
|
189
|
-
return await validateFields(
|
|
190
|
-
params.fields,
|
|
191
|
-
params.state,
|
|
192
|
-
params.ctx,
|
|
193
|
-
params.apiFactory,
|
|
194
|
-
params.parentPath,
|
|
195
|
-
params.mode ?? true
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
163
|
export function fieldPath(parentPath, field) {
|
|
199
164
|
return [...parentPath, field.key];
|
|
200
165
|
}
|
|
@@ -357,100 +322,6 @@ function buildFieldsOutput(fields, state, ctx, apiFactory, parentPath) {
|
|
|
357
322
|
}
|
|
358
323
|
return output;
|
|
359
324
|
}
|
|
360
|
-
async function validateFields(fields, state, ctx, apiFactory, parentPath, mode) {
|
|
361
|
-
const errors = [];
|
|
362
|
-
for (const field of fields) {
|
|
363
|
-
if (field.ignore === true) {
|
|
364
|
-
continue;
|
|
365
|
-
}
|
|
366
|
-
const fieldInstance = createFormFieldInstance(field);
|
|
367
|
-
if (fieldInstance.state.is("stateless")) {
|
|
368
|
-
continue;
|
|
369
|
-
}
|
|
370
|
-
if (isFlatPassthroughField(field)) {
|
|
371
|
-
errors.push(
|
|
372
|
-
...await validateFields(getChildFields(field), state, ctx, apiFactory, parentPath, mode)
|
|
373
|
-
);
|
|
374
|
-
continue;
|
|
375
|
-
}
|
|
376
|
-
const path = fieldPath(parentPath, field);
|
|
377
|
-
const api = apiFactory(path, field);
|
|
378
|
-
const params = callbackParams({
|
|
379
|
-
api,
|
|
380
|
-
ctx,
|
|
381
|
-
field,
|
|
382
|
-
parentPath,
|
|
383
|
-
state
|
|
384
|
-
});
|
|
385
|
-
if (!shouldRenderField(field, params)) {
|
|
386
|
-
continue;
|
|
387
|
-
}
|
|
388
|
-
if (isObjectContainerField(field)) {
|
|
389
|
-
errors.push(
|
|
390
|
-
...await validateFields(getChildFields(field), state, ctx, apiFactory, path, mode)
|
|
391
|
-
);
|
|
392
|
-
continue;
|
|
393
|
-
}
|
|
394
|
-
if (isPrimitiveArrayField(field)) {
|
|
395
|
-
errors.push(
|
|
396
|
-
...await validatePrimitiveArrayItems(
|
|
397
|
-
field,
|
|
398
|
-
getPathValue(state, path),
|
|
399
|
-
state,
|
|
400
|
-
ctx,
|
|
401
|
-
apiFactory,
|
|
402
|
-
path,
|
|
403
|
-
mode
|
|
404
|
-
)
|
|
405
|
-
);
|
|
406
|
-
}
|
|
407
|
-
if (isArrayField(field)) {
|
|
408
|
-
const value2 = getPathValue(state, path);
|
|
409
|
-
if (Array.isArray(value2)) {
|
|
410
|
-
for (const index of value2.keys()) {
|
|
411
|
-
errors.push(
|
|
412
|
-
...await validateFields(
|
|
413
|
-
getArrayItemFields(field, isRecord(value2[index]) ? value2[index] : {}),
|
|
414
|
-
state,
|
|
415
|
-
ctx,
|
|
416
|
-
apiFactory,
|
|
417
|
-
[...path, String(index)],
|
|
418
|
-
mode
|
|
419
|
-
)
|
|
420
|
-
);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
continue;
|
|
424
|
-
}
|
|
425
|
-
if (fieldInstance.type.is("matrix")) {
|
|
426
|
-
for (const row of getMatrixRows(field)) {
|
|
427
|
-
errors.push(
|
|
428
|
-
...await validateFields(
|
|
429
|
-
getChildFields(field),
|
|
430
|
-
state,
|
|
431
|
-
ctx,
|
|
432
|
-
apiFactory,
|
|
433
|
-
[...path, row],
|
|
434
|
-
mode
|
|
435
|
-
)
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
|
-
continue;
|
|
439
|
-
}
|
|
440
|
-
const value = getPathValue(state, path);
|
|
441
|
-
const required = mode !== "rules" && resolveRequired(field, params);
|
|
442
|
-
if (required && isEmptyValue(value)) {
|
|
443
|
-
errors.push({
|
|
444
|
-
message: resolveRequiredMessage(field),
|
|
445
|
-
path: path.join(".")
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
if (mode !== "required") {
|
|
449
|
-
errors.push(...await validateFieldRules(field, value, params, path));
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
return errors;
|
|
453
|
-
}
|
|
454
325
|
function collectFieldPaths(fields, parentPath) {
|
|
455
326
|
return fields.flatMap((field) => {
|
|
456
327
|
if (field.ignore === true) {
|
|
@@ -533,33 +404,6 @@ function buildPrimitiveArrayOutput(field, value, state, ctx, apiFactory, path) {
|
|
|
533
404
|
return [applyOutputTransform(itemField, item, itemParams)];
|
|
534
405
|
});
|
|
535
406
|
}
|
|
536
|
-
async function validatePrimitiveArrayItems(field, value, state, ctx, apiFactory, path, mode) {
|
|
537
|
-
const errors = [];
|
|
538
|
-
if (!Array.isArray(value)) {
|
|
539
|
-
return errors;
|
|
540
|
-
}
|
|
541
|
-
for (const [index, item] of value.entries()) {
|
|
542
|
-
const itemField = getPrimitiveArrayItemField(field, index);
|
|
543
|
-
if (!itemField) {
|
|
544
|
-
continue;
|
|
545
|
-
}
|
|
546
|
-
const itemPath = [...path, String(index)];
|
|
547
|
-
const itemParams = callbackParams({
|
|
548
|
-
api: apiFactory(itemPath, itemField),
|
|
549
|
-
ctx,
|
|
550
|
-
field: itemField,
|
|
551
|
-
parentPath: path,
|
|
552
|
-
state
|
|
553
|
-
});
|
|
554
|
-
if (mode !== "rules" && resolveRequired(itemField, itemParams) && isEmptyValue(item)) {
|
|
555
|
-
errors.push({ message: resolveRequiredMessage(itemField), path: itemPath.join(".") });
|
|
556
|
-
}
|
|
557
|
-
if (mode !== "required") {
|
|
558
|
-
errors.push(...await validateFieldRules(itemField, item, itemParams, itemPath));
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
return errors;
|
|
562
|
-
}
|
|
563
407
|
export function readStaticFieldProp(field, name) {
|
|
564
408
|
const props = Object.getOwnPropertyDescriptor(field, "props")?.value;
|
|
565
409
|
if (!isRecord(props)) {
|
|
@@ -689,49 +533,6 @@ export function resolveRequiredMessage(field, fallback = "This field is required
|
|
|
689
533
|
}
|
|
690
534
|
return fallback;
|
|
691
535
|
}
|
|
692
|
-
async function validateFieldRules(field, value, params, path) {
|
|
693
|
-
const validation = Object.getOwnPropertyDescriptor(field, "validation")?.value;
|
|
694
|
-
if (!isRecord(validation)) {
|
|
695
|
-
return [];
|
|
696
|
-
}
|
|
697
|
-
const rules = Object.getOwnPropertyDescriptor(validation, "rules")?.value;
|
|
698
|
-
if (!Array.isArray(rules)) {
|
|
699
|
-
return [];
|
|
700
|
-
}
|
|
701
|
-
const errors = [];
|
|
702
|
-
for (const rule of rules) {
|
|
703
|
-
if (!isRecord(rule)) {
|
|
704
|
-
continue;
|
|
705
|
-
}
|
|
706
|
-
const validate = Object.getOwnPropertyDescriptor(rule, "validate")?.value;
|
|
707
|
-
if (!isFunction(validate)) {
|
|
708
|
-
continue;
|
|
709
|
-
}
|
|
710
|
-
const result = await validate({
|
|
711
|
-
...params,
|
|
712
|
-
api: params.api
|
|
713
|
-
});
|
|
714
|
-
if (result === true || result === null || isUndefined(result)) {
|
|
715
|
-
continue;
|
|
716
|
-
}
|
|
717
|
-
errors.push({
|
|
718
|
-
message: isString(result) ? result : resolveRuleMessage(rule, value),
|
|
719
|
-
path: path.join(".")
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
return errors;
|
|
723
|
-
}
|
|
724
|
-
function resolveRuleMessage(rule, _value) {
|
|
725
|
-
const message = Object.getOwnPropertyDescriptor(rule, "message")?.value;
|
|
726
|
-
if (isFunction(message)) {
|
|
727
|
-
return String(message());
|
|
728
|
-
}
|
|
729
|
-
if (isString(message) || isNumber(message)) {
|
|
730
|
-
return String(message);
|
|
731
|
-
}
|
|
732
|
-
const name = Object.getOwnPropertyDescriptor(rule, "name")?.value;
|
|
733
|
-
return isString(name) ? `Invalid value for ${name}.` : "Invalid value.";
|
|
734
|
-
}
|
|
735
536
|
export function isEmptyValue(value) {
|
|
736
537
|
if (value === null || isUndefined(value)) {
|
|
737
538
|
return true;
|
|
@@ -14,32 +14,32 @@ declare var __VLS_1: {}, __VLS_4: "loading" | "initial-loading", __VLS_5: {
|
|
|
14
14
|
}, __VLS_7: {
|
|
15
15
|
error: {};
|
|
16
16
|
retry: typeof refresh;
|
|
17
|
-
},
|
|
17
|
+
}, __VLS_16: {
|
|
18
18
|
layout: import("../../types/index.js").TableLayout;
|
|
19
19
|
refresh: typeof refresh;
|
|
20
20
|
hasActiveQuery: boolean;
|
|
21
21
|
clearQuery: typeof clearQuery;
|
|
22
|
-
},
|
|
22
|
+
}, __VLS_18: {
|
|
23
23
|
layout: import("../../types/index.js").TableLayout;
|
|
24
24
|
rows: object[];
|
|
25
25
|
loading: boolean;
|
|
26
26
|
empty: boolean;
|
|
27
27
|
error: unknown;
|
|
28
|
-
},
|
|
28
|
+
}, __VLS_26: {
|
|
29
29
|
rows: object[];
|
|
30
|
-
},
|
|
30
|
+
}, __VLS_35: any, __VLS_38: {}, __VLS_40: {
|
|
31
31
|
layout: string;
|
|
32
32
|
refresh: typeof refresh;
|
|
33
33
|
hasActiveQuery: boolean;
|
|
34
34
|
clearQuery: typeof clearQuery;
|
|
35
|
-
},
|
|
35
|
+
}, __VLS_42: {
|
|
36
36
|
rows: object[];
|
|
37
|
-
},
|
|
37
|
+
}, __VLS_51: {}, __VLS_53: {
|
|
38
38
|
layout: string;
|
|
39
39
|
refresh: typeof refresh;
|
|
40
40
|
hasActiveQuery: boolean;
|
|
41
41
|
clearQuery: typeof clearQuery;
|
|
42
|
-
},
|
|
42
|
+
}, __VLS_55: {}, __VLS_57: {};
|
|
43
43
|
type __VLS_Slots = {} & {
|
|
44
44
|
[K in NonNullable<typeof __VLS_4>]?: (props: typeof __VLS_5) => any;
|
|
45
45
|
} & {
|
|
@@ -47,25 +47,27 @@ type __VLS_Slots = {} & {
|
|
|
47
47
|
} & {
|
|
48
48
|
error?: (props: typeof __VLS_7) => any;
|
|
49
49
|
} & {
|
|
50
|
-
empty?: (props: typeof
|
|
50
|
+
empty?: (props: typeof __VLS_16) => any;
|
|
51
51
|
} & {
|
|
52
|
-
content?: (props: typeof
|
|
52
|
+
content?: (props: typeof __VLS_18) => any;
|
|
53
53
|
} & {
|
|
54
|
-
table?: (props: typeof
|
|
54
|
+
table?: (props: typeof __VLS_26) => any;
|
|
55
55
|
} & {
|
|
56
|
-
|
|
56
|
+
error?: (props: typeof __VLS_35) => any;
|
|
57
57
|
} & {
|
|
58
|
-
empty?: (props: typeof
|
|
58
|
+
'empty-table'?: (props: typeof __VLS_38) => any;
|
|
59
59
|
} & {
|
|
60
|
-
|
|
60
|
+
empty?: (props: typeof __VLS_40) => any;
|
|
61
61
|
} & {
|
|
62
|
-
|
|
62
|
+
grid?: (props: typeof __VLS_42) => any;
|
|
63
63
|
} & {
|
|
64
|
-
empty?: (props: typeof
|
|
64
|
+
'empty-grid'?: (props: typeof __VLS_51) => any;
|
|
65
65
|
} & {
|
|
66
|
-
|
|
66
|
+
empty?: (props: typeof __VLS_53) => any;
|
|
67
67
|
} & {
|
|
68
|
-
|
|
68
|
+
refreshing?: (props: typeof __VLS_55) => any;
|
|
69
|
+
} & {
|
|
70
|
+
after?: (props: typeof __VLS_57) => any;
|
|
69
71
|
};
|
|
70
72
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
71
73
|
transition: boolean;
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import UButton from "@nuxt/ui/components/Button.vue";
|
|
3
|
-
import UIcon from "@nuxt/ui/components/Icon.vue";
|
|
4
2
|
import { computed, nextTick, ref, watch } from "vue";
|
|
5
|
-
import { useUiToolsLocale } from "#ui-tools/i18n";
|
|
6
3
|
import { isNumber } from "../../../shared/utils/predicate";
|
|
7
4
|
import { useDataListUi } from "../../composables/use-data-list-ui";
|
|
8
5
|
import { provideDataListViewport } from "../../composables/use-data-list-viewport";
|
|
9
6
|
import { useTableInternals } from "../../composables/use-table-internals";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
resolveDataListContentShellClass,
|
|
13
|
-
resolveDataListControlGeometry
|
|
14
|
-
} from "../../utils";
|
|
7
|
+
import { mergeDataListUiClass, resolveDataListContentShellClass } from "../../utils";
|
|
8
|
+
import DataListErrorState from "./data-list-error-state.vue";
|
|
15
9
|
import DataListGrid from "./data-list-grid.vue";
|
|
16
10
|
import DataListTable from "./data-list-table.vue";
|
|
17
11
|
const props = defineProps({
|
|
@@ -24,14 +18,13 @@ const props = defineProps({
|
|
|
24
18
|
});
|
|
25
19
|
const internals = useTableInternals();
|
|
26
20
|
const dataListUi = useDataListUi();
|
|
27
|
-
const { t } = useUiToolsLocale();
|
|
28
21
|
const viewport = ref(null);
|
|
29
22
|
provideDataListViewport(viewport);
|
|
30
23
|
const rows = computed(() => internals.queryContent.data.value.rows);
|
|
31
24
|
const loading = computed(
|
|
32
|
-
() => internals.queryContent.status.value.isBooting || internals.queryContent.status.value.isPending && rows.value.length === 0
|
|
25
|
+
() => internals.queryContent.status.value.isBooting || (internals.queryContent.status.value.isPending || internals.queryContent.status.value.isFetching) && rows.value.length === 0
|
|
33
26
|
);
|
|
34
|
-
const error = computed(() =>
|
|
27
|
+
const error = computed(() => internals.queryContent.error.value);
|
|
35
28
|
const empty = computed(() => !loading.value && !error.value && rows.value.length === 0);
|
|
36
29
|
const hasActiveQuery = computed(
|
|
37
30
|
() => internals.filters.hasActiveSearch.value || internals.filters.hasActiveUiFilters.value
|
|
@@ -55,7 +48,6 @@ const rootUi = computed(() => dataListUi.ui.value.content?.ui);
|
|
|
55
48
|
const resolvedSize = computed(
|
|
56
49
|
() => props.size ?? dataListUi.ui.value.content?.size ?? dataListUi.controlSize.value
|
|
57
50
|
);
|
|
58
|
-
const geometry = computed(() => resolveDataListControlGeometry(resolvedSize.value));
|
|
59
51
|
const shellClass = computed(
|
|
60
52
|
() => resolveDataListContentShellClass({
|
|
61
53
|
layout: internals.controls.tableLayout.value,
|
|
@@ -106,81 +98,13 @@ watch(
|
|
|
106
98
|
:name="$slots['initial-loading'] ? 'initial-loading' : 'loading'"
|
|
107
99
|
:layout="internals.controls.tableLayout.value"
|
|
108
100
|
/>
|
|
109
|
-
<slot
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
)
|
|
117
|
-
"
|
|
118
|
-
>
|
|
119
|
-
<div
|
|
120
|
-
:class="
|
|
121
|
-
mergeDataListUiClass(
|
|
122
|
-
`flex max-w-md items-start text-left ${geometry.toolbarGap}`,
|
|
123
|
-
rootUi?.errorBody,
|
|
124
|
-
ui?.errorBody
|
|
125
|
-
)
|
|
126
|
-
"
|
|
127
|
-
>
|
|
128
|
-
<span
|
|
129
|
-
:class="
|
|
130
|
-
mergeDataListUiClass(
|
|
131
|
-
'grid size-9 shrink-0 place-items-center rounded-md bg-error/10 text-error',
|
|
132
|
-
rootUi?.errorIcon,
|
|
133
|
-
ui?.errorIcon
|
|
134
|
-
)
|
|
135
|
-
"
|
|
136
|
-
>
|
|
137
|
-
<UIcon name="i-lucide-cloud-alert" class="size-4" />
|
|
138
|
-
</span>
|
|
139
|
-
<div
|
|
140
|
-
:class="
|
|
141
|
-
mergeDataListUiClass(
|
|
142
|
-
`min-w-0 flex-1 ${geometry.text}`,
|
|
143
|
-
rootUi?.errorCopy,
|
|
144
|
-
ui?.errorCopy
|
|
145
|
-
)
|
|
146
|
-
"
|
|
147
|
-
>
|
|
148
|
-
<div
|
|
149
|
-
:class="
|
|
150
|
-
mergeDataListUiClass(
|
|
151
|
-
'font-medium text-highlighted',
|
|
152
|
-
rootUi?.errorTitle,
|
|
153
|
-
ui?.errorTitle
|
|
154
|
-
)
|
|
155
|
-
"
|
|
156
|
-
>
|
|
157
|
-
{{ t("table.states.gridError.title") }}
|
|
158
|
-
</div>
|
|
159
|
-
<p
|
|
160
|
-
:class="
|
|
161
|
-
mergeDataListUiClass(
|
|
162
|
-
'mt-0.5 leading-5 text-muted',
|
|
163
|
-
rootUi?.errorDescription,
|
|
164
|
-
ui?.errorDescription
|
|
165
|
-
)
|
|
166
|
-
"
|
|
167
|
-
>
|
|
168
|
-
{{ t("table.states.gridError.description") }}
|
|
169
|
-
</p>
|
|
170
|
-
<UButton
|
|
171
|
-
color="neutral"
|
|
172
|
-
variant="soft"
|
|
173
|
-
:size="resolvedSize"
|
|
174
|
-
icon="i-lucide-refresh-cw"
|
|
175
|
-
class="mt-3"
|
|
176
|
-
:ui="{ base: mergeDataListUiClass(rootUi?.retry, ui?.retry) }"
|
|
177
|
-
@click="refresh"
|
|
178
|
-
>
|
|
179
|
-
{{ t("table.states.gridError.action") }}
|
|
180
|
-
</UButton>
|
|
181
|
-
</div>
|
|
182
|
-
</div>
|
|
183
|
-
</div>
|
|
101
|
+
<slot
|
|
102
|
+
v-else-if="error && internals.controls.tableLayout.value === 'grid'"
|
|
103
|
+
name="error"
|
|
104
|
+
:error="error"
|
|
105
|
+
:retry="refresh"
|
|
106
|
+
>
|
|
107
|
+
<DataListErrorState min-height="16rem" :size="resolvedSize" :ui="ui" @retry="refresh" />
|
|
184
108
|
</slot>
|
|
185
109
|
<slot
|
|
186
110
|
v-else-if="empty && $slots.empty"
|
|
@@ -207,6 +131,9 @@ watch(
|
|
|
207
131
|
>
|
|
208
132
|
<slot v-if="internals.controls.tableLayout.value === 'table'" name="table" :rows="rows">
|
|
209
133
|
<DataListTable :size="resolvedSize" :fill="fit !== 'content'" class="min-h-0 flex-1">
|
|
134
|
+
<template v-if="$slots.error" #error="scope">
|
|
135
|
+
<slot name="error" v-bind="scope" />
|
|
136
|
+
</template>
|
|
210
137
|
<template #empty>
|
|
211
138
|
<slot name="empty-table">
|
|
212
139
|
<slot
|
|
@@ -14,32 +14,32 @@ declare var __VLS_1: {}, __VLS_4: "loading" | "initial-loading", __VLS_5: {
|
|
|
14
14
|
}, __VLS_7: {
|
|
15
15
|
error: {};
|
|
16
16
|
retry: typeof refresh;
|
|
17
|
-
},
|
|
17
|
+
}, __VLS_16: {
|
|
18
18
|
layout: import("../../types/index.js").TableLayout;
|
|
19
19
|
refresh: typeof refresh;
|
|
20
20
|
hasActiveQuery: boolean;
|
|
21
21
|
clearQuery: typeof clearQuery;
|
|
22
|
-
},
|
|
22
|
+
}, __VLS_18: {
|
|
23
23
|
layout: import("../../types/index.js").TableLayout;
|
|
24
24
|
rows: object[];
|
|
25
25
|
loading: boolean;
|
|
26
26
|
empty: boolean;
|
|
27
27
|
error: unknown;
|
|
28
|
-
},
|
|
28
|
+
}, __VLS_26: {
|
|
29
29
|
rows: object[];
|
|
30
|
-
},
|
|
30
|
+
}, __VLS_35: any, __VLS_38: {}, __VLS_40: {
|
|
31
31
|
layout: string;
|
|
32
32
|
refresh: typeof refresh;
|
|
33
33
|
hasActiveQuery: boolean;
|
|
34
34
|
clearQuery: typeof clearQuery;
|
|
35
|
-
},
|
|
35
|
+
}, __VLS_42: {
|
|
36
36
|
rows: object[];
|
|
37
|
-
},
|
|
37
|
+
}, __VLS_51: {}, __VLS_53: {
|
|
38
38
|
layout: string;
|
|
39
39
|
refresh: typeof refresh;
|
|
40
40
|
hasActiveQuery: boolean;
|
|
41
41
|
clearQuery: typeof clearQuery;
|
|
42
|
-
},
|
|
42
|
+
}, __VLS_55: {}, __VLS_57: {};
|
|
43
43
|
type __VLS_Slots = {} & {
|
|
44
44
|
[K in NonNullable<typeof __VLS_4>]?: (props: typeof __VLS_5) => any;
|
|
45
45
|
} & {
|
|
@@ -47,25 +47,27 @@ type __VLS_Slots = {} & {
|
|
|
47
47
|
} & {
|
|
48
48
|
error?: (props: typeof __VLS_7) => any;
|
|
49
49
|
} & {
|
|
50
|
-
empty?: (props: typeof
|
|
50
|
+
empty?: (props: typeof __VLS_16) => any;
|
|
51
51
|
} & {
|
|
52
|
-
content?: (props: typeof
|
|
52
|
+
content?: (props: typeof __VLS_18) => any;
|
|
53
53
|
} & {
|
|
54
|
-
table?: (props: typeof
|
|
54
|
+
table?: (props: typeof __VLS_26) => any;
|
|
55
55
|
} & {
|
|
56
|
-
|
|
56
|
+
error?: (props: typeof __VLS_35) => any;
|
|
57
57
|
} & {
|
|
58
|
-
empty?: (props: typeof
|
|
58
|
+
'empty-table'?: (props: typeof __VLS_38) => any;
|
|
59
59
|
} & {
|
|
60
|
-
|
|
60
|
+
empty?: (props: typeof __VLS_40) => any;
|
|
61
61
|
} & {
|
|
62
|
-
|
|
62
|
+
grid?: (props: typeof __VLS_42) => any;
|
|
63
63
|
} & {
|
|
64
|
-
empty?: (props: typeof
|
|
64
|
+
'empty-grid'?: (props: typeof __VLS_51) => any;
|
|
65
65
|
} & {
|
|
66
|
-
|
|
66
|
+
empty?: (props: typeof __VLS_53) => any;
|
|
67
67
|
} & {
|
|
68
|
-
|
|
68
|
+
refreshing?: (props: typeof __VLS_55) => any;
|
|
69
|
+
} & {
|
|
70
|
+
after?: (props: typeof __VLS_57) => any;
|
|
69
71
|
};
|
|
70
72
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
71
73
|
transition: boolean;
|
|
@@ -9,10 +9,7 @@ declare var __VLS_1: {}, __VLS_18: {}, __VLS_52: {
|
|
|
9
9
|
layout: import("../../types/index.js").TableLayout;
|
|
10
10
|
}, __VLS_55: {
|
|
11
11
|
layout: import("../../types/index.js").TableLayout;
|
|
12
|
-
}, __VLS_58: {
|
|
13
|
-
error: {};
|
|
14
|
-
retry: () => void;
|
|
15
|
-
}, __VLS_61: {
|
|
12
|
+
}, __VLS_58: any, __VLS_61: {
|
|
16
13
|
layout: string;
|
|
17
14
|
refresh: () => void;
|
|
18
15
|
hasActiveQuery: boolean;
|
|
@@ -9,10 +9,7 @@ declare var __VLS_1: {}, __VLS_18: {}, __VLS_52: {
|
|
|
9
9
|
layout: import("../../types/index.js").TableLayout;
|
|
10
10
|
}, __VLS_55: {
|
|
11
11
|
layout: import("../../types/index.js").TableLayout;
|
|
12
|
-
}, __VLS_58: {
|
|
13
|
-
error: {};
|
|
14
|
-
retry: () => void;
|
|
15
|
-
}, __VLS_61: {
|
|
12
|
+
}, __VLS_58: any, __VLS_61: {
|
|
16
13
|
layout: string;
|
|
17
14
|
refresh: () => void;
|
|
18
15
|
hasActiveQuery: boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DataListContentUi, DataListControlSize } from '../../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
minHeight?: string;
|
|
4
|
+
size?: DataListControlSize;
|
|
5
|
+
ui?: DataListContentUi;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
8
|
+
retry: () => any;
|
|
9
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
10
|
+
onRetry?: (() => any) | undefined;
|
|
11
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import UButton from "@nuxt/ui/components/Button.vue";
|
|
3
|
+
import UIcon from "@nuxt/ui/components/Icon.vue";
|
|
4
|
+
import { computed } from "vue";
|
|
5
|
+
import { useUiToolsLocale } from "#ui-tools/i18n";
|
|
6
|
+
import { useDataListUi } from "../../composables/use-data-list-ui";
|
|
7
|
+
import { mergeDataListUiClass, resolveDataListControlGeometry } from "../../utils";
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
minHeight: { type: String, required: false },
|
|
10
|
+
size: { type: String, required: false },
|
|
11
|
+
ui: { type: Object, required: false }
|
|
12
|
+
});
|
|
13
|
+
const emit = defineEmits(["retry"]);
|
|
14
|
+
const dataListUi = useDataListUi();
|
|
15
|
+
const { t } = useUiToolsLocale();
|
|
16
|
+
const rootUi = computed(() => dataListUi.ui.value.content?.ui);
|
|
17
|
+
const resolvedSize = computed(
|
|
18
|
+
() => props.size ?? dataListUi.ui.value.content?.size ?? dataListUi.controlSize.value
|
|
19
|
+
);
|
|
20
|
+
const geometry = computed(() => resolveDataListControlGeometry(resolvedSize.value));
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<div
|
|
25
|
+
:class="
|
|
26
|
+
mergeDataListUiClass(
|
|
27
|
+
'grid place-items-center px-4 py-10 text-center',
|
|
28
|
+
rootUi?.error,
|
|
29
|
+
ui?.error
|
|
30
|
+
)
|
|
31
|
+
"
|
|
32
|
+
:style="{ minHeight }"
|
|
33
|
+
>
|
|
34
|
+
<div
|
|
35
|
+
:class="
|
|
36
|
+
mergeDataListUiClass(
|
|
37
|
+
`flex max-w-md items-start text-left ${geometry.toolbarGap}`,
|
|
38
|
+
rootUi?.errorBody,
|
|
39
|
+
ui?.errorBody
|
|
40
|
+
)
|
|
41
|
+
"
|
|
42
|
+
>
|
|
43
|
+
<span
|
|
44
|
+
:class="
|
|
45
|
+
mergeDataListUiClass(
|
|
46
|
+
'grid size-9 shrink-0 place-items-center rounded-md bg-error/10 text-error',
|
|
47
|
+
rootUi?.errorIcon,
|
|
48
|
+
ui?.errorIcon
|
|
49
|
+
)
|
|
50
|
+
"
|
|
51
|
+
>
|
|
52
|
+
<UIcon name="i-lucide-cloud-alert" class="size-4" />
|
|
53
|
+
</span>
|
|
54
|
+
<div
|
|
55
|
+
:class="
|
|
56
|
+
mergeDataListUiClass(`min-w-0 flex-1 ${geometry.text}`, rootUi?.errorCopy, ui?.errorCopy)
|
|
57
|
+
"
|
|
58
|
+
>
|
|
59
|
+
<div
|
|
60
|
+
:class="
|
|
61
|
+
mergeDataListUiClass('font-medium text-highlighted', rootUi?.errorTitle, ui?.errorTitle)
|
|
62
|
+
"
|
|
63
|
+
>
|
|
64
|
+
{{ t("table.states.gridError.title") }}
|
|
65
|
+
</div>
|
|
66
|
+
<p
|
|
67
|
+
:class="
|
|
68
|
+
mergeDataListUiClass(
|
|
69
|
+
'mt-0.5 leading-5 text-muted',
|
|
70
|
+
rootUi?.errorDescription,
|
|
71
|
+
ui?.errorDescription
|
|
72
|
+
)
|
|
73
|
+
"
|
|
74
|
+
>
|
|
75
|
+
{{ t("table.states.gridError.description") }}
|
|
76
|
+
</p>
|
|
77
|
+
<UButton
|
|
78
|
+
color="neutral"
|
|
79
|
+
variant="soft"
|
|
80
|
+
:size="resolvedSize"
|
|
81
|
+
icon="i-lucide-refresh-cw"
|
|
82
|
+
class="mt-3"
|
|
83
|
+
:ui="{ base: mergeDataListUiClass(rootUi?.retry, ui?.retry) }"
|
|
84
|
+
@click="emit('retry')"
|
|
85
|
+
>
|
|
86
|
+
{{ t("table.states.gridError.action") }}
|
|
87
|
+
</UButton>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</template>
|