@shapesos/clay 0.10.0 → 0.12.0
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/README.md +60 -0
- package/dist/artifacts.cjs +1467 -0
- package/dist/artifacts.cjs.map +1 -0
- package/dist/artifacts.d.cts +89 -0
- package/dist/artifacts.d.ts +89 -0
- package/dist/artifacts.js +33 -0
- package/dist/blocks.cjs +1418 -68
- package/dist/blocks.cjs.map +1 -1
- package/dist/blocks.css +2 -0
- package/dist/blocks.d.cts +36 -11
- package/dist/blocks.d.ts +36 -11
- package/dist/blocks.js +18 -5
- package/dist/button.d.cts +2 -2
- package/dist/button.d.ts +2 -2
- package/dist/chart.cjs +594 -0
- package/dist/chart.cjs.map +1 -0
- package/dist/chart.d.cts +439 -0
- package/dist/chart.d.ts +439 -0
- package/dist/chart.js +32 -0
- package/dist/chart.js.map +1 -0
- package/dist/chat.cjs +1462 -312
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.d.cts +28 -10
- package/dist/chat.d.ts +28 -10
- package/dist/chat.js +10 -3
- package/dist/{chunk-R3BGPOAM.js → chunk-36CB624W.js} +53 -45
- package/dist/chunk-36CB624W.js.map +1 -0
- package/dist/chunk-4MZZH3WX.js +93 -0
- package/dist/chunk-4MZZH3WX.js.map +1 -0
- package/dist/chunk-AQEJRMRN.js +1 -0
- package/dist/chunk-AQEJRMRN.js.map +1 -0
- package/dist/{chunk-WS4IPADR.js → chunk-FFX3CAOX.js} +41 -109
- package/dist/chunk-FFX3CAOX.js.map +1 -0
- package/dist/chunk-JGMN6W72.js +12 -0
- package/dist/chunk-JGMN6W72.js.map +1 -0
- package/dist/{chunk-27GJUWVN.js → chunk-JJUIBBBU.js} +14 -8
- package/dist/chunk-JJUIBBBU.js.map +1 -0
- package/dist/{chunk-MLCRDVQ2.js → chunk-OBOXCBDL.js} +13 -5
- package/dist/chunk-OBOXCBDL.js.map +1 -0
- package/dist/chunk-P6GUNIAE.js +11 -0
- package/dist/chunk-P6GUNIAE.js.map +1 -0
- package/dist/chunk-QXGYMDIA.js +477 -0
- package/dist/chunk-QXGYMDIA.js.map +1 -0
- package/dist/chunk-Z5JWF24N.js +719 -0
- package/dist/chunk-Z5JWF24N.js.map +1 -0
- package/dist/icon.cjs +12 -4
- package/dist/icon.cjs.map +1 -1
- package/dist/icon.d.cts +19 -6
- package/dist/icon.d.ts +19 -6
- package/dist/icon.js +1 -1
- package/dist/index.cjs +1520 -332
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +58 -25
- package/dist/lottie.d.cts +2 -2
- package/dist/lottie.d.ts +2 -2
- package/dist/table.cjs +142 -0
- package/dist/table.cjs.map +1 -0
- package/dist/table.d.cts +44 -0
- package/dist/table.d.ts +44 -0
- package/dist/table.js +25 -0
- package/dist/table.js.map +1 -0
- package/dist/text-area.d.cts +2 -2
- package/dist/text-area.d.ts +2 -2
- package/dist/types-B2aYk82c.d.cts +29 -0
- package/dist/types-B2aYk82c.d.ts +29 -0
- package/dist/types-C0BvwliI.d.cts +332 -0
- package/dist/types-C5bFH4v3.d.ts +332 -0
- package/dist/types-DCutaXjZ.d.cts +83 -0
- package/dist/types-uPfn67Dc.d.ts +83 -0
- package/dist/utils.cjs +14 -7
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +18 -1
- package/dist/utils.d.ts +18 -1
- package/dist/utils.js +6 -4
- package/package.json +41 -4
- package/dist/chunk-27GJUWVN.js.map +0 -1
- package/dist/chunk-MLCRDVQ2.js.map +0 -1
- package/dist/chunk-OKPNST44.js +0 -1
- package/dist/chunk-R3BGPOAM.js.map +0 -1
- package/dist/chunk-WS4IPADR.js.map +0 -1
- package/dist/types-Q9aqd9nq.d.cts +0 -34
- package/dist/types-Q9aqd9nq.d.ts +0 -34
- /package/dist/{chunk-OKPNST44.js.map → artifacts.js.map} +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { b as ArtifactRecord, a as ArtifactLabelsMap, p as ArtifactCallbacksMap } from './types-C0BvwliI.cjs';
|
|
3
|
+
|
|
4
|
+
/** Block-type discriminator constants. Mirrors the wire shape from io-server / shapes-agent. */
|
|
5
|
+
declare const blockTypes: {
|
|
6
|
+
readonly TEXT: "TEXT";
|
|
7
|
+
readonly ARTIFACT_REF: "ARTIFACT_REF";
|
|
8
|
+
};
|
|
9
|
+
/** Discriminator for content blocks. */
|
|
10
|
+
type BlockType = (typeof blockTypes)[keyof typeof blockTypes];
|
|
11
|
+
/** Plain-text content block — rendered as Markdown. */
|
|
12
|
+
interface TextBlockRecord {
|
|
13
|
+
/** Block-type discriminator. */
|
|
14
|
+
type: typeof blockTypes.TEXT;
|
|
15
|
+
/** Type-specific data; kept as `payload` to match the wire shape 1:1. */
|
|
16
|
+
payload: {
|
|
17
|
+
/** The Markdown source for this text segment. */
|
|
18
|
+
text: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Reference-to-an-artifact content block — dispatched to the per-type artifact component.
|
|
23
|
+
*
|
|
24
|
+
* The artifact-domain types (`ArtifactRecord`, `TableArtifactRecord`, etc.) live in
|
|
25
|
+
* `@/components/artifacts/types` so the artifact layer can be consumed independently of the
|
|
26
|
+
* block layer (e.g. by a future surface that renders an artifact outside chat). The block layer
|
|
27
|
+
* imports them here to wrap an artifact in an `ARTIFACT_REF` block.
|
|
28
|
+
*/
|
|
29
|
+
interface ArtifactRefBlockRecord {
|
|
30
|
+
/** Block-type discriminator. */
|
|
31
|
+
type: typeof blockTypes.ARTIFACT_REF;
|
|
32
|
+
/** Type-specific data; kept as `payload` to match the wire shape 1:1. */
|
|
33
|
+
payload: {
|
|
34
|
+
/** The artifact's stable identifier, used for keying / future cross-message reuse. */
|
|
35
|
+
artifactId: string;
|
|
36
|
+
/** Inlined artifact metadata — clients fetch the underlying data via `artifact.protectedAsset.presignedUrl`. */
|
|
37
|
+
artifact: ArtifactRecord;
|
|
38
|
+
/**
|
|
39
|
+
* Optional consumer-supplied labels for the rendered artifact's action buttons + status
|
|
40
|
+
* messages, keyed by artifact type. NOT a wire field — the consumer constructs this from
|
|
41
|
+
* their i18n layer when materialising the block-record from the server payload, then passes
|
|
42
|
+
* the augmented block to `<Block>`. The dispatcher stays generic — it forwards the whole
|
|
43
|
+
* `labels` bag to every artifact component, and each component reads its own slice
|
|
44
|
+
* (`labels.TABLE`, `labels.CHART`) internally.
|
|
45
|
+
*/
|
|
46
|
+
labels?: Partial<ArtifactLabelsMap>;
|
|
47
|
+
/**
|
|
48
|
+
* Optional side-effect callbacks for actions on the rendered artifact (e.g. `onDownload`).
|
|
49
|
+
* Keyed by artifact type, mirroring `labels`. NOT a wire field — the consumer wires this
|
|
50
|
+
* once to bridge artifact actions to their analytics / observability layer.
|
|
51
|
+
*/
|
|
52
|
+
callbacks?: Partial<ArtifactCallbacksMap>;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Discriminated union of all supported content blocks. Additive — new types extend this union. */
|
|
56
|
+
type BlockRecord = TextBlockRecord | ArtifactRefBlockRecord;
|
|
57
|
+
/** Props every concrete block component receives from the dispatcher. */
|
|
58
|
+
interface BlockComponentProps<TBlock extends BlockRecord = BlockRecord> {
|
|
59
|
+
/** The block to render. */
|
|
60
|
+
block: TBlock;
|
|
61
|
+
}
|
|
62
|
+
/** Per-block-type service — registry entry that pairs a discriminator with its concrete component. */
|
|
63
|
+
interface BlockService<TBlock extends BlockRecord = BlockRecord> {
|
|
64
|
+
/** Discriminator value this service handles. */
|
|
65
|
+
type: BlockType;
|
|
66
|
+
/** React component that renders a block of this type. */
|
|
67
|
+
Component: ComponentType<BlockComponentProps<TBlock>>;
|
|
68
|
+
/**
|
|
69
|
+
* Returns a plain-text or markdown string representation of this block suitable for clipboard
|
|
70
|
+
* copy. Called by `copyMessageText` when the user clicks "copy message".
|
|
71
|
+
*
|
|
72
|
+
* - `TextBlockService`: returns `block.payload.text` verbatim (markdown preserved).
|
|
73
|
+
* - `ArtifactRefBlockService`: delegates to `ArtifactServices[artifact.type].toClipboardText`.
|
|
74
|
+
* Falls back to `[Artifact: <title>]` when the artifact type has no registered component.
|
|
75
|
+
*
|
|
76
|
+
* Optional so external `BlockService` implementors don't break on upgrade — when omitted, the
|
|
77
|
+
* aggregator treats the block as contributing the empty string (silently skipped). Implementations
|
|
78
|
+
* must be pure, synchronous functions — no async, no hooks, no side effects.
|
|
79
|
+
*/
|
|
80
|
+
toClipboardText?: (block: TBlock) => string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { type ArtifactRefBlockRecord as A, type BlockComponentProps as B, type TextBlockRecord as T, type BlockRecord as a, type BlockService as b, type BlockType as c, blockTypes as d };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { b as ArtifactRecord, a as ArtifactLabelsMap, p as ArtifactCallbacksMap } from './types-C5bFH4v3.js';
|
|
3
|
+
|
|
4
|
+
/** Block-type discriminator constants. Mirrors the wire shape from io-server / shapes-agent. */
|
|
5
|
+
declare const blockTypes: {
|
|
6
|
+
readonly TEXT: "TEXT";
|
|
7
|
+
readonly ARTIFACT_REF: "ARTIFACT_REF";
|
|
8
|
+
};
|
|
9
|
+
/** Discriminator for content blocks. */
|
|
10
|
+
type BlockType = (typeof blockTypes)[keyof typeof blockTypes];
|
|
11
|
+
/** Plain-text content block — rendered as Markdown. */
|
|
12
|
+
interface TextBlockRecord {
|
|
13
|
+
/** Block-type discriminator. */
|
|
14
|
+
type: typeof blockTypes.TEXT;
|
|
15
|
+
/** Type-specific data; kept as `payload` to match the wire shape 1:1. */
|
|
16
|
+
payload: {
|
|
17
|
+
/** The Markdown source for this text segment. */
|
|
18
|
+
text: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Reference-to-an-artifact content block — dispatched to the per-type artifact component.
|
|
23
|
+
*
|
|
24
|
+
* The artifact-domain types (`ArtifactRecord`, `TableArtifactRecord`, etc.) live in
|
|
25
|
+
* `@/components/artifacts/types` so the artifact layer can be consumed independently of the
|
|
26
|
+
* block layer (e.g. by a future surface that renders an artifact outside chat). The block layer
|
|
27
|
+
* imports them here to wrap an artifact in an `ARTIFACT_REF` block.
|
|
28
|
+
*/
|
|
29
|
+
interface ArtifactRefBlockRecord {
|
|
30
|
+
/** Block-type discriminator. */
|
|
31
|
+
type: typeof blockTypes.ARTIFACT_REF;
|
|
32
|
+
/** Type-specific data; kept as `payload` to match the wire shape 1:1. */
|
|
33
|
+
payload: {
|
|
34
|
+
/** The artifact's stable identifier, used for keying / future cross-message reuse. */
|
|
35
|
+
artifactId: string;
|
|
36
|
+
/** Inlined artifact metadata — clients fetch the underlying data via `artifact.protectedAsset.presignedUrl`. */
|
|
37
|
+
artifact: ArtifactRecord;
|
|
38
|
+
/**
|
|
39
|
+
* Optional consumer-supplied labels for the rendered artifact's action buttons + status
|
|
40
|
+
* messages, keyed by artifact type. NOT a wire field — the consumer constructs this from
|
|
41
|
+
* their i18n layer when materialising the block-record from the server payload, then passes
|
|
42
|
+
* the augmented block to `<Block>`. The dispatcher stays generic — it forwards the whole
|
|
43
|
+
* `labels` bag to every artifact component, and each component reads its own slice
|
|
44
|
+
* (`labels.TABLE`, `labels.CHART`) internally.
|
|
45
|
+
*/
|
|
46
|
+
labels?: Partial<ArtifactLabelsMap>;
|
|
47
|
+
/**
|
|
48
|
+
* Optional side-effect callbacks for actions on the rendered artifact (e.g. `onDownload`).
|
|
49
|
+
* Keyed by artifact type, mirroring `labels`. NOT a wire field — the consumer wires this
|
|
50
|
+
* once to bridge artifact actions to their analytics / observability layer.
|
|
51
|
+
*/
|
|
52
|
+
callbacks?: Partial<ArtifactCallbacksMap>;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Discriminated union of all supported content blocks. Additive — new types extend this union. */
|
|
56
|
+
type BlockRecord = TextBlockRecord | ArtifactRefBlockRecord;
|
|
57
|
+
/** Props every concrete block component receives from the dispatcher. */
|
|
58
|
+
interface BlockComponentProps<TBlock extends BlockRecord = BlockRecord> {
|
|
59
|
+
/** The block to render. */
|
|
60
|
+
block: TBlock;
|
|
61
|
+
}
|
|
62
|
+
/** Per-block-type service — registry entry that pairs a discriminator with its concrete component. */
|
|
63
|
+
interface BlockService<TBlock extends BlockRecord = BlockRecord> {
|
|
64
|
+
/** Discriminator value this service handles. */
|
|
65
|
+
type: BlockType;
|
|
66
|
+
/** React component that renders a block of this type. */
|
|
67
|
+
Component: ComponentType<BlockComponentProps<TBlock>>;
|
|
68
|
+
/**
|
|
69
|
+
* Returns a plain-text or markdown string representation of this block suitable for clipboard
|
|
70
|
+
* copy. Called by `copyMessageText` when the user clicks "copy message".
|
|
71
|
+
*
|
|
72
|
+
* - `TextBlockService`: returns `block.payload.text` verbatim (markdown preserved).
|
|
73
|
+
* - `ArtifactRefBlockService`: delegates to `ArtifactServices[artifact.type].toClipboardText`.
|
|
74
|
+
* Falls back to `[Artifact: <title>]` when the artifact type has no registered component.
|
|
75
|
+
*
|
|
76
|
+
* Optional so external `BlockService` implementors don't break on upgrade — when omitted, the
|
|
77
|
+
* aggregator treats the block as contributing the empty string (silently skipped). Implementations
|
|
78
|
+
* must be pure, synchronous functions — no async, no hooks, no side effects.
|
|
79
|
+
*/
|
|
80
|
+
toClipboardText?: (block: TBlock) => string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { type ArtifactRefBlockRecord as A, type BlockComponentProps as B, type TextBlockRecord as T, type BlockRecord as a, type BlockService as b, type BlockType as c, blockTypes as d };
|
package/dist/utils.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var utils_exports = {};
|
|
22
22
|
__export(utils_exports, {
|
|
23
23
|
convertTableToCSV: () => convertTableToCSV,
|
|
24
|
+
escapeCsvField: () => escapeCsvField,
|
|
24
25
|
markdownToPlainText: () => markdownToPlainText,
|
|
25
26
|
mergeRefs: () => mergeRefs,
|
|
26
27
|
parseMarkdownTable: () => parseMarkdownTable
|
|
@@ -112,21 +113,27 @@ function parseMarkdownTable(markdown, tableIndex = 0) {
|
|
|
112
113
|
return null;
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
// src/utils/
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
// src/utils/escape-csv-field.ts
|
|
117
|
+
var FORMULA_TRIGGERS = /* @__PURE__ */ new Set(["=", "+", "@", " ", "\r"]);
|
|
118
|
+
function escapeCsvField(field) {
|
|
119
|
+
const needsNeutralise = field.length > 0 && FORMULA_TRIGGERS.has(field[0]);
|
|
120
|
+
const safeField = needsNeutralise ? ` ${field}` : field;
|
|
121
|
+
if (needsNeutralise || safeField.includes(",") || safeField.includes('"') || safeField.includes("\n") || safeField.includes("\r")) {
|
|
122
|
+
return `"${safeField.replace(/"/g, '""')}"`;
|
|
119
123
|
}
|
|
120
|
-
return
|
|
124
|
+
return safeField;
|
|
121
125
|
}
|
|
126
|
+
|
|
127
|
+
// src/utils/convert-table-to-csv.ts
|
|
122
128
|
function convertTableToCSV(table) {
|
|
123
|
-
const headerRow = table.columns.map(
|
|
124
|
-
const dataRows = table.rows.map((row) => row.map(
|
|
129
|
+
const headerRow = table.columns.map(escapeCsvField).join(",");
|
|
130
|
+
const dataRows = table.rows.map((row) => row.map(escapeCsvField).join(","));
|
|
125
131
|
return [headerRow, ...dataRows].join("\r\n");
|
|
126
132
|
}
|
|
127
133
|
// Annotate the CommonJS export names for ESM import in node:
|
|
128
134
|
0 && (module.exports = {
|
|
129
135
|
convertTableToCSV,
|
|
136
|
+
escapeCsvField,
|
|
130
137
|
markdownToPlainText,
|
|
131
138
|
mergeRefs,
|
|
132
139
|
parseMarkdownTable
|
package/dist/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/index.ts","../src/utils/markdown-to-plain-text.ts","../src/utils/merge-refs.ts","../src/utils/parse-markdown-table.ts","../src/utils/convert-table-to-csv.ts"],"sourcesContent":["export { markdownToPlainText } from \"./markdown-to-plain-text\";\nexport { mergeRefs } from \"./merge-refs\";\nexport { parseMarkdownTable } from \"./parse-markdown-table\";\nexport type { MarkdownTable } from \"./parse-markdown-table\";\nexport { convertTableToCSV } from \"./convert-table-to-csv\";\n","const PLACEHOLDER_PREFIX = \"\\u200B\\u200BIC\";\nconst PLACEHOLDER_SUFFIX = \"\\u200B\\u200B\";\nconst PLACEHOLDER_REGEX = new RegExp(`${PLACEHOLDER_PREFIX}(\\\\d+)${PLACEHOLDER_SUFFIX}`, \"g\");\n\n/**\n * Strips only inline markdown marks (bold, italic, strikethrough) from a string.\n * Does not touch block-level syntax (headings, blockquotes, horizontal rules, links, images)\n * so values like `> 100`, `# items`, or `---` are preserved as-is.\n * @param text - The text to strip inline marks from.\n * @returns The text with inline marks removed.\n */\nexport function stripInlineMarks(text: string): string {\n return (\n text\n // Bold + italic\n .replace(/\\*{3}(.+?)\\*{3}/g, \"$1\")\n // Bold\n .replace(/\\*{2}(.+?)\\*{2}/g, \"$1\")\n .replace(/_{2}(.+?)_{2}/g, \"$1\")\n // Italic\n .replace(/\\*(.+?)\\*/g, \"$1\")\n .replace(/_(.+?)_/g, \"$1\")\n // Strikethrough\n .replace(/~~(.+?)~~/g, \"$1\")\n );\n}\n\n/**\n * Converts a Markdown string to plain text by stripping all formatting syntax.\n *\n * Handles headings, bold/italic/strikethrough, links, images, blockquotes, code blocks,\n * inline code, tables, and horizontal rules. Inline code content is preserved literally\n * (formatting inside backticks is not stripped).\n *\n * @param markdown - The Markdown source string.\n * @returns A plain-text string with all Markdown syntax removed.\n */\nexport function markdownToPlainText(markdown: string): string {\n if (!markdown) return \"\";\n\n // Protect inline code content from bold/italic stripping by replacing with placeholders\n const inlineCodeSnippets: string[] = [];\n let result = markdown\n // HTML comments (e.g. <!-- table-title: ... -->), including multiline and --!> variants\n .replace(/^<!--[\\s\\S]*?--!?>\\n?/gm, \"\")\n // Code blocks (must come first)\n .replace(/```[\\s\\S]*?```/g, \"\")\n // Inline code → placeholder\n .replace(/`([^`]+)`/g, (_match, code: string) => {\n inlineCodeSnippets.push(code);\n return `${PLACEHOLDER_PREFIX}${inlineCodeSnippets.length - 1}${PLACEHOLDER_SUFFIX}`;\n })\n // Remove headings markers, keep text\n .replace(/^#{1,6}\\s+/gm, \"\")\n // Remove horizontal rules\n .replace(/^(?:---|\\*\\*\\*|___)\\s*$/gm, \"\");\n result = stripInlineMarks(result)\n // Images:  → alt (must come before links)\n .replace(/!\\[([^\\]]*)\\]\\([^)]+\\)/g, \"$1\")\n // Links: [text](url) → text\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, \"$1\")\n // Blockquote markers\n .replace(/^>\\s?/gm, \"\")\n // Table separator rows (|---|---|)\n .replace(/^\\|[-:\\s|]+\\|\\s*$/gm, \"\")\n // Table rows: | a | b | → a | b\n .replace(/^\\|\\s?/gm, \"\")\n .replace(/\\s?\\|$/gm, \"\")\n // Collapse multiple blank lines\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .trim();\n\n // Restore inline code content\n result = result.replace(PLACEHOLDER_REGEX, (_match, index: string) => inlineCodeSnippets[Number(index)]);\n\n return result;\n}\n","import type { Ref } from \"react\";\n\n/**\n * Combines multiple React refs into a single callback ref.\n * Useful when a component needs to forward its ref while also keeping a local ref.\n *\n * @param refs - Any number of React refs (callback refs, RefObjects, or `undefined`).\n * @returns A callback ref that updates all provided refs when the DOM node changes.\n */\nexport function mergeRefs<T>(...refs: (Ref<T> | undefined)[]): (node: T | null) => void {\n return (node) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n }\n };\n}\n","import { stripInlineMarks } from \"./markdown-to-plain-text\";\n\n/** Structured representation of a parsed markdown table. */\nexport interface MarkdownTable {\n /** Column header labels. */\n columns: string[];\n /** Data rows, each an array of cell values matching the column order. */\n rows: string[][];\n /** Optional title extracted from a `<!-- table-title: ... -->` comment above the table. */\n title?: string;\n}\n\n/**\n * Parses cells from a markdown table row, trimming whitespace and stripping leading/trailing pipes.\n * @param line - A single line of a markdown table.\n * @returns An array of trimmed cell values.\n */\nfunction parseCells(line: string): string[] {\n const trimmed = line.trim();\n const stripped = trimmed.startsWith(\"|\") ? trimmed.slice(1) : trimmed;\n const withoutTrailing = stripped.endsWith(\"|\") ? stripped.slice(0, -1) : stripped;\n return withoutTrailing.split(\"|\").map((cell) => cell.trim());\n}\n\n/**\n * Tests whether a line is a GFM table separator row (e.g. `| --- | --- |`).\n * @param line - A single line to test.\n * @returns `true` if the line matches the separator pattern.\n */\nfunction isSeparatorRow(line: string): boolean {\n const cells = parseCells(line);\n return cells.length > 0 && cells.every((cell) => /^:?-{1,}:?$/.test(cell));\n}\n\n/**\n * Tests whether a line looks like a markdown table row (contains at least one pipe).\n * @param line - A single line to test.\n * @returns `true` if the line contains a pipe character.\n */\nfunction isTableRow(line: string): boolean {\n return line.includes(\"|\");\n}\n\nconst TABLE_TITLE_PREFIX = \"<!-- table-title:\";\nconst TABLE_TITLE_SUFFIX = \"-->\";\n\n/**\n * Extracts a table title from a `<!-- table-title: ... -->` HTML comment.\n * Uses string methods instead of regex to avoid ReDoS on untrusted input.\n * @param line - A single line to test.\n * @returns The title string, or `undefined` if the line is not a title comment.\n */\nfunction extractTableTitle(line: string): string | undefined {\n const trimmed = line.trim();\n if (!trimmed.startsWith(TABLE_TITLE_PREFIX) || !trimmed.endsWith(TABLE_TITLE_SUFFIX)) {\n return undefined;\n }\n return trimmed.slice(TABLE_TITLE_PREFIX.length, -TABLE_TITLE_SUFFIX.length).trim() || undefined;\n}\n\n/**\n * Extracts the Nth GFM markdown table from a string.\n * @param markdown - The markdown content to parse.\n * @param tableIndex - Zero-based index of the table to extract.\n * @returns The parsed table, or `null` if no table exists at the given index.\n */\nexport function parseMarkdownTable(markdown: string, tableIndex = 0): MarkdownTable | null {\n const lines = markdown.split(\"\\n\");\n let tableCount = 0;\n\n for (let i = 0; i < lines.length - 1; i++) {\n const headerLine = lines[i];\n const separatorLine = lines[i + 1];\n\n if (!isTableRow(headerLine) || !isSeparatorRow(separatorLine)) {\n continue;\n }\n\n if (tableCount === tableIndex) {\n const columns = parseCells(headerLine).map(stripInlineMarks);\n const rows: string[][] = [];\n const title = i > 0 ? extractTableTitle(lines[i - 1]) : undefined;\n\n for (let j = i + 2; j < lines.length; j++) {\n if (!isTableRow(lines[j]) || isSeparatorRow(lines[j])) {\n break;\n }\n const trimmedLine = lines[j].trim();\n if (trimmedLine === \"\") {\n break;\n }\n rows.push(parseCells(lines[j]).map(stripInlineMarks));\n }\n\n return { columns, rows, ...(title ? { title } : {}) };\n }\n\n tableCount++;\n }\n\n return null;\n}\n","import type { MarkdownTable } from \"./parse-markdown-table\";\n\n/**\n * Escapes and optionally quotes a CSV field per RFC 4180.\n * Fields containing commas, double quotes, or newlines are wrapped in double quotes.\n * Existing double quotes are escaped by doubling them.\n * @param field - The raw field value.\n * @returns The escaped/quoted field string.\n */\nfunction escapeField(field: string): string {\n if (field.includes(\",\") || field.includes('\"') || field.includes(\"\\n\") || field.includes(\"\\r\")) {\n return `\"${field.replace(/\"/g, '\"\"')}\"`;\n }\n return field;\n}\n\n/**\n * Converts a parsed markdown table to a CSV string (RFC 4180).\n * Fields containing commas, double quotes, or newlines are quoted.\n * @param table - The structured table data to convert.\n * @returns A CSV-formatted string with CRLF line endings.\n */\nexport function convertTableToCSV(table: MarkdownTable): string {\n const headerRow = table.columns.map(escapeField).join(\",\");\n const dataRows = table.rows.map((row) => row.map(escapeField).join(\",\"));\n return [headerRow, ...dataRows].join(\"\\r\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;A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,eAAS,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACzC,YAAI,CAAC,WAAW,MAAM,CAAC,CAAC,KAAK,eAAe,MAAM,CAAC,CAAC,GAAG;AACrD;AAAA,QACF;AACA,cAAM,cAAc,MAAM,CAAC,EAAE,KAAK;AAClC,YAAI,gBAAgB,IAAI;AACtB;AAAA,QACF;AACA,aAAK,KAAK,WAAW,MAAM,CAAC,CAAC,EAAE,IAAI,gBAAgB,CAAC;AAAA,MACtD;AAEA,aAAO,EAAE,SAAS,MAAM,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC,EAAG;AAAA,IACtD;AAEA;AAAA,EACF;AAEA,SAAO;AACT;;;AC5FA,SAAS,YAAY,OAAuB;AAC1C,MAAI,MAAM,SAAS,GAAG,KAAK,MAAM,SAAS,GAAG,KAAK,MAAM,SAAS,IAAI,KAAK,MAAM,SAAS,IAAI,GAAG;AAC9F,WAAO,IAAI,MAAM,QAAQ,MAAM,IAAI,CAAC;AAAA,EACtC;AACA,SAAO;AACT;AAQO,SAAS,kBAAkB,OAA8B;AAC9D,QAAM,YAAY,MAAM,QAAQ,IAAI,WAAW,EAAE,KAAK,GAAG;AACzD,QAAM,WAAW,MAAM,KAAK,IAAI,CAAC,QAAQ,IAAI,IAAI,WAAW,EAAE,KAAK,GAAG,CAAC;AACvE,SAAO,CAAC,WAAW,GAAG,QAAQ,EAAE,KAAK,MAAM;AAC7C;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/index.ts","../src/utils/markdown-to-plain-text.ts","../src/utils/merge-refs.ts","../src/utils/parse-markdown-table.ts","../src/utils/escape-csv-field.ts","../src/utils/convert-table-to-csv.ts"],"sourcesContent":["export { markdownToPlainText } from \"./markdown-to-plain-text\";\nexport { mergeRefs } from \"./merge-refs\";\nexport { parseMarkdownTable } from \"./parse-markdown-table\";\nexport type { MarkdownTable } from \"./parse-markdown-table\";\nexport { convertTableToCSV } from \"./convert-table-to-csv\";\nexport { escapeCsvField } from \"./escape-csv-field\";\n","const PLACEHOLDER_PREFIX = \"\\u200B\\u200BIC\";\nconst PLACEHOLDER_SUFFIX = \"\\u200B\\u200B\";\nconst PLACEHOLDER_REGEX = new RegExp(`${PLACEHOLDER_PREFIX}(\\\\d+)${PLACEHOLDER_SUFFIX}`, \"g\");\n\n/**\n * Strips only inline markdown marks (bold, italic, strikethrough) from a string.\n * Does not touch block-level syntax (headings, blockquotes, horizontal rules, links, images)\n * so values like `> 100`, `# items`, or `---` are preserved as-is.\n * @param text - The text to strip inline marks from.\n * @returns The text with inline marks removed.\n */\nexport function stripInlineMarks(text: string): string {\n return (\n text\n // Bold + italic\n .replace(/\\*{3}(.+?)\\*{3}/g, \"$1\")\n // Bold\n .replace(/\\*{2}(.+?)\\*{2}/g, \"$1\")\n .replace(/_{2}(.+?)_{2}/g, \"$1\")\n // Italic\n .replace(/\\*(.+?)\\*/g, \"$1\")\n .replace(/_(.+?)_/g, \"$1\")\n // Strikethrough\n .replace(/~~(.+?)~~/g, \"$1\")\n );\n}\n\n/**\n * Converts a Markdown string to plain text by stripping all formatting syntax.\n *\n * Handles headings, bold/italic/strikethrough, links, images, blockquotes, code blocks,\n * inline code, tables, and horizontal rules. Inline code content is preserved literally\n * (formatting inside backticks is not stripped).\n *\n * @param markdown - The Markdown source string.\n * @returns A plain-text string with all Markdown syntax removed.\n */\nexport function markdownToPlainText(markdown: string): string {\n if (!markdown) return \"\";\n\n // Protect inline code content from bold/italic stripping by replacing with placeholders\n const inlineCodeSnippets: string[] = [];\n let result = markdown\n // HTML comments (e.g. <!-- table-title: ... -->), including multiline and --!> variants\n .replace(/^<!--[\\s\\S]*?--!?>\\n?/gm, \"\")\n // Code blocks (must come first)\n .replace(/```[\\s\\S]*?```/g, \"\")\n // Inline code → placeholder\n .replace(/`([^`]+)`/g, (_match, code: string) => {\n inlineCodeSnippets.push(code);\n return `${PLACEHOLDER_PREFIX}${inlineCodeSnippets.length - 1}${PLACEHOLDER_SUFFIX}`;\n })\n // Remove headings markers, keep text\n .replace(/^#{1,6}\\s+/gm, \"\")\n // Remove horizontal rules\n .replace(/^(?:---|\\*\\*\\*|___)\\s*$/gm, \"\");\n result = stripInlineMarks(result)\n // Images:  → alt (must come before links)\n .replace(/!\\[([^\\]]*)\\]\\([^)]+\\)/g, \"$1\")\n // Links: [text](url) → text\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, \"$1\")\n // Blockquote markers\n .replace(/^>\\s?/gm, \"\")\n // Table separator rows (|---|---|)\n .replace(/^\\|[-:\\s|]+\\|\\s*$/gm, \"\")\n // Table rows: | a | b | → a | b\n .replace(/^\\|\\s?/gm, \"\")\n .replace(/\\s?\\|$/gm, \"\")\n // Collapse multiple blank lines\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .trim();\n\n // Restore inline code content\n result = result.replace(PLACEHOLDER_REGEX, (_match, index: string) => inlineCodeSnippets[Number(index)]);\n\n return result;\n}\n","import type { Ref } from \"react\";\n\n/**\n * Combines multiple React refs into a single callback ref.\n * Useful when a component needs to forward its ref while also keeping a local ref.\n *\n * @param refs - Any number of React refs (callback refs, RefObjects, or `undefined`).\n * @returns A callback ref that updates all provided refs when the DOM node changes.\n */\nexport function mergeRefs<T>(...refs: (Ref<T> | undefined)[]): (node: T | null) => void {\n return (node) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n }\n };\n}\n","import { stripInlineMarks } from \"./markdown-to-plain-text\";\n\n/** Structured representation of a parsed markdown table. */\nexport interface MarkdownTable {\n /** Column header labels. */\n columns: string[];\n /** Data rows, each an array of cell values matching the column order. */\n rows: string[][];\n /** Optional title extracted from a `<!-- table-title: ... -->` comment above the table. */\n title?: string;\n}\n\n/**\n * Parses cells from a markdown table row, trimming whitespace and stripping leading/trailing pipes.\n * @param line - A single line of a markdown table.\n * @returns An array of trimmed cell values.\n */\nfunction parseCells(line: string): string[] {\n const trimmed = line.trim();\n const stripped = trimmed.startsWith(\"|\") ? trimmed.slice(1) : trimmed;\n const withoutTrailing = stripped.endsWith(\"|\") ? stripped.slice(0, -1) : stripped;\n return withoutTrailing.split(\"|\").map((cell) => cell.trim());\n}\n\n/**\n * Tests whether a line is a GFM table separator row (e.g. `| --- | --- |`).\n * @param line - A single line to test.\n * @returns `true` if the line matches the separator pattern.\n */\nfunction isSeparatorRow(line: string): boolean {\n const cells = parseCells(line);\n return cells.length > 0 && cells.every((cell) => /^:?-{1,}:?$/.test(cell));\n}\n\n/**\n * Tests whether a line looks like a markdown table row (contains at least one pipe).\n * @param line - A single line to test.\n * @returns `true` if the line contains a pipe character.\n */\nfunction isTableRow(line: string): boolean {\n return line.includes(\"|\");\n}\n\nconst TABLE_TITLE_PREFIX = \"<!-- table-title:\";\nconst TABLE_TITLE_SUFFIX = \"-->\";\n\n/**\n * Extracts a table title from a `<!-- table-title: ... -->` HTML comment.\n * Uses string methods instead of regex to avoid ReDoS on untrusted input.\n * @param line - A single line to test.\n * @returns The title string, or `undefined` if the line is not a title comment.\n */\nfunction extractTableTitle(line: string): string | undefined {\n const trimmed = line.trim();\n if (!trimmed.startsWith(TABLE_TITLE_PREFIX) || !trimmed.endsWith(TABLE_TITLE_SUFFIX)) {\n return undefined;\n }\n return trimmed.slice(TABLE_TITLE_PREFIX.length, -TABLE_TITLE_SUFFIX.length).trim() || undefined;\n}\n\n/**\n * Extracts the Nth GFM markdown table from a string.\n * @param markdown - The markdown content to parse.\n * @param tableIndex - Zero-based index of the table to extract.\n * @returns The parsed table, or `null` if no table exists at the given index.\n */\nexport function parseMarkdownTable(markdown: string, tableIndex = 0): MarkdownTable | null {\n const lines = markdown.split(\"\\n\");\n let tableCount = 0;\n\n for (let i = 0; i < lines.length - 1; i++) {\n const headerLine = lines[i];\n const separatorLine = lines[i + 1];\n\n if (!isTableRow(headerLine) || !isSeparatorRow(separatorLine)) {\n continue;\n }\n\n if (tableCount === tableIndex) {\n const columns = parseCells(headerLine).map(stripInlineMarks);\n const rows: string[][] = [];\n const title = i > 0 ? extractTableTitle(lines[i - 1]) : undefined;\n\n for (let j = i + 2; j < lines.length; j++) {\n if (!isTableRow(lines[j]) || isSeparatorRow(lines[j])) {\n break;\n }\n const trimmedLine = lines[j].trim();\n if (trimmedLine === \"\") {\n break;\n }\n rows.push(parseCells(lines[j]).map(stripInlineMarks));\n }\n\n return { columns, rows, ...(title ? { title } : {}) };\n }\n\n tableCount++;\n }\n\n return null;\n}\n","/**\n * Characters that trigger spreadsheet-formula evaluation when present at the start of a CSV cell.\n * Excel, Google Sheets, and Numbers all treat a field beginning with one of these as a formula\n * (e.g. `=HYPERLINK(...)`, `+1+1`, `@SUM(...)`), so a field exfiltrated from user-controlled\n * data can run arbitrary expressions in the spreadsheet on open.\n *\n * Note: `-` is intentionally excluded. While `+` and `-` are listed in some CSV injection docs,\n * `-42` is a valid negative number and Excel/Sheets do NOT evaluate it as a formula. Including `-`\n * would corrupt all negative-number cells. The actual risk from `-` is extremely low in practice.\n */\nconst FORMULA_TRIGGERS = new Set([\"=\", \"+\", \"@\", \"\\t\", \"\\r\"]);\n\n/**\n * Escapes and optionally quotes a CSV field per RFC 4180, with OWASP-recommended formula-injection\n * neutralisation for fields beginning with a trigger character.\n *\n * - Fields starting with `=`, `+`, `@`, `\\t`, or `\\r` are prefixed with a tab so the spreadsheet\n * renders them as literal text instead of evaluating them as a formula. The tab itself disappears\n * in the rendered cell.\n * - Fields containing commas, double quotes, newlines, or a leading tab (from formula neutralisation)\n * are wrapped in double quotes per RFC 4180. The double-quote wrapping ensures the tab prefix is\n * preserved in parsers that would otherwise strip leading whitespace.\n * - Existing double quotes are escaped by doubling them.\n *\n * @param field - The raw field value.\n * @returns The escaped/quoted field string.\n */\nexport function escapeCsvField(field: string): string {\n const needsNeutralise = field.length > 0 && FORMULA_TRIGGERS.has(field[0]);\n const safeField = needsNeutralise ? `\\t${field}` : field;\n if (\n needsNeutralise ||\n safeField.includes(\",\") ||\n safeField.includes('\"') ||\n safeField.includes(\"\\n\") ||\n safeField.includes(\"\\r\")\n ) {\n return `\"${safeField.replace(/\"/g, '\"\"')}\"`;\n }\n return safeField;\n}\n","import { escapeCsvField } from \"./escape-csv-field\";\nimport type { MarkdownTable } from \"./parse-markdown-table\";\n\n/**\n * Converts a parsed markdown table to a CSV string (RFC 4180).\n * Fields containing commas, double quotes, or newlines are quoted.\n * @param table - The structured table data to convert.\n * @returns A CSV-formatted string with CRLF line endings.\n */\nexport function convertTableToCSV(table: MarkdownTable): string {\n const headerRow = table.columns.map(escapeCsvField).join(\",\");\n const dataRows = table.rows.map((row) => row.map(escapeCsvField).join(\",\"));\n return [headerRow, ...dataRows].join(\"\\r\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAC3B,IAAM,oBAAoB,IAAI,OAAO,GAAG,kBAAkB,SAAS,kBAAkB,IAAI,GAAG;AASrF,SAAS,iBAAiB,MAAsB;AACrD,SACE,KAEG,QAAQ,oBAAoB,IAAI,EAEhC,QAAQ,oBAAoB,IAAI,EAChC,QAAQ,kBAAkB,IAAI,EAE9B,QAAQ,cAAc,IAAI,EAC1B,QAAQ,YAAY,IAAI,EAExB,QAAQ,cAAc,IAAI;AAEjC;AAYO,SAAS,oBAAoB,UAA0B;AAC5D,MAAI,CAAC,SAAU,QAAO;AAGtB,QAAM,qBAA+B,CAAC;AACtC,MAAI,SAAS,SAEV,QAAQ,2BAA2B,EAAE,EAErC,QAAQ,mBAAmB,EAAE,EAE7B,QAAQ,cAAc,CAAC,QAAQ,SAAiB;AAC/C,uBAAmB,KAAK,IAAI;AAC5B,WAAO,GAAG,kBAAkB,GAAG,mBAAmB,SAAS,CAAC,GAAG,kBAAkB;AAAA,EACnF,CAAC,EAEA,QAAQ,gBAAgB,EAAE,EAE1B,QAAQ,6BAA6B,EAAE;AAC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MACE,mBACA,UAAU,SAAS,GAAG,KACtB,UAAU,SAAS,GAAG,KACtB,UAAU,SAAS,IAAI,KACvB,UAAU,SAAS,IAAI,GACvB;AACA,WAAO,IAAI,UAAU,QAAQ,MAAM,IAAI,CAAC;AAAA,EAC1C;AACA,SAAO;AACT;;;AC/BO,SAAS,kBAAkB,OAA8B;AAC9D,QAAM,YAAY,MAAM,QAAQ,IAAI,cAAc,EAAE,KAAK,GAAG;AAC5D,QAAM,WAAW,MAAM,KAAK,IAAI,CAAC,QAAQ,IAAI,IAAI,cAAc,EAAE,KAAK,GAAG,CAAC;AAC1E,SAAO,CAAC,WAAW,GAAG,QAAQ,EAAE,KAAK,MAAM;AAC7C;","names":[]}
|
package/dist/utils.d.cts
CHANGED
|
@@ -46,4 +46,21 @@ declare function parseMarkdownTable(markdown: string, tableIndex?: number): Mark
|
|
|
46
46
|
*/
|
|
47
47
|
declare function convertTableToCSV(table: MarkdownTable): string;
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Escapes and optionally quotes a CSV field per RFC 4180, with OWASP-recommended formula-injection
|
|
51
|
+
* neutralisation for fields beginning with a trigger character.
|
|
52
|
+
*
|
|
53
|
+
* - Fields starting with `=`, `+`, `@`, `\t`, or `\r` are prefixed with a tab so the spreadsheet
|
|
54
|
+
* renders them as literal text instead of evaluating them as a formula. The tab itself disappears
|
|
55
|
+
* in the rendered cell.
|
|
56
|
+
* - Fields containing commas, double quotes, newlines, or a leading tab (from formula neutralisation)
|
|
57
|
+
* are wrapped in double quotes per RFC 4180. The double-quote wrapping ensures the tab prefix is
|
|
58
|
+
* preserved in parsers that would otherwise strip leading whitespace.
|
|
59
|
+
* - Existing double quotes are escaped by doubling them.
|
|
60
|
+
*
|
|
61
|
+
* @param field - The raw field value.
|
|
62
|
+
* @returns The escaped/quoted field string.
|
|
63
|
+
*/
|
|
64
|
+
declare function escapeCsvField(field: string): string;
|
|
65
|
+
|
|
66
|
+
export { type MarkdownTable, convertTableToCSV, escapeCsvField, markdownToPlainText, mergeRefs, parseMarkdownTable };
|
package/dist/utils.d.ts
CHANGED
|
@@ -46,4 +46,21 @@ declare function parseMarkdownTable(markdown: string, tableIndex?: number): Mark
|
|
|
46
46
|
*/
|
|
47
47
|
declare function convertTableToCSV(table: MarkdownTable): string;
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Escapes and optionally quotes a CSV field per RFC 4180, with OWASP-recommended formula-injection
|
|
51
|
+
* neutralisation for fields beginning with a trigger character.
|
|
52
|
+
*
|
|
53
|
+
* - Fields starting with `=`, `+`, `@`, `\t`, or `\r` are prefixed with a tab so the spreadsheet
|
|
54
|
+
* renders them as literal text instead of evaluating them as a formula. The tab itself disappears
|
|
55
|
+
* in the rendered cell.
|
|
56
|
+
* - Fields containing commas, double quotes, newlines, or a leading tab (from formula neutralisation)
|
|
57
|
+
* are wrapped in double quotes per RFC 4180. The double-quote wrapping ensures the tab prefix is
|
|
58
|
+
* preserved in parsers that would otherwise strip leading whitespace.
|
|
59
|
+
* - Existing double quotes are escaped by doubling them.
|
|
60
|
+
*
|
|
61
|
+
* @param field - The raw field value.
|
|
62
|
+
* @returns The escaped/quoted field string.
|
|
63
|
+
*/
|
|
64
|
+
declare function escapeCsvField(field: string): string;
|
|
65
|
+
|
|
66
|
+
export { type MarkdownTable, convertTableToCSV, escapeCsvField, markdownToPlainText, mergeRefs, parseMarkdownTable };
|
package/dist/utils.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
convertTableToCSV,
|
|
3
|
+
escapeCsvField,
|
|
3
4
|
parseMarkdownTable
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
markdownToPlainText
|
|
7
|
-
} from "./chunk-NMKKU2UG.js";
|
|
5
|
+
} from "./chunk-JJUIBBBU.js";
|
|
8
6
|
import {
|
|
9
7
|
mergeRefs
|
|
10
8
|
} from "./chunk-KNYB3RL7.js";
|
|
9
|
+
import {
|
|
10
|
+
markdownToPlainText
|
|
11
|
+
} from "./chunk-NMKKU2UG.js";
|
|
11
12
|
import "./chunk-5WRI5ZAA.js";
|
|
12
13
|
export {
|
|
13
14
|
convertTableToCSV,
|
|
15
|
+
escapeCsvField,
|
|
14
16
|
markdownToPlainText,
|
|
15
17
|
mergeRefs,
|
|
16
18
|
parseMarkdownTable
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapesos/clay",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"main": "./dist/index.cjs",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"devDependencies": {
|
|
@@ -13,11 +13,15 @@
|
|
|
13
13
|
"@storybook/react": "^10.2.13",
|
|
14
14
|
"@storybook/react-vite": "^10.2.13",
|
|
15
15
|
"@tabler/icons-react": "^3.37.1",
|
|
16
|
+
"@tailwindcss/cli": "^4.2.4",
|
|
17
|
+
"@tailwindcss/postcss": "^4.2.4",
|
|
18
|
+
"@tailwindcss/vite": "^4.2.4",
|
|
16
19
|
"@testing-library/dom": "^10.4.1",
|
|
17
20
|
"@testing-library/jest-dom": "^6.9.1",
|
|
18
21
|
"@testing-library/react": "^16.3.2",
|
|
19
22
|
"@testing-library/user-event": "^14.6.1",
|
|
20
23
|
"@types/node": "^25.3.2",
|
|
24
|
+
"@types/papaparse": "^5.5.2",
|
|
21
25
|
"@types/react": "^19.2.14",
|
|
22
26
|
"@types/react-dom": "^19.2.3",
|
|
23
27
|
"@vitejs/plugin-react": "^5.1.4",
|
|
@@ -29,9 +33,12 @@
|
|
|
29
33
|
"lefthook": "^2.1.1",
|
|
30
34
|
"react": "^19.2.4",
|
|
31
35
|
"react-dom": "^19.2.4",
|
|
36
|
+
"recharts": "^3.8.1",
|
|
32
37
|
"storybook": "^10.2.13",
|
|
33
38
|
"styled-components": "^6.3.11",
|
|
39
|
+
"tailwindcss": "^4",
|
|
34
40
|
"tsup": "~8.5.1",
|
|
41
|
+
"tw-animate-css": "^1.4.0",
|
|
35
42
|
"typescript": "~5.9.3",
|
|
36
43
|
"typescript-eslint": "^8.56.1",
|
|
37
44
|
"vite": "^7.3.1",
|
|
@@ -40,8 +47,14 @@
|
|
|
40
47
|
"peerDependencies": {
|
|
41
48
|
"react": "^17 || ^18 || ^19",
|
|
42
49
|
"react-dom": "^17 || ^18 || ^19",
|
|
50
|
+
"recharts": "^3",
|
|
43
51
|
"styled-components": "^5 || ^6"
|
|
44
52
|
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"recharts": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
45
58
|
"exports": {
|
|
46
59
|
".": {
|
|
47
60
|
"types": "./dist/index.d.ts",
|
|
@@ -63,6 +76,22 @@
|
|
|
63
76
|
"import": "./dist/blocks.js",
|
|
64
77
|
"require": "./dist/blocks.cjs"
|
|
65
78
|
},
|
|
79
|
+
"./blocks/styles.css": "./dist/blocks.css",
|
|
80
|
+
"./artifacts": {
|
|
81
|
+
"types": "./dist/artifacts.d.ts",
|
|
82
|
+
"import": "./dist/artifacts.js",
|
|
83
|
+
"require": "./dist/artifacts.cjs"
|
|
84
|
+
},
|
|
85
|
+
"./chart": {
|
|
86
|
+
"types": "./dist/chart.d.ts",
|
|
87
|
+
"import": "./dist/chart.js",
|
|
88
|
+
"require": "./dist/chart.cjs"
|
|
89
|
+
},
|
|
90
|
+
"./table": {
|
|
91
|
+
"types": "./dist/table.d.ts",
|
|
92
|
+
"import": "./dist/table.js",
|
|
93
|
+
"require": "./dist/table.cjs"
|
|
94
|
+
},
|
|
66
95
|
"./icon": {
|
|
67
96
|
"types": "./dist/icon.d.ts",
|
|
68
97
|
"import": "./dist/icon.js",
|
|
@@ -112,7 +141,9 @@
|
|
|
112
141
|
"registry": "https://registry.npmjs.org/"
|
|
113
142
|
},
|
|
114
143
|
"scripts": {
|
|
115
|
-
"build": "tsup",
|
|
144
|
+
"build": "bun run gen:theme && tsup && bun run build:css",
|
|
145
|
+
"build:css": "tailwindcss -i src/styles/tailwind.css -o dist/blocks.css --minify",
|
|
146
|
+
"gen:theme": "bun run scripts/generate-theme-tokens.ts",
|
|
116
147
|
"dev": "tsup --watch",
|
|
117
148
|
"storybook": "storybook dev -p 6006",
|
|
118
149
|
"build-storybook": "storybook build",
|
|
@@ -128,13 +159,19 @@
|
|
|
128
159
|
"check": "eslint . && tsc --noEmit && vitest run",
|
|
129
160
|
"prepare": "lefthook install"
|
|
130
161
|
},
|
|
131
|
-
"sideEffects":
|
|
162
|
+
"sideEffects": [
|
|
163
|
+
"**/*.css"
|
|
164
|
+
],
|
|
132
165
|
"type": "module",
|
|
133
166
|
"types": "./dist/index.d.ts",
|
|
134
167
|
"dependencies": {
|
|
168
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
169
|
+
"clsx": "^2.1.1",
|
|
135
170
|
"lottie-react": "^2.4.1",
|
|
171
|
+
"papaparse": "^5.5.3",
|
|
136
172
|
"react-markdown": "^8.0.7",
|
|
137
173
|
"remark-breaks": "^4.0.0",
|
|
138
|
-
"remark-gfm": "^3.0.1"
|
|
174
|
+
"remark-gfm": "^3.0.1",
|
|
175
|
+
"tailwind-merge": "^3.5.0"
|
|
139
176
|
}
|
|
140
177
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/parse-markdown-table.ts","../src/utils/convert-table-to-csv.ts"],"sourcesContent":["import { stripInlineMarks } from \"./markdown-to-plain-text\";\n\n/** Structured representation of a parsed markdown table. */\nexport interface MarkdownTable {\n /** Column header labels. */\n columns: string[];\n /** Data rows, each an array of cell values matching the column order. */\n rows: string[][];\n /** Optional title extracted from a `<!-- table-title: ... -->` comment above the table. */\n title?: string;\n}\n\n/**\n * Parses cells from a markdown table row, trimming whitespace and stripping leading/trailing pipes.\n * @param line - A single line of a markdown table.\n * @returns An array of trimmed cell values.\n */\nfunction parseCells(line: string): string[] {\n const trimmed = line.trim();\n const stripped = trimmed.startsWith(\"|\") ? trimmed.slice(1) : trimmed;\n const withoutTrailing = stripped.endsWith(\"|\") ? stripped.slice(0, -1) : stripped;\n return withoutTrailing.split(\"|\").map((cell) => cell.trim());\n}\n\n/**\n * Tests whether a line is a GFM table separator row (e.g. `| --- | --- |`).\n * @param line - A single line to test.\n * @returns `true` if the line matches the separator pattern.\n */\nfunction isSeparatorRow(line: string): boolean {\n const cells = parseCells(line);\n return cells.length > 0 && cells.every((cell) => /^:?-{1,}:?$/.test(cell));\n}\n\n/**\n * Tests whether a line looks like a markdown table row (contains at least one pipe).\n * @param line - A single line to test.\n * @returns `true` if the line contains a pipe character.\n */\nfunction isTableRow(line: string): boolean {\n return line.includes(\"|\");\n}\n\nconst TABLE_TITLE_PREFIX = \"<!-- table-title:\";\nconst TABLE_TITLE_SUFFIX = \"-->\";\n\n/**\n * Extracts a table title from a `<!-- table-title: ... -->` HTML comment.\n * Uses string methods instead of regex to avoid ReDoS on untrusted input.\n * @param line - A single line to test.\n * @returns The title string, or `undefined` if the line is not a title comment.\n */\nfunction extractTableTitle(line: string): string | undefined {\n const trimmed = line.trim();\n if (!trimmed.startsWith(TABLE_TITLE_PREFIX) || !trimmed.endsWith(TABLE_TITLE_SUFFIX)) {\n return undefined;\n }\n return trimmed.slice(TABLE_TITLE_PREFIX.length, -TABLE_TITLE_SUFFIX.length).trim() || undefined;\n}\n\n/**\n * Extracts the Nth GFM markdown table from a string.\n * @param markdown - The markdown content to parse.\n * @param tableIndex - Zero-based index of the table to extract.\n * @returns The parsed table, or `null` if no table exists at the given index.\n */\nexport function parseMarkdownTable(markdown: string, tableIndex = 0): MarkdownTable | null {\n const lines = markdown.split(\"\\n\");\n let tableCount = 0;\n\n for (let i = 0; i < lines.length - 1; i++) {\n const headerLine = lines[i];\n const separatorLine = lines[i + 1];\n\n if (!isTableRow(headerLine) || !isSeparatorRow(separatorLine)) {\n continue;\n }\n\n if (tableCount === tableIndex) {\n const columns = parseCells(headerLine).map(stripInlineMarks);\n const rows: string[][] = [];\n const title = i > 0 ? extractTableTitle(lines[i - 1]) : undefined;\n\n for (let j = i + 2; j < lines.length; j++) {\n if (!isTableRow(lines[j]) || isSeparatorRow(lines[j])) {\n break;\n }\n const trimmedLine = lines[j].trim();\n if (trimmedLine === \"\") {\n break;\n }\n rows.push(parseCells(lines[j]).map(stripInlineMarks));\n }\n\n return { columns, rows, ...(title ? { title } : {}) };\n }\n\n tableCount++;\n }\n\n return null;\n}\n","import type { MarkdownTable } from \"./parse-markdown-table\";\n\n/**\n * Escapes and optionally quotes a CSV field per RFC 4180.\n * Fields containing commas, double quotes, or newlines are wrapped in double quotes.\n * Existing double quotes are escaped by doubling them.\n * @param field - The raw field value.\n * @returns The escaped/quoted field string.\n */\nfunction escapeField(field: string): string {\n if (field.includes(\",\") || field.includes('\"') || field.includes(\"\\n\") || field.includes(\"\\r\")) {\n return `\"${field.replace(/\"/g, '\"\"')}\"`;\n }\n return field;\n}\n\n/**\n * Converts a parsed markdown table to a CSV string (RFC 4180).\n * Fields containing commas, double quotes, or newlines are quoted.\n * @param table - The structured table data to convert.\n * @returns A CSV-formatted string with CRLF line endings.\n */\nexport function convertTableToCSV(table: MarkdownTable): string {\n const headerRow = table.columns.map(escapeField).join(\",\");\n const dataRows = table.rows.map((row) => row.map(escapeField).join(\",\"));\n return [headerRow, ...dataRows].join(\"\\r\\n\");\n}\n"],"mappings":";;;;;AAiBA,SAAS,WAAW,MAAwB;AAC1C,QAAM,UAAU,KAAK,KAAK;AAC1B,QAAM,WAAW,QAAQ,WAAW,GAAG,IAAI,QAAQ,MAAM,CAAC,IAAI;AAC9D,QAAM,kBAAkB,SAAS,SAAS,GAAG,IAAI,SAAS,MAAM,GAAG,EAAE,IAAI;AACzE,SAAO,gBAAgB,MAAM,GAAG,EAAE,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC;AAC7D;AAOA,SAAS,eAAe,MAAuB;AAC7C,QA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,CAAC;AAAA,MACtD;AAEA,aAAO,EAAE,SAAS,MAAM,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC,EAAG;AAAA,IACtD;AAEA;AAAA,EACF;AAEA,SAAO;AACT;;;AC5FA,SAAS,YAAY,OAAuB;AAC1C,MAAI,MAAM,SAAS,GAAG,KAAK,MAAM,SAAS,GAAG,KAAK,MAAM,SAAS,IAAI,KAAK,MAAM,SAAS,IAAI,GAAG;AAC9F,WAAO,IAAI,MAAM,QAAQ,MAAM,IAAI,CAAC;AAAA,EACtC;AACA,SAAO;AACT;AAQO,SAAS,kBAAkB,OAA8B;AAC9D,QAAM,YAAY,MAAM,QAAQ,IAAI,WAAW,EAAE,KAAK,GAAG;AACzD,QAAM,WAAW,MAAM,KAAK,IAAI,CAAC,QAAQ,IAAI,IAAI,WAAW,EAAE,KAAK,GAAG,CAAC;AACvE,SAAO,CAAC,WAAW,GAAG,QAAQ,EAAE,KAAK,MAAM;AAC7C;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/icon-button/icon-button-styles.ts","../src/components/icon-button/icon-button.tsx"],"sourcesContent":["import styled from \"styled-components\";\n\nimport { colors } from \"../../tokens/colors\";\nimport type { IconButtonSize, IconButtonVariant } from \"./types\";\n\nconst PADDING: Record<IconButtonVariant, Record<IconButtonSize, string>> = {\n short: {\n small: \"4px\",\n medium: \"6px\",\n },\n long: {\n small: \"4px 6px\",\n medium: \"6px 10px\",\n },\n};\n\nconst BORDER_RADIUS: Record<IconButtonSize, number> = {\n small: 6,\n medium: 10,\n};\n\nexport const Button = styled.button<{\n $size: IconButtonSize;\n $variant: IconButtonVariant;\n $isSelected: boolean;\n}>`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: ${({ $size, $variant }) => PADDING[$variant][$size]};\n border: none;\n border-radius: ${({ $size }) => BORDER_RADIUS[$size]}px;\n background: ${({ $isSelected }) => ($isSelected ? colors[\"brown-40\"] : \"transparent\")};\n color: ${colors[\"brown-100\"]};\n cursor: pointer;\n transition: background-color 100ms ease;\n\n &:hover {\n background: ${({ $isSelected }) => ($isSelected ? colors[\"brown-40\"] : colors[\"brown-20\"])};\n }\n\n &:active {\n background: ${colors[\"brown-40\"]};\n }\n\n &:disabled {\n color: ${colors[\"brown-50\"]};\n background: transparent;\n cursor: not-allowed;\n }\n`;\n","import { Icon } from \"../icon/icon\";\nimport { Button } from \"./icon-button-styles\";\nimport type { IconButtonProps, IconButtonSize } from \"./types\";\n\nconst ICON_SIZE_BY_BUTTON_SIZE: Record<IconButtonSize, number> = {\n small: 16,\n medium: 20,\n};\n\nexport function IconButton({\n icon,\n size = \"small\",\n variant = \"short\",\n isSelected = false,\n disabled = false,\n onClick,\n className,\n id,\n as,\n \"aria-label\": ariaLabel,\n}: IconButtonProps): React.ReactNode {\n return (\n <Button\n className={className}\n id={id}\n as={as}\n $size={size}\n $variant={variant}\n $isSelected={isSelected}\n disabled={disabled}\n onClick={disabled ? undefined : onClick}\n aria-label={ariaLabel}\n >\n <Icon icon={icon} size={ICON_SIZE_BY_BUTTON_SIZE[size]} />\n </Button>\n );\n}\n"],"mappings":";;;;;;;;AAAA,OAAO,YAAY;AAKnB,IAAM,UAAqE;AAAA,EACzE,OAAO;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AACF;AAEA,IAAM,gBAAgD;AAAA,EACpD,OAAO;AAAA,EACP,QAAQ;AACV;AAEO,IAAM,SAAS,OAAO;AAAA;AAAA;AAAA;AAAA,aAQhB,CAAC,EAAE,OAAO,SAAS,MAAM,QAAQ,QAAQ,EAAE,KAAK,CAAC;AAAA;AAAA,mBAE3C,CAAC,EAAE,MAAM,MAAM,cAAc,KAAK,CAAC;AAAA,gBACtC,CAAC,EAAE,YAAY,MAAO,cAAc,OAAO,UAAU,IAAI,aAAc;AAAA,WAC5E,OAAO,WAAW,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,kBAKZ,CAAC,EAAE,YAAY,MAAO,cAAc,OAAO,UAAU,IAAI,OAAO,UAAU,CAAE;AAAA;AAAA;AAAA;AAAA,kBAI5E,OAAO,UAAU,CAAC;AAAA;AAAA;AAAA;AAAA,aAIvB,OAAO,UAAU,CAAC;AAAA;AAAA;AAAA;AAAA;;;ACbzB;AA7BN,IAAM,2BAA2D;AAAA,EAC/D,OAAO;AAAA,EACP,QAAQ;AACV;AAEO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA,OAAO;AAAA,EACP,UAAU;AAAA,EACV,aAAa;AAAA,EACb,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc;AAChB,GAAqC;AACnC,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,UAAU;AAAA,MACV,aAAa;AAAA,MACb;AAAA,MACA,SAAS,WAAW,SAAY;AAAA,MAChC,cAAY;AAAA,MAEZ,8BAAC,QAAK,MAAY,MAAM,yBAAyB,IAAI,GAAG;AAAA;AAAA,EAC1D;AAEJ;","names":[]}
|
package/dist/chunk-OKPNST44.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-OKPNST44.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/blocks/block-context/block-context.tsx","../src/components/blocks/types.ts","../src/components/blocks/text-block/text-block.tsx","../src/components/blocks/scrollable-table/scrollable-table-styles.ts","../src/components/blocks/scrollable-table/scrollable-table.tsx","../src/components/blocks/text-block/sanitize.ts","../src/components/blocks/text-block/text-block-styles.ts","../src/components/blocks/block-services/text-block-service.ts","../src/components/blocks/block-services/index.ts","../src/components/blocks/block/block.tsx"],"sourcesContent":["import { createContext, useContext, type ComponentType } from \"react\";\n\n/** Renderer-level concerns provided to descendants of any `Block`-rendering tree. */\nexport interface BlockContextValue {\n /** Optional component rendered next to each table in a TEXT block. Receives the zero-based table index. */\n TableActions?: ComponentType<{ tableIndex: number }>;\n}\n\nexport const BlockContext = createContext<BlockContextValue | null>(null);\n\n/** Returns the ambient block-rendering context. Returns an empty object outside a `<BlockContext.Provider>`. */\nexport function useBlockContext(): BlockContextValue {\n return useContext(BlockContext) ?? {};\n}\n","import type { ComponentType } from \"react\";\n\n/** Block-type discriminator constants. Mirrors the wire shape from io-server / shapes-agent. */\nexport const blockTypes = {\n TEXT: \"TEXT\",\n} as const;\n\n/** Discriminator for content blocks. */\nexport type BlockType = (typeof blockTypes)[keyof typeof blockTypes];\n\n/** Plain-text content block — rendered as Markdown. */\nexport interface TextBlockRecord {\n /** Block-type discriminator. */\n type: typeof blockTypes.TEXT;\n /** Type-specific data; kept as `payload` to match the wire shape 1:1. */\n payload: {\n /** The Markdown source for this text segment. */\n text: string;\n };\n}\n\n/** Discriminated union of all supported content blocks. Additive — new types extend this union. */\nexport type BlockRecord = TextBlockRecord;\n\n/** Props every concrete block component receives from the dispatcher. */\nexport interface BlockComponentProps<TBlock extends BlockRecord = BlockRecord> {\n /** The block to render. */\n block: TBlock;\n}\n\n/** Per-block-type service — registry entry that pairs a discriminator with its concrete renderer. */\nexport interface BlockService<TBlock extends BlockRecord = BlockRecord> {\n /** Discriminator value this service handles. */\n type: BlockType;\n /** React component that renders a block of this type. */\n Component: ComponentType<BlockComponentProps<TBlock>>;\n}\n","import type { ReactNode } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport remarkBreaks from \"remark-breaks\";\nimport remarkGfm from \"remark-gfm\";\n\nimport { ScrollableTable, type TableCounter } from \"../scrollable-table/scrollable-table\";\nimport type { BlockComponentProps, TextBlockRecord } from \"../types\";\nimport { sanitize } from \"./sanitize\";\nimport { TextBlockWrapper } from \"./text-block-styles\";\n\n/** Renders a TEXT block as Markdown with GFM (tables, strikethrough) and line breaks. */\nexport function TextBlock({ block }: BlockComponentProps<TextBlockRecord>): ReactNode {\n const counter: TableCounter = { value: 0 };\n\n const markdownComponents = {\n table: ((tableProps: { node?: unknown; children?: ReactNode }) => (\n <ScrollableTable {...tableProps} counter={counter} />\n )) as React.ComponentType<unknown>,\n };\n\n return (\n <TextBlockWrapper>\n <ReactMarkdown remarkPlugins={[remarkGfm, remarkBreaks]} components={markdownComponents}>\n {sanitize(block.payload.text)}\n </ReactMarkdown>\n </TextBlockWrapper>\n );\n}\n","import styled from \"styled-components\";\n\nimport { colors } from \"@/tokens/colors\";\n\nexport const TableContainer = styled.div`\n position: relative;\n margin-block: 8px 16px;\n`;\n\nexport const TableScroll = styled.div`\n width: 100%;\n overflow-x: auto;\n overflow-y: hidden;\n`;\n\nexport const TableActionsWrapper = styled.div`\n display: flex;\n justify-content: flex-start;\n margin-block: 8px 0;\n`;\n\nexport const TableActionsDivider = styled.div`\n height: 1px;\n background: ${colors[\"brown-40\"]};\n margin-block: 8px 0;\n`;\n","import { type ReactNode } from \"react\";\n\nimport { useBlockContext } from \"../block-context/block-context\";\nimport { TableActionsWrapper, TableActionsDivider, TableContainer, TableScroll } from \"./scrollable-table-styles\";\n\n/** Mutable counter used to assign sequential table indices during a single render pass. */\nexport interface TableCounter {\n /** The current value; incremented each time a table component is rendered. */\n value: number;\n}\n\n/** Props for the ScrollableTable component. */\ninterface ScrollableTableProps {\n /** Unused node prop from react-markdown. */\n node?: unknown;\n /** Table children elements. */\n children?: ReactNode;\n /** Mutable counter for tracking table indices. */\n counter?: TableCounter;\n}\n\n/** Renders a table inside a horizontally scrollable wrapper with optional actions below. */\nexport function ScrollableTable({ node: _node, counter, ...props }: ScrollableTableProps): ReactNode {\n const currentIndex = counter ? counter.value : 0;\n if (counter) {\n // eslint-disable-next-line react-hooks/immutability -- Counter is an intentionally mutable shared object for sequential table indexing\n counter.value += 1;\n }\n\n const { TableActions } = useBlockContext();\n\n return (\n <TableContainer>\n <TableScroll>\n <table {...props} />\n </TableScroll>\n {TableActions && (\n <>\n <TableActionsWrapper>\n <TableActions tableIndex={currentIndex} />\n </TableActionsWrapper>\n <TableActionsDivider />\n </>\n )}\n </TableContainer>\n );\n}\n","// Strips io-server's `<!-- table-title: ... -->` HTML-comment metadata before rendering.\n// The marker is emitted by the server's CSV-export pipeline so the export button can label\n// the file; it has no place in the visual output. If the server-side format changes\n// (prefix, spacing, closing-tag style), this filter silently stops matching and the\n// raw HTML comment leaks into rendered Markdown — keep this contract aligned with io-server.\nexport function sanitize(text: string): string {\n return text\n .split(\"\\n\")\n .filter((line) => {\n const t = line.trim();\n return !(t.startsWith(\"<!-- table-title:\") && t.endsWith(\"-->\"));\n })\n .join(\"\\n\");\n}\n","import styled from \"styled-components\";\n\nimport { colors } from \"@/tokens/colors\";\nimport { typographyMixin, typographyTypes } from \"@/tokens/typography\";\n\nexport const TextBlockWrapper = styled.div`\n ${typographyMixin(typographyTypes.GEIST_BODY_S_REGULAR)};\n color: ${colors[\"brown-100\"]};\n word-break: break-word;\n\n & h1 {\n ${typographyMixin(typographyTypes.GEIST_HEADING_S_BOLD)};\n margin-block: 20px;\n }\n\n & h2 {\n ${typographyMixin(typographyTypes.GEIST_BODY_L_SEMI_BOLD)};\n margin-block: 12px;\n }\n\n & h3,\n & h4,\n & h5,\n & h6 {\n ${typographyMixin(typographyTypes.GEIST_BODY_M_SEMI_BOLD)};\n margin-block: 8px;\n }\n\n & strong {\n ${typographyMixin(typographyTypes.GEIST_BODY_S_SEMI_BOLD)};\n }\n\n & p {\n margin-block: 0px;\n }\n\n & p + p {\n margin-block: 8px 0px;\n }\n\n & ul,\n & ol {\n margin-block: 16px;\n padding-left: 20px;\n }\n\n & li + li {\n margin-block: 4px;\n }\n\n & ol {\n list-style-type: decimal;\n }\n\n & ol ol {\n list-style-type: lower-alpha;\n }\n\n & ol ol ol {\n list-style-type: lower-roman;\n }\n\n & a {\n color: inherit;\n text-decoration-line: underline;\n text-decoration-style: dotted;\n text-decoration-thickness: auto;\n text-underline-offset: auto;\n text-underline-position: from-font;\n transition: color 75ms ease-in-out;\n\n &:hover {\n color: ${colors[\"blue-600\"]};\n }\n }\n\n & hr {\n border: none;\n border-top: 1px solid ${colors[\"brown-40\"]};\n margin-block: 20px;\n }\n\n & table {\n margin: 0;\n width: 100%;\n border-collapse: collapse;\n }\n\n & th,\n & td {\n border: none;\n border-bottom: 1px solid ${colors[\"brown-40\"]};\n text-align: left;\n }\n\n & th {\n ${typographyMixin(typographyTypes.GEIST_LABEL_CAPTION_MEDIUM)};\n padding: 8px;\n }\n\n & td {\n ${typographyMixin(typographyTypes.GEIST_BODY_XS_MEDIUM)};\n padding: 16px 8px;\n min-width: 150px;\n width: 1%;\n }\n\n & td strong {\n font-weight: inherit;\n font-size: inherit;\n line-height: inherit;\n }\n\n & blockquote {\n margin-block: 4px;\n margin-inline: 0px;\n padding-left: 16px;\n border-left: 4px solid ${colors[\"brown-40\"]};\n color: ${colors[\"brown-80\"]};\n }\n`;\n","import { TextBlock } from \"../text-block/text-block\";\nimport { blockTypes } from \"../types\";\nimport type { BlockService, TextBlockRecord } from \"../types\";\n\nexport const TextBlockService: BlockService<TextBlockRecord> = {\n type: blockTypes.TEXT,\n Component: TextBlock,\n};\n","import type { BlockService, BlockType } from \"../types\";\nimport { TextBlockService } from \"./text-block-service\";\n\nexport const BlockServices: Record<BlockType, BlockService> = {\n [TextBlockService.type]: TextBlockService,\n};\n","import type { ReactNode } from \"react\";\n\nimport { BlockServices } from \"../block-services\";\nimport type { BlockRecord } from \"../types\";\n\n/** Props for the Block dispatcher. */\ninterface BlockProps {\n /** The block to render. Dispatched to the registered concrete component for its `type`. */\n block: BlockRecord;\n}\n\n/** Dispatches a single block to its registered concrete component. Unknown types render as a no-op. */\nexport function Block({ block }: BlockProps): ReactNode {\n const service = BlockServices[block.type];\n if (!service) return null;\n const { Component } = service;\n return <Component block={block} />;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,eAAe,kBAAsC;AAQvD,IAAM,eAAe,cAAwC,IAAI;AAGjE,SAAS,kBAAqC;AACnD,SA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CAAC,WAAW,YAAY,GAAG,YAAY,oBAClE,mBAAS,MAAM,QAAQ,IAAI,GAC9B,GACF;AAEJ;;;AKvBO,IAAM,mBAAkD;AAAA,EAC7D,MAAM,WAAW;AAAA,EACjB,WAAW;AACb;;;ACJO,IAAM,gBAAiD;AAAA,EAC5D,CAAC,iBAAiB,IAAI,GAAG;AAC3B;;;ACWS,gBAAAC,YAAA;AAJF,SAAS,MAAM,EAAE,MAAM,GAA0B;AACtD,QAAM,UAAU,cAAc,MAAM,IAAI;AACxC,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,EAAE,UAAU,IAAI;AACtB,SAAO,gBAAAA,KAAC,aAAU,OAAc;AAClC;","names":["styled","styled","jsx","jsx"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat/chat-message/chat-message.tsx","../src/components/chat/chat-context/chat-context.ts","../src/components/chat/chat-message-actions/chat-message-actions.tsx","../node_modules/@tabler/icons-react/src/defaultAttributes.ts","../node_modules/@tabler/icons-react/src/createReactComponent.ts","../node_modules/@tabler/icons-react/src/icons/IconCheck.ts","../node_modules/@tabler/icons-react/src/icons/IconCopy.ts","../node_modules/@tabler/icons-react/src/icons/IconThumbDown.ts","../node_modules/@tabler/icons-react/src/icons/IconThumbUp.ts","../src/components/chat/hooks/use-copy-to-clipboard.ts","../src/utils/clipboard.ts","../src/components/chat/constants.ts","../src/components/chat/chat-message-actions/chat-message-actions-styles.ts","../src/components/chat/chat-message/chat-message-styles.ts"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport { Block } from \"@/components/blocks/block\";\nimport { BlockContext, type BlockContextValue } from \"@/components/blocks/block-context\";\nimport { useChatContext } from \"../chat-context/chat-context\";\nimport type { ChatMessage as ChatMessageType } from \"../types\";\nimport { ChatMessageActions } from \"../chat-message-actions/chat-message-actions\";\nimport { MessageRow, MessageBubble, MessageContainer } from \"./chat-message-styles\";\n\ninterface ChatMessageProps {\n message: ChatMessageType;\n}\n\nexport function ChatMessage({ message }: ChatMessageProps) {\n const { TableActions: ChatTableActions } = useChatContext();\n\n // Adapt the chat-shaped TableActions ({ messageId, tableIndex }) into the generic block-shaped\n // signature ({ tableIndex }) by binding this message's id. The blocks namespace stays\n // chat-agnostic; chat owns the messageId-to-action correlation.\n const blockContextValue = useMemo<BlockContextValue>(\n () => ({\n TableActions: ChatTableActions\n ? ({ tableIndex }) => <ChatTableActions messageId={message.id} tableIndex={tableIndex} />\n : undefined,\n }),\n [ChatTableActions, message.id]\n );\n\n return (\n <MessageRow $role={message.role} role=\"article\" aria-label={`${message.role} message`}>\n <MessageContainer $role={message.role}>\n <MessageBubble $role={message.role}>\n <BlockContext.Provider value={blockContextValue}>\n {message.blocks.map((block, index) => (\n <Block key={index} block={block} />\n ))}\n </BlockContext.Provider>\n </MessageBubble>\n <ChatMessageActions\n messageId={message.id}\n content={message.fallbackText}\n role={message.role}\n isHelpful={message.isHelpful}\n />\n </MessageContainer>\n </MessageRow>\n );\n}\n","import { createContext, useContext } from \"react\";\nimport type { ChatContextValue } from \"../types\";\n\nexport const ChatContext = createContext<ChatContextValue | null>(null);\n\nexport function useChatContext(): ChatContextValue {\n const context = useContext(ChatContext);\n if (!context) {\n throw new Error(\"useChatContext must be used within a Chat.Root component\");\n }\n return context;\n}\n","import { useCallback } from \"react\";\nimport { IconCopy, IconCheck, IconThumbUp, IconThumbDown } from \"@tabler/icons-react\";\n\nimport { IconButton } from \"../../icon-button/icon-button\";\nimport { useChatContext } from \"../chat-context/chat-context\";\nimport { useCopyToClipboard } from \"../hooks/use-copy-to-clipboard\";\nimport { MESSAGE_ROLE } from \"../constants\";\nimport type { MessageRole } from \"../types\";\nimport { ActionsContainer, AnimatedAction } from \"./chat-message-actions-styles\";\n\ninterface ChatMessageActionsProps {\n className?: string;\n messageId: string;\n content: string;\n role: MessageRole;\n isHelpful?: boolean | null;\n}\n\nexport function ChatMessageActions({ className, messageId, content, role, isHelpful }: ChatMessageActionsProps) {\n const { onCopyMessage, onThumbUpClick, onThumbDownClick } = useChatContext();\n const { isCopied, copy } = useCopyToClipboard();\n\n const handleCopy = useCallback(() => {\n copy(content);\n onCopyMessage?.(messageId);\n }, [content, messageId, copy, onCopyMessage]);\n\n const handleThumbUp = useCallback(() => {\n onThumbUpClick?.(messageId, isHelpful === true ? null : true);\n }, [messageId, isHelpful, onThumbUpClick]);\n\n const handleThumbDown = useCallback(() => {\n onThumbDownClick?.(messageId, isHelpful === false ? null : false);\n }, [messageId, isHelpful, onThumbDownClick]);\n\n const isAssistant = role === MESSAGE_ROLE.ASSISTANT;\n const hasFeedback = isAssistant && (onThumbUpClick || onThumbDownClick);\n\n return (\n <ActionsContainer $role={role} className={className}>\n <IconButton\n icon={isCopied ? IconCheck : IconCopy}\n onClick={handleCopy}\n aria-label={isCopied ? \"Copied\" : \"Copy message\"}\n />\n\n {hasFeedback && (\n <AnimatedAction $visible={isHelpful !== false}>\n <IconButton\n icon={IconThumbUp}\n onClick={handleThumbUp}\n isSelected={isHelpful === true}\n aria-label=\"Good response\"\n />\n </AnimatedAction>\n )}\n\n {hasFeedback && (\n <AnimatedAction $visible={isHelpful !== true}>\n <IconButton\n icon={IconThumbDown}\n onClick={handleThumbDown}\n isSelected={isHelpful === false}\n aria-label=\"Bad response\"\n />\n </AnimatedAction>\n )}\n </ActionsContainer>\n );\n}\n","export default {\n outline: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: 24,\n height: 24,\n viewBox: '0 0 24 24',\n fill: 'none',\n stroke: 'currentColor',\n strokeWidth: 2,\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n },\n filled: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: 24,\n height: 24,\n viewBox: '0 0 24 24',\n fill: 'currentColor',\n stroke: 'none',\n },\n};\n","import { forwardRef, createElement } from 'react';\nimport defaultAttributes from './defaultAttributes';\nimport type { IconNode, IconProps, Icon } from './types';\n\nconst createReactComponent = (\n type: 'outline' | 'filled',\n iconName: string,\n iconNamePascal: string,\n iconNode: IconNode,\n) => {\n const Component = forwardRef<SVGSVGElement, IconProps>(\n (\n { color = 'currentColor', size = 24, stroke = 2, title, className, children, ...rest }: IconProps,\n ref,\n ) =>\n createElement(\n 'svg',\n {\n ref,\n ...defaultAttributes[type],\n width: size,\n height: size,\n className: [`tabler-icon`, `tabler-icon-${iconName}`, className].join(' '),\n ...(type === 'filled'\n ? {\n fill: color,\n }\n : {\n strokeWidth: stroke,\n stroke: color,\n }),\n ...rest,\n },\n [\n title && createElement('title', { key: 'svg-title' }, title),\n ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),\n ...(Array.isArray(children) ? children : [children]),\n ],\n ),\n );\n\n Component.displayName = `${iconNamePascal}`;\n\n return Component;\n};\n\nexport default createReactComponent;\n","import createReactComponent from '../createReactComponent';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [[\"path\",{\"d\":\"M5 12l5 5l10 -10\",\"key\":\"svg-0\"}]]\n\nconst IconCheck = createReactComponent('outline', 'check', 'Check', __iconNode);\n\nexport default IconCheck;","import createReactComponent from '../createReactComponent';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [[\"path\",{\"d\":\"M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666\",\"key\":\"svg-0\"}],[\"path\",{\"d\":\"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1\",\"key\":\"svg-1\"}]]\n\nconst IconCopy = createReactComponent('outline', 'copy', 'Copy', __iconNode);\n\nexport default IconCopy;","import createReactComponent from '../createReactComponent';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [[\"path\",{\"d\":\"M7 13v-8a1 1 0 0 0 -1 -1h-2a1 1 0 0 0 -1 1v7a1 1 0 0 0 1 1h3a4 4 0 0 1 4 4v1a2 2 0 0 0 4 0v-5h3a2 2 0 0 0 2 -2l-1 -5a2 3 0 0 0 -2 -2h-7a3 3 0 0 0 -3 3\",\"key\":\"svg-0\"}]]\n\nconst IconThumbDown = createReactComponent('outline', 'thumb-down', 'ThumbDown', __iconNode);\n\nexport default IconThumbDown;","import createReactComponent from '../createReactComponent';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [[\"path\",{\"d\":\"M7 11v8a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1v-7a1 1 0 0 1 1 -1h3a4 4 0 0 0 4 -4v-1a2 2 0 0 1 4 0v5h3a2 2 0 0 1 2 2l-1 5a2 3 0 0 1 -2 2h-7a3 3 0 0 1 -3 -3\",\"key\":\"svg-0\"}]]\n\nconst IconThumbUp = createReactComponent('outline', 'thumb-up', 'ThumbUp', __iconNode);\n\nexport default IconThumbUp;","import { useState, useCallback, useRef, useEffect } from \"react\";\n\nimport { copyToClipboard } from \"@/utils/clipboard\";\nimport { markdownToPlainText } from \"@/utils/markdown-to-plain-text\";\n\nconst RESET_DELAY_MS = 2000;\n\ninterface UseCopyToClipboardResult {\n isCopied: boolean;\n copy: (text: string) => void;\n}\n\nexport function useCopyToClipboard(): UseCopyToClipboardResult {\n const [isCopied, setIsCopied] = useState(false);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n return () => {\n if (timeoutRef.current) clearTimeout(timeoutRef.current);\n };\n }, []);\n\n const copy = useCallback((text: string) => {\n copyToClipboard(markdownToPlainText(text), {\n onSuccess: () => {\n setIsCopied(true);\n if (timeoutRef.current) clearTimeout(timeoutRef.current);\n timeoutRef.current = setTimeout(() => {\n setIsCopied(false);\n timeoutRef.current = null;\n }, RESET_DELAY_MS);\n },\n });\n }, []);\n\n return { isCopied, copy };\n}\n","/** Options for the {@link copyToClipboard} function. */\ninterface CopyToClipboardOptions {\n /** Called after the text has been successfully written to the clipboard. */\n onSuccess?: () => void;\n /** Called if the clipboard write fails (e.g., permission denied). */\n onFailure?: (error: unknown) => void;\n}\n\n/**\n * Copies text to the system clipboard using the Clipboard API.\n * @param text - The string to copy.\n * @param options - Optional success/failure callbacks.\n */\nexport function copyToClipboard(text: string, options?: CopyToClipboardOptions): void {\n navigator.clipboard.writeText(text).then(\n () => options?.onSuccess?.(),\n (error) => options?.onFailure?.(error)\n );\n}\n","export const MESSAGE_ROLE = {\n USER: \"user\",\n ASSISTANT: \"assistant\",\n} as const;\n","import styled from \"styled-components\";\n\nimport { MESSAGE_ROLE } from \"../constants\";\nimport type { MessageRole } from \"../types\";\n\nconst FADE_DURATION_MS = 150;\nconst ANIMATE_DURATION_MS = 200;\n\nexport const ActionsContainer = styled.div<{ $role: MessageRole }>`\n display: flex;\n opacity: ${({ $role }) => ($role === MESSAGE_ROLE.ASSISTANT ? 1 : 0)};\n pointer-events: ${({ $role }) => ($role === MESSAGE_ROLE.ASSISTANT ? \"auto\" : \"none\")};\n transition: opacity ${FADE_DURATION_MS}ms ease;\n`;\n\nexport const AnimatedAction = styled.div<{ $visible: boolean }>`\n display: flex;\n overflow: hidden;\n max-width: ${({ $visible }) => ($visible ? \"40px\" : \"0\")};\n opacity: ${({ $visible }) => ($visible ? 1 : 0)};\n transition: max-width ${ANIMATE_DURATION_MS}ms ease, opacity ${ANIMATE_DURATION_MS}ms ease;\n`;\n","import styled from \"styled-components\";\n\nimport { colors } from \"../../../tokens/colors\";\nimport { typographyMixin, typographyTypes } from \"../../../tokens/typography\";\nimport { ActionsContainer } from \"../chat-message-actions/chat-message-actions-styles\";\nimport { MESSAGE_ROLE } from \"../constants\";\nimport type { MessageRole } from \"../types\";\n\nexport const MessageRow = styled.div<{ $role: MessageRole }>`\n display: flex;\n justify-content: ${({ $role }) => ($role === MESSAGE_ROLE.USER ? \"flex-end\" : \"flex-start\")};\n\n &:hover ${ActionsContainer} {\n opacity: 1;\n pointer-events: auto;\n }\n`;\n\nexport const MessageContainer = styled.div<{ $role: MessageRole }>`\n display: flex;\n flex-direction: column;\n align-items: ${({ $role }) => ($role === MESSAGE_ROLE.USER ? \"flex-end\" : \"flex-start\")};\n max-width: 90%;\n width: ${({ $role }) => ($role === MESSAGE_ROLE.USER ? \"auto\" : \"100%\")};\n gap: 12px;\n`;\n\nexport const MessageBubble = styled.div<{ $role: MessageRole }>`\n ${typographyMixin(typographyTypes.GEIST_BODY_S_REGULAR)};\n color: ${colors[\"brown-100\"]};\n background: ${({ $role }) => ($role === MESSAGE_ROLE.USER ? colors.white : \"transparent\")};\n padding: ${({ $role }) => ($role === MESSAGE_ROLE.USER ? \"12px 16px\" : \"0\")};\n border-radius: ${({ $role }) => ($role === MESSAGE_ROLE.USER ? \"16px\" : \"0\")};\n max-width: 100%;\n min-width: 0;\n`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAS,eAAe;;;ACAxB,SAAS,eAAe,kBAAkB;AAGnC,IAAM,cAAc,cAAuC,IAAI;AAE/D,SAAS,iBAAmC;AACjD,QAAM,UAAU,WAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AACA,SAAO;AACT;;;ACXA,SAAS,eAAAA,oBAAmB;A;;;;;ACA5B,IAAA,oBAAe;EACb,SAAS;IACP,OAAO;IACP,OAAO;IACP,QAAQ;IACR,SAAS;IACT,MAAM;IACN,QAAQ;IACR,aAAa;IACb,eAAe;IACf,gBAAgB;EAAA;EAElB,QAAQ;IACN,OAAO;IACP,OAAO;IACP,QAAQ;IACR,SAAS;IACT,MAAM;IACN,QAAQ;EAAA;AAEZ;;;AChBA,IAAM,uBAAuB,CAC3B,MACA,UACA,gBACA,aACG;AACH,QAAM,YAAY;IAChB,CACE,EAAE,QAAQ,gBAAgB,OAAO,IAAI,SAAS,GAAG,OAAO,WAAW,UAAU,GAAG,KAAA,GAChF,QAEA;MACE;MACA;QACE;QACA,GAAG,kBAAkB,IAAI;QACzB,OAAO;QACP,QAAQ;QACR,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B,SAAS,QAAQ;AAAA,QACjB,MAAM,QAAQ;AAAA,QACd,WAAW,QAAQ;AAAA;AAAA,IACrB;AAAA,KACF,GACF;AAEJ;","names":["useCallback","__iconNode","__iconNode","__iconNode","useCallback","styled","styled","jsx","jsxs"]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
|
|
3
|
-
/** Block-type discriminator constants. Mirrors the wire shape from io-server / shapes-agent. */
|
|
4
|
-
declare const blockTypes: {
|
|
5
|
-
readonly TEXT: "TEXT";
|
|
6
|
-
};
|
|
7
|
-
/** Discriminator for content blocks. */
|
|
8
|
-
type BlockType = (typeof blockTypes)[keyof typeof blockTypes];
|
|
9
|
-
/** Plain-text content block — rendered as Markdown. */
|
|
10
|
-
interface TextBlockRecord {
|
|
11
|
-
/** Block-type discriminator. */
|
|
12
|
-
type: typeof blockTypes.TEXT;
|
|
13
|
-
/** Type-specific data; kept as `payload` to match the wire shape 1:1. */
|
|
14
|
-
payload: {
|
|
15
|
-
/** The Markdown source for this text segment. */
|
|
16
|
-
text: string;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
/** Discriminated union of all supported content blocks. Additive — new types extend this union. */
|
|
20
|
-
type BlockRecord = TextBlockRecord;
|
|
21
|
-
/** Props every concrete block component receives from the dispatcher. */
|
|
22
|
-
interface BlockComponentProps<TBlock extends BlockRecord = BlockRecord> {
|
|
23
|
-
/** The block to render. */
|
|
24
|
-
block: TBlock;
|
|
25
|
-
}
|
|
26
|
-
/** Per-block-type service — registry entry that pairs a discriminator with its concrete renderer. */
|
|
27
|
-
interface BlockService<TBlock extends BlockRecord = BlockRecord> {
|
|
28
|
-
/** Discriminator value this service handles. */
|
|
29
|
-
type: BlockType;
|
|
30
|
-
/** React component that renders a block of this type. */
|
|
31
|
-
Component: ComponentType<BlockComponentProps<TBlock>>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { type BlockComponentProps as B, type TextBlockRecord as T, type BlockRecord as a, type BlockService as b, type BlockType as c, blockTypes as d };
|