@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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
3
  "configKey": "shwfed",
4
- "version": "0.1.17",
4
+ "version": "0.1.18",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -18,7 +18,6 @@ const module$1 = defineNuxtModule({
18
18
  prefix: "shwfed",
19
19
  extensions: ["vue"]
20
20
  });
21
- nuxt.options.typescript.tsConfig.include?.push(resolver.resolve("runtime/types/directive.d.ts"));
22
21
  }
23
22
  });
24
23
 
@@ -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, $markdown } = useNuxtApp();
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="renderInline(header.column.columnDef.meta.tooltip)"
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
- const env = createEnvironment();
6
- return {
7
- provide: {
8
- dsl: {
9
- check: (source) => {
10
- return env.check(source);
11
- },
12
- /**
13
- * Synchronous evaluation for render-time usage (e.g. table accessors).
14
- *
15
- * Will throw `TypeError` / `EvaluationError` on failure.
16
- */
17
- evaluate: (source, context) => {
18
- return env.evaluate(source, defu(context, {
19
- now: /* @__PURE__ */ new Date()
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: typeof md;
4
- markdown: {
5
- render: (source: string) => string;
6
- renderInline: (source: string) => string;
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: typeof md;
10
- markdown: {
11
- render: (source: string) => string;
12
- renderInline: (source: string) => string;
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((app) => {
5
- const engine = new MarkdownIt("commonmark", {
6
- html: true
7
- });
8
- app.vueApp.directive("md", {
9
- beforeMount(el, v) {
10
- if (["inline", "inline-flex", "inline-block"].includes(getComputedStyle(el).display)) {
11
- el.innerHTML = engine.renderInline(v.value);
12
- } else {
13
- el.innerHTML = engine.render(v.value);
14
- }
15
- },
16
- beforeUpdate(el, v) {
17
- if (["inline", "inline-flex", "inline-block"].includes(getComputedStyle(el).display)) {
18
- el.innerHTML = engine.renderInline(v.value);
19
- } else {
20
- el.innerHTML = engine.render(v.value);
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
- return {
25
- provide: {
26
- md,
27
- markdown: {
28
- render: (source) => engine.render(source),
29
- renderInline: (source) => engine.renderInline(source)
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 { $markdown } = useNuxtApp();
403
+ const { $md } = useNuxtApp();
404
404
  const source = options.source ?? String(ctx.cell.getValue());
405
- const html = $markdown.renderInline(source);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,9 +0,0 @@
1
- import type { Directive } from 'vue'
2
-
3
- export type MdDirective = Directive<HTMLElement, string>
4
-
5
- declare module 'vue' {
6
- export interface ComponentCustomProperties {
7
- vMd: MdDirective
8
- }
9
- }