@particle-academy/react-fancy 6.9.0 → 6.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +1 -0
  3. package/dist/autocomplete.cjs +3 -3
  4. package/dist/autocomplete.js +2 -2
  5. package/dist/{chunk-ZUJVGHFW.js → chunk-24RWB7Q3.js} +3 -3
  6. package/dist/{chunk-ZUJVGHFW.js.map → chunk-24RWB7Q3.js.map} +1 -1
  7. package/dist/{chunk-GEQKNV7E.js → chunk-26GRLVCQ.js} +17 -13
  8. package/dist/chunk-26GRLVCQ.js.map +1 -0
  9. package/dist/{chunk-GODJVIIO.js → chunk-3W6BKQVZ.js} +4 -4
  10. package/dist/{chunk-GODJVIIO.js.map → chunk-3W6BKQVZ.js.map} +1 -1
  11. package/dist/{chunk-AZ5DWOQY.cjs → chunk-6B43ARGW.cjs} +4 -4
  12. package/dist/{chunk-AZ5DWOQY.cjs.map → chunk-6B43ARGW.cjs.map} +1 -1
  13. package/dist/{chunk-Q62RDKRA.cjs → chunk-7N7XVBH7.cjs} +6 -6
  14. package/dist/{chunk-Q62RDKRA.cjs.map → chunk-7N7XVBH7.cjs.map} +1 -1
  15. package/dist/{chunk-VGUAIFGE.js → chunk-C2VGO375.js} +3 -3
  16. package/dist/{chunk-VGUAIFGE.js.map → chunk-C2VGO375.js.map} +1 -1
  17. package/dist/{chunk-H7OTLGRD.cjs → chunk-DQWAG7YY.cjs} +4 -4
  18. package/dist/{chunk-H7OTLGRD.cjs.map → chunk-DQWAG7YY.cjs.map} +1 -1
  19. package/dist/{chunk-3KJN3GTB.cjs → chunk-EDIB6V6Y.cjs} +4 -4
  20. package/dist/{chunk-3KJN3GTB.cjs.map → chunk-EDIB6V6Y.cjs.map} +1 -1
  21. package/dist/{chunk-G5MDMQVQ.cjs → chunk-EEFU5BVM.cjs} +6 -6
  22. package/dist/{chunk-G5MDMQVQ.cjs.map → chunk-EEFU5BVM.cjs.map} +1 -1
  23. package/dist/{chunk-IYG436ZY.js → chunk-EW2N52FD.js} +3 -3
  24. package/dist/{chunk-IYG436ZY.js.map → chunk-EW2N52FD.js.map} +1 -1
  25. package/dist/{chunk-RSB2P3JK.js → chunk-FECD3WKN.js} +3 -3
  26. package/dist/{chunk-RSB2P3JK.js.map → chunk-FECD3WKN.js.map} +1 -1
  27. package/dist/{chunk-6RXEWM3V.js → chunk-FNHKZMMI.js} +3 -3
  28. package/dist/{chunk-6RXEWM3V.js.map → chunk-FNHKZMMI.js.map} +1 -1
  29. package/dist/{chunk-M5ER3Y5I.cjs → chunk-FR3V5IAJ.cjs} +4 -4
  30. package/dist/{chunk-M5ER3Y5I.cjs.map → chunk-FR3V5IAJ.cjs.map} +1 -1
  31. package/dist/{chunk-DXLPBLNC.cjs → chunk-FSLEFL4U.cjs} +4 -4
  32. package/dist/{chunk-DXLPBLNC.cjs.map → chunk-FSLEFL4U.cjs.map} +1 -1
  33. package/dist/{chunk-FQCLJZZS.js → chunk-FX37P4KR.js} +3 -3
  34. package/dist/{chunk-FQCLJZZS.js.map → chunk-FX37P4KR.js.map} +1 -1
  35. package/dist/{chunk-HANQYZW2.cjs → chunk-GB2EGMVQ.cjs} +16 -12
  36. package/dist/chunk-GB2EGMVQ.cjs.map +1 -0
  37. package/dist/{chunk-DW2PHLOA.js → chunk-H5LJFN7D.js} +3 -3
  38. package/dist/{chunk-DW2PHLOA.js.map → chunk-H5LJFN7D.js.map} +1 -1
  39. package/dist/{chunk-F3U4AVGF.js → chunk-HCIEXBEB.js} +3 -3
  40. package/dist/{chunk-F3U4AVGF.js.map → chunk-HCIEXBEB.js.map} +1 -1
  41. package/dist/{chunk-QAM6N3VG.cjs → chunk-HEGM5LMZ.cjs} +4 -4
  42. package/dist/{chunk-QAM6N3VG.cjs.map → chunk-HEGM5LMZ.cjs.map} +1 -1
  43. package/dist/chunk-HHCVBIMM.js +21 -0
  44. package/dist/chunk-HHCVBIMM.js.map +1 -0
  45. package/dist/{chunk-KAKKZDCE.js → chunk-J57JSHDC.js} +3 -3
  46. package/dist/{chunk-KAKKZDCE.js.map → chunk-J57JSHDC.js.map} +1 -1
  47. package/dist/{chunk-ZBXJDQXN.js → chunk-JJYMRV62.js} +17 -13
  48. package/dist/chunk-JJYMRV62.js.map +1 -0
  49. package/dist/{chunk-6BCXGP2T.js → chunk-JN5DHZ6I.js} +3 -3
  50. package/dist/{chunk-6BCXGP2T.js.map → chunk-JN5DHZ6I.js.map} +1 -1
  51. package/dist/{chunk-R6O6SLXK.js → chunk-LG2O26CG.js} +13 -8
  52. package/dist/chunk-LG2O26CG.js.map +1 -0
  53. package/dist/chunk-LJCQI6ZS.js +1212 -0
  54. package/dist/chunk-LJCQI6ZS.js.map +1 -0
  55. package/dist/{chunk-JV2HEOCB.cjs → chunk-MAY4NMRI.cjs} +4 -4
  56. package/dist/{chunk-JV2HEOCB.cjs.map → chunk-MAY4NMRI.cjs.map} +1 -1
  57. package/dist/{chunk-BQENLOEV.js → chunk-MD7HUHJB.js} +4 -4
  58. package/dist/{chunk-BQENLOEV.js.map → chunk-MD7HUHJB.js.map} +1 -1
  59. package/dist/{chunk-5U2DZ7AV.js → chunk-MUV7OK3W.js} +8 -6
  60. package/dist/chunk-MUV7OK3W.js.map +1 -0
  61. package/dist/{chunk-EC4ZYZNK.cjs → chunk-NFUKNVB7.cjs} +13 -8
  62. package/dist/chunk-NFUKNVB7.cjs.map +1 -0
  63. package/dist/{chunk-QUZOGRZS.js → chunk-OE4AIUAN.js} +3 -3
  64. package/dist/{chunk-QUZOGRZS.js.map → chunk-OE4AIUAN.js.map} +1 -1
  65. package/dist/chunk-OP7A4SZZ.cjs +1216 -0
  66. package/dist/chunk-OP7A4SZZ.cjs.map +1 -0
  67. package/dist/{chunk-YBBBX5H2.cjs → chunk-OUPHLIXV.cjs} +11 -11
  68. package/dist/{chunk-YBBBX5H2.cjs.map → chunk-OUPHLIXV.cjs.map} +1 -1
  69. package/dist/{chunk-XGGAAG74.cjs → chunk-QQKWI7QP.cjs} +7 -3
  70. package/dist/chunk-QQKWI7QP.cjs.map +1 -0
  71. package/dist/{chunk-XT4WBBCD.cjs → chunk-R4SANV3G.cjs} +11 -11
  72. package/dist/{chunk-XT4WBBCD.cjs.map → chunk-R4SANV3G.cjs.map} +1 -1
  73. package/dist/chunk-RE3PMG47.cjs +23 -0
  74. package/dist/chunk-RE3PMG47.cjs.map +1 -0
  75. package/dist/{chunk-GJWNZMJT.js → chunk-RUEDMYBF.js} +7 -3
  76. package/dist/chunk-RUEDMYBF.js.map +1 -0
  77. package/dist/{chunk-UORN3Z7R.cjs → chunk-TBLKVTJC.cjs} +6 -6
  78. package/dist/{chunk-UORN3Z7R.cjs.map → chunk-TBLKVTJC.cjs.map} +1 -1
  79. package/dist/{chunk-7NRG77U5.cjs → chunk-TXQT6S4D.cjs} +16 -12
  80. package/dist/chunk-TXQT6S4D.cjs.map +1 -0
  81. package/dist/{chunk-TXTRTTG7.cjs → chunk-UOG3O3KP.cjs} +8 -6
  82. package/dist/chunk-UOG3O3KP.cjs.map +1 -0
  83. package/dist/{chunk-L5NDZEL6.cjs → chunk-ZFXCZ2QO.cjs} +9 -9
  84. package/dist/{chunk-L5NDZEL6.cjs.map → chunk-ZFXCZ2QO.cjs.map} +1 -1
  85. package/dist/command.cjs +5 -4
  86. package/dist/command.js +3 -2
  87. package/dist/composer.cjs +6 -6
  88. package/dist/composer.js +4 -4
  89. package/dist/drawer.cjs +5 -4
  90. package/dist/drawer.d.cts +8 -1
  91. package/dist/drawer.d.ts +8 -1
  92. package/dist/drawer.js +3 -2
  93. package/dist/dropdown.cjs +4 -4
  94. package/dist/dropdown.js +2 -2
  95. package/dist/editor.cjs +2 -2
  96. package/dist/editor.js +2 -2
  97. package/dist/index.cjs +111 -97
  98. package/dist/index.cjs.map +1 -1
  99. package/dist/index.d.cts +13 -1
  100. package/dist/index.d.ts +13 -1
  101. package/dist/index.js +27 -25
  102. package/dist/index.js.map +1 -1
  103. package/dist/input.cjs +5 -5
  104. package/dist/input.js +4 -4
  105. package/dist/inputs.cjs +19 -19
  106. package/dist/inputs.js +8 -8
  107. package/dist/json-editor.cjs +17 -17
  108. package/dist/json-editor.js +6 -6
  109. package/dist/mobile-menu.cjs +2 -2
  110. package/dist/mobile-menu.js +2 -2
  111. package/dist/modal.cjs +5 -4
  112. package/dist/modal.d.cts +11 -1
  113. package/dist/modal.d.ts +11 -1
  114. package/dist/modal.js +3 -2
  115. package/dist/number-field.cjs +6 -6
  116. package/dist/number-field.js +5 -5
  117. package/dist/paste-pills.cjs +16 -16
  118. package/dist/paste-pills.js +3 -3
  119. package/dist/phone-input.cjs +39 -0
  120. package/dist/phone-input.cjs.map +1 -0
  121. package/dist/phone-input.d.cts +139 -0
  122. package/dist/phone-input.d.ts +139 -0
  123. package/dist/phone-input.js +22 -0
  124. package/dist/phone-input.js.map +1 -0
  125. package/dist/popover.cjs +4 -4
  126. package/dist/popover.js +2 -2
  127. package/dist/prompt-input.cjs +8 -8
  128. package/dist/prompt-input.js +5 -5
  129. package/dist/reason-tag.cjs +4 -4
  130. package/dist/reason-tag.js +3 -3
  131. package/dist/select.cjs +3 -3
  132. package/dist/select.js +2 -2
  133. package/dist/sidebar.cjs +6 -6
  134. package/dist/sidebar.js +4 -4
  135. package/dist/tooltip.cjs +3 -3
  136. package/dist/tooltip.js +2 -2
  137. package/docs/PhoneInput.md +104 -0
  138. package/package.json +11 -1
  139. package/dist/chunk-5U2DZ7AV.js.map +0 -1
  140. package/dist/chunk-7NRG77U5.cjs.map +0 -1
  141. package/dist/chunk-EC4ZYZNK.cjs.map +0 -1
  142. package/dist/chunk-GEQKNV7E.js.map +0 -1
  143. package/dist/chunk-GJWNZMJT.js.map +0 -1
  144. package/dist/chunk-HANQYZW2.cjs.map +0 -1
  145. package/dist/chunk-R6O6SLXK.js.map +0 -1
  146. package/dist/chunk-TXTRTTG7.cjs.map +0 -1
  147. package/dist/chunk-XGGAAG74.cjs.map +0 -1
  148. package/dist/chunk-ZBXJDQXN.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkJV2HEOCB_cjs = require('./chunk-JV2HEOCB.cjs');
