@shwfed/nuxt 0.1.14 → 0.1.16
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
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import type { RowData, TableOptions } from '@tanstack/vue-table';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
tooltip?: string;
|
|
5
|
-
grow?: boolean;
|
|
6
|
-
__types?: [TData, TValue];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
type Expression = string;
|
|
10
|
-
type Accessor = string | Readonly<{
|
|
2
|
+
export type Expression = string;
|
|
3
|
+
export type Accessor = string | Readonly<{
|
|
11
4
|
read: Expression;
|
|
12
5
|
write: Expression;
|
|
13
6
|
}>;
|
|
14
|
-
type Column = Readonly<{
|
|
7
|
+
export type Column = Readonly<{
|
|
15
8
|
id?: string;
|
|
16
9
|
title?: string;
|
|
17
10
|
accessor?: Accessor;
|
|
@@ -25,8 +18,18 @@ type Column = Readonly<{
|
|
|
25
18
|
enableSorting?: boolean;
|
|
26
19
|
enableMultiSorting?: boolean;
|
|
27
20
|
enablePinning?: boolean;
|
|
21
|
+
columns?: ReadonlyArray<Column>;
|
|
28
22
|
grow?: boolean;
|
|
29
23
|
}>;
|
|
24
|
+
declare module '@tanstack/vue-table' {
|
|
25
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
26
|
+
tooltip?: string;
|
|
27
|
+
grow?: boolean;
|
|
28
|
+
__types?: [TData, TValue];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
declare const _default: typeof __VLS_export;
|
|
32
|
+
export default _default;
|
|
30
33
|
declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
31
34
|
id: string;
|
|
32
35
|
getRowId?: Expression;
|
|
@@ -55,5 +58,3 @@ declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
|
55
58
|
readonly enableRowSelection: Expression;
|
|
56
59
|
readonly cellStyles: Expression;
|
|
57
60
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
58
|
-
declare const _default: typeof __VLS_export;
|
|
59
|
-
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script>
|
|
2
2
|
import { FlexRender, getCoreRowModel, getExpandedRowModel, getPaginationRowModel, useVueTable } from "@tanstack/vue-table";
|
|
3
3
|
import { useVirtualizer } from "@tanstack/vue-virtual";
|
|
4
4
|
import { Icon } from "@iconify/vue";
|
|
@@ -9,6 +9,9 @@ import { useNuxtApp } from "#app";
|
|
|
9
9
|
import { useCheating } from "../composables/useCheating";
|
|
10
10
|
import { useTableRenderers } from "../composables/useTableRenderers";
|
|
11
11
|
import Tooltip from "./tooltip.vue";
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script setup>
|
|
12
15
|
const props = defineProps({
|
|
13
16
|
id: { type: String, required: true },
|
|
14
17
|
getRowId: { type: String, required: false, default: void 0 },
|
|
@@ -35,51 +38,31 @@ function genColumnId(column) {
|
|
|
35
38
|
}
|
|
36
39
|
return crypto.randomUUID();
|
|
37
40
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return renderer.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
return typeof column.title === "string" ? column.title : void 0;
|
|
61
|
-
};
|
|
41
|
+
function translate(column) {
|
|
42
|
+
const rendererId = typeof column.renderer === "string" ? column.renderer : column.renderer?.id ? column.renderer.id : "table.renderer.text";
|
|
43
|
+
const rendererProps = column.renderer && typeof column.renderer === "object" && "props" in column.renderer ? column.renderer.props : null;
|
|
44
|
+
const renderer = resolveTableRenderer(rendererId);
|
|
45
|
+
const options = renderer.parseOptions(rendererProps);
|
|
46
|
+
const helpers = {
|
|
47
|
+
renderInline,
|
|
48
|
+
evaluate: $dsl.evaluate
|
|
49
|
+
};
|
|
50
|
+
const header = (ctx) => {
|
|
51
|
+
if (renderer.header) {
|
|
52
|
+
return renderer.header({
|
|
53
|
+
ctx,
|
|
54
|
+
title: typeof column.title === "string" ? column.title : void 0,
|
|
55
|
+
options,
|
|
56
|
+
helpers
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return typeof column.title === "string" ? column.title : void 0;
|
|
60
|
+
};
|
|
61
|
+
if (Array.isArray(column.columns) && column.columns.length > 0) {
|
|
62
62
|
return {
|
|
63
63
|
id: column.id ?? genColumnId(column),
|
|
64
64
|
header,
|
|
65
|
-
|
|
66
|
-
accessorFn: (row, index) => {
|
|
67
|
-
const key = column.accessorKey ? column.accessorKey : column.accessor;
|
|
68
|
-
if (typeof key === "string") {
|
|
69
|
-
return getProperty(row, key);
|
|
70
|
-
} else if (key !== void 0) {
|
|
71
|
-
try {
|
|
72
|
-
return $dsl.evaluate(key.read, {
|
|
73
|
-
row,
|
|
74
|
-
index: BigInt(index)
|
|
75
|
-
});
|
|
76
|
-
} catch (e) {
|
|
77
|
-
console.error(e);
|
|
78
|
-
return void 0;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return void 0;
|
|
82
|
-
},
|
|
65
|
+
columns: column.columns?.map((column2) => translate(column2)) ?? [],
|
|
83
66
|
enableSorting: column.enableSorting ?? false,
|
|
84
67
|
enableMultiSort: column.enableMultiSorting,
|
|
85
68
|
enablePinning: column.enablePinning,
|
|
@@ -87,10 +70,47 @@ const columns = computed(() => {
|
|
|
87
70
|
meta: {
|
|
88
71
|
tooltip: column.tooltip,
|
|
89
72
|
grow: column.grow ?? false
|
|
90
|
-
}
|
|
91
|
-
...renderer.columnDefOverrides
|
|
73
|
+
}
|
|
92
74
|
};
|
|
93
|
-
}
|
|
75
|
+
}
|
|
76
|
+
const cell = (ctx) => {
|
|
77
|
+
return renderer.cell({ ctx, options, helpers });
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
id: column.id ?? genColumnId(column),
|
|
81
|
+
header,
|
|
82
|
+
cell,
|
|
83
|
+
accessorFn: (row, index) => {
|
|
84
|
+
const key = column.accessorKey ? column.accessorKey : column.accessor;
|
|
85
|
+
if (typeof key === "string") {
|
|
86
|
+
return getProperty(row, key);
|
|
87
|
+
} else if (key !== void 0) {
|
|
88
|
+
try {
|
|
89
|
+
return $dsl.evaluate(key.read, {
|
|
90
|
+
row,
|
|
91
|
+
index: BigInt(index)
|
|
92
|
+
});
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.error(e);
|
|
95
|
+
return void 0;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return void 0;
|
|
99
|
+
},
|
|
100
|
+
enableSorting: column.enableSorting ?? false,
|
|
101
|
+
enableMultiSort: column.enableMultiSorting,
|
|
102
|
+
enablePinning: column.enablePinning,
|
|
103
|
+
size: column.size,
|
|
104
|
+
columns: column.columns?.map((column2) => translate(column2)) ?? [],
|
|
105
|
+
meta: {
|
|
106
|
+
tooltip: column.tooltip,
|
|
107
|
+
grow: column.grow ?? false
|
|
108
|
+
},
|
|
109
|
+
...renderer.columnDefOverrides
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const columns = computed(() => {
|
|
113
|
+
return props.columns.map((column) => translate(column));
|
|
94
114
|
});
|
|
95
115
|
const table = useVueTable({
|
|
96
116
|
get columns() {
|
|
@@ -270,7 +290,7 @@ function getSortIcon(column) {
|
|
|
270
290
|
(header.column.getIsPinned() === 'left' || hasAdjacentColumns(header.column)) && 'border-r'
|
|
271
291
|
]"
|
|
272
292
|
:style="{
|
|
273
|
-
width: `${header.
|
|
293
|
+
width: `${header.getSize()}px`,
|
|
274
294
|
...pinnedStyle(header.column)
|
|
275
295
|
}"
|
|
276
296
|
>
|
|
@@ -281,7 +301,7 @@ function getSortIcon(column) {
|
|
|
281
301
|
/>
|
|
282
302
|
|
|
283
303
|
<Tooltip
|
|
284
|
-
v-if="header.column.columnDef.meta?.tooltip"
|
|
304
|
+
v-if="!header.isPlaceholder && header.column.columnDef.meta?.tooltip"
|
|
285
305
|
:delay-duration="180"
|
|
286
306
|
:content="renderInline(header.column.columnDef.meta.tooltip)"
|
|
287
307
|
>
|
|
@@ -289,7 +309,7 @@ function getSortIcon(column) {
|
|
|
289
309
|
</Tooltip>
|
|
290
310
|
|
|
291
311
|
<button
|
|
292
|
-
v-if="header.column.getCanSort()"
|
|
312
|
+
v-if="!header.isPlaceholder && header.column.getCanSort()"
|
|
293
313
|
type="button"
|
|
294
314
|
:class="[
|
|
295
315
|
'p-1 cursor-pointer outline-none absolute right-1 top-1/2 -translate-y-1/2 transform-3d',
|
|
@@ -301,7 +321,7 @@ function getSortIcon(column) {
|
|
|
301
321
|
</button>
|
|
302
322
|
|
|
303
323
|
<div
|
|
304
|
-
v-if="header.column.getCanResize() && (!header.column.getIsLastColumn('right') || !table.getIsSomeColumnsPinned('right') && !header.column.getIsLastColumn('center'))"
|
|
324
|
+
v-if="!header.isPlaceholder && header.column.getCanResize() && (!header.column.getIsLastColumn('right') || !table.getIsSomeColumnsPinned('right') && !header.column.getIsLastColumn('center'))"
|
|
305
325
|
:class="[
|
|
306
326
|
'group',
|
|
307
327
|
'absolute',
|
|
@@ -409,7 +429,7 @@ function getSortIcon(column) {
|
|
|
409
429
|
<Pagination.ListItem
|
|
410
430
|
v-if="page.type === 'page'"
|
|
411
431
|
:class="[
|
|
412
|
-
'w-7 h-7 flex items-center justify-center border border-zinc-200 rounded text-xs',
|
|
432
|
+
'w-7 h-7 flex items-center justify-center border border-zinc-200 rounded text-xs bg-transparent',
|
|
413
433
|
'data-[selected]:text-[var(--primary)] data-[selected]:border-[var(--primary)] hover:bg-zinc-100 transition cursor-pointer'
|
|
414
434
|
]"
|
|
415
435
|
:value="page.value"
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import type { RowData, TableOptions } from '@tanstack/vue-table';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
tooltip?: string;
|
|
5
|
-
grow?: boolean;
|
|
6
|
-
__types?: [TData, TValue];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
type Expression = string;
|
|
10
|
-
type Accessor = string | Readonly<{
|
|
2
|
+
export type Expression = string;
|
|
3
|
+
export type Accessor = string | Readonly<{
|
|
11
4
|
read: Expression;
|
|
12
5
|
write: Expression;
|
|
13
6
|
}>;
|
|
14
|
-
type Column = Readonly<{
|
|
7
|
+
export type Column = Readonly<{
|
|
15
8
|
id?: string;
|
|
16
9
|
title?: string;
|
|
17
10
|
accessor?: Accessor;
|
|
@@ -25,8 +18,18 @@ type Column = Readonly<{
|
|
|
25
18
|
enableSorting?: boolean;
|
|
26
19
|
enableMultiSorting?: boolean;
|
|
27
20
|
enablePinning?: boolean;
|
|
21
|
+
columns?: ReadonlyArray<Column>;
|
|
28
22
|
grow?: boolean;
|
|
29
23
|
}>;
|
|
24
|
+
declare module '@tanstack/vue-table' {
|
|
25
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
26
|
+
tooltip?: string;
|
|
27
|
+
grow?: boolean;
|
|
28
|
+
__types?: [TData, TValue];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
declare const _default: typeof __VLS_export;
|
|
32
|
+
export default _default;
|
|
30
33
|
declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
31
34
|
id: string;
|
|
32
35
|
getRowId?: Expression;
|
|
@@ -55,5 +58,3 @@ declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
|
55
58
|
readonly enableRowSelection: Expression;
|
|
56
59
|
readonly cellStyles: Expression;
|
|
57
60
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
58
|
-
declare const _default: typeof __VLS_export;
|
|
59
|
-
export default _default;
|
|
@@ -223,7 +223,7 @@ defineTableRenderer(
|
|
|
223
223
|
"cursor-pointer absolute right-1 top-1/2 -translate-y-1/2 bg-white border",
|
|
224
224
|
"w-6 h-6 flex items-center justify-center group-hover:opacity-100 opacity-0",
|
|
225
225
|
"transition-all duration-180 rounded border-zinc-200 text-zinc-500",
|
|
226
|
-
"hover:border-[var(--primary)]
|
|
226
|
+
"hover:border-[color-mix(in_srgb,var(--primary)_50%,white)] hover:text-[color-mix(in_srgb,var(--primary)_80%,#00000033)] hover:bg-[color-mix(in_srgb,var(--primary)_10%,white)]"
|
|
227
227
|
],
|
|
228
228
|
onClick: onCopy,
|
|
229
229
|
children: /* @__PURE__ */ jsx(Icon, { icon: "fluent:copy-20-regular" })
|