@particle-academy/react-fancy 5.31.0 → 5.33.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 (171) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/LICENSE +21 -0
  3. package/dist/accordion-panel.cjs +8 -8
  4. package/dist/accordion-panel.js +2 -2
  5. package/dist/autocomplete.cjs +3 -3
  6. package/dist/autocomplete.js +2 -2
  7. package/dist/carousel.cjs +8 -8
  8. package/dist/carousel.js +2 -2
  9. package/dist/checkbox-group.cjs +3 -3
  10. package/dist/checkbox-group.js +2 -2
  11. package/dist/checkbox.cjs +3 -3
  12. package/dist/checkbox.js +2 -2
  13. package/dist/{chunk-7MSIREUY.cjs → chunk-23FTDEGR.cjs} +59 -27
  14. package/dist/chunk-23FTDEGR.cjs.map +1 -0
  15. package/dist/{chunk-TQFQUNV3.js → chunk-2KAJ4L7C.js} +3 -3
  16. package/dist/{chunk-TQFQUNV3.js.map → chunk-2KAJ4L7C.js.map} +1 -1
  17. package/dist/{chunk-L5KKMJ2Q.js → chunk-2VIDYJUG.js} +3 -3
  18. package/dist/{chunk-L5KKMJ2Q.js.map → chunk-2VIDYJUG.js.map} +1 -1
  19. package/dist/{chunk-NH5XJ6VD.js → chunk-2XAVAPDA.js} +58 -27
  20. package/dist/chunk-2XAVAPDA.js.map +1 -0
  21. package/dist/{chunk-3EIB7RPD.cjs → chunk-3Q4NSAEA.cjs} +4 -4
  22. package/dist/{chunk-3EIB7RPD.cjs.map → chunk-3Q4NSAEA.cjs.map} +1 -1
  23. package/dist/{chunk-H6F6ZWAG.js → chunk-4HRD4S25.js} +3 -3
  24. package/dist/{chunk-H6F6ZWAG.js.map → chunk-4HRD4S25.js.map} +1 -1
  25. package/dist/{chunk-LY7PZEF4.cjs → chunk-6IBBAOQC.cjs} +4 -4
  26. package/dist/{chunk-LY7PZEF4.cjs.map → chunk-6IBBAOQC.cjs.map} +1 -1
  27. package/dist/{chunk-RFLPFQFF.js → chunk-BMTTSBHF.js} +3 -3
  28. package/dist/{chunk-RFLPFQFF.js.map → chunk-BMTTSBHF.js.map} +1 -1
  29. package/dist/{chunk-ASCATIDJ.js → chunk-BQ77ZWFM.js} +6 -6
  30. package/dist/{chunk-ASCATIDJ.js.map → chunk-BQ77ZWFM.js.map} +1 -1
  31. package/dist/{chunk-JM2H642B.cjs → chunk-BVRPDMB7.cjs} +4 -4
  32. package/dist/{chunk-JM2H642B.cjs.map → chunk-BVRPDMB7.cjs.map} +1 -1
  33. package/dist/{chunk-JDRKYYXP.cjs → chunk-BZDXX6E3.cjs} +4 -4
  34. package/dist/{chunk-JDRKYYXP.cjs.map → chunk-BZDXX6E3.cjs.map} +1 -1
  35. package/dist/{chunk-VUKIFFWK.cjs → chunk-BZZDHDMK.cjs} +5 -5
  36. package/dist/{chunk-VUKIFFWK.cjs.map → chunk-BZZDHDMK.cjs.map} +1 -1
  37. package/dist/{chunk-6SO2ZX3J.cjs → chunk-DHIUMQLP.cjs} +4 -4
  38. package/dist/{chunk-6SO2ZX3J.cjs.map → chunk-DHIUMQLP.cjs.map} +1 -1
  39. package/dist/chunk-EDYAXGUM.js +27 -0
  40. package/dist/chunk-EDYAXGUM.js.map +1 -0
  41. package/dist/{chunk-MRRKDRZU.js → chunk-EIUS2K72.js} +3 -3
  42. package/dist/{chunk-MRRKDRZU.js.map → chunk-EIUS2K72.js.map} +1 -1
  43. package/dist/{chunk-6PF5ENWM.js → chunk-F2GAZZVS.js} +3 -3
  44. package/dist/{chunk-6PF5ENWM.js.map → chunk-F2GAZZVS.js.map} +1 -1
  45. package/dist/{chunk-VME5743O.js → chunk-FNEPZ33A.js} +3 -3
  46. package/dist/{chunk-VME5743O.js.map → chunk-FNEPZ33A.js.map} +1 -1
  47. package/dist/{chunk-JP4C3ROX.js → chunk-FNJDMGJ3.js} +3 -3
  48. package/dist/{chunk-JP4C3ROX.js.map → chunk-FNJDMGJ3.js.map} +1 -1
  49. package/dist/{chunk-UA2C2U3M.cjs → chunk-FPZYPD3N.cjs} +4 -4
  50. package/dist/{chunk-UA2C2U3M.cjs.map → chunk-FPZYPD3N.cjs.map} +1 -1
  51. package/dist/{chunk-SX4CSO6C.js → chunk-FSRPZYZZ.js} +3 -3
  52. package/dist/{chunk-SX4CSO6C.js.map → chunk-FSRPZYZZ.js.map} +1 -1
  53. package/dist/{chunk-IRD6UXDK.cjs → chunk-FVTCPERB.cjs} +5 -5
  54. package/dist/{chunk-IRD6UXDK.cjs.map → chunk-FVTCPERB.cjs.map} +1 -1
  55. package/dist/{chunk-FUG3OCGP.js → chunk-G73TVXDQ.js} +3 -3
  56. package/dist/{chunk-FUG3OCGP.js.map → chunk-G73TVXDQ.js.map} +1 -1
  57. package/dist/{chunk-LHNC42J3.cjs → chunk-IPNJMHJ3.cjs} +4 -4
  58. package/dist/{chunk-LHNC42J3.cjs.map → chunk-IPNJMHJ3.cjs.map} +1 -1
  59. package/dist/{chunk-PIFJECFU.js → chunk-LBU3T2LF.js} +3 -3
  60. package/dist/{chunk-PIFJECFU.js.map → chunk-LBU3T2LF.js.map} +1 -1
  61. package/dist/{chunk-YAJYIRQL.cjs → chunk-LLA33GKC.cjs} +4 -4
  62. package/dist/{chunk-YAJYIRQL.cjs.map → chunk-LLA33GKC.cjs.map} +1 -1
  63. package/dist/{chunk-HIOMHITU.cjs → chunk-LQFQ2UKU.cjs} +5 -5
  64. package/dist/{chunk-HIOMHITU.cjs.map → chunk-LQFQ2UKU.cjs.map} +1 -1
  65. package/dist/{chunk-6ZDXG5VC.js → chunk-NBAHXZHJ.js} +3 -3
  66. package/dist/{chunk-6ZDXG5VC.js.map → chunk-NBAHXZHJ.js.map} +1 -1
  67. package/dist/{chunk-IUT3Q2EC.js → chunk-NE3Z4AWP.js} +3 -3
  68. package/dist/{chunk-IUT3Q2EC.js.map → chunk-NE3Z4AWP.js.map} +1 -1
  69. package/dist/{chunk-MIUSTEIV.js → chunk-O2ZHORSC.js} +3 -3
  70. package/dist/{chunk-MIUSTEIV.js.map → chunk-O2ZHORSC.js.map} +1 -1
  71. package/dist/{chunk-L2FPIFMN.js → chunk-OC75GWX5.js} +3 -3
  72. package/dist/{chunk-L2FPIFMN.js.map → chunk-OC75GWX5.js.map} +1 -1
  73. package/dist/{chunk-GKEWT3DW.js → chunk-OTCLBINT.js} +3 -3
  74. package/dist/{chunk-GKEWT3DW.js.map → chunk-OTCLBINT.js.map} +1 -1
  75. package/dist/{chunk-XXBW4EUO.js → chunk-P7Q2YIIS.js} +3 -3
  76. package/dist/{chunk-XXBW4EUO.js.map → chunk-P7Q2YIIS.js.map} +1 -1
  77. package/dist/{chunk-YTXBU6QC.cjs → chunk-QBNR5IVM.cjs} +4 -4
  78. package/dist/{chunk-YTXBU6QC.cjs.map → chunk-QBNR5IVM.cjs.map} +1 -1
  79. package/dist/{chunk-I3RPL3GE.js → chunk-RUSRAKKA.js} +3 -3
  80. package/dist/{chunk-I3RPL3GE.js.map → chunk-RUSRAKKA.js.map} +1 -1
  81. package/dist/{chunk-ZTC3EQFZ.cjs → chunk-S5KUYX3Z.cjs} +4 -4
  82. package/dist/{chunk-ZTC3EQFZ.cjs.map → chunk-S5KUYX3Z.cjs.map} +1 -1
  83. package/dist/chunk-SNHU2AI4.cjs +29 -0
  84. package/dist/chunk-SNHU2AI4.cjs.map +1 -0
  85. package/dist/{chunk-JV6RDIA6.cjs → chunk-T45XK5GN.cjs} +7 -7
  86. package/dist/{chunk-JV6RDIA6.cjs.map → chunk-T45XK5GN.cjs.map} +1 -1
  87. package/dist/{chunk-RKG2Q2HT.cjs → chunk-U7PFHQBN.cjs} +4 -4
  88. package/dist/{chunk-RKG2Q2HT.cjs.map → chunk-U7PFHQBN.cjs.map} +1 -1
  89. package/dist/{chunk-LAQGBLIU.cjs → chunk-VKXNCYLE.cjs} +14 -5
  90. package/dist/chunk-VKXNCYLE.cjs.map +1 -0
  91. package/dist/{chunk-3FG5K7A7.js → chunk-VYHZEQIG.js} +3 -3
  92. package/dist/{chunk-3FG5K7A7.js.map → chunk-VYHZEQIG.js.map} +1 -1
  93. package/dist/{chunk-32HCJ5GD.js → chunk-W6RDAZJC.js} +14 -5
  94. package/dist/chunk-W6RDAZJC.js.map +1 -0
  95. package/dist/{chunk-N6K2CTSU.cjs → chunk-WIS4QRGK.cjs} +4 -4
  96. package/dist/{chunk-N6K2CTSU.cjs.map → chunk-WIS4QRGK.cjs.map} +1 -1
  97. package/dist/{chunk-2LBRS6Z4.js → chunk-XDJSFGXW.js} +3 -3
  98. package/dist/{chunk-2LBRS6Z4.js.map → chunk-XDJSFGXW.js.map} +1 -1
  99. package/dist/{chunk-6LOV75CN.cjs → chunk-XK5WHQ3O.cjs} +4 -4
  100. package/dist/{chunk-6LOV75CN.cjs.map → chunk-XK5WHQ3O.cjs.map} +1 -1
  101. package/dist/{chunk-B5KK7NYP.cjs → chunk-Y52NXM73.cjs} +4 -4
  102. package/dist/{chunk-B5KK7NYP.cjs.map → chunk-Y52NXM73.cjs.map} +1 -1
  103. package/dist/{chunk-YLDYGT5O.js → chunk-YD4SXA6K.js} +3 -3
  104. package/dist/{chunk-YLDYGT5O.js.map → chunk-YD4SXA6K.js.map} +1 -1
  105. package/dist/{chunk-NR346SKH.cjs → chunk-YMDYDUBH.cjs} +4 -4
  106. package/dist/{chunk-NR346SKH.cjs.map → chunk-YMDYDUBH.cjs.map} +1 -1
  107. package/dist/{chunk-SCGE6DCE.cjs → chunk-YMU3SS6D.cjs} +14 -14
  108. package/dist/{chunk-SCGE6DCE.cjs.map → chunk-YMU3SS6D.cjs.map} +1 -1
  109. package/dist/{chunk-PWLBHNOA.cjs → chunk-Z3NSPDTW.cjs} +4 -4
  110. package/dist/{chunk-PWLBHNOA.cjs.map → chunk-Z3NSPDTW.cjs.map} +1 -1
  111. package/dist/{chunk-BJYTI2ID.cjs → chunk-ZUQUL53P.cjs} +4 -4
  112. package/dist/{chunk-BJYTI2ID.cjs.map → chunk-ZUQUL53P.cjs.map} +1 -1
  113. package/dist/color-picker.cjs +3 -3
  114. package/dist/color-picker.js +2 -2
  115. package/dist/composer.cjs +3 -3
  116. package/dist/composer.d.cts +2 -50
  117. package/dist/composer.d.ts +2 -50
  118. package/dist/composer.js +2 -2
  119. package/dist/date-picker.cjs +3 -3
  120. package/dist/date-picker.js +2 -2
  121. package/dist/editor.cjs +4 -4
  122. package/dist/editor.js +2 -2
  123. package/dist/emoji-select.cjs +3 -3
  124. package/dist/emoji-select.js +2 -2
  125. package/dist/file-browser.cjs +6 -6
  126. package/dist/file-browser.js +2 -2
  127. package/dist/file-upload.cjs +3 -3
  128. package/dist/file-upload.js +1 -1
  129. package/dist/index-C8PKWA_5.d.cts +153 -0
  130. package/dist/index-C8PKWA_5.d.ts +153 -0
  131. package/dist/index.cjs +78 -74
  132. package/dist/index.d.cts +34 -1
  133. package/dist/index.d.ts +34 -1
  134. package/dist/index.js +25 -25
  135. package/dist/input.cjs +3 -3
  136. package/dist/input.js +2 -2
  137. package/dist/inputs.cjs +17 -17
  138. package/dist/inputs.js +9 -9
  139. package/dist/json-editor.cjs +17 -17
  140. package/dist/json-editor.js +6 -6
  141. package/dist/mobile-menu.cjs +1 -1
  142. package/dist/mobile-menu.js +1 -1
  143. package/dist/multi-switch.cjs +3 -3
  144. package/dist/multi-switch.js +2 -2
  145. package/dist/otp-input.cjs +3 -3
  146. package/dist/otp-input.js +2 -2
  147. package/dist/pillbox.cjs +3 -3
  148. package/dist/pillbox.js +2 -2
  149. package/dist/radio-group.cjs +3 -3
  150. package/dist/radio-group.js +2 -2
  151. package/dist/sidebar.cjs +4 -4
  152. package/dist/sidebar.js +2 -2
  153. package/dist/slider.cjs +3 -3
  154. package/dist/slider.js +2 -2
  155. package/dist/switch.cjs +3 -3
  156. package/dist/switch.js +2 -2
  157. package/dist/table.cjs +12 -12
  158. package/dist/table.js +2 -2
  159. package/dist/tabs.cjs +4 -4
  160. package/dist/tabs.js +2 -2
  161. package/dist/time-picker.cjs +3 -3
  162. package/dist/time-picker.js +2 -2
  163. package/package.json +1 -1
  164. package/dist/chunk-32HCJ5GD.js.map +0 -1
  165. package/dist/chunk-6FQGMVF2.js +0 -25
  166. package/dist/chunk-6FQGMVF2.js.map +0 -1
  167. package/dist/chunk-7MSIREUY.cjs.map +0 -1
  168. package/dist/chunk-LAQGBLIU.cjs.map +0 -1
  169. package/dist/chunk-NH5XJ6VD.js.map +0 -1
  170. package/dist/chunk-OUOEQZHY.cjs +0 -27
  171. package/dist/chunk-OUOEQZHY.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -11,6 +11,100 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ## [5.33.0] - 2026-10-04