3
+ var chunkMAY4NMRI_cjs = require('./chunk-MAY4NMRI.cjs');
4
4
  var chunk6V44RRSB_cjs = require('./chunk-6V44RRSB.cjs');
5
5
  var chunkSNHU2AI4_cjs = require('./chunk-SNHU2AI4.cjs');
6
6
  var chunkZU5Q77OT_cjs = require('./chunk-ZU5Q77OT.cjs');
@@ -150,9 +150,9 @@ function InlinePill({
150
150
  children: textLabel ?? `Pasted text \xB7 ${textSize}`
151
151
  }
152
152
  );
153
- return /* @__PURE__ */ jsxRuntime.jsxs(chunkJV2HEOCB_cjs.Popover, { hover: true, open, onOpenChange: setOpen, placement: "top", children: [
154
- /* @__PURE__ */ jsxRuntime.jsx(chunkJV2HEOCB_cjs.Popover.Trigger, { children: pill }),
155
- /* @__PURE__ */ jsxRuntime.jsx(chunkJV2HEOCB_cjs.Popover.Content, { className: chunkZU5Q77OT_cjs.cn(PREVIEW_BASE, classNames?.preview), children: content })
153
+ return /* @__PURE__ */ jsxRuntime.jsxs(chunkMAY4NMRI_cjs.Popover, { hover: true, open, onOpenChange: setOpen, placement: "top", children: [
154
+ /* @__PURE__ */ jsxRuntime.jsx(chunkMAY4NMRI_cjs.Popover.Trigger, { children: pill }),
155
+ /* @__PURE__ */ jsxRuntime.jsx(chunkMAY4NMRI_cjs.Popover.Content, { className: chunkZU5Q77OT_cjs.cn(PREVIEW_BASE, classNames?.preview), children: content })
156
156
  ] });
157
157
  }
158
158
 
@@ -690,5 +690,5 @@ exports.segmentValue = segmentValue;
690
690
  exports.useInlinePaste = useInlinePaste;
691
691
  exports.usePastePills = usePastePills;
692
692
  exports.withSeparators = withSeparators;
693
- //# sourceMappingURL=chunk-UORN3Z7R.cjs.map
694
- //# sourceMappingURL=chunk-UORN3Z7R.cjs.map
693
+ //# sourceMappingURL=chunk-TBLKVTJC.cjs.map
694
+ //# sourceMappingURL=chunk-TBLKVTJC.cjs.map
@@ -1 +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":["useControllableState","useRef","useCallback","useState","useEffect","jsx","cn","jsxs","Popover","useMemo","createPortal","forwardRef","InlinePasteEditor","id","range","useLayoutEffect","useImperativeHandle","isImeComposing"],"mappings":";;;;;;;;;;AAkIO,SAAS,aAAA,CAAc;AAAA,EAC5B,SAAA;AAAA,EACA,UAAA,EAAY,oBAAA;AAAA,EACZ;AACF,CAAA,GAA0B,EAAC,EAAwB;AACjD,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAIA,sCAAA;AAAA,IAClC,oBAAA;AAAA,IACA,EAAC;AAAA,IACD;AAAA,GACF;AAUA,EAAA,MAAM,MAAA,GAASC,aAAO,CAAC,CAAA;AAEvB,EAAA,MAAM,IAAA,GAAOC,iBAAA;AAAA,IACX,CAAC,IAAA,KAAyB;AAOxB,MAAA,IAAI,EAAA;AACJ,MAAA,GAAG;AACD,QAAA,MAAA,CAAO,OAAA,IAAW,CAAA;AAClB,QAAA,EAAA,GAAK,CAAA,MAAA,EAAS,OAAO,OAAO,CAAA,CAAA;AAAA,MAC9B,SAAS,UAAA,CAAW,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,EAAE,CAAA;AAE3C,MAAA,aAAA,CAAc,CAAC,YAAY,CAAC,GAAG,SAAS,EAAE,EAAA,EAAI,IAAA,EAAM,CAAC,CAAA;AAErD,MAAA,OAAO,EAAA;AAAA,IACT,CAAA;AAAA,IACA,CAAC,YAAY,aAAa;AAAA,GAC5B;AAEA,EAAA,MAAM,WAAA,GAAcA,iBAAA;AAAA,IAClB,CAAC,KAAA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MAAM,QAAA,GAAW,IAAI,YAAA,EAAa;AAClC,IAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,EAAO,QAAA,CAAS,KAAA,CAAM,IAAI,IAAI,CAAA;AACjD,IAAA,EAAA,CAAG,QAAQ,QAAA,CAAS,KAAA;AAAA,EACtB,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AAEV,EAAA,uBACEC,cAAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,IAAA,EAAK,MAAA;AAAA,MACL,IAAA;AAAA,MACA,IAAA;AAAA,MACA,QAAA,EAAQ,IAAA;AAAA,MACR,MAAA,EAAM,IAAA;AAAA,MACN,QAAA,EAAU,EAAA;AAAA,MACV,+BAAA,EAA+B;AAAA;AAAA,GACjC;AAEJ","file":"chunk-UORN3Z7R.cjs","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 start-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"]}
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":["useControllableState","useRef","useCallback","useState","useEffect","jsx","cn","jsxs","Popover","useMemo","createPortal","forwardRef","InlinePasteEditor","id","range","useLayoutEffect","useImperativeHandle","isImeComposing"],"mappings":";;;;;;;;;;AAkIO,SAAS,aAAA,CAAc;AAAA,EAC5B,SAAA;AAAA,EACA,UAAA,EAAY,oBAAA;AAAA,EACZ;AACF,CAAA,GAA0B,EAAC,EAAwB;AACjD,EAAA,MAAM,CAAC,UAAA,E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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 start-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"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkTXTRTTG7_cjs = require('./chunk-TXTRTTG7.cjs');
3
+ var chunkRE3PMG47_cjs = require('./chunk-RE3PMG47.cjs');
4
4
  var chunkFQZE5N2N_cjs = require('./chunk-FQZE5N2N.cjs');
5
5
  var chunkTI7D4QDM_cjs = require('./chunk-TI7D4QDM.cjs');
6
6
  var chunkOUYC6EIL_cjs = require('./chunk-OUYC6EIL.cjs');
@@ -17,7 +17,7 @@ function useDrawer() {
17
17
  }
18
18
  return ctx;
19
19
  }
20
- function DrawerHeader({ children, closable = true, className }) {
20
+ function DrawerHeader({ children, closable = true, className, closeLabel = "Close" }) {
21
21
  const { close } = useDrawer();
22
22
  return /* @__PURE__ */ jsxRuntime.jsxs(
23
23
  "div",
@@ -34,8 +34,9 @@ function DrawerHeader({ children, closable = true, className }) {
34
34
  {
35
35
  type: "button",
36
36
  onClick: close,
37
- className: "rounded-lg p-1 text-zinc-400 transition-colors hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] hover:text-zinc-600 dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))] dark:hover:text-zinc-300",
38
- "aria-label": "Close",
37
+ "data-react-fancy-drawer-close": "",
38
+ className: "relative rounded-lg p-1 text-zinc-400 before:absolute before:-inset-[9px] before:content-[''] transition-colors hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] hover:text-zinc-600 dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))] dark:hover:text-zinc-300",
39
+ "aria-label": closeLabel,
39
40
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 18 })
40
41
  }
41
42
  ) : null
@@ -140,12 +141,10 @@ function DrawerRoot({
140
141
  className,
141
142
  ...rest
142
143
  }) {
143
- const panelRef = react.useRef(null);
144
144
  const horizontal = side !== "top" && side !== "bottom";
145
145
  const isViewport = attach === "viewport";
146
146
  const close = react.useCallback(() => onClose(), [onClose]);
147
147
  chunkOUYC6EIL_cjs.useEscapeKey(close, open && dismissOnEscape);
148
- chunkTXTRTTG7_cjs.useFocusTrap(panelRef, open && isViewport);
149
148
  react.useEffect(() => {
150
149
  if (!open || !isViewport) return;
151
150
  const original = document.body.style.overflow;
@@ -159,6 +158,14 @@ function DrawerRoot({
159
158
  enterClass: ENTER[side],
160
159
  exitClass: EXIT[side]
161
160
  });
161
+ const attachTrap = chunkRE3PMG47_cjs.useDialogFocusTrap(open, isViewport);
162
+ const attachPanel = react.useCallback(
163
+ (node) => {
164
+ animRef.current = node;
165
+ attachTrap(node);
166
+ },
167
+ [animRef, attachTrap]
168
+ );
162
169
  const ctx = react.useMemo(() => ({ open, close, side }), [open, close, side]);
163
170
  if (!mounted) return null;
164
171
  const frame = /* @__PURE__ */ jsxRuntime.jsxs(
@@ -183,10 +190,7 @@ function DrawerRoot({
183
190
  /* @__PURE__ */ jsxRuntime.jsx(
184
191
  "div",
185
192
  {
186
- ref: (node) => {
187
- panelRef.current = node;
188
- animRef.current = node;
189
- },
193
+ ref: attachPanel,
190
194
  "data-react-fancy-drawer": "",
191
195
  "data-side": side,
192
196
  role: "dialog",
@@ -222,5 +226,5 @@ var Drawer = Object.assign(DrawerRoot, {
222
226
 
223
227
  exports.Drawer = Drawer;
224
228
  exports.useDrawer = useDrawer;
225
- //# sourceMappingURL=chunk-7NRG77U5.cjs.map
226
- //# sourceMappingURL=chunk-7NRG77U5.cjs.map
229
+ //# sourceMappingURL=chunk-TXQT6S4D.cjs.map
230
+ //# sourceMappingURL=chunk-TXQT6S4D.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Drawer/Drawer.context.ts","../src/components/Drawer/DrawerHeader.tsx","../src/components/Drawer/DrawerBody.tsx","../src/components/Drawer/DrawerFooter.tsx","../src/components/Drawer/DrawerContainer.tsx","../src/components/Drawer/Drawer.tsx"],"names":["createContext","useContext","jsxs","cn","jsx","X","useCallback","useEscapeKey","useEffect","useAnimation","useDialogFocusTrap","useMemo","Portal"],"mappings":";;;;;;;;;;;AAGO,IAAM,aAAA,GAAgBA,oBAAyC,IAAI,CAAA;AAEnE,SAAS,SAAA,GAAgC;AAC9C,EAAA,MAAM,GAAA,GAAMC,iBAAW,aAAa,CAAA;AACpC,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,MAAM,yDAAyD,CAAA;AAAA,EAC3E;AACA,EAAA,OAAO,GAAA;AACT;ACDO,SAAS,YAAA,CAAa,EAAE,QAAA,EAAU,QAAA,GAAW,MAAM,SAAA,EAAW,UAAA,GAAa,SAAQ,EAAsB;AAC9G,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,SAAA,EAAU;AAE5B,EAAA,uBACEC,eAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,gCAAA,EAA+B,EAAA;AAAA,MAC/B,SAAA,EAAWC,oBAAA;AAAA,QACT,2LAAA;AAAA,QACA;AAAA,OACF;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAAC,cAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,2IAAA,EAA6I,QAAA,EAAS,CAAA;AAAA,QACpK,QAAA,mBACCA,cAAA;AAAA,UAAC,QAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAK,QAAA;AAAA,YACL,OAAA,EAAS,KAAA;AAAA,YACT,+BAAA,EAA8B,EAAA;AAAA,YAC9B,SAAA,EAAU,4SAAA;AAAA,YACV,YAAA,EAAY,UAAA;AAAA,YAEZ,QAAA,kBAAAA,cAAA,CAACC,aAAA,EAAA,EAAE,IAAA,EAAM,EAAA,E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CAAA;AAAA,cAC5C,SAAA;AAAA,cACA;AAAA,aACF;AAAA,YAEC;AAAA;AAAA;AACH;AAAA;AAAA,GACF;AAGF,EAAA,uBACEC,cAAAA,CAAC,aAAA,CAAc,QAAA,EAAd,EAAuB,KAAA,EAAO,GAAA,EAC5B,QAAA,EAAA,UAAA,mBAAaA,cAAAA,CAACQ,wBAAA,EAAA,EAAQ,QAAA,EAAA,KAAA,EAAM,IAAY,KAAA,EAC3C,CAAA;AAEJ;AAEO,IAAM,MAAA,GAAS,MAAA,CAAO,MAAA,CAAO,UAAA,EAAY;AAAA,EAC9C,MAAA,EAAQ,YAAA;AAAA,EACR,IAAA,EAAM,UAAA;AAAA,EACN,MAAA,EAAQ,YAAA;AAAA,EACR,SAAA,EAAW;AACb,CAAC","file":"chunk-TXQT6S4D.cjs","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { DrawerContextValue } from \"./Drawer.types\";\n\nexport const DrawerContext = createContext<DrawerContextValue | null>(null);\n\nexport function useDrawer(): DrawerContextValue {\n const ctx = useContext(DrawerContext);\n if (!ctx) {\n throw new Error(\"Drawer compound components must be used within <Drawer>\");\n }\n return ctx;\n}\n","import { X } from \"lucide-react\";\nimport { cn } from \"../../utils/cn\";\nimport { useDrawer } from \"./Drawer.context\";\nimport type { DrawerHeaderProps } from \"./Drawer.types\";\n\n/**\n * The close button draws at 26px (18px icon + `p-1`) and HITS at 44px (WCAG\n * 2.5.5, AAA): a `::before` overhangs it by 9px, inside the header's `py-3`. The\n * look is unchanged; see ModalHeader for why this over a size option.\n */\nexport function DrawerHeader({ children, closable = true, className, closeLabel = \"Close\" }: DrawerHeaderProps) {\n const { close } = useDrawer();\n\n return (\n <div\n data-react-fancy-drawer-header=\"\"\n className={cn(\n \"flex shrink-0 items-center justify-between border-b border-[color:var(--fancy-border,var(--color-zinc-200))] px-4 py-3 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n className,\n )}\n >\n <div className=\"text-sm font-semibold text-[color:var(--fancy-text,var(--color-zinc-900))] dark:text-[color:var(--fancy-text-dark,var(--color-zinc-100))]\">{children}</div>\n {closable ? (\n <button\n type=\"button\"\n onClick={close}\n data-react-fancy-drawer-close=\"\"\n className=\"relative rounded-lg p-1 text-zinc-400 before:absolute before:-inset-[9px] before:content-[''] transition-colors hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] hover:text-zinc-600 dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))] dark:hover:text-zinc-300\"\n aria-label={closeLabel}\n >\n <X size={18} />\n </button>\n ) : null}\n </div>\n );\n}\n\nDrawerHeader.displayName = \"DrawerHeader\";\n","import { cn } from \"../../utils/cn\";\nimport type { DrawerBodyProps } from \"./Drawer.types\";\n\nexport function DrawerBody({ children, className }: DrawerBodyProps) {\n return (\n <div\n data-react-fancy-drawer-body=\"\"\n className={cn(\"min-h-0 flex-1 overflow-auto px-4 py-3 text-[color:var(--fancy-text-soft,var(--color-zinc-700))] dark:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))]\", className)}\n >\n {children}\n </div>\n );\n}\n\nDrawerBody.displayName = \"DrawerBody\";\n","import { cn } from \"../../utils/cn\";\nimport type { DrawerFooterProps } from \"./Drawer.types\";\n\nexport function DrawerFooter({ children, className }: DrawerFooterProps) {\n return (\n <div\n data-react-fancy-drawer-footer=\"\"\n className={cn(\n \"flex shrink-0 items-center justify-end gap-2 border-t border-[color:var(--fancy-border,var(--color-zinc-200))] px-4 py-3 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nDrawerFooter.displayName = \"DrawerFooter\";\n","import { cn } from \"../../utils/cn\";\nimport type { DrawerContainerProps } from \"./Drawer.types\";\n\n/**\n * The anchor for `<Drawer attach=\"container\">`.\n *\n * A container-attached drawer positions itself `absolute`, which resolves\n * against the nearest *positioned* ancestor — so without `relative` somewhere\n * above it, the drawer silently escapes to the viewport and looks like it\n * ignored `attach` entirely. This wrapper supplies `relative` + `overflow-hidden`\n * so the panel slides within the box rather than out of it.\n *\n * <Drawer.Container className=\"h-80 rounded-xl border\">\n * <YourContent />\n * <Drawer attach=\"container\" side=\"bottom\" open={open} onClose={close}>\n * <Drawer.Body>Filters</Drawer.Body>\n * </Drawer>\n * </Drawer.Container>\n *\n * Any element works as long as it is positioned — this is the shortcut, not a\n * requirement. Wrapping a Card, a layout pane, or a prompt-input shell in\n * `relative overflow-hidden` does the same job.\n */\nexport function DrawerContainer({ children, className, ...rest }: DrawerContainerProps) {\n return (\n <div\n data-react-fancy-drawer-container=\"\"\n {...rest}\n className={cn(\"relative overflow-hidden\", className)}\n >\n {children}\n </div>\n );\n}\n\nDrawerContainer.displayName = \"DrawerContainer\";\n","import { useCallback, useEffect, useMemo } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Portal } from \"../Portal\";\nimport { DrawerContext } from \"./Drawer.context\";\nimport { DrawerHeader } from \"./DrawerHeader\";\nimport { DrawerBody } from \"./DrawerBody\";\nimport { DrawerFooter } from \"./DrawerFooter\";\nimport { DrawerContainer } from \"./DrawerContainer\";\nimport { useDialogFocusTrap } from \"../../hooks/use-dialog-focus-trap\";\nimport { useEscapeKey } from \"../../hooks/use-escape-key\";\nimport { useAnimation } from \"../../hooks/use-animation\";\nimport type { DrawerProps, DrawerSide } from \"./Drawer.types\";\n\n/**\n * `size` addresses the drawer's own axis: width on the horizontal edges,\n * height on the vertical ones. Keeping one scale across both means `size=\"lg\"`\n * does not have to be re-learned when a drawer moves from the side to the\n * bottom.\n */\nconst WIDTH = {\n sm: \"w-64\",\n md: \"w-80\",\n lg: \"w-96\",\n xl: \"w-[32rem]\",\n full: \"w-full\",\n} as const;\n\nconst HEIGHT = {\n sm: \"h-32\",\n md: \"h-64\",\n lg: \"h-96\",\n xl: \"h-[32rem]\",\n full: \"h-full\",\n} as const;\n\nconst ANCHOR: Record<DrawerSide, string> = {\n start: \"inset-y-0 start-0\",\n end: \"inset-y-0 end-0\",\n left: \"inset-y-0 left-0\",\n right: \"inset-y-0 right-0\",\n top: \"inset-x-0 top-0\",\n bottom: \"inset-x-0 bottom-0\",\n};\n\nconst ENTER: Record<DrawerSide, string> = {\n start: \"fancy-slide-in-start\",\n end: \"fancy-slide-in-end\",\n left: \"fancy-slide-in-left\",\n right: \"fancy-slide-in-right\",\n top: \"fancy-slide-in-top\",\n bottom: \"fancy-slide-in-bottom\",\n};\n\nconst EXIT: Record<DrawerSide, string> = {\n start: \"fancy-slide-out-start\",\n end: \"fancy-slide-out-end\",\n left: \"fancy-slide-out-left\",\n right: \"fancy-slide-out-right\",\n top: \"fancy-slide-out-top\",\n bottom: \"fancy-slide-out-bottom\",\n};\n\n/** The panel's edge shadow reads as depth away from the anchored edge. */\nconst EDGE: Record<DrawerSide, string> = {\n start: \"border-e\",\n end: \"border-s\",\n left: \"border-r\",\n right: \"border-l\",\n top: \"border-b\",\n bottom: \"border-t\",\n};\n\nfunction DrawerRoot({\n children,\n open,\n onClose,\n side = \"end\",\n size = \"md\",\n attach = \"viewport\",\n backdrop = true,\n dismissOnBackdrop = true,\n dismissOnEscape = true,\n className,\n ...rest\n}: DrawerProps) {\n const horizontal = side !== \"top\" && side !== \"bottom\";\n const isViewport = attach === \"viewport\";\n\n const close = useCallback(() => onClose(), [onClose]);\n useEscapeKey(close, open && dismissOnEscape);\n\n useEffect(() => {\n if (!open || !isViewport) return;\n const original = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n return () => {\n document.body.style.overflow = original;\n };\n }, [open, isViewport]);\n\n const { mounted, className: animClass, ref: animRef } = useAnimation({\n open,\n enterClass: ENTER[side],\n exitClass: EXIT[side],\n });\n\n // A container-attached drawer is a panel, not a dialog — trapping focus in it\n // would strand keyboard users inside a Card. Only the viewport form is modal.\n // The panel mounts renders after `open` flips; see useDialogFocusTrap.\n const attachTrap = useDialogFocusTrap(open, isViewport);\n const attachPanel = useCallback(\n (node: HTMLDivElement | null) => {\n (animRef as React.MutableRefObject<HTMLElement | null>).current = node;\n attachTrap(node);\n },\n [animRef, attachTrap],\n );\n\n const ctx = useMemo(() => ({ open, close, side }), [open, close, side]);\n\n if (!mounted) return null;\n\n const frame = (\n <div\n data-react-fancy-drawer-frame=\"\"\n className={cn(isViewport ? \"fixed inset-0 z-50\" : \"absolute inset-0 z-20\", !backdrop && \"pointer-events-none\")}\n >\n {backdrop ? (\n <div\n data-react-fancy-drawer-backdrop=\"\"\n className={cn(\n \"absolute inset-0 bg-black/40 transition-opacity\",\n isViewport && \"backdrop-blur-sm\",\n open ? \"opacity-100\" : \"opacity-0\",\n )}\n onClick={dismissOnBackdrop ? close : undefined}\n aria-hidden=\"true\"\n />\n ) : null}\n\n <div\n ref={attachPanel}\n data-react-fancy-drawer=\"\"\n data-side={side}\n role=\"dialog\"\n aria-modal={isViewport || undefined}\n {...rest}\n className={cn(\n \"pointer-events-auto absolute flex flex-col border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] shadow-xl dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n ANCHOR[side],\n EDGE[side],\n horizontal ? WIDTH[size] : HEIGHT[size],\n // Cross-axis fills the anchor; the main axis is capped so a viewport\n // drawer can never grow past the screen on a small device.\n horizontal ? \"h-full\" : \"w-full\",\n isViewport && (horizontal ? \"max-w-[90vw]\" : \"max-h-[90vh]\"),\n !isViewport && (horizontal ? \"max-w-full\" : \"max-h-full\"),\n animClass,\n className,\n )}\n >\n {children}\n </div>\n </div>\n );\n\n return (\n <DrawerContext.Provider value={ctx}>\n {isViewport ? <Portal>{frame}</Portal> : frame}\n </DrawerContext.Provider>\n );\n}\n\nexport const Drawer = Object.assign(DrawerRoot, {\n Header: DrawerHeader,\n Body: DrawerBody,\n Footer: DrawerFooter,\n Container: DrawerContainer,\n});\n"]}
@@ -11,13 +11,15 @@ var FOCUSABLE_SELECTOR = [
11
11
  "select:not([disabled])",
12
12
  "[tabindex]:not([tabindex='-1'])"
13
13
  ].join(", ");
14
- function useFocusTrap(ref, enabled = true) {
14
+ function useFocusTrap(ref, enabled = true, restoreTo) {
15
15
  react.useEffect(() => {
16
16
  if (!enabled) return;
17
17
  const el = ref.current;
18
18
  if (!el) return;
19
19
  const previouslyFocused = document.activeElement;
20
- const focusables = () => Array.from(el.querySelectorAll(FOCUSABLE_SELECTOR));
20
+ const focusables = () => Array.from(el.querySelectorAll(FOCUSABLE_SELECTOR)).filter(
21
+ (node) => node.getAttribute("tabindex") !== "-1"
22
+ );
21
23
  const first = focusables()[0];
22
24
  first?.focus();
23
25
  const listener = (event) => {
@@ -41,11 +43,11 @@ function useFocusTrap(ref, enabled = true) {
41
43
  el.addEventListener("keydown", listener);
42
44
  return () => {
43
45
  el.removeEventListener("keydown", listener);
44
- previouslyFocused?.focus();
46
+ (restoreTo?.current ?? previouslyFocused)?.focus();
45
47
  };
46
- }, [ref, enabled]);
48
+ }, [ref, enabled, restoreTo]);
47
49
  }
48
50
 
49
51
  exports.useFocusTrap = useFocusTrap;
50
- //# sourceMappingURL=chunk-TXTRTTG7.cjs.map
51
- //# sourceMappingURL=chunk-TXTRTTG7.cjs.map
52
+ //# sourceMappingURL=chunk-UOG3O3KP.cjs.map
53
+ //# sourceMappingURL=chunk-UOG3O3KP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-focus-trap.ts"],"names":["useEffect"],"mappings":";;;;;AAEA,IAAM,kBAAA,GAAqB;AAAA,EACzB,SAAA;AAAA,EACA,wBAAA;AAAA,EACA,uBAAA;AAAA,EACA,0BAAA;AAAA,EACA,wBAAA;AAAA,EACA;AACF,CAAA,CAAE,KAAK,IAAI,CAAA;AAaJ,SAAS,YAAA,CACd,GAAA,EACA,OAAA,GAAmB,IAAA,EACnB,SAAA,EACM;AACN,EAAAA,eAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,OAAA,EAAS;AAEd,IAAA,MAAM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AA,EAAW,OAAA,IAAW,iBAAA,GAAoB,KAAA,EAAM;AAAA,IACnD,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,GAAA,EAAK,OAAA,EAAS,SAAS,CAAC,CAAA;AAC9B","file":"chunk-UOG3O3KP.cjs","sourcesContent":["import { useEffect, type RefObject } from \"react\";\n\nconst FOCUSABLE_SELECTOR = [\n \"a[href]\",\n \"button:not([disabled])\",\n \"input:not([disabled])\",\n \"textarea:not([disabled])\",\n \"select:not([disabled])\",\n \"[tabindex]:not([tabindex='-1'])\",\n].join(\", \");\n\n/**\n * Moves focus into `ref`, keeps Tab inside it, and restores focus on disable.\n *\n * `ref.current` must already be set in the commit where `enabled` turns true:\n * the effect does not run again until `enabled` changes. A panel that mounts\n * later (an animation, a Portal) should key `enabled` on the node — see\n * `useDialogFocusTrap`.\n *\n * `restoreTo`, when it holds an element, is where focus returns on disable\n * instead of whatever was focused when the trap engaged.\n */\nexport function useFocusTrap(\n ref: RefObject<HTMLElement | null>,\n enabled: boolean = true,\n restoreTo?: RefObject<HTMLElement | null>,\n): void {\n useEffect(() => {\n if (!enabled) return;\n\n const el = ref.current;\n if (!el) return;\n\n const previouslyFocused = document.activeElement as HTMLElement | null;\n\n // Tab stops only. `button` / `input` match an element with `tabindex=\"-1\"`\n // too (Command's options), and treating one as the last stop meant Tab never\n // wrapped: focus was never ON it, so the browser walked out of the dialog.\n const focusables = () =>\n Array.from(el.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)).filter(\n (node) => node.getAttribute(\"tabindex\") !== \"-1\",\n );\n\n // Focus first focusable element\n const first = focusables()[0];\n first?.focus();\n\n const listener = (event: KeyboardEvent) => {\n if (event.key !== \"Tab\") return;\n\n const items = focusables();\n if (items.length === 0) return;\n\n const firstItem = items[0];\n const lastItem = items[items.length - 1];\n\n if (event.shiftKey) {\n if (document.activeElement === firstItem) {\n event.preventDefault();\n lastItem.focus();\n }\n } else {\n if (document.activeElement === lastItem) {\n event.preventDefault();\n firstItem.focus();\n }\n }\n };\n\n el.addEventListener(\"keydown\", listener);\n\n return () => {\n el.removeEventListener(\"keydown\", listener);\n (restoreTo?.current ?? previouslyFocused)?.focus();\n };\n }, [ref, enabled, restoreTo]);\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkJKD6CFIP_cjs = require('./chunk-JKD6CFIP.cjs');
4
- var chunkUORN3Z7R_cjs = require('./chunk-UORN3Z7R.cjs');
4
+ var chunkTBLKVTJC_cjs = require('./chunk-TBLKVTJC.cjs');
5
5
  var chunk2C64OVOZ_cjs = require('./chunk-2C64OVOZ.cjs');
6
6
  var chunk6V44RRSB_cjs = require('./chunk-6V44RRSB.cjs');
7
7
  var chunkSNHU2AI4_cjs = require('./chunk-SNHU2AI4.cjs');
@@ -44,7 +44,7 @@ var Composer = react.forwardRef(
44
44
  );
45
45
  const textareaRef = react.useRef(null);
46
46
  const editorRef = react.useRef(null);
47
- const paste = chunkUORN3Z7R_cjs.useInlinePaste({
47
+ const paste = chunkTBLKVTJC_cjs.useInlinePaste({
48
48
  pasteThreshold,
49
49
  pasteImages,
50
50
  previewChars,
@@ -155,7 +155,7 @@ ${text}` : text);
155
155
  "data-react-fancy-composer-paste-pill": paste2.id,
156
156
  onClick: () => insertPaste(paste2),
157
157
  disabled,
158
- "aria-label": `Insert this pasted text, ${chunkUORN3Z7R_cjs.withSeparators(paste2.text.length)} characters`,
158
+ "aria-label": `Insert this pasted text, ${chunkTBLKVTJC_cjs.withSeparators(paste2.text.length)} characters`,
159
159
  "aria-describedby": `${paste2.id}-preview`,
160
160
  className: chunkZU5Q77OT_cjs.cn(
161
161
  "inline-flex items-center gap-1.5 rounded-full border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-zinc-50 py-1 ps-2.5 pe-7 text-xs text-zinc-700 transition-colors hover:bg-zinc-100 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-zinc-800 dark:text-zinc-200 dark:hover:bg-zinc-700",
@@ -164,7 +164,7 @@ ${text}` : text);
164
164
  ),
165
165
  children: /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
166
166
  "Pasted text \xB7 ",
167
- chunkUORN3Z7R_cjs.withSeparators(paste2.text.length),
167
+ chunkTBLKVTJC_cjs.withSeparators(paste2.text.length),
168
168
  " characters"
169
169
  ] })
170
170
  }
@@ -194,7 +194,7 @@ ${text}` : text);
194
194
  "pointer-events-none absolute bottom-full start-0 z-10 mb-1 hidden max-w-xs whitespace-pre-wrap break-all rounded-md bg-zinc-900 px-2 py-1 text-xs text-white group-hover:block dark:bg-zinc-100 dark:text-zinc-900",
195
195
  classNames?.preview
196
196
  ),
197
- children: renderPastePreview?.({ kind: "text", paste: paste2 }) ?? chunkUORN3Z7R_cjs.endsOf(paste2.text, previewChars)
197
+ children: renderPastePreview?.({ kind: "text", paste: paste2 }) ?? chunkTBLKVTJC_cjs.endsOf(paste2.text, previewChars)
198
198
  }
199
199
  )
200
200
  ] }, paste2.id)
@@ -203,7 +203,7 @@ ${text}` : text);
203
203
  ),
204
204
  inline ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
205
205
  /* @__PURE__ */ jsxRuntime.jsx(
206
- chunkUORN3Z7R_cjs.InlinePasteEditor,
206
+ chunkTBLKVTJC_cjs.InlinePasteEditor,
207
207
  {
208
208
  ref: editorRef,
209
209
  value,
@@ -220,7 +220,7 @@ ${text}` : text);
220
220
  ),
221
221
  paste.portals,
222
222
  name && /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name, value: composeOutgoing() }),
223
- pasteImages && pasteFilesName && /* @__PURE__ */ jsxRuntime.jsx(chunkUORN3Z7R_cjs.PastedFilesInput, { name: pasteFilesName, files: pastedFiles })
223
+ pasteImages && pasteFilesName && /* @__PURE__ */ jsxRuntime.jsx(chunkTBLKVTJC_cjs.PastedFilesInput, { name: pasteFilesName, files: pastedFiles })
224
224
  ] }) : /* @__PURE__ */ jsxRuntime.jsx(
225
225
  "textarea",
226
226
  {
@@ -281,5 +281,5 @@ function sameImages(a, b) {
281
281
  }
282
282
 
283
283
  exports.Composer = Composer;
284
- //# sourceMappingURL=chunk-L5NDZEL6.cjs.map
285
- //# sourceMappingURL=chunk-L5NDZEL6.cjs.map
284
+ //# sourceMappingURL=chunk-ZFXCZ2QO.cjs.map
285
+ //# sourceMappingURL=chunk-ZFXCZ2QO.cjs.map