@particle-academy/react-fancy 5.64.1 → 5.66.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 (59) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/{PastePills.types-CDyotkUb.d.cts → PastePills.types-CpXzsuwJ.d.cts} +2 -0
  3. package/dist/{PastePills.types-CDyotkUb.d.ts → PastePills.types-CpXzsuwJ.d.ts} +2 -0
  4. package/dist/{PastedFilesInput-CrgNoEBd.d.ts → PastedFilesInput-Bt3KSTVN.d.ts} +1 -1
  5. package/dist/{PastedFilesInput-DQ1eZaHk.d.cts → PastedFilesInput-CUQeOeOA.d.cts} +1 -1
  6. package/dist/{chunk-SZH7TFME.js → chunk-4EUDW2WU.js} +3 -3
  7. package/dist/{chunk-SZH7TFME.js.map → chunk-4EUDW2WU.js.map} +1 -1
  8. package/dist/{chunk-CMC2TOEQ.cjs → chunk-6CAXLP7D.cjs} +6 -6
  9. package/dist/{chunk-CMC2TOEQ.cjs.map → chunk-6CAXLP7D.cjs.map} +1 -1
  10. package/dist/{chunk-TQGRXJ74.cjs → chunk-7FYRFNPX.cjs} +9 -9
  11. package/dist/{chunk-TQGRXJ74.cjs.map → chunk-7FYRFNPX.cjs.map} +1 -1
  12. package/dist/{chunk-4XHG6Q42.cjs → chunk-7HXFEYOV.cjs} +8 -8
  13. package/dist/{chunk-4XHG6Q42.cjs.map → chunk-7HXFEYOV.cjs.map} +1 -1
  14. package/dist/{chunk-MVVHUTXA.js → chunk-B4LVQ4QI.js} +3 -3
  15. package/dist/{chunk-MVVHUTXA.js.map → chunk-B4LVQ4QI.js.map} +1 -1
  16. package/dist/{chunk-QNQNGARW.cjs → chunk-HFK5SBNM.cjs} +27 -9
  17. package/dist/chunk-HFK5SBNM.cjs.map +1 -0
  18. package/dist/{chunk-BTNF3QBR.js → chunk-J44EV6SP.js} +366 -32
  19. package/dist/chunk-J44EV6SP.js.map +1 -0
  20. package/dist/{chunk-Z6LYBL5L.cjs → chunk-MCQWTOTV.cjs} +369 -33
  21. package/dist/chunk-MCQWTOTV.cjs.map +1 -0
  22. package/dist/{chunk-ELFTEJBT.js → chunk-QSGAFKK2.js} +3 -3
  23. package/dist/{chunk-ELFTEJBT.js.map → chunk-QSGAFKK2.js.map} +1 -1
  24. package/dist/{chunk-NILA2LZY.js → chunk-YIKXJWO4.js} +27 -9
  25. package/dist/chunk-YIKXJWO4.js.map +1 -0
  26. package/dist/composer.cjs +4 -4
  27. package/dist/composer.d.cts +2 -2
  28. package/dist/composer.d.ts +2 -2
  29. package/dist/composer.js +2 -2
  30. package/dist/{index-BZON-gXr.d.ts → index-DWtSViJ3.d.cts} +147 -4
  31. package/dist/{index-BF5qsQur.d.cts → index-XR5t8bTq.d.ts} +147 -4
  32. package/dist/index.cjs +36 -28
  33. package/dist/index.d.cts +3 -3
  34. package/dist/index.d.ts +3 -3
  35. package/dist/index.js +5 -5
  36. package/dist/input.cjs +3 -3
  37. package/dist/input.d.cts +1 -1
  38. package/dist/input.d.ts +1 -1
  39. package/dist/input.js +2 -2
  40. package/dist/inputs.cjs +3 -3
  41. package/dist/inputs.d.cts +1 -1
  42. package/dist/inputs.d.ts +1 -1
  43. package/dist/inputs.js +2 -2
  44. package/dist/json-editor.cjs +14 -14
  45. package/dist/json-editor.js +3 -3
  46. package/dist/paste-pills.cjs +14 -14
  47. package/dist/paste-pills.d.cts +3 -3
  48. package/dist/paste-pills.d.ts +3 -3
  49. package/dist/paste-pills.js +1 -1
  50. package/dist/prompt-input.cjs +11 -3
  51. package/dist/prompt-input.d.cts +2 -2
  52. package/dist/prompt-input.d.ts +2 -2
  53. package/dist/prompt-input.js +2 -2
  54. package/docs/PromptInput.md +101 -1
  55. package/package.json +1 -1
  56. package/dist/chunk-BTNF3QBR.js.map +0 -1
  57. package/dist/chunk-NILA2LZY.js.map +0 -1
  58. package/dist/chunk-QNQNGARW.cjs.map +0 -1
  59. package/dist/chunk-Z6LYBL5L.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -11,6 +11,73 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ## [5.66.0] - 2026-10-27
