@shwfed/nuxt 0.1.17 → 0.1.18
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/module.mjs +0 -1
- package/dist/runtime/components/table.d.vue.ts +5 -0
- package/dist/runtime/components/table.vue +8 -7
- package/dist/runtime/components/table.vue.d.ts +5 -0
- package/dist/runtime/plugins/cel/index.js +22 -19
- package/dist/runtime/plugins/markdown/index.d.ts +16 -8
- package/dist/runtime/plugins/markdown/index.js +29 -28
- package/dist/runtime/table-renderers/builtins.js +2 -3
- package/package.json +1 -1
- package/dist/runtime/types/directive.d.ts +0 -9
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RowData, TableOptions } from '@tanstack/vue-table';
|
|
2
2
|
export type Expression = string;
|
|
3
|
+
export type Markdown = string;
|
|
3
4
|
export type Render = string | Readonly<{
|
|
4
5
|
id: string;
|
|
5
6
|
props: unknown;
|
|
@@ -41,6 +42,8 @@ declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
|
41
42
|
data: Array<unknown>;
|
|
42
43
|
cellStyles?: Expression;
|
|
43
44
|
props?: Omit<TableOptions<unknown>, "columns" | "data" | "getRowId" | "getCoreRowModel">;
|
|
45
|
+
paginationLeft?: Markdown;
|
|
46
|
+
paginationRight?: Markdown;
|
|
44
47
|
}>, import("@tanstack/vue-table").Table<unknown>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Readonly<{
|
|
45
48
|
id: string;
|
|
46
49
|
getRowId?: Expression;
|
|
@@ -51,6 +54,8 @@ declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
|
51
54
|
data: Array<unknown>;
|
|
52
55
|
cellStyles?: Expression;
|
|
53
56
|
props?: Omit<TableOptions<unknown>, "columns" | "data" | "getRowId" | "getCoreRowModel">;
|
|
57
|
+
paginationLeft?: Markdown;
|
|
58
|
+
paginationRight?: Markdown;
|
|
54
59
|
}>> & Readonly<{}>, {
|
|
55
60
|
readonly props: Omit<TableOptions<unknown>, "columns" | "data" | "getRowId" | "getCoreRowModel">;
|
|
56
61
|
readonly getRowId: Expression;
|
|
@@ -20,14 +20,13 @@ const props = defineProps({
|
|
|
20
20
|
columns: { type: Array, required: true },
|
|
21
21
|
data: { type: Array, required: true },
|
|
22
22
|
cellStyles: { type: String, required: false, default: void 0 },
|
|
23
|
-
props: { type: Object, required: false, default: void 0 }
|
|
23
|
+
props: { type: Object, required: false, default: void 0 },
|
|
24
|
+
paginationLeft: { type: String, required: false },
|
|
25
|
+
paginationRight: { type: String, required: false }
|
|
24
26
|
});
|
|
25
|
-
const { $dsl
|
|
27
|
+
const { $dsl } = useNuxtApp();
|
|
26
28
|
const { resolveTableRenderer } = useTableRenderers();
|
|
27
29
|
const containerRef = ref(null);
|
|
28
|
-
function renderInline(source) {
|
|
29
|
-
return $markdown.renderInline(source);
|
|
30
|
-
}
|
|
31
30
|
function genColumnId(column) {
|
|
32
31
|
if (typeof column.accessor === "string") {
|
|
33
32
|
return column.accessor;
|
|
@@ -292,7 +291,7 @@ function getSortIcon(column) {
|
|
|
292
291
|
<Tooltip
|
|
293
292
|
v-if="!header.isPlaceholder && header.column.columnDef.meta?.tooltip"
|
|
294
293
|
:delay-duration="180"
|
|
295
|
-
:content="
|
|
294
|
+
:content="$md.inline`${header.column.columnDef.meta.tooltip}`"
|
|
296
295
|
>
|
|
297
296
|
<Icon icon="fluent:info-20-regular" />
|
|
298
297
|
</Tooltip>
|
|
@@ -408,7 +407,9 @@ function getSortIcon(column) {
|
|
|
408
407
|
</div>
|
|
409
408
|
|
|
410
409
|
<div class="flex items-center justify-between w-full p-4 text-sm text-zinc-600">
|
|
411
|
-
<div
|
|
410
|
+
<div>
|
|
411
|
+
<div />
|
|
412
|
+
</div>
|
|
412
413
|
<div class="flex items-center gap-4">
|
|
413
414
|
<span class="text-xs">{{ `\u5171 ${props.data.length} \u6761` }}</span>
|
|
414
415
|
<Pagination.Root
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RowData, TableOptions } from '@tanstack/vue-table';
|
|
2
2
|
export type Expression = string;
|
|
3
|
+
export type Markdown = string;
|
|
3
4
|
export type Render = string | Readonly<{
|
|
4
5
|
id: string;
|
|
5
6
|
props: unknown;
|
|
@@ -41,6 +42,8 @@ declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
|
41
42
|
data: Array<unknown>;
|
|
42
43
|
cellStyles?: Expression;
|
|
43
44
|
props?: Omit<TableOptions<unknown>, "columns" | "data" | "getRowId" | "getCoreRowModel">;
|
|
45
|
+
paginationLeft?: Markdown;
|
|
46
|
+
paginationRight?: Markdown;
|
|
44
47
|
}>, import("@tanstack/vue-table").Table<unknown>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Readonly<{
|
|
45
48
|
id: string;
|
|
46
49
|
getRowId?: Expression;
|
|
@@ -51,6 +54,8 @@ declare const __VLS_export: import("vue").DefineComponent<Readonly<{
|
|
|
51
54
|
data: Array<unknown>;
|
|
52
55
|
cellStyles?: Expression;
|
|
53
56
|
props?: Omit<TableOptions<unknown>, "columns" | "data" | "getRowId" | "getCoreRowModel">;
|
|
57
|
+
paginationLeft?: Markdown;
|
|
58
|
+
paginationRight?: Markdown;
|
|
54
59
|
}>> & Readonly<{}>, {
|
|
55
60
|
readonly props: Omit<TableOptions<unknown>, "columns" | "data" | "getRowId" | "getCoreRowModel">;
|
|
56
61
|
readonly getRowId: Expression;
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { defineNuxtPlugin } from "#app";
|
|
2
2
|
import defu from "defu";
|
|
3
3
|
import { createEnvironment } from "./env.js";
|
|
4
|
-
export default defineNuxtPlugin(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
export default defineNuxtPlugin({
|
|
5
|
+
name: "shwfed-nuxt:cel",
|
|
6
|
+
setup: () => {
|
|
7
|
+
const env = createEnvironment();
|
|
8
|
+
return {
|
|
9
|
+
provide: {
|
|
10
|
+
dsl: {
|
|
11
|
+
check: (source) => {
|
|
12
|
+
return env.check(source);
|
|
13
|
+
},
|
|
14
|
+
/**
|
|
15
|
+
* Synchronous evaluation for render-time usage (e.g. table accessors).
|
|
16
|
+
*
|
|
17
|
+
* Will throw `TypeError` / `EvaluationError` on failure.
|
|
18
|
+
*/
|
|
19
|
+
evaluate: (source, context) => {
|
|
20
|
+
return env.evaluate(source, defu(context, {
|
|
21
|
+
now: /* @__PURE__ */ new Date()
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
25
28
|
});
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { md } from './md.js';
|
|
2
2
|
declare const _default: import("#app").Plugin<{
|
|
3
|
-
md:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
md: {
|
|
4
|
+
raw: typeof md;
|
|
5
|
+
inline: (template: {
|
|
6
|
+
raw: readonly string[] | ArrayLike<string>;
|
|
7
|
+
}, ...substitutions: any[]) => string;
|
|
8
|
+
block: (template: {
|
|
9
|
+
raw: readonly string[] | ArrayLike<string>;
|
|
10
|
+
}, ...substitutions: any[]) => string;
|
|
7
11
|
};
|
|
8
12
|
}> & import("#app").ObjectPlugin<{
|
|
9
|
-
md:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
md: {
|
|
14
|
+
raw: typeof md;
|
|
15
|
+
inline: (template: {
|
|
16
|
+
raw: readonly string[] | ArrayLike<string>;
|
|
17
|
+
}, ...substitutions: any[]) => string;
|
|
18
|
+
block: (template: {
|
|
19
|
+
raw: readonly string[] | ArrayLike<string>;
|
|
20
|
+
}, ...substitutions: any[]) => string;
|
|
13
21
|
};
|
|
14
22
|
}>;
|
|
15
23
|
export default _default;
|
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import { defineNuxtPlugin } from "#app";
|
|
1
|
+
import { defineNuxtPlugin, useNuxtApp } from "#app";
|
|
2
2
|
import MarkdownIt from "markdown-it";
|
|
3
3
|
import { md } from "./md.js";
|
|
4
|
-
export default defineNuxtPlugin(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
export default defineNuxtPlugin({
|
|
5
|
+
name: "shwfed-nuxt:markdown",
|
|
6
|
+
dependsOn: ["shwfed-nuxt:cel"],
|
|
7
|
+
setup: () => {
|
|
8
|
+
const engine = new MarkdownIt("commonmark", {
|
|
9
|
+
html: true
|
|
10
|
+
});
|
|
11
|
+
const { $dsl } = useNuxtApp();
|
|
12
|
+
function evaluateBlock(source) {
|
|
13
|
+
return source.replace(/\{\{([\s\S]+?)\}\}/g, (_, expression) => {
|
|
14
|
+
if (!expression)
|
|
15
|
+
return "";
|
|
16
|
+
try {
|
|
17
|
+
return $dsl.evaluate(expression);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.error(e);
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
});
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
return {
|
|
25
|
+
provide: {
|
|
26
|
+
md: {
|
|
27
|
+
raw: md,
|
|
28
|
+
inline: (...args) => engine.renderInline(evaluateBlock(md(...args))),
|
|
29
|
+
block: (...args) => engine.render(evaluateBlock(md(...args)))
|
|
30
|
+
}
|
|
30
31
|
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
33
34
|
});
|
|
@@ -400,10 +400,9 @@ defineTableRenderer(
|
|
|
400
400
|
},
|
|
401
401
|
{
|
|
402
402
|
cell: ({ ctx, options }) => {
|
|
403
|
-
const { $
|
|
403
|
+
const { $md } = useNuxtApp();
|
|
404
404
|
const source = options.source ?? String(ctx.cell.getValue());
|
|
405
|
-
|
|
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 }) });
|
|
405
|
+
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: $md.inline`${source}` }) });
|
|
407
406
|
},
|
|
408
407
|
config: TableRendererMarkdownConfig
|
|
409
408
|
}
|
package/package.json
CHANGED