15
+
16
+ ### Fixed
17
+
18
+ - **`FileUpload` with `multiple={false}` could never change its file.** Choosing
19
+ a second file kept the first and discarded the new one in silence, so a
20
+ single-file field was write-once; the only way out was removing the file or
21
+ remounting the component. Reported by the YouGene estate, who were working
22
+ around it with a `key` remount.
23
+
24
+ **What changed, precisely:** `multiple={false}` now REPLACES. `maxFiles` is
25
+ unchanged and still refuses the overflow. The two used to share one rule — a
26
+ cap of one, first-wins — on the reasoning that they must not disagree about
27
+ what a single-file upload means. They are different statements and are now
28
+ allowed to differ: `maxFiles={n}` is a quota (drop five files into a
29
+ three-file field and you keep three, not the last three), while
30
+ `multiple={false}` is a field shape whose analogue is a radio group, where
31
+ choosing again moves the selection.
32
+
33
+ **Dropping several files at once onto a single-file field still keeps the
34
+ FIRST**, exactly as before. Only the across-gestures case changed. If you
35
+ depended on the old write-once behaviour — which we do not think anyone could
36
+ have wanted — pass `maxFiles={1}` instead of `multiple={false}`.
37
+
38
+ - **`FileUpload` ignored the same file being chosen twice.** The hidden
39
+ `<input type="file">` was never reset, and an input still holding a path fires
40
+ no `change` event when the user picks that same path again. So "remove it,
41
+ then choose it again" and "retry the import that just failed" were dead
42
+ gestures — the component was never asked, so it never rejected anything. The
43
+ input is now cleared after each change.
44
+
45
+
46
+ ## [5.32.0] - 2026-10-02
47
+
48
+ ### Added
49
+
50
+ - **`usePastePills` — the paste-holding logic without a surface.**
51
+
52
+ ```ts
53
+ const pills = usePastePills({ threshold: 500, heldPastes, onHeldPastesChange });
54
+
55
+ function onPaste(e) {
56
+ if (pills.handlePaste(e)) return; // it took the paste and called preventDefault
57
+ // ...your own handling
58
+ }
59
+ ```
60
+
61
+ Returns `heldPastes`, `handlePaste(event) => boolean`, `expand(id) => string | undefined`
62
+ (removes it and hands back the text for you to insert), `remove(id)` and `clear()`.
63
+
64
+ **It owns no DOM** — you render the pills. And `handlePaste` is **composable**: it
65
+ returns `true` only if it took the paste, having called `preventDefault()` itself,
66
+ and otherwise declines *without touching the event*, so a host whose own handler
67
+ already intercepts paste can ask "did you want this?" rather than hand over.
68
+
69
+ `HeldPaste` carries `id` and `text` and deliberately **no `length`** — it would be
70
+ `text.length` and nothing else, and a derived value stored beside its source is a
71
+ value that can disagree with it.
72
+
73
+ Exists because the estate that specified 5.31.0's `Composer` feature then
74
+ established that they cannot use `Composer` at all: their chat input is a
75
+ contenteditable rendering inline `[deal:42|Acme]` badges, which a textarea cannot
76
+ do. **`Composer` is now this hook's first caller** — one implementation rather than
77
+ two, because two copies of a rule drift and the copy nobody reads is the one that
78
+ rots.
79
+
80
+ **What you must DO: nothing.** `Composer`'s behaviour is unchanged and its tests
81
+ are the proof — all 15 from 5.31.0 pass untouched across the refactor.
82
+
83
+ ### Fixed
84
+
85
+ - **`useControllableState` silently lost an update when two functional updates
86
+ batched.** It resolved `setValue(fn)` against the **render closure's** value and
87
+ handed React a pre-computed result, so two calls before a re-render both computed
88
+ from the same stale value and **the first was dropped**:
89
+
90
+ ```
91
+ setItems(c => [...c, "a"]);
92
+ setItems(c => [...c, "b"]); // -> ["b"], not ["a", "b"]
93
+ ```
94
+
95
+ Most stateful components in this library use this hook, so the blast radius was
96
+ everything — but it only surfaces when a caller updates twice in one batch, which
97
+ is why it survived. No error, no warning: just less state than you asked for.
98
+
99
+ Found by a `usePastePills` test that held two pastes inside one `act()` and got
100
+ one. Four of the five new regression tests fail against the previous
101
+ implementation.
102
+
103
+ **What you must DO: nothing**, and one thing you may notice: **the setter is now
104
+ stable across renders.** It used to change identity on every update, which
105
+ invalidated any consumer `useCallback`/`useEffect` depending on it. If you were
106
+ relying on that churn to re-run an effect, you were relying on a bug.
107
+
14
108
  ## [5.31.0] - 2026-10-02
