@particle-academy/react-fancy 5.15.0 → 5.16.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 (141) hide show
  1. package/dist/badge.cjs +3 -2
  2. package/dist/badge.js +2 -1
  3. package/dist/button.cjs +4 -3
  4. package/dist/button.js +2 -1
  5. package/dist/callout.cjs +3 -2
  6. package/dist/callout.js +2 -1
  7. package/dist/{chunk-VE3EM4K2.cjs → chunk-23CLGUMT.cjs} +2 -2
  8. package/dist/{chunk-VE3EM4K2.cjs.map → chunk-23CLGUMT.cjs.map} +1 -1
  9. package/dist/{chunk-C4Z4S3CX.js → chunk-2ICXWLKS.js} +2 -2
  10. package/dist/{chunk-C4Z4S3CX.js.map → chunk-2ICXWLKS.js.map} +1 -1
  11. package/dist/chunk-3I2KWNXT.cjs +4 -0
  12. package/dist/chunk-3I2KWNXT.cjs.map +1 -0
  13. package/dist/{chunk-7C7VF4WY.cjs → chunk-6FYMMQ3G.cjs} +2 -2
  14. package/dist/{chunk-7C7VF4WY.cjs.map → chunk-6FYMMQ3G.cjs.map} +1 -1
  15. package/dist/{chunk-WEGL4S52.js → chunk-6RYZ2MOE.js} +2 -2
  16. package/dist/{chunk-WEGL4S52.js.map → chunk-6RYZ2MOE.js.map} +1 -1
  17. package/dist/{chunk-2CNSZCVE.cjs → chunk-6Y2QO7YV.cjs} +4 -4
  18. package/dist/{chunk-2CNSZCVE.cjs.map → chunk-6Y2QO7YV.cjs.map} +1 -1
  19. package/dist/chunk-AR2IBCX7.cjs +1354 -0
  20. package/dist/chunk-AR2IBCX7.cjs.map +1 -0
  21. package/dist/{chunk-CTMJYV3O.js → chunk-B4JLRS5E.js} +2 -2
  22. package/dist/{chunk-CTMJYV3O.js.map → chunk-B4JLRS5E.js.map} +1 -1
  23. package/dist/{chunk-ECZ66DKF.js → chunk-BWT2L6XP.js} +2 -2
  24. package/dist/{chunk-ECZ66DKF.js.map → chunk-BWT2L6XP.js.map} +1 -1
  25. package/dist/{chunk-O432BDEO.js → chunk-CEEEENPW.js} +6 -3
  26. package/dist/chunk-CEEEENPW.js.map +1 -0
  27. package/dist/{chunk-MILTPAF6.js → chunk-CQWPMRYS.js} +2 -2
  28. package/dist/{chunk-MILTPAF6.js.map → chunk-CQWPMRYS.js.map} +1 -1
  29. package/dist/{chunk-C5AZNBVB.js → chunk-DDRHCFUE.js} +2 -2
  30. package/dist/{chunk-C5AZNBVB.js.map → chunk-DDRHCFUE.js.map} +1 -1
  31. package/dist/{chunk-FA3D4GFC.cjs → chunk-EQGY3QDJ.cjs} +5 -5
  32. package/dist/{chunk-FA3D4GFC.cjs.map → chunk-EQGY3QDJ.cjs.map} +1 -1
  33. package/dist/{chunk-DOSSIU6S.cjs → chunk-FO4GCX67.cjs} +6 -3
  34. package/dist/chunk-FO4GCX67.cjs.map +1 -0
  35. package/dist/chunk-GNHQVPZP.js +3 -0
  36. package/dist/chunk-GNHQVPZP.js.map +1 -0
  37. package/dist/{chunk-GZIUE4DE.js → chunk-HNITJ2UR.js} +3 -3
  38. package/dist/{chunk-GZIUE4DE.js.map → chunk-HNITJ2UR.js.map} +1 -1
  39. package/dist/{chunk-XZYKPGSK.cjs → chunk-HTKDPFLJ.cjs} +2 -2
  40. package/dist/{chunk-XZYKPGSK.cjs.map → chunk-HTKDPFLJ.cjs.map} +1 -1
  41. package/dist/chunk-HXLSEBAL.cjs +4 -0
  42. package/dist/chunk-HXLSEBAL.cjs.map +1 -0
  43. package/dist/{chunk-GKPCXPCD.js → chunk-I2JXK25I.js} +51 -12
  44. package/dist/chunk-I2JXK25I.js.map +1 -0
  45. package/dist/chunk-IQ4KQJAO.js +3 -0
  46. package/dist/chunk-IQ4KQJAO.js.map +1 -0
  47. package/dist/chunk-J324MF75.js +3 -0
  48. package/dist/chunk-J324MF75.js.map +1 -0
  49. package/dist/{chunk-PZIAL4OP.cjs → chunk-JU5W65N3.cjs} +2 -2
  50. package/dist/{chunk-PZIAL4OP.cjs.map → chunk-JU5W65N3.cjs.map} +1 -1
  51. package/dist/{chunk-2G3L4BLU.cjs → chunk-KKYP5R3G.cjs} +2 -2
  52. package/dist/{chunk-2G3L4BLU.cjs.map → chunk-KKYP5R3G.cjs.map} +1 -1
  53. package/dist/chunk-LQ4ICCN2.js +3 -0
  54. package/dist/chunk-LQ4ICCN2.js.map +1 -0
  55. package/dist/{chunk-IF3T3ZCB.cjs → chunk-LYFUPTLG.cjs} +51 -12
  56. package/dist/chunk-LYFUPTLG.cjs.map +1 -0
  57. package/dist/chunk-M5MUGSON.cjs +4 -0
  58. package/dist/chunk-M5MUGSON.cjs.map +1 -0
  59. package/dist/{chunk-UH2YXQ2B.cjs → chunk-MPDLL4X3.cjs} +2 -2
  60. package/dist/{chunk-UH2YXQ2B.cjs.map → chunk-MPDLL4X3.cjs.map} +1 -1
  61. package/dist/chunk-NMXCQOHV.js +3 -0
  62. package/dist/chunk-NMXCQOHV.js.map +1 -0
  63. package/dist/chunk-NW3GJWJ7.js +3 -0
  64. package/dist/chunk-NW3GJWJ7.js.map +1 -0
  65. package/dist/chunk-OYZDSMNP.cjs +4 -0
  66. package/dist/chunk-OYZDSMNP.cjs.map +1 -0
  67. package/dist/{chunk-UWVVEB2N.js → chunk-P7AJAN62.js} +2 -2
  68. package/dist/{chunk-UWVVEB2N.js.map → chunk-P7AJAN62.js.map} +1 -1
  69. package/dist/{chunk-NPKE2IX6.js → chunk-PITWDKKY.js} +2 -2
  70. package/dist/{chunk-NPKE2IX6.js.map → chunk-PITWDKKY.js.map} +1 -1
  71. package/dist/{chunk-7AFEKDUS.js → chunk-PJ4TQ6YO.js} +4 -4
  72. package/dist/{chunk-7AFEKDUS.js.map → chunk-PJ4TQ6YO.js.map} +1 -1
  73. package/dist/chunk-QGPMVFZJ.cjs +4 -0
  74. package/dist/chunk-QGPMVFZJ.cjs.map +1 -0
  75. package/dist/{chunk-W2Q4OWHX.cjs → chunk-RMFLRBUC.cjs} +6 -6
  76. package/dist/{chunk-W2Q4OWHX.cjs.map → chunk-RMFLRBUC.cjs.map} +1 -1
  77. package/dist/chunk-SHDSKHCC.js +3 -0
  78. package/dist/chunk-SHDSKHCC.js.map +1 -0
  79. package/dist/chunk-TMR56BBE.js +3 -0
  80. package/dist/chunk-TMR56BBE.js.map +1 -0
  81. package/dist/chunk-URTLYNZI.cjs +4 -0
  82. package/dist/chunk-URTLYNZI.cjs.map +1 -0
  83. package/dist/chunk-V4EARA4F.js +3 -0
  84. package/dist/chunk-V4EARA4F.js.map +1 -0
  85. package/dist/chunk-VBWRH4UW.cjs +4 -0
  86. package/dist/chunk-VBWRH4UW.cjs.map +1 -0
  87. package/dist/{chunk-K2DZEYBF.js → chunk-WNIP443K.js} +3 -3
  88. package/dist/{chunk-K2DZEYBF.js.map → chunk-WNIP443K.js.map} +1 -1
  89. package/dist/{chunk-2S7WRR5P.cjs → chunk-X5VZRFQD.cjs} +2 -2
  90. package/dist/{chunk-2S7WRR5P.cjs.map → chunk-X5VZRFQD.cjs.map} +1 -1
  91. package/dist/chunk-XFBLUPKF.cjs +4 -0
  92. package/dist/chunk-XFBLUPKF.cjs.map +1 -0
  93. package/dist/chunk-XURQVDCN.cjs +4 -0
  94. package/dist/chunk-XURQVDCN.cjs.map +1 -0
  95. package/dist/{chunk-WVO2EKE6.cjs → chunk-Y5V5GBN4.cjs} +2 -2
  96. package/dist/{chunk-WVO2EKE6.cjs.map → chunk-Y5V5GBN4.cjs.map} +1 -1
  97. package/dist/chunk-Y6DK4CGY.js +1341 -0
  98. package/dist/chunk-Y6DK4CGY.js.map +1 -0
  99. package/dist/color-picker.cjs +3 -2
  100. package/dist/color-picker.d.cts +10 -1
  101. package/dist/color-picker.d.ts +10 -1
  102. package/dist/color-picker.js +2 -1
  103. package/dist/date-picker.cjs +3 -2
  104. package/dist/date-picker.js +2 -1
  105. package/dist/index-BfFk-CIv.d.ts +330 -0
  106. package/dist/index-BypPN_6l.d.cts +330 -0
  107. package/dist/index.cjs +123 -65
  108. package/dist/index.d.cts +1 -0
  109. package/dist/index.d.ts +1 -0
  110. package/dist/index.js +28 -18
  111. package/dist/input.cjs +3 -2
  112. package/dist/input.js +2 -1
  113. package/dist/inputs.cjs +26 -22
  114. package/dist/inputs.js +10 -6
  115. package/dist/json-editor.cjs +77 -0
  116. package/dist/json-editor.cjs.map +1 -0
  117. package/dist/json-editor.d.cts +4 -0
  118. package/dist/json-editor.d.ts +4 -0
  119. package/dist/json-editor.js +28 -0
  120. package/dist/json-editor.js.map +1 -0
  121. package/dist/magic-wand.cjs +6 -4
  122. package/dist/magic-wand.js +5 -3
  123. package/dist/prompt-input.cjs +4 -3
  124. package/dist/prompt-input.js +3 -2
  125. package/dist/reason-tag.cjs +4 -3
  126. package/dist/reason-tag.js +3 -2
  127. package/dist/select.cjs +3 -2
  128. package/dist/select.js +2 -1
  129. package/dist/switch.cjs +3 -2
  130. package/dist/switch.js +2 -1
  131. package/dist/table.cjs +11 -11
  132. package/dist/table.d.cts +18 -9
  133. package/dist/table.d.ts +18 -9
  134. package/dist/table.js +1 -1
  135. package/dist/text.cjs +3 -2
  136. package/dist/text.js +2 -1
  137. package/package.json +12 -2
  138. package/dist/chunk-DOSSIU6S.cjs.map +0 -1
  139. package/dist/chunk-GKPCXPCD.js.map +0 -1
  140. package/dist/chunk-IF3T3ZCB.cjs.map +0 -1
  141. package/dist/chunk-O432BDEO.js.map +0 -1
