@shapesos/clay 0.11.0 → 0.13.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 +1420 -245
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.d.cts +167 -6
- package/dist/artifacts.d.ts +167 -6
- package/dist/artifacts.js +18 -3
- package/dist/blocks.cjs +1696 -532
- package/dist/blocks.cjs.map +1 -1
- package/dist/blocks.css +1 -1
- package/dist/blocks.d.cts +21 -10
- package/dist/blocks.d.ts +21 -10
- package/dist/blocks.js +7 -3
- package/dist/capture.cjs +220 -0
- package/dist/capture.cjs.map +1 -0
- package/dist/capture.d.cts +113 -0
- package/dist/capture.d.ts +113 -0
- package/dist/capture.js +17 -0
- 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 +1687 -532
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.d.cts +3 -2
- package/dist/chat.d.ts +3 -2
- package/dist/chat.js +8 -4
- package/dist/{chunk-MXOPG747.js → chunk-26XVDY6Z.js} +8 -8
- package/dist/chunk-26XVDY6Z.js.map +1 -0
- package/dist/{chunk-L35M3OD5.js → chunk-4MZZH3WX.js} +5 -11
- package/dist/chunk-4MZZH3WX.js.map +1 -0
- package/dist/chunk-DT44KNCV.js +1004 -0
- package/dist/chunk-DT44KNCV.js.map +1 -0
- package/dist/chunk-JAGNXEWK.js +116 -0
- package/dist/chunk-JAGNXEWK.js.map +1 -0
- package/dist/chunk-LXYCT4YO.js +7 -0
- package/dist/chunk-LXYCT4YO.js.map +1 -0
- package/dist/chunk-P6GUNIAE.js +11 -0
- package/dist/chunk-P6GUNIAE.js.map +1 -0
- package/dist/{chunk-OUW6PUEB.js → chunk-QH2WW2MW.js} +7 -7
- package/dist/chunk-QXGYMDIA.js +477 -0
- package/dist/chunk-QXGYMDIA.js.map +1 -0
- package/dist/chunk-RSRNSWJN.js +1 -0
- package/dist/chunk-RSRNSWJN.js.map +1 -0
- package/dist/dom-to-image-NATF3446.js +21 -0
- package/dist/dom-to-image-NATF3446.js.map +1 -0
- package/dist/index.cjs +1489 -317
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +28 -15
- package/dist/table.js +2 -1
- package/dist/types-B2aYk82c.d.cts +29 -0
- package/dist/types-B2aYk82c.d.ts +29 -0
- package/dist/types-BzXPBy6s.d.cts +330 -0
- package/dist/{types-DuuRI4ll.d.cts → types-CW45GBXl.d.cts} +31 -4
- package/dist/{types-C9XX-Uhk.d.ts → types-D1b8v7EY.d.ts} +31 -4
- package/dist/types-GCkXbyFm.d.ts +330 -0
- package/package.json +24 -2
- package/dist/chunk-BX5TCEPR.js +0 -436
- package/dist/chunk-BX5TCEPR.js.map +0 -1
- package/dist/chunk-L35M3OD5.js.map +0 -1
- package/dist/chunk-MEJESPTZ.js +0 -1
- package/dist/chunk-MXOPG747.js.map +0 -1
- package/dist/types-3Gzk7cRt.d.cts +0 -121
- package/dist/types-3Gzk7cRt.d.ts +0 -121
- /package/dist/{chunk-MEJESPTZ.js.map → capture.js.map} +0 -0
- /package/dist/{chunk-OUW6PUEB.js.map → chunk-QH2WW2MW.js.map} +0 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { C as ChartSeries } from './types-B2aYk82c.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shared artifact primitives — the discriminator constant and the cross-variant `ArtifactBase`
|
|
6
|
+
* shape that every concrete artifact record extends.
|
|
7
|
+
*
|
|
8
|
+
* Pulled into its own file so the per-type `types.ts` files (`table-artifact/types.ts`,
|
|
9
|
+
* `chart-artifact/types.ts`) and the union assembler (`artifacts/types.ts`) can all depend on
|
|
10
|
+
* one canonical source without creating a circular module graph between them.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Artifact-type discriminator constants. Uppercase to match the server-side `artifactTypes`
|
|
14
|
+
* constant — io-server stores `artifact.type === "TABLE"` (aligned with the GraphQL enum).
|
|
15
|
+
*/
|
|
16
|
+
declare const artifactTypes: {
|
|
17
|
+
readonly TABLE: "TABLE";
|
|
18
|
+
readonly CHART: "CHART";
|
|
19
|
+
};
|
|
20
|
+
/** Discriminator for artifact types. Additive — new types extend this union. */
|
|
21
|
+
type ArtifactType = (typeof artifactTypes)[keyof typeof artifactTypes];
|
|
22
|
+
/** Common shape every artifact record carries. Discriminated by `type`. */
|
|
23
|
+
interface ArtifactBase<TType extends ArtifactType, TConfig> {
|
|
24
|
+
/** Artifact-type discriminator. */
|
|
25
|
+
type: TType;
|
|
26
|
+
/** Human-readable label. Nullable when the artifact has no title. */
|
|
27
|
+
title: string | null;
|
|
28
|
+
/** Rendering config — shape varies per artifact type. */
|
|
29
|
+
config: TConfig;
|
|
30
|
+
/** Protected-asset metadata pointing to the underlying data payload. Null while the asset is unavailable. */
|
|
31
|
+
protectedAsset: {
|
|
32
|
+
/** Time-limited URL the renderer fetches the artifact's data from. */
|
|
33
|
+
presignedUrl: string;
|
|
34
|
+
} | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A row inside an artifact's parsed CSV. Every cell is the raw string from the CSV (or `null`
|
|
38
|
+
* for the empty string). Used by every artifact kind whose data wire is a CSV (`TABLE`, `CHART`).
|
|
39
|
+
* The renderer never coerces — type-aware formatting is a server concern (the CSV's contents
|
|
40
|
+
* are what the user sees).
|
|
41
|
+
*/
|
|
42
|
+
type ArtifactDataRow = Record<string, string | null>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Rendering config for a `BAR` chart. `xKey` selects the categorical axis; each series
|
|
46
|
+
* contributes one `<Bar>`. `stacked` collapses all series onto a single stack-id (so they sum
|
|
47
|
+
* vertically); when false / omitted bars are grouped side-by-side per x-tick.
|
|
48
|
+
*/
|
|
49
|
+
interface BarChartConfig extends ChartConfigBase {
|
|
50
|
+
variant: "BAR";
|
|
51
|
+
/** CSV column key used as the x-axis. */
|
|
52
|
+
xKey: string;
|
|
53
|
+
/** When true, stack all series on one stack-id. When false / omitted, group bars side-by-side. */
|
|
54
|
+
stacked?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Rendering config for a `LINE` chart. `xKey` selects the categorical/temporal axis from the
|
|
59
|
+
* CSV; each series contributes one `<Line>` overlaid against that axis.
|
|
60
|
+
*/
|
|
61
|
+
interface LineChartConfig extends ChartConfigBase {
|
|
62
|
+
variant: "LINE";
|
|
63
|
+
/** CSV column key used as the x-axis. */
|
|
64
|
+
xKey: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Rendering config for a `PIE` chart. `categoryKey` names the slice; `valueKey` carries the
|
|
69
|
+
* slice's numeric magnitude. One row of CSV becomes one slice. The base's `series` array is
|
|
70
|
+
* always empty for pie — colors are resolved by row index from the palette.
|
|
71
|
+
*/
|
|
72
|
+
interface PieChartConfig extends ChartConfigBase {
|
|
73
|
+
variant: "PIE";
|
|
74
|
+
/** CSV column key used as the slice label. */
|
|
75
|
+
categoryKey: string;
|
|
76
|
+
/** CSV column key used as the slice numeric value. */
|
|
77
|
+
valueKey: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Discriminated union of all supported chart variant configs. Assembled here (not in the parent
|
|
82
|
+
* `types.ts`) because the union depends on each variant service file as its single source of
|
|
83
|
+
* truth for that variant's config type.
|
|
84
|
+
*
|
|
85
|
+
* Extension pattern: add a new variant by creating one `*-chart-variant-service.ts` file and
|
|
86
|
+
* extending this union + the `ChartVariantServices` map below. No edits to the dispatcher.
|
|
87
|
+
*/
|
|
88
|
+
type ChartConfig = LineChartConfig | BarChartConfig | PieChartConfig;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Optional stats embedded in `ChartConfig` so clients can pre-render UI before fetching the
|
|
92
|
+
* actual CSV (e.g. a skeleton sized to the eventual row count). Mirrors `TableStats`.
|
|
93
|
+
*/
|
|
94
|
+
interface ChartStats {
|
|
95
|
+
/** Total number of rows in the materialised CSV. */
|
|
96
|
+
rowCount: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Cross-variant base for `ChartConfig`. Carries the fields every variant shares — series
|
|
100
|
+
* descriptors and optional stats. Per-variant config interfaces (in `chart-variant-services/`)
|
|
101
|
+
* extend this with their own required fields.
|
|
102
|
+
*
|
|
103
|
+
* Note: `series` is always present on the wire (matching the GraphQL `[ChartSeries!]!` shape)
|
|
104
|
+
* even for PIE — PIE just receives an empty array. Keeping it on the base mirrors the wire shape
|
|
105
|
+
* exactly and avoids TS object-literal freshness errors for callers that explicitly set
|
|
106
|
+
* `series: []` on a pie config.
|
|
107
|
+
*/
|
|
108
|
+
interface ChartConfigBase {
|
|
109
|
+
/** Series descriptors in render order. LINE/BAR consume these; PIE ignores in favour of `categoryKey`+`valueKey`. */
|
|
110
|
+
series: ChartSeries[];
|
|
111
|
+
/** Optional metadata describing the underlying data — used for loading-state UI. */
|
|
112
|
+
stats?: ChartStats;
|
|
113
|
+
}
|
|
114
|
+
/** Concrete chart artifact record. */
|
|
115
|
+
type ChartArtifactRecord = ArtifactBase<typeof artifactTypes.CHART, ChartConfig>;
|
|
116
|
+
/**
|
|
117
|
+
* Localized labels for the `CHART` artifact's user-facing strings. Covers action buttons AND
|
|
118
|
+
* status messages — see `TableArtifactLabels` for the same shape philosophy. Extends as the
|
|
119
|
+
* chart artifact grows its action set (e.g. future `copyAsPng`); optional keys document
|
|
120
|
+
* anticipated additions without forcing every consumer to provide them today.
|
|
121
|
+
*/
|
|
122
|
+
interface ChartArtifactLabels {
|
|
123
|
+
/** Tooltip + aria-label on the Download menu's trigger button (icon-only, opens the format
|
|
124
|
+
* picker). The trigger is action-shaped (just "Download"); the menu items spell out the
|
|
125
|
+
* format. */
|
|
126
|
+
download: string;
|
|
127
|
+
/** Label for the "Download CSV" item inside the Download menu. */
|
|
128
|
+
downloadCsv: string;
|
|
129
|
+
/** Label for the "Download PNG" item inside the Download menu. */
|
|
130
|
+
downloadPng: string;
|
|
131
|
+
/** Tooltip + aria-label on the "Copy Image" button in the chart artifact header (idle state).
|
|
132
|
+
* Transient working / success / error tooltips remain in English — they flash for ~1.5s and the
|
|
133
|
+
* cost of translating them is rarely worth it. */
|
|
134
|
+
copyAsImage: string;
|
|
135
|
+
/** Status message shown when no presigned URL is available or the chart config is malformed. */
|
|
136
|
+
unavailable: string;
|
|
137
|
+
/** Status message shown when the fetch / parse fails at runtime. */
|
|
138
|
+
loadError: string;
|
|
139
|
+
/** Status message shown while the CSV is being fetched. */
|
|
140
|
+
loading: string;
|
|
141
|
+
/** Status message shown when the fetched CSV has zero data rows. */
|
|
142
|
+
empty: string;
|
|
143
|
+
/**
|
|
144
|
+
* Category labels treated as the "Others" bucket in pie charts (case-insensitive). Matching
|
|
145
|
+
* slices are pinned to the end of the sweep and rendered in neutral grey. The agent writes a
|
|
146
|
+
* translated bucket name in non-English UIs (e.g. "אחרים", "Otros") — consumer passes the
|
|
147
|
+
* localized list here so clay can detect the bucket regardless of language. English fallback
|
|
148
|
+
* is `["Others", "Other"]`. Pass `[]` to disable Others detection (every slice from the palette).
|
|
149
|
+
*/
|
|
150
|
+
othersCategoryLabels: readonly string[];
|
|
151
|
+
}
|
|
152
|
+
/** English fallback for `ChartArtifactLabels`. Used when the consumer hasn't passed `labels`. */
|
|
153
|
+
declare const DEFAULT_CHART_ARTIFACT_LABELS: ChartArtifactLabels;
|
|
154
|
+
/**
|
|
155
|
+
* Consumer-supplied side-effect callbacks for actions on the chart artifact. Mirrors
|
|
156
|
+
* `ChartArtifactLabels`'s shape philosophy: one entry per action this artifact exposes
|
|
157
|
+
* (download today; future "Copy as PNG" etc.). Every callback is optional — consumers wire
|
|
158
|
+
* only the actions they care about. The artifact passes its own `ChartArtifactRecord` as the
|
|
159
|
+
* only argument so consumers can derive analytics context (title, config.variant, etc.) without
|
|
160
|
+
* a per-block closure at every render site.
|
|
161
|
+
*
|
|
162
|
+
* The callback fires alongside the default browser behaviour (e.g. `onDownload` does not
|
|
163
|
+
* prevent the anchor's download navigation) — it's purely for analytics / observability hooks.
|
|
164
|
+
*/
|
|
165
|
+
interface ChartArtifactCallbacks {
|
|
166
|
+
/** Fires when the "Download CSV" menu item is selected. Browser-native download still happens. */
|
|
167
|
+
onDownload?: (artifact: ChartArtifactRecord) => void;
|
|
168
|
+
/** Fires when the "Download PNG" menu item is selected. Runs alongside the rasterise — fires
|
|
169
|
+
* regardless of whether the rasterise ultimately succeeds (failures surface via console.warn). */
|
|
170
|
+
onDownloadPng?: (artifact: ChartArtifactRecord) => void;
|
|
171
|
+
/** Fires when the Copy Image button is clicked. Fires regardless of whether the copy ultimately
|
|
172
|
+
* succeeds (the result is reported via the button's own state flash) — use this only for
|
|
173
|
+
* analytics / observability, not for retrying failed copies. */
|
|
174
|
+
onCopyAsImage?: (artifact: ChartArtifactRecord) => void;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* A single column descriptor for a `TableArtifact`. Carries the ORDER and LABEL for the
|
|
179
|
+
* rendered table — `key` selects a column from the CSV header; `label` overrides the rendered
|
|
180
|
+
* header text. The CSV is always the source of truth for the data shape; clay never coerces,
|
|
181
|
+
* reformats, or interprets cell values.
|
|
182
|
+
*/
|
|
183
|
+
interface TableColumn {
|
|
184
|
+
/** Matches a header in the CSV. Required. Used to project + order the CSV's columns. */
|
|
185
|
+
key: string;
|
|
186
|
+
/** Human-readable header text. Required. */
|
|
187
|
+
label: string;
|
|
188
|
+
/**
|
|
189
|
+
* Accepted in the wire payload but not consulted by the renderer — every cell is rendered as
|
|
190
|
+
* the raw CSV string (or empty for null). Format conversion is a server concern; if a column
|
|
191
|
+
* needs to be "Yes/No" instead of "true/false", the server should emit it that way in the CSV.
|
|
192
|
+
* Kept in the interface so callers that pass `type` (e.g. io-client) don't get a type error.
|
|
193
|
+
*/
|
|
194
|
+
type?: "string" | "number" | "date" | "boolean";
|
|
195
|
+
/**
|
|
196
|
+
* Accepted in the wire payload but not consulted by the renderer — every column is left-aligned
|
|
197
|
+
* by design. Kept in the interface for forward-compat; restore per-column alignment by editing
|
|
198
|
+
* `table-artifact-content.tsx` if a future use case justifies it.
|
|
199
|
+
*/
|
|
200
|
+
align?: "left" | "center" | "right";
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Optional stats embedded in `TableConfig` so clients can pre-render UI before fetching the
|
|
204
|
+
* actual data payload (e.g. N loading shimmers sized to the eventual row count).
|
|
205
|
+
*
|
|
206
|
+
* Backward-compat: optional everywhere — older artifacts persisted before this field shipped
|
|
207
|
+
* still validate. The renderer falls back to a single status-message line when `stats` is absent.
|
|
208
|
+
*/
|
|
209
|
+
interface TableStats {
|
|
210
|
+
/** Total number of rows in the materialised CSV. Lets the loading branch render shimmers. */
|
|
211
|
+
rowCount: number;
|
|
212
|
+
}
|
|
213
|
+
/** Rendering config for a table artifact, stored at `artifact.config` (JSONB on the server). */
|
|
214
|
+
interface TableConfig {
|
|
215
|
+
/** Column descriptors in render order. */
|
|
216
|
+
columns: TableColumn[];
|
|
217
|
+
/** Optional metadata describing the underlying data — used for loading-state UI. */
|
|
218
|
+
stats?: TableStats;
|
|
219
|
+
}
|
|
220
|
+
/** Alias retained for callers typed against the table-specific name. */
|
|
221
|
+
type TableRow = ArtifactDataRow;
|
|
222
|
+
/** Concrete table artifact record. */
|
|
223
|
+
type TableArtifactRecord = ArtifactBase<typeof artifactTypes.TABLE, TableConfig>;
|
|
224
|
+
/**
|
|
225
|
+
* Localized labels for the `TABLE` artifact's user-facing strings. Covers both action buttons
|
|
226
|
+
* (download today; future "Copy as CSV", etc.) AND status messages (loading / error / empty /
|
|
227
|
+
* unavailable). Consumer passes the bag from their i18n layer; clay falls back to English
|
|
228
|
+
* defaults when omitted (per-key Partial merge).
|
|
229
|
+
*/
|
|
230
|
+
interface TableArtifactLabels {
|
|
231
|
+
/** Tooltip + aria-label on the Download CSV button in the table artifact header. */
|
|
232
|
+
download: string;
|
|
233
|
+
/**
|
|
234
|
+
* Status message shown when no presigned URL is available (permanent server-side absence) or
|
|
235
|
+
* the artifact config is malformed. Both states reduce to "the underlying file isn't usable".
|
|
236
|
+
*/
|
|
237
|
+
unavailable: string;
|
|
238
|
+
/** Status message shown when the fetch / parse fails at runtime (transient). */
|
|
239
|
+
loadError: string;
|
|
240
|
+
/** Status message shown while the CSV is being fetched and `stats.rowCount` is not known. */
|
|
241
|
+
loading: string;
|
|
242
|
+
/** Empty-state row inside the table body when the fetched CSV has zero data rows. */
|
|
243
|
+
empty: string;
|
|
244
|
+
}
|
|
245
|
+
/** English fallback for `TableArtifactLabels`. Used when the consumer hasn't passed `labels`. */
|
|
246
|
+
declare const DEFAULT_TABLE_ARTIFACT_LABELS: TableArtifactLabels;
|
|
247
|
+
/**
|
|
248
|
+
* Consumer-supplied side-effect callbacks for actions on the table artifact. Mirrors
|
|
249
|
+
* `ChartArtifactCallbacks` — see that interface for the shape philosophy. Every callback is
|
|
250
|
+
* optional; the artifact passes its own `TableArtifactRecord` as the only argument so consumers
|
|
251
|
+
* can derive analytics context without a per-block closure at every render site.
|
|
252
|
+
*/
|
|
253
|
+
interface TableArtifactCallbacks {
|
|
254
|
+
/** Fires when the Download CSV button is clicked. Browser-native download still happens. */
|
|
255
|
+
onDownload?: (artifact: TableArtifactRecord) => void;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Artifact-domain types — wire-protocol shapes shared between artifact components, block-services,
|
|
260
|
+
* and consumers. Splits responsibilities across three layers so each artifact kind owns its own
|
|
261
|
+
* `types.ts` and this file assembles the cross-type union + service contract:
|
|
262
|
+
*
|
|
263
|
+
* 1. **`artifact-base.ts`** — discriminator (`artifactTypes`), `ArtifactBase<TType, TConfig>`, and
|
|
264
|
+
* `ArtifactDataRow`. Pulled out so each per-type `types.ts` and this assembler can depend on
|
|
265
|
+
* one canonical base without a circular module graph.
|
|
266
|
+
* 2. **`<type>-artifact/types.ts`** — per-artifact-type records, configs, labels, and defaults.
|
|
267
|
+
* Variant-specific types (e.g. `LineChartConfig`) live in even deeper per-variant service files.
|
|
268
|
+
* 3. **This file** — the cross-type `ArtifactRecord` union, the labels map keyed by artifact type,
|
|
269
|
+
* and the `ArtifactService<TArtifact, TLabels>` registry contract used by the dispatcher.
|
|
270
|
+
*
|
|
271
|
+
* Mirrored from the agent / io-server contract — see the `chat-typed-content-blocks-and-artifacts`
|
|
272
|
+
* plan, §6.4 (table contract).
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Discriminated union of all supported artifacts. Extension pattern: add the new branch here AND
|
|
277
|
+
* in the `ArtifactServices` map (single source of truth for the type→component mapping). Older
|
|
278
|
+
* clay versions that don't know about a new type silently render nothing — see `ArtifactRefBlock`
|
|
279
|
+
* guard.
|
|
280
|
+
*/
|
|
281
|
+
type ArtifactRecord = TableArtifactRecord | ChartArtifactRecord;
|
|
282
|
+
/**
|
|
283
|
+
* Type-level lookup from an `ArtifactRecord` branch to its labels / callbacks slice. The block
|
|
284
|
+
* layer already carries the discriminator on `artifact.type`, so the renderer-side `labels` and
|
|
285
|
+
* `callbacks` props expose exactly one type's slice — never a union-bag keyed by type. Consumers
|
|
286
|
+
* emit a flat object; the dispatcher narrows it implicitly via `TArtifact`.
|
|
287
|
+
*/
|
|
288
|
+
type ArtifactLabelsOf<TArtifact extends ArtifactRecord> = TArtifact extends ChartArtifactRecord ? ChartArtifactLabels : TArtifact extends TableArtifactRecord ? TableArtifactLabels : never;
|
|
289
|
+
/** Sibling to `ArtifactLabelsOf` — callbacks slice matching the artifact branch. */
|
|
290
|
+
type ArtifactCallbacksOf<TArtifact extends ArtifactRecord> = TArtifact extends ChartArtifactRecord ? ChartArtifactCallbacks : TArtifact extends TableArtifactRecord ? TableArtifactCallbacks : never;
|
|
291
|
+
/**
|
|
292
|
+
* Props every concrete artifact component receives from the dispatcher.
|
|
293
|
+
*
|
|
294
|
+
* `labels` and `callbacks` are the renderer's OWN flat slice — narrowed by `TArtifact` so a
|
|
295
|
+
* `ChartArtifact` reads `ChartArtifactLabels` directly. The block layer (`ArtifactRefBlockRecord`)
|
|
296
|
+
* is a *distributed* union over `ArtifactRecord` branches, so wrong-shape labels for a given
|
|
297
|
+
* artifact.type are caught at the consumer's construction site — not silently forwarded here.
|
|
298
|
+
*/
|
|
299
|
+
interface ArtifactServiceProps<TArtifact extends ArtifactRecord = ArtifactRecord> {
|
|
300
|
+
/** The artifact metadata (config + presigned URL). */
|
|
301
|
+
artifact: TArtifact;
|
|
302
|
+
/**
|
|
303
|
+
* Optional localized labels for this artifact's action buttons + status messages. Per-key
|
|
304
|
+
* `Partial` merge against `DEFAULT_*_ARTIFACT_LABELS` — anything omitted falls back to English.
|
|
305
|
+
*/
|
|
306
|
+
labels?: Partial<ArtifactLabelsOf<TArtifact>>;
|
|
307
|
+
/**
|
|
308
|
+
* Optional side-effect callbacks for actions on this artifact — for analytics / observability
|
|
309
|
+
* hooks (e.g. tracking a download event). Callbacks fire alongside the default browser
|
|
310
|
+
* behaviour and do not replace it.
|
|
311
|
+
*/
|
|
312
|
+
callbacks?: Partial<ArtifactCallbacksOf<TArtifact>>;
|
|
313
|
+
}
|
|
314
|
+
/** Per-artifact-type service — registry entry that pairs a discriminator with its concrete component. */
|
|
315
|
+
interface ArtifactService<TArtifact extends ArtifactRecord = ArtifactRecord> {
|
|
316
|
+
/** Discriminator value this service handles. */
|
|
317
|
+
type: (typeof artifactTypes)[keyof typeof artifactTypes];
|
|
318
|
+
/** React component that renders an artifact of this type — composes ai-elements primitives
|
|
319
|
+
* (`Artifact`, `ArtifactHeader`, `ArtifactTitle`, `ArtifactActions`, `ArtifactContent`) directly. */
|
|
320
|
+
Component: ComponentType<ArtifactServiceProps<TArtifact>>;
|
|
321
|
+
/**
|
|
322
|
+
* Returns a plain-text / markdown string suitable for clipboard copy.
|
|
323
|
+
*
|
|
324
|
+
* Called by `ArtifactRefBlockService.toClipboardText` when the user copies a message that
|
|
325
|
+
* contains this artifact. Must be pure and synchronous.
|
|
326
|
+
*/
|
|
327
|
+
toClipboardText: (artifact: TArtifact) => string;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export { type ArtifactCallbacksOf as A, type BarChartConfig as B, type ChartArtifactLabels as C, DEFAULT_CHART_ARTIFACT_LABELS as D, type LineChartConfig as L, type PieChartConfig as P, type TableArtifactLabels as T, type ArtifactDataRow as a, type ArtifactLabelsOf as b, type ArtifactRecord as c, type ArtifactService as d, type ArtifactServiceProps as e, type ArtifactType as f, type ChartArtifactRecord as g, type ChartConfig as h, type ChartStats as i, DEFAULT_TABLE_ARTIFACT_LABELS as j, type TableArtifactRecord as k, type TableColumn as l, type TableConfig as m, type TableRow as n, type TableStats as o, artifactTypes as p };
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapesos/clay",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"main": "./dist/index.cjs",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@changesets/changelog-github": "^0.6.0",
|
|
8
8
|
"@changesets/cli": "^2.30.0",
|
|
9
9
|
"@eslint/js": "^10.0.1",
|
|
10
|
+
"@fontsource-variable/crimson-pro": "^5.2.8",
|
|
11
|
+
"@fontsource-variable/geist": "^5.2.9",
|
|
10
12
|
"@playwright/test": "^1.58.2",
|
|
11
13
|
"@storybook/addon-a11y": "^10.2.19",
|
|
12
14
|
"@storybook/addon-docs": "^10.2.19",
|
|
@@ -33,6 +35,7 @@
|
|
|
33
35
|
"lefthook": "^2.1.1",
|
|
34
36
|
"react": "^19.2.4",
|
|
35
37
|
"react-dom": "^19.2.4",
|
|
38
|
+
"recharts": "^3.8.1",
|
|
36
39
|
"storybook": "^10.2.13",
|
|
37
40
|
"styled-components": "^6.3.11",
|
|
38
41
|
"tailwindcss": "^4",
|
|
@@ -46,8 +49,14 @@
|
|
|
46
49
|
"peerDependencies": {
|
|
47
50
|
"react": "^17 || ^18 || ^19",
|
|
48
51
|
"react-dom": "^17 || ^18 || ^19",
|
|
52
|
+
"recharts": "^3",
|
|
49
53
|
"styled-components": "^5 || ^6"
|
|
50
54
|
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"recharts": {
|
|
57
|
+
"optional": true
|
|
58
|
+
}
|
|
59
|
+
},
|
|
51
60
|
"exports": {
|
|
52
61
|
".": {
|
|
53
62
|
"types": "./dist/index.d.ts",
|
|
@@ -75,6 +84,11 @@
|
|
|
75
84
|
"import": "./dist/artifacts.js",
|
|
76
85
|
"require": "./dist/artifacts.cjs"
|
|
77
86
|
},
|
|
87
|
+
"./chart": {
|
|
88
|
+
"types": "./dist/chart.d.ts",
|
|
89
|
+
"import": "./dist/chart.js",
|
|
90
|
+
"require": "./dist/chart.cjs"
|
|
91
|
+
},
|
|
78
92
|
"./table": {
|
|
79
93
|
"types": "./dist/table.d.ts",
|
|
80
94
|
"import": "./dist/table.js",
|
|
@@ -105,6 +119,11 @@
|
|
|
105
119
|
"import": "./dist/utils.js",
|
|
106
120
|
"require": "./dist/utils.cjs"
|
|
107
121
|
},
|
|
122
|
+
"./capture": {
|
|
123
|
+
"types": "./dist/capture.d.ts",
|
|
124
|
+
"import": "./dist/capture.js",
|
|
125
|
+
"require": "./dist/capture.cjs"
|
|
126
|
+
},
|
|
108
127
|
"./button": {
|
|
109
128
|
"types": "./dist/button.d.ts",
|
|
110
129
|
"import": "./dist/button.js",
|
|
@@ -129,8 +148,9 @@
|
|
|
129
148
|
"registry": "https://registry.npmjs.org/"
|
|
130
149
|
},
|
|
131
150
|
"scripts": {
|
|
132
|
-
"build": "bun run gen:theme && tsup && bun run build:css",
|
|
151
|
+
"build": "bun run gen:font && bun run gen:theme && tsup && bun run build:css",
|
|
133
152
|
"build:css": "tailwindcss -i src/styles/tailwind.css -o dist/blocks.css --minify",
|
|
153
|
+
"gen:font": "bun run scripts/generate-font-embed.ts",
|
|
134
154
|
"gen:theme": "bun run scripts/generate-theme-tokens.ts",
|
|
135
155
|
"dev": "tsup --watch",
|
|
136
156
|
"storybook": "storybook dev -p 6006",
|
|
@@ -153,8 +173,10 @@
|
|
|
153
173
|
"type": "module",
|
|
154
174
|
"types": "./dist/index.d.ts",
|
|
155
175
|
"dependencies": {
|
|
176
|
+
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
156
177
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
157
178
|
"clsx": "^2.1.1",
|
|
179
|
+
"html-to-image": "^1.11.13",
|
|
158
180
|
"lottie-react": "^2.4.1",
|
|
159
181
|
"papaparse": "^5.5.3",
|
|
160
182
|
"react-markdown": "^8.0.7",
|