@shwfed/nuxt 0.1.12 → 0.1.14
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 +2 -2
- package/dist/module.mjs +7 -1
- package/dist/runtime/components/app.d.vue.ts +13 -0
- package/dist/runtime/components/app.vue +9 -0
- package/dist/runtime/components/app.vue.d.ts +13 -0
- package/dist/runtime/components/table.d.vue.ts +59 -0
- package/dist/runtime/components/table.vue +456 -0
- package/dist/runtime/components/table.vue.d.ts +59 -0
- package/dist/runtime/components/tooltip.d.vue.ts +21 -0
- package/dist/runtime/components/tooltip.vue +48 -0
- package/dist/runtime/components/tooltip.vue.d.ts +21 -0
- package/dist/runtime/composables/useTableRenderers.d.ts +8 -0
- package/dist/runtime/composables/useTableRenderers.js +9 -0
- package/dist/runtime/plugins/cel/index.d.ts +15 -6
- package/dist/runtime/plugins/cel/index.js +11 -23
- package/dist/runtime/plugins/markdown/index.d.ts +8 -0
- package/dist/runtime/plugins/markdown/index.js +10 -2
- package/dist/runtime/table-renderers/builtins.d.ts +1 -0
- package/dist/runtime/table-renderers/builtins.js +404 -0
- package/dist/runtime/table-renderers/registry.d.ts +40 -0
- package/dist/runtime/table-renderers/registry.js +25 -0
- package/package.json +10 -5
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addPlugin, addImportsDir } from '@nuxt/kit';
|
|
1
|
+
import { defineNuxtModule, createResolver, addPlugin, addImportsDir, addComponentsDir } from '@nuxt/kit';
|
|
2
2
|
|
|
3
3
|
const module$1 = defineNuxtModule({
|
|
4
4
|
meta: {
|
|
@@ -12,6 +12,12 @@ const module$1 = defineNuxtModule({
|
|
|
12
12
|
addPlugin(resolver.resolve("runtime/plugins/cel/index"));
|
|
13
13
|
addPlugin(resolver.resolve("runtime/plugins/markdown/index"));
|
|
14
14
|
addImportsDir(resolver.resolve("runtime/composables"));
|
|
15
|
+
addComponentsDir({
|
|
16
|
+
path: resolver.resolve("runtime/components"),
|
|
17
|
+
ignore: ["ui/**/*.{vue,ts}"],
|
|
18
|
+
prefix: "shwfed",
|
|
19
|
+
extensions: ["vue"]
|
|
20
|
+
});
|
|
15
21
|
nuxt.options.typescript.tsConfig.include?.push(resolver.resolve("runtime/types/directive.d.ts"));
|
|
16
22
|
}
|
|
17
23
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare var __VLS_8: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_8) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
10
|
+
new (): {
|
|
11
|
+
$slots: S;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare var __VLS_8: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_8) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
10
|
+
new (): {
|
|
11
|
+
$slots: S;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { RowData, TableOptions } from '@tanstack/vue-table';
|
|
2
|
+
declare module '@tanstack/vue-table' {
|
|
3
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
4
|
+
tooltip?: string;
|
|
5
|
+
grow?: boolean;
|
|
6
|
+
__types?: [TData, TValue];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
type Expression = string;
|
|
10
|
+
type Accessor = string | Readonly<{
|
|
11
|
+
read: Expression;
|
|
12
|
+
write: Expression;
|
|
13
|
+
}>;
|
|
14
|
+
type Column = Readonly<{
|
|
15
|
+
id?: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
accessor?: Accessor;
|
|
18
|
+
accessorKey?: string;
|
|
19
|
+
renderer?: string | Readonly<{
|
|
20
|
+
id: string;
|
|
21
|
+
props: unknown;
|
|
22
|
+
}>;
|
|
23
|
+
tooltip?: string;
|
|
24
|
+
size?: number;
|
|
25
|
+
enableSorting?: boolean;
|
|
26
|
+
enableMultiSorting?: boolean;
|
|
27
|
+
enablePinning?: boolean;
|
|
28
|
+
grow?: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
31
|
+
id: string;
|
|
32
|
+
getRowId?: Expression;
|
|
33
|
+
getSubRows?: Expression;
|
|
34
|
+
enableRowSelection?: Expression;
|
|
35
|
+
enableMultiRowSelection?: Expression;
|
|
36
|
+
columns: ReadonlyArray<Column>;
|
|
37
|
+
data: Array<unknown>;
|
|
38
|
+
cellStyles?: Expression;
|
|
39
|
+
props?: Omit<TableOptions<unknown>, "columns" | "data" | "getRowId" | "getCoreRowModel">;
|
|
40
|
+
}>, import("@tanstack/vue-table").Table<unknown>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Readonly<{
|
|
41
|
+
id: string;
|
|
42
|
+
getRowId?: Expression;
|
|
43
|
+
getSubRows?: Expression;
|
|
44
|
+
enableRowSelection?: Expression;
|
|
45
|
+
enableMultiRowSelection?: Expression;
|
|
46
|
+
columns: ReadonlyArray<Column>;
|
|
47
|
+
data: Array<unknown>;
|
|
48
|
+
cellStyles?: Expression;
|
|
49
|
+
props?: Omit<TableOptions<unknown>, "columns" | "data" | "getRowId" | "getCoreRowModel">;
|
|
50
|
+
}>> & Readonly<{}>, {
|
|
51
|
+
readonly props: Omit<TableOptions<unknown>, "columns" | "data" | "getRowId" | "getCoreRowModel">;
|
|
52
|
+
readonly getRowId: Expression;
|
|
53
|
+
readonly getSubRows: Expression;
|
|
54
|
+
readonly enableMultiRowSelection: Expression;
|
|
55
|
+
readonly enableRowSelection: Expression;
|
|
56
|
+
readonly cellStyles: Expression;
|
|
57
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
58
|
+
declare const _default: typeof __VLS_export;
|
|
59
|
+
export default _default;
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
<script setup>
|
|
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 { computed, ref } from "vue";
|
|
8
|
+
import { useNuxtApp } from "#app";
|
|
9
|
+
import { useCheating } from "../composables/useCheating";
|
|
10
|
+
import { useTableRenderers } from "../composables/useTableRenderers";
|
|
11
|
+
import Tooltip from "./tooltip.vue";
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
id: { type: String, required: true },
|
|
14
|
+
getRowId: { type: String, required: false, default: void 0 },
|
|
15
|
+
getSubRows: { type: String, required: false, default: void 0 },
|
|
16
|
+
enableRowSelection: { type: String, required: false, default: void 0 },
|
|
17
|
+
enableMultiRowSelection: { type: String, required: false, default: void 0 },
|
|
18
|
+
columns: { type: Array, required: true },
|
|
19
|
+
data: { type: Array, required: true },
|
|
20
|
+
cellStyles: { type: String, required: false, default: void 0 },
|
|
21
|
+
props: { type: Object, required: false, default: void 0 }
|
|
22
|
+
});
|
|
23
|
+
const isCheating = useCheating();
|
|
24
|
+
const { $dsl, $markdown } = useNuxtApp();
|
|
25
|
+
const { resolveTableRenderer } = useTableRenderers();
|
|
26
|
+
const containerRef = ref(null);
|
|
27
|
+
function renderInline(source) {
|
|
28
|
+
return $markdown.renderInline(source);
|
|
29
|
+
}
|
|
30
|
+
function genColumnId(column) {
|
|
31
|
+
if (typeof column.accessor === "string") {
|
|
32
|
+
return column.accessor;
|
|
33
|
+
} else if (column.accessor) {
|
|
34
|
+
return column.accessor.read;
|
|
35
|
+
}
|
|
36
|
+
return crypto.randomUUID();
|
|
37
|
+
}
|
|
38
|
+
const columns = computed(() => {
|
|
39
|
+
return props.columns.map((column) => {
|
|
40
|
+
const rendererId = typeof column.renderer === "string" ? column.renderer : column.renderer?.id ? column.renderer.id : "table.renderer.text";
|
|
41
|
+
const rendererProps = column.renderer && typeof column.renderer === "object" && "props" in column.renderer ? column.renderer.props : null;
|
|
42
|
+
const renderer = resolveTableRenderer(rendererId);
|
|
43
|
+
const options = renderer.parseOptions(rendererProps);
|
|
44
|
+
const helpers = {
|
|
45
|
+
renderInline,
|
|
46
|
+
evaluate: $dsl.evaluate
|
|
47
|
+
};
|
|
48
|
+
const cell = (ctx) => {
|
|
49
|
+
return renderer.cell({ ctx, options, helpers });
|
|
50
|
+
};
|
|
51
|
+
const header = (ctx) => {
|
|
52
|
+
if (renderer.header) {
|
|
53
|
+
return renderer.header({
|
|
54
|
+
ctx,
|
|
55
|
+
title: typeof column.title === "string" ? column.title : void 0,
|
|
56
|
+
options,
|
|
57
|
+
helpers
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return typeof column.title === "string" ? column.title : void 0;
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
id: column.id ?? genColumnId(column),
|
|
64
|
+
header,
|
|
65
|
+
cell,
|
|
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
|
+
},
|
|
83
|
+
enableSorting: column.enableSorting ?? false,
|
|
84
|
+
enableMultiSort: column.enableMultiSorting,
|
|
85
|
+
enablePinning: column.enablePinning,
|
|
86
|
+
size: column.size,
|
|
87
|
+
meta: {
|
|
88
|
+
tooltip: column.tooltip,
|
|
89
|
+
grow: column.grow ?? false
|
|
90
|
+
},
|
|
91
|
+
...renderer.columnDefOverrides
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
const table = useVueTable({
|
|
96
|
+
get columns() {
|
|
97
|
+
return columns.value;
|
|
98
|
+
},
|
|
99
|
+
get data() {
|
|
100
|
+
return props.data;
|
|
101
|
+
},
|
|
102
|
+
getCoreRowModel: getCoreRowModel(),
|
|
103
|
+
getExpandedRowModel: getExpandedRowModel(),
|
|
104
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
105
|
+
getRowId: props.getRowId ? (originalRow, index, parent) => {
|
|
106
|
+
try {
|
|
107
|
+
const key = $dsl.evaluate(
|
|
108
|
+
props.getRowId,
|
|
109
|
+
{
|
|
110
|
+
row: originalRow,
|
|
111
|
+
index,
|
|
112
|
+
parent: parent ? {
|
|
113
|
+
id: parent.id,
|
|
114
|
+
index: BigInt(parent.index),
|
|
115
|
+
original: parent.original
|
|
116
|
+
} : null
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
if (typeof key === "string") {
|
|
120
|
+
return key;
|
|
121
|
+
}
|
|
122
|
+
} catch (e) {
|
|
123
|
+
console.error(e);
|
|
124
|
+
}
|
|
125
|
+
return parent ? `${parent.index}.${index}` : `${index}`;
|
|
126
|
+
} : void 0,
|
|
127
|
+
getSubRows: (row, index) => {
|
|
128
|
+
if (!props.getSubRows)
|
|
129
|
+
return void 0;
|
|
130
|
+
try {
|
|
131
|
+
const value = $dsl.evaluate(props.getSubRows, {
|
|
132
|
+
row,
|
|
133
|
+
index
|
|
134
|
+
});
|
|
135
|
+
return Array.isArray(value) ? value : void 0;
|
|
136
|
+
} catch (e) {
|
|
137
|
+
console.error(e);
|
|
138
|
+
return void 0;
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
enableRowSelection: (row) => {
|
|
142
|
+
if (!props.enableRowSelection)
|
|
143
|
+
return true;
|
|
144
|
+
try {
|
|
145
|
+
return Boolean($dsl.evaluate(props.enableRowSelection, {
|
|
146
|
+
row: row.original,
|
|
147
|
+
index: BigInt(row.index),
|
|
148
|
+
id: row.id
|
|
149
|
+
}));
|
|
150
|
+
} catch (e) {
|
|
151
|
+
console.error(e);
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
enableMultiRowSelection: props.enableMultiRowSelection ? (row) => {
|
|
156
|
+
try {
|
|
157
|
+
return Boolean($dsl.evaluate(props.enableMultiRowSelection, {
|
|
158
|
+
row: row.original,
|
|
159
|
+
index: BigInt(row.index),
|
|
160
|
+
id: row.id
|
|
161
|
+
}));
|
|
162
|
+
} catch (e) {
|
|
163
|
+
console.error(e);
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
} : void 0,
|
|
167
|
+
columnResizeMode: "onChange",
|
|
168
|
+
...props.props
|
|
169
|
+
});
|
|
170
|
+
defineExpose(table);
|
|
171
|
+
const rowVirtualizer = useVirtualizer(
|
|
172
|
+
computed(() => ({
|
|
173
|
+
count: table.getRowModel().rows.length,
|
|
174
|
+
estimateSize: () => 35,
|
|
175
|
+
getScrollElement: () => containerRef.value,
|
|
176
|
+
overscan: 30
|
|
177
|
+
}))
|
|
178
|
+
);
|
|
179
|
+
const rowTotalSize = computed(() => rowVirtualizer.value.getTotalSize());
|
|
180
|
+
const rowWindow = computed(() => rowVirtualizer.value.getVirtualItems());
|
|
181
|
+
function measureRow(el) {
|
|
182
|
+
if (!el || !(el instanceof Element))
|
|
183
|
+
return;
|
|
184
|
+
rowVirtualizer.value.measureElement(el);
|
|
185
|
+
}
|
|
186
|
+
const rows = computed(() => table.getRowModel().rows);
|
|
187
|
+
function isStyleRecord(x) {
|
|
188
|
+
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
189
|
+
}
|
|
190
|
+
function getCellStyles(ctx) {
|
|
191
|
+
if (!props.cellStyles)
|
|
192
|
+
return {};
|
|
193
|
+
try {
|
|
194
|
+
const result = $dsl.evaluate(props.cellStyles, {
|
|
195
|
+
row: ctx.row.original,
|
|
196
|
+
index: BigInt(ctx.row.index),
|
|
197
|
+
id: ctx.column.id,
|
|
198
|
+
selected: ctx.row.getIsSelected(),
|
|
199
|
+
pinned: ctx.column.getIsPinned()
|
|
200
|
+
});
|
|
201
|
+
return isStyleRecord(result) ? result : {};
|
|
202
|
+
} catch (e) {
|
|
203
|
+
console.error(e);
|
|
204
|
+
return {};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function hasAdjacentColumns(column) {
|
|
208
|
+
switch (column.getIsPinned()) {
|
|
209
|
+
case "left":
|
|
210
|
+
return !column.getIsLastColumn("left");
|
|
211
|
+
// why would anyone pin all columns to the left?
|
|
212
|
+
case "right":
|
|
213
|
+
return !column.getIsLastColumn("right");
|
|
214
|
+
case false:
|
|
215
|
+
return !column.getIsLastColumn("center") || table.getIsSomeColumnsPinned("right");
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function pinnedStyle(column) {
|
|
219
|
+
const pinned = column.getIsPinned();
|
|
220
|
+
if (!pinned)
|
|
221
|
+
return {};
|
|
222
|
+
const style = {
|
|
223
|
+
[pinned]: `${column.getStart(pinned)}px`
|
|
224
|
+
};
|
|
225
|
+
if (column.getIsLastColumn("left"))
|
|
226
|
+
style.boxShadow = "5px 5px 5px #00000005";
|
|
227
|
+
if (column.getIsFirstColumn("right"))
|
|
228
|
+
style.boxShadow = "-5px 5px 5px #00000005";
|
|
229
|
+
return style;
|
|
230
|
+
}
|
|
231
|
+
const SORT_ICONS = {
|
|
232
|
+
unsorted: "fluent:arrow-sort-16-regular",
|
|
233
|
+
asc: "fluent:arrow-sort-up-16-regular",
|
|
234
|
+
desc: "fluent:arrow-sort-down-16-regular"
|
|
235
|
+
};
|
|
236
|
+
function getSortIcon(column) {
|
|
237
|
+
const sortDir = column.getIsSorted();
|
|
238
|
+
const iconKey = sortDir === false ? "unsorted" : sortDir;
|
|
239
|
+
return SORT_ICONS[iconKey];
|
|
240
|
+
}
|
|
241
|
+
</script>
|
|
242
|
+
|
|
243
|
+
<template>
|
|
244
|
+
<div
|
|
245
|
+
class="flex flex-col h-full"
|
|
246
|
+
:style="isCheating ? { '--primary': '#BC1111' } : { '--primary': '#2DA8BC' }"
|
|
247
|
+
>
|
|
248
|
+
<div
|
|
249
|
+
ref="containerRef"
|
|
250
|
+
class="overflow-scroll flex-1 border border-zinc-200 rounded relative"
|
|
251
|
+
>
|
|
252
|
+
<div :style="{ height: `${rowTotalSize}px` }">
|
|
253
|
+
<table class="grid">
|
|
254
|
+
<thead class="grid sticky top-0 z-10 select-none">
|
|
255
|
+
<tr
|
|
256
|
+
v-for="group in table.getHeaderGroups()"
|
|
257
|
+
:key="group.id"
|
|
258
|
+
class="flex w-full border-b border-zinc-200"
|
|
259
|
+
>
|
|
260
|
+
<th
|
|
261
|
+
v-for="header in group.headers"
|
|
262
|
+
:key="header.id"
|
|
263
|
+
:colspan="header.colSpan"
|
|
264
|
+
:class="[
|
|
265
|
+
header.column.columnDef.meta?.grow && 'flex-1',
|
|
266
|
+
'flex items-center gap-2 border-zinc-300 py-2 text-zinc-600',
|
|
267
|
+
'text-xs flex items-center justify-center relative',
|
|
268
|
+
'bg-[color-mix(in_srgb,var(--primary)_10%,white)] group',
|
|
269
|
+
header.column.getIsPinned() && 'sticky z-15',
|
|
270
|
+
(header.column.getIsPinned() === 'left' || hasAdjacentColumns(header.column)) && 'border-r'
|
|
271
|
+
]"
|
|
272
|
+
:style="{
|
|
273
|
+
width: `${header.column.getSize()}px`,
|
|
274
|
+
...pinnedStyle(header.column)
|
|
275
|
+
}"
|
|
276
|
+
>
|
|
277
|
+
<FlexRender
|
|
278
|
+
v-if="!header.isPlaceholder"
|
|
279
|
+
:render="header.column.columnDef.header"
|
|
280
|
+
:props="header.getContext()"
|
|
281
|
+
/>
|
|
282
|
+
|
|
283
|
+
<Tooltip
|
|
284
|
+
v-if="header.column.columnDef.meta?.tooltip"
|
|
285
|
+
:delay-duration="180"
|
|
286
|
+
:content="renderInline(header.column.columnDef.meta.tooltip)"
|
|
287
|
+
>
|
|
288
|
+
<Icon icon="fluent:info-20-regular" />
|
|
289
|
+
</Tooltip>
|
|
290
|
+
|
|
291
|
+
<button
|
|
292
|
+
v-if="header.column.getCanSort()"
|
|
293
|
+
type="button"
|
|
294
|
+
:class="[
|
|
295
|
+
'p-1 cursor-pointer outline-none absolute right-1 top-1/2 -translate-y-1/2 transform-3d',
|
|
296
|
+
'group-hover:opacity-100 opacity-60 transition-opacity duration-180 bg-transparent'
|
|
297
|
+
]"
|
|
298
|
+
@click="header.column.getToggleSortingHandler()?.($event)"
|
|
299
|
+
>
|
|
300
|
+
<Icon :icon="getSortIcon(header.column)" />
|
|
301
|
+
</button>
|
|
302
|
+
|
|
303
|
+
<div
|
|
304
|
+
v-if="header.column.getCanResize() && (!header.column.getIsLastColumn('right') || !table.getIsSomeColumnsPinned('right') && !header.column.getIsLastColumn('center'))"
|
|
305
|
+
:class="[
|
|
306
|
+
'group',
|
|
307
|
+
'absolute',
|
|
308
|
+
'top-0',
|
|
309
|
+
'bottom-0',
|
|
310
|
+
'right-0',
|
|
311
|
+
'px-2',
|
|
312
|
+
'translate-x-2',
|
|
313
|
+
'z-5',
|
|
314
|
+
'opacity-0',
|
|
315
|
+
'duration-150',
|
|
316
|
+
'transition-opacity',
|
|
317
|
+
'ease-out',
|
|
318
|
+
'hover:opacity-100',
|
|
319
|
+
'cursor-col-resize'
|
|
320
|
+
]"
|
|
321
|
+
@mousedown="header.getResizeHandler()($event)"
|
|
322
|
+
>
|
|
323
|
+
<div :class="['w-2pt', 'translate-x-1pt', 'h-full', 'bg-blue-400']" />
|
|
324
|
+
</div>
|
|
325
|
+
</th>
|
|
326
|
+
</tr>
|
|
327
|
+
</thead>
|
|
328
|
+
|
|
329
|
+
<tbody
|
|
330
|
+
class="grid relative"
|
|
331
|
+
:style="{ height: `${rowTotalSize}px` }"
|
|
332
|
+
>
|
|
333
|
+
<tr
|
|
334
|
+
v-for="r in rowWindow"
|
|
335
|
+
:key="rows[r.index]?.id ?? r.index"
|
|
336
|
+
:ref="measureRow"
|
|
337
|
+
class="flex absolute w-full"
|
|
338
|
+
:data-index="rows[r.index]?.index"
|
|
339
|
+
:style="{ transform: `translate3d(0, ${r.start}px, 0)` }"
|
|
340
|
+
>
|
|
341
|
+
<td
|
|
342
|
+
v-for="cell in rows[r.index]?.getVisibleCells() ?? []"
|
|
343
|
+
:key="cell.id"
|
|
344
|
+
:class="[
|
|
345
|
+
'border-b border-zinc-300',
|
|
346
|
+
cell.column.columnDef.meta?.grow && 'flex-1',
|
|
347
|
+
cell.column.getIsPinned() && 'sticky z-15',
|
|
348
|
+
(cell.column.getIsPinned() === 'left' || hasAdjacentColumns(cell.column)) && 'border-r'
|
|
349
|
+
]"
|
|
350
|
+
:style="{
|
|
351
|
+
width: `${cell.column.getSize()}px`,
|
|
352
|
+
...pinnedStyle(cell.column),
|
|
353
|
+
...getCellStyles(cell.getContext())
|
|
354
|
+
}"
|
|
355
|
+
>
|
|
356
|
+
<FlexRender
|
|
357
|
+
:render="cell.column.columnDef.cell"
|
|
358
|
+
:props="cell.getContext()"
|
|
359
|
+
/>
|
|
360
|
+
</td>
|
|
361
|
+
</tr>
|
|
362
|
+
</tbody>
|
|
363
|
+
</table>
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
|
|
367
|
+
<div class="flex items-center justify-between w-full p-4 text-sm text-zinc-600">
|
|
368
|
+
<div />
|
|
369
|
+
<div class="flex items-center gap-4">
|
|
370
|
+
<span class="text-xs">{{ `\u5171 ${props.data.length} \u6761` }}</span>
|
|
371
|
+
<Pagination.Root
|
|
372
|
+
show-edges
|
|
373
|
+
:total="props.data.length"
|
|
374
|
+
:items-per-page="table.getState().pagination.pageSize"
|
|
375
|
+
:page="table.getState().pagination.pageIndex + 1"
|
|
376
|
+
@update:page="(page2) => table.setPageIndex(page2 - 1)"
|
|
377
|
+
>
|
|
378
|
+
<Pagination.List
|
|
379
|
+
v-slot="{ items }"
|
|
380
|
+
class="flex items-center gap-1"
|
|
381
|
+
>
|
|
382
|
+
<Pagination.First
|
|
383
|
+
:class="[
|
|
384
|
+
'w-7 h-7 flex items-center justify-center bg-transparent hover:bg-zinc-100 transition disabled:opacity-50 rounded text-zinc-600',
|
|
385
|
+
'data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed cursor-pointer'
|
|
386
|
+
]"
|
|
387
|
+
>
|
|
388
|
+
<Icon
|
|
389
|
+
icon="radix-icons:double-arrow-left"
|
|
390
|
+
class="w-4 h-4"
|
|
391
|
+
/>
|
|
392
|
+
</Pagination.First>
|
|
393
|
+
<Pagination.Prev
|
|
394
|
+
:class="[
|
|
395
|
+
'w-7 h-7 flex items-center justify-center bg-transparent hover:bg-zinc-100 transition disabled:opacity-50 rounded text-zinc-600',
|
|
396
|
+
'data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed cursor-pointer'
|
|
397
|
+
]"
|
|
398
|
+
>
|
|
399
|
+
<Icon
|
|
400
|
+
icon="radix-icons:chevron-left"
|
|
401
|
+
class="w-4 h-4"
|
|
402
|
+
/>
|
|
403
|
+
</Pagination.Prev>
|
|
404
|
+
|
|
405
|
+
<template
|
|
406
|
+
v-for="(page, index) in items"
|
|
407
|
+
:key="page.type === 'page' ? `${page.type}-${page.value}` : `${page.type}-${index}`"
|
|
408
|
+
>
|
|
409
|
+
<Pagination.ListItem
|
|
410
|
+
v-if="page.type === 'page'"
|
|
411
|
+
:class="[
|
|
412
|
+
'w-7 h-7 flex items-center justify-center border border-zinc-200 rounded text-xs',
|
|
413
|
+
'data-[selected]:text-[var(--primary)] data-[selected]:border-[var(--primary)] hover:bg-zinc-100 transition cursor-pointer'
|
|
414
|
+
]"
|
|
415
|
+
:value="page.value"
|
|
416
|
+
>
|
|
417
|
+
{{ page.value }}
|
|
418
|
+
</Pagination.ListItem>
|
|
419
|
+
<Pagination.Ellipsis
|
|
420
|
+
v-else
|
|
421
|
+
class="w-7 h-7 flex items-center justify-center text-zinc-400"
|
|
422
|
+
>
|
|
423
|
+
…
|
|
424
|
+
</Pagination.Ellipsis>
|
|
425
|
+
</template>
|
|
426
|
+
|
|
427
|
+
<Pagination.Next
|
|
428
|
+
:class="[
|
|
429
|
+
'w-7 h-7 flex items-center justify-center bg-transparent hover:bg-zinc-100 transition disabled:opacity-50 rounded text-zinc-600',
|
|
430
|
+
'data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed cursor-pointer'
|
|
431
|
+
]"
|
|
432
|
+
>
|
|
433
|
+
<Icon
|
|
434
|
+
icon="radix-icons:chevron-right"
|
|
435
|
+
class="w-4 h-4"
|
|
436
|
+
/>
|
|
437
|
+
</Pagination.Next>
|
|
438
|
+
<Pagination.Last
|
|
439
|
+
:class="[
|
|
440
|
+
'w-7 h-7 flex items-center justify-center bg-transparent hover:bg-zinc-100 transition disabled:opacity-50 rounded text-zinc-600',
|
|
441
|
+
'data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed cursor-pointer'
|
|
442
|
+
]"
|
|
443
|
+
>
|
|
444
|
+
<Icon
|
|
445
|
+
icon="radix-icons:double-arrow-right"
|
|
446
|
+
class="w-4 h-4"
|
|
447
|
+
/>
|
|
448
|
+
</Pagination.Last>
|
|
449
|
+
</Pagination.List>
|
|
450
|
+
</Pagination.Root>
|
|
451
|
+
<span class="text-xs">前往</span>
|
|
452
|
+
</div>
|
|
453
|
+
<div />
|
|
454
|
+
</div>
|
|
455
|
+
</div>
|
|
456
|
+
</template>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { RowData, TableOptions } from '@tanstack/vue-table';
|
|
2
|
+
declare module '@tanstack/vue-table' {
|
|
3
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
4
|
+
tooltip?: string;
|
|
5
|
+
grow?: boolean;
|
|
6
|
+
__types?: [TData, TValue];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
type Expression = string;
|
|
10
|
+
type Accessor = string | Readonly<{
|
|
11
|
+
read: Expression;
|
|
12
|
+
write: Expression;
|
|
13
|
+
}>;
|
|
14
|
+
type Column = Readonly<{
|
|
15
|
+
id?: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
accessor?: Accessor;
|
|
18
|
+
accessorKey?: string;
|
|
19
|
+
renderer?: string | Readonly<{
|
|
20
|
+
id: string;
|
|
21
|
+
props: unknown;
|
|
22
|
+
}>;
|
|
23
|
+
tooltip?: string;
|
|
24
|
+
size?: number;
|
|
25
|
+
enableSorting?: boolean;
|
|
26
|
+
enableMultiSorting?: boolean;
|
|
27
|
+
enablePinning?: boolean;
|
|
28
|
+
grow?: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
31
|
+
id: string;
|
|
32
|
+
getRowId?: Expression;
|
|
33
|
+
getSubRows?: Expression;
|
|
34
|
+
enableRowSelection?: Expression;
|
|
35
|
+
enableMultiRowSelection?: Expression;
|
|
36
|
+
columns: ReadonlyArray<Column>;
|
|
37
|
+
data: Array<unknown>;
|
|
38
|
+
cellStyles?: Expression;
|
|
39
|
+
props?: Omit<TableOptions<unknown>, "columns" | "data" | "getRowId" | "getCoreRowModel">;
|
|
40
|
+
}>, import("@tanstack/vue-table").Table<unknown>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Readonly<{
|
|
41
|
+
id: string;
|
|
42
|
+
getRowId?: Expression;
|
|
43
|
+
getSubRows?: Expression;
|
|
44
|
+
enableRowSelection?: Expression;
|
|
45
|
+
enableMultiRowSelection?: Expression;
|
|
46
|
+
columns: ReadonlyArray<Column>;
|
|
47
|
+
data: Array<unknown>;
|
|
48
|
+
cellStyles?: Expression;
|
|
49
|
+
props?: Omit<TableOptions<unknown>, "columns" | "data" | "getRowId" | "getCoreRowModel">;
|
|
50
|
+
}>> & Readonly<{}>, {
|
|
51
|
+
readonly props: Omit<TableOptions<unknown>, "columns" | "data" | "getRowId" | "getCoreRowModel">;
|
|
52
|
+
readonly getRowId: Expression;
|
|
53
|
+
readonly getSubRows: Expression;
|
|
54
|
+
readonly enableMultiRowSelection: Expression;
|
|
55
|
+
readonly enableRowSelection: Expression;
|
|
56
|
+
readonly cellStyles: Expression;
|
|
57
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
58
|
+
declare const _default: typeof __VLS_export;
|
|
59
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type TooltipRootProps } from 'reka-ui';
|
|
2
|
+
type __VLS_Props = TooltipRootProps & {
|
|
3
|
+
content?: string;
|
|
4
|
+
};
|
|
5
|
+
declare var __VLS_14: {};
|
|
6
|
+
type __VLS_Slots = {} & {
|
|
7
|
+
default?: (props: typeof __VLS_14) => any;
|
|
8
|
+
};
|
|
9
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
|
+
"update:open": (value: boolean) => any;
|
|
11
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
12
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
13
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
17
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
18
|
+
new (): {
|
|
19
|
+
$slots: S;
|
|
20
|
+
};
|
|
21
|
+
};
|