@xleddyl/443-components-vue 0.16.69 → 0.16.71
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/CATALOG.md +130 -127
- package/README.md +70 -16
- package/dist/components/core/Button.vue +67 -5
- package/dist/components/core/Button.vue.d.ts +9 -4
- package/dist/components/core/Form.vue +8 -2
- package/dist/components/core/Form.vue.d.ts +1 -0
- package/dist/components/core/Input.vue.d.ts +2 -2
- package/dist/components/data/RecordList.vue +29 -7
- package/dist/components/forms/ColorInput.vue.d.ts +2 -2
- package/dist/components/forms/DateInput.vue.d.ts +2 -2
- package/dist/components/forms/Fieldset.vue +16 -2
- package/dist/components/forms/Fieldset.vue.d.ts +3 -3
- package/dist/components/forms/NumberInput.vue.d.ts +2 -2
- package/dist/components/forms/PaletteSelect.vue.d.ts +4 -4
- package/dist/components/forms/PasswordInput.vue.d.ts +2 -2
- package/dist/components/forms/PinInput.vue.d.ts +2 -2
- package/dist/components/forms/Slider.vue.d.ts +2 -2
- package/dist/components/forms/TimeInput.vue.d.ts +2 -2
- package/dist/components/layout/Tabs.vue +10 -1
- package/dist/components/layout/ThemeSwitch.vue.d.ts +4 -0
- package/dist/components/overlays/CommandButton.vue +1 -0
- package/dist/components/overlays/ConfirmDialog.vue.d.ts +8 -2
- package/dist/components/overlays/ConfirmHost.vue.d.ts +8 -2
- package/dist/components/overlays/ContextMenu.vue.d.ts +2 -2
- package/dist/components/overlays/Drawer.vue +9 -1
- package/dist/components/overlays/Drawer.vue.d.ts +9 -0
- package/dist/components/overlays/Modal.vue +8 -0
- package/dist/components/overlays/Modal.vue.d.ts +9 -0
- package/dist/components/overlays/Tooltip.vue +3 -1
- package/dist/components/overlays/types.d.ts +1 -0
- package/dist/components/templates/AuthLogin.vue +4 -2
- package/dist/components/templates/FormDrawer.vue +14 -33
- package/dist/components/templates/FormDrawer.vue.d.ts +5 -1
- package/dist/components/templates/FormModal.vue +153 -0
- package/dist/components/templates/FormModal.vue.d.ts +303 -0
- package/dist/components/templates/FormPage.vue +1 -0
- package/dist/components/templates/SettingsModal.vue +63 -8
- package/dist/components/templates/SettingsModal.vue.d.ts +7 -0
- package/dist/components/templates/index.d.ts +1 -0
- package/dist/components/templates/index.mjs +1 -0
- package/dist/components/templates/types.d.ts +4 -2
- package/dist/composables/templates.d.ts +1 -0
- package/dist/composables/templates.mjs +1 -0
- package/dist/composables/useConfirm.mjs +11 -8
- package/dist/composables/useDirtyGuard.mjs +7 -47
- package/dist/composables/useForm.d.ts +4 -0
- package/dist/composables/useForm.mjs +9 -1
- package/dist/composables/useLeaveGuard.d.ts +19 -0
- package/dist/composables/useLeaveGuard.mjs +52 -0
- package/dist/composables/useRouteRecord.mjs +6 -5
- package/dist/grid/DataGrid.vue +124 -8
- package/dist/grid/DataGrid.vue.d.ts +7 -23
- package/dist/grid/cells/ButtonCell.vue +21 -1
- package/dist/grid/cells/ButtonCell.vue.d.ts +4 -0
- package/dist/grid/data-grid.css +7 -1
- package/dist/grid/types.d.ts +12 -0
- package/dist/internal/forms/form-overlay.d.ts +25 -0
- package/dist/internal/forms/form-overlay.mjs +31 -0
- package/dist/internal/forms/leave.d.ts +30 -0
- package/dist/internal/forms/leave.mjs +135 -0
- package/dist/internal/keys.d.ts +1 -0
- package/dist/internal/keys.mjs +1 -0
- package/dist/internal/layout/query.d.ts +4 -0
- package/dist/internal/layout/query.mjs +3 -0
- package/dist/internal/overlays/DialogFrame.vue +43 -5
- package/dist/internal/overlays/DialogFrame.vue.d.ts +11 -1
- package/dist/internal/overlays/HintTooltip.vue +65 -0
- package/dist/internal/overlays/HintTooltip.vue.d.ts +402 -0
- package/dist/internal/overlays/OverlayView.vue.d.ts +10 -4
- package/dist/styles/data/record-list.css +31 -1
- package/dist/styles/forms/fieldset.css +8 -0
- package/dist/styles/overlays/tooltip.css +11 -0
- package/dist/styles/templates/form-modal.css +16 -0
- package/dist/styles/templates.css +1 -0
- package/package.json +1 -1
package/dist/grid/DataGrid.vue
CHANGED
|
@@ -89,8 +89,8 @@
|
|
|
89
89
|
|
|
90
90
|
<div v-if="showFooter" class="k-data-grid-footer">
|
|
91
91
|
<span class="k-data-grid-footer-info" aria-live="polite">
|
|
92
|
-
<template v-if="
|
|
93
|
-
formatLocaleMessage(locale.code, text.selected, { count:
|
|
92
|
+
<template v-if="footerSelectedCount > 0">{{
|
|
93
|
+
formatLocaleMessage(locale.code, text.selected, { count: footerSelectedCount })
|
|
94
94
|
}}</template>
|
|
95
95
|
</span>
|
|
96
96
|
<Pagination
|
|
@@ -117,7 +117,17 @@
|
|
|
117
117
|
|
|
118
118
|
<script setup>
|
|
119
119
|
import { AgGridVue } from "ag-grid-vue3";
|
|
120
|
-
import {
|
|
120
|
+
import {
|
|
121
|
+
computed,
|
|
122
|
+
getCurrentInstance,
|
|
123
|
+
nextTick,
|
|
124
|
+
onBeforeUnmount,
|
|
125
|
+
onMounted,
|
|
126
|
+
ref,
|
|
127
|
+
shallowRef,
|
|
128
|
+
warn,
|
|
129
|
+
watch
|
|
130
|
+
} from "vue";
|
|
121
131
|
import Pagination from "../components/data/Pagination.vue";
|
|
122
132
|
import Spinner from "../components/core/Spinner.vue";
|
|
123
133
|
import { useCopy } from "../composables/useCopy";
|
|
@@ -187,6 +197,7 @@ const query = defineModel("query", { type: String, ...{ default: "" } });
|
|
|
187
197
|
const page = defineModel("page", { type: Number, ...{ default: 1 } });
|
|
188
198
|
const pageSize = defineModel("pageSize", { type: [Number, String], ...{ default: 25 } });
|
|
189
199
|
const sort = defineModel("sort", { type: null, ...{ default: void 0 } });
|
|
200
|
+
const selected = defineModel("selected", { type: Array });
|
|
190
201
|
if (props.filterable) registerGridFilterModules();
|
|
191
202
|
function hasEditableColumn() {
|
|
192
203
|
return props.editable || props.spreadsheet || Boolean(props.gridOptions?.defaultColDef?.editable) || props.columns.some((column) => Boolean(column.editable));
|
|
@@ -250,6 +261,9 @@ const theme = computed(
|
|
|
250
261
|
const mounted = ref(false);
|
|
251
262
|
const api = shallowRef(null);
|
|
252
263
|
const selectedCount = ref(0);
|
|
264
|
+
const footerSelectedCount = computed(
|
|
265
|
+
() => props.serverPagination && selected.value ? selected.value.length : selectedCount.value
|
|
266
|
+
);
|
|
253
267
|
const clientTotal = ref(0);
|
|
254
268
|
const clientPageCount = ref(1);
|
|
255
269
|
const { copied, copy } = useCopy();
|
|
@@ -314,9 +328,12 @@ const loadingTemplate = computed(
|
|
|
314
328
|
);
|
|
315
329
|
const gridRowSelection = computed(() => {
|
|
316
330
|
if (!props.selectable) return props.gridOptions?.rowSelection;
|
|
331
|
+
if (props.selectable === "single")
|
|
332
|
+
return { mode: "singleRow", enableClickSelection: false };
|
|
317
333
|
return {
|
|
318
|
-
mode:
|
|
319
|
-
enableClickSelection: false
|
|
334
|
+
mode: "multiRow",
|
|
335
|
+
enableClickSelection: false,
|
|
336
|
+
selectAll: "filtered"
|
|
320
337
|
};
|
|
321
338
|
});
|
|
322
339
|
const defaultColDef = computed(() => ({
|
|
@@ -425,6 +442,7 @@ function onGridReady(event) {
|
|
|
425
442
|
if (stored?.length) event.api.applyColumnState({ state: stored, applyOrder: true });
|
|
426
443
|
applySort();
|
|
427
444
|
syncPagination();
|
|
445
|
+
applySelection();
|
|
428
446
|
}
|
|
429
447
|
function sameSort(a, b) {
|
|
430
448
|
return (a?.column ?? null) === (b?.column ?? null) && (a?.direction ?? null) === (b?.direction ?? null);
|
|
@@ -476,11 +494,94 @@ function goToPage(next) {
|
|
|
476
494
|
page.value = target;
|
|
477
495
|
if (paginated.value) api.value?.paginationGoToPage(target - 1);
|
|
478
496
|
}
|
|
497
|
+
const instance = getCurrentInstance();
|
|
498
|
+
let warnedMissingRowId = false;
|
|
499
|
+
function isSelectionBound() {
|
|
500
|
+
const vnodeProps = instance?.vnode.props;
|
|
501
|
+
return Boolean(vnodeProps && ("selected" in vnodeProps || "onUpdate:selected" in vnodeProps));
|
|
502
|
+
}
|
|
503
|
+
function checkSelectionRowIds() {
|
|
504
|
+
if (warnedMissingRowId || !isSelectionBound() || rowIdGetter.value) return;
|
|
505
|
+
warnedMissingRowId = true;
|
|
506
|
+
warn(
|
|
507
|
+
"[@xleddyl/443-components-vue] DataGrid v-model:selected needs row ids: set rowIdKey, getRowId or gridOptions.getRowId."
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
function sameIds(a, b) {
|
|
511
|
+
if (a.length !== b.length) return false;
|
|
512
|
+
const lookup = new Set(a);
|
|
513
|
+
return b.every((id) => lookup.has(id));
|
|
514
|
+
}
|
|
515
|
+
function readNodeIds(current) {
|
|
516
|
+
const present = /* @__PURE__ */ new Set();
|
|
517
|
+
current.forEachNode((node) => {
|
|
518
|
+
if (node.id !== void 0) present.add(node.id);
|
|
519
|
+
});
|
|
520
|
+
return present;
|
|
521
|
+
}
|
|
522
|
+
function mergedSelection(current) {
|
|
523
|
+
const gridIds = current.getSelectedNodes().flatMap((node) => node.id ? [node.id] : []);
|
|
524
|
+
const model = selected.value ?? [];
|
|
525
|
+
const keepUnknown = props.serverPagination || props.loading;
|
|
526
|
+
if (!keepUnknown) return gridIds;
|
|
527
|
+
const present = readNodeIds(current);
|
|
528
|
+
const kept = model.filter((id) => !present.has(id));
|
|
529
|
+
return props.selectable === "single" ? gridIds : [...kept, ...gridIds];
|
|
530
|
+
}
|
|
531
|
+
function applyIds(ids) {
|
|
532
|
+
const current = api.value;
|
|
533
|
+
if (!current || !props.selectable) return;
|
|
534
|
+
const wanted = new Set(ids);
|
|
535
|
+
const single = props.selectable === "single";
|
|
536
|
+
const select = [];
|
|
537
|
+
const deselect = [];
|
|
538
|
+
let chosen = false;
|
|
539
|
+
current.forEachNode((node) => {
|
|
540
|
+
const id = node.id;
|
|
541
|
+
const should = id !== void 0 && wanted.has(id) && !(single && chosen);
|
|
542
|
+
if (should) chosen = true;
|
|
543
|
+
if (Boolean(node.isSelected()) === should) return;
|
|
544
|
+
(should ? select : deselect).push(node);
|
|
545
|
+
});
|
|
546
|
+
if (deselect.length) current.setNodesSelected({ nodes: deselect, newValue: false });
|
|
547
|
+
if (select.length) current.setNodesSelected({ nodes: select, newValue: true });
|
|
548
|
+
}
|
|
549
|
+
function applySelection() {
|
|
550
|
+
if (!isSelectionBound() || !selected.value) return;
|
|
551
|
+
applyIds(selected.value);
|
|
552
|
+
}
|
|
553
|
+
function reconcileSelection() {
|
|
554
|
+
const current = api.value;
|
|
555
|
+
if (!current || !isSelectionBound() || !selected.value) return;
|
|
556
|
+
if (!props.serverPagination && !props.loading) {
|
|
557
|
+
const present = readNodeIds(current);
|
|
558
|
+
if (present.size) {
|
|
559
|
+
const pruned = selected.value.filter((id) => present.has(id));
|
|
560
|
+
if (pruned.length !== selected.value.length) selected.value = pruned;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
applySelection();
|
|
564
|
+
}
|
|
565
|
+
function writeSelection(current) {
|
|
566
|
+
if (!isSelectionBound()) return;
|
|
567
|
+
const next = mergedSelection(current);
|
|
568
|
+
if (!sameIds(next, selected.value ?? [])) selected.value = next;
|
|
569
|
+
}
|
|
479
570
|
function onSelectionChanged(event) {
|
|
480
571
|
const rows = event.api.getSelectedRows();
|
|
481
572
|
selectedCount.value = rows.length;
|
|
482
573
|
emit("selectionChange", rows);
|
|
574
|
+
if (event.source === "rowDataChanged") return;
|
|
575
|
+
writeSelection(event.api);
|
|
483
576
|
}
|
|
577
|
+
watch(selected, applySelection, { deep: true });
|
|
578
|
+
watch(
|
|
579
|
+
() => props.loading,
|
|
580
|
+
(value) => {
|
|
581
|
+
if (!value) nextTick(reconcileSelection);
|
|
582
|
+
}
|
|
583
|
+
);
|
|
584
|
+
watch(rowIdGetter, checkSelectionRowIds);
|
|
484
585
|
function onSortChanged(event) {
|
|
485
586
|
const change = readSort(event.api);
|
|
486
587
|
if (!sameSort(change, sort.value)) sort.value = change;
|
|
@@ -523,6 +624,7 @@ const gridEvents = {
|
|
|
523
624
|
cellContextMenu: onCellContextMenu,
|
|
524
625
|
paginationChanged: syncPagination,
|
|
525
626
|
modelUpdated: onModelUpdated,
|
|
627
|
+
rowDataUpdated: reconcileSelection,
|
|
526
628
|
columnMoved: persistState,
|
|
527
629
|
columnResized: persistState,
|
|
528
630
|
columnVisible: persistState,
|
|
@@ -533,17 +635,31 @@ watch(pageSize, () => {
|
|
|
533
635
|
else nextTick(syncPagination);
|
|
534
636
|
});
|
|
535
637
|
onMounted(() => {
|
|
638
|
+
checkSelectionRowIds();
|
|
536
639
|
hasStoredState.value = readStoredState() !== null;
|
|
537
640
|
mounted.value = true;
|
|
538
641
|
});
|
|
539
|
-
|
|
642
|
+
const exposed = {
|
|
540
643
|
...sheet.methods,
|
|
541
644
|
api,
|
|
542
645
|
getSelectedRows: () => api.value?.getSelectedRows() ?? [],
|
|
543
|
-
|
|
646
|
+
getSelectedIds: () => {
|
|
647
|
+
if (isSelectionBound() && selected.value) return [...selected.value];
|
|
648
|
+
return api.value?.getSelectedNodes().flatMap((node) => node.id ? [node.id] : []) ?? [];
|
|
649
|
+
},
|
|
650
|
+
selectRows: (ids) => {
|
|
651
|
+
if (isSelectionBound()) selected.value = [...ids];
|
|
652
|
+
else applyIds(ids);
|
|
653
|
+
},
|
|
654
|
+
selectAllRows: () => api.value?.selectAll("filtered"),
|
|
655
|
+
deselectAll: () => {
|
|
656
|
+
if (isSelectionBound()) selected.value = [];
|
|
657
|
+
api.value?.deselectAll();
|
|
658
|
+
},
|
|
544
659
|
resetColumns: () => {
|
|
545
660
|
api.value?.resetColumnState();
|
|
546
661
|
clearStoredState();
|
|
547
662
|
}
|
|
548
|
-
}
|
|
663
|
+
};
|
|
664
|
+
defineExpose(exposed);
|
|
549
665
|
</script>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { FilterChangedEvent, FilterModel, ColDef, GetRowIdParams, GridApi, GridOptions, RowClickedEvent } from 'ag-grid-community';
|
|
2
|
+
import type { ShallowRef } from 'vue';
|
|
2
3
|
import type { PageSize } from '../components/data/types';
|
|
3
|
-
import type { GridCellRange, GridCellsChange, GridCellsInvalid, GridActiveFilter, GridDensity, GridMessages, GridSelection, GridSortChange } from './types';
|
|
4
|
+
import type { GridCellRange, GridCellsChange, GridCellsInvalid, GridActiveFilter, DataGridMethods, GridDensity, GridMessages, GridSelection, GridSortChange } from './types';
|
|
4
5
|
declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
5
6
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<({
|
|
6
7
|
rows?: T[];
|
|
@@ -44,12 +45,14 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
44
45
|
page?: number;
|
|
45
46
|
pageSize?: PageSize;
|
|
46
47
|
sort?: GridSortChange | null | undefined;
|
|
48
|
+
selected?: string[];
|
|
47
49
|
}) & {
|
|
48
50
|
onCopy?: ((text: string) => any) | undefined;
|
|
49
51
|
"onUpdate:page"?: ((value: number) => any) | undefined;
|
|
50
52
|
"onUpdate:pageSize"?: ((value: PageSize) => any) | undefined;
|
|
51
53
|
onRowClick?: ((event: RowClickedEvent<T, any>) => any) | undefined;
|
|
52
54
|
"onUpdate:sort"?: ((value: GridSortChange | null | undefined) => any) | undefined;
|
|
55
|
+
"onUpdate:selected"?: ((value: string[] | undefined) => any) | undefined;
|
|
53
56
|
"onUpdate:query"?: ((value: string) => any) | undefined;
|
|
54
57
|
onFiltersReset?: (() => any) | undefined;
|
|
55
58
|
onFilterRemove?: ((id: string) => any) | undefined;
|
|
@@ -63,27 +66,8 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
63
66
|
} & Partial<import("vue").HTMLAttributes & import("vue").ReservedProps>> & (typeof globalThis extends {
|
|
64
67
|
__VLS_PROPS_FALLBACK: infer P;
|
|
65
68
|
} ? P : {});
|
|
66
|
-
expose: (exposed: import("vue").ShallowUnwrapRef<{
|
|
67
|
-
api:
|
|
68
|
-
getSelectedRows: () => T[];
|
|
69
|
-
deselectAll: () => void | undefined;
|
|
70
|
-
resetColumns: () => void;
|
|
71
|
-
getRange: () => GridCellRange | null;
|
|
72
|
-
getSelectedCells: () => import("./types").GridSelectedCell<T>[];
|
|
73
|
-
selectRange: (range: import("./types").GridRangeInput) => void;
|
|
74
|
-
selectAll: () => void;
|
|
75
|
-
clearRange: () => void;
|
|
76
|
-
setRangeValue: (value: unknown, options?: import("./types").GridSetRangeValueOptions) => number;
|
|
77
|
-
copyRange: () => Promise<string | null>;
|
|
78
|
-
paste: (text: string) => number;
|
|
79
|
-
fillDown: () => number;
|
|
80
|
-
fillRight: () => number;
|
|
81
|
-
clearCells: () => number;
|
|
82
|
-
undo: () => boolean;
|
|
83
|
-
redo: () => boolean;
|
|
84
|
-
clearHistory: () => void;
|
|
85
|
-
getDirtyCells: () => import("./types").GridDirtyCell[];
|
|
86
|
-
clearDirty: (rowIds?: string[]) => void;
|
|
69
|
+
expose: (exposed: import("vue").ShallowUnwrapRef<Omit<DataGridMethods<T>, "api"> & {
|
|
70
|
+
api: ShallowRef<GridApi<T> | null>;
|
|
87
71
|
}>) => void;
|
|
88
72
|
attrs: any;
|
|
89
73
|
slots: {
|
|
@@ -142,7 +126,7 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
142
126
|
count: number;
|
|
143
127
|
}) => any;
|
|
144
128
|
};
|
|
145
|
-
emit: (((evt: "copy", text: string) => void) & ((evt: "rowClick", event: RowClickedEvent<T, any>) => void) & ((evt: "filtersReset") => void) & ((evt: "filterRemove", id: string) => void) & ((evt: "selectionChange", rows: T[]) => void) & ((evt: "sortChange", change: GridSortChange | null) => void) & ((evt: "filterChange", model: FilterModel, event: FilterChangedEvent<T, any>) => void) & ((evt: "cellsChange", event: GridCellsChange) => void) & ((evt: "cellsInvalid", event: GridCellsInvalid) => void) & ((evt: "dirtyChange", count: number) => void) & ((evt: "rangeChange", range: GridCellRange | null) => void)) & (((event: "update:page", value: number) => void) & ((event: "update:pageSize", value: PageSize) => void) & ((event: "update:sort", value: GridSortChange | null | undefined) => void) & ((event: "update:query", value: string) => void));
|
|
129
|
+
emit: (((evt: "copy", text: string) => void) & ((evt: "rowClick", event: RowClickedEvent<T, any>) => void) & ((evt: "filtersReset") => void) & ((evt: "filterRemove", id: string) => void) & ((evt: "selectionChange", rows: T[]) => void) & ((evt: "sortChange", change: GridSortChange | null) => void) & ((evt: "filterChange", model: FilterModel, event: FilterChangedEvent<T, any>) => void) & ((evt: "cellsChange", event: GridCellsChange) => void) & ((evt: "cellsInvalid", event: GridCellsInvalid) => void) & ((evt: "dirtyChange", count: number) => void) & ((evt: "rangeChange", range: GridCellRange | null) => void)) & (((event: "update:page", value: number) => void) & ((event: "update:pageSize", value: PageSize) => void) & ((event: "update:sort", value: GridSortChange | null | undefined) => void) & ((event: "update:selected", value: string[] | undefined) => void) & ((event: "update:query", value: string) => void));
|
|
146
130
|
}>) => import("vue").VNode & {
|
|
147
131
|
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
148
132
|
};
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
:variant="params.variant ?? 'link'"
|
|
8
8
|
:icon="params.icon"
|
|
9
9
|
:aria-label="ariaLabel"
|
|
10
|
+
:tooltip="tooltip"
|
|
11
|
+
:disabled="disabled"
|
|
12
|
+
:disabled-reason="disabledReason"
|
|
10
13
|
@click.stop="onClick"
|
|
11
14
|
@mousedown.stop
|
|
12
15
|
>
|
|
@@ -17,17 +20,22 @@
|
|
|
17
20
|
type="button"
|
|
18
21
|
class="k-data-grid-button"
|
|
19
22
|
:aria-label="ariaLabel"
|
|
23
|
+
:aria-disabled="disabled ? 'true' : void 0"
|
|
24
|
+
:aria-describedby="hint && hydrated ? hintId : void 0"
|
|
25
|
+
:title="hydrated ? void 0 : hint"
|
|
20
26
|
@click.stop="onClick"
|
|
21
27
|
@mousedown.stop
|
|
22
28
|
>
|
|
23
29
|
{{ text }}
|
|
30
|
+
<HintTooltip v-if="hint && hydrated" :id="hintId" :text="hint" />
|
|
24
31
|
</button>
|
|
25
32
|
<EmptyCell v-else :context="cellContext" />
|
|
26
33
|
</template>
|
|
27
34
|
|
|
28
35
|
<script setup>
|
|
29
|
-
import { computed } from "vue";
|
|
36
|
+
import { computed, onMounted, ref, useId } from "vue";
|
|
30
37
|
import Button from "../../components/core/Button.vue";
|
|
38
|
+
import HintTooltip from "../../internal/overlays/HintTooltip.vue";
|
|
31
39
|
import EmptyCell from "./EmptyCell.vue";
|
|
32
40
|
const props = defineProps({
|
|
33
41
|
params: { type: Object, required: true }
|
|
@@ -45,7 +53,19 @@ const styled = computed(
|
|
|
45
53
|
() => Boolean(props.params.tone || props.params.variant || props.params.icon)
|
|
46
54
|
);
|
|
47
55
|
const ariaLabel = computed(() => props.params.ariaLabel?.(raw.value, props.params.data));
|
|
56
|
+
const tooltip = computed(() => props.params.tooltip?.(raw.value, props.params.data));
|
|
57
|
+
const disabled = computed(() => Boolean(props.params.disabled?.(raw.value, props.params.data)));
|
|
58
|
+
const disabledReason = computed(
|
|
59
|
+
() => disabled.value ? props.params.disabledReason?.(raw.value, props.params.data) : void 0
|
|
60
|
+
);
|
|
61
|
+
const hint = computed(() => disabledReason.value ?? tooltip.value);
|
|
62
|
+
const hintId = `${useId()}-hint`;
|
|
63
|
+
const hydrated = ref(false);
|
|
64
|
+
onMounted(() => {
|
|
65
|
+
hydrated.value = true;
|
|
66
|
+
});
|
|
48
67
|
function onClick(event) {
|
|
68
|
+
if (disabled.value) return;
|
|
49
69
|
props.params.onClick?.(raw.value, props.params.data, event);
|
|
50
70
|
}
|
|
51
71
|
const cellContext = computed(() => props.params.context);
|
|
@@ -16,6 +16,8 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
16
16
|
loading?: boolean;
|
|
17
17
|
block?: boolean;
|
|
18
18
|
square?: boolean;
|
|
19
|
+
tooltip?: string | false;
|
|
20
|
+
disabledReason?: string;
|
|
19
21
|
download?: any;
|
|
20
22
|
hreflang?: string | undefined;
|
|
21
23
|
media?: string | undefined;
|
|
@@ -249,6 +251,8 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
249
251
|
loading?: boolean;
|
|
250
252
|
block?: boolean;
|
|
251
253
|
square?: boolean;
|
|
254
|
+
tooltip?: string | false;
|
|
255
|
+
disabledReason?: string;
|
|
252
256
|
download?: any;
|
|
253
257
|
hreflang?: string | undefined;
|
|
254
258
|
media?: string | undefined;
|
package/dist/grid/data-grid.css
CHANGED
|
@@ -343,10 +343,16 @@
|
|
|
343
343
|
transition: text-decoration-color var(--k-duration) var(--k-ease);
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
.k-data-grid-button:hover {
|
|
346
|
+
.k-data-grid-button:hover:not([aria-disabled='true']) {
|
|
347
347
|
text-decoration-color: currentColor;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
+
.k-data-grid-button[aria-disabled='true'] {
|
|
351
|
+
color: var(--k-text-muted);
|
|
352
|
+
text-decoration: none;
|
|
353
|
+
cursor: not-allowed;
|
|
354
|
+
}
|
|
355
|
+
|
|
350
356
|
.k-data-grid-action {
|
|
351
357
|
max-width: 100%;
|
|
352
358
|
}
|
package/dist/grid/types.d.ts
CHANGED
|
@@ -83,6 +83,9 @@ export interface ButtonCellParams<T = unknown> {
|
|
|
83
83
|
onClick?: (value: unknown, data: T | undefined, event: MouseEvent) => void;
|
|
84
84
|
label?: (value: unknown, data: T | undefined) => string | undefined;
|
|
85
85
|
ariaLabel?: (value: unknown, data: T | undefined) => string | undefined;
|
|
86
|
+
tooltip?: (value: unknown, data: T | undefined) => string | undefined;
|
|
87
|
+
disabled?: (value: unknown, data: T | undefined) => boolean;
|
|
88
|
+
disabledReason?: (value: unknown, data: T | undefined) => string | undefined;
|
|
86
89
|
emptyLabel?: string;
|
|
87
90
|
tone?: Tone;
|
|
88
91
|
variant?: ButtonVariant;
|
|
@@ -173,3 +176,12 @@ export interface GridSpreadsheetSlotProps<T = unknown> extends GridSpreadsheetMe
|
|
|
173
176
|
canUndo: boolean;
|
|
174
177
|
canRedo: boolean;
|
|
175
178
|
}
|
|
179
|
+
export interface DataGridMethods<T = unknown> extends GridSpreadsheetMethods<T> {
|
|
180
|
+
api: GridApi<T> | null;
|
|
181
|
+
getSelectedRows: () => T[];
|
|
182
|
+
getSelectedIds: () => string[];
|
|
183
|
+
selectRows: (ids: string[]) => void;
|
|
184
|
+
selectAllRows: () => void;
|
|
185
|
+
deselectAll: () => void;
|
|
186
|
+
resetColumns: () => void;
|
|
187
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FormContext } from '../../composables/useForm';
|
|
2
|
+
import type { useLocale } from '../../composables/useLocale';
|
|
3
|
+
export interface FormOverlayProps {
|
|
4
|
+
form?: Pick<FormContext, 'submitting'> & {
|
|
5
|
+
dirty: {
|
|
6
|
+
value: boolean;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
readonly?: boolean;
|
|
11
|
+
creating?: boolean;
|
|
12
|
+
requireDirty?: boolean;
|
|
13
|
+
submitLabel?: string;
|
|
14
|
+
cancelLabel?: string;
|
|
15
|
+
deleteLabel?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function useFormOverlay(props: FormOverlayProps, t: ReturnType<typeof useLocale>['t']): {
|
|
18
|
+
formKey: import("vue").ComputedRef<number | undefined>;
|
|
19
|
+
isDirty: import("vue").ComputedRef<boolean>;
|
|
20
|
+
isSaving: import("vue").ComputedRef<boolean>;
|
|
21
|
+
submitDisabled: import("vue").ComputedRef<boolean>;
|
|
22
|
+
submitText: import("vue").ComputedRef<string>;
|
|
23
|
+
cancelText: import("vue").ComputedRef<string>;
|
|
24
|
+
deleteText: import("vue").ComputedRef<string>;
|
|
25
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
export function useFormOverlay(props, t) {
|
|
3
|
+
const formKeys = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
let nextFormKey = 0;
|
|
5
|
+
const formKey = computed(() => {
|
|
6
|
+
const form = props.form;
|
|
7
|
+
if (!form) return void 0;
|
|
8
|
+
if (!formKeys.has(form)) formKeys.set(form, nextFormKey++);
|
|
9
|
+
return formKeys.get(form);
|
|
10
|
+
});
|
|
11
|
+
const isDirty = computed(() => Boolean(props.form?.dirty.value));
|
|
12
|
+
const isSaving = computed(() => Boolean(props.form?.submitting.value));
|
|
13
|
+
const needsDirty = computed(() => props.requireDirty ?? !props.creating);
|
|
14
|
+
const submitDisabled = computed(() => props.loading || needsDirty.value && !isDirty.value);
|
|
15
|
+
const submitText = computed(
|
|
16
|
+
() => props.submitLabel ?? (props.creating ? t("common.create") : t("common.save"))
|
|
17
|
+
);
|
|
18
|
+
const cancelText = computed(
|
|
19
|
+
() => props.cancelLabel ?? (props.readonly ? t("common.dismiss") : t("common.cancel"))
|
|
20
|
+
);
|
|
21
|
+
const deleteText = computed(() => props.deleteLabel ?? t("common.delete"));
|
|
22
|
+
return {
|
|
23
|
+
formKey,
|
|
24
|
+
isDirty,
|
|
25
|
+
isSaving,
|
|
26
|
+
submitDisabled,
|
|
27
|
+
submitText,
|
|
28
|
+
cancelText,
|
|
29
|
+
deleteText
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
+
import type { ConfirmOptions } from '../overlays/confirm';
|
|
3
|
+
export interface LeaveEntry {
|
|
4
|
+
dirty: () => boolean;
|
|
5
|
+
options?: () => ConfirmOptions | undefined;
|
|
6
|
+
}
|
|
7
|
+
export interface LeaveScope {
|
|
8
|
+
readonly dirty: ComputedRef<boolean>;
|
|
9
|
+
register: (entry: LeaveEntry) => () => void;
|
|
10
|
+
confirmOptions: () => ConfirmOptions;
|
|
11
|
+
confirmLeave: (options?: ConfirmOptions) => Promise<boolean>;
|
|
12
|
+
allowNext: () => void;
|
|
13
|
+
}
|
|
14
|
+
export interface LeaveScopeOptions {
|
|
15
|
+
enabled?: () => boolean;
|
|
16
|
+
options?: () => ConfirmOptions | undefined;
|
|
17
|
+
}
|
|
18
|
+
export type DiscardConfirm = (options?: ConfirmOptions) => Promise<boolean>;
|
|
19
|
+
export declare const LEAVE_SCOPE_KEY: InjectionKey<LeaveScope>;
|
|
20
|
+
export declare function askDiscard(ask: () => Promise<boolean>): Promise<boolean>;
|
|
21
|
+
export declare function runNavigationGuard(to: object, run: () => boolean | void | Promise<boolean | void>): Promise<boolean>;
|
|
22
|
+
export declare function createLeaveScope(discard: DiscardConfirm, options?: LeaveScopeOptions & {
|
|
23
|
+
allowNext?: () => void;
|
|
24
|
+
}): LeaveScope;
|
|
25
|
+
export declare function rootLeaveScope(discard: DiscardConfirm, page: () => ConfirmOptions): LeaveScope;
|
|
26
|
+
export declare function injectedLeaveScope(): LeaveScope | null;
|
|
27
|
+
export declare function registerLeaveEntry(scope: LeaveScope, entry: LeaveEntry): () => void;
|
|
28
|
+
export declare function provideScope(scope: LeaveScope, parent: LeaveScope): LeaveScope;
|
|
29
|
+
export declare function setDialogScope(dialog: Element, scope: LeaveScope | null): void;
|
|
30
|
+
export declare function dialogScope(dialog: Element | null | undefined): LeaveScope | undefined;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
getCurrentInstance,
|
|
4
|
+
getCurrentScope,
|
|
5
|
+
hasInjectionContext,
|
|
6
|
+
inject,
|
|
7
|
+
onScopeDispose,
|
|
8
|
+
provide,
|
|
9
|
+
shallowReactive
|
|
10
|
+
} from "vue";
|
|
11
|
+
import { isClient } from "../core/env.mjs";
|
|
12
|
+
export const LEAVE_SCOPE_KEY = Symbol("k-leave-scope");
|
|
13
|
+
let pendingAsk = null;
|
|
14
|
+
let activeNavigation = null;
|
|
15
|
+
let acceptedNavigation = null;
|
|
16
|
+
export function askDiscard(ask) {
|
|
17
|
+
if (activeNavigation && acceptedNavigation === activeNavigation) return Promise.resolve(true);
|
|
18
|
+
if (pendingAsk) return pendingAsk;
|
|
19
|
+
const navigation = activeNavigation;
|
|
20
|
+
const request = ask().then((confirmed) => {
|
|
21
|
+
if (confirmed && navigation) acceptedNavigation = navigation;
|
|
22
|
+
return confirmed;
|
|
23
|
+
}).finally(() => {
|
|
24
|
+
if (pendingAsk === request) pendingAsk = null;
|
|
25
|
+
});
|
|
26
|
+
pendingAsk = request;
|
|
27
|
+
return request;
|
|
28
|
+
}
|
|
29
|
+
export async function runNavigationGuard(to, run) {
|
|
30
|
+
activeNavigation = to;
|
|
31
|
+
try {
|
|
32
|
+
return await run() !== false;
|
|
33
|
+
} finally {
|
|
34
|
+
if (activeNavigation === to) activeNavigation = null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function definedOptions(options) {
|
|
38
|
+
if (!options) return {};
|
|
39
|
+
return Object.fromEntries(
|
|
40
|
+
Object.entries(options).filter(([, value]) => value !== void 0 && value !== "")
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
export function createLeaveScope(discard, options = {}) {
|
|
44
|
+
const entries = shallowReactive(/* @__PURE__ */ new Set());
|
|
45
|
+
const enabled = () => options.enabled?.() ?? true;
|
|
46
|
+
function firstDirty() {
|
|
47
|
+
if (!enabled()) return void 0;
|
|
48
|
+
for (const entry of entries) if (entry.dirty()) return entry;
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
const dirty = computed(() => Boolean(firstDirty()));
|
|
52
|
+
function register(entry) {
|
|
53
|
+
entries.add(entry);
|
|
54
|
+
return () => {
|
|
55
|
+
entries.delete(entry);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function confirmOptions() {
|
|
59
|
+
return {
|
|
60
|
+
...definedOptions(options.options?.()),
|
|
61
|
+
...definedOptions(firstDirty()?.options?.())
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function confirmLeave(extra) {
|
|
65
|
+
if (!dirty.value) return Promise.resolve(true);
|
|
66
|
+
return discard({ ...confirmOptions(), ...definedOptions(extra) });
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
dirty,
|
|
70
|
+
register,
|
|
71
|
+
confirmOptions,
|
|
72
|
+
confirmLeave,
|
|
73
|
+
allowNext: () => options.allowNext?.()
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const rootScopes = /* @__PURE__ */ new WeakMap();
|
|
77
|
+
const detachedRoot = {};
|
|
78
|
+
function createRootScope(discard, page) {
|
|
79
|
+
let bypass = false;
|
|
80
|
+
const scope = createLeaveScope(discard, {
|
|
81
|
+
options: page,
|
|
82
|
+
allowNext: () => {
|
|
83
|
+
bypass = true;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const instance = getCurrentInstance();
|
|
87
|
+
const router = instance?.appContext.config.globalProperties.$router;
|
|
88
|
+
if (isClient()) {
|
|
89
|
+
window.addEventListener("beforeunload", (event) => {
|
|
90
|
+
if (bypass || !scope.dirty.value) return;
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
event.returnValue = "";
|
|
93
|
+
});
|
|
94
|
+
router?.beforeEach((to, from) => {
|
|
95
|
+
if (bypass) {
|
|
96
|
+
bypass = false;
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
if (to.path === from.path || !scope.dirty.value) return true;
|
|
100
|
+
return runNavigationGuard(to, () => scope.confirmLeave());
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return scope;
|
|
104
|
+
}
|
|
105
|
+
export function rootLeaveScope(discard, page) {
|
|
106
|
+
const app = getCurrentInstance()?.appContext.app;
|
|
107
|
+
if (!app) return detachedRoot.scope ??= createLeaveScope(discard, { options: page });
|
|
108
|
+
let scope = rootScopes.get(app);
|
|
109
|
+
if (!scope) {
|
|
110
|
+
scope = createRootScope(discard, page);
|
|
111
|
+
rootScopes.set(app, scope);
|
|
112
|
+
}
|
|
113
|
+
return scope;
|
|
114
|
+
}
|
|
115
|
+
export function injectedLeaveScope() {
|
|
116
|
+
return hasInjectionContext() ? inject(LEAVE_SCOPE_KEY, null) : null;
|
|
117
|
+
}
|
|
118
|
+
export function registerLeaveEntry(scope, entry) {
|
|
119
|
+
const unregister = scope.register(entry);
|
|
120
|
+
if (getCurrentScope()) onScopeDispose(unregister);
|
|
121
|
+
return unregister;
|
|
122
|
+
}
|
|
123
|
+
export function provideScope(scope, parent) {
|
|
124
|
+
provide(LEAVE_SCOPE_KEY, scope);
|
|
125
|
+
registerLeaveEntry(parent, { dirty: () => scope.dirty.value, options: scope.confirmOptions });
|
|
126
|
+
return scope;
|
|
127
|
+
}
|
|
128
|
+
const dialogScopes = /* @__PURE__ */ new WeakMap();
|
|
129
|
+
export function setDialogScope(dialog, scope) {
|
|
130
|
+
if (scope) dialogScopes.set(dialog, scope);
|
|
131
|
+
else dialogScopes.delete(dialog);
|
|
132
|
+
}
|
|
133
|
+
export function dialogScope(dialog) {
|
|
134
|
+
return dialog ? dialogScopes.get(dialog) : void 0;
|
|
135
|
+
}
|
package/dist/internal/keys.d.ts
CHANGED
|
@@ -19,3 +19,4 @@ export declare const FORM_CONFIG_KEY: InjectionKey<FormConfig>;
|
|
|
19
19
|
export declare const GRID_CONFIG_KEY: InjectionKey<GridConfig>;
|
|
20
20
|
export declare const LOCALE_KEY: InjectionKey<ComputedRef<KLocale>>;
|
|
21
21
|
export declare const ROUTE_LOCATION_KEY: InjectionKey<'query' | 'hash'>;
|
|
22
|
+
export declare const TOOLTIP_TRIGGER_KEY: InjectionKey<true>;
|
package/dist/internal/keys.mjs
CHANGED
|
@@ -11,3 +11,4 @@ export const FORM_CONFIG_KEY = Symbol("k-form-config");
|
|
|
11
11
|
export const GRID_CONFIG_KEY = Symbol("k-grid-config");
|
|
12
12
|
export const LOCALE_KEY = Symbol("k-locale");
|
|
13
13
|
export const ROUTE_LOCATION_KEY = Symbol("k-route-location");
|
|
14
|
+
export const TOOLTIP_TRIGGER_KEY = Symbol("k-tooltip-trigger");
|
|
@@ -8,6 +8,10 @@ export declare function parseRouteHash(hash: string | undefined): HashEntry[];
|
|
|
8
8
|
export declare function stringifyRouteHash(entries: HashEntry[]): string;
|
|
9
9
|
export declare function isRouteStateHash(hash: string | undefined): boolean;
|
|
10
10
|
export declare function hashParamValue(hash: string | undefined, key: string): string | undefined;
|
|
11
|
+
export declare function routeParam(route: {
|
|
12
|
+
hash?: string;
|
|
13
|
+
query?: Record<string, unknown>;
|
|
14
|
+
} | undefined, key: string, location: RouteLocation): string | undefined;
|
|
11
15
|
export declare function useDefaultRouteLocation(): RouteLocation;
|
|
12
16
|
export declare function useRouteValue(router: RouterLike | undefined, key: MaybeRefOrGetter<string | undefined>, location?: MaybeRefOrGetter<RouteLocation>): import("vue").ComputedRef<string | undefined>;
|
|
13
17
|
export declare function routeHash(hash: string | undefined, changes: Record<string, string | undefined>): string;
|
|
@@ -32,6 +32,9 @@ export function hashParamValue(hash, key) {
|
|
|
32
32
|
for (const [name, value] of parseRouteHash(hash)) if (name === key && value) return value;
|
|
33
33
|
return void 0;
|
|
34
34
|
}
|
|
35
|
+
export function routeParam(route, key, location) {
|
|
36
|
+
return location === "hash" ? hashParamValue(route?.hash, key) : firstQueryValue(route?.query?.[key]);
|
|
37
|
+
}
|
|
35
38
|
export function useDefaultRouteLocation() {
|
|
36
39
|
if (!getCurrentInstance()) return "query";
|
|
37
40
|
return inject(ROUTE_LOCATION_KEY, "query");
|