claude-artifact-framework 0.6.0 → 0.7.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/README.md +60 -9
- package/dist/index.esm.js +315 -254
- package/dist/index.esm.js.map +4 -4
- package/dist/index.global.js +23 -13
- package/dist/index.global.js.map +4 -4
- package/package.json +1 -1
- package/src/app.js +73 -18
- package/src/blocks.js +15 -4
- package/src/chat.js +10 -3
- package/src/records.js +2 -0
- package/src/steps.js +1 -0
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.
|
|
15
|
+
<script src="https://cdn.jsdelivr.net/npm/claude-artifact-framework@0.7.1/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.
|
|
30
|
+
} from "https://cdn.jsdelivr.net/npm/claude-artifact-framework@0.7.1/dist/index.esm.js";
|
|
31
31
|
</script>
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
Pin a version (`@0.
|
|
34
|
+
Pin a version (`@0.7.1`) 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,41 @@ 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
|
+
|
|
318
353
|
## API reference
|
|
319
354
|
|
|
320
355
|
Everything an app can declare, in one place.
|
|
@@ -323,18 +358,20 @@ Everything an app can declare, in one place.
|
|
|
323
358
|
`records`, `steps`, `chat`, `data`, `shared`. Anything else throws.
|
|
324
359
|
|
|
325
360
|
**Layouts** (`layout:`): `panel` (default — grid of blocks), `records` (CRUD
|
|
326
|
-
list), `steps` (wizard), `chat` (conversation with Claude)
|
|
327
|
-
matching key (`blocks` /
|
|
361
|
+
list), `steps` (wizard), `chat` (conversation with Claude), `workspace`
|
|
362
|
+
(main column + sidebar). Each requires its matching key (`blocks` /
|
|
363
|
+
`records` / `steps` / `chat` / `main`+`sidebar`).
|
|
328
364
|
|
|
329
|
-
**Block types** (entries of `blocks
|
|
330
|
-
`chart`, `timer`, `actions`, `custom`. One type per entry, plus optional `title`, `empty`,
|
|
365
|
+
**Block types** (entries of `blocks`, `main`, or `sidebar`): `fields`,
|
|
366
|
+
`output`, `text`, `list`, `chart`, `timer`, `actions`, `chat`, `custom`. One type per entry, plus optional `title`, `empty`,
|
|
331
367
|
`wide`. In the `records` layout, `blocks` render below the list (never on the
|
|
332
368
|
detail screen); their functions receive the same `data` object as everywhere
|
|
333
369
|
else — the collection lives at `d.records`.
|
|
334
370
|
|
|
335
371
|
**Field types** (`type:` on any field): `text` (default), `textarea`,
|
|
336
372
|
`number`, `money`, `percent`, `check` (checkbox), `date`, `select` (needs
|
|
337
|
-
`options`
|
|
373
|
+
`options` — an array, or `(d) => [...]` for choices that come from the
|
|
374
|
+
app's data, e.g. a "who paid" select fed by a user-entered group). Other field keys: `key` (required), `label`, `value` (initial),
|
|
338
375
|
`required`, `min`, `max`, `step`, `placeholder`, `hint`, `rows`, `options`.
|
|
339
376
|
An unknown `type` throws naming the valid ones.
|
|
340
377
|
|
|
@@ -350,7 +387,21 @@ keys must be unique across steps.
|
|
|
350
387
|
`{ description, input, run(input, ctx) }`.
|
|
351
388
|
|
|
352
389
|
**Formats** (`format:` on output/chart/compute items): `money`, `percent`,
|
|
353
|
-
`number`, `date`.
|
|
390
|
+
`number`, `date`. `percent` expects 0–100 (pass `ratio * 100`, not the raw
|
|
391
|
+
ratio).
|
|
392
|
+
|
|
393
|
+
**Quick-add pattern** — a lightweight alternative to `records` when you just
|
|
394
|
+
need "type something, press a button, it lands in a list":
|
|
395
|
+
|
|
396
|
+
```js
|
|
397
|
+
blocks: [
|
|
398
|
+
{ fields: [{ key: "nueva", label: "Persona", type: "text" }] },
|
|
399
|
+
{ actions: [{ label: "Agregar", kind: "primary", run: (d) => {
|
|
400
|
+
if (d.nueva && d.nueva.trim()) { d.personas = [...(d.personas || []), d.nueva.trim()]; d.nueva = ""; }
|
|
401
|
+
}}]},
|
|
402
|
+
{ text: (d) => (d.personas || []).join(", ") || "Sin personas todavía" },
|
|
403
|
+
]
|
|
404
|
+
```
|
|
354
405
|
|
|
355
406
|
## `storage`
|
|
356
407
|
|