15
109
 
16
110
  ### Added
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Particle Academy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,34 +1,34 @@
1
1
  'use strict';
2
2
 
3
- var chunkZTC3EQFZ_cjs = require('./chunk-ZTC3EQFZ.cjs');
4
- require('./chunk-OUOEQZHY.cjs');
3
+ var chunkS5KUYX3Z_cjs = require('./chunk-S5KUYX3Z.cjs');
4
+ require('./chunk-SNHU2AI4.cjs');
5
5
  require('./chunk-ZU5Q77OT.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, "AccordionPanel", {
10
10
  enumerable: true,
11
- get: function () { return chunkZTC3EQFZ_cjs.AccordionPanel; }
11
+ get: function () { return chunkS5KUYX3Z_cjs.AccordionPanel; }
12
12
  });
13
13
  Object.defineProperty(exports, "AccordionPanelContent", {
14
14
  enumerable: true,
15
- get: function () { return chunkZTC3EQFZ_cjs.AccordionPanelContent; }
15
+ get: function () { return chunkS5KUYX3Z_cjs.AccordionPanelContent; }
16
16
  });
17
17
  Object.defineProperty(exports, "AccordionPanelSection", {
18
18
  enumerable: true,
19
- get: function () { return chunkZTC3EQFZ_cjs.AccordionPanelSection; }
19
+ get: function () { return chunkS5KUYX3Z_cjs.AccordionPanelSection; }
20
20
  });
