@shwfed/nuxt 0.7.9 → 0.7.10
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.d.vue.ts +7 -56
- package/dist/runtime/components/app.vue +17 -404
- package/dist/runtime/components/app.vue.d.ts +7 -56
- package/dist/runtime/components/fields.d.vue.ts +154 -132
- package/dist/runtime/components/fields.vue +30 -295
- package/dist/runtime/components/fields.vue.d.ts +154 -132
- package/dist/runtime/components/table.d.vue.ts +63 -59
- package/dist/runtime/components/table.vue +52 -617
- package/dist/runtime/components/table.vue.d.ts +63 -59
- package/dist/runtime/components/ui/app/App.d.vue.ts +86 -0
- package/dist/runtime/components/ui/app/App.vue +414 -0
- package/dist/runtime/components/ui/app/App.vue.d.ts +86 -0
- package/dist/runtime/components/ui/checkbox/Checkbox.vue +6 -2
- package/dist/runtime/components/ui/expression-editor/ExpressionEditor.d.vue.ts +30 -0
- package/dist/runtime/components/ui/expression-editor/ExpressionEditor.vue +87 -0
- package/dist/runtime/components/ui/expression-editor/ExpressionEditor.vue.d.ts +30 -0
- package/dist/runtime/components/ui/expression-editor/index.d.ts +1 -0
- package/dist/runtime/components/ui/expression-editor/index.js +1 -0
- package/dist/runtime/components/ui/field/FieldContent.vue +1 -1
- package/dist/runtime/components/ui/field/FieldError.vue +2 -2
- package/dist/runtime/components/ui/fields/Fields.d.vue.ts +376 -0
- package/dist/runtime/components/ui/fields/Fields.vue +441 -0
- package/dist/runtime/components/ui/fields/Fields.vue.d.ts +376 -0
- package/dist/runtime/components/ui/fields-configurator/FieldsConfiguratorDialog.d.vue.ts +163 -0
- package/dist/runtime/components/ui/fields-configurator/FieldsConfiguratorDialog.vue +363 -0
- package/dist/runtime/components/ui/fields-configurator/FieldsConfiguratorDialog.vue.d.ts +163 -0
- package/dist/runtime/components/ui/input/Input.d.vue.ts +1 -0
- package/dist/runtime/components/ui/input/Input.vue +2 -0
- package/dist/runtime/components/ui/input/Input.vue.d.ts +1 -0
- package/dist/runtime/components/ui/input-group/InputGroupAddon.vue +4 -1
- package/dist/runtime/components/ui/input-group/InputGroupCombobox.d.vue.ts +8 -3
- package/dist/runtime/components/ui/input-group/InputGroupCombobox.vue +8 -3
- package/dist/runtime/components/ui/input-group/InputGroupCombobox.vue.d.ts +8 -3
- package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.d.vue.ts +8 -1
- package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.vue +10 -1
- package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.vue.d.ts +8 -1
- package/dist/runtime/components/ui/input-group/InputGroupNumberField.d.vue.ts +5 -2
- package/dist/runtime/components/ui/input-group/InputGroupNumberField.vue +9 -3
- package/dist/runtime/components/ui/input-group/InputGroupNumberField.vue.d.ts +5 -2
- package/dist/runtime/components/ui/input-group/index.js +1 -1
- package/dist/runtime/components/ui/locale/Locale.d.vue.ts +20 -0
- package/dist/runtime/components/ui/locale/Locale.vue +291 -0
- package/dist/runtime/components/ui/locale/Locale.vue.d.ts +20 -0
- package/dist/runtime/components/ui/locale/index.d.ts +1 -0
- package/dist/runtime/components/ui/locale/index.js +1 -0
- package/dist/runtime/components/ui/native-select/NativeSelectOption.d.vue.ts +1 -0
- package/dist/runtime/components/ui/native-select/NativeSelectOption.vue +4 -1
- package/dist/runtime/components/ui/native-select/NativeSelectOption.vue.d.ts +1 -0
- package/dist/runtime/components/ui/number-field/NumberFieldInput.vue +1 -1
- package/dist/runtime/components/ui/switch/Switch.vue +1 -1
- package/dist/runtime/components/ui/table/Table.d.vue.ts +81 -0
- package/dist/runtime/components/ui/table/Table.vue +792 -0
- package/dist/runtime/components/ui/table/Table.vue.d.ts +81 -0
- package/dist/runtime/components/ui/table/schema.d.ts +48 -0
- package/dist/runtime/components/ui/table/schema.js +126 -0
- package/dist/runtime/components/ui/table-configurator/TableConfiguratorDialog.d.vue.ts +62 -0
- package/dist/runtime/components/ui/table-configurator/TableConfiguratorDialog.vue +2233 -0
- package/dist/runtime/components/ui/table-configurator/TableConfiguratorDialog.vue.d.ts +62 -0
- package/dist/runtime/components/ui/table-configurator/menu.d.ts +37 -0
- package/dist/runtime/components/ui/table-configurator/menu.js +227 -0
- package/dist/runtime/components/ui/tabs/Tabs.d.vue.ts +24 -0
- package/dist/runtime/components/ui/tabs/Tabs.vue +30 -0
- package/dist/runtime/components/ui/tabs/Tabs.vue.d.ts +24 -0
- package/dist/runtime/components/ui/tabs/TabsContent.d.vue.ts +18 -0
- package/dist/runtime/components/ui/tabs/TabsContent.vue +23 -0
- package/dist/runtime/components/ui/tabs/TabsContent.vue.d.ts +18 -0
- package/dist/runtime/components/ui/tabs/TabsList.d.vue.ts +18 -0
- package/dist/runtime/components/ui/tabs/TabsList.vue +25 -0
- package/dist/runtime/components/ui/tabs/TabsList.vue.d.ts +18 -0
- package/dist/runtime/components/ui/tabs/TabsTrigger.d.vue.ts +18 -0
- package/dist/runtime/components/ui/tabs/TabsTrigger.vue +27 -0
- package/dist/runtime/components/ui/tabs/TabsTrigger.vue.d.ts +18 -0
- package/dist/runtime/components/ui/tabs/index.d.ts +4 -0
- package/dist/runtime/components/ui/tabs/index.js +4 -0
- package/dist/runtime/components/ui/textarea/Textarea.d.vue.ts +1 -0
- package/dist/runtime/components/ui/textarea/Textarea.vue +3 -1
- package/dist/runtime/components/ui/textarea/Textarea.vue.d.ts +1 -0
- package/dist/runtime/components/ui/toggle/Toggle.d.vue.ts +34 -0
- package/dist/runtime/components/ui/toggle/Toggle.vue +32 -0
- package/dist/runtime/components/ui/toggle/Toggle.vue.d.ts +34 -0
- package/dist/runtime/components/ui/toggle/index.d.ts +7 -0
- package/dist/runtime/components/ui/toggle/index.js +22 -0
- package/dist/runtime/composables/useTableRenderers.d.ts +2 -1
- package/dist/runtime/composables/useTableRenderers.js +2 -1
- package/dist/runtime/style.css +1 -1
- package/dist/runtime/table-renderers/builtins.js +213 -98
- package/dist/runtime/table-renderers/registry.d.ts +1 -0
- package/dist/runtime/table-renderers/registry.js +3 -0
- package/dist/runtime/utils/coders.d.ts +27 -2
- package/dist/runtime/utils/coders.js +27 -2
- package/package.json +3 -1
- /package/dist/runtime/components/{logo.d.vue.ts → ui/logo/Logo.d.vue.ts} +0 -0
- /package/dist/runtime/components/{logo.vue → ui/logo/Logo.vue} +0 -0
- /package/dist/runtime/components/{logo.vue.d.ts → ui/logo/Logo.vue.d.ts} +0 -0
|
@@ -1,633 +1,68 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { FlexRender, getCoreRowModel, getExpandedRowModel, getPaginationRowModel, useVueTable } from "@tanstack/vue-table";
|
|
3
|
-
import { useVirtualizer } from "@tanstack/vue-virtual";
|
|
4
|
-
import { Icon } from "@iconify/vue";
|
|
5
|
-
import { getProperty } from "dot-prop";
|
|
6
|
-
import { Pagination } from "reka-ui/namespaced";
|
|
7
|
-
import { useI18n } from "vue-i18n";
|
|
8
|
-
import { computed, ref } from "vue";
|
|
9
|
-
import { useNuxtApp } from "#app";
|
|
10
|
-
import { Button } from "./ui/button";
|
|
11
|
-
import { NumberField, NumberFieldInput } from "./ui/number-field";
|
|
12
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
|
|
13
|
-
import { useTableRenderers } from "../composables/useTableRenderers";
|
|
14
|
-
import { useCheating } from "#imports";
|
|
15
|
-
import { defu } from "defu";
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
1
|
<script setup>
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import UiTable from "./ui/table/Table.vue";
|
|
4
|
+
defineOptions({
|
|
5
|
+
inheritAttrs: false
|
|
6
|
+
});
|
|
19
7
|
const props = defineProps({
|
|
20
|
-
|
|
21
|
-
getRowId: { type: String, required: false, default: void 0 },
|
|
22
|
-
getSubRows: { type: String, required: false, default: void 0 },
|
|
23
|
-
enableRowSelection: { type: String, required: false, default: void 0 },
|
|
24
|
-
enableMultiRowSelection: { type: String, required: false, default: void 0 },
|
|
25
|
-
columns: { type: Array, required: true },
|
|
8
|
+
config: { type: null, required: true },
|
|
26
9
|
data: { type: Array, required: true },
|
|
27
|
-
|
|
28
|
-
props: { type: Object, required: false, default: void 0 },
|
|
29
|
-
paginationLeft: { type: String, required: false },
|
|
30
|
-
paginationRight: { type: String, required: false }
|
|
10
|
+
rowCount: { type: Number, required: false }
|
|
31
11
|
});
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return defu(
|
|
36
|
-
acc,
|
|
37
|
-
Object.fromEntries(
|
|
38
|
-
Object.entries(
|
|
39
|
-
column2.title ?? {}
|
|
40
|
-
).map(([locale, message]) => [locale, { [genColumnId(column2)]: message }])
|
|
41
|
-
),
|
|
42
|
-
column2.tooltip ? Object.fromEntries(Object.entries(column2.tooltip).map(([locale, message]) => [locale, { [`${genColumnId(column2)}-tooltip`]: message }])) : {},
|
|
43
|
-
...column2.columns?.map((column3) => f(column3)) ?? []
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
return f(column);
|
|
47
|
-
}, {})
|
|
48
|
-
});
|
|
49
|
-
const slots = defineSlots();
|
|
50
|
-
const { $dsl } = useNuxtApp();
|
|
51
|
-
const isCheating = useCheating();
|
|
52
|
-
const { resolveTableRenderer } = useTableRenderers();
|
|
53
|
-
const containerRef = ref(null);
|
|
54
|
-
function genColumnId(column) {
|
|
55
|
-
if (typeof column.accessor === "string") {
|
|
56
|
-
return column.accessor;
|
|
57
|
-
} else if (column.accessor) {
|
|
58
|
-
return column.accessor.read;
|
|
59
|
-
} else if (column.id) {
|
|
60
|
-
return column.id;
|
|
61
|
-
}
|
|
62
|
-
return crypto.randomUUID();
|
|
12
|
+
const emit = defineEmits(["update:config"]);
|
|
13
|
+
function handleConfigUpdate(config) {
|
|
14
|
+
emit("update:config", config);
|
|
63
15
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
header: t(genColumnId(column)),
|
|
69
|
-
columns: column.columns?.map((column2) => translate(column2)) ?? [],
|
|
70
|
-
enableSorting: column.enableSorting ?? false,
|
|
71
|
-
enableMultiSort: column.enableMultiSorting,
|
|
72
|
-
enablePinning: column.enablePinning,
|
|
73
|
-
size: column.size,
|
|
74
|
-
meta: {
|
|
75
|
-
tooltip: column.tooltip ? `${genColumnId(column)}-tooltip` : void 0,
|
|
76
|
-
grow: column.grow ?? false
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const renderer = resolveTableRenderer(typeof column.renderer === "string" ? column.renderer : column.renderer?.id ? column.renderer.id : "table.renderer.text");
|
|
81
|
-
const options = renderer.parseOptions(column.renderer && typeof column.renderer === "object" && "props" in column.renderer ? column.renderer.props : null);
|
|
82
|
-
return {
|
|
83
|
-
id: column.id ?? genColumnId(column),
|
|
84
|
-
header: (ctx) => renderer.header?.({ ctx, options }) ?? t(genColumnId(column)),
|
|
85
|
-
cell: (ctx) => {
|
|
86
|
-
if (ctx.column.id in slots) {
|
|
87
|
-
return slots[ctx.column.id]?.({ cell: ctx });
|
|
88
|
-
}
|
|
89
|
-
return renderer.cell({ ctx, options });
|
|
90
|
-
},
|
|
91
|
-
accessorFn: (row, index) => {
|
|
92
|
-
const key = column.accessorKey ? column.accessorKey : column.accessor;
|
|
93
|
-
if (typeof key === "string") {
|
|
94
|
-
return getProperty(row, key);
|
|
95
|
-
} else if (key !== void 0) {
|
|
96
|
-
try {
|
|
97
|
-
return $dsl.evaluate`${key.read}`({
|
|
98
|
-
row,
|
|
99
|
-
index: BigInt(index)
|
|
100
|
-
});
|
|
101
|
-
} catch (e) {
|
|
102
|
-
console.error(e);
|
|
103
|
-
return void 0;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return void 0;
|
|
107
|
-
},
|
|
108
|
-
enableSorting: column.enableSorting ?? false,
|
|
109
|
-
enableMultiSort: column.enableMultiSorting,
|
|
110
|
-
enablePinning: column.enablePinning,
|
|
111
|
-
size: column.size,
|
|
112
|
-
columns: column.columns?.map((column2) => translate(column2)) ?? [],
|
|
113
|
-
meta: {
|
|
114
|
-
tooltip: column.tooltip ? `${genColumnId(column)}-tooltip` : void 0,
|
|
115
|
-
grow: column.grow ?? false
|
|
116
|
-
},
|
|
117
|
-
...renderer.columnDefOverrides
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
const columns = computed(() => {
|
|
121
|
-
return props.columns.map((column) => translate(column));
|
|
122
|
-
});
|
|
123
|
-
const table = useVueTable({
|
|
124
|
-
get columns() {
|
|
125
|
-
return columns.value;
|
|
126
|
-
},
|
|
127
|
-
get data() {
|
|
128
|
-
return props.data;
|
|
16
|
+
const tableRef = ref(null);
|
|
17
|
+
defineExpose(new Proxy({}, {
|
|
18
|
+
get(_target, property) {
|
|
19
|
+
return tableRef.value ? Reflect.get(tableRef.value, property) : void 0;
|
|
129
20
|
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
getPaginationRowModel: getPaginationRowModel(),
|
|
133
|
-
getRowId: props.getRowId ? (originalRow, index, parent) => {
|
|
134
|
-
try {
|
|
135
|
-
const key = $dsl.evaluate`${props.getRowId}`(
|
|
136
|
-
{
|
|
137
|
-
row: originalRow,
|
|
138
|
-
index,
|
|
139
|
-
parent: parent ? {
|
|
140
|
-
id: parent.id,
|
|
141
|
-
index: BigInt(parent.index),
|
|
142
|
-
original: parent.original
|
|
143
|
-
} : null
|
|
144
|
-
}
|
|
145
|
-
);
|
|
146
|
-
if (typeof key === "string") {
|
|
147
|
-
return key;
|
|
148
|
-
}
|
|
149
|
-
} catch (e) {
|
|
150
|
-
console.error(e);
|
|
151
|
-
}
|
|
152
|
-
return parent ? `${parent.index}.${index}` : `${index}`;
|
|
153
|
-
} : void 0,
|
|
154
|
-
getSubRows: (row, index) => {
|
|
155
|
-
if (!props.getSubRows)
|
|
156
|
-
return void 0;
|
|
157
|
-
try {
|
|
158
|
-
const value = $dsl.evaluate`${props.getSubRows}`({
|
|
159
|
-
row,
|
|
160
|
-
index
|
|
161
|
-
});
|
|
162
|
-
return Array.isArray(value) ? value : void 0;
|
|
163
|
-
} catch (e) {
|
|
164
|
-
console.error(e);
|
|
165
|
-
return void 0;
|
|
166
|
-
}
|
|
21
|
+
has(_target, property) {
|
|
22
|
+
return tableRef.value ? Reflect.has(tableRef.value, property) : false;
|
|
167
23
|
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return true;
|
|
171
|
-
try {
|
|
172
|
-
return Boolean($dsl.evaluate`${props.enableRowSelection}`({
|
|
173
|
-
row: row.original,
|
|
174
|
-
index: BigInt(row.index),
|
|
175
|
-
id: row.id
|
|
176
|
-
}));
|
|
177
|
-
} catch (e) {
|
|
178
|
-
console.error(e);
|
|
179
|
-
return true;
|
|
180
|
-
}
|
|
24
|
+
ownKeys() {
|
|
25
|
+
return tableRef.value ? Reflect.ownKeys(tableRef.value) : [];
|
|
181
26
|
},
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return
|
|
185
|
-
row: row.original,
|
|
186
|
-
index: BigInt(row.index),
|
|
187
|
-
id: row.id
|
|
188
|
-
}));
|
|
189
|
-
} catch (e) {
|
|
190
|
-
console.error(e);
|
|
191
|
-
return true;
|
|
27
|
+
getOwnPropertyDescriptor(_target, property) {
|
|
28
|
+
if (!tableRef.value || !Reflect.has(tableRef.value, property)) {
|
|
29
|
+
return void 0;
|
|
192
30
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
overscan: 30
|
|
204
|
-
}))
|
|
205
|
-
);
|
|
206
|
-
const rowTotalSize = computed(() => rowVirtualizer.value.getTotalSize());
|
|
207
|
-
const rowWindow = computed(() => rowVirtualizer.value.getVirtualItems());
|
|
208
|
-
function measureRow(el) {
|
|
209
|
-
if (!el || !(el instanceof Element))
|
|
210
|
-
return;
|
|
211
|
-
rowVirtualizer.value.measureElement(el);
|
|
212
|
-
}
|
|
213
|
-
const rows = computed(() => table.getRowModel().rows);
|
|
214
|
-
function isStyleRecord(x) {
|
|
215
|
-
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
216
|
-
}
|
|
217
|
-
function getCellStyles(ctx) {
|
|
218
|
-
if (!props.cellStyles)
|
|
219
|
-
return {};
|
|
220
|
-
try {
|
|
221
|
-
const result = $dsl.evaluate`${props.cellStyles}`({
|
|
222
|
-
row: ctx.row.original,
|
|
223
|
-
index: BigInt(ctx.row.index),
|
|
224
|
-
id: ctx.column.id,
|
|
225
|
-
selected: ctx.row.getIsSelected(),
|
|
226
|
-
pinned: ctx.column.getIsPinned()
|
|
227
|
-
});
|
|
228
|
-
return isStyleRecord(result) ? result : {};
|
|
229
|
-
} catch (e) {
|
|
230
|
-
console.error(e);
|
|
231
|
-
return {};
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
function shouldHaveRightBorder(column) {
|
|
235
|
-
switch (column.getIsPinned()) {
|
|
236
|
-
case "left":
|
|
237
|
-
return true;
|
|
238
|
-
case "right":
|
|
239
|
-
return !column.getIsLastColumn("right");
|
|
240
|
-
case false:
|
|
241
|
-
return !column.getIsLastColumn("center");
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
function shouldHaveLeftBorder(column) {
|
|
245
|
-
switch (column.getIsPinned()) {
|
|
246
|
-
case "left":
|
|
247
|
-
return false;
|
|
248
|
-
case "right":
|
|
249
|
-
return true;
|
|
250
|
-
case false:
|
|
251
|
-
return false;
|
|
31
|
+
return {
|
|
32
|
+
configurable: true,
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get() {
|
|
35
|
+
if (!tableRef.value) {
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
return Reflect.get(tableRef.value, property);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
252
41
|
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const style = {
|
|
259
|
-
[pinned]: `${column.getStart(pinned)}px`
|
|
260
|
-
};
|
|
261
|
-
if (column.getIsLastColumn("left"))
|
|
262
|
-
style.boxShadow = "5px 5px 5px #00000005";
|
|
263
|
-
if (column.getIsFirstColumn("right"))
|
|
264
|
-
style.boxShadow = "-5px 5px 5px #00000005";
|
|
265
|
-
return style;
|
|
266
|
-
}
|
|
267
|
-
const SORT_ICONS = {
|
|
268
|
-
unsorted: "fluent:arrow-sort-16-regular",
|
|
269
|
-
asc: "fluent:arrow-sort-up-16-regular",
|
|
270
|
-
desc: "fluent:arrow-sort-down-16-regular"
|
|
271
|
-
};
|
|
272
|
-
function getSortIcon(column) {
|
|
273
|
-
const sortDir = column.getIsSorted();
|
|
274
|
-
const iconKey = sortDir === false ? "unsorted" : sortDir;
|
|
275
|
-
return SORT_ICONS[iconKey];
|
|
276
|
-
}
|
|
42
|
+
}));
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<script>
|
|
46
|
+
export { AccessorC, ColumnC, RenderC, TableConfigC } from "./ui/table/schema";
|
|
277
47
|
</script>
|
|
278
48
|
|
|
279
49
|
<template>
|
|
280
|
-
<
|
|
281
|
-
|
|
50
|
+
<UiTable
|
|
51
|
+
ref="tableRef"
|
|
52
|
+
v-bind="$attrs"
|
|
53
|
+
:config="props.config"
|
|
54
|
+
:data="props.data"
|
|
55
|
+
:row-count="props.rowCount"
|
|
56
|
+
@update:config="handleConfigUpdate"
|
|
282
57
|
>
|
|
283
|
-
<
|
|
284
|
-
|
|
285
|
-
|
|
58
|
+
<template
|
|
59
|
+
v-for="(_, slotName) in $slots"
|
|
60
|
+
#[slotName]="slotProps"
|
|
286
61
|
>
|
|
287
|
-
<
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
class="flex w-full border-b border-zinc-200"
|
|
294
|
-
>
|
|
295
|
-
<th
|
|
296
|
-
v-for="header in group.headers"
|
|
297
|
-
:key="header.id"
|
|
298
|
-
:colspan="header.colSpan"
|
|
299
|
-
:class="[
|
|
300
|
-
header.column.columnDef.meta?.grow && 'flex-1',
|
|
301
|
-
'flex items-center gap-2 border-zinc-300 py-2 text-zinc-600',
|
|
302
|
-
'text-xs flex items-center justify-center relative',
|
|
303
|
-
'bg-[color-mix(in_srgb,var(--primary)_10%,white)] group',
|
|
304
|
-
header.column.getIsPinned() && 'sticky z-15',
|
|
305
|
-
shouldHaveRightBorder(header.column) && 'border-r',
|
|
306
|
-
shouldHaveLeftBorder(header.column) && 'border-l'
|
|
307
|
-
]"
|
|
308
|
-
:style="{
|
|
309
|
-
width: `${header.getSize()}px`,
|
|
310
|
-
...pinnedStyle(header.column)
|
|
311
|
-
}"
|
|
312
|
-
>
|
|
313
|
-
<FlexRender
|
|
314
|
-
v-if="!header.isPlaceholder"
|
|
315
|
-
:render="header.column.columnDef.header"
|
|
316
|
-
:props="header.getContext()"
|
|
317
|
-
/>
|
|
318
|
-
|
|
319
|
-
<Tooltip
|
|
320
|
-
v-if="!header.isPlaceholder && header.column.columnDef.meta?.tooltip"
|
|
321
|
-
:delay-duration="180"
|
|
322
|
-
>
|
|
323
|
-
<TooltipTrigger as-child>
|
|
324
|
-
<Icon icon="fluent:info-20-regular" />
|
|
325
|
-
</TooltipTrigger>
|
|
326
|
-
<TooltipContent
|
|
327
|
-
align="center"
|
|
328
|
-
side="top"
|
|
329
|
-
>
|
|
330
|
-
<span v-html="$md.inline`${t(`${header.column.id}-tooltip`)}`()" />
|
|
331
|
-
</TooltipContent>
|
|
332
|
-
</Tooltip>
|
|
333
|
-
|
|
334
|
-
<Tooltip
|
|
335
|
-
v-if="!header.isPlaceholder && header.column.getCanSort()"
|
|
336
|
-
:delay-duration="800"
|
|
337
|
-
>
|
|
338
|
-
<TooltipTrigger as-child>
|
|
339
|
-
<Button
|
|
340
|
-
variant="ghost"
|
|
341
|
-
size="xs"
|
|
342
|
-
:class="[
|
|
343
|
-
'absolute hover:bg-transparent right-1 top-1/2 -translate-y-1/2 transform-3d transition-opacity duration-180',
|
|
344
|
-
!header.column.getIsSorted() ? 'opacity-30 hover:opacity-60' : 'text-(--primary)/80 hover:text-(--primary)'
|
|
345
|
-
]"
|
|
346
|
-
as-child
|
|
347
|
-
>
|
|
348
|
-
<button
|
|
349
|
-
type="button"
|
|
350
|
-
@click="header.column.getToggleSortingHandler()?.($event)"
|
|
351
|
-
>
|
|
352
|
-
<Icon :icon="getSortIcon(header.column)" />
|
|
353
|
-
</button>
|
|
354
|
-
</Button>
|
|
355
|
-
</TooltipTrigger>
|
|
356
|
-
<TooltipContent>
|
|
357
|
-
{{
|
|
358
|
-
header.column.getIsSorted() ? t(`table-sort-${header.column.getIsSorted()}`) : t("table-sort-unsorted")
|
|
359
|
-
}}
|
|
360
|
-
</TooltipContent>
|
|
361
|
-
</Tooltip>
|
|
362
|
-
|
|
363
|
-
<div
|
|
364
|
-
v-if="!header.isPlaceholder && header.column.getCanResize() && (!header.column.getIsLastColumn('right') || !table.getIsSomeColumnsPinned('right') && !header.column.getIsLastColumn('center'))"
|
|
365
|
-
:class="[
|
|
366
|
-
'group',
|
|
367
|
-
'absolute',
|
|
368
|
-
'top-0',
|
|
369
|
-
'bottom-0',
|
|
370
|
-
'right-0',
|
|
371
|
-
'px-2',
|
|
372
|
-
'translate-x-2',
|
|
373
|
-
'z-5',
|
|
374
|
-
'opacity-0',
|
|
375
|
-
'duration-150',
|
|
376
|
-
'transition-opacity',
|
|
377
|
-
'ease-out',
|
|
378
|
-
'hover:opacity-100',
|
|
379
|
-
'cursor-col-resize'
|
|
380
|
-
]"
|
|
381
|
-
@mousedown="header.getResizeHandler()($event)"
|
|
382
|
-
>
|
|
383
|
-
<div :class="['w-2pt', 'h-full', 'translate-x-1pt', 'transform-3d', 'bg-[color-mix(in_srgb,var(--primary)_80%,white)]']" />
|
|
384
|
-
</div>
|
|
385
|
-
</th>
|
|
386
|
-
</tr>
|
|
387
|
-
</thead>
|
|
388
|
-
|
|
389
|
-
<tbody
|
|
390
|
-
class="grid relative"
|
|
391
|
-
:style="{ height: `${rowTotalSize}px` }"
|
|
392
|
-
>
|
|
393
|
-
<tr
|
|
394
|
-
v-for="r in rowWindow"
|
|
395
|
-
:key="rows[r.index]?.id ?? r.index"
|
|
396
|
-
:ref="measureRow"
|
|
397
|
-
class="flex absolute w-full not-last:border-b border-zinc-300"
|
|
398
|
-
:data-index="rows[r.index]?.index"
|
|
399
|
-
:style="{ transform: `translate3d(0, ${r.start}px, 0)` }"
|
|
400
|
-
>
|
|
401
|
-
<td
|
|
402
|
-
v-for="cell in rows[r.index]?.getVisibleCells() ?? []"
|
|
403
|
-
:key="cell.id"
|
|
404
|
-
:class="[
|
|
405
|
-
'border-zinc-300',
|
|
406
|
-
cell.column.columnDef.meta?.grow && 'flex-1',
|
|
407
|
-
cell.column.getIsPinned() && 'sticky z-15',
|
|
408
|
-
shouldHaveRightBorder(cell.column) && 'border-r',
|
|
409
|
-
shouldHaveLeftBorder(cell.column) && 'border-l'
|
|
410
|
-
]"
|
|
411
|
-
:style="{
|
|
412
|
-
width: `${cell.column.getSize()}px`,
|
|
413
|
-
...pinnedStyle(cell.column),
|
|
414
|
-
...getCellStyles(cell.getContext())
|
|
415
|
-
}"
|
|
416
|
-
>
|
|
417
|
-
<FlexRender
|
|
418
|
-
:render="cell.column.columnDef.cell"
|
|
419
|
-
:props="cell.getContext()"
|
|
420
|
-
/>
|
|
421
|
-
</td>
|
|
422
|
-
</tr>
|
|
423
|
-
</tbody>
|
|
424
|
-
|
|
425
|
-
<tfoot class="hidden has-data-footer:grid sticky bottom-0 z-10 select-none border-t border-zinc-200">
|
|
426
|
-
<tr
|
|
427
|
-
v-for="group in table.getFooterGroups()"
|
|
428
|
-
:key="group.id"
|
|
429
|
-
class="flex w-full border-zinc-200"
|
|
430
|
-
>
|
|
431
|
-
<th
|
|
432
|
-
v-for="header in group.headers"
|
|
433
|
-
:key="header.id"
|
|
434
|
-
:colSpan="header.colSpan"
|
|
435
|
-
:class="[
|
|
436
|
-
header.column.columnDef.meta?.grow && 'flex-1',
|
|
437
|
-
'flex items-center gap-2 border-zinc-300 text-zinc-600 p-0',
|
|
438
|
-
'text-xs flex items-center justify-center relative',
|
|
439
|
-
'bg-[color-mix(in_srgb,var(--primary)_10%,white)] group',
|
|
440
|
-
header.column.getIsPinned() && 'sticky z-15',
|
|
441
|
-
shouldHaveRightBorder(header.column) && 'border-r',
|
|
442
|
-
shouldHaveLeftBorder(header.column) && 'border-l'
|
|
443
|
-
]"
|
|
444
|
-
:style="{
|
|
445
|
-
width: `${header.getSize()}px`,
|
|
446
|
-
...pinnedStyle(header.column)
|
|
447
|
-
}"
|
|
448
|
-
>
|
|
449
|
-
<FlexRender
|
|
450
|
-
v-if="!header.isPlaceholder"
|
|
451
|
-
:render="header.column.columnDef.footer"
|
|
452
|
-
:props="header.getContext()"
|
|
453
|
-
/>
|
|
454
|
-
</th>
|
|
455
|
-
</tr>
|
|
456
|
-
</tfoot>
|
|
457
|
-
</table>
|
|
458
|
-
</div>
|
|
459
|
-
</div>
|
|
460
|
-
|
|
461
|
-
<div class="flex items-center justify-between w-full py-2 gap-2 text-sm text-zinc-600">
|
|
462
|
-
<div
|
|
463
|
-
:class="[
|
|
464
|
-
'relative p-1 flex-1 prose prose-zinc text-xs border border-dashed',
|
|
465
|
-
isCheating ? 'border-(--primary)/20 rounded hover:border-(--primary)/40 transition-colors duration-150 group cursor-pointer' : 'border-transparent'
|
|
466
|
-
]"
|
|
467
|
-
>
|
|
468
|
-
<span
|
|
469
|
-
v-html="$md.inline`${props.paginationLeft}`({
|
|
470
|
-
selected: table.getSelectedRowModel().rows.map((row) => row.original)
|
|
471
|
-
})"
|
|
472
|
-
/>
|
|
473
|
-
<Icon
|
|
474
|
-
v-if="isCheating"
|
|
475
|
-
icon="fluent:edit-20-regular"
|
|
476
|
-
class="w-4 h-4 text-(--primary) absolute right-1 top-1/2 -translate-y-1/2 transform-3d group-hover:opacity-100 opacity-50 transition-opacity duration-150"
|
|
477
|
-
/>
|
|
478
|
-
|
|
479
|
-
</div>
|
|
480
|
-
<div class="flex items-center gap-4">
|
|
481
|
-
<i18n-t
|
|
482
|
-
keypath="total"
|
|
483
|
-
tag="span"
|
|
484
|
-
class="text-xs"
|
|
485
|
-
>
|
|
486
|
-
<template #count>
|
|
487
|
-
<strong>{{ props.data.length }}</strong>
|
|
488
|
-
</template>
|
|
489
|
-
</i18n-t>
|
|
490
|
-
<Pagination.Root
|
|
491
|
-
show-edges
|
|
492
|
-
:total="props.data.length"
|
|
493
|
-
:items-per-page="table.getState().pagination.pageSize"
|
|
494
|
-
:page="table.getState().pagination.pageIndex + 1"
|
|
495
|
-
@update:page="(page2) => table.setPageIndex(page2 - 1)"
|
|
496
|
-
>
|
|
497
|
-
<Pagination.List
|
|
498
|
-
v-slot="{ items }"
|
|
499
|
-
class="flex items-center gap-1"
|
|
500
|
-
>
|
|
501
|
-
<Pagination.First
|
|
502
|
-
:class="[
|
|
503
|
-
'w-7 h-7 flex items-center justify-center bg-transparent hover:bg-zinc-100 transition disabled:opacity-50 rounded text-zinc-600',
|
|
504
|
-
'data-disabled:opacity-50 data-disabled:cursor-not-allowed cursor-pointer'
|
|
505
|
-
]"
|
|
506
|
-
>
|
|
507
|
-
<Icon
|
|
508
|
-
icon="radix-icons:double-arrow-left"
|
|
509
|
-
class="w-4 h-4"
|
|
510
|
-
/>
|
|
511
|
-
</Pagination.First>
|
|
512
|
-
<Pagination.Prev
|
|
513
|
-
:class="[
|
|
514
|
-
'w-7 h-7 flex items-center justify-center bg-transparent hover:bg-zinc-100 transition disabled:opacity-50 rounded text-zinc-600',
|
|
515
|
-
'data-disabled:opacity-50 data-disabled:cursor-not-allowed cursor-pointer'
|
|
516
|
-
]"
|
|
517
|
-
>
|
|
518
|
-
<Icon
|
|
519
|
-
icon="radix-icons:chevron-left"
|
|
520
|
-
class="w-4 h-4"
|
|
521
|
-
/>
|
|
522
|
-
</Pagination.Prev>
|
|
523
|
-
|
|
524
|
-
<template
|
|
525
|
-
v-for="(page, index) in items"
|
|
526
|
-
:key="page.type === 'page' ? `${page.type}-${page.value}` : `${page.type}-${index}`"
|
|
527
|
-
>
|
|
528
|
-
<Pagination.ListItem
|
|
529
|
-
v-if="page.type === 'page'"
|
|
530
|
-
:class="[
|
|
531
|
-
'w-7 h-7 flex items-center justify-center rounded text-xs bg-transparent',
|
|
532
|
-
'data-selected:text-(--primary) hover:bg-zinc-100 transition cursor-pointer'
|
|
533
|
-
]"
|
|
534
|
-
:value="page.value"
|
|
535
|
-
>
|
|
536
|
-
{{ page.value }}
|
|
537
|
-
</Pagination.ListItem>
|
|
538
|
-
<Pagination.Ellipsis
|
|
539
|
-
v-else
|
|
540
|
-
class="w-7 h-7 flex items-center justify-center text-zinc-400"
|
|
541
|
-
>
|
|
542
|
-
…
|
|
543
|
-
</Pagination.Ellipsis>
|
|
544
|
-
</template>
|
|
545
|
-
|
|
546
|
-
<Pagination.Next
|
|
547
|
-
:class="[
|
|
548
|
-
'w-7 h-7 flex items-center justify-center bg-transparent hover:bg-zinc-100 transition disabled:opacity-50 rounded text-zinc-600',
|
|
549
|
-
'data-disabled:opacity-50 data-disabled:cursor-not-allowed cursor-pointer'
|
|
550
|
-
]"
|
|
551
|
-
>
|
|
552
|
-
<Icon
|
|
553
|
-
icon="radix-icons:chevron-right"
|
|
554
|
-
class="w-4 h-4"
|
|
555
|
-
/>
|
|
556
|
-
</Pagination.Next>
|
|
557
|
-
<Pagination.Last
|
|
558
|
-
:class="[
|
|
559
|
-
'w-7 h-7 flex items-center justify-center bg-transparent hover:bg-zinc-100 transition disabled:opacity-50 rounded text-zinc-600',
|
|
560
|
-
'data-disabled:opacity-50 data-disabled:cursor-not-allowed cursor-pointer'
|
|
561
|
-
]"
|
|
562
|
-
>
|
|
563
|
-
<Icon
|
|
564
|
-
icon="radix-icons:double-arrow-right"
|
|
565
|
-
class="w-4 h-4"
|
|
566
|
-
/>
|
|
567
|
-
</Pagination.Last>
|
|
568
|
-
</Pagination.List>
|
|
569
|
-
</Pagination.Root>
|
|
570
|
-
<i18n-t
|
|
571
|
-
keypath="goto"
|
|
572
|
-
tag="div"
|
|
573
|
-
class="text-xs flex items-center gap-2"
|
|
574
|
-
>
|
|
575
|
-
<template #page>
|
|
576
|
-
<NumberField
|
|
577
|
-
:model-value="table.getState().pagination.pageIndex + 1"
|
|
578
|
-
:min="1"
|
|
579
|
-
:max="Math.ceil(props.data.length / table.getState().pagination.pageSize)"
|
|
580
|
-
@update:model-value="(value) => table.setPageIndex(value - 1)"
|
|
581
|
-
>
|
|
582
|
-
<NumberFieldInput class="h-6 w-16 text-xs" />
|
|
583
|
-
</NumberField>
|
|
584
|
-
</template>
|
|
585
|
-
</i18n-t>
|
|
586
|
-
</div>
|
|
587
|
-
<div
|
|
588
|
-
:class="[
|
|
589
|
-
'relative p-1 flex-1 prose prose-zinc text-xs border border-dashed',
|
|
590
|
-
isCheating ? 'border-(--primary)/20 rounded hover:border-(--primary)/40 transition-colors duration-150 group cursor-pointer' : 'border-transparent'
|
|
591
|
-
]"
|
|
592
|
-
>
|
|
593
|
-
<span
|
|
594
|
-
v-html="$md.inline`${props.paginationRight}`({
|
|
595
|
-
selected: table.getSelectedRowModel().rows.map((row) => row.original)
|
|
596
|
-
})"
|
|
597
|
-
/>
|
|
598
|
-
<Icon
|
|
599
|
-
v-if="isCheating"
|
|
600
|
-
icon="fluent:edit-20-regular"
|
|
601
|
-
class="w-4 h-4 text-(--primary) absolute right-1 top-1/2 -translate-y-1/2 transform-3d group-hover:opacity-100 opacity-50 transition-opacity duration-150"
|
|
602
|
-
/>
|
|
603
|
-
|
|
604
|
-
</div>
|
|
605
|
-
</div>
|
|
606
|
-
</div>
|
|
62
|
+
<slot
|
|
63
|
+
:name="slotName"
|
|
64
|
+
v-bind="slotProps ?? {}"
|
|
65
|
+
/>
|
|
66
|
+
</template>
|
|
67
|
+
</UiTable>
|
|
607
68
|
</template>
|
|
608
|
-
|
|
609
|
-
<i18n lang="json">
|
|
610
|
-
{
|
|
611
|
-
"zh": {
|
|
612
|
-
"total": "共 {count} 条",
|
|
613
|
-
"goto": "前往 {page} 页",
|
|
614
|
-
"table-sort-asc": "升序",
|
|
615
|
-
"table-sort-desc": "降序",
|
|
616
|
-
"table-sort-unsorted": "未排序"
|
|
617
|
-
},
|
|
618
|
-
"ja": {
|
|
619
|
-
"total": "合計 {count} 件",
|
|
620
|
-
"goto": "ページ {page} に移動",
|
|
621
|
-
"table-sort-asc": "昇順",
|
|
622
|
-
"table-sort-desc": "降順",
|
|
623
|
-
"table-sort-unsorted": "未排序"
|
|
624
|
-
},
|
|
625
|
-
"en": {
|
|
626
|
-
"total": "Total {count} items",
|
|
627
|
-
"goto": "Go to page {page}",
|
|
628
|
-
"table-sort-asc": "Ascending",
|
|
629
|
-
"table-sort-desc": "Descending",
|
|
630
|
-
"table-sort-unsorted": "Unsorted"
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
</i18n>
|