@@ -0,0 +1,330 @@
1
+ import * as react from 'react';
2
+ import { HTMLAttributes } from 'react';
3
+ import { F as FieldMode, b as InputOption } from './inputs.types-DERzxpe1.js';
4
+ import { S as Size } from './types-8Sv0rCjw.js';
5
+
6
+ type JsonPrimitive = string | number | boolean | null;
7
+ interface JsonObject {
8
+ [key: string]: JsonValue;
9
+ }
10
+ type JsonArray = JsonValue[];
11
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
12
+ /**
13
+ * A location inside a JSON document, one array element per segment. Array
14
+ * indices are decimal STRINGS (`["orders", "0", "total"]`) so a path is a plain
15
+ * `string[]` an agent can emit without a tagged union, and so object keys and
16
+ * array indices are addressed identically.
17
+ *
18
+ * The wire form is the dotted string produced by `pathToString` — see
19
+ * `JsonEditor.paths.ts` for the escaping rule.
20
+ */
21
+ type JsonPath = string[];
22
+ /**
23
+ * The data types a `keyMap` can impose on a JSON value.
24
+ *
25
+ * Each one owes BOTH a read-only representation and an edit control — that
26
+ * pairing is the whole point of the feature, so a type with no distinct input
27
+ * does not earn a place here.
28
+ *
29
+ * `json` is the escape hatch: it matches any value and edits as raw text, which
30
+ * is how a sub-document opts out of the row-per-key treatment.
31
+ */
32
+ declare const JSON_FIELD_TYPES: readonly ["string", "text", "number", "integer", "boolean", "date", "datetime", "enum", "secret", "url", "email", "color", "json", "object", "array"];
33
+ type JsonFieldType = (typeof JSON_FIELD_TYPES)[number];
34
+ /**
35
+ * The long form of a `keyMap` entry. The short form — a bare type name — is
36
+ * sugar for `{ type }`.
37
+ */
38
+ interface JsonKeyRule {
39
+ type: JsonFieldType;
40
+ /** Overrides the raw key as the row's label. */
41
+ label?: string;
42
+ /** Choices for `type: "enum"`. Required there; ignored elsewhere. */
43
+ options?: InputOption[];
44
+ /** Render the value but never offer a control for it. */
45
+ readOnly?: boolean;
46
+ /** The key must be present. Only enforced on wildcard-free patterns. */
47
+ required?: boolean;
48
+ description?: string;
49
+ placeholder?: string;
50
+ /** Forwarded to the control for `number` / `integer` / `date` / `datetime`. */
51
+ min?: number | string;
52
+ max?: number | string;
53
+ }
54
+ /** One compiled `keyMap` entry: a path pattern plus the rule it imposes. */
55
+ interface JsonKeyMapEntry {
56
+ /** Path pattern; a `"*"` segment matches any single key or index. */
57
+ pattern: JsonPath;
58
+ rule: JsonKeyRule;
59
+ /** The key exactly as written in the `keyMap`, for error messages. */
60
+ source: string;
61
+ /** Non-wildcard segment count — the specificity score. */
62
+ literals: number;
63
+ /** Declaration order, the tie-breaker at equal specificity. */
64
+ order: number;
65
+ }
66
+ interface ParsedKeyMap {
67
+ /**
68
+ * `false` only when the STRING itself was unusable (unparseable, or valid
69
+ * JSON of the wrong shape). Individual bad rules leave this `true` — they are
70
+ * reported and skipped so one typo cannot silently disable a whole map.
71
+ */
72
+ ok: boolean;
73
+ rules: JsonKeyMapEntry[];
74
+ issues: JsonEditorIssue[];
75
+ }
76
+ /**
77
+ * Everything the editor knows to be wrong, in one shape.
78
+ *
79
+ * A typing feature that silently stops typing things is worse than no typing at
80
+ * all, because the caller believes the constraint is in force. So a broken
81
+ * `keyMap`, a broken rule inside a working one, and a value that contradicts
82
+ * its declared type all surface through the SAME channel — the panel, the
83
+ * `data-issues` count, and `onIssuesChange`.
84
+ */
85
+ interface JsonEditorIssue {
86
+ /**
87
+ * - `keymap` — the `keyMap` string could not be used at all.
88
+ * - `rule` — one entry in an otherwise-usable map is malformed.
89
+ * - `type` — a value contradicts the type declared for its path.
90
+ * - `edit` — a structural edit was refused (duplicate key, and the like).
91
+ */
92
+ kind: "keymap" | "rule" | "type" | "edit";
93
+ /** Dotted path; `""` for the `keyMap` as a whole. */
94
+ path: string;
95
+ message: string;
96
+ /** The declared type, when the issue has one. */
97
+ expected?: JsonFieldType;
98
+ /** What the value actually is: `"string"`, `"array"`, `"null"`, … */
99
+ actual?: string;
100
+ }
101
+ /**
102
+ * One mutation, as data.
103
+ *
104
+ * Every change the UI makes is expressed as one of these and applied through
105
+ * `applyJsonEdit`, which means an MCP bridge can replay exactly what a human
106
+ * did — and `pendingMode` can hold one in a queue instead of applying it —
107
+ * without a second code path.
108
+ */
109
+ type JsonEditorEditBase = {
110
+ id?: string;
111
+ /** Human-readable summary, used by the pending strip. */
112
+ label?: string;
113
+ };
114
+ type JsonEditorEdit = (JsonEditorEditBase & {
115
+ op: "set";
116
+ path: string;
117
+ value: JsonValue;
118
+ }) | (JsonEditorEditBase & {
119
+ op: "remove";
120
+ path: string;
121
+ }) | (JsonEditorEditBase & {
122
+ op: "rename";
123
+ path: string;
124
+ key: string;
125
+ })
126
+ /** `path` is the CONTAINER. `key` is required for an object, ignored for an array. */
127
+ | (JsonEditorEditBase & {
128
+ op: "insert";
129
+ path: string;
130
+ key?: string;
131
+ value: JsonValue;
132
+ })
133
+ /** `path` is the element; `to` is its new index in the same array. */
134
+ | (JsonEditorEditBase & {
135
+ op: "move";
136
+ path: string;
137
+ to: number;
138
+ });
139
+ type JsonEditorPendingEdit = JsonEditorEdit & {
140
+ id: string;
141
+ };
142
+ interface JsonEditorActivity {
143
+ /** `commit` — applied to the document. `stage` / `accept` / `reject` — pending flow. */
144
+ type: "commit" | "stage" | "accept" | "reject";
145
+ edit: JsonEditorEdit;
146
+ }
147
+ /** One rendered key/value row — also the unit a bridge would address. */
148
+ interface JsonEditorNode {
149
+ path: JsonPath;
150
+ /** `pathToString(path)`; `""` for a scalar root. */
151
+ dotted: string;
152
+ /** The last segment: an object key or an array index. */
153
+ key: string;
154
+ depth: number;
155
+ value: JsonValue;
156
+ parentKind: "object" | "array" | "root";
157
+ /** The rule that matched, if any. */
158
+ rule?: JsonKeyRule;
159
+ /** Declared type if a rule matched, otherwise inferred from the value. */
160
+ type: JsonFieldType;
161
+ declared: boolean;
162
+ /** Renders as a collapsible branch rather than a value. */
163
+ container: boolean;
164
+ childCount: number;
165
+ /** Set when the value contradicts its declared type. */
166
+ conflict?: JsonEditorIssue;
167
+ }
168
+ interface JsonEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue"> {
169
+ /** The document. Controlled — the editor keeps no copy of it. */
170
+ value: JsonValue;
171
+ /**
172
+ * Called with the WHOLE next document plus the edit that produced it. The
173
+ * edit is what a bridge would log, replay, or undo.
174
+ */
175
+ onChange?: (value: JsonValue, edit: JsonEditorEdit) => void;
176
+ /**
177
+ * Type declarations, as a **JSON string** — not an object, and an object is
178
+ * NOT accepted as a convenience overload.
179
+ *
180
+ * A string survives every boundary this prop actually crosses: an MCP tool
181
+ * argument, a config column, a `data-*` attribute, a form field. A live
182
+ * object survives none of them, so accepting both would make the documented
183
+ * form the second-class one in practice.
184
+ *
185
+ * ```jsonc
186
+ * {
187
+ * "user.age": "number", // short form: a bare type name
188
+ * "tags.*": "string", // every element of an array
189
+ * "orders.*.total": "number",
190
+ * "role": { "type": "enum", "options": ["admin", "member"] }
191
+ * }
192
+ * ```
193
+ *
194
+ * Malformed input is never thrown and never silently ignored — see
195
+ * {@link JsonEditorIssue}.
196
+ */
197
+ keyMap?: string | null;
198
+ /**
199
+ * `"view"` (the default here) renders values as text that turns into the
200
+ * typed control when clicked; `"edit"` renders every control at once.
201
+ *
202
+ * The kit default is `"edit"`, and this component deliberately differs: a
203
+ * forty-key document drawn as forty boxed inputs is not a document you can
204
+ * read, and reading is most of what a JSON editor is for.
205
+ */
206
+ mode?: FieldMode;
207
+ size?: Size;
208
+ /** Show every value, offer no control. Overrides `mode` and every `allow*`. */
209
+ readOnly?: boolean;
210
+ /**
211
+ * Dotted paths of the expanded containers. Omit BOTH this and
212
+ * `defaultExpanded` to expand everything (pass `defaultExpanded={[]}` for a
213
+ * large document).
214
+ */
215
+ expanded?: string[];
216
+ defaultExpanded?: string[];
217
+ onExpandedChange?: (expanded: string[]) => void;
218
+ /** Render the issues panel. The `data-issues` count and `onIssuesChange` are unaffected. */
219
+ showIssues?: boolean;
220
+ onIssuesChange?: (issues: JsonEditorIssue[]) => void;
221
+ /**
222
+ * Trust-but-verify. With this on, an edit is STAGED into `pending` instead of
223
+ * being applied: `onChange` does not fire until a human accepts it.
224
+ */
225
+ pendingMode?: boolean;
226
+ /** Staged edits. Controlled, so an agent's proposals are inspectable. */
227
+ pending?: JsonEditorPendingEdit[];
228
+ onPendingChange?: (pending: JsonEditorPendingEdit[]) => void;
229
+ /** Every mutation, staged or applied — the hook presence / undo layers listen on. */
230
+ onActivity?: (event: JsonEditorActivity) => void;
231
+ allowAdd?: boolean;
232
+ allowRemove?: boolean;
233
+ allowRename?: boolean;
234
+ allowReorder?: boolean;
235
+ /** Label for a scalar root document. Default `"value"`. */
236
+ rootLabel?: string;
237
+ /** Shown when the document has no keys. */
238
+ emptyLabel?: string;
239
+ /** Prefix for generated control ids — `<idPrefix>-<dotted path>`. */
240
+ idPrefix?: string;
241
+ }
242
+
243
+ /**
244
+ * JsonEditor — a key/value editor over arbitrary, arbitrarily-nested JSON, with
245
+ * a caller-supplied `keyMap` imposing a data type on any path.
246
+ *
247
+ * The type does two jobs at once, which is the point of the feature: it decides
248
+ * how a value is RENDERED when you are reading, and which control appears when
249
+ * you are editing. `{"user.age": "number"}` is not documentation — it is the
250
+ * reason that row is a numeric field and the reason `"thirty-six"` shows up in
251
+ * red instead of quietly becoming `0`.
252
+ *
253
+ * The three design decisions worth knowing before you use it:
254
+ *
255
+ * - **`keyMap` is a JSON string, and only a string.** It has to survive an MCP
256
+ * tool argument, a config column and a `data-*` attribute; a live object
257
+ * survives none of those. See {@link JsonEditorProps.keyMap}.
258
+ * - **Nothing is coerced and nothing is dropped.** A value that contradicts
259
+ * its declared type keeps its real value, renders through the raw editor,
260
+ * and is reported through the issues panel, the `data-issues` count and
261
+ * `onIssuesChange` — the same channel a broken `keyMap` uses.
262
+ * - **It is controlled, all the way down.** The document lives in `value`.
263
+ * The only state here is which rows are expanded, which add-form is open,
264
+ * and the half-typed text inside a control that has not committed yet.
265
+ *
266
+ * Every control is a `react-fancy` primitive, so restyling the kit restyles
267
+ * this, and `mode="view"` gets the kit's click-to-edit behaviour for free.
268
+ */
269
+ declare const JsonEditor: react.ForwardRefExoticComponent<JsonEditorProps & react.RefAttributes<HTMLDivElement>>;
270
+
271
+ /**
272
+ * Compile a `keyMap` JSON **string**.
273
+ *
274
+ * Never throws. Two failure modes, deliberately distinct:
275
+ *
276
+ * - The string itself is unusable (not JSON, or JSON that is not an object) —
277
+ * `ok: false`, no rules, one `keymap` issue. The caller must show this: an
278
+ * editor that quietly runs untyped is worse than one that refuses, because
279
+ * the person editing believes the constraint is in force.
280
+ * - One entry is malformed — `ok: true`, that entry dropped, one `rule` issue.
281
+ * A typo in `orders.*.totl` must not disable the other forty rules.
282
+ */
283
+ declare function parseKeyMap(source?: string | null): ParsedKeyMap;
284
+ /**
285
+ * The rule governing `segments`, or `undefined` when the map is silent.
286
+ *
287
+ * Specificity: the pattern with the most literal (non-`*`) segments wins, and
288
+ * at equal specificity the one declared LAST wins — so a general
289
+ * `orders.*.total` can be overridden by a specific `orders.0.total` placed
290
+ * anywhere in the map.
291
+ */
292
+ declare function resolveKeyRule(rules: JsonKeyMapEntry[], segments: JsonPath): JsonKeyRule | undefined;
293
+ /** The type a value carries on its own, when nothing declares one for it. */
294
+ declare function inferType(value: JsonValue | undefined): JsonFieldType;
295
+ /**
296
+ * Does the value satisfy the declared type?
297
+ *
298
+ * Deliberately strict and deliberately non-coercing. `"36"` is NOT a number
299
+ * here — the whole reason a `keyMap` exists is to make that visible rather than
300
+ * to paper over it.
301
+ */
302
+ declare function typeMatches(rule: JsonKeyRule, value: JsonValue | undefined): boolean;
303
+ /**
304
+ * Every place the document contradicts its `keyMap`.
305
+ *
306
+ * Walks the value (so a conflict is found at any depth, arrays included), then
307
+ * checks `required` on the wildcard-free patterns — a wildcard cannot say "this
308
+ * must exist" about a key nobody has named.
309
+ */
310
+ declare function findJsonConflicts(value: JsonValue, rules: JsonKeyMapEntry[]): JsonEditorIssue[];
311
+
312
+ /** Split a dotted path into segments, honouring `\.` and `\\`. */
313
+ declare function parsePath(path: string): JsonPath;
314
+ /** The inverse of {@link parsePath}. */
315
+ declare function pathToString(segments: JsonPath): string;
316
+ declare function getAtPath(value: JsonValue, segments: JsonPath): JsonValue | undefined;
317
+ /**
318
+ * Apply one {@link JsonEditorEdit} and return a NEW document.
319
+ *
320
+ * Pure and total: an edit that cannot be applied — a path that does not exist,
321
+ * a rename onto an occupied key, an insert without a key into an object —
322
+ * returns the input unchanged rather than throwing or half-applying. The
323
+ * component checks those cases first and raises an issue; this function is the
324
+ * backstop for the same op arriving from a bridge, where there is no UI to warn.
325
+ */
326
+ declare function applyJsonEdit(value: JsonValue, edit: JsonEditorEdit): JsonValue;
327
+ /** A one-line summary of an edit, for the pending strip and activity events. */
328
+ declare function describeEdit(edit: JsonEditorEdit): string;
329
+
330
+ export { JSON_FIELD_TYPES as J, type ParsedKeyMap as P, type JsonArray as a, JsonEditor as b, type JsonEditorActivity as c, type JsonEditorEdit as d, type JsonEditorIssue as e, type JsonEditorNode as f, type JsonEditorPendingEdit as g, type JsonEditorProps as h, type JsonFieldType as i, type JsonKeyMapEntry as j, type JsonKeyRule as k, type JsonObject as l, type JsonPath as m, type JsonPrimitive as n, type JsonValue as o, applyJsonEdit as p, describeEdit as q, findJsonConflicts as r, getAtPath as s, inferType as t, parseKeyMap as u, parsePath as v, pathToString as w, resolveKeyRule as x, typeMatches as y };
@@ -0,0 +1,330 @@
1
+ import * as react from 'react';
2
+ import { HTMLAttributes } from 'react';
3
+ import { F as FieldMode, b as InputOption } from './inputs.types-CkWdvN-t.cjs';
4
+ import { S as Size } from './types-8Sv0rCjw.cjs';
5
+
6
+ type JsonPrimitive = string | number | boolean | null;
7
+ interface JsonObject {
8
+ [key: string]: JsonValue;
9
+ }
10
+ type JsonArray = JsonValue[];
11
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
12
+ /**
13
+ * A location inside a JSON document, one array element per segment. Array
14
+ * indices are decimal STRINGS (`["orders", "0", "total"]`) so a path is a plain
15
+ * `string[]` an agent can emit without a tagged union, and so object keys and
16
+ * array indices are addressed identically.
17
+ *
18
+ * The wire form is the dotted string produced by `pathToString` — see
19
+ * `JsonEditor.paths.ts` for the escaping rule.
20
+ */
21
+ type JsonPath = string[];
22
+ /**
23
+ * The data types a `keyMap` can impose on a JSON value.
24
+ *
25
+ * Each one owes BOTH a read-only representation and an edit control — that
26
+ * pairing is the whole point of the feature, so a type with no distinct input
27
+ * does not earn a place here.
28
+ *
29
+ * `json` is the escape hatch: it matches any value and edits as raw text, which
30
+ * is how a sub-document opts out of the row-per-key treatment.
31
+ */
32
+ declare const JSON_FIELD_TYPES: readonly ["string", "text", "number", "integer", "boolean", "date", "datetime", "enum", "secret", "url", "email", "color", "json", "object", "array"];
33
+ type JsonFieldType = (typeof JSON_FIELD_TYPES)[number];
34
+ /**
35
+ * The long form of a `keyMap` entry. The short form — a bare type name — is
36
+ * sugar for `{ type }`.
37
+ */
38
+ interface JsonKeyRule {
39
+ type: JsonFieldType;
40
+ /** Overrides the raw key as the row's label. */
41
+ label?: string;
42
+ /** Choices for `type: "enum"`. Required there; ignored elsewhere. */
43
+ options?: InputOption[];
44
+ /** Render the value but never offer a control for it. */
45
+ readOnly?: boolean;
46
+ /** The key must be present. Only enforced on wildcard-free patterns. */
47
+ required?: boolean;
48
+ description?: string;
49
+ placeholder?: string;
50
+ /** Forwarded to the control for `number` / `integer` / `date` / `datetime`. */
51
+ min?: number | string;
52
+ max?: number | string;
53
+ }
54
+ /** One compiled `keyMap` entry: a path pattern plus the rule it imposes. */
55
+ interface JsonKeyMapEntry {
56
+ /** Path pattern; a `"*"` segment matches any single key or index. */
57
+ pattern: JsonPath;
58
+ rule: JsonKeyRule;
59
+ /** The key exactly as written in the `keyMap`, for error messages. */
60
+ source: string;
61
+ /** Non-wildcard segment count — the specificity score. */
62
+ literals: number;
63
+ /** Declaration order, the tie-breaker at equal specificity. */
64
+ order: number;
65
+ }
66
+ interface ParsedKeyMap {
67
+ /**
68
+ * `false` only when the STRING itself was unusable (unparseable, or valid
69
+ * JSON of the wrong shape). Individual bad rules leave this `true` — they are
70
+ * reported and skipped so one typo cannot silently disable a whole map.
71
+ */
72
+ ok: boolean;
73
+ rules: JsonKeyMapEntry[];
74
+ issues: JsonEditorIssue[];
75
+ }
76
+ /**
77
+ * Everything the editor knows to be wrong, in one shape.
78
+ *
79
+ * A typing feature that silently stops typing things is worse than no typing at
80
+ * all, because the caller believes the constraint is in force. So a broken
81
+ * `keyMap`, a broken rule inside a working one, and a value that contradicts
82
+ * its declared type all surface through the SAME channel — the panel, the
83
+ * `data-issues` count, and `onIssuesChange`.
84
+ */
85
+ interface JsonEditorIssue {
86
+ /**
87
+ * - `keymap` — the `keyMap` string could not be used at all.
88
+ * - `rule` — one entry in an otherwise-usable map is malformed.
89
+ * - `type` — a value contradicts the type declared for its path.
90
+ * - `edit` — a structural edit was refused (duplicate key, and the like).
91
+ */
92
+ kind: "keymap" | "rule" | "type" | "edit";
93
+ /** Dotted path; `""` for the `keyMap` as a whole. */
94
+ path: string;
95
+ message: string;
96
+ /** The declared type, when the issue has one. */
97
+ expected?: JsonFieldType;
98
+ /** What the value actually is: `"string"`, `"array"`, `"null"`, … */
99
+ actual?: string;
100
+ }
101
+ /**
102
+ * One mutation, as data.
103
+ *
104
+ * Every change the UI makes is expressed as one of these and applied through
105
+ * `applyJsonEdit`, which means an MCP bridge can replay exactly what a human
106
+ * did — and `pendingMode` can hold one in a queue instead of applying it —
107
+ * without a second code path.
108
+ */
109
+ type JsonEditorEditBase = {
110
+ id?: string;
111
+ /** Human-readable summary, used by the pending strip. */
112
+ label?: string;
113
+ };
114
+ type JsonEditorEdit = (JsonEditorEditBase & {
115
+ op: "set";
116
+ path: string;
117
+ value: JsonValue;
118
+ }) | (JsonEditorEditBase & {
119
+ op: "remove";
120
+ path: string;
121
+ }) | (JsonEditorEditBase & {
122
+ op: "rename";
123
+ path: string;
124
+ key: string;
125
+ })
126
+ /** `path` is the CONTAINER. `key` is required for an object, ignored for an array. */
127
+ | (JsonEditorEditBase & {
128
+ op: "insert";
129
+ path: string;
130
+ key?: string;
131
+ value: JsonValue;
132
+ })
133
+ /** `path` is the element; `to` is its new index in the same array. */
134
+ | (JsonEditorEditBase & {
135
+ op: "move";
136
+ path: string;
137
+ to: number;
138
+ });
139
+ type JsonEditorPendingEdit = JsonEditorEdit & {
140
+ id: string;
141
+ };
142
+ interface JsonEditorActivity {
143
+ /** `commit` — applied to the document. `stage` / `accept` / `reject` — pending flow. */
144
+ type: "commit" | "stage" | "accept" | "reject";
145
+ edit: JsonEditorEdit;
146
+ }
147
+ /** One rendered key/value row — also the unit a bridge would address. */
148
+ interface JsonEditorNode {
149
+ path: JsonPath;
150
+ /** `pathToString(path)`; `""` for a scalar root. */
151
+ dotted: string;
152
+ /** The last segment: an object key or an array index. */
153
+ key: string;
154
+ depth: number;
155
+ value: JsonValue;
156
+ parentKind: "object" | "array" | "root";
157
+ /** The rule that matched, if any. */
158
+ rule?: JsonKeyRule;
159
+ /** Declared type if a rule matched, otherwise inferred from the value. */
160
+ type: JsonFieldType;
161
+ declared: boolean;
162
+ /** Renders as a collapsible branch rather than a value. */
163
+ container: boolean;
164
+ childCount: number;
165
+ /** Set when the value contradicts its declared type. */
166
+ conflict?: JsonEditorIssue;
167
+ }
168
+ interface JsonEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue"> {
169
+ /** The document. Controlled — the editor keeps no copy of it. */
170
+ value: JsonValue;
171
+ /**
172
+ * Called with the WHOLE next document plus the edit that produced it. The
173
+ * edit is what a bridge would log, replay, or undo.
174
+ */
175
+ onChange?: (value: JsonValue, edit: JsonEditorEdit) => void;
176
+ /**
177
+ * Type declarations, as a **JSON string** — not an object, and an object is
178
+ * NOT accepted as a convenience overload.
179
+ *
180
+ * A string survives every boundary this prop actually crosses: an MCP tool
181
+ * argument, a config column, a `data-*` attribute, a form field. A live
182
+ * object survives none of them, so accepting both would make the documented
183
+ * form the second-class one in practice.
184
+ *
185
+ * ```jsonc
186
+ * {
187
+ * "user.age": "number", // short form: a bare type name
188
+ * "tags.*": "string", // every element of an array
189
+ * "orders.*.total": "number",
190
+ * "role": { "type": "enum", "options": ["admin", "member"] }
191
+ * }
192
+ * ```
193
+ *
194
+ * Malformed input is never thrown and never silently ignored — see
195
+ * {@link JsonEditorIssue}.
196
+ */
197
+ keyMap?: string | null;
198
+ /**
199
+ * `"view"` (the default here) renders values as text that turns into the
200
+ * typed control when clicked; `"edit"` renders every control at once.
201
+ *
202
+ * The kit default is `"edit"`, and this component deliberately differs: a
203
+ * forty-key document drawn as forty boxed inputs is not a document you can
204
+ * read, and reading is most of what a JSON editor is for.
205
+ */
206
+ mode?: FieldMode;
207
+ size?: Size;
208
+ /** Show every value, offer no control. Overrides `mode` and every `allow*`. */
209
+ readOnly?: boolean;
210
+ /**
211
+ * Dotted paths of the expanded containers. Omit BOTH this and
212
+ * `defaultExpanded` to expand everything (pass `defaultExpanded={[]}` for a
213
+ * large document).
214
+ */
215
+ expanded?: string[];
216
+ defaultExpanded?: string[];
217
+ onExpandedChange?: (expanded: string[]) => void;
218
+ /** Render the issues panel. The `data-issues` count and `onIssuesChange` are unaffected. */
219
+ showIssues?: boolean;
220
+ onIssuesChange?: (issues: JsonEditorIssue[]) => void;
221
+ /**
222
+ * Trust-but-verify. With this on, an edit is STAGED into `pending` instead of
223
+ * being applied: `onChange` does not fire until a human accepts it.
224
+ */
225
+ pendingMode?: boolean;
226
+ /** Staged edits. Controlled, so an agent's proposals are inspectable. */
227
+ pending?: JsonEditorPendingEdit[];
228
+ onPendingChange?: (pending: JsonEditorPendingEdit[]) => void;
229
+ /** Every mutation, staged or applied — the hook presence / undo layers listen on. */
230
+ onActivity?: (event: JsonEditorActivity) => void;
231
+ allowAdd?: boolean;
232
+ allowRemove?: boolean;
233
+ allowRename?: boolean;
234
+ allowReorder?: boolean;
235
+ /** Label for a scalar root document. Default `"value"`. */
236
+ rootLabel?: string;
237
+ /** Shown when the document has no keys. */
238
+ emptyLabel?: string;
239
+ /** Prefix for generated control ids — `<idPrefix>-<dotted path>`. */
240
+ idPrefix?: string;
241
+ }
242
+
243
+ /**
244
+ * JsonEditor — a key/value editor over arbitrary, arbitrarily-nested JSON, with
245
+ * a caller-supplied `keyMap` imposing a data type on any path.
246
+ *
247
+ * The type does two jobs at once, which is the point of the feature: it decides
248
+ * how a value is RENDERED when you are reading, and which control appears when
249
+ * you are editing. `{"user.age": "number"}` is not documentation — it is the
250
+ * reason that row is a numeric field and the reason `"thirty-six"` shows up in
251
+ * red instead of quietly becoming `0`.
252
+ *
253
+ * The three design decisions worth knowing before you use it:
254
+ *
255
+ * - **`keyMap` is a JSON string, and only a string.** It has to survive an MCP
256
+ * tool argument, a config column and a `data-*` attribute; a live object
257
+ * survives none of those. See {@link JsonEditorProps.keyMap}.
258
+ * - **Nothing is coerced and nothing is dropped.** A value that contradicts
259
+ * its declared type keeps its real value, renders through the raw editor,
260
+ * and is reported through the issues panel, the `data-issues` count and
261
+ * `onIssuesChange` — the same channel a broken `keyMap` uses.
262
+ * - **It is controlled, all the way down.** The document lives in `value`.
263
+ * The only state here is which rows are expanded, which add-form is open,
264
+ * and the half-typed text inside a control that has not committed yet.
265
+ *
266
+ * Every control is a `react-fancy` primitive, so restyling the kit restyles
267
+ * this, and `mode="view"` gets the kit's click-to-edit behaviour for free.
268
+ */
269
+ declare const JsonEditor: react.ForwardRefExoticComponent<JsonEditorProps & react.RefAttributes<HTMLDivElement>>;
270
+
271
+ /**
272
+ * Compile a `keyMap` JSON **string**.
273
+ *
274
+ * Never throws. Two failure modes, deliberately distinct:
275
+ *
276
+ * - The string itself is unusable (not JSON, or JSON that is not an object) —
277
+ * `ok: false`, no rules, one `keymap` issue. The caller must show this: an
278
+ * editor that quietly runs untyped is worse than one that refuses, because
279
+ * the person editing believes the constraint is in force.
280
+ * - One entry is malformed — `ok: true`, that entry dropped, one `rule` issue.
281
+ * A typo in `orders.*.totl` must not disable the other forty rules.
282
+ */
283
+ declare function parseKeyMap(source?: string | null): ParsedKeyMap;
284
+ /**
285
+ * The rule governing `segments`, or `undefined` when the map is silent.
286
+ *
287
+ * Specificity: the pattern with the most literal (non-`*`) segments wins, and
288
+ * at equal specificity the one declared LAST wins — so a general
289
+ * `orders.*.total` can be overridden by a specific `orders.0.total` placed
290
+ * anywhere in the map.
291
+ */
292
+ declare function resolveKeyRule(rules: JsonKeyMapEntry[], segments: JsonPath): JsonKeyRule | undefined;
293
+ /** The type a value carries on its own, when nothing declares one for it. */
294
+ declare function inferType(value: JsonValue | undefined): JsonFieldType;
295
+ /**
296
+ * Does the value satisfy the declared type?
297
+ *
298
+ * Deliberately strict and deliberately non-coercing. `"36"` is NOT a number
299
+ * here — the whole reason a `keyMap` exists is to make that visible rather than
300
+ * to paper over it.
301
+ */
302
+ declare function typeMatches(rule: JsonKeyRule, value: JsonValue | undefined): boolean;
303
+ /**
304
+ * Every place the document contradicts its `keyMap`.
305
+ *
306
+ * Walks the value (so a conflict is found at any depth, arrays included), then
307
+ * checks `required` on the wildcard-free patterns — a wildcard cannot say "this
308
+ * must exist" about a key nobody has named.
309
+ */
310
+ declare function findJsonConflicts(value: JsonValue, rules: JsonKeyMapEntry[]): JsonEditorIssue[];
311
+
312
+ /** Split a dotted path into segments, honouring `\.` and `\\`. */
313
+ declare function parsePath(path: string): JsonPath;
314
+ /** The inverse of {@link parsePath}. */
315
+ declare function pathToString(segments: JsonPath): string;
316
+ declare function getAtPath(value: JsonValue, segments: JsonPath): JsonValue | undefined;
317
+ /**
318
+ * Apply one {@link JsonEditorEdit} and return a NEW document.
319
+ *
320
+ * Pure and total: an edit that cannot be applied — a path that does not exist,
321
+ * a rename onto an occupied key, an insert without a key into an object —
322
+ * returns the input unchanged rather than throwing or half-applying. The
323
+ * component checks those cases first and raises an issue; this function is the
324
+ * backstop for the same op arriving from a bridge, where there is no UI to warn.
325
+ */
326
+ declare function applyJsonEdit(value: JsonValue, edit: JsonEditorEdit): JsonValue;
327
+ /** A one-line summary of an edit, for the pending strip and activity events. */
328
+ declare function describeEdit(edit: JsonEditorEdit): string;
329
+
330
+ export { JSON_FIELD_TYPES as J, type ParsedKeyMap as P, type JsonArray as a, JsonEditor as b, type JsonEditorActivity as c, type JsonEditorEdit as d, type JsonEditorIssue as e, type JsonEditorNode as f, type JsonEditorPendingEdit as g, type JsonEditorProps as h, type JsonFieldType as i, type JsonKeyMapEntry as j, type JsonKeyRule as k, type JsonObject as l, type JsonPath as m, type JsonPrimitive as n, type JsonValue as o, applyJsonEdit as p, describeEdit as q, findJsonConflicts as r, getAtPath as s, inferType as t, parseKeyMap as u, parsePath as v, pathToString as w, resolveKeyRule as x, typeMatches as y };