21
21
  Object.defineProperty(exports, "AccordionPanelTrigger", {
22
22
  enumerable: true,
23
- get: function () { return chunkZTC3EQFZ_cjs.AccordionPanelTrigger; }
23
+ get: function () { return chunkS5KUYX3Z_cjs.AccordionPanelTrigger; }
24
24
  });
25
25
  Object.defineProperty(exports, "useAccordionPanel", {
26
26
  enumerable: true,
27
- get: function () { return chunkZTC3EQFZ_cjs.useAccordionPanel; }
27
+ get: function () { return chunkS5KUYX3Z_cjs.useAccordionPanel; }
28
28
  });
29
29
  Object.defineProperty(exports, "useAccordionSection", {
30
30
  enumerable: true,
31
- get: function () { return chunkZTC3EQFZ_cjs.useAccordionSection; }
31
+ get: function () { return chunkS5KUYX3Z_cjs.useAccordionSection; }
32
32
  });
33
33
  //# sourceMappingURL=accordion-panel.cjs.map
34
34
  //# sourceMappingURL=accordion-panel.cjs.map
@@ -1,5 +1,5 @@
1
- export { AccordionPanel, AccordionPanelContent, AccordionPanelSection, AccordionPanelTrigger, useAccordionPanel, useAccordionSection } from './chunk-I3RPL3GE.js';
2
- import './chunk-6FQGMVF2.js';
1
+ export { AccordionPanel, AccordionPanelContent, AccordionPanelSection, AccordionPanelTrigger, useAccordionPanel, useAccordionSection } from './chunk-RUSRAKKA.js';
2
+ import './chunk-EDYAXGUM.js';
3
3
  import './chunk-MMW2JGKZ.js';
4
4
  //# sourceMappingURL=accordion-panel.js.map
5
5
  //# sourceMappingURL=accordion-panel.js.map
@@ -1,20 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var chunkYTXBU6QC_cjs = require('./chunk-YTXBU6QC.cjs');
3
+ var chunkQBNR5IVM_cjs = require('./chunk-QBNR5IVM.cjs');
4
4
  require('./chunk-J2DI6RMR.cjs');
5
5
  require('./chunk-KJ22KE56.cjs');
6
6
  require('./chunk-L3V3BYVS.cjs');
7
7
  require('./chunk-NBZC6LOB.cjs');
8
8
  require('./chunk-57FQGQJK.cjs');
9
9
  require('./chunk-RXDRYWVD.cjs');
10
- require('./chunk-OUOEQZHY.cjs');
10
+ require('./chunk-SNHU2AI4.cjs');
11
11
  require('./chunk-ZU5Q77OT.cjs');
