nuance-ui 0.1.25 → 0.1.27
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/components/app-shell/app-shell.d.vue.ts +19 -9
- package/dist/runtime/components/app-shell/app-shell.vue +20 -16
- package/dist/runtime/components/app-shell/app-shell.vue.d.ts +19 -9
- package/dist/runtime/components/app-shell/context.d.ts +5 -5
- package/dist/runtime/components/checkbox/checkbox.d.vue.ts +3 -4
- package/dist/runtime/components/checkbox/checkbox.vue +4 -6
- package/dist/runtime/components/checkbox/checkbox.vue.d.ts +3 -4
- package/dist/runtime/components/index.d.ts +1 -0
- package/dist/runtime/components/index.js +1 -0
- package/dist/runtime/components/table/_ui/table-row.d.vue.ts +35 -0
- package/dist/runtime/components/table/_ui/table-row.vue +74 -0
- package/dist/runtime/components/table/_ui/table-row.vue.d.ts +35 -0
- package/dist/runtime/components/table/index.d.ts +1 -0
- package/dist/runtime/components/table/index.js +1 -0
- package/dist/runtime/components/table/lib.d.ts +6 -0
- package/dist/runtime/components/table/lib.js +24 -0
- package/dist/runtime/components/table/model.d.ts +150 -0
- package/dist/runtime/components/table/model.js +0 -0
- package/dist/runtime/components/table/table.d.ts +30 -0
- package/dist/runtime/components/table/table.d.vue.ts +48 -0
- package/dist/runtime/components/table/table.vue +520 -0
- package/dist/runtime/components/table/table.vue.d.ts +48 -0
- package/dist/runtime/components/tree/_ui/tree-root.d.vue.ts +2 -2
- package/dist/runtime/components/tree/_ui/tree-root.vue.d.ts +2 -2
- package/dist/runtime/components/tree/lib/item-handlers.js +2 -2
- package/dist/runtime/components/tree/tree.d.vue.ts +2 -2
- package/dist/runtime/components/tree/tree.vue.d.ts +2 -2
- package/package.json +7 -5
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ColumnFiltersState, ColumnOrderState, ColumnPinningState, ColumnSizingInfoState, ColumnSizingState, ExpandedState, GroupingState, PaginationState, RowPinningState, RowSelectionState, SortingState, VisibilityState } from '@tanstack/vue-table';
|
|
2
|
+
import type { TableData, TableProps, TableSlots } from './model.js';
|
|
3
|
+
declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: __VLS_PrettifyLocal<(TableProps<T> & {
|
|
5
|
+
globalFilter?: string;
|
|
6
|
+
columnFilters?: ColumnFiltersState;
|
|
7
|
+
columnOrder?: ColumnOrderState;
|
|
8
|
+
columnVisibility?: VisibilityState;
|
|
9
|
+
columnPinning?: ColumnPinningState;
|
|
10
|
+
columnSizing?: ColumnSizingState;
|
|
11
|
+
columnSizingInfo?: ColumnSizingInfoState;
|
|
12
|
+
rowSelection?: RowSelectionState;
|
|
13
|
+
rowPinning?: RowPinningState;
|
|
14
|
+
sorting?: SortingState;
|
|
15
|
+
grouping?: GroupingState;
|
|
16
|
+
expanded?: ExpandedState;
|
|
17
|
+
pagination?: PaginationState;
|
|
18
|
+
}) & {
|
|
19
|
+
"onUpdate:globalFilter"?: ((value: string | undefined) => any) | undefined;
|
|
20
|
+
"onUpdate:columnFilters"?: ((value: ColumnFiltersState | undefined) => any) | undefined;
|
|
21
|
+
"onUpdate:columnOrder"?: ((value: ColumnOrderState | undefined) => any) | undefined;
|
|
22
|
+
"onUpdate:columnVisibility"?: ((value: VisibilityState | undefined) => any) | undefined;
|
|
23
|
+
"onUpdate:columnPinning"?: ((value: ColumnPinningState | undefined) => any) | undefined;
|
|
24
|
+
"onUpdate:columnSizing"?: ((value: ColumnSizingState | undefined) => any) | undefined;
|
|
25
|
+
"onUpdate:columnSizingInfo"?: ((value: ColumnSizingInfoState | undefined) => any) | undefined;
|
|
26
|
+
"onUpdate:rowSelection"?: ((value: RowSelectionState | undefined) => any) | undefined;
|
|
27
|
+
"onUpdate:rowPinning"?: ((value: RowPinningState | undefined) => any) | undefined;
|
|
28
|
+
"onUpdate:sorting"?: ((value: SortingState | undefined) => any) | undefined;
|
|
29
|
+
"onUpdate:grouping"?: ((value: GroupingState | undefined) => any) | undefined;
|
|
30
|
+
"onUpdate:expanded"?: ((value: ExpandedState | undefined) => any) | undefined;
|
|
31
|
+
"onUpdate:pagination"?: ((value: PaginationState | undefined) => any) | undefined;
|
|
32
|
+
}> & import("vue").PublicProps;
|
|
33
|
+
expose: (exposed: import("vue").ShallowUnwrapRef<{
|
|
34
|
+
readonly $el: HTMLElement;
|
|
35
|
+
tableRef: Readonly<import("vue").ShallowRef<HTMLTableElement | null>>;
|
|
36
|
+
table: import("@tanstack/table-core").Table<T>;
|
|
37
|
+
}>) => void;
|
|
38
|
+
attrs: any;
|
|
39
|
+
slots: TableSlots<T>;
|
|
40
|
+
emit: ((evt: "update:globalFilter", value: string | undefined) => void) & ((evt: "update:columnFilters", value: ColumnFiltersState | undefined) => void) & ((evt: "update:columnOrder", value: ColumnOrderState | undefined) => void) & ((evt: "update:columnVisibility", value: VisibilityState | undefined) => void) & ((evt: "update:columnPinning", value: ColumnPinningState | undefined) => void) & ((evt: "update:columnSizing", value: ColumnSizingState | undefined) => void) & ((evt: "update:columnSizingInfo", value: ColumnSizingInfoState | undefined) => void) & ((evt: "update:rowSelection", value: RowSelectionState | undefined) => void) & ((evt: "update:rowPinning", value: RowPinningState | undefined) => void) & ((evt: "update:sorting", value: SortingState | undefined) => void) & ((evt: "update:grouping", value: GroupingState | undefined) => void) & ((evt: "update:expanded", value: ExpandedState | undefined) => void) & ((evt: "update:pagination", value: PaginationState | undefined) => void);
|
|
41
|
+
}>) => import("vue").VNode & {
|
|
42
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
43
|
+
};
|
|
44
|
+
declare const _default: typeof __VLS_export;
|
|
45
|
+
export default _default;
|
|
46
|
+
type __VLS_PrettifyLocal<T> = {
|
|
47
|
+
[K in keyof T as K]: T[K];
|
|
48
|
+
} & {};
|
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { FlexRender, getCoreRowModel, getExpandedRowModel, getFilteredRowModel, getSortedRowModel, useVueTable } from "@tanstack/vue-table";
|
|
3
|
+
import { useVirtualizer } from "@tanstack/vue-virtual";
|
|
4
|
+
import { reactivePick, unrefElement } from "@vueuse/core";
|
|
5
|
+
import { useStyleResolver } from "#imports";
|
|
6
|
+
import defu from "defu";
|
|
7
|
+
import { computed, ref, toRef, useTemplateRef, watch } from "vue";
|
|
8
|
+
import { getThemeColor } from "../../utils";
|
|
9
|
+
import Box from "../box.vue";
|
|
10
|
+
import TableRow from "./_ui/table-row.vue";
|
|
11
|
+
import { processColumns, resolveValue, valueUpdater } from "./lib";
|
|
12
|
+
defineOptions({ inheritAttrs: false });
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
data: { type: Array, required: false },
|
|
15
|
+
columns: { type: Array, required: false },
|
|
16
|
+
caption: { type: String, required: false },
|
|
17
|
+
meta: { type: Object, required: false },
|
|
18
|
+
virtualize: { type: [Boolean, Object], required: false },
|
|
19
|
+
empty: { type: String, required: false },
|
|
20
|
+
sticky: { type: [Boolean, String], required: false },
|
|
21
|
+
loading: { type: Boolean, required: false },
|
|
22
|
+
loadingColor: { type: null, required: false },
|
|
23
|
+
onSelect: { type: Function, required: false },
|
|
24
|
+
onHover: { type: Function, required: false },
|
|
25
|
+
onContextmenu: { type: [Function, Array], required: false },
|
|
26
|
+
classes: { type: Object, required: false },
|
|
27
|
+
watchOptions: { type: Object, required: false },
|
|
28
|
+
globalFilterOptions: { type: Object, required: false },
|
|
29
|
+
columnFiltersOptions: { type: Object, required: false },
|
|
30
|
+
columnPinningOptions: { type: Object, required: false },
|
|
31
|
+
columnSizingOptions: { type: Object, required: false },
|
|
32
|
+
visibilityOptions: { type: Object, required: false },
|
|
33
|
+
sortingOptions: { type: Object, required: false },
|
|
34
|
+
groupingOptions: { type: Object, required: false },
|
|
35
|
+
expandedOptions: { type: Object, required: false },
|
|
36
|
+
rowSelectionOptions: { type: Object, required: false },
|
|
37
|
+
rowPinningOptions: { type: Object, required: false },
|
|
38
|
+
paginationOptions: { type: Object, required: false },
|
|
39
|
+
facetedOptions: { type: Object, required: false },
|
|
40
|
+
state: { type: Object, required: false },
|
|
41
|
+
onStateChange: { type: Function, required: false },
|
|
42
|
+
renderFallbackValue: { type: null, required: false },
|
|
43
|
+
_features: { type: Array, required: false },
|
|
44
|
+
autoResetAll: { type: Boolean, required: false },
|
|
45
|
+
debugAll: { type: Boolean, required: false },
|
|
46
|
+
debugCells: { type: Boolean, required: false },
|
|
47
|
+
debugColumns: { type: Boolean, required: false },
|
|
48
|
+
debugHeaders: { type: Boolean, required: false },
|
|
49
|
+
debugRows: { type: Boolean, required: false },
|
|
50
|
+
debugTable: { type: Boolean, required: false },
|
|
51
|
+
defaultColumn: { type: Object, required: false },
|
|
52
|
+
getRowId: { type: Function, required: false },
|
|
53
|
+
getSubRows: { type: Function, required: false },
|
|
54
|
+
initialState: { type: Object, required: false },
|
|
55
|
+
mergeOptions: { type: Function, required: false }
|
|
56
|
+
});
|
|
57
|
+
defineSlots();
|
|
58
|
+
const data = ref(props.data ?? []);
|
|
59
|
+
const meta = computed(() => props?.meta ?? {});
|
|
60
|
+
const columns = computed(() => processColumns(props.columns ?? Object.keys(data.value[0] ?? {}).map((accessorKey) => ({ accessorKey, header: accessorKey }))));
|
|
61
|
+
const hasFooter = computed(() => {
|
|
62
|
+
function hasFooterRecursive(columns2) {
|
|
63
|
+
for (const column of columns2) {
|
|
64
|
+
if ("footer" in column)
|
|
65
|
+
return true;
|
|
66
|
+
if ("columns" in column && hasFooterRecursive(column.columns))
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return hasFooterRecursive(columns.value);
|
|
72
|
+
});
|
|
73
|
+
const globalFilterState = defineModel("globalFilter", { type: String });
|
|
74
|
+
const columnFiltersState = defineModel("columnFilters", { type: Array });
|
|
75
|
+
const columnOrderState = defineModel("columnOrder", { type: Array });
|
|
76
|
+
const columnVisibilityState = defineModel("columnVisibility", { type: Object });
|
|
77
|
+
const columnPinningState = defineModel("columnPinning", { type: Object });
|
|
78
|
+
const columnSizingState = defineModel("columnSizing", { type: Object });
|
|
79
|
+
const columnSizingInfoState = defineModel("columnSizingInfo", { type: Object });
|
|
80
|
+
const rowSelectionState = defineModel("rowSelection", { type: Object });
|
|
81
|
+
const rowPinningState = defineModel("rowPinning", { type: Object });
|
|
82
|
+
const sortingState = defineModel("sorting", { type: Array });
|
|
83
|
+
const groupingState = defineModel("grouping", { type: Array });
|
|
84
|
+
const expandedState = defineModel("expanded", { type: [Boolean, Object] });
|
|
85
|
+
const paginationState = defineModel("pagination", { type: Object });
|
|
86
|
+
const tableProps = reactivePick(props, "_features", "autoResetAll", "debugAll", "debugCells", "debugColumns", "debugHeaders", "debugRows", "debugTable", "defaultColumn", "getRowId", "getSubRows", "initialState", "mergeOptions", "renderFallbackValue");
|
|
87
|
+
const rootRef = useTemplateRef("rootRef");
|
|
88
|
+
const tableRef = useTemplateRef("tableRef");
|
|
89
|
+
const table = useVueTable({
|
|
90
|
+
...tableProps,
|
|
91
|
+
get data() {
|
|
92
|
+
return data.value;
|
|
93
|
+
},
|
|
94
|
+
get columns() {
|
|
95
|
+
return columns.value;
|
|
96
|
+
},
|
|
97
|
+
meta: meta.value,
|
|
98
|
+
getCoreRowModel: getCoreRowModel(),
|
|
99
|
+
...props.globalFilterOptions || {},
|
|
100
|
+
...globalFilterState.value !== void 0 && {
|
|
101
|
+
onGlobalFilterChange: (updaterOrValue) => valueUpdater(updaterOrValue, globalFilterState)
|
|
102
|
+
},
|
|
103
|
+
...props.columnFiltersOptions || {},
|
|
104
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
105
|
+
...columnFiltersState.value !== void 0 && {
|
|
106
|
+
onColumnFiltersChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnFiltersState)
|
|
107
|
+
},
|
|
108
|
+
...columnOrderState.value !== void 0 && {
|
|
109
|
+
onColumnOrderChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnOrderState)
|
|
110
|
+
},
|
|
111
|
+
...props.visibilityOptions || {},
|
|
112
|
+
...columnVisibilityState.value !== void 0 && {
|
|
113
|
+
onColumnVisibilityChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnVisibilityState)
|
|
114
|
+
},
|
|
115
|
+
...props.columnPinningOptions || {},
|
|
116
|
+
...columnPinningState.value !== void 0 && {
|
|
117
|
+
onColumnPinningChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnPinningState)
|
|
118
|
+
},
|
|
119
|
+
...props.columnSizingOptions || {},
|
|
120
|
+
...columnSizingState.value !== void 0 && {
|
|
121
|
+
onColumnSizingChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnSizingState)
|
|
122
|
+
},
|
|
123
|
+
...columnSizingInfoState.value !== void 0 && {
|
|
124
|
+
onColumnSizingInfoChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnSizingInfoState)
|
|
125
|
+
},
|
|
126
|
+
...props.rowSelectionOptions || {},
|
|
127
|
+
...rowSelectionState.value !== void 0 && {
|
|
128
|
+
onRowSelectionChange: (updaterOrValue) => valueUpdater(updaterOrValue, rowSelectionState)
|
|
129
|
+
},
|
|
130
|
+
...props.rowPinningOptions || {},
|
|
131
|
+
...rowPinningState.value !== void 0 && {
|
|
132
|
+
onRowPinningChange: (updaterOrValue) => valueUpdater(updaterOrValue, rowPinningState)
|
|
133
|
+
},
|
|
134
|
+
...props.sortingOptions || {},
|
|
135
|
+
getSortedRowModel: getSortedRowModel(),
|
|
136
|
+
...sortingState.value !== void 0 && {
|
|
137
|
+
onSortingChange: (updaterOrValue) => valueUpdater(updaterOrValue, sortingState)
|
|
138
|
+
},
|
|
139
|
+
...props.groupingOptions || {},
|
|
140
|
+
...groupingState.value !== void 0 && {
|
|
141
|
+
onGroupingChange: (updaterOrValue) => valueUpdater(updaterOrValue, groupingState)
|
|
142
|
+
},
|
|
143
|
+
...props.expandedOptions || {},
|
|
144
|
+
getExpandedRowModel: getExpandedRowModel(),
|
|
145
|
+
...expandedState.value !== void 0 && {
|
|
146
|
+
onExpandedChange: (updaterOrValue) => valueUpdater(updaterOrValue, expandedState)
|
|
147
|
+
},
|
|
148
|
+
...props.paginationOptions || {},
|
|
149
|
+
...paginationState.value !== void 0 && {
|
|
150
|
+
onPaginationChange: (updaterOrValue) => valueUpdater(updaterOrValue, paginationState)
|
|
151
|
+
},
|
|
152
|
+
...props.facetedOptions || {},
|
|
153
|
+
state: {
|
|
154
|
+
get globalFilter() {
|
|
155
|
+
return globalFilterState.value;
|
|
156
|
+
},
|
|
157
|
+
get columnFilters() {
|
|
158
|
+
return columnFiltersState.value;
|
|
159
|
+
},
|
|
160
|
+
get columnOrder() {
|
|
161
|
+
return columnOrderState.value;
|
|
162
|
+
},
|
|
163
|
+
get columnVisibility() {
|
|
164
|
+
return columnVisibilityState.value;
|
|
165
|
+
},
|
|
166
|
+
get columnPinning() {
|
|
167
|
+
return columnPinningState.value;
|
|
168
|
+
},
|
|
169
|
+
get expanded() {
|
|
170
|
+
return expandedState.value;
|
|
171
|
+
},
|
|
172
|
+
get rowSelection() {
|
|
173
|
+
return rowSelectionState.value;
|
|
174
|
+
},
|
|
175
|
+
get sorting() {
|
|
176
|
+
return sortingState.value;
|
|
177
|
+
},
|
|
178
|
+
get grouping() {
|
|
179
|
+
return groupingState.value;
|
|
180
|
+
},
|
|
181
|
+
get rowPinning() {
|
|
182
|
+
return rowPinningState.value;
|
|
183
|
+
},
|
|
184
|
+
get columnSizing() {
|
|
185
|
+
return columnSizingState.value;
|
|
186
|
+
},
|
|
187
|
+
get columnSizingInfo() {
|
|
188
|
+
return columnSizingInfoState.value;
|
|
189
|
+
},
|
|
190
|
+
get pagination() {
|
|
191
|
+
return paginationState.value;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
const rows = computed(() => table.getRowModel().rows);
|
|
196
|
+
watch(() => props.data, () => {
|
|
197
|
+
data.value = props.data ? [...props.data] : [];
|
|
198
|
+
}, props.watchOptions);
|
|
199
|
+
const virtualizerProps = toRef(() => defu(typeof props.virtualize === "boolean" ? {} : props.virtualize, {
|
|
200
|
+
estimateSize: 65,
|
|
201
|
+
overscan: 12
|
|
202
|
+
}));
|
|
203
|
+
const virtualizer = !!props.virtualize && useVirtualizer({
|
|
204
|
+
...virtualizerProps.value,
|
|
205
|
+
get count() {
|
|
206
|
+
return rows.value.length;
|
|
207
|
+
},
|
|
208
|
+
getScrollElement: () => unrefElement(rootRef),
|
|
209
|
+
estimateSize: (index) => {
|
|
210
|
+
const estimate = virtualizerProps.value.estimateSize;
|
|
211
|
+
return typeof estimate === "function" ? estimate(index) : estimate;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
const renderedSize = computed(() => {
|
|
215
|
+
if (!virtualizer)
|
|
216
|
+
return 0;
|
|
217
|
+
const virtualItems = virtualizer.value.getVirtualItems();
|
|
218
|
+
if (!virtualItems?.length)
|
|
219
|
+
return 0;
|
|
220
|
+
return virtualItems.reduce((sum, item) => sum + item.size, 0);
|
|
221
|
+
});
|
|
222
|
+
const style = computed(() => useStyleResolver((theme) => ({
|
|
223
|
+
"--table-loader-color": props.loadingColor ? getThemeColor(props.loadingColor, theme) : void 0
|
|
224
|
+
})));
|
|
225
|
+
defineExpose({
|
|
226
|
+
get $el() {
|
|
227
|
+
return unrefElement(rootRef);
|
|
228
|
+
},
|
|
229
|
+
tableRef,
|
|
230
|
+
table
|
|
231
|
+
});
|
|
232
|
+
</script>
|
|
233
|
+
|
|
234
|
+
<template>
|
|
235
|
+
<Box
|
|
236
|
+
ref='rootRef'
|
|
237
|
+
:class='[$style.root, props.classes?.root]'
|
|
238
|
+
:style='[
|
|
239
|
+
virtualizer ? { height: `${virtualizer.getTotalSize()}px` } : void 0,
|
|
240
|
+
style
|
|
241
|
+
]'
|
|
242
|
+
:mod='{ virtualize: !!virtualizer }'
|
|
243
|
+
>
|
|
244
|
+
<table ref='tableRef' :class='[$style.table, props.classes?.table]'>
|
|
245
|
+
<caption v-if='caption || $slots.caption' :class='props.classes?.caption'>
|
|
246
|
+
<slot name='caption'>
|
|
247
|
+
{{ props.caption }}
|
|
248
|
+
</slot>
|
|
249
|
+
</caption>
|
|
250
|
+
|
|
251
|
+
<Box
|
|
252
|
+
is='thead'
|
|
253
|
+
:class='$style.thead'
|
|
254
|
+
:mod='{
|
|
255
|
+
sticky: props.sticky === "header" || props.sticky === true,
|
|
256
|
+
loading: props.loading
|
|
257
|
+
}'
|
|
258
|
+
>
|
|
259
|
+
<tr v-for='headerGroup in table.getHeaderGroups()' :key='headerGroup.id' :class='$style.tr'>
|
|
260
|
+
<Box
|
|
261
|
+
is='th'
|
|
262
|
+
v-for='header in headerGroup.headers'
|
|
263
|
+
:key='header.id'
|
|
264
|
+
:mod='{ pinned: header.column.getIsPinned() }'
|
|
265
|
+
:scope="header.colSpan > 1 ? 'colgroup' : 'col'"
|
|
266
|
+
:colspan='header.colSpan > 1 ? header.colSpan : void 0'
|
|
267
|
+
:rowspan='header.rowSpan > 1 ? header.rowSpan : void 0'
|
|
268
|
+
:class='[$style.th, props.classes?.th, resolveValue(header.column.columnDef.meta?.class?.th, header)]'
|
|
269
|
+
:style='resolveValue(header.column.columnDef.meta?.style?.th, header)'
|
|
270
|
+
>
|
|
271
|
+
<slot :name='`${header.id}-header`' v-bind='header.getContext()'>
|
|
272
|
+
<FlexRender
|
|
273
|
+
v-if='!header.isPlaceholder'
|
|
274
|
+
:render='header.column.columnDef.header'
|
|
275
|
+
:props='header.getContext()'
|
|
276
|
+
/>
|
|
277
|
+
</slot>
|
|
278
|
+
</Box>
|
|
279
|
+
</tr>
|
|
280
|
+
|
|
281
|
+
<tr :class='[$style.separator, props.classes?.separator]' />
|
|
282
|
+
</Box>
|
|
283
|
+
|
|
284
|
+
<tbody :class='[$style.tbody, props.classes?.tbody]'>
|
|
285
|
+
<slot name='body-top' />
|
|
286
|
+
|
|
287
|
+
<template v-if='rows.length'>
|
|
288
|
+
<template v-if='virtualizer'>
|
|
289
|
+
<template v-for='(virtualRow, index) in virtualizer.getVirtualItems()' :key='rows[virtualRow.index]?.id'>
|
|
290
|
+
<TableRow
|
|
291
|
+
:row='rows[virtualRow.index]'
|
|
292
|
+
:class='[$style.tr, props.classes?.tr, resolveValue(table.options.meta?.class?.tr, virtualRow)]'
|
|
293
|
+
:style='[
|
|
294
|
+
{
|
|
295
|
+
height: `${virtualRow.size}px`,
|
|
296
|
+
transform: `translateY(${virtualRow.start - index * virtualRow.size}px)`
|
|
297
|
+
},
|
|
298
|
+
resolveValue(table.options.meta?.style?.tr, virtualRow)
|
|
299
|
+
]'
|
|
300
|
+
:on-select='props?.onSelect'
|
|
301
|
+
:on-hover='props?.onHover'
|
|
302
|
+
:on-contextmenu='props?.onContextmenu'
|
|
303
|
+
/>
|
|
304
|
+
</template>
|
|
305
|
+
</template>
|
|
306
|
+
|
|
307
|
+
<template v-else>
|
|
308
|
+
<TableRow
|
|
309
|
+
v-for='row in rows'
|
|
310
|
+
:key='row.id'
|
|
311
|
+
:row='row'
|
|
312
|
+
:class='[$style.tr, props.classes?.tr, resolveValue(table.options.meta?.class?.tr, row)]'
|
|
313
|
+
:style='resolveValue(table.options.meta?.style?.tr, row)'
|
|
314
|
+
:on-select='props?.onSelect'
|
|
315
|
+
:on-hover='props?.onHover'
|
|
316
|
+
:on-contextmenu='props?.onContextmenu'
|
|
317
|
+
/>
|
|
318
|
+
</template>
|
|
319
|
+
</template>
|
|
320
|
+
|
|
321
|
+
<tr v-else-if='loading && !!$slots.loading'>
|
|
322
|
+
<td :colspan='table.getAllLeafColumns().length' :class='[$style.loading, props.classes?.loading]'>
|
|
323
|
+
<slot name='loading' />
|
|
324
|
+
</td>
|
|
325
|
+
</tr>
|
|
326
|
+
|
|
327
|
+
<tr v-else>
|
|
328
|
+
<td :colspan='table.getAllLeafColumns().length' :class='[$style.empty, props.classes?.empty]'>
|
|
329
|
+
<slot name='empty'>
|
|
330
|
+
{{ empty || "\u041D\u0435\u0442 \u0434\u0430\u043D\u043D\u044B\u0445" }}
|
|
331
|
+
</slot>
|
|
332
|
+
</td>
|
|
333
|
+
</tr>
|
|
334
|
+
|
|
335
|
+
<slot name='body-bottom' />
|
|
336
|
+
</tbody>
|
|
337
|
+
|
|
338
|
+
<Box
|
|
339
|
+
is='tfoot'
|
|
340
|
+
v-if='hasFooter'
|
|
341
|
+
:class='[$style.tfoot, props.classes?.tfoot]'
|
|
342
|
+
:style='virtualizer ? { transform: `translateY(${virtualizer.getTotalSize() - renderedSize}px)` } : void 0'
|
|
343
|
+
:mod='{ sticky: props.sticky === "footer" || props.sticky === true }'
|
|
344
|
+
>
|
|
345
|
+
<tr :class='[$style.separator, props.classes?.separator]' />
|
|
346
|
+
|
|
347
|
+
<tr v-for='footerGroup in table.getFooterGroups()' :key='footerGroup.id' :class='[$style.tr, props.classes?.tr]'>
|
|
348
|
+
<Box
|
|
349
|
+
is='th'
|
|
350
|
+
v-for='header in footerGroup.headers'
|
|
351
|
+
:key='header.id'
|
|
352
|
+
:mod='{ pinned: header.column.getIsPinned() }'
|
|
353
|
+
:colspan='header.colSpan > 1 ? header.colSpan : void 0'
|
|
354
|
+
:rowspan='header.rowSpan > 1 ? header.rowSpan : void 0'
|
|
355
|
+
:class='[$style.th, props.classes?.th, resolveValue(header.column.columnDef.meta?.class?.th, header)]'
|
|
356
|
+
:style='resolveValue(header.column.columnDef.meta?.style?.th, header)'
|
|
357
|
+
>
|
|
358
|
+
<slot :name='`${header.id}-footer`' v-bind='header.getContext()'>
|
|
359
|
+
<FlexRender
|
|
360
|
+
v-if='!header.isPlaceholder'
|
|
361
|
+
:render='header.column.columnDef.footer'
|
|
362
|
+
:props='header.getContext()'
|
|
363
|
+
/>
|
|
364
|
+
</slot>
|
|
365
|
+
</Box>
|
|
366
|
+
</tr>
|
|
367
|
+
</Box>
|
|
368
|
+
</table>
|
|
369
|
+
</Box>
|
|
370
|
+
</template>
|
|
371
|
+
|
|
372
|
+
<style lang="postcss" module>
|
|
373
|
+
.root {
|
|
374
|
+
--table-color: var(--color-primary-4);
|
|
375
|
+
--table-loader-color: var(--table-color);
|
|
376
|
+
--table-loader-animation: carousel 2s ease-in-out infinite;
|
|
377
|
+
|
|
378
|
+
@mixin where-light {
|
|
379
|
+
--table-active-bg: alpha(var(--color-slate-1), .5);
|
|
380
|
+
--table-c: var(--color-slate-7);
|
|
381
|
+
--table-bd-color: var(--color-slate-3);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
@mixin where-dark {
|
|
385
|
+
--table-active-bg: alpha(var(--color-slate-7), .5);
|
|
386
|
+
--table-c: var(--color-slate-4);
|
|
387
|
+
--table-bd-color: var(--color-slate-7);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
position: relative;
|
|
391
|
+
overflow: auto;
|
|
392
|
+
|
|
393
|
+
&:not([data-virtualize]) {
|
|
394
|
+
.table {
|
|
395
|
+
overflow: clip;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.tbody > tr:not(:last-of-type) {
|
|
399
|
+
border-bottom: 1px solid var(--table-bd-color);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.table {
|
|
405
|
+
min-width: 100%;
|
|
406
|
+
border-collapse: collapse;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
.thead {
|
|
410
|
+
position: relative;
|
|
411
|
+
|
|
412
|
+
&[data-loading]::after {
|
|
413
|
+
content: '';
|
|
414
|
+
position: absolute;
|
|
415
|
+
z-index: 1;
|
|
416
|
+
height: 1px;
|
|
417
|
+
background-color: alpha(var(--table-loader-color), .75);
|
|
418
|
+
animation: var(--table-loader-animation);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
&[data-sticky] {
|
|
422
|
+
position: sticky;
|
|
423
|
+
top: 0;
|
|
424
|
+
inset-inline: 0rem;
|
|
425
|
+
z-index: 1;
|
|
426
|
+
|
|
427
|
+
background-color: alpha(var(--color-body), .75);
|
|
428
|
+
backdrop-filter: blur(8px);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.th {
|
|
433
|
+
font-weight: 600;
|
|
434
|
+
padding-block: .75rem;
|
|
435
|
+
padding-inline: 1rem;
|
|
436
|
+
text-align: left;
|
|
437
|
+
color: var(--table-c);
|
|
438
|
+
|
|
439
|
+
&:has([role='checkbox']) {
|
|
440
|
+
padding-inline-end: 0;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.th[data-pinned],
|
|
445
|
+
.tr td[data-pinned] {
|
|
446
|
+
position: sticky;
|
|
447
|
+
z-index: 1;
|
|
448
|
+
background-color: alpha(var(--color-body), .75);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.tbody {
|
|
452
|
+
isolation: isolate;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.tfoot {
|
|
456
|
+
position: relative;
|
|
457
|
+
|
|
458
|
+
&[data-sticky] {
|
|
459
|
+
position: sticky;
|
|
460
|
+
bottom: 0;
|
|
461
|
+
inset-inline: 0rem;
|
|
462
|
+
z-index: 1;
|
|
463
|
+
|
|
464
|
+
background-color: var(--color-body);
|
|
465
|
+
backdrop-filter: blur(8px);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.tr {
|
|
470
|
+
&[data-selectable] {
|
|
471
|
+
&:hover {
|
|
472
|
+
background-color: var(--table-active-bg);
|
|
473
|
+
}
|
|
474
|
+
&:focus-visible {
|
|
475
|
+
outline: 1px solid var(--table-color);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
&[data-selected] {
|
|
480
|
+
background-color: var(--table-active-bg);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
td {
|
|
484
|
+
white-space: nowrap;
|
|
485
|
+
padding: 1rem;
|
|
486
|
+
color: var(--table-c);
|
|
487
|
+
|
|
488
|
+
&:has([role='checkbox']) {
|
|
489
|
+
padding-inline-end: 0;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.separator {
|
|
495
|
+
position: absolute;
|
|
496
|
+
z-index: 1;
|
|
497
|
+
left: 0;
|
|
498
|
+
width: 100%;
|
|
499
|
+
height: 1px;
|
|
500
|
+
background-color: var(--table-bd-color);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
.loading,
|
|
504
|
+
.empty {
|
|
505
|
+
padding-inline: 1.5rem;
|
|
506
|
+
text-align: center;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
@keyframes carousel {
|
|
510
|
+
0%, to{
|
|
511
|
+
width:50%
|
|
512
|
+
}
|
|
513
|
+
0%{
|
|
514
|
+
transform:translate(-100%)
|
|
515
|
+
}
|
|
516
|
+
to{
|
|
517
|
+
transform:translate(200%)
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
</style>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ColumnFiltersState, ColumnOrderState, ColumnPinningState, ColumnSizingInfoState, ColumnSizingState, ExpandedState, GroupingState, PaginationState, RowPinningState, RowSelectionState, SortingState, VisibilityState } from '@tanstack/vue-table';
|
|
2
|
+
import type { TableData, TableProps, TableSlots } from './model.js';
|
|
3
|
+
declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: __VLS_PrettifyLocal<(TableProps<T> & {
|
|
5
|
+
globalFilter?: string;
|
|
6
|
+
columnFilters?: ColumnFiltersState;
|
|
7
|
+
columnOrder?: ColumnOrderState;
|
|
8
|
+
columnVisibility?: VisibilityState;
|
|
9
|
+
columnPinning?: ColumnPinningState;
|
|
10
|
+
columnSizing?: ColumnSizingState;
|
|
11
|
+
columnSizingInfo?: ColumnSizingInfoState;
|
|
12
|
+
rowSelection?: RowSelectionState;
|
|
13
|
+
rowPinning?: RowPinningState;
|
|
14
|
+
sorting?: SortingState;
|
|
15
|
+
grouping?: GroupingState;
|
|
16
|
+
expanded?: ExpandedState;
|
|
17
|
+
pagination?: PaginationState;
|
|
18
|
+
}) & {
|
|
19
|
+
"onUpdate:globalFilter"?: ((value: string | undefined) => any) | undefined;
|
|
20
|
+
"onUpdate:columnFilters"?: ((value: ColumnFiltersState | undefined) => any) | undefined;
|
|
21
|
+
"onUpdate:columnOrder"?: ((value: ColumnOrderState | undefined) => any) | undefined;
|
|
22
|
+
"onUpdate:columnVisibility"?: ((value: VisibilityState | undefined) => any) | undefined;
|
|
23
|
+
"onUpdate:columnPinning"?: ((value: ColumnPinningState | undefined) => any) | undefined;
|
|
24
|
+
"onUpdate:columnSizing"?: ((value: ColumnSizingState | undefined) => any) | undefined;
|
|
25
|
+
"onUpdate:columnSizingInfo"?: ((value: ColumnSizingInfoState | undefined) => any) | undefined;
|
|
26
|
+
"onUpdate:rowSelection"?: ((value: RowSelectionState | undefined) => any) | undefined;
|
|
27
|
+
"onUpdate:rowPinning"?: ((value: RowPinningState | undefined) => any) | undefined;
|
|
28
|
+
"onUpdate:sorting"?: ((value: SortingState | undefined) => any) | undefined;
|
|
29
|
+
"onUpdate:grouping"?: ((value: GroupingState | undefined) => any) | undefined;
|
|
30
|
+
"onUpdate:expanded"?: ((value: ExpandedState | undefined) => any) | undefined;
|
|
31
|
+
"onUpdate:pagination"?: ((value: PaginationState | undefined) => any) | undefined;
|
|
32
|
+
}> & import("vue").PublicProps;
|
|
33
|
+
expose: (exposed: import("vue").ShallowUnwrapRef<{
|
|
34
|
+
readonly $el: HTMLElement;
|
|
35
|
+
tableRef: Readonly<import("vue").ShallowRef<HTMLTableElement | null>>;
|
|
36
|
+
table: import("@tanstack/table-core").Table<T>;
|
|
37
|
+
}>) => void;
|
|
38
|
+
attrs: any;
|
|
39
|
+
slots: TableSlots<T>;
|
|
40
|
+
emit: ((evt: "update:globalFilter", value: string | undefined) => void) & ((evt: "update:columnFilters", value: ColumnFiltersState | undefined) => void) & ((evt: "update:columnOrder", value: ColumnOrderState | undefined) => void) & ((evt: "update:columnVisibility", value: VisibilityState | undefined) => void) & ((evt: "update:columnPinning", value: ColumnPinningState | undefined) => void) & ((evt: "update:columnSizing", value: ColumnSizingState | undefined) => void) & ((evt: "update:columnSizingInfo", value: ColumnSizingInfoState | undefined) => void) & ((evt: "update:rowSelection", value: RowSelectionState | undefined) => void) & ((evt: "update:rowPinning", value: RowPinningState | undefined) => void) & ((evt: "update:sorting", value: SortingState | undefined) => void) & ((evt: "update:grouping", value: GroupingState | undefined) => void) & ((evt: "update:expanded", value: ExpandedState | undefined) => void) & ((evt: "update:pagination", value: PaginationState | undefined) => void);
|
|
41
|
+
}>) => import("vue").VNode & {
|
|
42
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
43
|
+
};
|
|
44
|
+
declare const _default: typeof __VLS_export;
|
|
45
|
+
export default _default;
|
|
46
|
+
type __VLS_PrettifyLocal<T> = {
|
|
47
|
+
[K in keyof T as K]: T[K];
|
|
48
|
+
} & {};
|
|
@@ -23,14 +23,14 @@ type __VLS_Slots = {} & {
|
|
|
23
23
|
};
|
|
24
24
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
25
25
|
delete: (path: string[]) => any;
|
|
26
|
+
"update:expanded": (value: string[]) => any;
|
|
26
27
|
"update:active": (value: string | null) => any;
|
|
27
28
|
"update:selected": (value: string[]) => any;
|
|
28
|
-
"update:expanded": (value: string[]) => any;
|
|
29
29
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
30
30
|
onDelete?: ((path: string[]) => any) | undefined;
|
|
31
|
+
"onUpdate:expanded"?: ((value: string[]) => any) | undefined;
|
|
31
32
|
"onUpdate:active"?: ((value: string | null) => any) | undefined;
|
|
32
33
|
"onUpdate:selected"?: ((value: string[]) => any) | undefined;
|
|
33
|
-
"onUpdate:expanded"?: ((value: string[]) => any) | undefined;
|
|
34
34
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
35
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
36
36
|
declare const _default: typeof __VLS_export;
|
|
@@ -23,14 +23,14 @@ type __VLS_Slots = {} & {
|
|
|
23
23
|
};
|
|
24
24
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
25
25
|
delete: (path: string[]) => any;
|
|
26
|
+
"update:expanded": (value: string[]) => any;
|
|
26
27
|
"update:active": (value: string | null) => any;
|
|
27
28
|
"update:selected": (value: string[]) => any;
|
|
28
|
-
"update:expanded": (value: string[]) => any;
|
|
29
29
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
30
30
|
onDelete?: ((path: string[]) => any) | undefined;
|
|
31
|
+
"onUpdate:expanded"?: ((value: string[]) => any) | undefined;
|
|
31
32
|
"onUpdate:active"?: ((value: string | null) => any) | undefined;
|
|
32
33
|
"onUpdate:selected"?: ((value: string[]) => any) | undefined;
|
|
33
|
-
"onUpdate:expanded"?: ((value: string[]) => any) | undefined;
|
|
34
34
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
35
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
36
36
|
declare const _default: typeof __VLS_export;
|
|
@@ -21,7 +21,7 @@ export function useTreeItemHandlers(path, isFolder, expanded) {
|
|
|
21
21
|
if (isFolder.value && expanded.value)
|
|
22
22
|
return ctx.off("expand", path);
|
|
23
23
|
else
|
|
24
|
-
return focus("prev", event.currentTarget);
|
|
24
|
+
return focus?.("prev", event.currentTarget);
|
|
25
25
|
}
|
|
26
26
|
// Arrow Right - открыть папку или перейти к первому ребенку
|
|
27
27
|
case "ArrowRight": {
|
|
@@ -29,7 +29,7 @@ export function useTreeItemHandlers(path, isFolder, expanded) {
|
|
|
29
29
|
if (isFolder.value && !expanded.value)
|
|
30
30
|
return ctx.on("expand", path);
|
|
31
31
|
else if (expanded.value)
|
|
32
|
-
return focus("next", event.currentTarget);
|
|
32
|
+
return focus?.("next", event.currentTarget);
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
35
35
|
// Enter/Space - выбор элемента
|