@shapesos/clay 0.11.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.
Files changed (56) hide show
  1. package/README.md +60 -0
  2. package/dist/artifacts.cjs +858 -132
  3. package/dist/artifacts.cjs.map +1 -1
  4. package/dist/artifacts.d.cts +38 -5
  5. package/dist/artifacts.d.ts +38 -5
  6. package/dist/artifacts.js +13 -3
  7. package/dist/blocks.cjs +1185 -467
  8. package/dist/blocks.cjs.map +1 -1
  9. package/dist/blocks.css +1 -1
  10. package/dist/blocks.d.cts +23 -10
  11. package/dist/blocks.d.ts +23 -10
  12. package/dist/blocks.js +6 -3
  13. package/dist/chart.cjs +594 -0
  14. package/dist/chart.cjs.map +1 -0
  15. package/dist/chart.d.cts +439 -0
  16. package/dist/chart.d.ts +439 -0
  17. package/dist/chart.js +32 -0
  18. package/dist/chat.cjs +1207 -489
  19. package/dist/chat.cjs.map +1 -1
  20. package/dist/chat.d.cts +3 -2
  21. package/dist/chat.d.ts +3 -2
  22. package/dist/chat.js +7 -4
  23. package/dist/{chunk-MXOPG747.js → chunk-36CB624W.js} +7 -7
  24. package/dist/chunk-36CB624W.js.map +1 -0
  25. package/dist/{chunk-L35M3OD5.js → chunk-4MZZH3WX.js} +5 -11
  26. package/dist/chunk-4MZZH3WX.js.map +1 -0
  27. package/dist/chunk-AQEJRMRN.js +1 -0
  28. package/dist/chunk-AQEJRMRN.js.map +1 -0
  29. package/dist/{chunk-OUW6PUEB.js → chunk-FFX3CAOX.js} +7 -7
  30. package/dist/chunk-P6GUNIAE.js +11 -0
  31. package/dist/chunk-P6GUNIAE.js.map +1 -0
  32. package/dist/chunk-QXGYMDIA.js +477 -0
  33. package/dist/chunk-QXGYMDIA.js.map +1 -0
  34. package/dist/{chunk-BX5TCEPR.js → chunk-Z5JWF24N.js} +388 -105
  35. package/dist/chunk-Z5JWF24N.js.map +1 -0
  36. package/dist/index.cjs +924 -198
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +4 -3
  39. package/dist/index.d.ts +4 -3
  40. package/dist/index.js +23 -15
  41. package/dist/table.js +2 -1
  42. package/dist/types-B2aYk82c.d.cts +29 -0
  43. package/dist/types-B2aYk82c.d.ts +29 -0
  44. package/dist/types-C0BvwliI.d.cts +332 -0
  45. package/dist/types-C5bFH4v3.d.ts +332 -0
  46. package/dist/{types-DuuRI4ll.d.cts → types-DCutaXjZ.d.cts} +16 -1
  47. package/dist/{types-C9XX-Uhk.d.ts → types-uPfn67Dc.d.ts} +16 -1
  48. package/package.json +13 -1
  49. package/dist/chunk-BX5TCEPR.js.map +0 -1
  50. package/dist/chunk-L35M3OD5.js.map +0 -1
  51. package/dist/chunk-MEJESPTZ.js +0 -1
  52. package/dist/chunk-MXOPG747.js.map +0 -1
  53. package/dist/types-3Gzk7cRt.d.cts +0 -121
  54. package/dist/types-3Gzk7cRt.d.ts +0 -121
  55. /package/dist/{chunk-MEJESPTZ.js.map → chart.js.map} +0 -0
  56. /package/dist/{chunk-OUW6PUEB.js.map → chunk-FFX3CAOX.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.