@shwfed/nuxt 0.1.15 → 0.1.17
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.vue +8 -0
- package/dist/runtime/components/table.d.vue.ts +18 -16
- package/dist/runtime/components/table.vue +106 -63
- package/dist/runtime/components/table.vue.d.ts +18 -16
- package/dist/runtime/composables/useTableRenderers.d.ts +1 -1
- package/dist/runtime/table-renderers/builtins.js +14 -8
- package/dist/runtime/table-renderers/registry.d.ts +6 -9
- package/dist/runtime/table-renderers/registry.js +2 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
import type { RowData, TableOptions } from '@tanstack/vue-table';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
type Expression = string;
|
|
10
|
-
type Accessor = string | Readonly<{
|
|
2
|
+
export type Expression = string;
|
|
3
|
+
export type Render = string | Readonly<{
|
|
4
|
+
id: string;
|
|
5
|
+
props: unknown;
|
|
6
|
+
}>;
|
|
7
|
+
export type Accessor = string | Readonly<{
|
|
11
8
|
read: Expression;
|
|
12
9
|
write: Expression;
|
|
13
10
|
}>;
|
|
14
|
-
type Column = Readonly<{
|
|
11
|
+
export type Column = Readonly<{
|
|
15
12
|
id?: string;
|
|
16
13
|
title?: string;
|
|
17
14
|
accessor?: Accessor;
|
|
18
15
|
accessorKey?: string;
|
|
19
|
-
renderer?:
|
|
20
|
-
id: string;
|
|
21
|
-
props: unknown;
|
|
22
|
-
}>;
|
|
16
|
+
renderer?: Render;
|
|
23
17
|
tooltip?: string;
|
|
24
18
|
size?: number;
|
|
25
19
|
enableSorting?: boolean;
|
|
26
20
|
enableMultiSorting?: boolean;
|
|
27
21
|
enablePinning?: boolean;
|
|
22
|
+
columns?: ReadonlyArray<Column>;
|
|
28
23
|
grow?: boolean;
|
|
29
24
|
}>;
|
|
25
|
+
declare module '@tanstack/vue-table' {
|
|
26
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
27
|
+
tooltip?: string;
|
|
28
|
+
grow?: boolean;
|
|
29
|
+
__types?: [TData, TValue];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
declare const _default: typeof __VLS_export;
|
|
33
|
+
export default _default;
|
|
30
34
|
declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
31
35
|
id: string;
|
|
32
36
|
getRowId?: Expression;
|
|
@@ -55,5 +59,3 @@ declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
|
55
59
|
readonly enableRowSelection: Expression;
|
|
56
60
|
readonly cellStyles: Expression;
|
|
57
61
|
}, {}, {}, {}, 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";
|
|
@@ -6,9 +6,11 @@ import { getProperty } from "dot-prop";
|
|
|
6
6
|
import { Pagination } from "reka-ui/namespaced";
|
|
7
7
|
import { computed, ref } from "vue";
|
|
8
8
|
import { useNuxtApp } from "#app";
|
|
9
|
-
import { useCheating } from "../composables/useCheating";
|
|
10
9
|
import { useTableRenderers } from "../composables/useTableRenderers";
|
|
11
10
|
import Tooltip from "./tooltip.vue";
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script setup>
|
|
12
14
|
const props = defineProps({
|
|
13
15
|
id: { type: String, required: true },
|
|
14
16
|
getRowId: { type: String, required: false, default: void 0 },
|
|
@@ -20,7 +22,6 @@ const props = defineProps({
|
|
|
20
22
|
cellStyles: { type: String, required: false, default: void 0 },
|
|
21
23
|
props: { type: Object, required: false, default: void 0 }
|
|
22
24
|
});
|
|
23
|
-
const isCheating = useCheating();
|
|
24
25
|
const { $dsl, $markdown } = useNuxtApp();
|
|
25
26
|
const { resolveTableRenderer } = useTableRenderers();
|
|
26
27
|
const containerRef = ref(null);
|
|
@@ -35,51 +36,12 @@ function genColumnId(column) {
|
|
|
35
36
|
}
|
|
36
37
|
return crypto.randomUUID();
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
};
|
|
39
|
+
function translate(column) {
|
|
40
|
+
if (Array.isArray(column.columns) && column.columns.length > 0) {
|
|
62
41
|
return {
|
|
63
42
|
id: column.id ?? genColumnId(column),
|
|
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
|
-
},
|
|
43
|
+
header: column.title,
|
|
44
|
+
columns: column.columns?.map((column2) => translate(column2)) ?? [],
|
|
83
45
|
enableSorting: column.enableSorting ?? false,
|
|
84
46
|
enableMultiSort: column.enableMultiSorting,
|
|
85
47
|
enablePinning: column.enablePinning,
|
|
@@ -87,10 +49,48 @@ const columns = computed(() => {
|
|
|
87
49
|
meta: {
|
|
88
50
|
tooltip: column.tooltip,
|
|
89
51
|
grow: column.grow ?? false
|
|
90
|
-
}
|
|
91
|
-
...renderer.columnDefOverrides
|
|
52
|
+
}
|
|
92
53
|
};
|
|
93
|
-
}
|
|
54
|
+
}
|
|
55
|
+
const renderer = resolveTableRenderer(typeof column.renderer === "string" ? column.renderer : column.renderer?.id ? column.renderer.id : "table.renderer.text");
|
|
56
|
+
const options = renderer.parseOptions(column.renderer && typeof column.renderer === "object" && "props" in column.renderer ? column.renderer.props : null);
|
|
57
|
+
return {
|
|
58
|
+
id: column.id ?? genColumnId(column),
|
|
59
|
+
header: (ctx) => renderer.header?.({ ctx, options }) ?? column.title,
|
|
60
|
+
cell: (ctx) => {
|
|
61
|
+
return renderer.cell({ ctx, options });
|
|
62
|
+
},
|
|
63
|
+
accessorFn: (row, index) => {
|
|
64
|
+
const key = column.accessorKey ? column.accessorKey : column.accessor;
|
|
65
|
+
if (typeof key === "string") {
|
|
66
|
+
return getProperty(row, key);
|
|
67
|
+
} else if (key !== void 0) {
|
|
68
|
+
try {
|
|
69
|
+
return $dsl.evaluate(key.read, {
|
|
70
|
+
row,
|
|
71
|
+
index: BigInt(index)
|
|
72
|
+
});
|
|
73
|
+
} catch (e) {
|
|
74
|
+
console.error(e);
|
|
75
|
+
return void 0;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return void 0;
|
|
79
|
+
},
|
|
80
|
+
enableSorting: column.enableSorting ?? false,
|
|
81
|
+
enableMultiSort: column.enableMultiSorting,
|
|
82
|
+
enablePinning: column.enablePinning,
|
|
83
|
+
size: column.size,
|
|
84
|
+
columns: column.columns?.map((column2) => translate(column2)) ?? [],
|
|
85
|
+
meta: {
|
|
86
|
+
tooltip: column.tooltip,
|
|
87
|
+
grow: column.grow ?? false
|
|
88
|
+
},
|
|
89
|
+
...renderer.columnDefOverrides
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const columns = computed(() => {
|
|
93
|
+
return props.columns.map((column) => translate(column));
|
|
94
94
|
});
|
|
95
95
|
const table = useVueTable({
|
|
96
96
|
get columns() {
|
|
@@ -204,15 +204,24 @@ function getCellStyles(ctx) {
|
|
|
204
204
|
return {};
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function shouldHaveRightBorder(column) {
|
|
208
208
|
switch (column.getIsPinned()) {
|
|
209
209
|
case "left":
|
|
210
|
-
return
|
|
211
|
-
// why would anyone pin all columns to the left?
|
|
210
|
+
return true;
|
|
212
211
|
case "right":
|
|
213
212
|
return !column.getIsLastColumn("right");
|
|
214
213
|
case false:
|
|
215
|
-
return !column.getIsLastColumn("center")
|
|
214
|
+
return !column.getIsLastColumn("center");
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function shouldHaveLeftBorder(column) {
|
|
218
|
+
switch (column.getIsPinned()) {
|
|
219
|
+
case "left":
|
|
220
|
+
return false;
|
|
221
|
+
case "right":
|
|
222
|
+
return true;
|
|
223
|
+
case false:
|
|
224
|
+
return false;
|
|
216
225
|
}
|
|
217
226
|
}
|
|
218
227
|
function pinnedStyle(column) {
|
|
@@ -243,11 +252,10 @@ function getSortIcon(column) {
|
|
|
243
252
|
<template>
|
|
244
253
|
<div
|
|
245
254
|
class="flex flex-col h-full"
|
|
246
|
-
:style="isCheating ? { '--primary': '#BC1111' } : { '--primary': '#2DA8BC' }"
|
|
247
255
|
>
|
|
248
256
|
<div
|
|
249
257
|
ref="containerRef"
|
|
250
|
-
class="overflow-scroll flex-1 border border-zinc-200 rounded relative"
|
|
258
|
+
class="overflow-scroll overscroll-none flex-1 border border-zinc-200 rounded relative"
|
|
251
259
|
>
|
|
252
260
|
<div :style="{ height: `${rowTotalSize}px` }">
|
|
253
261
|
<table class="grid">
|
|
@@ -267,10 +275,11 @@ function getSortIcon(column) {
|
|
|
267
275
|
'text-xs flex items-center justify-center relative',
|
|
268
276
|
'bg-[color-mix(in_srgb,var(--primary)_10%,white)] group',
|
|
269
277
|
header.column.getIsPinned() && 'sticky z-15',
|
|
270
|
-
(header.column
|
|
278
|
+
shouldHaveRightBorder(header.column) && 'border-r',
|
|
279
|
+
shouldHaveLeftBorder(header.column) && 'border-l'
|
|
271
280
|
]"
|
|
272
281
|
:style="{
|
|
273
|
-
width: `${header.
|
|
282
|
+
width: `${header.getSize()}px`,
|
|
274
283
|
...pinnedStyle(header.column)
|
|
275
284
|
}"
|
|
276
285
|
>
|
|
@@ -281,7 +290,7 @@ function getSortIcon(column) {
|
|
|
281
290
|
/>
|
|
282
291
|
|
|
283
292
|
<Tooltip
|
|
284
|
-
v-if="header.column.columnDef.meta?.tooltip"
|
|
293
|
+
v-if="!header.isPlaceholder && header.column.columnDef.meta?.tooltip"
|
|
285
294
|
:delay-duration="180"
|
|
286
295
|
:content="renderInline(header.column.columnDef.meta.tooltip)"
|
|
287
296
|
>
|
|
@@ -289,7 +298,7 @@ function getSortIcon(column) {
|
|
|
289
298
|
</Tooltip>
|
|
290
299
|
|
|
291
300
|
<button
|
|
292
|
-
v-if="header.column.getCanSort()"
|
|
301
|
+
v-if="!header.isPlaceholder && header.column.getCanSort()"
|
|
293
302
|
type="button"
|
|
294
303
|
:class="[
|
|
295
304
|
'p-1 cursor-pointer outline-none absolute right-1 top-1/2 -translate-y-1/2 transform-3d',
|
|
@@ -301,7 +310,7 @@ function getSortIcon(column) {
|
|
|
301
310
|
</button>
|
|
302
311
|
|
|
303
312
|
<div
|
|
304
|
-
v-if="header.column.getCanResize() && (!header.column.getIsLastColumn('right') || !table.getIsSomeColumnsPinned('right') && !header.column.getIsLastColumn('center'))"
|
|
313
|
+
v-if="!header.isPlaceholder && header.column.getCanResize() && (!header.column.getIsLastColumn('right') || !table.getIsSomeColumnsPinned('right') && !header.column.getIsLastColumn('center'))"
|
|
305
314
|
:class="[
|
|
306
315
|
'group',
|
|
307
316
|
'absolute',
|
|
@@ -334,7 +343,7 @@ function getSortIcon(column) {
|
|
|
334
343
|
v-for="r in rowWindow"
|
|
335
344
|
:key="rows[r.index]?.id ?? r.index"
|
|
336
345
|
:ref="measureRow"
|
|
337
|
-
class="flex absolute w-full"
|
|
346
|
+
class="flex absolute w-full not-last:border-b border-zinc-300"
|
|
338
347
|
:data-index="rows[r.index]?.index"
|
|
339
348
|
:style="{ transform: `translate3d(0, ${r.start}px, 0)` }"
|
|
340
349
|
>
|
|
@@ -342,10 +351,11 @@ function getSortIcon(column) {
|
|
|
342
351
|
v-for="cell in rows[r.index]?.getVisibleCells() ?? []"
|
|
343
352
|
:key="cell.id"
|
|
344
353
|
:class="[
|
|
345
|
-
'border-
|
|
354
|
+
'border-zinc-300',
|
|
346
355
|
cell.column.columnDef.meta?.grow && 'flex-1',
|
|
347
356
|
cell.column.getIsPinned() && 'sticky z-15',
|
|
348
|
-
(cell.column
|
|
357
|
+
shouldHaveRightBorder(cell.column) && 'border-r',
|
|
358
|
+
shouldHaveLeftBorder(cell.column) && 'border-l'
|
|
349
359
|
]"
|
|
350
360
|
:style="{
|
|
351
361
|
width: `${cell.column.getSize()}px`,
|
|
@@ -360,6 +370,39 @@ function getSortIcon(column) {
|
|
|
360
370
|
</td>
|
|
361
371
|
</tr>
|
|
362
372
|
</tbody>
|
|
373
|
+
|
|
374
|
+
<tfoot class="hidden has-[[data-footer]]:grid sticky bottom-0 z-10 select-none border-t border-zinc-200">
|
|
375
|
+
<tr
|
|
376
|
+
v-for="group in table.getFooterGroups()"
|
|
377
|
+
:key="group.id"
|
|
378
|
+
class="flex w-full border-zinc-200"
|
|
379
|
+
>
|
|
380
|
+
<th
|
|
381
|
+
v-for="header in group.headers"
|
|
382
|
+
:key="header.id"
|
|
383
|
+
:colSpan="header.colSpan"
|
|
384
|
+
:class="[
|
|
385
|
+
header.column.columnDef.meta?.grow && 'flex-1',
|
|
386
|
+
'flex items-center gap-2 border-zinc-300 text-zinc-600 p-0',
|
|
387
|
+
'text-xs flex items-center justify-center relative',
|
|
388
|
+
'bg-[color-mix(in_srgb,var(--primary)_10%,white)] group',
|
|
389
|
+
header.column.getIsPinned() && 'sticky z-15',
|
|
390
|
+
shouldHaveRightBorder(header.column) && 'border-r',
|
|
391
|
+
shouldHaveLeftBorder(header.column) && 'border-l'
|
|
392
|
+
]"
|
|
393
|
+
:style="{
|
|
394
|
+
width: `${header.getSize()}px`,
|
|
395
|
+
...pinnedStyle(header.column)
|
|
396
|
+
}"
|
|
397
|
+
>
|
|
398
|
+
<FlexRender
|
|
399
|
+
v-if="!header.isPlaceholder"
|
|
400
|
+
:render="header.column.columnDef.footer"
|
|
401
|
+
:props="header.getContext()"
|
|
402
|
+
/>
|
|
403
|
+
</th>
|
|
404
|
+
</tr>
|
|
405
|
+
</tfoot>
|
|
363
406
|
</table>
|
|
364
407
|
</div>
|
|
365
408
|
</div>
|
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
import type { RowData, TableOptions } from '@tanstack/vue-table';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
type Expression = string;
|
|
10
|
-
type Accessor = string | Readonly<{
|
|
2
|
+
export type Expression = string;
|
|
3
|
+
export type Render = string | Readonly<{
|
|
4
|
+
id: string;
|
|
5
|
+
props: unknown;
|
|
6
|
+
}>;
|
|
7
|
+
export type Accessor = string | Readonly<{
|
|
11
8
|
read: Expression;
|
|
12
9
|
write: Expression;
|
|
13
10
|
}>;
|
|
14
|
-
type Column = Readonly<{
|
|
11
|
+
export type Column = Readonly<{
|
|
15
12
|
id?: string;
|
|
16
13
|
title?: string;
|
|
17
14
|
accessor?: Accessor;
|
|
18
15
|
accessorKey?: string;
|
|
19
|
-
renderer?:
|
|
20
|
-
id: string;
|
|
21
|
-
props: unknown;
|
|
22
|
-
}>;
|
|
16
|
+
renderer?: Render;
|
|
23
17
|
tooltip?: string;
|
|
24
18
|
size?: number;
|
|
25
19
|
enableSorting?: boolean;
|
|
26
20
|
enableMultiSorting?: boolean;
|
|
27
21
|
enablePinning?: boolean;
|
|
22
|
+
columns?: ReadonlyArray<Column>;
|
|
28
23
|
grow?: boolean;
|
|
29
24
|
}>;
|
|
25
|
+
declare module '@tanstack/vue-table' {
|
|
26
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
27
|
+
tooltip?: string;
|
|
28
|
+
grow?: boolean;
|
|
29
|
+
__types?: [TData, TValue];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
declare const _default: typeof __VLS_export;
|
|
33
|
+
export default _default;
|
|
30
34
|
declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
31
35
|
id: string;
|
|
32
36
|
getRowId?: Expression;
|
|
@@ -55,5 +59,3 @@ declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
|
55
59
|
readonly enableRowSelection: Expression;
|
|
56
60
|
readonly cellStyles: Expression;
|
|
57
61
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
58
|
-
declare const _default: typeof __VLS_export;
|
|
59
|
-
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '../table-renderers/builtins.js';
|
|
2
2
|
import { getTableRenderer, resolveTableRenderer } from '../table-renderers/registry.js';
|
|
3
3
|
export { defineTableRenderer } from '../table-renderers/registry.js';
|
|
4
|
-
export type { TableRenderer, TableRendererCellArgs, TableRendererColumnDefOverrides, TableRendererConfigComponent, TableRendererHeaderArgs, TableRendererId, } from '../table-renderers/registry.js';
|
|
4
|
+
export type { TableRenderer, TableRendererCellArgs, TableRendererColumnDefOverrides, TableRendererConfigComponent, TableRendererFooterArgs, TableRendererHeaderArgs, TableRendererId, } from '../table-renderers/registry.js';
|
|
5
5
|
export declare function useTableRenderers(): {
|
|
6
6
|
getTableRenderer: typeof getTableRenderer;
|
|
7
7
|
resolveTableRenderer: typeof resolveTableRenderer;
|
|
@@ -4,6 +4,7 @@ import { format as formatDate, isValid, toDate } from "date-fns";
|
|
|
4
4
|
import { defineComponent } from "vue";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { defineTableRenderer } from "./registry.js";
|
|
7
|
+
import { useNuxtApp } from "#app";
|
|
7
8
|
const JUSTIFY_CLASS = {
|
|
8
9
|
left: "justify-start",
|
|
9
10
|
center: "justify-center",
|
|
@@ -185,16 +186,17 @@ defineTableRenderer(
|
|
|
185
186
|
align: z.enum(["left", "center", "right"]).default("left")
|
|
186
187
|
},
|
|
187
188
|
{
|
|
188
|
-
cell: ({ ctx, options
|
|
189
|
+
cell: ({ ctx, options }) => {
|
|
189
190
|
const rawValue = ctx.cell.getValue();
|
|
190
191
|
const isEmpty = rawValue === void 0 || rawValue === null;
|
|
191
192
|
const align = isEmpty ? "center" : options.align ?? "left";
|
|
192
193
|
const justifyClass = JUSTIFY_CLASS[align];
|
|
194
|
+
const { $dsl } = useNuxtApp();
|
|
193
195
|
const onCopy = async () => {
|
|
194
196
|
try {
|
|
195
197
|
let text = String(ctx.cell.getValue());
|
|
196
|
-
if (options.copyExpression
|
|
197
|
-
text = String(
|
|
198
|
+
if (options.copyExpression) {
|
|
199
|
+
text = String($dsl.evaluate(options.copyExpression, {
|
|
198
200
|
row: ctx.row.original,
|
|
199
201
|
index: BigInt(ctx.row.index)
|
|
200
202
|
}));
|
|
@@ -223,7 +225,7 @@ defineTableRenderer(
|
|
|
223
225
|
"cursor-pointer absolute right-1 top-1/2 -translate-y-1/2 bg-white border",
|
|
224
226
|
"w-6 h-6 flex items-center justify-center group-hover:opacity-100 opacity-0",
|
|
225
227
|
"transition-all duration-180 rounded border-zinc-200 text-zinc-500",
|
|
226
|
-
"hover:border-[var(--primary)]
|
|
228
|
+
"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
229
|
],
|
|
228
230
|
onClick: onCopy,
|
|
229
231
|
children: /* @__PURE__ */ jsx(Icon, { icon: "fluent:copy-20-regular" })
|
|
@@ -287,7 +289,7 @@ defineTableRenderer(
|
|
|
287
289
|
type: "checkbox",
|
|
288
290
|
checked,
|
|
289
291
|
class: [
|
|
290
|
-
"peer h-4 w-4 cursor-pointer transition-colors duration-180 appearance-none rounded",
|
|
292
|
+
"peer h-4 w-4 cursor-pointer transition-colors duration-180 appearance-none rounded bg-white",
|
|
291
293
|
"border border-[color-mix(in_srgb,var(--primary)_10%,#00000033)] not-checked-group-hover:border-[color-mix(in_srgb,var(--primary)_20%,#00000033)]",
|
|
292
294
|
"not-checked-group-hover:bg-[color-mix(in_srgb,var(--primary)_5%,#00000011)] checked:border-[var(--primary)] checked:bg-[var(--primary)]"
|
|
293
295
|
],
|
|
@@ -333,7 +335,10 @@ defineTableRenderer(
|
|
|
333
335
|
children: /* @__PURE__ */ jsx(Icon, { icon: ctx.table.getIsAllRowsExpanded() ? "fluent:subtract-square-20-regular" : "fluent:add-square-20-regular" })
|
|
334
336
|
}
|
|
335
337
|
) }),
|
|
336
|
-
config: NoOptionsConfig
|
|
338
|
+
config: NoOptionsConfig,
|
|
339
|
+
columnDefOverrides: {
|
|
340
|
+
enableResizing: false
|
|
341
|
+
}
|
|
337
342
|
}
|
|
338
343
|
);
|
|
339
344
|
defineTableRenderer(
|
|
@@ -394,9 +399,10 @@ defineTableRenderer(
|
|
|
394
399
|
source: z.string().optional()
|
|
395
400
|
},
|
|
396
401
|
{
|
|
397
|
-
cell: ({ ctx, options
|
|
402
|
+
cell: ({ ctx, options }) => {
|
|
403
|
+
const { $markdown } = useNuxtApp();
|
|
398
404
|
const source = options.source ?? String(ctx.cell.getValue());
|
|
399
|
-
const html =
|
|
405
|
+
const html = $markdown.renderInline(source);
|
|
400
406
|
return /* @__PURE__ */ jsx("div", { class: "relative w-full py-2 px-1 flex items-center justify-center text-xs", children: /* @__PURE__ */ jsx("span", { class: "prose prose-zinc text-xs", innerHTML: html }) });
|
|
401
407
|
},
|
|
402
408
|
config: TableRendererMarkdownConfig
|
|
@@ -6,19 +6,14 @@ export type TableRendererColumnDefOverrides<TData extends RowData = unknown> = P
|
|
|
6
6
|
export type TableRendererCellArgs<TData extends RowData, TValue, TOptions> = Readonly<{
|
|
7
7
|
ctx: CellContext<TData, TValue>;
|
|
8
8
|
options: TOptions;
|
|
9
|
-
helpers: Readonly<{
|
|
10
|
-
renderInline: (source: string) => string;
|
|
11
|
-
evaluate?: (source: string, context?: Record<string, unknown>) => unknown;
|
|
12
|
-
}>;
|
|
13
9
|
}>;
|
|
14
10
|
export type TableRendererHeaderArgs<TData extends RowData, TValue, TOptions> = Readonly<{
|
|
15
11
|
ctx: HeaderContext<TData, TValue>;
|
|
16
|
-
title?: string;
|
|
17
12
|
options: TOptions;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
}>;
|
|
14
|
+
export type TableRendererFooterArgs<TData extends RowData, TValue, TOptions> = Readonly<{
|
|
15
|
+
ctx: HeaderContext<TData, TValue>;
|
|
16
|
+
options: TOptions;
|
|
22
17
|
}>;
|
|
23
18
|
export type TableRendererConfigComponent<_TOptions> = unknown;
|
|
24
19
|
export type TableRenderer<TOptions> = Readonly<{
|
|
@@ -27,12 +22,14 @@ export type TableRenderer<TOptions> = Readonly<{
|
|
|
27
22
|
parseOptions: (input: unknown) => TOptions;
|
|
28
23
|
cell: (args: TableRendererCellArgs<unknown, unknown, TOptions>) => VNodeChild;
|
|
29
24
|
header?: (args: TableRendererHeaderArgs<unknown, unknown, TOptions>) => VNodeChild;
|
|
25
|
+
footer?: (args: TableRendererFooterArgs<unknown, unknown, TOptions>) => VNodeChild;
|
|
30
26
|
config?: TableRendererConfigComponent<TOptions>;
|
|
31
27
|
columnDefOverrides?: TableRendererColumnDefOverrides;
|
|
32
28
|
}>;
|
|
33
29
|
export declare function defineTableRenderer<const TShape extends z.ZodRawShape, const TOptions = z.infer<z.ZodObject<TShape>>>(id: TableRendererId, shape: TShape, impl: Readonly<{
|
|
34
30
|
cell: TableRenderer<TOptions>['cell'];
|
|
35
31
|
header?: TableRenderer<TOptions>['header'];
|
|
32
|
+
footer?: TableRenderer<TOptions>['footer'];
|
|
36
33
|
config?: TableRenderer<TOptions>['config'];
|
|
37
34
|
columnDefOverrides?: TableRenderer<TOptions>['columnDefOverrides'];
|
|
38
35
|
}>): TableRenderer<TOptions>;
|
|
@@ -6,11 +6,12 @@ export function defineTableRenderer(id, shape, impl) {
|
|
|
6
6
|
id,
|
|
7
7
|
optionsSchema,
|
|
8
8
|
parseOptions: (input) => {
|
|
9
|
-
const normalized = input
|
|
9
|
+
const normalized = input === null || input === void 0 ? {} : input;
|
|
10
10
|
return optionsSchema.parse(normalized);
|
|
11
11
|
},
|
|
12
12
|
cell: impl.cell,
|
|
13
13
|
header: impl.header,
|
|
14
|
+
footer: impl.footer,
|
|
14
15
|
config: impl.config,
|
|
15
16
|
columnDefOverrides: impl.columnDefOverrides
|
|
16
17
|
};
|