15
+
16
+ ### Added
17
+
18
+ - **`PromptInput`: text paste pills take an optional `label`** (genie#1280).
19
+ A text pill (`{ kind: "text", id, text, label? }` in `PromptDraft`) shows its
20
+ `label` in place of `Pasted text · N characters`. This mirrors the label image
21
+ pills already have. It lets a host that inserts a pill itself, such as Genie
22
+ sending a plan step into the chat, show which step it is.
23
+ - The label is display only. The submitted value still expands the pill to
24
+ the full `text`.
25
+ - The accessible name becomes `Insert this pasted text: <label>, N characters`,
26
+ so it still says the pill is pasted text.
27
+ - The label is drawn as plain text, never HTML. Whitespace, control characters
28
+ and U+FFFC are flattened to single spaces, and the label is capped at 80
29
+ characters with `…`. If it is blank or not a string, the generic text is
30
+ shown. A non-string `label` is dropped when a draft is read.
31
+ - It round-trips through `getDraft` / `setDraft`, `defaultDraft`, a controlled
32
+ `draft` and `onDraftChange`. `HeldPaste` (the `Composer` / `usePastePills`
33
+ shape) gains the same optional `label`.
34
+ - Additive. With no `label` the markup is unchanged, so you need do nothing.
35
+
36
+ ## [5.65.0] - 2026-10-27
37
+
38
+ ### Added
39
+
40
+ - **`PromptInput`: controlled state and draft save/restore** (genie#1261).
41
+ Before this, nothing outside the composer could read or set what had been
42
+ typed, so a host could not keep a draft across a restart. That also broke the
43
+ component contract, which requires controlled state.
44
+ - `value` / `defaultValue` / `onChange(text)` cover the simple case. With
45
+ paste pills on, `value` carries a `pasteMarker(id)` for each pill, the same
46
+ as `Composer`'s `value`.
47
+ - `draft` / `defaultDraft` / `onDraftChange(draft)` cover the whole draft.
48
+ A `PromptDraft` is plain JSON:
49
+ `{ v: 1, text, pills: [{ kind: "text", id, text } | { kind: "image", id, label, file }], attachments: [{ id, name, type, bytes, ref? }] }`.
50
+ - A `ref` now resolves to a `PromptInputHandle`: `getDraft()`,
51
+ `setDraft(draft, { focus?: false })` and `focus()`.
52
+ - **Restoring a draft never moves focus or a caret** (genie#1235). This holds
53
+ when nothing is focused and when another input is. Pass `{ focus: true }`
54
+ to focus the composer.
55
+ - `setDraft` does **not** call `onChange` / `onDraftChange`. The host set the
56
+ draft and already has it, and firing the callbacks would make a restore
57
+ look like typing (a dirty flag, a typing indicator, a save over what was
58
+ just loaded). This is the same as assigning `input.value` in the DOM.
59
+ - The file bytes are not in the draft. `persistAttachment(file, entry)`
60
+ stores each attached or pasted file wherever the host chooses and returns
61
+ a handle, which becomes the entry's `ref`. It can be sync or async.
62
+ `restoreAttachment(entry)` gets the File back on restore. To keep the bytes
63
+ inline, use the new `promptFileToDataUrl` / `promptDataUrlToFile` helpers.
64
+ A restored entry with no File still shows its chip or pill, and reaches
65
+ `onSubmit` with its `ref` and `file: undefined`.
66
+ - `PromptAttachment` gains an optional `ref`. Each attachment chip gets a
67
+ stable `data-react-fancy-prompt-input-attachment="<id>"` handle.
68
+ - A draft whose `v` is unknown is refused with a console warning rather than
69
+ guessed at. Pills restored into a composer with no pills turned on are
70
+ expanded in place, and image pills become attachments, so no raw markers
71
+ show.
72
+
73
+ **What you must do: nothing, unless you opt in.** Existing usage renders the
74
+ same markup as 5.64.1, checked against a snapshot written by 5.64.1 itself.
75
+ Two edge cases. `ref`, `onChange` and `defaultValue` used to fall through
76
+ `...rest` to the root `<div>`, but none of them was in the props type, so a
77
+ TypeScript consumer could not have passed them. If you passed one anyway
78
+ (an untyped `onChange` that listened for DOM change events bubbling to the
79
+ root), it now means the new prop.
80
+
14
81
  ## [5.64.1] - 2026-10-27
15
82
 
16
83
  ### Fixed
@@ -9,6 +9,8 @@
9
9
  interface HeldPaste {
10
10
  id: string;
11
11
  text: string;
12
+ /** Shown on the pill instead of `Pasted text · N characters`. Display only. */
13
+ label?: string;
12
14
  }
13
15
  /**
14
16
  * The minimum of a clipboard event this hook touches.
@@ -9,6 +9,8 @@
9
9
  interface HeldPaste {
10
10
  id: string;
11
11
  text: string;
12
+ /** Shown on the pill instead of `Pasted text · N characters`. Display only. */
13
+ label?: string;
12
14
  }
13
15
  /**
14
16
  * The minimum of a clipboard event this hook touches.
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, RefObject } from 'react';
3
- import { C as ComposerPastePreview, a as ComposerPasteClassNames, b as HeldPaste, H as HeldImage, f as UsePastePillsResult } from './PastePills.types-CDyotkUb.js';
3
+ import { C as ComposerPastePreview, a as ComposerPasteClassNames, b as HeldPaste, H as HeldImage, f as UsePastePillsResult } from './PastePills.types-CpXzsuwJ.js';
4
4
 
5
5
  /** The attribute on the placeholder span a pill is portalled into. */
6
6
  declare const HOST_ATTR = "data-react-fancy-composer-paste-host";
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, RefObject } from 'react';
3
- import { C as ComposerPastePreview, a as ComposerPasteClassNames, b as HeldPaste, H as HeldImage, f as UsePastePillsResult } from './PastePills.types-CDyotkUb.cjs';
3
+ import { C as ComposerPastePreview, a as ComposerPasteClassNames, b as HeldPaste, H as HeldImage, f as UsePastePillsResult } from './PastePills.types-CpXzsuwJ.cjs';
4
4
 
5
5
  /** The attribute on the placeholder span a pill is portalled into. */
6
6
  declare const HOST_ATTR = "data-react-fancy-composer-paste-host";
@@ -1,6 +1,6 @@
1
1
  import { Switch } from './chunk-DXZCKDYS.js';
2
2
  import { DatePicker } from './chunk-2UTN3EFK.js';
3
- import { Input } from './chunk-MVVHUTXA.js';
3
+ import { Input } from './chunk-B4LVQ4QI.js';
4
4
  import { Select } from './chunk-FVI4JDLA.js';
5
5
  import { Textarea } from './chunk-UVUBV4VZ.js';
6
6
  import { DisplayValue } from './chunk-WX5XYDVN.js';
@@ -1337,5 +1337,5 @@ function buildItems({
1337
1337
  }
1338
1338
 
1339
1339
  export { JSON_FIELD_TYPES, JsonEditor, applyJsonEdit, describeEdit, findJsonConflicts, getAtPath, inferType, parseKeyMap, parsePath, pathToString, resolveKeyRule, typeMatches };
1340
- //# sourceMappingURL=chunk-SZH7TFME.js.map
1341
- //# sourceMappingURL=chunk-SZH7TFME.js.map
1340
+ //# sourceMappingURL=chunk-4EUDW2WU.js.map
1341
+ //# sourceMappingURL=chunk-4EUDW2WU.js.map