@shapesos/clay 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artifacts.cjs +695 -246
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.d.cts +133 -5
- package/dist/artifacts.d.ts +133 -5
- package/dist/artifacts.js +7 -2
- package/dist/blocks.cjs +717 -259
- package/dist/blocks.cjs.map +1 -1
- package/dist/blocks.css +1 -1
- package/dist/blocks.d.cts +8 -10
- package/dist/blocks.d.ts +8 -10
- package/dist/blocks.js +3 -2
- 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/chat.cjs +736 -287
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.d.cts +2 -2
- package/dist/chat.d.ts +2 -2
- package/dist/chat.js +4 -3
- package/dist/{chunk-Z5JWF24N.js → chunk-DT44KNCV.js} +367 -82
- 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-36CB624W.js → chunk-QAK7NM5F.js} +15 -3
- package/dist/chunk-QAK7NM5F.js.map +1 -0
- package/dist/chunk-RSRNSWJN.js +1 -0
- package/dist/chunk-RSRNSWJN.js.map +1 -0
- package/dist/{chunk-FFX3CAOX.js → chunk-YSSLTXZG.js} +3 -3
- package/dist/dom-to-image-NATF3446.js +21 -0
- package/dist/dom-to-image-NATF3446.js.map +1 -0
- package/dist/index.cjs +775 -317
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -4
- package/dist/{types-C0BvwliI.d.cts → types-BzXPBy6s.d.cts} +39 -41
- package/dist/{types-uPfn67Dc.d.ts → types-CW45GBXl.d.cts} +25 -13
- package/dist/{types-DCutaXjZ.d.cts → types-D1b8v7EY.d.ts} +25 -13
- package/dist/{types-C5bFH4v3.d.ts → types-GCkXbyFm.d.ts} +39 -41
- package/package.json +12 -2
- package/dist/chunk-36CB624W.js.map +0 -1
- package/dist/chunk-AQEJRMRN.js +0 -1
- package/dist/chunk-Z5JWF24N.js.map +0 -1
- /package/dist/{chunk-AQEJRMRN.js.map → capture.js.map} +0 -0
- /package/dist/{chunk-FFX3CAOX.js.map → chunk-YSSLTXZG.js.map} +0 -0
package/dist/artifacts.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as
|
|
3
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { f as ArtifactType, d as ArtifactService, c as ArtifactRecord, e as ArtifactServiceProps, k as TableArtifactRecord, g as ChartArtifactRecord } from './types-BzXPBy6s.cjs';
|
|
2
|
+
export { A as ArtifactCallbacksOf, a as ArtifactDataRow, b as ArtifactLabelsOf, B as BarChartConfig, C as ChartArtifactLabels, h as ChartConfig, i as ChartStats, D as DEFAULT_CHART_ARTIFACT_LABELS, j as DEFAULT_TABLE_ARTIFACT_LABELS, L as LineChartConfig, P as PieChartConfig, T as TableArtifactLabels, l as TableColumn, m as TableConfig, n as TableRow, o as TableStats, p as artifactTypes } from './types-BzXPBy6s.cjs';
|
|
3
|
+
import { ReactNode, RefObject } from 'react';
|
|
4
4
|
export { C as ChartSeries, a as ChartVariant } from './types-B2aYk82c.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -57,6 +57,129 @@ declare function ArtifactDownloadButton({ href, label, onClick, }: ArtifactDownl
|
|
|
57
57
|
*/
|
|
58
58
|
declare function isSafeDownloadUrl(url: string): boolean;
|
|
59
59
|
|
|
60
|
+
/** Props for `ArtifactCopyAsImageButton`. */
|
|
61
|
+
interface ArtifactCopyAsImageButtonProps {
|
|
62
|
+
/**
|
|
63
|
+
* Ref to the DOM node to capture as an image. Typically the artifact card root. The capture
|
|
64
|
+
* walks the subtree and includes everything except elements marked with
|
|
65
|
+
* `data-clay-capture-exclude` (the action toolbar should carry that marker so it doesn't
|
|
66
|
+
* capture itself).
|
|
67
|
+
*/
|
|
68
|
+
targetRef: RefObject<HTMLElement | null>;
|
|
69
|
+
/**
|
|
70
|
+
* Tooltip text + `aria-label` for the idle state. Defaults to `"Copy Image"`. Per-type
|
|
71
|
+
* artifact orchestrators pass a translated value via their own `labels` prop so the button
|
|
72
|
+
* reads in the user's language. The transient working / success / error tooltips remain
|
|
73
|
+
* English-hardcoded — they flash for ~1.5s and the cost of translating them is rarely worth it.
|
|
74
|
+
*/
|
|
75
|
+
label?: string;
|
|
76
|
+
/** Disable the button (e.g. while artifact data is still loading and the captured image would
|
|
77
|
+
* be empty / partial). */
|
|
78
|
+
disabled?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Optional callback fired on click — runs alongside the copy attempt itself. Used for analytics
|
|
81
|
+
* / observability hooks; per-type artifact orchestrators wire this from their `callbacks` prop.
|
|
82
|
+
* Fires regardless of whether the copy ultimately succeeds (the result is reported via the
|
|
83
|
+
* button's own state flash).
|
|
84
|
+
*/
|
|
85
|
+
onClick?: () => void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Reusable "copy artifact as image" button for artifact headers. Drop it inside
|
|
90
|
+
* `<ArtifactActions>` alongside `ArtifactDownloadButton`.
|
|
91
|
+
*
|
|
92
|
+
* Captures the DOM node referenced by `targetRef`, rasterises it to PNG, and writes the result
|
|
93
|
+
* to the system clipboard. Must be invoked from a user gesture (the button click is enough).
|
|
94
|
+
*
|
|
95
|
+
* The button flashes a check icon on success and an alert icon on failure, reverting to its
|
|
96
|
+
* idle photo icon after ~1.5s. While capturing, it disables itself and shows a spinner.
|
|
97
|
+
*
|
|
98
|
+
* On failure, the rejection is logged via `console.warn` so production errors are visible in
|
|
99
|
+
* observability tooling (any consumer wiring a global console transport — Sentry, Datadog,
|
|
100
|
+
* Logfire — picks them up). The user-visible affordance is the error-state flash + tooltip.
|
|
101
|
+
*/
|
|
102
|
+
declare function ArtifactCopyAsImageButton({ targetRef, label, disabled, onClick, }: ArtifactCopyAsImageButtonProps): ReactNode;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Per-format props for the CSV menu item. Pass within `actions.csv` to expose the item;
|
|
106
|
+
* omit the slot entirely to hide it. The item is also auto-hidden if `href` doesn't satisfy
|
|
107
|
+
* the `http(s):` safety guard — mirrors `ArtifactDownloadButton`'s defense against
|
|
108
|
+
* `javascript:` / `data:` URIs smuggled into a presigned URL field.
|
|
109
|
+
*/
|
|
110
|
+
interface ArtifactDownloadMenuCsvAction {
|
|
111
|
+
/** Presigned URL backing the CSV download. The browser uses whatever filename the server
|
|
112
|
+
* supplies via `Content-Disposition`. */
|
|
113
|
+
href: string;
|
|
114
|
+
/** Label for the menu item. Defaults to `"Download CSV"`. */
|
|
115
|
+
label?: string;
|
|
116
|
+
/** Optional analytics callback. Fires alongside the browser-native download navigation. */
|
|
117
|
+
onSelect?: () => void;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Per-format props for the PNG menu item. Pass within `actions.png` to expose the item; omit
|
|
121
|
+
* the slot entirely to hide it. PNG capture rasterises `targetRef.current` via
|
|
122
|
+
* `@shapesos/clay/capture`'s `downloadNodeAsPng`.
|
|
123
|
+
*/
|
|
124
|
+
interface ArtifactDownloadMenuPngAction {
|
|
125
|
+
/** Ref to the DOM node to rasterise. Typically the artifact card root. The capture walks the
|
|
126
|
+
* subtree and excludes anything marked with `data-clay-capture-exclude`. */
|
|
127
|
+
targetRef: RefObject<HTMLElement | null>;
|
|
128
|
+
/** Suggested filename for the saved file (without extension — the menu appends `.png`).
|
|
129
|
+
* Defaults to `"artifact"`. Pass artifact-title-derived names for recognisable downloads. */
|
|
130
|
+
filename?: string;
|
|
131
|
+
/** Label for the menu item. Defaults to `"Download PNG"`. */
|
|
132
|
+
label?: string;
|
|
133
|
+
/** Disable the menu item (e.g. while artifact data is still loading). Default: `false`. */
|
|
134
|
+
disabled?: boolean;
|
|
135
|
+
/** Optional analytics callback. Fires alongside the rasterise + download — regardless of
|
|
136
|
+
* whether the download ultimately succeeds. */
|
|
137
|
+
onSelect?: () => void;
|
|
138
|
+
}
|
|
139
|
+
/** Props for `ArtifactDownloadMenu`. */
|
|
140
|
+
interface ArtifactDownloadMenuProps {
|
|
141
|
+
/**
|
|
142
|
+
* Format-keyed bag of action descriptors. Each entry exposes one menu item; omit the slot
|
|
143
|
+
* to hide it. Grouping per-format props this way (rather than spreading flat
|
|
144
|
+
* `csvHref` / `pngFilename` / `pngLabel` props at the top level) keeps the consumer's call
|
|
145
|
+
* site readable as more formats land — a future `actions.svg` or `actions.xlsx` follows the
|
|
146
|
+
* same shape without growing the prop list at the call site.
|
|
147
|
+
*
|
|
148
|
+
* Caller responsibility: include at least one action. An empty `{}` renders a menu with no
|
|
149
|
+
* items, which has no UX value — orchestrators should gate the entire `<ArtifactDownloadMenu>`
|
|
150
|
+
* mount on "at least one format reachable" before passing this prop.
|
|
151
|
+
*
|
|
152
|
+
* **Future generalisation** — if more action shapes land (SVG, XLSX, share-link, …), consider
|
|
153
|
+
* lifting these into a shared `ArtifactAction` discriminated union that both this menu and
|
|
154
|
+
* a future `<ArtifactActions>` toolbar can render generically. Postponed until a second
|
|
155
|
+
* non-Download action type appears — premature abstraction with two flavours.
|
|
156
|
+
*/
|
|
157
|
+
actions: {
|
|
158
|
+
/** CSV download via presigned URL. Browser-native navigation; consumer i18n + analytics. */
|
|
159
|
+
csv?: ArtifactDownloadMenuCsvAction;
|
|
160
|
+
/** PNG download via DOM-to-image rasterise. Browser-only (capture entry). */
|
|
161
|
+
png?: ArtifactDownloadMenuPngAction;
|
|
162
|
+
};
|
|
163
|
+
/** Tooltip + `aria-label` for the trigger button. Defaults to `"Download"`. */
|
|
164
|
+
triggerLabel?: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Reusable "Download" affordance for artifact headers. Renders as a single icon-button trigger;
|
|
169
|
+
* clicking it opens a menu with one item per format the caller passes via `actions`. Today's
|
|
170
|
+
* formats: CSV (presigned URL) + PNG (DOM-to-image rasterise). Future formats (SVG, XLSX, …)
|
|
171
|
+
* slot into the same `actions` bag without touching the call-site prop list.
|
|
172
|
+
*
|
|
173
|
+
* Drop this inside `<ArtifactActions>` in any per-type artifact orchestrator that supports
|
|
174
|
+
* multiple download formats. For single-format artifacts (e.g. a future table artifact that
|
|
175
|
+
* only ships CSV), prefer the simpler `ArtifactDownloadButton` instead.
|
|
176
|
+
*
|
|
177
|
+
* The menu uses Radix's `DropdownMenu` primitive (vendored in `src/components/ui/dropdown-menu.tsx`)
|
|
178
|
+
* with `asChild` on the trigger so clay's `IconButton` is the real button — preserves the
|
|
179
|
+
* design-system look across all action affordances.
|
|
180
|
+
*/
|
|
181
|
+
declare function ArtifactDownloadMenu({ actions, triggerLabel, }: ArtifactDownloadMenuProps): ReactNode;
|
|
182
|
+
|
|
60
183
|
/**
|
|
61
184
|
* Orchestrator for the `table`-typed artifact.
|
|
62
185
|
*
|
|
@@ -80,10 +203,15 @@ declare function TableArtifact({ artifact, labels, callbacks }: ArtifactServiceP
|
|
|
80
203
|
* Variant dispatch lives inside `ChartArtifactContent` so the orchestrator can focus on the
|
|
81
204
|
* data lifecycle and the chrome.
|
|
82
205
|
*
|
|
83
|
-
* Labels for action buttons (download,
|
|
206
|
+
* Labels for action buttons (download, copy-as-image) are pulled from the optional `labels`
|
|
84
207
|
* prop with per-key fallback to `DEFAULT_CHART_ARTIFACT_LABELS`. Consumers translate via their
|
|
85
208
|
* own i18n layer and pass the bag; non-i18n consumers omit it and get English defaults.
|
|
209
|
+
*
|
|
210
|
+
* `ArtifactCopyAsImageButton` snapshots the card root to PNG. The ref attaches directly to the
|
|
211
|
+
* `<Artifact>` primitive (which forwards refs as of this PR), so the captured DOM contains the
|
|
212
|
+
* artifact chrome exactly — no extra wrapper div, no layout-contract drift. The action toolbar
|
|
213
|
+
* carries `data-clay-capture-exclude` so its own buttons don't end up in the captured image.
|
|
86
214
|
*/
|
|
87
215
|
declare function ChartArtifact({ artifact, labels, callbacks }: ArtifactServiceProps<ChartArtifactRecord>): ReactNode;
|
|
88
216
|
|
|
89
|
-
export { ArtifactDownloadButton, type ArtifactDownloadButtonProps, ArtifactRecord, ArtifactService, ArtifactServiceProps, ArtifactServices, ArtifactType, ChartArtifact, ChartArtifactRecord, TableArtifact, TableArtifactRecord, artifactToClipboardText, isSafeDownloadUrl };
|
|
217
|
+
export { ArtifactCopyAsImageButton, type ArtifactCopyAsImageButtonProps, ArtifactDownloadButton, type ArtifactDownloadButtonProps, ArtifactDownloadMenu, type ArtifactDownloadMenuCsvAction, type ArtifactDownloadMenuPngAction, type ArtifactDownloadMenuProps, ArtifactRecord, ArtifactService, ArtifactServiceProps, ArtifactServices, ArtifactType, ChartArtifact, ChartArtifactRecord, TableArtifact, TableArtifactRecord, artifactToClipboardText, isSafeDownloadUrl };
|
package/dist/artifacts.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as
|
|
3
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { f as ArtifactType, d as ArtifactService, c as ArtifactRecord, e as ArtifactServiceProps, k as TableArtifactRecord, g as ChartArtifactRecord } from './types-GCkXbyFm.js';
|
|
2
|
+
export { A as ArtifactCallbacksOf, a as ArtifactDataRow, b as ArtifactLabelsOf, B as BarChartConfig, C as ChartArtifactLabels, h as ChartConfig, i as ChartStats, D as DEFAULT_CHART_ARTIFACT_LABELS, j as DEFAULT_TABLE_ARTIFACT_LABELS, L as LineChartConfig, P as PieChartConfig, T as TableArtifactLabels, l as TableColumn, m as TableConfig, n as TableRow, o as TableStats, p as artifactTypes } from './types-GCkXbyFm.js';
|
|
3
|
+
import { ReactNode, RefObject } from 'react';
|
|
4
4
|
export { C as ChartSeries, a as ChartVariant } from './types-B2aYk82c.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -57,6 +57,129 @@ declare function ArtifactDownloadButton({ href, label, onClick, }: ArtifactDownl
|
|
|
57
57
|
*/
|
|
58
58
|
declare function isSafeDownloadUrl(url: string): boolean;
|
|
59
59
|
|
|
60
|
+
/** Props for `ArtifactCopyAsImageButton`. */
|
|
61
|
+
interface ArtifactCopyAsImageButtonProps {
|
|
62
|
+
/**
|
|
63
|
+
* Ref to the DOM node to capture as an image. Typically the artifact card root. The capture
|
|
64
|
+
* walks the subtree and includes everything except elements marked with
|
|
65
|
+
* `data-clay-capture-exclude` (the action toolbar should carry that marker so it doesn't
|
|
66
|
+
* capture itself).
|
|
67
|
+
*/
|
|
68
|
+
targetRef: RefObject<HTMLElement | null>;
|
|
69
|
+
/**
|
|
70
|
+
* Tooltip text + `aria-label` for the idle state. Defaults to `"Copy Image"`. Per-type
|
|
71
|
+
* artifact orchestrators pass a translated value via their own `labels` prop so the button
|
|
72
|
+
* reads in the user's language. The transient working / success / error tooltips remain
|
|
73
|
+
* English-hardcoded — they flash for ~1.5s and the cost of translating them is rarely worth it.
|
|
74
|
+
*/
|
|
75
|
+
label?: string;
|
|
76
|
+
/** Disable the button (e.g. while artifact data is still loading and the captured image would
|
|
77
|
+
* be empty / partial). */
|
|
78
|
+
disabled?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Optional callback fired on click — runs alongside the copy attempt itself. Used for analytics
|
|
81
|
+
* / observability hooks; per-type artifact orchestrators wire this from their `callbacks` prop.
|
|
82
|
+
* Fires regardless of whether the copy ultimately succeeds (the result is reported via the
|
|
83
|
+
* button's own state flash).
|
|
84
|
+
*/
|
|
85
|
+
onClick?: () => void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Reusable "copy artifact as image" button for artifact headers. Drop it inside
|
|
90
|
+
* `<ArtifactActions>` alongside `ArtifactDownloadButton`.
|
|
91
|
+
*
|
|
92
|
+
* Captures the DOM node referenced by `targetRef`, rasterises it to PNG, and writes the result
|
|
93
|
+
* to the system clipboard. Must be invoked from a user gesture (the button click is enough).
|
|
94
|
+
*
|
|
95
|
+
* The button flashes a check icon on success and an alert icon on failure, reverting to its
|
|
96
|
+
* idle photo icon after ~1.5s. While capturing, it disables itself and shows a spinner.
|
|
97
|
+
*
|
|
98
|
+
* On failure, the rejection is logged via `console.warn` so production errors are visible in
|
|
99
|
+
* observability tooling (any consumer wiring a global console transport — Sentry, Datadog,
|
|
100
|
+
* Logfire — picks them up). The user-visible affordance is the error-state flash + tooltip.
|
|
101
|
+
*/
|
|
102
|
+
declare function ArtifactCopyAsImageButton({ targetRef, label, disabled, onClick, }: ArtifactCopyAsImageButtonProps): ReactNode;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Per-format props for the CSV menu item. Pass within `actions.csv` to expose the item;
|
|
106
|
+
* omit the slot entirely to hide it. The item is also auto-hidden if `href` doesn't satisfy
|
|
107
|
+
* the `http(s):` safety guard — mirrors `ArtifactDownloadButton`'s defense against
|
|
108
|
+
* `javascript:` / `data:` URIs smuggled into a presigned URL field.
|
|
109
|
+
*/
|
|
110
|
+
interface ArtifactDownloadMenuCsvAction {
|
|
111
|
+
/** Presigned URL backing the CSV download. The browser uses whatever filename the server
|
|
112
|
+
* supplies via `Content-Disposition`. */
|
|
113
|
+
href: string;
|
|
114
|
+
/** Label for the menu item. Defaults to `"Download CSV"`. */
|
|
115
|
+
label?: string;
|
|
116
|
+
/** Optional analytics callback. Fires alongside the browser-native download navigation. */
|
|
117
|
+
onSelect?: () => void;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Per-format props for the PNG menu item. Pass within `actions.png` to expose the item; omit
|
|
121
|
+
* the slot entirely to hide it. PNG capture rasterises `targetRef.current` via
|
|
122
|
+
* `@shapesos/clay/capture`'s `downloadNodeAsPng`.
|
|
123
|
+
*/
|
|
124
|
+
interface ArtifactDownloadMenuPngAction {
|
|
125
|
+
/** Ref to the DOM node to rasterise. Typically the artifact card root. The capture walks the
|
|
126
|
+
* subtree and excludes anything marked with `data-clay-capture-exclude`. */
|
|
127
|
+
targetRef: RefObject<HTMLElement | null>;
|
|
128
|
+
/** Suggested filename for the saved file (without extension — the menu appends `.png`).
|
|
129
|
+
* Defaults to `"artifact"`. Pass artifact-title-derived names for recognisable downloads. */
|
|
130
|
+
filename?: string;
|
|
131
|
+
/** Label for the menu item. Defaults to `"Download PNG"`. */
|
|
132
|
+
label?: string;
|
|
133
|
+
/** Disable the menu item (e.g. while artifact data is still loading). Default: `false`. */
|
|
134
|
+
disabled?: boolean;
|
|
135
|
+
/** Optional analytics callback. Fires alongside the rasterise + download — regardless of
|
|
136
|
+
* whether the download ultimately succeeds. */
|
|
137
|
+
onSelect?: () => void;
|
|
138
|
+
}
|
|
139
|
+
/** Props for `ArtifactDownloadMenu`. */
|
|
140
|
+
interface ArtifactDownloadMenuProps {
|
|
141
|
+
/**
|
|
142
|
+
* Format-keyed bag of action descriptors. Each entry exposes one menu item; omit the slot
|
|
143
|
+
* to hide it. Grouping per-format props this way (rather than spreading flat
|
|
144
|
+
* `csvHref` / `pngFilename` / `pngLabel` props at the top level) keeps the consumer's call
|
|
145
|
+
* site readable as more formats land — a future `actions.svg` or `actions.xlsx` follows the
|
|
146
|
+
* same shape without growing the prop list at the call site.
|
|
147
|
+
*
|
|
148
|
+
* Caller responsibility: include at least one action. An empty `{}` renders a menu with no
|
|
149
|
+
* items, which has no UX value — orchestrators should gate the entire `<ArtifactDownloadMenu>`
|
|
150
|
+
* mount on "at least one format reachable" before passing this prop.
|
|
151
|
+
*
|
|
152
|
+
* **Future generalisation** — if more action shapes land (SVG, XLSX, share-link, …), consider
|
|
153
|
+
* lifting these into a shared `ArtifactAction` discriminated union that both this menu and
|
|
154
|
+
* a future `<ArtifactActions>` toolbar can render generically. Postponed until a second
|
|
155
|
+
* non-Download action type appears — premature abstraction with two flavours.
|
|
156
|
+
*/
|
|
157
|
+
actions: {
|
|
158
|
+
/** CSV download via presigned URL. Browser-native navigation; consumer i18n + analytics. */
|
|
159
|
+
csv?: ArtifactDownloadMenuCsvAction;
|
|
160
|
+
/** PNG download via DOM-to-image rasterise. Browser-only (capture entry). */
|
|
161
|
+
png?: ArtifactDownloadMenuPngAction;
|
|
162
|
+
};
|
|
163
|
+
/** Tooltip + `aria-label` for the trigger button. Defaults to `"Download"`. */
|
|
164
|
+
triggerLabel?: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Reusable "Download" affordance for artifact headers. Renders as a single icon-button trigger;
|
|
169
|
+
* clicking it opens a menu with one item per format the caller passes via `actions`. Today's
|
|
170
|
+
* formats: CSV (presigned URL) + PNG (DOM-to-image rasterise). Future formats (SVG, XLSX, …)
|
|
171
|
+
* slot into the same `actions` bag without touching the call-site prop list.
|
|
172
|
+
*
|
|
173
|
+
* Drop this inside `<ArtifactActions>` in any per-type artifact orchestrator that supports
|
|
174
|
+
* multiple download formats. For single-format artifacts (e.g. a future table artifact that
|
|
175
|
+
* only ships CSV), prefer the simpler `ArtifactDownloadButton` instead.
|
|
176
|
+
*
|
|
177
|
+
* The menu uses Radix's `DropdownMenu` primitive (vendored in `src/components/ui/dropdown-menu.tsx`)
|
|
178
|
+
* with `asChild` on the trigger so clay's `IconButton` is the real button — preserves the
|
|
179
|
+
* design-system look across all action affordances.
|
|
180
|
+
*/
|
|
181
|
+
declare function ArtifactDownloadMenu({ actions, triggerLabel, }: ArtifactDownloadMenuProps): ReactNode;
|
|
182
|
+
|
|
60
183
|
/**
|
|
61
184
|
* Orchestrator for the `table`-typed artifact.
|
|
62
185
|
*
|
|
@@ -80,10 +203,15 @@ declare function TableArtifact({ artifact, labels, callbacks }: ArtifactServiceP
|
|
|
80
203
|
* Variant dispatch lives inside `ChartArtifactContent` so the orchestrator can focus on the
|
|
81
204
|
* data lifecycle and the chrome.
|
|
82
205
|
*
|
|
83
|
-
* Labels for action buttons (download,
|
|
206
|
+
* Labels for action buttons (download, copy-as-image) are pulled from the optional `labels`
|
|
84
207
|
* prop with per-key fallback to `DEFAULT_CHART_ARTIFACT_LABELS`. Consumers translate via their
|
|
85
208
|
* own i18n layer and pass the bag; non-i18n consumers omit it and get English defaults.
|
|
209
|
+
*
|
|
210
|
+
* `ArtifactCopyAsImageButton` snapshots the card root to PNG. The ref attaches directly to the
|
|
211
|
+
* `<Artifact>` primitive (which forwards refs as of this PR), so the captured DOM contains the
|
|
212
|
+
* artifact chrome exactly — no extra wrapper div, no layout-contract drift. The action toolbar
|
|
213
|
+
* carries `data-clay-capture-exclude` so its own buttons don't end up in the captured image.
|
|
86
214
|
*/
|
|
87
215
|
declare function ChartArtifact({ artifact, labels, callbacks }: ArtifactServiceProps<ChartArtifactRecord>): ReactNode;
|
|
88
216
|
|
|
89
|
-
export { ArtifactDownloadButton, type ArtifactDownloadButtonProps, ArtifactRecord, ArtifactService, ArtifactServiceProps, ArtifactServices, ArtifactType, ChartArtifact, ChartArtifactRecord, TableArtifact, TableArtifactRecord, artifactToClipboardText, isSafeDownloadUrl };
|
|
217
|
+
export { ArtifactCopyAsImageButton, type ArtifactCopyAsImageButtonProps, ArtifactDownloadButton, type ArtifactDownloadButtonProps, ArtifactDownloadMenu, type ArtifactDownloadMenuCsvAction, type ArtifactDownloadMenuPngAction, type ArtifactDownloadMenuProps, ArtifactRecord, ArtifactService, ArtifactServiceProps, ArtifactServices, ArtifactType, ChartArtifact, ChartArtifactRecord, TableArtifact, TableArtifactRecord, artifactToClipboardText, isSafeDownloadUrl };
|
package/dist/artifacts.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-RSRNSWJN.js";
|
|
2
2
|
import {
|
|
3
|
+
ArtifactCopyAsImageButton,
|
|
3
4
|
ArtifactDownloadButton,
|
|
5
|
+
ArtifactDownloadMenu,
|
|
4
6
|
ArtifactServices,
|
|
5
7
|
ChartArtifact,
|
|
6
8
|
DEFAULT_CHART_ARTIFACT_LABELS,
|
|
@@ -9,7 +11,8 @@ import {
|
|
|
9
11
|
artifactToClipboardText,
|
|
10
12
|
artifactTypes,
|
|
11
13
|
isSafeDownloadUrl
|
|
12
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-DT44KNCV.js";
|
|
15
|
+
import "./chunk-LXYCT4YO.js";
|
|
13
16
|
import "./chunk-QXGYMDIA.js";
|
|
14
17
|
import "./chunk-C77QMQNT.js";
|
|
15
18
|
import "./chunk-SV24ONND.js";
|
|
@@ -20,7 +23,9 @@ import "./chunk-OLJIJYB5.js";
|
|
|
20
23
|
import "./chunk-JF3P66JF.js";
|
|
21
24
|
import "./chunk-5WRI5ZAA.js";
|
|
22
25
|
export {
|
|
26
|
+
ArtifactCopyAsImageButton,
|
|
23
27
|
ArtifactDownloadButton,
|
|
28
|
+
ArtifactDownloadMenu,
|
|
24
29
|
ArtifactServices,
|
|
25
30
|
ChartArtifact,
|
|
26
31
|
DEFAULT_CHART_ARTIFACT_LABELS,
|