@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
package/README.md
CHANGED
|
@@ -33,6 +33,8 @@ Clay is tree-shakeable with multiple entry points — import only what you need.
|
|
|
33
33
|
| `@shapesos/clay/tokens` | Colors, typography, font families | None (pure JS) |
|
|
34
34
|
| `@shapesos/clay/chat` | Chat compound components + types | React, styled-components |
|
|
35
35
|
| `@shapesos/clay/blocks` | Typed content blocks (Block, BlockServices, BlockContext) | React, styled-components |
|
|
36
|
+
| `@shapesos/clay/artifacts`| Per-type artifact renderers + ArtifactServices map (TABLE, CHART) | React, styled-components, recharts (optional, only for CHART) |
|
|
37
|
+
| `@shapesos/clay/chart` | Standalone chart library (`<BarChart>`, `<LineChart>`, `<PieChart>` + composable primitives) | React, recharts |
|
|
36
38
|
| `@shapesos/clay/icon` | Icon, IconButton components + types | React, styled-components |
|
|
37
39
|
| `@shapesos/clay/lottie` | Lottie animation component + types | React, styled-components |
|
|
38
40
|
| `@shapesos/clay` | Everything (convenience re-export) | React, styled-components |
|
|
@@ -176,6 +178,64 @@ The wire shape (`{ type, payload }`) matches `dreamteam-io-server` / `shapes-age
|
|
|
176
178
|
|
|
177
179
|
---
|
|
178
180
|
|
|
181
|
+
## Artifacts
|
|
182
|
+
|
|
183
|
+
Per-type renderers for the artifact union (`TABLE`, `CHART`) plus the `ArtifactServices` registry. The block layer's `ARTIFACT_REF` block consumes this map to dispatch the inlined artifact to its concrete component; non-block surfaces can render an artifact directly.
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
import { TableArtifact, ChartArtifact, ArtifactServices } from "@shapesos/clay/artifacts";
|
|
187
|
+
import type {
|
|
188
|
+
ArtifactCallbacksMap,
|
|
189
|
+
ArtifactLabelsMap,
|
|
190
|
+
ChartArtifactRecord,
|
|
191
|
+
TableArtifactRecord,
|
|
192
|
+
} from "@shapesos/clay/artifacts";
|
|
193
|
+
|
|
194
|
+
// Direct render — picks the renderer at the call site.
|
|
195
|
+
<ChartArtifact
|
|
196
|
+
artifact={chartRecord}
|
|
197
|
+
labels={{ CHART: { download: "Download CSV", /* … */ } }}
|
|
198
|
+
callbacks={{ CHART: { onDownload: (artifact) => analytics.track("chart_downloaded", artifact) } }}
|
|
199
|
+
/>
|
|
200
|
+
|
|
201
|
+
// Registry-driven dispatch — block layer does this.
|
|
202
|
+
const { Component } = ArtifactServices[artifact.type];
|
|
203
|
+
<Component artifact={artifact} labels={labels} callbacks={callbacks} />
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Every artifact reads from a CSV at `artifact.protectedAsset.presignedUrl`. Loading / error / unavailable / empty states surface as inline status messages with consumer-translated copy from the `labels` prop (`Partial<ArtifactLabelsMap>`). Action callbacks (today: `onDownload`) wire through the `callbacks` prop (`Partial<ArtifactCallbacksMap>`) — each callback receives the artifact record so you can derive analytics context. Both props get passed through the block layer via `block.payload.labels` and `block.payload.callbacks`.
|
|
207
|
+
|
|
208
|
+
The `CHART` artifact requires `recharts` as a peer dep; bring your own if you import this entry. Adding a new artifact type is one `ArtifactService` registration plus a concrete component — no changes to the block dispatcher.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Chart
|
|
213
|
+
|
|
214
|
+
Standalone chart library — usable beyond the artifact path. Three pre-composed high-level components with smart defaults, plus composable primitives for custom recharts trees.
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
import { BarChart, LineChart, PieChart } from "@shapesos/clay/chart";
|
|
218
|
+
|
|
219
|
+
<BarChart
|
|
220
|
+
data={[{ month: "Jan", us: 120, uk: 60 }, { month: "Feb", us: 132, uk: 64 }]}
|
|
221
|
+
xKey="month"
|
|
222
|
+
series={[{ key: "us", label: "US" }, { key: "uk", label: "UK" }]}
|
|
223
|
+
stacked
|
|
224
|
+
/>
|
|
225
|
+
|
|
226
|
+
<PieChart
|
|
227
|
+
data={departments}
|
|
228
|
+
categoryKey="department"
|
|
229
|
+
valueKey="headcount"
|
|
230
|
+
// Localise the "Others" bucket detection in non-English UIs:
|
|
231
|
+
othersCategoryLabels={["אחרים"]}
|
|
232
|
+
/>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Smart defaults: legend auto-hides for single-series charts; legend at top; x-axis labels truncate by category count; pie's "Others" bucket pins to the end of the sweep in neutral grey. Override any default with the named prop. Bring `recharts` as a peer dep.
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
179
239
|
## Icon
|
|
180
240
|
|
|
181
241
|
Render SVG icons with consistent sizing, and icon buttons with selection states.
|