12
12
 
13
13
 
14
14
 
15
15
  Object.defineProperty(exports, "Autocomplete", {
16
16
  enumerable: true,
17
- get: function () { return chunkYTXBU6QC_cjs.Autocomplete; }
17
+ get: function () { return chunkQBNR5IVM_cjs.Autocomplete; }
18
18
  });
19
19
  //# sourceMappingURL=autocomplete.cjs.map
20
20
  //# sourceMappingURL=autocomplete.cjs.map
@@ -1,11 +1,11 @@
1
- export { Autocomplete } from './chunk-MIUSTEIV.js';
1
+ export { Autocomplete } from './chunk-O2ZHORSC.js';
2
2
  import './chunk-MQ6VGG62.js';
3
3
  import './chunk-OL53XYHF.js';
4
4
  import './chunk-NRXK42LO.js';
5
5
  import './chunk-WHEXTDPV.js';
6
6
  import './chunk-RGANGU7X.js';
7
7
  import './chunk-JXE5XID6.js';
8
- import './chunk-6FQGMVF2.js';
8
+ import './chunk-EDYAXGUM.js';
9
9
  import './chunk-MMW2JGKZ.js';
10
10
  //# sourceMappingURL=autocomplete.js.map
11
11
  //# sourceMappingURL=autocomplete.js.map
package/dist/carousel.cjs CHANGED
@@ -1,34 +1,34 @@
1
1
  'use strict';
2
2
 
3
- var chunk6SO2ZX3J_cjs = require('./chunk-6SO2ZX3J.cjs');
4
- require('./chunk-OUOEQZHY.cjs');
3
+ var chunkDHIUMQLP_cjs = require('./chunk-DHIUMQLP.cjs');
4
+ require('./chunk-SNHU2AI4.cjs');
5
5
  require('./chunk-ZU5Q77OT.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, "Carousel", {
10
10
  enumerable: true,
11
- get: function () { return chunk6SO2ZX3J_cjs.Carousel; }
11
+ get: function () { return chunkDHIUMQLP_cjs.Carousel; }
12
12
  });
13
13
  Object.defineProperty(exports, "CarouselControls", {
14
14
  enumerable: true,
15
- get: function () { return chunk6SO2ZX3J_cjs.CarouselControls; }
15
+ get: function () { return chunkDHIUMQLP_cjs.CarouselControls; }
16
16
  });
17
17
  Object.defineProperty(exports, "CarouselPanels", {
18
18
  enumerable: true,
19
- get: function () { return chunk6SO2ZX3J_cjs.CarouselPanels; }
19
+ get: function () { return chunkDHIUMQLP_cjs.CarouselPanels; }
20
20
  });
21
21
  Object.defineProperty(exports, "CarouselSlide", {
22
22
  enumerable: true,
23
- get: function () { return chunk6SO2ZX3J_cjs.CarouselSlide; }
23
+ get: function () { return chunkDHIUMQLP_cjs.CarouselSlide; }
24
24
  });
25
25
  Object.defineProperty(exports, "CarouselSteps", {
26
26
  enumerable: true,
27
- get: function () { return chunk6SO2ZX3J_cjs.CarouselSteps; }
27
+ get: function () { return chunkDHIUMQLP_cjs.CarouselSteps; }
28
28
  });
29
29
  Object.defineProperty(exports, "useCarousel", {
30
30
  enumerable: true,
31
- get: function () { return chunk6SO2ZX3J_cjs.useCarousel; }
31
+ get: function () { return chunkDHIUMQLP_cjs.useCarousel; }
32
32
  });
33
33
  //# sourceMappingURL=carousel.cjs.map
34
34
  //# sourceMappingURL=carousel.cjs.map
package/dist/carousel.js CHANGED
@@ -1,5 +1,5 @@
1
- export { Carousel, CarouselControls, CarouselPanels, CarouselSlide, CarouselSteps, useCarousel } from './chunk-RFLPFQFF.js';
2
- import './chunk-6FQGMVF2.js';
1
+ export { Carousel, CarouselControls, CarouselPanels, CarouselSlide, CarouselSteps, useCarousel } from './chunk-BMTTSBHF.js';
2
+ import './chunk-EDYAXGUM.js';
3
3
  import './chunk-MMW2JGKZ.js';
4
4
  //# sourceMappingURL=carousel.js.map
5
5
  //# sourceMappingURL=carousel.js.map
@@ -1,19 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunkJDRKYYXP_cjs = require('./chunk-JDRKYYXP.cjs');
3
+ var chunkBZDXX6E3_cjs = require('./chunk-BZDXX6E3.cjs');
4
4
  require('./chunk-XKDW6B7X.cjs');
5
5
  require('./chunk-BBOIFV27.cjs');
6
6
  require('./chunk-YLGTDBB2.cjs');
7
7
  require('./chunk-KJ22KE56.cjs');
8
8
  require('./chunk-L3V3BYVS.cjs');
9
- require('./chunk-OUOEQZHY.cjs');
9
+ require('./chunk-SNHU2AI4.cjs');
10
10
  require('./chunk-ZU5Q77OT.cjs');
11
11
 
12
12
 
13
13
 
14
14
  Object.defineProperty(exports, "CheckboxGroup", {
15
15
  enumerable: true,
16
- get: function () { return chunkJDRKYYXP_cjs.CheckboxGroup; }
16
+ get: function () { return chunkBZDXX6E3_cjs.CheckboxGroup; }
17
17
  });
18
18
  //# sourceMappingURL=checkbox-group.cjs.map
19
19
  //# sourceMappingURL=checkbox-group.cjs.map
@@ -1,10 +1,10 @@
1
- export { CheckboxGroup } from './chunk-JP4C3ROX.js';
1
+ export { CheckboxGroup } from './chunk-FNJDMGJ3.js';
2
2
  import './chunk-KKWNKBKR.js';
3
3
  import './chunk-5MU6X3KO.js';
4
4
  import './chunk-GFYSELJF.js';
5
5
  import './chunk-OL53XYHF.js';
