@particle-academy/react-fancy 5.69.0 → 5.70.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/CHANGELOG.md +73 -0
- package/dist/autocomplete.cjs +3 -2
- package/dist/autocomplete.js +2 -1
- package/dist/chunk-2C64OVOZ.cjs +18 -0
- package/dist/chunk-2C64OVOZ.cjs.map +1 -0
- package/dist/{chunk-BX7EDTL4.js → chunk-37D5PYEF.js} +4 -3
- package/dist/chunk-37D5PYEF.js.map +1 -0
- package/dist/{chunk-UJRMY54A.cjs → chunk-3QCAOD2W.cjs} +4 -2
- package/dist/chunk-3QCAOD2W.cjs.map +1 -0
- package/dist/{chunk-KSU6RYWU.cjs → chunk-3T3LBIQA.cjs} +4 -2
- package/dist/chunk-3T3LBIQA.cjs.map +1 -0
- package/dist/{chunk-O4KZYGGC.cjs → chunk-5YRSYS2F.cjs} +10 -10
- package/dist/{chunk-O4KZYGGC.cjs.map → chunk-5YRSYS2F.cjs.map} +1 -1
- package/dist/{chunk-2PSHIUM7.cjs → chunk-6EA3DSPT.cjs} +14 -13
- package/dist/chunk-6EA3DSPT.cjs.map +1 -0
- package/dist/{chunk-4WIPWJYD.js → chunk-6PRXG7L6.js} +4 -3
- package/dist/chunk-6PRXG7L6.js.map +1 -0
- package/dist/{chunk-WKPBCB67.cjs → chunk-6QAF35AJ.cjs} +4 -2
- package/dist/chunk-6QAF35AJ.cjs.map +1 -0
- package/dist/chunk-6V44RRSB.cjs +11 -0
- package/dist/chunk-6V44RRSB.cjs.map +1 -0
- package/dist/{chunk-G35XN5WV.js → chunk-CDW7MFPG.js} +4 -2
- package/dist/chunk-CDW7MFPG.js.map +1 -0
- package/dist/{chunk-U4PWNLOH.js → chunk-EZL5DILH.js} +7 -6
- package/dist/chunk-EZL5DILH.js.map +1 -0
- package/dist/{chunk-ARO2DNGS.js → chunk-EZZKHMR4.js} +4 -2
- package/dist/chunk-EZZKHMR4.js.map +1 -0
- package/dist/{chunk-LLVYCACC.js → chunk-F4GMOMUT.js} +3 -3
- package/dist/{chunk-LLVYCACC.js.map → chunk-F4GMOMUT.js.map} +1 -1
- package/dist/{chunk-R6URPHEP.cjs → chunk-FHRVSYJU.cjs} +4 -3
- package/dist/chunk-FHRVSYJU.cjs.map +1 -0
- package/dist/{chunk-HRZDEZSE.js → chunk-FYUEDPST.js} +95 -23
- package/dist/chunk-FYUEDPST.js.map +1 -0
- package/dist/{chunk-4UEIMGHZ.js → chunk-GDH43QH6.js} +59 -11
- package/dist/chunk-GDH43QH6.js.map +1 -0
- package/dist/{chunk-J5TFVYYM.cjs → chunk-HNJXBMHI.cjs} +6 -6
- package/dist/{chunk-J5TFVYYM.cjs.map → chunk-HNJXBMHI.cjs.map} +1 -1
- package/dist/chunk-I3LAFKJU.js +16 -0
- package/dist/chunk-I3LAFKJU.js.map +1 -0
- package/dist/chunk-J6IQHJET.js +76 -0
- package/dist/chunk-J6IQHJET.js.map +1 -0
- package/dist/chunk-JKD6CFIP.cjs +78 -0
- package/dist/chunk-JKD6CFIP.cjs.map +1 -0
- package/dist/{chunk-YJETQ76J.cjs → chunk-KKYILQTG.cjs} +4 -3
- package/dist/chunk-KKYILQTG.cjs.map +1 -0
- package/dist/{chunk-FVI4JDLA.js → chunk-M6UAVA2I.js} +4 -2
- package/dist/chunk-M6UAVA2I.js.map +1 -0
- package/dist/{chunk-Z6RA37IC.js → chunk-NAYXNVNU.js} +3 -15
- package/dist/chunk-NAYXNVNU.js.map +1 -0
- package/dist/{chunk-FPFQBYKJ.cjs → chunk-NPSKZ7ZB.cjs} +65 -17
- package/dist/chunk-NPSKZ7ZB.cjs.map +1 -0
- package/dist/{chunk-G5DMYAWL.cjs → chunk-O5ORO2RX.cjs} +5 -2
- package/dist/chunk-O5ORO2RX.cjs.map +1 -0
- package/dist/{chunk-YEGFOMJB.js → chunk-PJNUGSKI.js} +3 -3
- package/dist/{chunk-YEGFOMJB.js.map → chunk-PJNUGSKI.js.map} +1 -1
- package/dist/{chunk-ISNS4GAW.cjs → chunk-PS7C6GKI.cjs} +100 -28
- package/dist/chunk-PS7C6GKI.cjs.map +1 -0
- package/dist/{chunk-KGJ2ORY6.cjs → chunk-R3EJNGJV.cjs} +4 -16
- package/dist/chunk-R3EJNGJV.cjs.map +1 -0
- package/dist/chunk-S42OGG43.js +9 -0
- package/dist/chunk-S42OGG43.js.map +1 -0
- package/dist/{chunk-VZNBTCGA.js → chunk-TCMOD3WW.js} +4 -3
- package/dist/chunk-TCMOD3WW.js.map +1 -0
- package/dist/{chunk-6MXFZ3B5.cjs → chunk-UK6BGM74.cjs} +4 -3
- package/dist/chunk-UK6BGM74.cjs.map +1 -0
- package/dist/{chunk-XS3EIQFP.js → chunk-WZAKEJDL.js} +5 -2
- package/dist/chunk-WZAKEJDL.js.map +1 -0
- package/dist/command.cjs +4 -3
- package/dist/command.js +2 -1
- package/dist/composer.cjs +7 -4
- package/dist/composer.d.cts +45 -2
- package/dist/composer.d.ts +45 -2
- package/dist/composer.js +5 -2
- package/dist/content-renderer.cjs +5 -4
- package/dist/content-renderer.js +2 -1
- package/dist/editor.cjs +5 -4
- package/dist/editor.js +3 -2
- package/dist/file-browser.cjs +6 -5
- package/dist/file-browser.js +2 -1
- package/dist/{index-BQi_n6eS.d.ts → index-B8OkuYSt.d.ts} +49 -2
- package/dist/{index-n_4_OZK_.d.cts → index-BMVQnKTH.d.cts} +49 -2
- package/dist/index.cjs +61 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +16 -13
- package/dist/index.js.map +1 -1
- package/dist/input-tag.cjs +7 -6
- package/dist/input-tag.js +2 -1
- package/dist/input.cjs +4 -3
- package/dist/input.js +3 -2
- package/dist/inputs.cjs +6 -5
- package/dist/inputs.js +4 -3
- package/dist/json-editor.cjs +16 -15
- package/dist/json-editor.js +5 -4
- package/dist/paste-pills.cjs +15 -14
- package/dist/paste-pills.js +2 -1
- package/dist/pillbox.cjs +3 -2
- package/dist/pillbox.js +2 -1
- package/dist/prompt-input.cjs +8 -5
- package/dist/prompt-input.d.cts +2 -1
- package/dist/prompt-input.d.ts +2 -1
- package/dist/prompt-input.js +5 -2
- package/dist/select.cjs +3 -2
- package/dist/select.js +2 -1
- package/dist/use-acknowledged-submit-7nC0vSCP.d.cts +12 -0
- package/dist/use-acknowledged-submit-7nC0vSCP.d.ts +12 -0
- package/docs/Composer.md +65 -2
- package/docs/PromptInput.md +70 -4
- package/package.json +1 -1
- package/dist/chunk-2PSHIUM7.cjs.map +0 -1
- package/dist/chunk-4UEIMGHZ.js.map +0 -1
- package/dist/chunk-4WIPWJYD.js.map +0 -1
- package/dist/chunk-6MXFZ3B5.cjs.map +0 -1
- package/dist/chunk-ARO2DNGS.js.map +0 -1
- package/dist/chunk-BX7EDTL4.js.map +0 -1
- package/dist/chunk-FPFQBYKJ.cjs.map +0 -1
- package/dist/chunk-FVI4JDLA.js.map +0 -1
- package/dist/chunk-G35XN5WV.js.map +0 -1
- package/dist/chunk-G5DMYAWL.cjs.map +0 -1
- package/dist/chunk-HRZDEZSE.js.map +0 -1
- package/dist/chunk-ISNS4GAW.cjs.map +0 -1
- package/dist/chunk-KGJ2ORY6.cjs.map +0 -1
- package/dist/chunk-KSU6RYWU.cjs.map +0 -1
- package/dist/chunk-R6URPHEP.cjs.map +0 -1
- package/dist/chunk-U4PWNLOH.js.map +0 -1
- package/dist/chunk-UJRMY54A.cjs.map +0 -1
- package/dist/chunk-VZNBTCGA.js.map +0 -1
- package/dist/chunk-WKPBCB67.cjs.map +0 -1
- package/dist/chunk-XS3EIQFP.js.map +0 -1
- package/dist/chunk-YJETQ76J.cjs.map +0 -1
- package/dist/chunk-Z6RA37IC.js.map +0 -1
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
var chunk2O5UXH5R_cjs = require('./chunk-2O5UXH5R.cjs');
|
|
4
4
|
var chunkTLRFXSPA_cjs = require('./chunk-TLRFXSPA.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var chunkHNJXBMHI_cjs = require('./chunk-HNJXBMHI.cjs');
|
|
6
|
+
var chunk6QAF35AJ_cjs = require('./chunk-6QAF35AJ.cjs');
|
|
7
7
|
var chunkMAZEX4EZ_cjs = require('./chunk-MAZEX4EZ.cjs');
|
|
8
8
|
var chunkP53432AK_cjs = require('./chunk-P53432AK.cjs');
|
|
9
9
|
var chunkO3F6DYWR_cjs = require('./chunk-O3F6DYWR.cjs');
|
|
10
10
|
var chunk4XMBXG4K_cjs = require('./chunk-4XMBXG4K.cjs');
|
|
11
11
|
var chunkGKLETY7D_cjs = require('./chunk-GKLETY7D.cjs');
|
|
12
12
|
var chunkKJ22KE56_cjs = require('./chunk-KJ22KE56.cjs');
|
|
13
|
+
var chunk6V44RRSB_cjs = require('./chunk-6V44RRSB.cjs');
|
|
13
14
|
var chunkMOU6O324_cjs = require('./chunk-MOU6O324.cjs');
|
|
14
15
|
var chunk3U7PUZLI_cjs = require('./chunk-3U7PUZLI.cjs');
|
|
15
16
|
var chunkLCNHEYIM_cjs = require('./chunk-LCNHEYIM.cjs');
|
|
@@ -522,7 +523,7 @@ function JsonEditorValue({ node, mode, size, readOnly, id, onCommit }) {
|
|
|
522
523
|
case "enum": {
|
|
523
524
|
const options = rule?.options ?? [];
|
|
524
525
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
525
|
-
|
|
526
|
+
chunk6QAF35AJ_cjs.Select,
|
|
526
527
|
{
|
|
527
528
|
...common,
|
|
528
529
|
list: options,
|
|
@@ -572,7 +573,7 @@ function JsonEditorValue({ node, mode, size, readOnly, id, onCommit }) {
|
|
|
572
573
|
);
|
|
573
574
|
case "secret":
|
|
574
575
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
575
|
-
|
|
576
|
+
chunkHNJXBMHI_cjs.Input,
|
|
576
577
|
{
|
|
577
578
|
...common,
|
|
578
579
|
type: "password",
|
|
@@ -587,7 +588,7 @@ function JsonEditorValue({ node, mode, size, readOnly, id, onCommit }) {
|
|
|
587
588
|
case "string":
|
|
588
589
|
default:
|
|
589
590
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
590
|
-
|
|
591
|
+
chunkHNJXBMHI_cjs.Input,
|
|
591
592
|
{
|
|
592
593
|
...common,
|
|
593
594
|
type: node.type === "url" ? "url" : node.type === "email" ? "email" : "text",
|
|
@@ -639,7 +640,7 @@ function RawValueEditor({
|
|
|
639
640
|
);
|
|
640
641
|
}
|
|
641
642
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
642
|
-
|
|
643
|
+
chunkHNJXBMHI_cjs.Input,
|
|
643
644
|
{
|
|
644
645
|
id,
|
|
645
646
|
size,
|
|
@@ -652,7 +653,7 @@ function RawValueEditor({
|
|
|
652
653
|
spellCheck: false,
|
|
653
654
|
autoFocus: interactive,
|
|
654
655
|
onKeyDown: (event) => {
|
|
655
|
-
if (event.key === "Enter") event.currentTarget.blur();
|
|
656
|
+
if (event.key === "Enter" && !chunk6V44RRSB_cjs.isImeComposing(event)) event.currentTarget.blur();
|
|
656
657
|
},
|
|
657
658
|
onBlur: (event) => {
|
|
658
659
|
commit(event.currentTarget.value);
|
|
@@ -712,7 +713,7 @@ function JsonEditorRow({ node }) {
|
|
|
712
713
|
className: "w-1/3 min-w-0 shrink-0",
|
|
713
714
|
children: [
|
|
714
715
|
renameable ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
715
|
-
|
|
716
|
+
chunkHNJXBMHI_cjs.Input,
|
|
716
717
|
{
|
|
717
718
|
size: ctx.size,
|
|
718
719
|
mode: "edit",
|
|
@@ -720,7 +721,7 @@ function JsonEditorRow({ node }) {
|
|
|
720
721
|
spellCheck: false,
|
|
721
722
|
"aria-label": `Key of ${dotted}`,
|
|
722
723
|
onKeyDown: (event) => {
|
|
723
|
-
if (event.key === "Enter") event.currentTarget.blur();
|
|
724
|
+
if (event.key === "Enter" && !chunk6V44RRSB_cjs.isImeComposing(event)) event.currentTarget.blur();
|
|
724
725
|
},
|
|
725
726
|
onBlur: (event) => {
|
|
726
727
|
const next = event.currentTarget.value;
|
|
@@ -889,7 +890,7 @@ function JsonEditorAddForm({ path, kind, depth, suggestedType }) {
|
|
|
889
890
|
style: { paddingInlineStart: depth * INDENT + 32 },
|
|
890
891
|
children: [
|
|
891
892
|
kind === "object" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
892
|
-
|
|
893
|
+
chunkHNJXBMHI_cjs.Input,
|
|
893
894
|
{
|
|
894
895
|
size: ctx.size,
|
|
895
896
|
mode: "edit",
|
|
@@ -902,7 +903,7 @@ function JsonEditorAddForm({ path, kind, depth, suggestedType }) {
|
|
|
902
903
|
}
|
|
903
904
|
),
|
|
904
905
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
905
|
-
|
|
906
|
+
chunk6QAF35AJ_cjs.Select,
|
|
906
907
|
{
|
|
907
908
|
size: ctx.size,
|
|
908
909
|
mode: "edit",
|
|
@@ -1350,5 +1351,5 @@ exports.parsePath = parsePath;
|
|
|
1350
1351
|
exports.pathToString = pathToString;
|
|
1351
1352
|
exports.resolveKeyRule = resolveKeyRule;
|
|
1352
1353
|
exports.typeMatches = typeMatches;
|
|
1353
|
-
//# sourceMappingURL=chunk-
|
|
1354
|
-
//# sourceMappingURL=chunk-
|
|
1354
|
+
//# sourceMappingURL=chunk-6EA3DSPT.cjs.map
|
|
1355
|
+
//# sourceMappingURL=chunk-6EA3DSPT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/JsonEditor/JsonEditor.paths.ts","../src/components/JsonEditor/JsonEditor.types.ts","../src/components/JsonEditor/JsonEditor.keymap.ts","../src/components/JsonEditor/JsonEditor.context.ts","../src/components/JsonEditor/JsonEditorValue.tsx","../src/components/JsonEditor/JsonEditorRow.tsx","../src/components/JsonEditor/JsonEditor.tsx"],"names":["resolveOption","createContext","useContext","jsx","Switch","Select","DatePicker","ColorPicker","Textarea","Input","useInlineEdit","DisplayValue","isImeComposing","jsxs","cn","Button","Text","Badge","Fragment","useState","forwardRef","JsonEditor","useId","useRef","useMemo","useEffect","useCallback","Callout","issue"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkBO,SAAS,aAAa,KAAA,EAAmD;AAC9E,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAEO,SAAS,YAAY,KAAA,EAAkD;AAC5E,EAAA,OAAO,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5B;AAEO,SAAS,iBAAiB,KAAA,EAAuC;AACtE,EAAA,OAAO,YAAA,CAAa,KAAK,CAAA,IAAK,WAAA,CAAY,KAAK,CAAA;AACjD;AAGO,SAAS,UAAU,IAAA,EAAwB;AAChD,EAAA,IAAI,CAAC,IAAA,EAAM,OAAO,EAAC;AAEnB,EAAA,MAAM,WAAqB,EAAC;AAC5B,EAAA,IAAI,OAAA,GAAU,EAAA;AACd,EAAA,IAAI,OAAA,GAAU,KAAA;AAEd,EAAA,KAAA,MAAW,QAAQ,IAAA,EAAM;AACvB,IAAA,IAAI,OAAA,EAAS;AACX,MAAA,OAAA,IAAW,IAAA;AACX,MAAA,OAAA,GAAU,KAAA;AACV,MAAA;AAAA,IACF;AACA,IAAA,IAAI,SAAS,IAAA,EAAM;AACjB,MAAA,OAAA,GAAU,IAAA;AACV,MAAA;AAAA,IACF;AACA,IAAA,IAAI,SAAS,GAAA,EAAK;AAChB,MAAA,QAAA,CAAS,KAAK,OAAO,CAAA;AACrB,MAAA,OAAA,GAAU,EAAA;AACV,MAAA;AAAA,IACF;AACA,IAAA,OAAA,IAAW,IAAA;AAAA,EACb;AAGA,EAAA,IAAI,SAAS,OAAA,IAAW,IAAA;AACxB,EAAA,QAAA,CAAS,KAAK,OAAO,CAAA;AAErB,EAAA,OAAO,QAAA;AACT;AAGO,SAAS,aAAa,QAAA,EAA4B;AACvD,EAAA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ACF,CAAA,MAAO;AACL,IAAA,GAAA,CAAI,IAAA,CAAK,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,QAAA,CAAS,EAAC,EAAG,KAAA,EAAO,CAAA,EAAG,MAAM,CAAA,EAAG,CAAA;AAAA,EACjE;AAEA,EAAA,OAAO,GAAA;AACT","file":"chunk-6EA3DSPT.cjs","sourcesContent":["import type {\n JsonArray,\n JsonEditorEdit,\n JsonObject,\n JsonPath,\n JsonValue,\n} from \"./JsonEditor.types\";\n\n// ---------------------------------------------------------------------------\n// Paths\n//\n// The wire form of a path is a dotted string — `user.address.city`,\n// `orders.0.total` — because that is what fits in a `data-*` attribute, a\n// keyMap key, an MCP tool argument, and a log line. `.` separates segments and\n// `\\` escapes, so a key that genuinely contains a dot is still addressable\n// (`meta.a\\.b` is `[\"meta\", \"a.b\"]`, not three segments).\n// ---------------------------------------------------------------------------\n\nexport function isJsonObject(value: JsonValue | undefined): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function isJsonArray(value: JsonValue | undefined): value is JsonArray {\n return Array.isArray(value);\n}\n\nexport function isContainerValue(value: JsonValue | undefined): boolean {\n return isJsonObject(value) || isJsonArray(value);\n}\n\n/** Split a dotted path into segments, honouring `\\.` and `\\\\`. */\nexport function parsePath(path: string): JsonPath {\n if (!path) return [];\n\n const segments: string[] = [];\n let current = \"\";\n let escaped = false;\n\n for (const char of path) {\n if (escaped) {\n current += char;\n escaped = false;\n continue;\n }\n if (char === \"\\\\\") {\n escaped = true;\n continue;\n }\n if (char === \".\") {\n segments.push(current);\n current = \"\";\n continue;\n }\n current += char;\n }\n // A trailing lone backslash is a typo, not a separator — keep it literal\n // rather than throwing on a half-typed path.\n if (escaped) current += \"\\\\\";\n segments.push(current);\n\n return segments;\n}\n\n/** The inverse of {@link parsePath}. */\nexport function pathToString(segments: JsonPath): string {\n return segments\n .map((segment) => segment.replace(/\\\\/g, \"\\\\\\\\\").replace(/\\./g, \"\\\\.\"))\n .join(\".\");\n}\n\nexport function getAtPath(value: JsonValue, segments: JsonPath): JsonValue | undefined {\n let current: JsonValue | undefined = value;\n\n for (const segment of segments) {\n if (isJsonArray(current)) {\n const index = Number(segment);\n if (!Number.isInteger(index)) return undefined;\n current = current[index];\n } else if (isJsonObject(current)) {\n if (!Object.prototype.hasOwnProperty.call(current, segment)) return undefined;\n current = current[segment];\n } else {\n return undefined;\n }\n if (current === undefined) return undefined;\n }\n\n return current;\n}\n\n/**\n * Rebuild `value` with `updater` applied to the container at `segments`,\n * cloning only the containers along that path. Returns the original reference\n * when the path does not resolve, so a no-op edit is detectable by identity.\n */\nfunction updateContainer(\n value: JsonValue,\n segments: JsonPath,\n updater: (container: JsonObject | JsonArray) => JsonObject | JsonArray | undefined,\n): JsonValue {\n if (segments.length === 0) {\n if (!isContainerValue(value)) return value;\n const next = updater(value as JsonObject | JsonArray);\n return next === undefined ? value : next;\n }\n\n const [head, ...rest] = segments as [string, ...string[]];\n\n if (isJsonArray(value)) {\n const index = Number(head);\n if (!Number.isInteger(index) || index < 0 || index >= value.length) return value;\n const child = updateContainer(value[index]!, rest, updater);\n if (child === value[index]) return value;\n const clone = value.slice();\n clone[index] = child;\n return clone;\n }\n\n if (isJsonObject(value)) {\n if (!Object.prototype.hasOwnProperty.call(value, head)) return value;\n const child = updateContainer(value[head]!, rest, updater);\n if (child === value[head]) return value;\n return { ...value, [head]: child };\n }\n\n return value;\n}\n\n/**\n * Apply one {@link JsonEditorEdit} and return a NEW document.\n *\n * Pure and total: an edit that cannot be applied — a path that does not exist,\n * a rename onto an occupied key, an insert without a key into an object —\n * returns the input unchanged rather than throwing or half-applying. The\n * component checks those cases first and raises an issue; this function is the\n * backstop for the same op arriving from a bridge, where there is no UI to warn.\n */\nexport function applyJsonEdit(value: JsonValue, edit: JsonEditorEdit): JsonValue {\n const segments = parsePath(edit.path);\n\n switch (edit.op) {\n case \"set\": {\n // An empty path is the document itself.\n if (segments.length === 0) return edit.value;\n\n const parent = segments.slice(0, -1);\n const key = segments[segments.length - 1]!;\n\n return updateContainer(value, parent, (container) => {\n if (isJsonArray(container)) {\n const index = Number(key);\n if (!Number.isInteger(index) || index < 0 || index >= container.length) return undefined;\n const clone = container.slice();\n clone[index] = edit.value;\n return clone;\n }\n return { ...container, [key]: edit.value };\n });\n }\n\n case \"remove\": {\n if (segments.length === 0) return value;\n\n const parent = segments.slice(0, -1);\n const key = segments[segments.length - 1]!;\n\n return updateContainer(value, parent, (container) => {\n if (isJsonArray(container)) {\n const index = Number(key);\n if (!Number.isInteger(index) || index < 0 || index >= container.length) return undefined;\n return container.filter((_, i) => i !== index);\n }\n if (!Object.prototype.hasOwnProperty.call(container, key)) return undefined;\n const clone: JsonObject = {};\n for (const [k, v] of Object.entries(container)) {\n if (k !== key) clone[k] = v;\n }\n return clone;\n });\n }\n\n case \"rename\": {\n if (segments.length === 0) return value;\n\n const parent = segments.slice(0, -1);\n const key = segments[segments.length - 1]!;\n\n return updateContainer(value, parent, (container) => {\n // Array indices are positional, not names — reorder is `move`.\n if (!isJsonObject(container)) return undefined;\n if (!Object.prototype.hasOwnProperty.call(container, key)) return undefined;\n if (edit.key === key) return undefined;\n // Renaming onto a live sibling would silently destroy it.\n if (Object.prototype.hasOwnProperty.call(container, edit.key)) return undefined;\n\n // Rebuilt in order: `delete` + re-add would move the key to the end,\n // which reads as the row jumping down the list for no reason.\n const clone: JsonObject = {};\n for (const [k, v] of Object.entries(container)) {\n clone[k === key ? edit.key : k] = v;\n }\n return clone;\n });\n }\n\n case \"insert\": {\n return updateContainer(value, segments, (container) => {\n if (isJsonArray(container)) return [...container, edit.value];\n if (edit.key === undefined || edit.key === \"\") return undefined;\n if (Object.prototype.hasOwnProperty.call(container, edit.key)) return undefined;\n return { ...container, [edit.key]: edit.value };\n });\n }\n\n case \"move\": {\n if (segments.length === 0) return value;\n\n const parent = segments.slice(0, -1);\n const from = Number(segments[segments.length - 1]);\n\n return updateContainer(value, parent, (container) => {\n if (!isJsonArray(container)) return undefined;\n if (!Number.isInteger(from) || from < 0 || from >= container.length) return undefined;\n const to = Math.min(Math.max(edit.to, 0), container.length - 1);\n if (to === from) return undefined;\n const clone = container.slice();\n const [moved] = clone.splice(from, 1);\n clone.splice(to, 0, moved!);\n return clone;\n });\n }\n }\n}\n\n/** A one-line summary of an edit, for the pending strip and activity events. */\nexport function describeEdit(edit: JsonEditorEdit): string {\n const at = edit.path === \"\" ? \"the document\" : edit.path;\n switch (edit.op) {\n case \"set\":\n return `set ${at}`;\n case \"remove\":\n return `remove ${at}`;\n case \"rename\":\n return `rename ${at} to ${edit.key}`;\n case \"insert\":\n return edit.key === undefined ? `append to ${at}` : `add ${edit.key} to ${at}`;\n case \"move\":\n return `move ${at} to index ${edit.to}`;\n }\n}\n","import type { HTMLAttributes } from \"react\";\nimport type { InputOption } from \"../inputs/inputs.types\";\nimport type { FieldMode } from \"../inputs/inputs.types\";\nimport type { Size } from \"../../utils/types\";\n\n// ---------------------------------------------------------------------------\n// JSON\n// ---------------------------------------------------------------------------\n\nexport type JsonPrimitive = string | number | boolean | null;\n\nexport interface JsonObject {\n [key: string]: JsonValue;\n}\n\nexport type JsonArray = JsonValue[];\n\nexport type JsonValue = JsonPrimitive | JsonObject | JsonArray;\n\n/**\n * A location inside a JSON document, one array element per segment. Array\n * indices are decimal STRINGS (`[\"orders\", \"0\", \"total\"]`) so a path is a plain\n * `string[]` an agent can emit without a tagged union, and so object keys and\n * array indices are addressed identically.\n *\n * The wire form is the dotted string produced by `pathToString` — see\n * `JsonEditor.paths.ts` for the escaping rule.\n */\nexport type JsonPath = string[];\n\n// ---------------------------------------------------------------------------\n// Declared types\n// ---------------------------------------------------------------------------\n\n/**\n * The data types a `keyMap` can impose on a JSON value.\n *\n * Each one owes BOTH a read-only representation and an edit control — that\n * pairing is the whole point of the feature, so a type with no distinct input\n * does not earn a place here.\n *\n * `json` is the escape hatch: it matches any value and edits as raw text, which\n * is how a sub-document opts out of the row-per-key treatment.\n */\nexport const JSON_FIELD_TYPES = [\n \"string\",\n \"text\",\n \"number\",\n \"integer\",\n \"boolean\",\n \"date\",\n \"datetime\",\n \"enum\",\n \"secret\",\n \"url\",\n \"email\",\n \"color\",\n \"json\",\n \"object\",\n \"array\",\n] as const;\n\nexport type JsonFieldType = (typeof JSON_FIELD_TYPES)[number];\n\n/**\n * The long form of a `keyMap` entry. The short form — a bare type name — is\n * sugar for `{ type }`.\n */\nexport interface JsonKeyRule {\n type: JsonFieldType;\n /** Overrides the raw key as the row's label. */\n label?: string;\n /** Choices for `type: \"enum\"`. Required there; ignored elsewhere. */\n options?: InputOption[];\n /** Render the value but never offer a control for it. */\n readOnly?: boolean;\n /** The key must be present. Only enforced on wildcard-free patterns. */\n required?: boolean;\n description?: string;\n placeholder?: string;\n /** Forwarded to the control for `number` / `integer` / `date` / `datetime`. */\n min?: number | string;\n max?: number | string;\n}\n\n/** One compiled `keyMap` entry: a path pattern plus the rule it imposes. */\nexport interface JsonKeyMapEntry {\n /** Path pattern; a `\"*\"` segment matches any single key or index. */\n pattern: JsonPath;\n rule: JsonKeyRule;\n /** The key exactly as written in the `keyMap`, for error messages. */\n source: string;\n /** Non-wildcard segment count — the specificity score. */\n literals: number;\n /** Declaration order, the tie-breaker at equal specificity. */\n order: number;\n}\n\nexport interface ParsedKeyMap {\n /**\n * `false` only when the STRING itself was unusable (unparseable, or valid\n * JSON of the wrong shape). Individual bad rules leave this `true` — they are\n * reported and skipped so one typo cannot silently disable a whole map.\n */\n ok: boolean;\n rules: JsonKeyMapEntry[];\n issues: JsonEditorIssue[];\n}\n\n// ---------------------------------------------------------------------------\n// Issues\n// ---------------------------------------------------------------------------\n\n/**\n * Everything the editor knows to be wrong, in one shape.\n *\n * A typing feature that silently stops typing things is worse than no typing at\n * all, because the caller believes the constraint is in force. So a broken\n * `keyMap`, a broken rule inside a working one, and a value that contradicts\n * its declared type all surface through the SAME channel — the panel, the\n * `data-issues` count, and `onIssuesChange`.\n */\nexport interface JsonEditorIssue {\n /**\n * - `keymap` — the `keyMap` string could not be used at all.\n * - `rule` — one entry in an otherwise-usable map is malformed.\n * - `type` — a value contradicts the type declared for its path.\n * - `edit` — a structural edit was refused (duplicate key, and the like).\n */\n kind: \"keymap\" | \"rule\" | \"type\" | \"edit\";\n /** Dotted path; `\"\"` for the `keyMap` as a whole. */\n path: string;\n message: string;\n /** The declared type, when the issue has one. */\n expected?: JsonFieldType;\n /** What the value actually is: `\"string\"`, `\"array\"`, `\"null\"`, … */\n actual?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Edits\n// ---------------------------------------------------------------------------\n\n/**\n * One mutation, as data.\n *\n * Every change the UI makes is expressed as one of these and applied through\n * `applyJsonEdit`, which means an MCP bridge can replay exactly what a human\n * did — and `pendingMode` can hold one in a queue instead of applying it —\n * without a second code path.\n */\nexport type JsonEditorEditBase = {\n id?: string;\n /** Human-readable summary, used by the pending strip. */\n label?: string;\n};\n\nexport type JsonEditorEdit =\n | (JsonEditorEditBase & { op: \"set\"; path: string; value: JsonValue })\n | (JsonEditorEditBase & { op: \"remove\"; path: string })\n | (JsonEditorEditBase & { op: \"rename\"; path: string; key: string })\n /** `path` is the CONTAINER. `key` is required for an object, ignored for an array. */\n | (JsonEditorEditBase & { op: \"insert\"; path: string; key?: string; value: JsonValue })\n /** `path` is the element; `to` is its new index in the same array. */\n | (JsonEditorEditBase & { op: \"move\"; path: string; to: number });\n\nexport type JsonEditorPendingEdit = JsonEditorEdit & { id: string };\n\nexport interface JsonEditorActivity {\n /** `commit` — applied to the document. `stage` / `accept` / `reject` — pending flow. */\n type: \"commit\" | \"stage\" | \"accept\" | \"reject\";\n edit: JsonEditorEdit;\n}\n\n// ---------------------------------------------------------------------------\n// Rows\n// ---------------------------------------------------------------------------\n\n/** One rendered key/value row — also the unit a bridge would address. */\nexport interface JsonEditorNode {\n path: JsonPath;\n /** `pathToString(path)`; `\"\"` for a scalar root. */\n dotted: string;\n /** The last segment: an object key or an array index. */\n key: string;\n depth: number;\n value: JsonValue;\n parentKind: \"object\" | \"array\" | \"root\";\n /** The rule that matched, if any. */\n rule?: JsonKeyRule;\n /** Declared type if a rule matched, otherwise inferred from the value. */\n type: JsonFieldType;\n declared: boolean;\n /** Renders as a collapsible branch rather than a value. */\n container: boolean;\n childCount: number;\n /** Set when the value contradicts its declared type. */\n conflict?: JsonEditorIssue;\n}\n\n// ---------------------------------------------------------------------------\n// Props\n// ---------------------------------------------------------------------------\n\nexport interface JsonEditorProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n /** The document. Controlled — the editor keeps no copy of it. */\n value: JsonValue;\n /**\n * Called with the WHOLE next document plus the edit that produced it. The\n * edit is what a bridge would log, replay, or undo.\n */\n onChange?: (value: JsonValue, edit: JsonEditorEdit) => void;\n /**\n * Type declarations, as a **JSON string** — not an object, and an object is\n * NOT accepted as a convenience overload.\n *\n * A string survives every boundary this prop actually crosses: an MCP tool\n * argument, a config column, a `data-*` attribute, a form field. A live\n * object survives none of them, so accepting both would make the documented\n * form the second-class one in practice.\n *\n * ```jsonc\n * {\n * \"user.age\": \"number\", // short form: a bare type name\n * \"tags.*\": \"string\", // every element of an array\n * \"orders.*.total\": \"number\",\n * \"role\": { \"type\": \"enum\", \"options\": [\"admin\", \"member\"] }\n * }\n * ```\n *\n * Malformed input is never thrown and never silently ignored — see\n * {@link JsonEditorIssue}.\n */\n keyMap?: string | null;\n /**\n * `\"view\"` (the default here) renders values as text that turns into the\n * typed control when clicked; `\"edit\"` renders every control at once.\n *\n * The kit default is `\"edit\"`, and this component deliberately differs: a\n * forty-key document drawn as forty boxed inputs is not a document you can\n * read, and reading is most of what a JSON editor is for.\n */\n mode?: FieldMode;\n size?: Size;\n /** Show every value, offer no control. Overrides `mode` and every `allow*`. */\n readOnly?: boolean;\n /**\n * Dotted paths of the expanded containers. Omit BOTH this and\n * `defaultExpanded` to expand everything (pass `defaultExpanded={[]}` for a\n * large document).\n */\n expanded?: string[];\n defaultExpanded?: string[];\n onExpandedChange?: (expanded: string[]) => void;\n /** Render the issues panel. The `data-issues` count and `onIssuesChange` are unaffected. */\n showIssues?: boolean;\n onIssuesChange?: (issues: JsonEditorIssue[]) => void;\n /**\n * Trust-but-verify. With this on, an edit is STAGED into `pending` instead of\n * being applied: `onChange` does not fire until a human accepts it.\n */\n pendingMode?: boolean;\n /** Staged edits. Controlled, so an agent's proposals are inspectable. */\n pending?: JsonEditorPendingEdit[];\n onPendingChange?: (pending: JsonEditorPendingEdit[]) => void;\n /** Every mutation, staged or applied — the hook presence / undo layers listen on. */\n onActivity?: (event: JsonEditorActivity) => void;\n allowAdd?: boolean;\n allowRemove?: boolean;\n allowRename?: boolean;\n allowReorder?: boolean;\n /** Label for a scalar root document. Default `\"value\"`. */\n rootLabel?: string;\n /** Shown when the document has no keys. */\n emptyLabel?: string;\n /** Prefix for generated control ids — `<idPrefix>-<dotted path>`. */\n idPrefix?: string;\n}\n","import { resolveOption } from \"../inputs/inputs.utils\";\nimport {\n getAtPath,\n isJsonArray,\n isJsonObject,\n parsePath,\n pathToString,\n} from \"./JsonEditor.paths\";\nimport { JSON_FIELD_TYPES } from \"./JsonEditor.types\";\nimport type {\n JsonEditorIssue,\n JsonFieldType,\n JsonKeyMapEntry,\n JsonKeyRule,\n JsonPath,\n JsonValue,\n ParsedKeyMap,\n} from \"./JsonEditor.types\";\n\n// ---------------------------------------------------------------------------\n// The keyMap\n//\n// Shape: a FLAT object whose keys are dotted path patterns and whose values are\n// either a bare type name or a rule object.\n//\n// { \"user.age\": \"number\", \"orders.*.total\": \"number\", \"tags.*\": \"string\" }\n//\n// Why flat paths rather than a nested mirror of the data:\n//\n// - A nested mirror is ambiguous the moment a key needs a type AND typed\n// children — `{\"user\": {\"age\": \"number\"}}` could mean either, and resolving\n// it needs a magic key (`$type`) that a flat map does not.\n// - Arrays force a wildcard into a nested mirror anyway, so the mirror buys\n// nothing there and costs a level of nesting per segment.\n// - One rule per line is greppable, diffable and reviewable, which matters\n// when the map arrives as a string from an agent or a config column.\n// - It is sparse by construction: you declare the keys you care about, and\n// everything else is inferred from the value.\n//\n// A `*` segment matches exactly one key or index. There is deliberately no\n// `**`: \"any depth\" makes two patterns overlap in ways that are hard to reason\n// about, and every case we had for it was really \"this array's elements\".\n// ---------------------------------------------------------------------------\n\nconst TYPE_NAMES = new Set<string>(JSON_FIELD_TYPES);\n\nfunction isTypeName(value: unknown): value is JsonFieldType {\n return typeof value === \"string\" && TYPE_NAMES.has(value);\n}\n\nfunction issue(kind: JsonEditorIssue[\"kind\"], path: string, message: string): JsonEditorIssue {\n return { kind, path, message };\n}\n\n/**\n * Compile a `keyMap` JSON **string**.\n *\n * Never throws. Two failure modes, deliberately distinct:\n *\n * - The string itself is unusable (not JSON, or JSON that is not an object) —\n * `ok: false`, no rules, one `keymap` issue. The caller must show this: an\n * editor that quietly runs untyped is worse than one that refuses, because\n * the person editing believes the constraint is in force.\n * - One entry is malformed — `ok: true`, that entry dropped, one `rule` issue.\n * A typo in `orders.*.totl` must not disable the other forty rules.\n */\nexport function parseKeyMap(source?: string | null): ParsedKeyMap {\n if (source === undefined || source === null || source.trim() === \"\") {\n return { ok: true, rules: [], issues: [] };\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(source);\n } catch (error) {\n return {\n ok: false,\n rules: [],\n issues: [\n issue(\n \"keymap\",\n \"\",\n `keyMap is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,\n ),\n ],\n };\n }\n\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n return {\n ok: false,\n rules: [],\n issues: [\n issue(\n \"keymap\",\n \"\",\n `keyMap must be a JSON object of path → type, got ${describeValue(parsed as JsonValue)}.`,\n ),\n ],\n };\n }\n\n const rules: JsonKeyMapEntry[] = [];\n const issues: JsonEditorIssue[] = [];\n let order = 0;\n\n for (const [key, raw] of Object.entries(parsed as Record<string, unknown>)) {\n const rule = normalizeRule(key, raw, issues);\n if (!rule) continue;\n\n const pattern = parsePath(key);\n rules.push({\n pattern,\n rule,\n source: key,\n literals: pattern.reduce((n, segment) => n + (segment === \"*\" ? 0 : 1), 0),\n order: order++,\n });\n }\n\n return { ok: true, rules, issues };\n}\n\nfunction normalizeRule(\n key: string,\n raw: unknown,\n issues: JsonEditorIssue[],\n): JsonKeyRule | undefined {\n let candidate: Record<string, unknown>;\n\n if (typeof raw === \"string\") {\n candidate = { type: raw };\n } else if (typeof raw === \"object\" && raw !== null && !Array.isArray(raw)) {\n candidate = raw as Record<string, unknown>;\n } else {\n issues.push(\n issue(\n \"rule\",\n key,\n `Expected a type name or a rule object, got ${describeValue(raw as JsonValue)}.`,\n ),\n );\n return undefined;\n }\n\n if (!isTypeName(candidate.type)) {\n issues.push(\n issue(\n \"rule\",\n key,\n `Unknown type ${JSON.stringify(candidate.type)}. Known types: ${JSON_FIELD_TYPES.join(\", \")}.`,\n ),\n );\n return undefined;\n }\n\n if (candidate.options !== undefined && !Array.isArray(candidate.options)) {\n issues.push(issue(\"rule\", key, \"`options` must be an array.\"));\n return undefined;\n }\n\n // An enum with nothing to choose from cannot type anything, and would render\n // an empty select that looks like a loading state.\n if (candidate.type === \"enum\" && (!candidate.options || candidate.options.length === 0)) {\n issues.push(issue(\"rule\", key, \"`enum` requires a non-empty `options` array.\"));\n return undefined;\n }\n\n return candidate as unknown as JsonKeyRule;\n}\n\n/**\n * The rule governing `segments`, or `undefined` when the map is silent.\n *\n * Specificity: the pattern with the most literal (non-`*`) segments wins, and\n * at equal specificity the one declared LAST wins — so a general\n * `orders.*.total` can be overridden by a specific `orders.0.total` placed\n * anywhere in the map.\n */\nexport function resolveKeyRule(\n rules: JsonKeyMapEntry[],\n segments: JsonPath,\n): JsonKeyRule | undefined {\n let best: JsonKeyMapEntry | undefined;\n\n for (const entry of rules) {\n if (!matches(entry.pattern, segments)) continue;\n if (\n !best ||\n entry.literals > best.literals ||\n (entry.literals === best.literals && entry.order > best.order)\n ) {\n best = entry;\n }\n }\n\n return best?.rule;\n}\n\nfunction matches(pattern: JsonPath, segments: JsonPath): boolean {\n if (pattern.length !== segments.length) return false;\n return pattern.every((p, i) => p === \"*\" || p === segments[i]);\n}\n\n/** What a value IS, in the vocabulary the issue messages use. */\nexport function describeValue(value: JsonValue | undefined): string {\n if (value === undefined) return \"undefined\";\n if (value === null) return \"null\";\n if (Array.isArray(value)) return \"array\";\n return typeof value;\n}\n\n/** The type a value carries on its own, when nothing declares one for it. */\nexport function inferType(value: JsonValue | undefined): JsonFieldType {\n if (Array.isArray(value)) return \"array\";\n if (value === null || value === undefined) {\n // `null` carries no type information at all, so the raw editor is the only\n // choice that neither invents a type nor drops the value.\n return \"json\";\n }\n if (typeof value === \"object\") return \"object\";\n if (typeof value === \"boolean\") return \"boolean\";\n if (typeof value === \"number\") return \"number\";\n return \"string\";\n}\n\nfunction enumValues(rule: JsonKeyRule): (string | number | boolean)[] {\n return (rule.options ?? []).map((option) => resolveOption(option).value as string);\n}\n\n/**\n * Does the value satisfy the declared type?\n *\n * Deliberately strict and deliberately non-coercing. `\"36\"` is NOT a number\n * here — the whole reason a `keyMap` exists is to make that visible rather than\n * to paper over it.\n */\nexport function typeMatches(rule: JsonKeyRule, value: JsonValue | undefined): boolean {\n switch (rule.type) {\n case \"string\":\n case \"text\":\n case \"url\":\n case \"email\":\n case \"secret\":\n case \"color\":\n return typeof value === \"string\";\n case \"number\":\n return typeof value === \"number\" && Number.isFinite(value);\n case \"integer\":\n return typeof value === \"number\" && Number.isInteger(value);\n case \"boolean\":\n return typeof value === \"boolean\";\n case \"date\":\n case \"datetime\":\n return typeof value === \"string\" && value !== \"\" && !Number.isNaN(Date.parse(value));\n case \"enum\":\n return (\n (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") &&\n enumValues(rule).some((option) => String(option) === String(value))\n );\n case \"object\":\n return isJsonObject(value);\n case \"array\":\n return isJsonArray(value);\n case \"json\":\n // The escape hatch matches anything EXCEPT text that does not parse —\n // which is exactly the state the raw editor leaves behind when someone\n // saves a half-written document.\n if (typeof value !== \"string\") return true;\n try {\n JSON.parse(value);\n return true;\n } catch {\n return false;\n }\n }\n}\n\nfunction conflictMessage(rule: JsonKeyRule, value: JsonValue | undefined): string {\n if (rule.type === \"enum\") {\n return `${JSON.stringify(value)} is not one of the declared options (${enumValues(rule)\n .map((option) => JSON.stringify(option))\n .join(\", \")}).`;\n }\n if (rule.type === \"json\") {\n return \"Raw text is not valid JSON.\";\n }\n if (rule.type === \"date\" || rule.type === \"datetime\") {\n return `Declared ${rule.type}, got ${describeValue(value)} that is not a parseable date.`;\n }\n return `Declared ${rule.type}, got ${describeValue(value)}.`;\n}\n\n/**\n * Every place the document contradicts its `keyMap`.\n *\n * Walks the value (so a conflict is found at any depth, arrays included), then\n * checks `required` on the wildcard-free patterns — a wildcard cannot say \"this\n * must exist\" about a key nobody has named.\n */\nexport function findJsonConflicts(value: JsonValue, rules: JsonKeyMapEntry[]): JsonEditorIssue[] {\n const issues: JsonEditorIssue[] = [];\n if (rules.length === 0) return issues;\n\n const walk = (node: JsonValue, segments: JsonPath) => {\n if (segments.length > 0) {\n const rule = resolveKeyRule(rules, segments);\n if (rule && !typeMatches(rule, node)) {\n issues.push({\n kind: \"type\",\n path: pathToString(segments),\n message: conflictMessage(rule, node),\n expected: rule.type,\n actual: describeValue(node),\n });\n }\n }\n\n if (isJsonArray(node)) {\n node.forEach((child, index) => walk(child, [...segments, String(index)]));\n } else if (isJsonObject(node)) {\n for (const [key, child] of Object.entries(node)) walk(child, [...segments, key]);\n }\n };\n\n walk(value, []);\n\n for (const entry of rules) {\n if (!entry.rule.required) continue;\n if (entry.pattern.includes(\"*\")) continue;\n if (getAtPath(value, entry.pattern) !== undefined) continue;\n issues.push({\n kind: \"type\",\n path: entry.source,\n message: `Required key is missing (declared ${entry.rule.type}).`,\n expected: entry.rule.type,\n actual: \"undefined\",\n });\n }\n\n return issues;\n}\n\n/** The value a newly-added key starts as, so a new row is never `undefined`. */\nexport function seedValue(type: JsonFieldType, rule?: JsonKeyRule): JsonValue {\n switch (type) {\n case \"number\":\n case \"integer\":\n return 0;\n case \"boolean\":\n return false;\n case \"object\":\n return {};\n case \"array\":\n return [];\n case \"json\":\n return null;\n case \"enum\":\n return rule?.options?.length ? (resolveOption(rule.options[0]!).value as string) : \"\";\n default:\n return \"\";\n }\n}\n","import { createContext, useContext } from \"react\";\nimport type { FieldMode } from \"../inputs/inputs.types\";\nimport type { Size } from \"../../utils/types\";\nimport type {\n JsonEditorNode,\n JsonEditorPendingEdit,\n JsonFieldType,\n JsonValue,\n} from \"./JsonEditor.types\";\n\n/**\n * Everything a row needs that is not the row itself.\n *\n * Same shape as `Table`'s context and for the same reason: a row is rendered\n * once per key in a document that can be hundreds deep, and threading a dozen\n * props through the recursion makes every signature change a rewrite.\n */\nexport interface JsonEditorContextValue {\n mode: FieldMode;\n size: Size;\n readOnly: boolean;\n allowAdd: boolean;\n allowRemove: boolean;\n allowRename: boolean;\n allowReorder: boolean;\n pendingMode: boolean;\n idPrefix: string;\n\n isExpanded: (dotted: string) => boolean;\n toggleExpanded: (dotted: string) => void;\n\n setValueAt: (node: JsonEditorNode, value: JsonValue) => void;\n removeAt: (node: JsonEditorNode) => void;\n renameAt: (node: JsonEditorNode, key: string) => void;\n moveAt: (node: JsonEditorNode, to: number) => void;\n insertInto: (dotted: string, key: string | undefined, type: JsonFieldType) => void;\n\n /** Which container's add form is open, if any. Transient UI state, never model state. */\n addingAt: string | null;\n setAddingAt: (dotted: string | null) => void;\n\n pendingFor: (dotted: string) => JsonEditorPendingEdit[];\n acceptPending: (id: string) => void;\n rejectPending: (id: string) => void;\n}\n\nexport const JsonEditorContext = createContext<JsonEditorContextValue | null>(null);\n\nexport function useJsonEditorContext(): JsonEditorContextValue {\n const context = useContext(JsonEditorContext);\n if (!context) {\n throw new Error(\"JsonEditor rows must be rendered inside a <JsonEditor>.\");\n }\n return context;\n}\n","import { ColorPicker } from \"../ColorPicker/ColorPicker\";\nimport { Input } from \"../inputs/Input/Input\";\nimport { Textarea } from \"../inputs/Textarea/Textarea\";\nimport { Select } from \"../inputs/Select/Select\";\nimport { Switch } from \"../inputs/Switch/Switch\";\nimport { DatePicker } from \"../inputs/DatePicker/DatePicker\";\nimport { DisplayValue } from \"../inputs/mode/DisplayValue\";\nimport { useInlineEdit } from \"../inputs/mode/useInlineEdit\";\nimport { resolveOption } from \"../inputs/inputs.utils\";\nimport type { FieldMode } from \"../inputs/inputs.types\";\nimport type { Size } from \"../../utils/types\";\nimport { isImeComposing } from \"../../utils/ime\";\nimport type { JsonEditorNode, JsonFieldType, JsonValue } from \"./JsonEditor.types\";\n\nexport interface JsonEditorValueProps {\n node: JsonEditorNode;\n mode: FieldMode;\n size: Size;\n /** No control at all — the row still shows the value. */\n readOnly: boolean;\n /** Stable control id: `<idPrefix>-<dotted path>`. */\n id: string;\n onCommit: (value: JsonValue) => void;\n}\n\nconst COLOR_PICKER_SIZE: Record<Size, \"sm\" | \"md\" | \"lg\"> = {\n xs: \"sm\",\n sm: \"sm\",\n md: \"md\",\n lg: \"lg\",\n xl: \"lg\",\n};\n\n/**\n * Types whose text form IS the value commit on every keystroke; types that must\n * be PARSED out of text commit on blur instead.\n *\n * That split is not fussiness. A controlled `number` field that parses per\n * keystroke turns `1.5` into `1` the moment you type the dot, and moves the\n * caret while you are still typing. Committing on blur means the intermediate\n * text is never anybody's value.\n */\nfunction isRawTextType(type: JsonFieldType): boolean {\n return type === \"number\" || type === \"integer\" || type === \"json\";\n}\n\n/** The text shown for a value in a raw editor — strings verbatim, everything else as JSON. */\nexport function toText(value: JsonValue | undefined): string {\n if (value === undefined) return \"\";\n if (typeof value === \"string\") return value;\n return JSON.stringify(value) ?? \"\";\n}\n\n/**\n * Read a raw editor's text back into a value.\n *\n * Text that will not parse as the declared type is stored AS TEXT. That is the\n * deliberate choice at the heart of this component: typing `abc` into a field\n * declared `number` neither coerces to `0`/`NaN` nor throws the keystrokes\n * away — it writes `\"abc\"` and lets the conflict machinery say so, in the same\n * place it reports bad data that arrived from the server.\n */\nexport function fromText(text: string, type: JsonFieldType): JsonValue {\n switch (type) {\n case \"number\":\n case \"integer\": {\n const trimmed = text.trim();\n if (trimmed === \"\") return text;\n const parsed = Number(trimmed);\n return Number.isFinite(parsed) ? parsed : text;\n }\n case \"boolean\": {\n const trimmed = text.trim().toLowerCase();\n if (trimmed === \"true\") return true;\n if (trimmed === \"false\") return false;\n return text;\n }\n case \"json\":\n case \"object\":\n case \"array\":\n try {\n return JSON.parse(text) as JsonValue;\n } catch {\n return text;\n }\n default:\n return text;\n }\n}\n\n/**\n * The read-or-edit control for one leaf value.\n *\n * Everything here is a `react-fancy` primitive — `Input`, `Textarea`, `Select`,\n * `Switch`, `DatePicker`, `ColorPicker` — and the view/edit swap is the kit's\n * own `useInlineEdit` + `DisplayValue`, not a private re-implementation of it.\n */\nexport function JsonEditorValue({ node, mode, size, readOnly, id, onCommit }: JsonEditorValueProps) {\n const locked = readOnly || node.rule?.readOnly === true;\n const resolvedMode: FieldMode = locked ? \"view\" : mode;\n const { value, rule } = node;\n\n // A value that contradicts its declared type cannot be shown through that\n // type's control — a number input cannot hold \"thirty-six\" — so it falls back\n // to the raw editor, which is also the only place it can be repaired.\n if (node.conflict || isRawTextType(node.type)) {\n return (\n <RawValueEditor\n id={id}\n text={toText(value)}\n type={node.type}\n mode={resolvedMode}\n size={size}\n disabled={locked}\n multiline={node.type === \"json\" || typeof value === \"object\"}\n placeholder={rule?.placeholder}\n onCommitText={(text) => onCommit(fromText(text, node.type))}\n />\n );\n }\n\n const common = { id, size, mode: resolvedMode, disabled: locked } as const;\n\n switch (node.type) {\n case \"boolean\":\n return (\n <Switch\n {...common}\n checked={value === true}\n onCheckedChange={(next) => onCommit(next)}\n />\n );\n\n case \"enum\": {\n const options = rule?.options ?? [];\n return (\n <Select\n {...common}\n list={options}\n value={String(value)}\n onValueChange={(next) => {\n // Emit the option's ORIGINAL value, so a numeric or boolean enum\n // does not silently become a string on its way through the DOM.\n const match = options\n .map((option) => resolveOption(option))\n .find((option) => String(option.value) === next);\n onCommit((match?.value ?? next) as JsonValue);\n }}\n />\n );\n }\n\n case \"date\":\n case \"datetime\":\n return (\n <DatePicker\n {...common}\n includeTime={node.type === \"datetime\"}\n min={rule?.min === undefined ? undefined : String(rule.min)}\n max={rule?.max === undefined ? undefined : String(rule.max)}\n value={typeof value === \"string\" ? value : \"\"}\n onValueChange={(next) => onCommit(next)}\n />\n );\n\n case \"color\":\n return (\n <ColorPicker\n size={COLOR_PICKER_SIZE[size]}\n mode={resolvedMode}\n disabled={locked}\n value={typeof value === \"string\" ? value : \"\"}\n onChange={(next) => onCommit(next)}\n />\n );\n\n case \"text\":\n return (\n <Textarea\n {...common}\n minRows={2}\n autoResize\n placeholder={rule?.placeholder}\n value={typeof value === \"string\" ? value : \"\"}\n onValueChange={(next) => onCommit(next)}\n />\n );\n\n case \"secret\":\n return (\n <Input\n {...common}\n type=\"password\"\n reveal\n placeholder={rule?.placeholder}\n value={typeof value === \"string\" ? value : \"\"}\n onValueChange={(next) => onCommit(next)}\n />\n );\n\n case \"url\":\n case \"email\":\n case \"string\":\n default:\n return (\n <Input\n {...common}\n type={node.type === \"url\" ? \"url\" : node.type === \"email\" ? \"email\" : \"text\"}\n placeholder={rule?.placeholder}\n value={typeof value === \"string\" ? value : \"\"}\n onValueChange={(next) => onCommit(next)}\n />\n );\n }\n}\n\ninterface RawValueEditorProps {\n id: string;\n text: string;\n type: JsonFieldType;\n mode: FieldMode;\n size: Size;\n disabled: boolean;\n multiline: boolean;\n placeholder?: string;\n onCommitText: (text: string) => void;\n}\n\n/**\n * An uncontrolled text control that commits on blur.\n *\n * Uncontrolled is what keeps the component free of a private copy of the\n * document: the half-typed text lives in the DOM node, never in React state,\n * and the `key` is the committed text — so a value changed from OUTSIDE (an\n * agent writing through a bridge, a server push) remounts the control with the\n * new text, while local typing does not.\n */\nfunction RawValueEditor({\n id,\n text,\n type,\n mode,\n size,\n disabled,\n multiline,\n placeholder,\n onCommitText,\n}: RawValueEditorProps) {\n const { showControl, interactive, enterEdit, exitEdit } = useInlineEdit(mode, disabled);\n\n if (!showControl) {\n return (\n <DisplayValue size={size} interactive={interactive} onActivate={enterEdit}>\n {text}\n </DisplayValue>\n );\n }\n\n const commit = (next: string) => {\n if (next !== text) onCommitText(next);\n };\n\n if (multiline) {\n return (\n <Textarea\n id={id}\n key={text}\n size={size}\n mode=\"edit\"\n minRows={3}\n disabled={disabled}\n placeholder={placeholder}\n defaultValue={text}\n spellCheck={false}\n autoFocus={interactive}\n className=\"font-mono\"\n onBlur={(event) => {\n commit(event.currentTarget.value);\n exitEdit();\n }}\n />\n );\n }\n\n return (\n <Input\n id={id}\n key={text}\n size={size}\n mode=\"edit\"\n type=\"text\"\n // Not `type=\"number\"`: an `<input type=number>` reports \"\" for text it\n // considers invalid, so the literal keystrokes we promise to keep would\n // be unreadable on commit. The numeric keyboard is requested instead.\n inputMode={type === \"number\" || type === \"integer\" ? \"decimal\" : undefined}\n disabled={disabled}\n placeholder={placeholder}\n defaultValue={text}\n spellCheck={false}\n autoFocus={interactive}\n onKeyDown={(event) => {\n if (event.key === \"Enter\" && !isImeComposing(event)) event.currentTarget.blur();\n }}\n onBlur={(event) => {\n commit(event.currentTarget.value);\n exitEdit();\n }}\n />\n );\n}\n","import { useState } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { isImeComposing } from \"../../utils/ime\";\nimport { Badge } from \"../Badge/Badge\";\nimport { Button } from \"../Button/Button\";\nimport { Text } from \"../Text/Text\";\nimport { Input } from \"../inputs/Input/Input\";\nimport { Select } from \"../inputs/Select/Select\";\nimport { useJsonEditorContext } from \"./JsonEditor.context\";\nimport { describeEdit } from \"./JsonEditor.paths\";\nimport { JsonEditorValue, toText } from \"./JsonEditorValue\";\nimport { JSON_FIELD_TYPES } from \"./JsonEditor.types\";\nimport type { JsonEditorNode, JsonFieldType } from \"./JsonEditor.types\";\n\n/** One indent step, in px. Applied as an inline style because depth is data. */\nconst INDENT = 18;\n\nexport interface JsonEditorRowProps {\n node: JsonEditorNode;\n}\n\n/**\n * One key/value row.\n *\n * Flat in the DOM rather than nested: `aria-level` carries the depth, so an\n * agent can address `[data-path=\"orders.2.total\"]` in one selector instead of\n * walking a nesting it would have to guess the shape of. It is also the\n * standard flat-tree ARIA pattern.\n */\nexport function JsonEditorRow({ node }: JsonEditorRowProps) {\n const ctx = useJsonEditorContext();\n const { dotted, key, depth, container, conflict } = node;\n\n const expanded = container ? ctx.isExpanded(dotted) : undefined;\n const pending = ctx.pendingFor(dotted);\n const renameable =\n ctx.allowRename && !ctx.readOnly && node.parentKind === \"object\" && ctx.mode === \"edit\";\n const label = node.rule?.label ?? key;\n\n return (\n <div\n data-react-fancy-json-editor-row=\"\"\n data-path={dotted}\n data-key={key}\n data-type={node.type}\n data-depth={depth}\n data-declared={node.declared ? \"true\" : \"false\"}\n data-conflict={conflict ? \"true\" : undefined}\n data-pending={pending.length > 0 ? \"true\" : undefined}\n role=\"treeitem\"\n aria-level={depth + 1}\n aria-expanded={expanded}\n className={cn(\n \"border-b border-zinc-100 py-1 last:border-b-0 dark:border-zinc-800\",\n conflict && \"bg-red-50/60 dark:bg-red-950/20\",\n pending.length > 0 && \"bg-violet-50/60 dark:bg-violet-950/20\",\n )}\n >\n <div className=\"flex items-start gap-2 px-2\" style={{ paddingInlineStart: depth * INDENT + 8 }}>\n {container ? (\n <Button\n variant=\"ghost\"\n size=\"xs\"\n data-react-fancy-json-editor-toggle=\"\"\n data-path={dotted}\n aria-label={expanded ? `Collapse ${label}` : `Expand ${label}`}\n aria-expanded={expanded}\n icon={expanded ? \"chevron-down\" : \"chevron-right\"}\n onClick={() => ctx.toggleExpanded(dotted)}\n />\n ) : (\n <span aria-hidden=\"true\" className=\"inline-block w-6 shrink-0\" />\n )}\n\n <div\n data-react-fancy-json-editor-key=\"\"\n data-path={dotted}\n className=\"w-1/3 min-w-0 shrink-0\"\n >\n {renameable ? (\n <Input\n // Uncontrolled + keyed + commit on blur: renaming per keystroke\n // would fire one structural edit per character.\n key={key}\n size={ctx.size}\n mode=\"edit\"\n defaultValue={key}\n spellCheck={false}\n aria-label={`Key of ${dotted}`}\n onKeyDown={(event) => {\n if (event.key === \"Enter\" && !isImeComposing(event)) event.currentTarget.blur();\n }}\n onBlur={(event) => {\n const next = event.currentTarget.value;\n if (next !== key) ctx.renameAt(node, next);\n }}\n />\n ) : (\n <Text\n as=\"span\"\n size=\"sm\"\n weight=\"medium\"\n color={node.parentKind === \"array\" ? \"muted\" : \"default\"}\n className=\"block truncate py-1 font-mono\"\n title={dotted}\n >\n {node.parentKind === \"array\" ? `[${key}]` : label}\n </Text>\n )}\n {node.rule?.description && (\n <Text as=\"span\" size=\"xs\" color=\"muted\" className=\"block truncate\">\n {node.rule.description}\n </Text>\n )}\n </div>\n\n <div\n data-react-fancy-json-editor-value=\"\"\n data-path={dotted}\n data-type={node.type}\n className=\"min-w-0 flex-1\"\n >\n {container ? (\n <Text as=\"span\" size=\"sm\" color=\"muted\" className=\"block py-1 font-mono\">\n {node.type === \"array\"\n ? `[ ${node.childCount} ${node.childCount === 1 ? \"item\" : \"items\"} ]`\n : `{ ${node.childCount} ${node.childCount === 1 ? \"key\" : \"keys\"} }`}\n </Text>\n ) : (\n <JsonEditorValue\n node={node}\n mode={ctx.mode}\n size={ctx.size}\n readOnly={ctx.readOnly}\n id={`${ctx.idPrefix}-${dotted}`}\n onCommit={(next) => ctx.setValueAt(node, next)}\n />\n )}\n </div>\n\n <div className=\"flex shrink-0 items-center gap-0.5 pt-0.5\">\n {node.declared && (\n <Badge size=\"sm\" variant=\"soft\" color={conflict ? \"red\" : \"zinc\"}>\n {node.type}\n </Badge>\n )}\n {container && ctx.allowAdd && !ctx.readOnly && (\n <Button\n variant=\"ghost\"\n size=\"xs\"\n data-react-fancy-json-editor-add=\"\"\n data-path={dotted}\n aria-label={`Add to ${label}`}\n icon=\"plus\"\n onClick={() => ctx.setAddingAt(ctx.addingAt === dotted ? null : dotted)}\n />\n )}\n {ctx.allowReorder && !ctx.readOnly && node.parentKind === \"array\" && (\n <>\n <Button\n variant=\"ghost\"\n size=\"xs\"\n data-react-fancy-json-editor-move-up=\"\"\n data-path={dotted}\n aria-label={`Move ${dotted} up`}\n icon=\"arrow-up\"\n onClick={() => ctx.moveAt(node, Number(key) - 1)}\n />\n <Button\n variant=\"ghost\"\n size=\"xs\"\n data-react-fancy-json-editor-move-down=\"\"\n data-path={dotted}\n aria-label={`Move ${dotted} down`}\n icon=\"arrow-down\"\n onClick={() => ctx.moveAt(node, Number(key) + 1)}\n />\n </>\n )}\n {ctx.allowRemove && !ctx.readOnly && node.parentKind !== \"root\" && (\n <Button\n variant=\"ghost\"\n size=\"xs\"\n color=\"red\"\n data-react-fancy-json-editor-remove=\"\"\n data-path={dotted}\n aria-label={`Remove ${dotted}`}\n icon=\"trash-2\"\n onClick={() => ctx.removeAt(node)}\n />\n )}\n </div>\n </div>\n\n {conflict && (\n <Text\n as=\"span\"\n size=\"xs\"\n color=\"danger\"\n data-react-fancy-json-editor-conflict=\"\"\n data-path={dotted}\n className=\"block px-2 pb-1\"\n style={{ paddingInlineStart: depth * INDENT + 40 }}\n >\n {conflict.message}\n </Text>\n )}\n\n {pending.map((edit) => (\n <div\n key={edit.id}\n data-react-fancy-json-editor-pending=\"\"\n data-id={edit.id}\n data-path={dotted}\n className=\"flex items-center gap-2 px-2 pb-1\"\n style={{ paddingInlineStart: depth * INDENT + 40 }}\n >\n <Badge size=\"sm\" variant=\"soft\" color=\"violet\">\n proposed\n </Badge>\n <Text as=\"span\" size=\"xs\" color=\"muted\" className=\"min-w-0 truncate font-mono\">\n {edit.label ?? describeEdit(edit)}\n {edit.op === \"set\" || edit.op === \"insert\" ? ` → ${toText(edit.value)}` : \"\"}\n </Text>\n <Button\n size=\"xs\"\n color=\"emerald\"\n data-react-fancy-json-editor-accept=\"\"\n data-id={edit.id}\n onClick={() => ctx.acceptPending(edit.id)}\n >\n Accept\n </Button>\n <Button\n size=\"xs\"\n variant=\"ghost\"\n data-react-fancy-json-editor-reject=\"\"\n data-id={edit.id}\n onClick={() => ctx.rejectPending(edit.id)}\n >\n Reject\n </Button>\n </div>\n ))}\n </div>\n );\n}\n\nexport interface JsonEditorAddFormProps {\n /** Dotted path of the container being added to; `\"\"` is the document root. */\n path: string;\n kind: \"object\" | \"array\";\n depth: number;\n /** Declared type for the container's children, when the keyMap names one. */\n suggestedType?: JsonFieldType;\n}\n\n/**\n * The inline \"add a key\" form.\n *\n * Its open/closed state and its two draft fields are the only state this\n * component owns that is not in `value` — and deliberately so: a half-typed key\n * name is not part of the document, and an agent adding a key does it through\n * an `insert` edit, never by driving this form.\n */\nexport function JsonEditorAddForm({ path, kind, depth, suggestedType }: JsonEditorAddFormProps) {\n const ctx = useJsonEditorContext();\n const [key, setKey] = useState(\"\");\n const [type, setType] = useState<JsonFieldType>(suggestedType ?? \"string\");\n\n return (\n <div\n data-react-fancy-json-editor-add-form=\"\"\n data-path={path}\n className=\"flex items-center gap-2 border-b border-zinc-100 px-2 py-1.5 dark:border-zinc-800\"\n style={{ paddingInlineStart: depth * INDENT + 32 }}\n >\n {kind === \"object\" && (\n <Input\n size={ctx.size}\n mode=\"edit\"\n value={key}\n placeholder=\"key\"\n aria-label=\"New key\"\n spellCheck={false}\n data-react-fancy-json-editor-add-key=\"\"\n onValueChange={setKey}\n />\n )}\n <Select\n size={ctx.size}\n mode=\"edit\"\n aria-label=\"New value type\"\n data-react-fancy-json-editor-add-type=\"\"\n list={[...JSON_FIELD_TYPES]}\n value={type}\n onValueChange={(next) => setType(next as JsonFieldType)}\n />\n <Button\n size=\"xs\"\n color=\"blue\"\n data-react-fancy-json-editor-add-confirm=\"\"\n onClick={() => ctx.insertInto(path, kind === \"object\" ? key : undefined, type)}\n >\n Add\n </Button>\n <Button\n size=\"xs\"\n variant=\"ghost\"\n data-react-fancy-json-editor-add-cancel=\"\"\n onClick={() => ctx.setAddingAt(null)}\n >\n Cancel\n </Button>\n </div>\n );\n}\n","import { forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button } from \"../Button/Button\";\nimport { Callout } from \"../Callout/Callout\";\nimport { Text } from \"../Text/Text\";\nimport { JsonEditorContext } from \"./JsonEditor.context\";\nimport { JsonEditorAddForm, JsonEditorRow } from \"./JsonEditorRow\";\nimport { findJsonConflicts, inferType, parseKeyMap, resolveKeyRule, seedValue } from \"./JsonEditor.keymap\";\nimport {\n applyJsonEdit,\n describeEdit,\n getAtPath,\n isContainerValue,\n isJsonArray,\n isJsonObject,\n parsePath,\n pathToString,\n} from \"./JsonEditor.paths\";\nimport type { JsonEditorContextValue } from \"./JsonEditor.context\";\nimport type {\n JsonEditorEdit,\n JsonEditorIssue,\n JsonEditorNode,\n JsonEditorPendingEdit,\n JsonEditorProps,\n JsonFieldType,\n JsonKeyMapEntry,\n JsonPath,\n JsonValue,\n} from \"./JsonEditor.types\";\n\ntype RenderItem =\n | { kind: \"node\"; node: JsonEditorNode }\n | {\n kind: \"add\";\n path: string;\n containerKind: \"object\" | \"array\";\n depth: number;\n suggestedType?: JsonFieldType;\n };\n\n/** Dotted paths of every container in the document — the \"expand everything\" set. */\nfunction collectContainerPaths(value: JsonValue): string[] {\n const out: string[] = [];\n\n const walk = (node: JsonValue, segments: JsonPath) => {\n if (!isContainerValue(node)) return;\n if (segments.length > 0) out.push(pathToString(segments));\n if (isJsonArray(node)) {\n node.forEach((child, index) => walk(child, [...segments, String(index)]));\n } else if (isJsonObject(node)) {\n for (const [key, child] of Object.entries(node)) walk(child, [...segments, key]);\n }\n };\n\n walk(value, []);\n return out;\n}\n\n/**\n * JsonEditor — a key/value editor over arbitrary, arbitrarily-nested JSON, with\n * a caller-supplied `keyMap` imposing a data type on any path.\n *\n * The type does two jobs at once, which is the point of the feature: it decides\n * how a value is RENDERED when you are reading, and which control appears when\n * you are editing. `{\"user.age\": \"number\"}` is not documentation — it is the\n * reason that row is a numeric field and the reason `\"thirty-six\"` shows up in\n * red instead of quietly becoming `0`.\n *\n * The three design decisions worth knowing before you use it:\n *\n * - **`keyMap` is a JSON string, and only a string.** It has to survive an MCP\n * tool argument, a config column and a `data-*` attribute; a live object\n * survives none of those. See {@link JsonEditorProps.keyMap}.\n * - **Nothing is coerced and nothing is dropped.** A value that contradicts\n * its declared type keeps its real value, renders through the raw editor,\n * and is reported through the issues panel, the `data-issues` count and\n * `onIssuesChange` — the same channel a broken `keyMap` uses.\n * - **It is controlled, all the way down.** The document lives in `value`.\n * The only state here is which rows are expanded, which add-form is open,\n * and the half-typed text inside a control that has not committed yet.\n *\n * Every control is a `react-fancy` primitive, so restyling the kit restyles\n * this, and `mode=\"view\"` gets the kit's click-to-edit behaviour for free.\n */\nexport const JsonEditor = forwardRef<HTMLDivElement, JsonEditorProps>(function JsonEditor(\n {\n value,\n onChange,\n keyMap,\n mode = \"view\",\n size = \"sm\",\n readOnly = false,\n expanded,\n defaultExpanded,\n onExpandedChange,\n showIssues = true,\n onIssuesChange,\n pendingMode = false,\n pending,\n onPendingChange,\n onActivity,\n allowAdd = true,\n allowRemove = true,\n allowRename = true,\n allowReorder = true,\n rootLabel = \"value\",\n emptyLabel = \"No keys yet.\",\n idPrefix,\n className,\n ...rest\n },\n ref,\n) {\n const autoId = useId();\n const prefix = idPrefix ?? autoId;\n const editSeq = useRef(0);\n\n // Parsed ONCE per distinct keyMap string — not per row, not per render. The\n // map is compiled into path patterns with a specificity score, and rows only\n // ever do a match against that.\n const parsedKeyMap = useMemo(() => parseKeyMap(keyMap), [keyMap]);\n const rules = parsedKeyMap.rules;\n\n const conflicts = useMemo(() => findJsonConflicts(value, rules), [value, rules]);\n\n // Transient complaints about an edit that was refused (duplicate key, empty\n // key). They belong beside the type conflicts because from the user's side\n // they are the same thing: something they can see is wrong and can fix.\n const [editIssues, setEditIssues] = useState<JsonEditorIssue[]>([]);\n\n const issues = useMemo(\n () => [...parsedKeyMap.issues, ...conflicts, ...editIssues],\n [parsedKeyMap.issues, conflicts, editIssues],\n );\n\n const onIssuesChangeRef = useRef(onIssuesChange);\n onIssuesChangeRef.current = onIssuesChange;\n const lastIssueSignature = useRef<string | null>(null);\n\n useEffect(() => {\n const signature = JSON.stringify(issues);\n if (signature === lastIssueSignature.current) return;\n lastIssueSignature.current = signature;\n onIssuesChangeRef.current?.(issues);\n }, [issues]);\n\n // ── expansion ─────────────────────────────────────────────────────────\n // `null` means \"expanded, everything\" — the state a caller that named no\n // paths is in. Storing it as a sentinel rather than materialising every\n // container path keeps a container added later expanded too.\n const expandedControlled = expanded !== undefined;\n const [expandedUncontrolled, setExpandedUncontrolled] = useState<string[] | null>(\n defaultExpanded ?? null,\n );\n const expandedList = expandedControlled ? expanded : expandedUncontrolled;\n\n const isExpanded = useCallback(\n (dotted: string) => expandedList === null || expandedList.includes(dotted),\n [expandedList],\n );\n\n const toggleExpanded = useCallback(\n (dotted: string) => {\n const current = expandedList ?? collectContainerPaths(value);\n const next = current.includes(dotted)\n ? current.filter((path) => path !== dotted)\n : [...current, dotted];\n if (!expandedControlled) setExpandedUncontrolled(next);\n onExpandedChange?.(next);\n },\n [expandedList, expandedControlled, onExpandedChange, value],\n );\n\n // ── add form ──────────────────────────────────────────────────────────\n const [addingAt, setAddingAt] = useState<string | null>(null);\n\n // ── committing ────────────────────────────────────────────────────────\n const stagedPending = useMemo(() => pending ?? [], [pending]);\n\n const commit = useCallback(\n (edit: JsonEditorEdit) => {\n setEditIssues([]);\n\n if (pendingMode) {\n // Trust-but-verify: the edit becomes a PROPOSAL. `value` does not move\n // and `onChange` does not fire until a human accepts it.\n const staged: JsonEditorPendingEdit = {\n ...edit,\n id: edit.id ?? `${prefix}-edit-${editSeq.current++}`,\n label: edit.label ?? describeEdit(edit),\n };\n onPendingChange?.([...stagedPending, staged]);\n onActivity?.({ type: \"stage\", edit: staged });\n return;\n }\n\n const next = applyJsonEdit(value, edit);\n // `applyJsonEdit` returns the same reference when it refuses an edit, so\n // a refusal never reaches the host as a spurious \"changed\" callback.\n if (next === value) return;\n onChange?.(next, edit);\n onActivity?.({ type: \"commit\", edit });\n },\n [pendingMode, prefix, stagedPending, onPendingChange, onActivity, value, onChange],\n );\n\n const refuse = useCallback((path: string, message: string) => {\n setEditIssues([{ kind: \"edit\", path, message }]);\n }, []);\n\n const setValueAt = useCallback(\n (node: JsonEditorNode, next: JsonValue) => {\n commit({ op: \"set\", path: node.dotted, value: next });\n },\n [commit],\n );\n\n const removeAt = useCallback(\n (node: JsonEditorNode) => {\n commit({ op: \"remove\", path: node.dotted });\n },\n [commit],\n );\n\n const moveAt = useCallback(\n (node: JsonEditorNode, to: number) => {\n commit({ op: \"move\", path: node.dotted, to });\n },\n [commit],\n );\n\n const renameAt = useCallback(\n (node: JsonEditorNode, key: string) => {\n if (key === node.key) return;\n if (key.trim() === \"\") {\n refuse(node.dotted, \"A key cannot be empty.\");\n return;\n }\n const parent = getAtPath(value, node.path.slice(0, -1));\n if (isJsonObject(parent) && Object.prototype.hasOwnProperty.call(parent, key)) {\n refuse(node.dotted, `A key named \"${key}\" already exists here — rename refused.`);\n return;\n }\n commit({ op: \"rename\", path: node.dotted, key });\n },\n [commit, refuse, value],\n );\n\n const insertInto = useCallback(\n (dotted: string, key: string | undefined, type: JsonFieldType) => {\n const segments = parsePath(dotted);\n const container = dotted === \"\" ? value : getAtPath(value, segments);\n const isArray = isJsonArray(container);\n\n if (!isArray) {\n if (key === undefined || key.trim() === \"\") {\n refuse(dotted, \"A new key needs a name.\");\n return;\n }\n if (isJsonObject(container) && Object.prototype.hasOwnProperty.call(container, key)) {\n refuse(dotted, `A key named \"${key}\" already exists here.`);\n return;\n }\n }\n\n const rule = resolveKeyRule(rules, [...segments, isArray ? \"*\" : key!]);\n setAddingAt(null);\n commit({\n op: \"insert\",\n path: dotted,\n key: isArray ? undefined : key,\n value: seedValue(type, rule),\n });\n },\n [commit, refuse, rules, value],\n );\n\n const pendingFor = useCallback(\n (dotted: string) => stagedPending.filter((edit) => edit.path === dotted),\n [stagedPending],\n );\n\n const acceptPending = useCallback(\n (id: string) => {\n const edit = stagedPending.find((candidate) => candidate.id === id);\n if (!edit) return;\n const next = applyJsonEdit(value, edit);\n onPendingChange?.(stagedPending.filter((candidate) => candidate.id !== id));\n if (next !== value) {\n onChange?.(next, edit);\n onActivity?.({ type: \"accept\", edit });\n }\n },\n [stagedPending, value, onPendingChange, onChange, onActivity],\n );\n\n const rejectPending = useCallback(\n (id: string) => {\n const edit = stagedPending.find((candidate) => candidate.id === id);\n onPendingChange?.(stagedPending.filter((candidate) => candidate.id !== id));\n if (edit) onActivity?.({ type: \"reject\", edit });\n },\n [stagedPending, onPendingChange, onActivity],\n );\n\n // ── rows ──────────────────────────────────────────────────────────────\n const items = useMemo(\n () =>\n buildItems({\n value,\n rules,\n conflicts,\n isExpanded,\n addingAt,\n rootLabel,\n }),\n [value, rules, conflicts, isExpanded, addingAt, rootLabel],\n );\n\n const rootIsContainer = isContainerValue(value);\n const rootKind = isJsonArray(value) ? \"array\" : \"object\";\n const attachedIds = new Set(\n items.flatMap((item) => (item.kind === \"node\" ? [item.node.dotted] : [])),\n );\n const orphanPending = stagedPending.filter((edit) => !attachedIds.has(edit.path));\n\n const context = useMemo<JsonEditorContextValue>(\n () => ({\n mode: readOnly ? \"view\" : mode,\n size,\n readOnly,\n allowAdd: allowAdd && !readOnly,\n allowRemove: allowRemove && !readOnly,\n allowRename: allowRename && !readOnly,\n allowReorder: allowReorder && !readOnly,\n pendingMode,\n idPrefix: prefix,\n isExpanded,\n toggleExpanded,\n setValueAt,\n removeAt,\n renameAt,\n moveAt,\n insertInto,\n addingAt,\n setAddingAt,\n pendingFor,\n acceptPending,\n rejectPending,\n }),\n [\n mode,\n size,\n readOnly,\n allowAdd,\n allowRemove,\n allowRename,\n allowReorder,\n pendingMode,\n prefix,\n isExpanded,\n toggleExpanded,\n setValueAt,\n removeAt,\n renameAt,\n moveAt,\n insertInto,\n addingAt,\n pendingFor,\n acceptPending,\n rejectPending,\n ],\n );\n\n return (\n <JsonEditorContext.Provider value={context}>\n <div\n ref={ref}\n // Rest FIRST: a caller's `data-*` / `aria-*` reach the DOM, but nothing\n // they pass can overwrite the marker below or drop the internal classes.\n {...rest}\n data-react-fancy-json-editor=\"\"\n data-issues={String(issues.length)}\n data-keymap-error={parsedKeyMap.ok ? undefined : \"true\"}\n data-mode={readOnly ? \"readonly\" : mode}\n className={cn(\n \"overflow-hidden rounded-lg border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] text-[color:var(--fancy-text,var(--color-zinc-900))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))] dark:text-[color:var(--fancy-text-dark,var(--color-zinc-100))]\",\n className,\n )}\n >\n {showIssues && issues.length > 0 && (\n <div data-react-fancy-json-editor-issues=\"\" className=\"p-2\">\n <Callout color={parsedKeyMap.ok ? \"amber\" : \"red\"}>\n <Text size=\"sm\" weight=\"semibold\" className=\"mb-1\">\n {parsedKeyMap.ok\n ? `${issues.length} ${issues.length === 1 ? \"issue\" : \"issues\"}`\n : \"The keyMap could not be used — values are shown untyped.\"}\n </Text>\n <ul className=\"space-y-0.5\">\n {issues.map((issue, index) => (\n <li key={`${issue.kind}-${issue.path}-${index}`}>\n <Text as=\"span\" size=\"xs\" data-react-fancy-json-editor-issue=\"\" data-kind={issue.kind} data-path={issue.path}>\n {issue.path ? `${issue.path} — ` : \"\"}\n {issue.message}\n </Text>\n </li>\n ))}\n </ul>\n </Callout>\n </div>\n )}\n\n <div data-react-fancy-json-editor-tree=\"\" role=\"tree\" aria-label={rest[\"aria-label\"] ?? \"JSON document\"}>\n {items.length === 0 ? (\n <Text as=\"p\" size=\"sm\" color=\"muted\" className=\"px-3 py-4\">\n {emptyLabel}\n </Text>\n ) : (\n items.map((item) =>\n item.kind === \"node\" ? (\n <JsonEditorRow key={`row:${item.node.dotted}`} node={item.node} />\n ) : (\n <JsonEditorAddForm\n key={`add:${item.path}`}\n path={item.path}\n kind={item.containerKind}\n depth={item.depth}\n suggestedType={item.suggestedType}\n />\n ),\n )\n )}\n </div>\n\n {orphanPending.length > 0 && (\n <div data-react-fancy-json-editor-orphan-pending=\"\" className=\"border-t border-zinc-100 p-2 dark:border-zinc-800\">\n {orphanPending.map((edit) => (\n <div key={edit.id} className=\"flex items-center gap-2 py-0.5\">\n <Text as=\"span\" size=\"xs\" color=\"muted\" className=\"min-w-0 flex-1 truncate font-mono\">\n {edit.label ?? describeEdit(edit)}\n </Text>\n <Button\n size=\"xs\"\n color=\"emerald\"\n data-react-fancy-json-editor-accept=\"\"\n data-id={edit.id}\n onClick={() => acceptPending(edit.id)}\n >\n Accept\n </Button>\n <Button\n size=\"xs\"\n variant=\"ghost\"\n data-react-fancy-json-editor-reject=\"\"\n data-id={edit.id}\n onClick={() => rejectPending(edit.id)}\n >\n Reject\n </Button>\n </div>\n ))}\n </div>\n )}\n\n {rootIsContainer && allowAdd && !readOnly && (\n <div className=\"border-t border-zinc-100 p-2 dark:border-zinc-800\">\n <Button\n variant=\"ghost\"\n size=\"xs\"\n icon=\"plus\"\n data-react-fancy-json-editor-add=\"\"\n data-path=\"\"\n onClick={() => setAddingAt(addingAt === \"\" ? null : \"\")}\n >\n {rootKind === \"array\" ? \"Append item\" : \"Add key\"}\n </Button>\n </div>\n )}\n </div>\n </JsonEditorContext.Provider>\n );\n});\n\ninterface BuildItemsOptions {\n value: JsonValue;\n rules: JsonKeyMapEntry[];\n conflicts: JsonEditorIssue[];\n isExpanded: (dotted: string) => boolean;\n addingAt: string | null;\n rootLabel: string;\n}\n\nfunction buildItems({\n value,\n rules,\n conflicts,\n isExpanded,\n addingAt,\n rootLabel,\n}: BuildItemsOptions): RenderItem[] {\n const out: RenderItem[] = [];\n const conflictByPath = new Map<string, JsonEditorIssue>();\n for (const issue of conflicts) {\n if (issue.kind === \"type\" && !conflictByPath.has(issue.path)) conflictByPath.set(issue.path, issue);\n }\n\n const makeNode = (\n segments: JsonPath,\n node: JsonValue,\n depth: number,\n parentKind: JsonEditorNode[\"parentKind\"],\n ): JsonEditorNode => {\n const rule = segments.length > 0 ? resolveKeyRule(rules, segments) : undefined;\n const type = rule?.type ?? inferType(node);\n const dotted = pathToString(segments);\n const conflict = conflictByPath.get(dotted);\n // A `json` node is raw text by definition, and a node in conflict must show\n // what it really holds — neither is a branch to walk into.\n const container = !conflict && type !== \"json\" && isContainerValue(node);\n\n return {\n path: segments,\n dotted,\n key: segments[segments.length - 1] ?? rootLabel,\n depth,\n value: node,\n parentKind,\n rule,\n type,\n declared: rule !== undefined,\n container,\n childCount: isJsonArray(node)\n ? node.length\n : isJsonObject(node)\n ? Object.keys(node).length\n : 0,\n conflict,\n };\n };\n\n const emitChildren = (node: JsonValue, segments: JsonPath, depth: number) => {\n if (isJsonArray(node)) {\n node.forEach((child, index) => emit(child, [...segments, String(index)], depth, \"array\"));\n } else if (isJsonObject(node)) {\n for (const [key, child] of Object.entries(node)) {\n emit(child, [...segments, key], depth, \"object\");\n }\n }\n };\n\n const emit = (\n node: JsonValue,\n segments: JsonPath,\n depth: number,\n parentKind: JsonEditorNode[\"parentKind\"],\n ) => {\n const built = makeNode(segments, node, depth, parentKind);\n out.push({ kind: \"node\", node: built });\n\n if (!built.container || !isExpanded(built.dotted)) return;\n\n emitChildren(node, segments, depth + 1);\n if (addingAt === built.dotted) {\n out.push({\n kind: \"add\",\n path: built.dotted,\n containerKind: isJsonArray(node) ? \"array\" : \"object\",\n depth: depth + 1,\n suggestedType: resolveKeyRule(rules, [...segments, \"*\"])?.type,\n });\n }\n };\n\n if (isContainerValue(value)) {\n emitChildren(value, [], 0);\n if (addingAt === \"\") {\n out.push({\n kind: \"add\",\n path: \"\",\n containerKind: isJsonArray(value) ? \"array\" : \"object\",\n depth: 0,\n suggestedType: resolveKeyRule(rules, [\"*\"])?.type,\n });\n }\n } else {\n out.push({ kind: \"node\", node: makeNode([], value, 0, \"root\") });\n }\n\n return out;\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Popover } from './chunk-QTS4Q2NK.js';
|
|
2
|
+
import { isImeComposing } from './chunk-S42OGG43.js';
|
|
2
3
|
import { useControllableState } from './chunk-EDYAXGUM.js';
|
|
3
4
|
import { cn } from './chunk-MMW2JGKZ.js';
|
|
4
5
|
import { forwardRef, useRef, useCallback, useLayoutEffect, useImperativeHandle, useState, useMemo, useEffect } from 'react';
|
|
@@ -602,7 +603,7 @@ var InlinePasteEditor = forwardRef(
|
|
|
602
603
|
const handleKeyDown = (e) => {
|
|
603
604
|
onKeyDown?.(e);
|
|
604
605
|
if (e.defaultPrevented) return;
|
|
605
|
-
if (e.key !== "Enter" || e
|
|
606
|
+
if (e.key !== "Enter" || isImeComposing(e)) return;
|
|
606
607
|
e.preventDefault();
|
|
607
608
|
const sends = !multiline || (submitKey === "mod-enter" ? e.ctrlKey || e.metaKey : !e.shiftKey);
|
|
608
609
|
if (sends) {
|
|
@@ -675,5 +676,5 @@ function PastedFilesInput({ name, files, form }) {
|
|
|
675
676
|
}
|
|
676
677
|
|
|
677
678
|
export { HOST_ATTR, InlinePasteEditor, InlinePill, PILL_MARK, PastedFilesInput, endsOf, expandMarkers, markedIds, pasteMarker, segmentValue, useInlinePaste, usePastePills, withSeparators };
|
|
678
|
-
//# sourceMappingURL=chunk-
|
|
679
|
-
//# sourceMappingURL=chunk-
|
|
679
|
+
//# sourceMappingURL=chunk-6PRXG7L6.js.map
|
|
680
|
+
//# sourceMappingURL=chunk-6PRXG7L6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/PastePills/use-paste-pills.ts","../src/components/PastePills/InlinePill.tsx","../src/components/PastePills/paste-markers.ts","../src/components/PastePills/use-inline-paste.tsx","../src/components/PastePills/InlinePasteEditor.tsx","../src/components/PastePills/PastedFilesInput.tsx"],"names":["useRef","useCallback","useState","jsx","InlinePasteEditor","id","range","jsxs","useEffect"],"mappings":";;;;;;;;AAkIO,SAAS,aAAA,CAAc;AAAA,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AAEJ","file":"chunk-6PRXG7L6.js","sourcesContent":["import { useCallback, useRef } from \"react\";\nimport { useControllableState } from \"../../hooks/use-controllable-state\";\n\n/**\n * A paste held beside a composer rather than inserted into it.\n *\n * There is deliberately **no `length` field.** It would be `text.length` and\n * nothing else, and a derived value stored beside its source is a value that can\n * disagree with it — the two drift the moment anything edits one. Read\n * `paste.text.length`.\n */\nexport interface HeldPaste {\n id: string;\n text: string;\n /** Shown on the pill instead of `Pasted text · N characters`. Display only. */\n label?: string;\n}\n\n/**\n * The minimum of a clipboard event this hook touches.\n *\n * Structural rather than `React.ClipboardEvent` so a host can call it from a\n * native listener, a synthetic one, or a test double. React's own event satisfies\n * it.\n */\nexport interface PasteEventLike {\n clipboardData?: { getData(type: string): string } | null;\n preventDefault(): void;\n}\n\nexport interface UsePastePillsOptions {\n /**\n * Hold a paste of at least this many characters. Try 500 — about a long\n * paragraph.\n *\n * **No default, on purpose.** Paste is a fundamental interaction, so holding one\n * is something a host asks for rather than something it discovers. Omit this and\n * `handlePaste` always returns `false` and touches nothing.\n */\n threshold?: number;\n /** Own the list yourself. Omit to let the hook keep it. */\n heldPastes?: HeldPaste[];\n onHeldPastesChange?: (pastes: HeldPaste[]) => void;\n}\n\nexport interface UsePastePillsResult {\n heldPastes: HeldPaste[];\n /**\n * Call this from your OWN paste handler. Returns `true` if it took the paste —\n * in which case it has already called `preventDefault()` — and `false` if it\n * declined, having touched nothing.\n *\n * Composable on purpose: a host whose handler already intercepts paste for its\n * own reasons needs to ask \"did you want this?\" rather than hand over the event.\n *\n * function onPaste(e) {\n * if (pills.handlePaste(e)) return;\n * // ...your own handling\n * }\n */\n handlePaste: (event: PasteEventLike) => boolean;\n /**\n * Hold `text` unconditionally and return the new pill's id.\n *\n * For a host that decides for itself what to hold and needs to know WHICH pill\n * it made — `Composer`'s inline placement puts the pill at the caret, so it needs\n * the id at paste time. Ignores `threshold`; the caller has already decided.\n */\n hold: (text: string) => string;\n /**\n * Removes the paste and returns its text, for the host to insert into its own\n * surface. `undefined` if there is no such id.\n *\n * The hook cannot insert it — it owns no DOM and does not know what a host's\n * surface is. That is the point.\n */\n expand: (id: string) => string | undefined;\n /** Discard one without returning it. */\n remove: (id: string) => void;\n /** Empty the list, e.g. after a send. */\n clear: () => void;\n}\n\n/**\n * Hold a large paste as state, so a composer can show it as a pill instead of\n * turning itself into a scrolling wall.\n *\n * ---------------------------------------------------------------------------\n * Why this is a hook and not just a feature of `Composer`\n * ---------------------------------------------------------------------------\n *\n * `Composer` shipped the behaviour in 5.31.0 and the MOIC estate, who specified it,\n * then established something I had missed: their chat input is a contenteditable\n * rendering inline `[deal:42|Acme]` badges, so they **cannot** adopt `Composer` (a\n * plain textarea) however much they want its behaviour. Their plan to delete their\n * own composer when ours landed could never have worked.\n *\n * So the logic lives here and **`Composer` is its first caller.** One\n * implementation rather than two, which matters more than the convenience: two\n * copies of a rule drift, and the copy nobody reads is the one that rots. The rule\n * that must not drift is the one in `Composer`'s own tests — a send with pills\n * still closed carries the text.\n *\n * It owns no DOM. The host renders the pills.\n *\n * ---------------------------------------------------------------------------\n * Who actually calls this (as of 5.32.0): `Composer`, and nothing else\n * ---------------------------------------------------------------------------\n *\n * The estate that specified it **withdrew before adopting it**, hours after it\n * shipped — their design moved the pill INTO the message as a `[paste:id|label]`\n * marker in the same grammar as their other object tags, which makes the message\n * itself the record of what is attached. A parallel `heldPastes` array would then be\n * a second place answering \"what am I sending?\", and the two would disagree the\n * moment someone backspaced a badge. Their reasoning was better than the spec.\n *\n * Recorded because a reader should not infer an extension point under active\n * external use. It is kept rather than withdrawn for two reasons that are about\n * cost, not optimism: it is published API on a 5.x package, so removing it needs a\n * major; and `Composer` calls it, so it is exercised by that component's tests on\n * every run and cannot rot unnoticed.\n *\n * **It gets no further surface without a real caller.** No extra options, no second\n * hook. An API with one hypothetical consumer is how a package accumulates surface\n * nobody uses.\n *\n * `hold` (5.38.0) met that bar: `Composer`'s inline placement — MOIC's\n * pill-inside-the-message design, built into the component — needs the id of the\n * pill it just made so it can put it at the caret.\n */\nexport function usePastePills({\n threshold,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n}: UsePastePillsOptions = {}): UsePastePillsResult {\n const [heldPastes, setHeldPastes] = useControllableState<HeldPaste[]>(\n controlledHeldPastes,\n [],\n onHeldPastesChange,\n );\n\n /*\n * A counter rather than `crypto.randomUUID()` or an index.\n *\n * An index is not an id — removing the first pill renumbers the rest, and a host\n * keying its DOM on that remounts every pill and loses hover state. A counter in\n * a ref is stable for the life of the component and needs no platform API that a\n * server renderer might lack.\n */\n const nextId = useRef(0);\n\n const hold = useCallback(\n (text: string): string => {\n /*\n * Skip any id the list already holds. A controlled list can arrive seeded\n * (restored drafts, an agent attaching a paste) before this counter has\n * counted anything, and minting `paste-1` beside an existing `paste-1` gives\n * two pills one id — expanding either then takes both.\n */\n let id: string;\n do {\n nextId.current += 1;\n id = `paste-${nextId.current}`;\n } while (heldPastes.some((p) => p.id === id));\n\n setHeldPastes((current) => [...current, { id, text }]);\n\n return id;\n },\n [heldPastes, setHeldPastes],\n );\n\n const handlePaste = useCallback(\n (event: PasteEventLike): boolean => {\n if (!threshold || threshold <= 0) return false;\n\n const text = event.clipboardData?.getData(\"text/plain\") ?? \"\";\n\n // Below the threshold, decline WITHOUT touching the event. A host calling\n // this from inside its own handler has to be able to carry on as if the hook\n // were not there.\n if (text.length < threshold) return false;\n\n event.preventDefault();\n hold(text);\n\n return true;\n },\n [threshold, hold],\n );\n\n const expand = useCallback(\n (id: string): string | undefined => {\n const found = heldPastes.find((p) => p.id === id);\n\n if (found === undefined) return undefined;\n\n setHeldPastes((current) => current.filter((p) => p.id !== id));\n\n return found.text;\n },\n [heldPastes, setHeldPastes],\n );\n\n const remove = useCallback(\n (id: string) => setHeldPastes((current) => current.filter((p) => p.id !== id)),\n [setHeldPastes],\n );\n\n const clear = useCallback(() => setHeldPastes([]), [setHeldPastes]);\n\n return { heldPastes, handlePaste, hold, expand, remove, clear };\n}\n","import { useEffect, useState, type ReactNode } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Popover } from \"../Popover\";\nimport type { ComposerPasteClassNames, ComposerPastePreview } from \"./PastePills.types\";\n\n/**\n * Thousands separators, written out rather than left to `toLocaleString()`.\n *\n * The number exists so someone can size the paste at a glance, and `2,036` sizes\n * faster than `2036`. It is not left to the runtime locale because the label beside\n * it (\"Pasted text\") is not localised either, so a locale-formatted number next to\n * an English noun would be half a translation.\n */\nexport function withSeparators(n: number): string {\n return String(n).replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\n}\n\n/** First and last N characters, middle elided. The ends say WHICH paste this is. */\nexport function endsOf(text: string, chars: number): string {\n if (text.length <= chars * 2) return text;\n\n return `${text.slice(0, chars)} … ${text.slice(-chars)}`;\n}\n\n/** The most a text pill's label shows, counted in code points, ellipsis included. */\nexport const TEXT_PILL_LABEL_MAX = 80;\n\n/**\n * A host-supplied text pill label as it may be drawn: one line of plain text.\n *\n * Whitespace, C0/C1 control characters and U+FFFC (the pill marker character)\n * each become a space, runs collapse to one, the ends are trimmed, and anything\n * past `TEXT_PILL_LABEL_MAX` is cut with an ellipsis, so a label cannot reflow the\n * message, smuggle a marker, or swallow the composer. It is rendered as a React\n * text node, never as HTML. `null` when there is nothing left to show, which\n * means the generic `Pasted text · N characters` is drawn instead.\n *\n * Checked by code point rather than with a regex so the source carries no\n * escape sequences (see the envelope rule on escapes).\n */\nexport function textPillLabel(raw: unknown): string | null {\n if (typeof raw !== \"string\") return null;\n let out = \"\";\n let pendingSpace = false;\n for (const ch of raw) {\n const c = ch.codePointAt(0)!;\n const blank = c < 0x20 || (c >= 0x7f && c <= 0x9f) || c === 0xfffc || ch.trim() === \"\";\n if (blank) {\n pendingSpace = out.length > 0;\n continue;\n }\n if (pendingSpace) out += \" \";\n pendingSpace = false;\n out += ch;\n }\n if (out === \"\") return null;\n const points = Array.from(out);\n return points.length > TEXT_PILL_LABEL_MAX\n ? `${points.slice(0, TEXT_PILL_LABEL_MAX - 1).join(\"\").trimEnd()}…`\n : out;\n}\n\nconst PILL_BASE =\n \"inline-flex select-none items-center rounded-md px-2 py-0.5 text-xs leading-5 transition-colors\";\nconst TEXT_PILL =\n \"cursor-pointer bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] text-zinc-700 hover:bg-zinc-200 dark:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))] dark:text-zinc-200 dark:hover:bg-zinc-700\";\nconst IMAGE_PILL =\n \"bg-rose-100 font-medium text-rose-600 dark:bg-rose-500/20 dark:text-rose-300\";\n/** Merged onto the Popover panel's own defaults: tighter padding for a preview. */\nconst PREVIEW_BASE = \"max-w-xs whitespace-pre-wrap break-all p-2 text-xs\";\n\n/**\n * An image's thumbnail, made from the File only while the preview is open.\n *\n * If the image cannot be shown — a Content-Security-Policy without `blob:` in\n * `img-src` is the usual reason — the label is shown instead. A broken `<img>`\n * with an empty `alt` renders as nothing at all, which is how a preview ends up\n * as an empty box.\n */\nfunction ImageThumb({ file, label }: { file: File; label: string }) {\n const [url, setUrl] = useState<string | null>(null);\n const [failed, setFailed] = useState(false);\n\n useEffect(() => {\n if (typeof URL.createObjectURL !== \"function\") return;\n const made = URL.createObjectURL(file);\n setUrl(made);\n setFailed(false);\n return () => URL.revokeObjectURL(made);\n }, [file]);\n\n return url && !failed ? (\n <img\n src={url}\n alt={label}\n onError={() => setFailed(true)}\n className=\"block max-h-40 max-w-[16rem] rounded\"\n />\n ) : (\n <span>{label}</span>\n );\n}\n\ninterface InlinePillProps {\n preview: ComposerPastePreview;\n previewChars: number;\n renderPastePreview?: (preview: ComposerPastePreview) => ReactNode;\n classNames?: ComposerPasteClassNames;\n disabled: boolean;\n onExpand: (id: string) => void;\n}\n\n/**\n * One pill inside the message, portalled by `Composer` into a placeholder the\n * editor made. Internal — its own file so its props are not read as `Composer`'s.\n *\n * The preview is a hover `Popover` (portalled, so the scrolling input cannot clip\n * it), and it opens on FOCUS too, so a keyboard user reaches the same preview. It\n * was a `Tooltip` until 5.51.0; a tooltip is for a short label, not an image.\n */\nexport function InlinePill({\n preview,\n previewChars,\n renderPastePreview,\n classNames,\n disabled,\n onExpand,\n}: InlinePillProps) {\n const [open, setOpen] = useState(false);\n const id = preview.kind === \"text\" ? preview.paste.id : preview.image.id;\n const content = (\n <span data-react-fancy-composer-paste-pill-preview={id}>\n {renderPastePreview?.(preview) ??\n (preview.kind === \"text\" ? (\n endsOf(preview.paste.text, previewChars)\n ) : (\n <ImageThumb file={preview.image.file} label={preview.image.label} />\n ))}\n </span>\n );\n const focusOpen = {\n onFocus: () => setOpen(true),\n onBlur: () => setOpen(false),\n };\n\n const textLabel = preview.kind === \"text\" ? textPillLabel(preview.paste.label) : null;\n const textSize =\n preview.kind === \"text\" ? `${withSeparators(preview.paste.text.length)} characters` : \"\";\n\n const pill =\n preview.kind === \"image\" ? (\n <span\n data-react-fancy-composer-image-pill={id}\n role=\"img\"\n tabIndex={0}\n aria-label={preview.image.label}\n {...focusOpen}\n className={cn(PILL_BASE, IMAGE_PILL, classNames?.pill, classNames?.imagePill)}\n >\n {preview.image.label}\n </span>\n ) : (\n <button\n type=\"button\"\n data-react-fancy-composer-paste-pill={id}\n onClick={() => onExpand(id)}\n disabled={disabled}\n aria-label={\n textLabel === null\n ? `Insert this pasted text, ${textSize}`\n : `Insert this pasted text: ${textLabel}, ${textSize}`\n }\n {...focusOpen}\n className={cn(PILL_BASE, TEXT_PILL, classNames?.pill, classNames?.textPill)}\n >\n {textLabel ?? `Pasted text · ${textSize}`}\n </button>\n );\n\n return (\n <Popover hover open={open} onOpenChange={setOpen} placement=\"top\">\n <Popover.Trigger>{pill}</Popover.Trigger>\n <Popover.Content className={cn(PREVIEW_BASE, classNames?.preview)}>\n {content}\n </Popover.Content>\n </Popover>\n );\n}\n","import type { HeldPaste } from \"./use-paste-pills\";\n\n/**\n * An image pasted into a `Composer` and held as a pill.\n *\n * `label` is stored rather than derived because the number in it is the order of\n * ARRIVAL: \"Pasted image 2\" must stay 2 after image 1 is deleted, and nothing left\n * in the list could recompute that.\n */\nexport interface HeldImage {\n id: string;\n file: File;\n label: string;\n}\n\n/**\n * U+FFFC OBJECT REPLACEMENT CHARACTER — Unicode's own \"an embedded object sits\n * here\". A marker is the id wrapped in a pair of them.\n *\n * Why the message carries a marker at all: with inline placement the message\n * ITSELF is the record of what is attached and where, so there is one answer to\n * \"what am I sending?\" rather than a text plus a parallel list that can disagree\n * the moment someone backspaces a pill. This is the MOIC estate's design for their\n * own composer, and the reason they withdrew from the beside-the-input layout.\n *\n * Only a marker whose id the composer actually holds is a pill; anything else is\n * left as text, so a stray U+FFFC in pasted content cannot invent an attachment.\n */\nexport const PILL_MARK = \"\\uFFFC\";\n\nconst MARKER = /\\uFFFC([^\\uFFFC\\n]+)\\uFFFC/g;\n\n/** The marker for a held paste or image, for a host or agent writing `value` itself. */\nexport function pasteMarker(id: string): string {\n return `${PILL_MARK}${id}${PILL_MARK}`;\n}\n\nexport type ValueSegment =\n | { type: \"text\"; text: string }\n | { type: \"pill\"; id: string };\n\n/** Split a value into text and pills. Markers for ids not in `known` stay text. */\nexport function segmentValue(value: string, known: ReadonlySet<string>): ValueSegment[] {\n const out: ValueSegment[] = [];\n let last = 0;\n\n for (const match of value.matchAll(MARKER)) {\n const id = match[1];\n if (!known.has(id)) continue;\n\n const start = match.index ?? 0;\n if (start > last) out.push({ type: \"text\", text: value.slice(last, start) });\n out.push({ type: \"pill\", id });\n last = start + match[0].length;\n }\n\n if (last < value.length) out.push({ type: \"text\", text: value.slice(last) });\n\n return out;\n}\n\n/** The id of every marker the value contains, in order, held or not. */\nexport function markedIds(value: string): string[] {\n return Array.from(value.matchAll(MARKER), (m) => m[1]);\n}\n\n/**\n * What actually gets sent: every text pill replaced by its full text, every image\n * pill by `[Pasted image N]` so the reader of the message can see where the image\n * sat. The images themselves go to `onSubmit`'s second argument.\n */\nexport function expandMarkers(\n value: string,\n pastes: readonly HeldPaste[],\n images: readonly HeldImage[],\n): string {\n const text = new Map(pastes.map((p) => [p.id, p.text]));\n const image = new Map(images.map((i) => [i.id, `[${i.label}]`]));\n\n return value.replace(MARKER, (whole, id: string) => text.get(id) ?? image.get(id) ?? whole);\n}\n","import { useCallback, useMemo, useRef, useState, type ReactNode, type RefObject } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useControllableState } from \"../../hooks/use-controllable-state\";\nimport { usePastePills, type HeldPaste } from \"./use-paste-pills\";\nimport { InlinePill } from \"./InlinePill\";\nimport type { InlinePasteEditorHandle, PillToInsert } from \"./InlinePasteEditor\";\nimport { expandMarkers, markedIds, type HeldImage } from \"./paste-markers\";\nimport type { ComposerPasteClassNames, ComposerPastePreview } from \"./PastePills.types\";\n\nexport interface UseInlinePasteOptions {\n pasteThreshold?: number;\n pasteImages?: boolean;\n previewChars: number;\n renderPastePreview?: (preview: ComposerPastePreview) => ReactNode;\n classNames?: ComposerPasteClassNames;\n disabled: boolean;\n heldPastes?: HeldPaste[];\n onHeldPastesChange?: (pastes: HeldPaste[]) => void;\n heldImages?: HeldImage[];\n onHeldImagesChange?: (images: HeldImage[]) => void;\n editorRef: RefObject<InlinePasteEditorHandle | null>;\n /**\n * Give a text pill a line to itself. Default `true`; a single-line field\n * (`Input`) has no lines to give, so its pills sit in the text.\n */\n blockText?: boolean;\n}\n\n/**\n * Everything inline paste pills need besides the editor itself: the held pastes\n * and images, deciding what a paste becomes, dropping a pill's hold when it is\n * deleted from the message, rendering the pills into the editor, and expanding\n * them on send.\n *\n * Shared by `Composer`, `PromptInput` and `Input` so they cannot disagree about\n * what a pill means. The rule that must not drift is the one `expand` and `imagesIn`\n * carry: a send with pills still closed carries everything they hold.\n */\nexport function useInlinePaste({\n pasteThreshold,\n pasteImages = false,\n previewChars,\n renderPastePreview,\n classNames,\n disabled,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n heldImages: controlledHeldImages,\n onHeldImagesChange,\n editorRef,\n blockText = true,\n}: UseInlinePasteOptions) {\n const pills = usePastePills({\n threshold: pasteThreshold,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n });\n const heldPastes = pills.heldPastes;\n const [heldImages, setHeldImages] = useControllableState<HeldImage[]>(\n controlledHeldImages,\n [],\n onHeldImagesChange,\n );\n const imageCount = useRef(0);\n\n const known = useMemo(\n () => new Set([...heldPastes.map((p) => p.id), ...heldImages.map((i) => i.id)]),\n [heldPastes, heldImages],\n );\n\n const holdImage = useCallback(\n (file: File): string => {\n let id: string;\n do {\n imageCount.current += 1;\n id = `image-${imageCount.current}`;\n } while (heldImages.some((i) => i.id === id));\n\n const image = { id, file, label: `Pasted image ${imageCount.current}` };\n setHeldImages((current) => [...current, image]);\n\n return id;\n },\n [heldImages, setHeldImages],\n );\n\n /** What a paste becomes. `null` means \"just text\". */\n const decidePaste = useCallback(\n (data: DataTransfer | null): PillToInsert[] | null => {\n const text = data?.getData(\"text/plain\") ?? \"\";\n\n // Only a PURE image paste: a clipboard with text as well usually carries a\n // picture OF that text (copying from a document), and holding it would turn\n // every pasted sentence into a screenshot of the sentence.\n if (pasteImages && text === \"\") {\n const files = Array.from(data?.files ?? []).filter((f) =>\n f.type.startsWith(\"image/\"),\n );\n if (files.length > 0) {\n return files.map((file) => ({ id: holdImage(file), block: false }));\n }\n }\n\n if (pasteThreshold && pasteThreshold > 0 && text.length >= pasteThreshold) {\n return [{ id: pills.hold(text), block: blockText }];\n }\n\n return null;\n },\n [pasteImages, pasteThreshold, holdImage, pills, blockText],\n );\n\n /*\n * The message is the record of what is attached. A pill backspaced out of it is\n * no longer attached, so its held entry goes too — otherwise state would say\n * \"attached\" about something the message no longer contains.\n */\n const prune = useCallback(\n (next: string) => {\n const present = new Set(markedIds(next));\n for (const paste of heldPastes) if (!present.has(paste.id)) pills.remove(paste.id);\n if (heldImages.some((i) => !present.has(i.id))) {\n setHeldImages((current) => current.filter((i) => present.has(i.id)));\n }\n },\n [heldPastes, heldImages, pills, setHeldImages],\n );\n\n const [hosts, setHosts] = useState<ReadonlyMap<string, HTMLElement>>(new Map());\n const onHostsChange = useCallback((next: ReadonlyMap<string, HTMLElement>) => {\n setHosts((prev) => {\n if (prev.size === next.size && [...next].every(([id, el]) => prev.get(id) === el)) {\n return prev;\n }\n return next;\n });\n }, []);\n\n /** Click a text pill and its full text takes the pill's place. */\n const expandPill = useCallback(\n (id: string) => {\n const text = pills.expand(id);\n if (text === undefined) return;\n editorRef.current?.replacePill(id, text);\n },\n [pills, editorRef],\n );\n\n /** The value as it is sent: every text pill expanded, every image marked. */\n const expand = useCallback(\n (value: string) => expandMarkers(value, heldPastes, heldImages),\n [heldPastes, heldImages],\n );\n\n /** The images the value still contains, in message order. */\n const imagesIn = useCallback(\n (value: string) =>\n markedIds(value).flatMap((id) => heldImages.filter((i) => i.id === id)),\n [heldImages],\n );\n\n const clear = useCallback(() => {\n pills.clear();\n setHeldImages([]);\n }, [pills, setHeldImages]);\n\n /** The pills, portalled into the placeholders the editor made. Render this anywhere. */\n const portals = Array.from(hosts, ([id, host]) => {\n const paste = heldPastes.find((p) => p.id === id);\n const image = paste ? undefined : heldImages.find((i) => i.id === id);\n const preview: ComposerPastePreview | null = paste\n ? { kind: \"text\", paste }\n : image\n ? { kind: \"image\", image }\n : null;\n\n return preview\n ? createPortal(\n <InlinePill\n preview={preview}\n previewChars={previewChars}\n renderPastePreview={renderPastePreview}\n classNames={classNames}\n disabled={disabled}\n onExpand={expandPill}\n />,\n host,\n id,\n )\n : null;\n });\n\n return {\n pills,\n heldPastes,\n heldImages,\n known,\n decidePaste,\n prune,\n onHostsChange,\n expand,\n imagesIn,\n clear,\n portals,\n };\n}\n","import {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n} from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { isImeComposing } from \"../../utils/ime\";\nimport { PILL_MARK, pasteMarker, segmentValue } from \"./paste-markers\";\n\n/** The attribute on the placeholder span a pill is portalled into. */\nexport const HOST_ATTR = \"data-react-fancy-composer-paste-host\";\n\n/** What a paste becomes, as decided by `Composer`. `block` pills get their own line. */\nexport interface PillToInsert {\n id: string;\n block: boolean;\n}\n\nexport interface InlinePasteEditorHandle {\n /** Focus, caret at the end. `options` go to the element's `focus()` as given. */\n focus(options?: FocusOptions): void;\n /** Swap a pill for plain text, where it sits. */\n replacePill(id: string, text: string): void;\n /**\n * Replace the whole value and put the caret at `caret` (an offset into the\n * value). For a host that edits text itself — `PromptInput`'s `/` and `@`\n * pickers — where rebuilding from `value` alone would lose the caret.\n */\n setValue(value: string, caret: number): void;\n}\n\ninterface InlinePasteEditorProps {\n value: string;\n /** Ids the composer holds. A marker for anything else stays text. */\n known: ReadonlySet<string>;\n /** `caret` is the caret's offset into `value`, or `value.length` if it is elsewhere. */\n onChange(value: string, caret: number): void;\n onSubmit(): void;\n /**\n * Which key sends. `\"enter\"` (default): Enter sends, Shift+Enter is a newline.\n * `\"mod-enter\"`: Ctrl/⌘+Enter sends and a plain Enter is a newline.\n */\n submitKey?: \"enter\" | \"mod-enter\";\n /** Runs BEFORE the editor's own key handling; `preventDefault()` to claim the key. */\n onKeyDown?(e: React.KeyboardEvent<HTMLDivElement>): void;\n placeholderClassName?: string;\n /** Height in px past which the input scrolls. Defaults to the class's max height. */\n maxHeight?: number;\n /** Return the pills a paste becomes, or null to insert its text as typed. */\n onPaste(data: DataTransfer | null): PillToInsert[] | null;\n /** Every pill placeholder currently in the editor, for the composer to portal into. */\n onHostsChange(hosts: ReadonlyMap<string, HTMLElement>): void;\n placeholder: string;\n disabled: boolean;\n className?: string;\n /**\n * `false` makes it a single-line field, as `Input` uses it: Enter always\n * submits, and a newline in pasted text becomes a space, as a browser does for\n * an `<input>`. A held paste keeps its newlines; it is only the field that has\n * one line. Default `true`.\n */\n multiline?: boolean;\n /** The editable surface's id, so a host can find it. */\n id?: string;\n /** Names the textbox for assistive tech; a `<div>` cannot be the target of a `<label>`. */\n ariaLabelledBy?: string;\n ariaInvalid?: boolean;\n style?: React.CSSProperties;\n}\n\n/**\n * Walk a node's children back into a value string.\n *\n * `<br>` as the LAST child of its parent is filler — browsers put one in an empty\n * line, and this editor puts one after a trailing newline so the caret has a line\n * to sit on — so it counts for nothing. Block elements a browser invents count as\n * a line break before them. Non-breaking spaces become spaces: a browser inserts\n * them for typed spaces it fears would collapse, not because anyone asked.\n */\nfunction serialize(parent: Node, keep: (id: string) => boolean): string {\n let out = \"\";\n const children = Array.from(parent.childNodes);\n\n children.forEach((node, i) => {\n if (node.nodeType === Node.TEXT_NODE) {\n out += (node.textContent ?? \"\").replace(/\\u00A0/g, \" \");\n return;\n }\n if (!(node instanceof HTMLElement)) return;\n\n const id = node.getAttribute(HOST_ATTR);\n if (id !== null) {\n if (keep(id)) out += pasteMarker(id);\n return;\n }\n if (node.tagName === \"BR\") {\n if (i !== children.length - 1) out += \"\\n\";\n return;\n }\n if (/^(DIV|P)$/.test(node.tagName) && out.length > 0 && !out.endsWith(\"\\n\")) {\n out += \"\\n\";\n }\n out += serialize(node, keep);\n });\n\n return out;\n}\n\nfunction makeHost(id: string): HTMLElement {\n const host = document.createElement(\"span\");\n host.setAttribute(\"contenteditable\", \"false\");\n host.setAttribute(HOST_ATTR, id);\n host.className = \"inline-block align-baseline\";\n return host;\n}\n\n/** A value ending in a newline needs a `<br>` after it, or the caret has no line to sit on. */\nfunction ensureTrailingBreak(root: HTMLElement, value: string) {\n const last = root.lastChild;\n const hasBreak = last instanceof HTMLElement && last.tagName === \"BR\";\n\n if (value.endsWith(\"\\n\") && !hasBreak) root.append(document.createElement(\"br\"));\n if (!value.endsWith(\"\\n\") && hasBreak && value.length > 0) last.remove();\n}\n\nfunction placeCaretAfter(node: Node) {\n const selection = window.getSelection();\n if (!selection) return;\n\n const range = document.createRange();\n range.setStartAfter(node);\n range.collapse(true);\n selection.removeAllRanges();\n selection.addRange(range);\n}\n\n/**\n * Put the caret `offset` characters into the serialised value. Walks the shape\n * `render` produces — text nodes, pill hosts (each worth its marker's length) and\n * a trailing `<br>` — so it is only called straight after a render.\n */\nfunction placeCaretAtOffset(root: HTMLElement, offset: number, keep: (id: string) => boolean) {\n const selection = window.getSelection();\n if (!selection) return;\n\n const range = document.createRange();\n let remaining = offset;\n let placed = false;\n\n for (const node of Array.from(root.childNodes)) {\n if (node.nodeType === Node.TEXT_NODE) {\n const length = node.textContent?.length ?? 0;\n if (remaining <= length) {\n range.setStart(node, remaining);\n placed = true;\n break;\n }\n remaining -= length;\n continue;\n }\n const id = node instanceof HTMLElement ? node.getAttribute(HOST_ATTR) : null;\n if (id !== null && keep(id)) {\n const length = pasteMarker(id).length;\n if (remaining < length) {\n range.setStartAfter(node);\n placed = true;\n break;\n }\n remaining -= length;\n }\n }\n\n if (!placed) {\n range.selectNodeContents(root);\n range.collapse(false);\n const last = root.lastChild;\n if (last instanceof HTMLElement && last.tagName === \"BR\") range.setStartBefore(last);\n }\n range.collapse(true);\n selection.removeAllRanges();\n selection.addRange(range);\n}\n\n/**\n * The plain-text-plus-pills surface behind `Composer`'s inline placement.\n *\n * The DOM is the source of truth WHILE TYPING and `value` is its serialisation;\n * the DOM is rebuilt from `value` only when `value` changes from outside (a send,\n * a host, an agent). Rebuilding on every keystroke would throw the caret away.\n *\n * Every insertion is done here by hand, never by the browser: a paste is always\n * intercepted, so no foreign HTML ever lands in the editor, and Enter is handled\n * so a browser never invents a `<div>` per line.\n */\nexport const InlinePasteEditor = forwardRef<InlinePasteEditorHandle, InlinePasteEditorProps>(\n function InlinePasteEditor(\n {\n value,\n known,\n onChange,\n onSubmit,\n onPaste,\n onHostsChange,\n placeholder,\n disabled,\n className,\n submitKey = \"enter\",\n onKeyDown,\n placeholderClassName,\n maxHeight,\n multiline = true,\n id,\n ariaLabelledBy,\n ariaInvalid,\n style,\n },\n ref,\n ) {\n const rootRef = useRef<HTMLDivElement>(null);\n /** The last value this editor produced or rendered. Anything else came from outside. */\n const lastValue = useRef<string | null>(null);\n /**\n * Ids inserted here whose hold has not reached `known` yet. A pill is held and\n * placed in the same event, and the composer's state lands a render later.\n */\n const pending = useRef(new Set<string>());\n const knownRef = useRef(known);\n knownRef.current = known;\n\n const keep = useCallback(\n (id: string) => knownRef.current.has(id) || pending.current.has(id),\n [],\n );\n\n const reportHosts = useCallback(() => {\n const root = rootRef.current;\n if (!root) return;\n\n const hosts = new Map<string, HTMLElement>();\n root.querySelectorAll<HTMLElement>(`[${HOST_ATTR}]`).forEach((el) => {\n const id = el.getAttribute(HOST_ATTR)!;\n if (keep(id)) hosts.set(id, el);\n });\n onHostsChange(hosts);\n }, [keep, onHostsChange]);\n\n /** The caret's offset into the serialised value, or its length if the caret is elsewhere. */\n const caretOffset = useCallback(\n (whole: string): number => {\n const root = rootRef.current;\n const selection = window.getSelection();\n if (!root || !selection || selection.rangeCount === 0) return whole.length;\n\n const range = selection.getRangeAt(0);\n if (!root.contains(range.endContainer)) return whole.length;\n\n const head = document.createRange();\n head.selectNodeContents(root);\n head.setEnd(range.endContainer, range.endOffset);\n return serialize(head.cloneContents(), keep).length;\n },\n [keep],\n );\n\n /** Read the DOM back into a value and tell the composer. */\n const emit = useCallback(() => {\n const root = rootRef.current;\n if (!root) return;\n\n const next = serialize(root, keep);\n ensureTrailingBreak(root, next);\n reportHosts();\n\n // Reported even when the value is unchanged: a host reading the caret (a\n // `/` picker) needs to hear about it.\n lastValue.current = next;\n onChange(next, caretOffset(next));\n }, [keep, onChange, reportHosts, caretOffset]);\n\n /** Rebuild the DOM from a value. Throws the caret away; callers put it back. */\n const render = useCallback(\n (next: string) => {\n const root = rootRef.current;\n if (!root) return;\n\n root.replaceChildren();\n for (const segment of segmentValue(next, knownRef.current)) {\n if (segment.type === \"text\") {\n root.append(document.createTextNode(segment.text));\n } else {\n root.append(makeHost(segment.id));\n }\n }\n ensureTrailingBreak(root, next);\n lastValue.current = next;\n reportHosts();\n },\n [reportHosts],\n );\n\n /** The caret's range, or the end of the editor if the caret is elsewhere. */\n const caret = useCallback((): Range => {\n const root = rootRef.current!;\n const selection = window.getSelection();\n\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n if (root.contains(range.commonAncestorContainer)) return range;\n }\n\n const range = document.createRange();\n range.selectNodeContents(root);\n range.collapse(false);\n const last = root.lastChild;\n if (last instanceof HTMLElement && last.tagName === \"BR\") {\n range.setStartBefore(last);\n range.collapse(true);\n }\n return range;\n }, []);\n\n /** Replace the selection with `nodes` and leave the caret after them. */\n const insert = useCallback(\n (build: (before: string, after: string) => Node[]) => {\n const root = rootRef.current!;\n const range = caret();\n range.deleteContents();\n\n const head = document.createRange();\n head.selectNodeContents(root);\n head.setEnd(range.startContainer, range.startOffset);\n const tail = document.createRange();\n tail.selectNodeContents(root);\n tail.setStart(range.endContainer, range.endOffset);\n\n const nodes = build(\n serialize(head.cloneContents(), () => true),\n serialize(tail.cloneContents(), () => true),\n );\n if (nodes.length === 0) return;\n\n const fragment = document.createDocumentFragment();\n nodes.forEach((n) => fragment.append(n));\n range.insertNode(fragment);\n placeCaretAfter(nodes[nodes.length - 1]);\n emit();\n },\n [caret, emit],\n );\n\n const insertText = useCallback(\n (text: string) => insert(() => (text ? [document.createTextNode(text)] : [])),\n [insert],\n );\n\n /*\n * Rebuild from `value` when it changed from outside — or when `known` now\n * disagrees with the pills on screen, e.g. a host set a marker and then the\n * paste it names. Never on our own edits: that would discard the caret.\n */\n useLayoutEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n for (const id of pending.current) if (known.has(id)) pending.current.delete(id);\n\n const wanted = segmentValue(value, known)\n .flatMap((s) => (s.type === \"pill\" ? [s.id] : []))\n .join(PILL_MARK);\n const onScreen = Array.from(root.querySelectorAll(`[${HOST_ATTR}]`))\n .map((el) => el.getAttribute(HOST_ATTR))\n .filter((id): id is string => id !== null && keep(id))\n .join(PILL_MARK);\n\n if (value === lastValue.current && wanted === onScreen) return;\n\n render(value);\n }, [value, known, keep, render]);\n\n useImperativeHandle(\n ref,\n () => ({\n focus(options) {\n const root = rootRef.current;\n if (!root) return;\n if (options) root.focus(options);\n else root.focus();\n const range = caret();\n const selection = window.getSelection();\n selection?.removeAllRanges();\n selection?.addRange(range);\n },\n replacePill(id, text) {\n const root = rootRef.current;\n const host = Array.from(\n root?.querySelectorAll(`[${HOST_ATTR}]`) ?? [],\n ).find((el) => el.getAttribute(HOST_ATTR) === id);\n if (!root || !host) return;\n\n const node = document.createTextNode(text);\n host.replaceWith(node);\n root.focus();\n placeCaretAfter(node);\n emit();\n },\n setValue(next, offset) {\n const root = rootRef.current;\n if (!root) return;\n\n render(next);\n root.focus();\n placeCaretAtOffset(root, offset, keep);\n emit();\n },\n }),\n [caret, emit, render, keep],\n );\n\n const handlePaste = (e: React.ClipboardEvent<HTMLDivElement>) => {\n // ALWAYS intercepted: a browser left to paste into a contenteditable inserts\n // the clipboard's HTML, styles and all.\n e.preventDefault();\n if (disabled) return;\n\n const pills = onPaste(e.clipboardData);\n\n if (pills === null) {\n const text = (e.clipboardData?.getData(\"text/plain\") ?? \"\").replace(/\\r\\n?/g, \"\\n\");\n insertText(multiline ? text : text.replace(/\\n+/g, \" \"));\n return;\n }\n\n for (const { id } of pills) pending.current.add(id);\n\n insert((before, after) => {\n const nodes: Node[] = [];\n\n for (const { id, block } of pills) {\n if (block) {\n // A text pill gets a line to itself: a newline above unless it is\n // already at the start of one, and below unless one follows.\n const precededByBreak =\n nodes.length === 0\n ? before === \"\" || before.endsWith(\"\\n\")\n : nodes[nodes.length - 1].textContent === \"\\n\";\n if (!precededByBreak) nodes.push(document.createTextNode(\"\\n\"));\n nodes.push(makeHost(id));\n nodes.push(document.createTextNode(\"\\n\"));\n } else {\n nodes.push(makeHost(id));\n }\n }\n\n // The trailing newline of a block pill is redundant if one already follows.\n const last = nodes[nodes.length - 1];\n if (last.textContent === \"\\n\" && after.startsWith(\"\\n\")) nodes.pop();\n\n return nodes;\n });\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n if (e.key !== \"Enter\" || isImeComposing(e)) return;\n\n e.preventDefault();\n const sends =\n !multiline || (submitKey === \"mod-enter\" ? e.ctrlKey || e.metaKey : !e.shiftKey);\n if (sends) {\n onSubmit();\n } else {\n insertText(\"\\n\");\n }\n };\n\n return (\n <div className=\"relative\">\n {value === \"\" && (\n <span\n aria-hidden=\"true\"\n className={cn(\n \"pointer-events-none absolute left-4 top-3 text-sm text-zinc-400\",\n placeholderClassName,\n )}\n >\n {placeholder}\n </span>\n )}\n <div\n ref={rootRef}\n id={id}\n data-react-fancy-composer-input=\"\"\n role=\"textbox\"\n aria-multiline={multiline}\n aria-labelledby={ariaLabelledBy}\n aria-invalid={ariaInvalid || undefined}\n aria-placeholder={placeholder}\n aria-disabled={disabled || undefined}\n contentEditable={!disabled}\n suppressContentEditableWarning\n onInput={emit}\n onPaste={handlePaste}\n onKeyDown={handleKeyDown}\n style={maxHeight === undefined ? style : { ...style, maxHeight }}\n className={cn(\n \"max-h-72 min-h-[4.5rem] w-full overflow-y-auto whitespace-pre-wrap break-words bg-transparent px-4 pt-3 text-sm outline-none\",\n className,\n )}\n />\n </div>\n );\n },\n);\n","import { useEffect, useRef } from \"react\";\n\nexport interface PastedFilesInputProps {\n /** The form field name the files are submitted under. */\n name: string;\n /** The files to submit, in the order the message holds them. */\n files: readonly File[];\n /** Associate with a `<form id>` elsewhere in the document, as `<input form>` does. */\n form?: string;\n}\n\n/**\n * A hidden `<input type=\"file\">` carrying the files pasted into a field, so a\n * plain `<form>` submits them with everything else.\n *\n * A pasted file is not in any form field: the clipboard hands it to the paste\n * handler and nowhere else. Held as a pill, it is attached as far as the person can\n * see, and a native submit would then post the text without it. A file input is\n * the one element a form posts files from, and its `files` can be set from a\n * `DataTransfer`, so the pills keep it in step: delete a pill and its file leaves\n * the input too.\n *\n * Hidden rather than visually hidden: `hidden` keeps it out of the tab order and\n * the accessibility tree, where the pills already represent it, and does not stop\n * a form submitting it.\n */\nexport function PastedFilesInput({ name, files, form }: PastedFilesInputProps) {\n const ref = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n const el = ref.current;\n // No DataTransfer (a server render, an old engine): nothing can be set, and\n // the host still has the files from its own state.\n if (!el || typeof DataTransfer === \"undefined\") return;\n\n const transfer = new DataTransfer();\n for (const file of files) transfer.items.add(file);\n el.files = transfer.files;\n }, [files]);\n\n return (\n <input\n ref={ref}\n type=\"file\"\n name={name}\n form={form}\n multiple\n hidden\n tabIndex={-1}\n data-react-fancy-pasted-files={name}\n />\n );\n}\n"]}
|