claude-artifact-framework 0.7.0 → 0.7.2
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 +70 -8
- package/dist/index.esm.js +417 -260
- package/dist/index.esm.js.map +3 -3
- package/dist/index.global.js +40 -9
- package/dist/index.global.js.map +4 -4
- package/package.json +1 -1
- package/src/app.js +192 -23
- package/src/appState.js +1 -1
- package/src/blocks.js +2 -0
- package/src/chat.js +10 -3
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ mirrors npm packages automatically.
|
|
|
12
12
|
### As a global script (`<script>` tag)
|
|
13
13
|
|
|
14
14
|
```html
|
|
15
|
-
<script src="https://cdn.jsdelivr.net/npm/claude-artifact-framework@0.7.
|
|
15
|
+
<script src="https://cdn.jsdelivr.net/npm/claude-artifact-framework@0.7.2/dist/index.global.js"></script>
|
|
16
16
|
<script>
|
|
17
17
|
const { storage, createStore, createPersistedStore, createSharedStore } = ArtifactKit;
|
|
18
18
|
</script>
|
|
@@ -27,11 +27,11 @@ mirrors npm packages automatically.
|
|
|
27
27
|
createStore,
|
|
28
28
|
createPersistedStore,
|
|
29
29
|
createSharedStore,
|
|
30
|
-
} from "https://cdn.jsdelivr.net/npm/claude-artifact-framework@0.7.
|
|
30
|
+
} from "https://cdn.jsdelivr.net/npm/claude-artifact-framework@0.7.2/dist/index.esm.js";
|
|
31
31
|
</script>
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
Pin a version (`@0.7.
|
|
34
|
+
Pin a version (`@0.7.2`) for reproducible artifacts, or drop the version
|
|
35
35
|
(`claude-artifact-framework/dist/...`) to always get the latest release.
|
|
36
36
|
|
|
37
37
|
### Inside a React artifact
|
|
@@ -315,6 +315,65 @@ Chat bubbles render the assistant's **markdown** (bold, code, lists,
|
|
|
315
315
|
headings) automatically — HTML is escaped first, so model output can't
|
|
316
316
|
inject markup.
|
|
317
317
|
|
|
318
|
+
### The `workspace` layout — content + copilot
|
|
319
|
+
|
|
320
|
+
A full-width main column and a sidebar, for apps where content and an
|
|
321
|
+
assistant live side by side: an editor with a writing copilot, a dashboard
|
|
322
|
+
with an analyst, a viewer with an annotator. `chat` is available as a block,
|
|
323
|
+
so the copilot's tools can drive the main content:
|
|
324
|
+
|
|
325
|
+
```js
|
|
326
|
+
ArtifactKit.createApp({
|
|
327
|
+
title: "Editor con copiloto",
|
|
328
|
+
layout: "workspace",
|
|
329
|
+
main: [
|
|
330
|
+
{ fields: [{ key: "nota", type: "textarea", rows: 8 }], title: "Documento" },
|
|
331
|
+
{ output: (d) => [{ label: "Palabras", value: countWords(d.nota), big: true }] },
|
|
332
|
+
],
|
|
333
|
+
sidebar: [
|
|
334
|
+
{ chat: {
|
|
335
|
+
system: (d) => "Sos un copiloto de escritura. Nota actual: " + (d.nota || ""),
|
|
336
|
+
tools: {
|
|
337
|
+
reescribir_nota: {
|
|
338
|
+
description: "Reemplaza el texto de la nota",
|
|
339
|
+
input: { texto: "string" },
|
|
340
|
+
run: (input, ctx) => { ctx.update((d) => { d.nota = input.texto; }); },
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
}},
|
|
344
|
+
],
|
|
345
|
+
})
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
`main` is required; `sidebar` is optional. Both take the same blocks as
|
|
349
|
+
`panel`. The panes sit side by side and stack on narrow screens. One chat
|
|
350
|
+
block per app — the conversation persists under `data.chat` and there is
|
|
351
|
+
exactly one.
|
|
352
|
+
|
|
353
|
+
### Tabs, conditional blocks, and accordions
|
|
354
|
+
|
|
355
|
+
Three in-screen navigation primitives, usable in `panel`, `workspace`, and
|
|
356
|
+
below a `records` list alike:
|
|
357
|
+
|
|
358
|
+
```js
|
|
359
|
+
blocks: [
|
|
360
|
+
{ tabs: [
|
|
361
|
+
{ label: "Registrar", blocks: [{ fields: [...] }] },
|
|
362
|
+
{ label: "Resumen", blocks: [{ output: (d) => [...] }, { chart: (d) => ({...}) }] },
|
|
363
|
+
], wide: true },
|
|
364
|
+
|
|
365
|
+
// `when` hides any block until the condition holds
|
|
366
|
+
{ output: (d) => [...], when: (d) => d.records.length > 0 },
|
|
367
|
+
|
|
368
|
+
// `collapsible` needs a title; `"collapsed"` starts closed
|
|
369
|
+
{ text: "Instrucciones…", title: "Ayuda", collapsible: "collapsed" },
|
|
370
|
+
]
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
The active tab and each accordion's open/closed state are framework-owned
|
|
374
|
+
view state — they survive reload, per viewer. Tabs cannot nest inside tabs;
|
|
375
|
+
`when` must be a function; both throw otherwise.
|
|
376
|
+
|
|
318
377
|
## API reference
|
|
319
378
|
|
|
320
379
|
Everything an app can declare, in one place.
|
|
@@ -323,11 +382,14 @@ Everything an app can declare, in one place.
|
|
|
323
382
|
`records`, `steps`, `chat`, `data`, `shared`. Anything else throws.
|
|
324
383
|
|
|
325
384
|
**Layouts** (`layout:`): `panel` (default — grid of blocks), `records` (CRUD
|
|
326
|
-
list), `steps` (wizard), `chat` (conversation with Claude)
|
|
327
|
-
matching key (`blocks` /
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
385
|
+
list), `steps` (wizard), `chat` (conversation with Claude), `workspace`
|
|
386
|
+
(main column + sidebar). Each requires its matching key (`blocks` /
|
|
387
|
+
`records` / `steps` / `chat` / `main`+`sidebar`).
|
|
388
|
+
|
|
389
|
+
**Block types** (entries of `blocks`, `main`, or `sidebar`): `fields`,
|
|
390
|
+
`output`, `text`, `list`, `chart`, `timer`, `actions`, `chat`, `tabs`,
|
|
391
|
+
`custom`. Any block also accepts `when: (d) => bool` (conditional
|
|
392
|
+
visibility) and `collapsible: true | "collapsed"` (accordion; needs `title`). One type per entry, plus optional `title`, `empty`,
|
|
331
393
|
`wide`. In the `records` layout, `blocks` render below the list (never on the
|
|
332
394
|
detail screen); their functions receive the same `data` object as everywhere
|
|
333
395
|
else — the collection lives at `d.records`.
|