6
6
  import './chunk-NRXK42LO.js';
7
- import './chunk-6FQGMVF2.js';
7
+ import './chunk-EDYAXGUM.js';
8
8
  import './chunk-MMW2JGKZ.js';
9
9
  //# sourceMappingURL=checkbox-group.js.map
10
10
  //# sourceMappingURL=checkbox-group.js.map
package/dist/checkbox.cjs CHANGED
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunkRKG2Q2HT_cjs = require('./chunk-RKG2Q2HT.cjs');
3
+ var chunkU7PFHQBN_cjs = require('./chunk-U7PFHQBN.cjs');
4
4
  require('./chunk-YLGTDBB2.cjs');
5
5
  require('./chunk-KJ22KE56.cjs');
6
6
  require('./chunk-L3V3BYVS.cjs');
7
- require('./chunk-OUOEQZHY.cjs');
7
+ require('./chunk-SNHU2AI4.cjs');
8
8
  require('./chunk-ZU5Q77OT.cjs');
9
9
 
10
10
 
11
11
 
12
12
  Object.defineProperty(exports, "Checkbox", {
13
13
  enumerable: true,
14
- get: function () { return chunkRKG2Q2HT_cjs.Checkbox; }
14
+ get: function () { return chunkU7PFHQBN_cjs.Checkbox; }
15
15
  });
16
16
  //# sourceMappingURL=checkbox.cjs.map
17
17
  //# sourceMappingURL=checkbox.cjs.map
package/dist/checkbox.js CHANGED
@@ -1,8 +1,8 @@
1
- export { Checkbox } from './chunk-H6F6ZWAG.js';
1
+ export { Checkbox } from './chunk-4HRD4S25.js';
2
2
  import './chunk-GFYSELJF.js';
3
3
  import './chunk-OL53XYHF.js';
4
4
  import './chunk-NRXK42LO.js';
5
- import './chunk-6FQGMVF2.js';
5
+ import './chunk-EDYAXGUM.js';
6
6
  import './chunk-MMW2JGKZ.js';
7
7
  //# sourceMappingURL=checkbox.js.map
8
8
  //# sourceMappingURL=checkbox.js.map
@@ -1,10 +1,50 @@
1
1
  'use strict';
2
2
 
3
- var chunkOUOEQZHY_cjs = require('./chunk-OUOEQZHY.cjs');
3
+ var chunkSNHU2AI4_cjs = require('./chunk-SNHU2AI4.cjs');
4
4
  var chunkZU5Q77OT_cjs = require('./chunk-ZU5Q77OT.cjs');
5
5
  var react = require('react');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
 
8
+ function usePastePills({
9
+ threshold,
10
+ heldPastes: controlledHeldPastes,
11
+ onHeldPastesChange
12
+ } = {}) {
13
+ const [heldPastes, setHeldPastes] = chunkSNHU2AI4_cjs.useControllableState(
14
+ controlledHeldPastes,
15
+ [],
16
+ onHeldPastesChange
17
+ );
18
+ const nextId = react.useRef(0);
19
+ const handlePaste = react.useCallback(
20
+ (event) => {
21
+ if (!threshold || threshold <= 0) return false;
22
+ const text = event.clipboardData?.getData("text/plain") ?? "";
23
+ if (text.length < threshold) return false;
24
+ event.preventDefault();
25
+ nextId.current += 1;
26
+ const id = `paste-${nextId.current}`;
27
+ setHeldPastes((current) => [...current, { id, text }]);
28
+ return true;
29
+ },
30
+ [threshold, setHeldPastes]
31
+ );
32
+ const expand = react.useCallback(
33
+ (id) => {
34
+ const found = heldPastes.find((p) => p.id === id);
35
+ if (found === void 0) return void 0;
36
+ setHeldPastes((current) => current.filter((p) => p.id !== id));
37
+ return found.text;
38
+ },
39
+ [heldPastes, setHeldPastes]
40
+ );
41
+ const remove = react.useCallback(
42
+ (id) => setHeldPastes((current) => current.filter((p) => p.id !== id)),
43
+ [setHeldPastes]
44
+ );
45
+ const clear = react.useCallback(() => setHeldPastes([]), [setHeldPastes]);
46
+ return { heldPastes, handlePaste, expand, remove, clear };
47
+ }
8
48
  var PREVIEW_CHARS = 20;
9
49
  function withSeparators(n) {
10
50
  return String(n).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
@@ -27,29 +67,23 @@ var Composer = react.forwardRef(
27
67
  heldPastes: controlledHeldPastes,
28
68
  onHeldPastesChange
29
69
  }, ref) {
30
- const [value, setValue] = chunkOUOEQZHY_cjs.useControllableState(
70
+ const [value, setValue] = chunkSNHU2AI4_cjs.useControllableState(
31
71
  controlledValue,
32
72
  defaultValue,
33
73
  onChange
34
74
  );
35
- const [heldPastes, setHeldPastes] = chunkOUOEQZHY_cjs.useControllableState(
36
- controlledHeldPastes,
37
- [],
75
+ const pills = usePastePills({
76
+ threshold: pasteThreshold,
77
+ heldPastes: controlledHeldPastes,
38
78
  onHeldPastesChange
39
- );
79
+ });
80
+ const heldPastes = pills.heldPastes;
40
81
  const textareaRef = react.useRef(null);
41
- const nextId = react.useRef(0);
42
82
  const handlePaste = react.useCallback(
43
83
  (e) => {
44
- if (!pasteThreshold || pasteThreshold <= 0) return;
45
- const text = e.clipboardData?.getData("text/plain") ?? "";
46
- if (text.length < pasteThreshold) return;
47
- e.preventDefault();
48
- nextId.current += 1;
49
- const id = `paste-${nextId.current}`;
50
- setHeldPastes((current) => [...current, { id, text }]);
84
+ pills.handlePaste(e);
51
85
  },
52
- [pasteThreshold, setHeldPastes]
86
+ [pills]
53
87
  );
54
88
  const composeOutgoing = react.useCallback(
55
89
  () => [value, ...heldPastes.map((p) => p.text)].filter(Boolean).join("\n\n"),
@@ -60,9 +94,9 @@ var Composer = react.forwardRef(
60
94
  if (!hasContent || disabled) return;
61
95
  onSubmit?.(composeOutgoing());
62
96
  setValue("");
63
- setHeldPastes([]);
97
+ pills.clear();
64
98
  textareaRef.current?.focus();
65
- }, [hasContent, disabled, onSubmit, composeOutgoing, setValue, setHeldPastes]);
99
+ }, [hasContent, disabled, onSubmit, composeOutgoing, setValue, pills]);
66
100
  const handleKeyDown = (e) => {
67
101
  if (e.key === "Enter" && !e.shiftKey) {
68
102
  e.preventDefault();
@@ -71,17 +105,14 @@ var Composer = react.forwardRef(
71
105
  };
72
106
  const insertPaste = react.useCallback(
73
107
  (paste) => {
108
+ const text = pills.expand(paste.id);
109
+ if (text === void 0) return;
74
110
  setValue((current) => current ? `${current}
75
111
 
76
- ${paste.text}` : paste.text);
77
- setHeldPastes((current) => current.filter((p) => p.id !== paste.id));
112
+ ${text}` : text);
78
113
  textareaRef.current?.focus();
79
114
  },
80
- [setValue, setHeldPastes]
81
- );
82
- const discardPaste = react.useCallback(
83
- (id) => setHeldPastes((current) => current.filter((p) => p.id !== id)),
84
- [setHeldPastes]
115
+ [pills, setValue]
85
116
  );
86
117
  return /* @__PURE__ */ jsxRuntime.jsxs(
87
118
  "div",
@@ -126,7 +157,7 @@ ${paste.text}` : paste.text);
126
157
  {
127
158
  type: "button",
128
159
  "data-react-fancy-composer-paste-pill-remove": paste.id,
129
- onClick: () => discardPaste(paste.id),
160
+ onClick: () => pills.remove(paste.id),
130
161
  disabled,
131
162
  "aria-label": "Discard this pasted text",
132
163
  className: "absolute right-1 top-1/2 -translate-y-1/2 rounded-full px-1 text-xs text-zinc-400 transition-colors hover:text-zinc-700 dark:hover:text-zinc-100",
@@ -182,5 +213,6 @@ ${paste.text}` : paste.text);
182
213
  Composer.displayName = "Composer";
183
214
 
184
215
  exports.Composer = Composer;
185
- //# sourceMappingURL=chunk-7MSIREUY.cjs.map
186
- //# sourceMappingURL=chunk-7MSIREUY.cjs.map
216
+ exports.usePastePills = usePastePills;
217
+ //# sourceMappingURL=chunk-23FTDEGR.cjs.map
218
+ //# sourceMappingURL=chunk-23FTDEGR.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-paste-pills.ts","../src/components/Composer/Composer.tsx"],"names":["useControllableState","useRef","useCallback","forwardRef","Composer","jsxs","cn","jsx"],"mappings":";;;;;;;AAoHO,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,WAAA,GAAcC,iBAAA;AAAA,IAClB,CAAC,KAAA,KAAmC;AAClC,MAAA,IAAI,CAAC,SAAA,IAAa,SAAA,IAAa,CAAA,EAAG,OAAO,KAAA;AAEzC,MAAA,MAAM,IAAA,GAAO,KAAA,CAAM,aAAA,EAAe,OAAA,CAAQ,YAAY,CAAA,IAAK,EAAA;AAK3D,MAAA,IAAI,IAAA,CAAK,MAAA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AA;AAAA,gBACL,OAAA,EAAS,YAAA;AAAA,gBACT,QAAA,EAAU,YAAY,CAAC,UAAA;AAAA,gBACvB,SAAA,EAAU,mLAAA;AAAA,gBACX,QAAA,EAAA;AAAA;AAAA;AAED,WAAA,EACF;AAAA;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AAEA,QAAA,CAAS,WAAA,GAAc,UAAA","file":"chunk-23FTDEGR.cjs","sourcesContent":["import { useCallback, useRef } from \"react\";\nimport { useControllableState } from \"./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}\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 * 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 */\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 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 nextId.current += 1;\n const id = `paste-${nextId.current}`;\n setHeldPastes((current) => [...current, { id, text }]);\n\n return true;\n },\n [threshold, setHeldPastes],\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, expand, remove, clear };\n}\n","import { forwardRef, useCallback, useRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useControllableState } from \"../../hooks/use-controllable-state\";\nimport { usePastePills, type HeldPaste } from \"../../hooks/use-paste-pills\";\nimport type { ComposerProps } from \"./Composer.types\";\n\n/** Characters of a held paste shown at each end of the hover preview. */\nconst PREVIEW_CHARS = 20;\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 */\nfunction 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. */\nfunction endsOf(text: string): string {\n if (text.length <= PREVIEW_CHARS * 2) return text;\n\n return `${text.slice(0, PREVIEW_CHARS)} … ${text.slice(-PREVIEW_CHARS)}`;\n}\n\nexport const Composer = forwardRef<HTMLDivElement, ComposerProps>(\n function Composer(\n {\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n onSubmit,\n placeholder = \"Type a message...\",\n actions,\n disabled = false,\n className,\n pasteThreshold,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n },\n ref,\n ) {\n const [value, setValue] = useControllableState(\n controlledValue,\n defaultValue,\n onChange,\n );\n /*\n * The holding logic lives in `usePastePills` and this is its first caller.\n *\n * It moved out in 5.32.0 because the estate that specified the feature cannot\n * use this component at all — their chat input is a contenteditable rendering\n * inline tag badges, which a textarea cannot do. One implementation rather than\n * two: two copies of a rule drift, and the copy nobody reads is the one that\n * rots. The rule that must not drift is the one below — a send with pills still\n * closed carries the text.\n */\n const pills = usePastePills({\n threshold: pasteThreshold,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n });\n const heldPastes = pills.heldPastes;\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const handlePaste = useCallback(\n (e: React.ClipboardEvent<HTMLTextAreaElement>) => {\n // Composable by design, so this reads as a question rather than a handover.\n // Nothing else here wants the paste, so the answer is simply ignored.\n pills.handlePaste(e);\n },\n [pills],\n );\n\n /** Everything the person believes they are sending, in the order they built it. */\n const composeOutgoing = useCallback(\n () => [value, ...heldPastes.map((p) => p.text)].filter(Boolean).join(\"\\n\\n\"),\n [value, heldPastes],\n );\n\n const hasContent = value.trim().length > 0 || heldPastes.length > 0;\n\n const handleSubmit = useCallback(() => {\n if (!hasContent || disabled) return;\n\n /*\n * THE DANGEROUS STATE, and the reason this feature needed a spec rather than\n * a guess. A pill reads as \"your paste is attached\" — so a send that drops it\n * means asking a question about a document without the document, and nobody\n * can tell: the sender believes it went, the receiver sees a question about\n * nothing.\n *\n * Held pastes go out in arrival order, after what was typed, because people\n * type the question BEFORE pasting the thing it is about.\n */\n onSubmit?.(composeOutgoing());\n setValue(\"\");\n pills.clear();\n textareaRef.current?.focus();\n }, [hasContent, disabled, onSubmit, composeOutgoing, setValue, pills]);\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n };\n\n /** Click a pill: dump it into the input, APPENDED to what is already typed. */\n const insertPaste = useCallback(\n (paste: HeldPaste) => {\n // `expand` removes it and hands back the text; inserting is this\n // component's job because the hook owns no DOM.\n const text = pills.expand(paste.id);\n\n if (text === undefined) return;\n\n setValue((current) => (current ? `${current}\\n\\n${text}` : text));\n textareaRef.current?.focus();\n },\n [pills, setValue],\n );\n\n return (\n <div\n data-react-fancy-composer=\"\"\n ref={ref}\n className={cn(\n \"rounded-xl border border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900\",\n disabled && \"opacity-50\",\n className,\n )}\n >\n {heldPastes.length > 0 && (\n <div\n data-react-fancy-composer-paste-pills=\"\"\n className=\"flex flex-wrap gap-1.5 px-3 pt-3\"\n >\n {heldPastes.map((paste) => (\n // `group` + `group-hover` rather than hover state: the preview is\n // presentation, and a useState for it would be one more thing an\n // agent could desynchronise.\n <span key={paste.id} className=\"group relative inline-flex\">\n <button\n type=\"button\"\n data-react-fancy-composer-paste-pill={paste.id}\n onClick={() => insertPaste(paste)}\n disabled={disabled}\n // No `title`. A native tooltip plus the hover preview below\n // renders TWO tooltips on the same hover, at different delays.\n // The label says what clicking does; the preview says what the\n // text is, and it is linked rather than merely adjacent so a\n // screen reader reaches it too.\n aria-label={`Insert this pasted text, ${withSeparators(paste.text.length)} characters`}\n aria-describedby={`${paste.id}-preview`}\n // `pr-7` leaves room for the absolutely-positioned × that sits\n // over this button's right edge. With a smaller right padding the\n // × lands on top of the label.\n className=\"inline-flex items-center gap-1.5 rounded-full border border-zinc-200 bg-zinc-50 py-1 pl-2.5 pr-7 text-xs text-zinc-700 transition-colors hover:bg-zinc-100 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-200 dark:hover:bg-zinc-700\"\n >\n <span>\n Pasted text · {withSeparators(paste.text.length)} characters\n </span>\n </button>\n\n <button\n type=\"button\"\n data-react-fancy-composer-paste-pill-remove={paste.id}\n onClick={() => pills.remove(paste.id)}\n disabled={disabled}\n aria-label=\"Discard this pasted text\"\n className=\"absolute right-1 top-1/2 -translate-y-1/2 rounded-full px-1 text-xs text-zinc-400 transition-colors hover:text-zinc-700 dark:hover:text-zinc-100\"\n >\n ×\n </button>\n\n <span\n id={`${paste.id}-preview`}\n data-react-fancy-composer-paste-pill-preview={paste.id}\n role=\"tooltip\"\n className=\"pointer-events-none absolute bottom-full left-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\"\n >\n {endsOf(paste.text)}\n </span>\n </span>\n ))}\n </div>\n )}\n\n <textarea\n ref={textareaRef}\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n disabled={disabled}\n rows={3}\n className=\"w-full resize-none bg-transparent px-4 pt-3 text-sm outline-none placeholder:text-zinc-400\"\n />\n <div className=\"flex items-center justify-between border-t border-zinc-100 px-3 py-2 dark:border-zinc-800\">\n <div className=\"flex items-center gap-1\">{actions}</div>\n <button\n type=\"button\"\n onClick={handleSubmit}\n disabled={disabled || !hasContent}\n className=\"rounded-lg bg-zinc-900 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-zinc-800 disabled:opacity-50 dark:bg-white dark:text-zinc-900 dark:hover:bg-zinc-100\"\n >\n Send\n </button>\n </div>\n </div>\n );\n },\n);\n\nComposer.displayName = \"Composer\";\n"]}
@@ -1,4 +1,4 @@
1
- import { useControllableState } from './chunk-6FQGMVF2.js';
1
+ import { useControllableState } from './chunk-EDYAXGUM.js';
2
2
  import { cn } from './chunk-MMW2JGKZ.js';
3
3
  import { createContext, useState, useMemo, useRef, useCallback, useEffect, Fragment as Fragment$1, useContext } from 'react';
4
4
  import { Loader2, ChevronRight, Search, X, ArrowUp, ArrowDown, Pencil, CircleAlert, RotateCw, FolderPlus } from 'lucide-react';
@@ -1079,5 +1079,5 @@ var FileBrowser = Object.assign(FileBrowserRoot, {
1079
1079
  });
1080
1080
 
1081
1081
  export { FileBrowser, FileBrowserNewFolder, useFileBrowser, validateFolderName };
1082
- //# sourceMappingURL=chunk-TQFQUNV3.js.map
1083
- //# sourceMappingURL=chunk-TQFQUNV3.js.map
1082
+ //# sourceMappingURL=chunk-2KAJ4L7C.js.map
1083
+ //# sourceMappingURL=chunk-2KAJ4L7C.js.map