@tempots/beatui 1.5.0 → 1.6.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 (184) hide show
  1. package/dist/ar-Wr6gMs-M.cjs +1 -0
  2. package/dist/{ar-C-kUt6f9.js → ar-fdUqbCvM.js} +154 -1
  3. package/dist/auth/index.cjs.js +1 -1
  4. package/dist/auth/index.es.js +1 -1
  5. package/dist/auth-divider-DewHpITQ.cjs +1 -0
  6. package/dist/{auth-divider-BIATan1F.js → auth-divider-qnJuYK-x.js} +7 -7
  7. package/dist/beatui.css +1711 -132
  8. package/dist/beatui.tailwind.css +1711 -132
  9. package/dist/better-auth/index.cjs.js +1 -1
  10. package/dist/better-auth/index.es.js +5 -5
  11. package/dist/{modal-BHlp4QeT.js → custom-validation-BetUqAEz.js} +186 -186
  12. package/dist/custom-validation-CLscGHY4.cjs +1 -0
  13. package/dist/{de-CP0kbElb.js → de-C5-k5Eov.js} +156 -3
  14. package/dist/de-DZqdSEta.cjs +1 -0
  15. package/dist/deep-merge-D90SW1Ci.cjs +1 -0
  16. package/dist/deep-merge-ZVigk5Qf.js +1765 -0
  17. package/dist/{duration-input-C5il_E0F.cjs → duration-input-4AQnQpyo.cjs} +1 -1
  18. package/dist/{duration-input-DoCCrqOG.js → duration-input-GMBmT1BE.js} +4 -4
  19. package/dist/{editor-toolbar-group-QVdBUbB8.cjs → editor-toolbar-group-C_ft_T8D.cjs} +1 -1
  20. package/dist/{editor-toolbar-group-DWUWUO-B.js → editor-toolbar-group-FpOHrmtx.js} +2 -2
  21. package/dist/es-CJgYfRap.cjs +1 -0
  22. package/dist/{es-BtIkcnsw.js → es-h6jmoF4X.js} +156 -3
  23. package/dist/fa-BQ5PzwNY.cjs +1 -0
  24. package/dist/{fa-11-rZmQ-.js → fa-BuxK837l.js} +154 -1
  25. package/dist/fr-Bv3TG44U.cjs +1 -0
  26. package/dist/{fr-C-L2F8w2.js → fr-BwILQ9G2.js} +165 -12
  27. package/dist/he-5LbvgMCC.cjs +1 -0
  28. package/dist/{he-Bu1xGoQ9.js → he-yC9Sc7JD.js} +154 -1
  29. package/dist/{hi-CewH-MAH.js → hi-Da7rcCpP.js} +154 -1
  30. package/dist/hi-YWhWcG_L.cjs +1 -0
  31. package/dist/{index-BGKz2Nol.js → index-DI8bf9oC.js} +175 -172
  32. package/dist/index-DeUj-5ph.cjs +1 -0
  33. package/dist/index.cjs.js +4 -4
  34. package/dist/index.es.js +11548 -8326
  35. package/dist/{input-container-CO3DNqpp.js → input-container-8JFB11xN.js} +1 -1
  36. package/dist/{input-container-BkPcNDaZ.cjs → input-container-CyOgiiQD.cjs} +1 -1
  37. package/dist/it-BxOIJE45.cjs +1 -0
  38. package/dist/{it-5hiKQO_p.js → it-Yeklau78.js} +156 -3
  39. package/dist/ja-CNhjK06P.cjs +1 -0
  40. package/dist/{ja-CGfEmZrm.js → ja-Dxj9Q5Yd.js} +155 -2
  41. package/dist/json-schema/index.cjs.js +1 -1
  42. package/dist/json-schema/index.es.js +10 -10
  43. package/dist/json-schema-display/index.cjs.js +1 -1
  44. package/dist/json-schema-display/index.es.js +1 -1
  45. package/dist/json-structure/index.cjs.js +1 -1
  46. package/dist/json-structure/index.es.js +5 -5
  47. package/dist/ko-DgkqcXTs.cjs +1 -0
  48. package/dist/{ko-DZthvREd.js → ko-gn_MsegK.js} +154 -1
  49. package/dist/lexical/index.cjs.js +1 -1
  50. package/dist/lexical/index.es.js +4 -4
  51. package/dist/nl-Dy9lmbBO.cjs +1 -0
  52. package/dist/{nl-CcKyHlQ7.js → nl-vHNFtXXb.js} +162 -9
  53. package/dist/{notice-BXKtBEiC.js → notice-B6ojfenv.js} +4 -4
  54. package/dist/{notice-BBnSXYUc.cjs → notice-p2IqXS5-.cjs} +1 -1
  55. package/dist/{oneof-branch-detection-DSzC0PkO.js → oneof-branch-detection-Q_jxvJIA.js} +1 -1
  56. package/dist/{oneof-branch-detection-BEkAezNi.cjs → oneof-branch-detection-xDDDdYRk.cjs} +1 -1
  57. package/dist/pl-BtYbtsmG.cjs +1 -0
  58. package/dist/{pl-Mwtjp4MV.js → pl-C0UdHla0.js} +184 -31
  59. package/dist/prosemirror/index.cjs.js +1 -1
  60. package/dist/prosemirror/index.es.js +4 -4
  61. package/dist/pt-CtNmqQ1X.cjs +1 -0
  62. package/dist/{pt-BaTsY-8f.js → pt-DGKtfN0d.js} +156 -3
  63. package/dist/ru-BaL_NPRU.cjs +1 -0
  64. package/dist/{ru-CvbGmz5s.js → ru-CpXYLt-v.js} +154 -1
  65. package/dist/tailwind/preset.cjs.js +1 -1
  66. package/dist/tailwind/preset.es.js +1 -1
  67. package/dist/tailwind/vite-plugin.cjs.js +1 -1
  68. package/dist/tailwind/vite-plugin.es.js +1 -1
  69. package/dist/{text-input-D_IxFd0M.cjs → text-input-DS5zlXb2.cjs} +1 -1
  70. package/dist/{text-input-BAn02BzO.js → text-input-NJypZSnE.js} +1 -1
  71. package/dist/{toolbar-CnecqhaU.cjs → toolbar-BBwfe8U9.cjs} +1 -1
  72. package/dist/{toolbar-BKan3NHw.js → toolbar-BF2L6WKC.js} +1 -1
  73. package/dist/{tr-YFqQdZjM.js → tr-DIFZDFW_.js} +156 -3
  74. package/dist/tr-DwOd87oB.cjs +1 -0
  75. package/dist/{translations-CxDUnbXn.js → translations-5cXBrENb.js} +1 -1
  76. package/dist/{translations-DT5QQ4WO.js → translations-BCMP-h52.js} +269 -115
  77. package/dist/{translations-C_-cObaF.cjs → translations-BqWc0ZHz.cjs} +1 -1
  78. package/dist/translations-EwEmHe3v.cjs +1 -0
  79. package/dist/types/beatui-i18n/default.d.ts +109 -0
  80. package/dist/types/beatui-i18n/locales/en.d.ts +109 -0
  81. package/dist/types/beatui-i18n/translations.d.ts +109 -0
  82. package/dist/types/components/button/copy-button.d.ts +42 -0
  83. package/dist/types/components/button/index.d.ts +1 -0
  84. package/dist/types/components/button/toggle-button-group.d.ts +2 -2
  85. package/dist/types/components/button/toggle-button.d.ts +2 -2
  86. package/dist/types/components/data/date-picker-shared.d.ts +2 -5
  87. package/dist/types/components/data/date-picker.d.ts +1 -1
  88. package/dist/types/components/data/date-range-picker.d.ts +1 -1
  89. package/dist/types/components/data/index.d.ts +3 -0
  90. package/dist/types/components/data/stat-card.d.ts +108 -0
  91. package/dist/types/components/data/time-picker.d.ts +54 -0
  92. package/dist/types/components/data/virtual-scrolling/index.d.ts +1 -0
  93. package/dist/types/components/data/virtual-scrolling/virtual-list.d.ts +91 -0
  94. package/dist/types/components/form/input/checkbox-input.d.ts +1 -1
  95. package/dist/types/components/form/input/color-input.d.ts +1 -1
  96. package/dist/types/components/form/input/color-picker/canvas-draw.d.ts +12 -0
  97. package/dist/types/components/form/input/color-picker/channel-picker.d.ts +71 -0
  98. package/dist/types/components/form/input/color-picker/hex-color-picker.d.ts +20 -0
  99. package/dist/types/components/form/input/color-picker/hsl-color-picker.d.ts +14 -0
  100. package/dist/types/components/form/input/color-picker/hwb-color-picker.d.ts +15 -0
  101. package/dist/types/components/form/input/color-picker/index.d.ts +7 -0
  102. package/dist/types/components/form/input/color-picker/oklch-color-picker.d.ts +15 -0
  103. package/dist/types/components/form/input/color-picker/rgb-color-picker.d.ts +17 -0
  104. package/dist/types/components/form/input/color-swatch-input.d.ts +1 -1
  105. package/dist/types/components/form/input/combobox-input.d.ts +1 -1
  106. package/dist/types/components/form/input/date-input.d.ts +1 -1
  107. package/dist/types/components/form/input/date-range-select-base.d.ts +23 -0
  108. package/dist/types/components/form/input/date-range-select.d.ts +64 -0
  109. package/dist/types/components/form/input/date-select.d.ts +52 -0
  110. package/dist/types/components/form/input/date-time-input.d.ts +1 -1
  111. package/dist/types/components/form/input/date-time-select-base.d.ts +23 -0
  112. package/dist/types/components/form/input/date-time-select.d.ts +66 -0
  113. package/dist/types/components/form/input/dropdown-input.d.ts +1 -1
  114. package/dist/types/components/form/input/email-input.d.ts +1 -1
  115. package/dist/types/components/form/input/index.d.ts +17 -0
  116. package/dist/types/components/form/input/nullable-date-select.d.ts +55 -0
  117. package/dist/types/components/form/input/nullable-date-time-select.d.ts +68 -0
  118. package/dist/types/components/form/input/nullable-time-select.d.ts +64 -0
  119. package/dist/types/components/form/input/number-input.d.ts +5 -40
  120. package/dist/types/components/form/input/number-stepper.d.ts +53 -0
  121. package/dist/types/components/form/input/open-date-range-select.d.ts +75 -0
  122. package/dist/types/components/form/input/otp-input.d.ts +2 -2
  123. package/dist/types/components/form/input/password-input.d.ts +1 -1
  124. package/dist/types/components/form/input/radio-group.d.ts +1 -1
  125. package/dist/types/components/form/input/range-slider.d.ts +4 -4
  126. package/dist/types/components/form/input/rating-input.d.ts +1 -1
  127. package/dist/types/components/form/input/segmented-input.d.ts +6 -2
  128. package/dist/types/components/form/input/segmented-select.d.ts +84 -0
  129. package/dist/types/components/form/input/slider-input.d.ts +2 -2
  130. package/dist/types/components/form/input/sortable-list.d.ts +68 -0
  131. package/dist/types/components/form/input/switch.d.ts +1 -1
  132. package/dist/types/components/form/input/text-area.d.ts +1 -1
  133. package/dist/types/components/form/input/text-input.d.ts +1 -1
  134. package/dist/types/components/form/input/time-format.d.ts +31 -0
  135. package/dist/types/components/form/input/time-select-base.d.ts +23 -0
  136. package/dist/types/components/form/input/time-select.d.ts +61 -0
  137. package/dist/types/components/form/input/transfer-list.d.ts +56 -0
  138. package/dist/types/components/form/input/tri-state-checkbox-input.d.ts +1 -1
  139. package/dist/types/components/form/input/url-input.d.ts +1 -1
  140. package/dist/types/components/layout/nine-slice-scroll-view.d.ts +1 -1
  141. package/dist/types/components/navigation/index.d.ts +1 -0
  142. package/dist/types/components/navigation/stepper.d.ts +102 -0
  143. package/dist/types/components/overlay/index.d.ts +1 -1
  144. package/dist/types/components/overlay/spotlight.d.ts +62 -0
  145. package/dist/types/utils/index.d.ts +0 -1
  146. package/dist/ur-D9nLchps.cjs +1 -0
  147. package/dist/{ur-CdnwwnG_.js → ur-DBst-TXc.js} +154 -1
  148. package/dist/{use-form-CP6nftVl.cjs → use-form-Dcra7GeE.cjs} +1 -1
  149. package/dist/{use-form-CmQdxpOi.js → use-form-NfobsGNl.js} +2 -2
  150. package/dist/{vi-Bwvz1d_n.js → vi-DQOJp32U.js} +183 -30
  151. package/dist/vi-Dg1aiMr5.cjs +1 -0
  152. package/dist/widget-customization-BtkexHgm.js +1458 -0
  153. package/dist/widget-customization-pqmtsraC.cjs +1 -0
  154. package/dist/{zh-hy7Uw6c5.js → zh-DPK4HXl2.js} +154 -1
  155. package/dist/zh-tbwSTbmn.cjs +1 -0
  156. package/package.json +9 -9
  157. package/dist/ar-Dc56zcjW.cjs +0 -1
  158. package/dist/auth-divider-CVKfA8Cp.cjs +0 -1
  159. package/dist/de-DboQlEC4.cjs +0 -1
  160. package/dist/deep-merge-B33Qtlmw.cjs +0 -1
  161. package/dist/deep-merge-BUsrE2v4.js +0 -1704
  162. package/dist/es-CAmE_0Ph.cjs +0 -1
  163. package/dist/fa-D9LrFZdW.cjs +0 -1
  164. package/dist/fr-DKogQyss.cjs +0 -1
  165. package/dist/he-CVx91Jdr.cjs +0 -1
  166. package/dist/hi-BgrHV72l.cjs +0 -1
  167. package/dist/index-DFF7Uahh.cjs +0 -1
  168. package/dist/it-B1rA1F9l.cjs +0 -1
  169. package/dist/ja-DZnjjqoi.cjs +0 -1
  170. package/dist/ko-CDnYKYWU.cjs +0 -1
  171. package/dist/modal-BmpfNL48.cjs +0 -1
  172. package/dist/nl-Bj8QnDEY.cjs +0 -1
  173. package/dist/pl-BmuuxxVd.cjs +0 -1
  174. package/dist/pt-RiC0yeVA.cjs +0 -1
  175. package/dist/ru-pRqtOQHF.cjs +0 -1
  176. package/dist/tr-B9JhBJeL.cjs +0 -1
  177. package/dist/translations-qefRsdGi.cjs +0 -1
  178. package/dist/types/components/overlay/command-palette.d.ts +0 -17
  179. package/dist/types/utils/color.d.ts +0 -346
  180. package/dist/ur-BZakU0iv.cjs +0 -1
  181. package/dist/vi-D1nly0nb.cjs +0 -1
  182. package/dist/widget-customization-B0y-eesp.cjs +0 -1
  183. package/dist/widget-customization-CKbR4Dsg.js +0 -1066
  184. package/dist/zh-DBk7sSD9.cjs +0 -1
@@ -1,1704 +0,0 @@
1
- import { Task as ye, Use as F, Value as p, prop as ae, html as g, attr as r, on as C, WithElement as te, Empty as M, aria as J, bind as ie, OnDispose as ne, coalesce as Ne, ForEach as ee, Fragment as N, Ensure as Pe, OneOfType as je, computedOf as A, input as se, emitValue as P, emitValueAsNumber as we, style as _e, When as U, NotEmpty as We, Repeat as Ze, signal as ke } from "@tempots/dom";
2
- import { I as W, a as He, B as be } from "./input-container-CO3DNqpp.js";
3
- import { C as q, m as qe } from "./text-input-BAn02BzO.js";
4
- import { F as Ae, m as Ye, c as Ge, C as oe, d as fe, e as Ce } from "./use-form-CmQdxpOi.js";
5
- import { B as O, d as ce, I as E, b as De, f as Ie } from "./translations-DT5QQ4WO.js";
6
- import { S as Le } from "./stack-BLMteGTn.js";
7
- import { objectEntries as Je, delayedAnimationFrame as Xe, strictEqual as K } from "@tempots/std";
8
- import { ElementRect as Qe } from "@tempots/ui";
9
- let pe = null;
10
- async function he() {
11
- const t = globalThis;
12
- return t.Temporal ? t.Temporal : (pe || (pe = import("./index.esm-By0m3ki1.js").then((e) => {
13
- const n = e.Temporal;
14
- return t.Temporal || (t.Temporal = n), n;
15
- })), pe);
16
- }
17
- const Ke = (t, e) => e ? ye(he, {
18
- then: t,
19
- pending: e.pending,
20
- error: e.error
21
- }) : ye(he, t);
22
- function de({
23
- onChange: t,
24
- value: e,
25
- accept: n = "*/*",
26
- enableClick: s = !0,
27
- content: l,
28
- disabled: h = !1,
29
- allowMultiple: o
30
- }) {
31
- return F(O, (d) => {
32
- const b = p.deriveProp(e ?? []), w = ae(!1), f = (a) => {
33
- a.preventDefault(), a.stopPropagation(), w.value = !0;
34
- }, m = (a) => {
35
- a.preventDefault(), a.stopPropagation(), (!a.currentTarget || !a.currentTarget.contains(a.relatedTarget)) && (w.value = !1);
36
- }, v = (a) => {
37
- a.preventDefault(), a.stopPropagation(), w.value = !1;
38
- const x = Array.from(a.dataTransfer?.files || []);
39
- x.length > 0 && (b.value = x, t(x, "dragdrop"));
40
- }, i = (a) => {
41
- p.get(s) && a.currentTarget.querySelector(
42
- 'input[type="file"]'
43
- )?.click();
44
- };
45
- let u = null;
46
- const D = () => {
47
- if (u == null) return;
48
- const a = Array.from(u.files ?? []);
49
- a.length > 0 && (b.value = a, t(a, "click")), u.value = "";
50
- }, S = (a) => {
51
- p.get(s) && (a.key === "Enter" || a.key === " ") && (a.preventDefault(), i(a));
52
- };
53
- return g.div(
54
- r.role("button"),
55
- r.tabindex(
56
- p.map(s, (a) => a ? 0 : -1)
57
- ),
58
- r.style("position: relative;"),
59
- C.dragover(f),
60
- C.dragleave(m),
61
- C.drop(v),
62
- C.click(i),
63
- C.keydown(S),
64
- // Hidden file input
65
- g.input(
66
- r.type("file"),
67
- r.disabled(h),
68
- r.accept(n),
69
- r.multiple(o),
70
- r.style(
71
- "position: absolute; left: -9999px; opacity: 0; pointer-events: none;"
72
- ),
73
- C.change(D),
74
- te((a) => (u = a, b.on((x) => {
75
- const $ = globalThis.DataTransfer;
76
- if ($ != null) {
77
- const I = new $();
78
- x.forEach((V) => I.items.add(V)), a.files = I.files;
79
- }
80
- }), M))
81
- ),
82
- // Screen reader instructions
83
- J.label(ie(d.$.dropZoneInstructions)(s)),
84
- // Content
85
- l({
86
- files: b,
87
- clear: () => b.value = [],
88
- change: (a) => b.set(a)
89
- })
90
- );
91
- });
92
- }
93
- const ge = "$$tts-exp-", et = (t, e) => te((n) => {
94
- const s = `${ge}${t}`;
95
- return ne(p.on(e, (l) => Reflect.set(n, s, l)));
96
- }), $t = (t, e) => {
97
- const n = `${ge}${t}`;
98
- return (s) => {
99
- e(Reflect.get(s.target, n));
100
- };
101
- }, $e = (t, e) => {
102
- const n = `${ge}${t}`;
103
- return (s) => {
104
- const l = s.target, h = l.selectedIndex, o = l.options[h];
105
- e(Reflect.get(o, n));
106
- };
107
- }, Ue = (t, e, n) => Pe(
108
- t,
109
- (s) => je(s, {
110
- value: (l) => {
111
- const h = A(
112
- l,
113
- n
114
- )((o, d) => e(o.value, d));
115
- return g.option(
116
- r.selected(h),
117
- et("value", l.$.value),
118
- l.$.label
119
- );
120
- },
121
- group: (l) => g.optgroup(
122
- r.label(l.$.group),
123
- ee(
124
- l.$.options,
125
- (h) => Ue(
126
- h,
127
- e,
128
- n
129
- )
130
- )
131
- ),
132
- break: () => g.hr()
133
- })
134
- ), tt = (t) => {
135
- const {
136
- value: e,
137
- onBlur: n,
138
- onChange: s,
139
- onInput: l,
140
- options: h,
141
- unselectedLabel: o,
142
- equality: d = (f, m) => f === m,
143
- after: b
144
- } = t;
145
- let w;
146
- return W(
147
- {
148
- ...t,
149
- after: N(
150
- He({
151
- icon: "ph:caret-up-down-bold",
152
- color: "neutral",
153
- size: "sm"
154
- }),
155
- b
156
- ),
157
- input: g.select(
158
- te((f) => {
159
- w = f;
160
- const m = new MutationObserver((v) => {
161
- const { removedNodes: i } = v[0];
162
- i.length > 0 && (w.selectedIndex = 0);
163
- });
164
- return m.observe(f, { childList: !0 }), ne(() => m.disconnect());
165
- }),
166
- q(t),
167
- r.class("bc-native-select bc-input"),
168
- F(
169
- O,
170
- (f) => g.option(
171
- r.hidden("hidden"),
172
- Ne(o, f.$.selectOne)
173
- )
174
- ),
175
- ee(h, (f) => Ue(f, d, e)),
176
- n != null ? C.blur(n) : M,
177
- s != null ? C.change($e("value", (f) => s(f))) : M,
178
- l != null ? C.input($e("value", (f) => l(f))) : M
179
- )
180
- },
181
- C.click(() => {
182
- if (w?.focus(), typeof w?.showPicker == "function")
183
- try {
184
- w.showPicker();
185
- } catch {
186
- }
187
- })
188
- );
189
- };
190
- function nt(t) {
191
- const { controller: e, onChange: n, onBlur: s, ...l } = t;
192
- return tt({
193
- ...l,
194
- value: e.signal,
195
- onChange: Ge(e, n),
196
- onBlur: Ye(e, s)
197
- });
198
- }
199
- function Mt(t) {
200
- return Ae({
201
- ...t,
202
- content: nt(t)
203
- });
204
- }
205
- function Ee(t, e, n) {
206
- const s = p.map(t, (o) => o != null), l = A(
207
- s,
208
- e ?? !1
209
- )((o, d) => !o || d), h = ce.clearValue;
210
- return g.button(
211
- r.type("button"),
212
- r.class("bc-input-container__reset"),
213
- J.label(h),
214
- r.title(h),
215
- r.disabled(l),
216
- E({ icon: "mdi:close", size: "sm" }),
217
- C.click((o) => {
218
- o.stopPropagation(), n?.(null);
219
- })
220
- );
221
- }
222
- function Me(...t) {
223
- return g.div(r.class("bc-group"), ...t);
224
- }
225
- function st(t) {
226
- const e = String(t), n = e.indexOf(".");
227
- return n === -1 ? 0 : e.length - n - 1;
228
- }
229
- function G(t, e) {
230
- const n = st(e);
231
- if (n === 0) return Math.round(t);
232
- const s = Math.pow(10, n);
233
- return Math.round(t * s) / s;
234
- }
235
- const St = (t) => {
236
- const { value: e, step: n, min: s, max: l, onBlur: h, onChange: o, onInput: d, after: b } = t, w = (v) => {
237
- const i = s != null ? p.get(s) : void 0, u = l != null ? p.get(l) : void 0;
238
- return i != null && v < i ? i : u != null && v > u ? u : v;
239
- }, f = n != null ? F(O, (v) => {
240
- const i = A(
241
- e,
242
- s
243
- )((a, x) => x == null ? !0 : (a ?? 0) > x), u = A(
244
- e,
245
- l
246
- )((a, x) => x == null ? !0 : (a ?? 0) < x), D = (a) => {
247
- const x = p.get(e) ?? 0, $ = p.get(n), I = a?.shiftKey ? 10 : 1, V = G(
248
- x - $ * I,
249
- $
250
- ), k = s != null ? p.get(s) : void 0;
251
- if (k != null && V < k)
252
- return;
253
- const c = w(V);
254
- c !== x && (o?.(c), d?.(c));
255
- }, S = (a) => {
256
- const x = p.get(e) ?? 0, $ = p.get(n), I = a?.shiftKey ? 10 : 1, V = G(
257
- x + $ * I,
258
- $
259
- ), k = l != null ? p.get(l) : void 0;
260
- if (k != null && V > k)
261
- return;
262
- const c = w(V);
263
- c !== x && (o?.(c), d?.(c));
264
- };
265
- return Le(
266
- r.class("bc-number-input-steppers"),
267
- // Increment second
268
- g.button(
269
- r.type("button"),
270
- r.class(
271
- "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--increment"
272
- ),
273
- r.disabled(
274
- A(
275
- u,
276
- t.disabled ?? !1
277
- )((a, x) => !a || x)
278
- ),
279
- C.click((a) => S(a)),
280
- J.label(v.$.incrementValue),
281
- E({ icon: "line-md:plus", size: "xs" })
282
- ),
283
- // Decrement first (matches tests expecting first button to be decrement)
284
- g.button(
285
- r.type("button"),
286
- r.class(
287
- "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--decrement"
288
- ),
289
- r.disabled(
290
- A(
291
- i,
292
- t.disabled ?? !1
293
- )((a, x) => !a || x)
294
- ),
295
- C.click((a) => D(a)),
296
- J.label(v.$.decrementValue),
297
- E({ icon: "line-md:minus", size: "xs" })
298
- )
299
- );
300
- }) : null, m = b != null && f != null ? N(f, b) : b ?? f;
301
- return W({
302
- ...t,
303
- input: se.number(
304
- s != null ? r.min(s) : M,
305
- l != null ? r.max(l) : M,
306
- q(t),
307
- r.valueAsNumber(e),
308
- r.step(n),
309
- r.class("bc-input bc-number-input"),
310
- h != null ? C.blur(P(h)) : M,
311
- o != null ? C.change(we(o)) : M,
312
- d != null ? C.input(we(d)) : M,
313
- // Add wheel event support when step is defined
314
- n != null ? C.wheel((v) => {
315
- v.preventDefault();
316
- const i = p.get(e) ?? 0, u = p.get(n), D = v.shiftKey ? 10 : 1, S = v.deltaY < 0 ? u * D : -u * D, a = w(G(i + S, u));
317
- a !== i && (o?.(a), d?.(a));
318
- }) : M
319
- ),
320
- after: m
321
- });
322
- };
323
- function lt(t, e) {
324
- return t.length === e.length && t.every((n, s) => n === e[s]);
325
- }
326
- function rt(t, e, n) {
327
- const s = ["bc-segmented-input", `bc-segmented-input--size-${t}`];
328
- return n === "squared" && s.push("bc-segmented-input--squared"), e && s.push("bc-segmented-input--disabled"), s.join(" ");
329
- }
330
- function it(t) {
331
- if (t == null) return "";
332
- const e = /* @__PURE__ */ new Map(), n = De(t, "solid", "light"), s = De(t, "solid", "dark");
333
- return e.set("--si-indicator-bg", n.backgroundColor), e.set("--si-active-text", n.textColor), e.set("--si-indicator-bg-dark", s.backgroundColor), e.set("--si-active-text-dark", s.textColor), Array.from(e.entries()).map(([l, h]) => `${l}: ${h}`).join("; ");
334
- }
335
- function Tt({
336
- options: t,
337
- value: e,
338
- onChange: n,
339
- size: s = "md",
340
- disabled: l = !1,
341
- variant: h = "pill",
342
- color: o
343
- }, ...d) {
344
- const b = Je(t).map(([w, f]) => ({
345
- key: w,
346
- label: f
347
- }));
348
- return te(() => {
349
- const w = Object.fromEntries(
350
- b.map((m, v) => [m.key, v])
351
- ), f = ae(
352
- b.map(() => ({ left: 0, width: 0 })),
353
- lt
354
- );
355
- return g.div(
356
- r.class(
357
- A(
358
- s,
359
- l,
360
- h
361
- )(
362
- (m, v, i) => rt(
363
- m ?? "md",
364
- v ?? !1,
365
- i ?? "pill"
366
- )
367
- )
368
- ),
369
- r.style(
370
- o != null ? p.map(o, (m) => it(m)) : ""
371
- ),
372
- g.div(
373
- r.class("bc-segmented-input__container"),
374
- g.div(
375
- r.class("bc-segmented-input__indicator"),
376
- _e.width(
377
- A(
378
- e,
379
- f
380
- )((m, v) => {
381
- const { width: i } = v[w[m] ?? 0];
382
- return `${i}px`;
383
- })
384
- ),
385
- _e.left(
386
- A(
387
- e,
388
- f
389
- )((m, v) => {
390
- const { left: i } = v[w[m] ?? 0];
391
- return `${i}px`;
392
- })
393
- )
394
- ),
395
- // clickable buttons
396
- b.map(({ label: m, key: v }, i) => g.button(
397
- r.type("button"),
398
- C.click((u) => {
399
- u.preventDefault(), p.get(l) || n?.(v);
400
- }),
401
- r.disabled(l),
402
- r.class("bc-segmented-input__segment"),
403
- r.class(
404
- p.map(e, (u) => u === v ? "bc-segmented-input__segment--active" : "bc-segmented-input__segment--inactive")
405
- ),
406
- Qe((u) => {
407
- function D() {
408
- f.update((a) => {
409
- const x = [...a];
410
- return x[i] = {
411
- width: u.value.width,
412
- left: u.value.localLeft
413
- }, x;
414
- });
415
- }
416
- const S = Xe(D);
417
- return ne(S, u.on(D));
418
- }),
419
- m
420
- ))
421
- ),
422
- ...d
423
- );
424
- });
425
- }
426
- function ot(t) {
427
- const e = t.type.toLowerCase();
428
- return e.startsWith("image/") && (e.includes("jpeg") || e.includes("jpg") || e.includes("png") || e.includes("gif") || e.includes("webp") || e.includes("svg"));
429
- }
430
- function ct(t) {
431
- const e = t.type.toLowerCase();
432
- return e.startsWith("image/") ? "vscode-icons:file-type-image" : e.startsWith("video/") ? "vscode-icons:file-type-video" : e.startsWith("audio/") ? "vscode-icons:file-type-audio" : e.includes("pdf") ? "vscode-icons:file-type-pdf2" : e.includes("word") || e.includes("document") ? "vscode-icons:file-type-word" : e.includes("excel") || e.includes("spreadsheet") ? "vscode-icons:file-type-excel" : e.includes("powerpoint") || e.includes("presentation") ? "vscode-icons:file-type-powerpoint" : e.includes("zip") || e.includes("archive") ? "vscode-icons:file-type-zip" : e.includes("text") ? "vscode-icons:file-type-text" : e.includes("json") ? "vscode-icons:file-type-json-official" : e.includes("csv") ? "vscode-icons:file-type-csv" : e.includes("xml") ? "vscode-icons:file-type-xml" : e.includes("yaml") ? "vscode-icons:file-type-yaml-official" : "vscode-icons:file-type-binary";
433
- }
434
- function me(t) {
435
- return U(
436
- t.map(ot),
437
- () => {
438
- const e = ae(null);
439
- return t.on((n) => {
440
- e.value && URL.revokeObjectURL(e.value);
441
- const s = URL.createObjectURL(n);
442
- e.value = s;
443
- }), g.div(
444
- ne(() => {
445
- e.value && URL.revokeObjectURL(e.value);
446
- }),
447
- r.class("bc-file-input__thumbnail-container"),
448
- g.img(
449
- r.src(e),
450
- r.alt(t.map((n) => n.name)),
451
- r.class("bc-file-input__thumbnail")
452
- )
453
- );
454
- },
455
- () => E({ icon: t.map(ct) })
456
- );
457
- }
458
- const zt = (t, ...e) => {
459
- const {
460
- value: n = ae([]),
461
- accept: s = "*/*",
462
- maxFiles: l,
463
- maxFileSize: h,
464
- onChange: o,
465
- onBlur: d,
466
- disabled: b,
467
- hasError: w,
468
- mode: f = "default",
469
- showFileList: m = !0,
470
- ...v
471
- } = t, i = n, u = p.map(f, (k) => k === "input"), D = p.map(f, (k) => k === "compact"), S = (k) => {
472
- let c = k;
473
- if (l != null) {
474
- const y = p.get(l);
475
- c = c.slice(0, y);
476
- }
477
- if (h) {
478
- const y = p.get(h);
479
- c = c.filter((T) => T.size <= y);
480
- }
481
- o?.(c);
482
- }, a = (k) => {
483
- const y = i.value.filter((T, z) => z !== k);
484
- o?.(y);
485
- }, x = () => {
486
- o?.([]);
487
- }, $ = ({
488
- files: k,
489
- clear: c,
490
- change: y
491
- }) => F(
492
- O,
493
- (T) => g.div(
494
- r.class("bc-file-input__drop-zone"),
495
- g.div(
496
- r.class(
497
- "bc-file-input__drop-zone-content bc-file-input__drop-zone-content--empty"
498
- ),
499
- E({ icon: "mdi:cloud-upload-outline", size: "xl" }),
500
- g.div(
501
- r.class("bc-file-input__drop-zone-text"),
502
- ie(T.$.filesInputInstructions)(
503
- l,
504
- h,
505
- T.$.fileSizeUnits.value
506
- )
507
- )
508
- )
509
- )
510
- ), I = ({
511
- files: k
512
- }) => F(
513
- O,
514
- (c) => g.div(
515
- r.class("bc-file-input__compact-drop-zone"),
516
- U(
517
- k.map((y) => y.length > 0),
518
- () => g.div(
519
- r.class("bc-file-input__compact-file-list"),
520
- ee(k, (y, T) => {
521
- const z = T.index;
522
- return g.div(
523
- r.class("bc-file-input__compact-file-item"),
524
- g.div(
525
- r.class("bc-file-input__compact-file-icon"),
526
- me(y)
527
- ),
528
- g.div(
529
- r.class("bc-file-input__compact-file-info"),
530
- g.div(
531
- r.class("bc-file-input__compact-file-name"),
532
- r.title(y.$.name),
533
- y.$.name
534
- ),
535
- g.div(
536
- r.class("bc-file-input__compact-file-meta"),
537
- A(
538
- y.$.size,
539
- c.$.fileSizeUnits
540
- )((_, B) => Ie(_, { units: B })),
541
- " • ",
542
- A(
543
- y.$.type,
544
- c.$.unknownType
545
- )((_, B) => _ || B)
546
- )
547
- ),
548
- oe(
549
- {
550
- size: "sm",
551
- label: c.$.removeFile,
552
- disabled: b,
553
- onClick: () => a(z)
554
- },
555
- r.class("bc-file-input__compact-remove-button")
556
- )
557
- );
558
- })
559
- ),
560
- () => g.div(
561
- r.class("bc-file-input__compact-placeholder"),
562
- E({ icon: "mdi:cloud-upload-outline", size: "lg" }),
563
- g.div(
564
- r.class("bc-file-input__compact-placeholder-text"),
565
- ie(c.$.filesInputInstructions)(
566
- l,
567
- h,
568
- c.$.fileSizeUnits.value
569
- )
570
- )
571
- )
572
- )
573
- )
574
- ), V = ({
575
- files: k
576
- }) => F(
577
- O,
578
- (c) => g.div(
579
- r.class("bc-file-input__compact-input"),
580
- U(
581
- k.map((y) => y.length > 0),
582
- () => g.span(
583
- r.class("bc-file-input__compact-value"),
584
- ee(
585
- k,
586
- (y) => g.span(
587
- r.class("bc-file-input__compact-value-item"),
588
- me(y),
589
- g.span(
590
- r.class("bc-file-input__compact-value-item-name"),
591
- y.$.name
592
- )
593
- )
594
- )
595
- ),
596
- () => g.span(
597
- r.class("bc-file-input__compact-placeholder"),
598
- E({ icon: "mdi:cloud-upload-outline", size: "md" }),
599
- " ",
600
- ie(c.$.filesInputInstructions)(
601
- l,
602
- h,
603
- c.$.fileSizeUnits.value
604
- )
605
- )
606
- )
607
- )
608
- );
609
- return F(
610
- O,
611
- (k) => W(
612
- {
613
- baseContainer: p.map(u, (c) => !c),
614
- disabled: b,
615
- hasError: w,
616
- after: U(
617
- u,
618
- () => U(
619
- i.map(({ length: c }) => c > 0),
620
- () => oe(
621
- {
622
- size: "sm",
623
- label: k.$.clearAllFiles,
624
- disabled: b,
625
- onClick: x
626
- },
627
- r.class("bc-file-input__compact-clear")
628
- )
629
- )
630
- ),
631
- ...v,
632
- input: U(
633
- u,
634
- () => g.div(
635
- r.class("bc-file-input bc-file-input--input"),
636
- de({
637
- value: i,
638
- accept: s,
639
- enableClick: !0,
640
- allowMultiple: p.map(l ?? 1 / 0, (c) => c > 1),
641
- disabled: b,
642
- onChange: S,
643
- content: V
644
- })
645
- ),
646
- () => U(
647
- D,
648
- () => g.div(
649
- r.class("bc-file-input bc-file-input--compact"),
650
- de({
651
- value: i,
652
- accept: s,
653
- enableClick: !0,
654
- allowMultiple: p.map(l ?? 1 / 0, (c) => c > 1),
655
- disabled: b,
656
- onChange: S,
657
- content: I
658
- })
659
- ),
660
- () => g.div(
661
- r.class("bc-file-input"),
662
- de({
663
- value: i,
664
- accept: s,
665
- enableClick: !0,
666
- allowMultiple: p.map(l ?? 1 / 0, (c) => c > 1),
667
- disabled: b,
668
- onChange: S,
669
- content: $
670
- }),
671
- U(
672
- m,
673
- () => We(
674
- i,
675
- () => N(
676
- g.div(
677
- r.class("bc-file-input__file-list"),
678
- ee(i, (c, y) => {
679
- const T = y.index;
680
- return g.div(
681
- r.class("bc-file-input__file-item"),
682
- g.div(
683
- r.class("bc-file-input__file-icon"),
684
- me(c)
685
- ),
686
- g.div(
687
- r.class("bc-file-input__file-info"),
688
- g.div(
689
- r.class("bc-file-input__file-name"),
690
- r.title(c.$.name),
691
- c.$.name
692
- ),
693
- g.div(
694
- r.class("bc-file-input__file-meta"),
695
- A(
696
- c.$.size,
697
- k.$.fileSizeUnits
698
- )(
699
- (z, _) => Ie(z, { units: _ })
700
- ),
701
- " • ",
702
- A(
703
- c.$.type,
704
- k.$.unknownType
705
- )((z, _) => z || _)
706
- )
707
- ),
708
- oe(
709
- {
710
- size: "sm",
711
- label: k.$.removeFile,
712
- disabled: b,
713
- onClick: () => a(T)
714
- },
715
- r.class("bc-file-input__remove-button")
716
- )
717
- );
718
- })
719
- ),
720
- U(
721
- i.map(({ length: c }) => c > 1),
722
- () => g.div(
723
- r.class(
724
- "bc-file-input__clear-all-button-container"
725
- ),
726
- g.button(
727
- r.type("button"),
728
- r.class("bc-file-input__clear-all-button"),
729
- r.disabled(b),
730
- k.$.clearAllFiles,
731
- C.click((c) => {
732
- c.preventDefault(), c.stopPropagation(), x();
733
- })
734
- )
735
- )
736
- )
737
- )
738
- )
739
- )
740
- )
741
- )
742
- )
743
- },
744
- ...e
745
- )
746
- );
747
- };
748
- function at(t, e, n) {
749
- const s = t.length.map((l) => l);
750
- return Ze(
751
- s,
752
- (l) => {
753
- const h = t.item(l.index), o = [];
754
- return N(
755
- ne(() => {
756
- o.forEach((d) => d());
757
- }),
758
- e({
759
- list: t,
760
- item: h,
761
- position: l,
762
- remove: () => t.removeAt(l.index),
763
- move: (d) => {
764
- switch (d) {
765
- case "up":
766
- if (l.index === 0) return;
767
- t.move(l.index, l.index - 1);
768
- break;
769
- case "down":
770
- if (l.index === t.length.value - 1) return;
771
- t.move(l.index, l.index + 1);
772
- break;
773
- case "first":
774
- t.move(l.index, 0);
775
- break;
776
- case "last":
777
- t.move(l.index, t.length.value - 1);
778
- }
779
- },
780
- canMove: (d) => {
781
- const b = (() => {
782
- switch (d) {
783
- case "up":
784
- return ke(l.index > 0);
785
- case "down":
786
- return t.length.map((w) => l.index < w - 1);
787
- }
788
- })();
789
- return o.push(() => b.dispose()), b;
790
- },
791
- cannotMove: (d) => {
792
- const b = (() => {
793
- switch (d) {
794
- case "up":
795
- return ke(l.index === 0);
796
- case "down":
797
- return t.length.map((w) => l.index === w - 1);
798
- }
799
- })();
800
- return o.push(() => b.dispose()), b;
801
- }
802
- })
803
- );
804
- },
805
- n
806
- );
807
- }
808
- const Se = {
809
- 9: { pattern: /^[0-9]$/ },
810
- A: { pattern: /^[A-Za-z]$/, transform: (t) => t.toUpperCase() },
811
- "*": { pattern: /^.$/ }
812
- }, ut = (t) => t instanceof RegExp;
813
- function Fe(t, e, n) {
814
- if (t == null) return [];
815
- const s = n ? { ...Se, ...e } : e ?? Se, l = (o, d) => {
816
- const b = s[d];
817
- b ? o.push({ type: "pattern", name: d, ...b }) : o.push({ type: "literal", char: d });
818
- }, h = [];
819
- if (typeof t == "string") {
820
- for (const o of t) l(h, o);
821
- return h;
822
- }
823
- for (const o of t)
824
- if (typeof o == "string")
825
- if (o.length <= 1) l(h, o);
826
- else for (const d of o) l(h, d);
827
- else ut(o) ? h.push({ type: "pattern", pattern: o }) : typeof o == "object" && o && h.push(o);
828
- return h;
829
- }
830
- function ft(t, e) {
831
- return (n) => {
832
- switch (t) {
833
- case "digits":
834
- return /[0-9]/.test(n);
835
- case "letters":
836
- return /[A-Za-z]/.test(n);
837
- case "alphanumeric":
838
- return /[A-Za-z0-9]/.test(n);
839
- case "custom":
840
- return e?.(n) ?? !0;
841
- default:
842
- return !0;
843
- }
844
- };
845
- }
846
- function Te(t, e, n, s, l, h) {
847
- const o = {
848
- raw: t,
849
- previousConformed: e,
850
- cursor: l ?? t.length,
851
- completed: !1
852
- }, d = s.definitions ?? {}, b = typeof n == "function" ? n(t, o) : n, w = Fe(
853
- b,
854
- d,
855
- s.useDefaultDefinitions ?? !0
856
- ), f = ft(s.allowMode, s.allow), m = /* @__PURE__ */ new Set();
857
- for (const _ of w) _.type === "literal" && m.add(_.char);
858
- if (s.prefix) for (const _ of s.prefix) m.add(_);
859
- if (s.suffix) for (const _ of s.suffix) m.add(_);
860
- const v = Array.from(t).filter((_) => f(_) && !m.has(_));
861
- if (v.length === 0) return { value: "", cursor: 0, completed: !1 };
862
- const i = [], u = [];
863
- let D = 0, S = 0, a = 0, x = -1;
864
- for (const _ of w) {
865
- if (_.type === "literal") {
866
- i.push(_.char), u.push({ kind: "literal", filled: !0 });
867
- continue;
868
- }
869
- S += _.optional ? 0 : 1;
870
- const B = v[D];
871
- if (B == null)
872
- break;
873
- if (_.type === "any") {
874
- a++, i.push(_.transform ? _.transform(B) : B), u.push({ kind: "slot", filled: !0 }), x = u.length - 1, D++;
875
- continue;
876
- }
877
- if (_.type === "pattern")
878
- if (_.pattern.test(B)) {
879
- a++;
880
- const R = _.transform ? _.transform(B) : B;
881
- i.push(R), u.push({ kind: "slot", filled: !0 }), x = u.length - 1, D++;
882
- } else {
883
- D++;
884
- continue;
885
- }
886
- }
887
- const $ = i.join(""), I = (s.prefix ?? "") + $ + (s.suffix ?? "");
888
- let k = (s.prefix ?? "").length;
889
- if (x >= 0) {
890
- let _ = x + 1;
891
- if ((h?.policy ?? "smart") !== "sticky")
892
- for (; _ < u.length && u[_].kind === "literal"; ) _++;
893
- k += _;
894
- }
895
- const c = s.completion?.mode === "min" ? (s.completion.minChars ?? 0) <= a : s.completion?.mode === "custom" ? !!s.completion.isComplete?.(I) : S > 0 && a >= S, y = s.pipe?.(I, { ...o, completed: c });
896
- let T, z = k;
897
- return y === !1 ? (T = e, z = e.length) : typeof y == "string" ? (T = y, z = y.length) : typeof y == "object" && y ? (T = y.value, z = y.cursor ?? y.value.length) : T = I, { value: T, cursor: z, completed: c };
898
- }
899
- function pt(t, e) {
900
- const n = e?.strategy ?? "none";
901
- return n === "custom" && e?.unmask ? e.unmask(t) : n === "strip" ? t.replace(/[^A-Za-z0-9]/g, "") : t;
902
- }
903
- const Oe = (t) => {
904
- const {
905
- value: e,
906
- onBlur: n,
907
- onChange: s,
908
- onInput: l,
909
- onAccept: h,
910
- onComplete: o,
911
- mask: d,
912
- definitions: b,
913
- useDefaultDefinitions: w,
914
- extraLiterals: f,
915
- prefix: m,
916
- suffix: v,
917
- autofix: i,
918
- pipe: u,
919
- completion: D,
920
- unmask: S,
921
- allowMode: a,
922
- allow: x,
923
- placeholder: $,
924
- placeholderOptions: I
925
- } = t, V = A(
926
- e,
927
- d,
928
- b,
929
- w,
930
- f,
931
- m,
932
- v,
933
- i,
934
- D,
935
- S,
936
- a,
937
- $,
938
- I
939
- )((c, y, T, z, _, B, R, X, Q, Y, Z, le, j) => y ? Te(c ?? "", "", y, {
940
- definitions: T ?? {},
941
- useDefaultDefinitions: z ?? !0,
942
- extraLiterals: _ ?? [],
943
- autofix: X ?? "none",
944
- completion: Q ?? { mode: "mask" },
945
- pipe: u ?? ((L) => L),
946
- unmask: Y ?? { strategy: "none" },
947
- allowMode: Z ?? "all",
948
- allow: x,
949
- prefix: B,
950
- suffix: R
951
- }).value : c ?? ""), k = (c, y) => {
952
- const T = c.value ?? "", z = p.get(e) ?? "", _ = d != null ? p.get(d) : null, B = b != null ? p.get(b) : void 0, R = w != null ? p.get(w) : void 0, X = f != null ? p.get(f) : void 0, Q = i != null ? p.get(i) : void 0, Y = D != null ? p.get(D) : void 0, Z = S != null ? p.get(S) : void 0, le = a != null ? p.get(a) : void 0, j = m != null ? p.get(m) : void 0, L = v != null ? p.get(v) : void 0, {
953
- value: H,
954
- cursor: ue,
955
- completed: ve
956
- } = _ ? Te(
957
- T,
958
- z,
959
- _,
960
- {
961
- definitions: B ?? {},
962
- useDefaultDefinitions: R ?? !0,
963
- extraLiterals: X ?? [],
964
- autofix: Q ?? "none",
965
- completion: Y ?? { mode: "mask" },
966
- pipe: u ?? ((Re) => Re),
967
- unmask: Z ?? { strategy: "none" },
968
- allowMode: le ?? "all",
969
- allow: x,
970
- prefix: j,
971
- suffix: L
972
- },
973
- c.selectionStart ?? T.length,
974
- t.cursor ? p.get(t.cursor) : void 0
975
- ) : { value: T, cursor: T.length, completed: !0 };
976
- if (H !== T) {
977
- c.value = H;
978
- try {
979
- c.setSelectionRange(ue, ue);
980
- } catch {
981
- }
982
- }
983
- const xe = pt(H, Z);
984
- h?.({
985
- raw: xe,
986
- conformed: H,
987
- completed: ve,
988
- cursor: ue
989
- }), y === "input" ? l?.(H) : (s?.(H), ve && o?.({ raw: xe, conformed: H }));
990
- };
991
- return W({
992
- ...t,
993
- input: se.text(
994
- q(t),
995
- r.value(V),
996
- r.class("bc-input"),
997
- n != null ? C.blur(n) : M,
998
- te(
999
- (c) => c instanceof HTMLInputElement ? N(
1000
- C.input(() => k(c, "input")),
1001
- C.change(() => k(c, "change")),
1002
- C.keydown((y) => {
1003
- if (y.key !== "Backspace" || !(t.cursor ? p.get(t.cursor)?.backspaceRubberBand ?? !0 : !0)) return;
1004
- const z = c.selectionStart ?? 0, _ = c.selectionEnd ?? z;
1005
- if (z !== _ || z <= 0) return;
1006
- const B = c.value ?? "", R = d != null ? p.get(d) : null;
1007
- if (!R) return;
1008
- const X = b != null ? p.get(b) : void 0, Q = w != null ? p.get(w) : !0, Y = m != null ? p.get(m) : void 0, Z = v != null ? p.get(v) : void 0, le = Fe(
1009
- typeof R == "function" ? R(B, {
1010
- raw: B,
1011
- previousConformed: B,
1012
- cursor: z,
1013
- completed: !1
1014
- }) : R,
1015
- X ?? {},
1016
- Q ?? !0
1017
- ), j = /* @__PURE__ */ new Set();
1018
- for (const L of le)
1019
- L.type === "literal" && j.add(L.char);
1020
- if (Y) for (const L of Y) j.add(L);
1021
- if (Z) for (const L of Z) j.add(L);
1022
- if (j.has(B[z - 1])) {
1023
- let L = z - 1;
1024
- for (; L >= 0 && j.has(B[L]); ) L--;
1025
- L >= 0 && (y.preventDefault(), y.stopPropagation(), c.value = B.slice(0, L) + B.slice(L + 1), k(c, "input"));
1026
- }
1027
- })
1028
- ) : M
1029
- )
1030
- )
1031
- });
1032
- }, Bt = (t) => {
1033
- const { value: e, onBlur: n, onChange: s, onInput: l, rows: h } = t;
1034
- return W({
1035
- ...t,
1036
- input: g.textarea(
1037
- q(t),
1038
- r.rows(h ?? 3),
1039
- r.value(e),
1040
- r.class("bc-input"),
1041
- n != null ? C.blur(P(n)) : M,
1042
- s != null ? C.change(P(s)) : M,
1043
- l != null ? C.input(P(l)) : M
1044
- )
1045
- });
1046
- }, ze = (t) => {
1047
- if (t == null || t === "") return null;
1048
- const e = Number(t);
1049
- return Number.isNaN(e) ? null : e;
1050
- }, Vt = (t) => {
1051
- const { value: e, step: n, min: s, max: l, onBlur: h, onChange: o, onInput: d, after: b } = t, w = (i) => {
1052
- const u = s != null ? p.get(s) : void 0, D = l != null ? p.get(l) : void 0;
1053
- return u != null && i < u ? u : D != null && i > D ? D : i;
1054
- }, f = (() => {
1055
- if (n == null) return null;
1056
- const i = A(
1057
- e,
1058
- s
1059
- )((x, $) => {
1060
- const I = x ?? 0;
1061
- return $ == null ? !0 : I > $;
1062
- }), u = A(
1063
- e,
1064
- l
1065
- )((x, $) => {
1066
- const I = x ?? 0;
1067
- return $ == null ? !0 : I < $;
1068
- }), D = (x) => {
1069
- const $ = p.get(e) ?? 0, I = p.get(n), V = x?.shiftKey ? 10 : 1, k = G($ - I * V, I), c = s != null ? p.get(s) : void 0;
1070
- if (c != null && k < c) return;
1071
- const y = w(k);
1072
- y !== $ && (o?.(y), d?.(y));
1073
- }, S = (x) => {
1074
- const $ = p.get(e) ?? 0, I = p.get(n), V = x?.shiftKey ? 10 : 1, k = G($ + I * V, I), c = l != null ? p.get(l) : void 0;
1075
- if (c != null && k > c) return;
1076
- const y = w(k);
1077
- y !== $ && (o?.(y), d?.(y));
1078
- };
1079
- return ((x, $) => Le(
1080
- r.class("bc-number-input-steppers"),
1081
- g.button(
1082
- r.type("button"),
1083
- r.class(
1084
- "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--increment"
1085
- ),
1086
- r.disabled(
1087
- A(
1088
- u,
1089
- t.disabled ?? !1
1090
- )((I, V) => !I || V)
1091
- ),
1092
- C.click((I) => S(I)),
1093
- J.label(x),
1094
- E({ icon: "line-md:plus", size: "xs" })
1095
- ),
1096
- g.button(
1097
- r.type("button"),
1098
- r.class(
1099
- "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--decrement"
1100
- ),
1101
- r.disabled(
1102
- A(
1103
- i,
1104
- t.disabled ?? !1
1105
- )((I, V) => !I || V)
1106
- ),
1107
- C.click((I) => D(I)),
1108
- J.label($),
1109
- E({ icon: "line-md:minus", size: "xs" })
1110
- )
1111
- ))(
1112
- ce.incrementValue,
1113
- ce.decrementValue
1114
- );
1115
- })(), m = Ee(
1116
- e,
1117
- t.disabled,
1118
- o ?? d
1119
- ), v = b != null && f != null ? N(f, m, b) : b != null ? N(m, b) : f != null ? N(f, m) : m;
1120
- return W({
1121
- ...t,
1122
- input: se.number(
1123
- // min/max attributes and reactive watchers (no forced correction)
1124
- s != null ? r.min(s) : M,
1125
- l != null ? r.max(l) : M,
1126
- q(t),
1127
- // Represent null as empty string so the field can be cleared
1128
- r.value(p.map(e, (i) => i == null ? "" : String(i))),
1129
- r.step(n),
1130
- r.class("bc-input bc-number-input"),
1131
- h != null ? C.blur(P(h)) : M,
1132
- o != null ? C.change(
1133
- P((i) => {
1134
- const u = ze(i);
1135
- o(u);
1136
- })
1137
- ) : M,
1138
- d != null ? C.input(
1139
- P((i) => {
1140
- const u = ze(i);
1141
- d(u);
1142
- })
1143
- ) : M,
1144
- // Wheel support when step is defined
1145
- n != null ? C.wheel((i) => {
1146
- i.preventDefault();
1147
- const u = p.get(e) ?? 0, D = p.get(n), S = i.shiftKey ? 10 : 1, a = i.deltaY < 0 ? D * S : -D * S, x = w(G(u + a, D));
1148
- x !== u && (o?.(x), d?.(x));
1149
- }) : M
1150
- ),
1151
- after: v
1152
- });
1153
- }, At = (t) => {
1154
- const e = {
1155
- type: "pattern",
1156
- pattern: /[0-9A-Fa-f]/,
1157
- transform: (l) => l.toLowerCase()
1158
- }, n = [
1159
- e,
1160
- e,
1161
- e,
1162
- e,
1163
- e,
1164
- e,
1165
- e,
1166
- e,
1167
- "-",
1168
- e,
1169
- e,
1170
- e,
1171
- e,
1172
- "-",
1173
- e,
1174
- e,
1175
- e,
1176
- e,
1177
- "-",
1178
- e,
1179
- e,
1180
- e,
1181
- e,
1182
- "-",
1183
- e,
1184
- e,
1185
- e,
1186
- e,
1187
- e,
1188
- e,
1189
- e,
1190
- e,
1191
- e,
1192
- e,
1193
- e,
1194
- e
1195
- ], s = t.class ? p.map(t.class, (l) => `bc-uuid-input ${l}`) : "bc-uuid-input";
1196
- return Oe({
1197
- ...t,
1198
- class: s,
1199
- mask: n,
1200
- // Sensible default placeholder; can be overridden via options.placeholder
1201
- placeholder: t.placeholder ?? "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1202
- });
1203
- }, dt = /^P(\d+([YMWD]|$)){0,4}(T(\d+([HMS]|$)){0,3})?$/i, mt = /^P(?:(\d+Y)?(\d+M)?(\d+W)?(\d+D)?)(T(\d+H)?(\d+M)?(\d+S)?)?$/i;
1204
- function bt(t) {
1205
- return {
1206
- mask: null,
1207
- allowMode: "custom",
1208
- allow: (e) => /[0-9ptwdhms]/i.test(e),
1209
- pipe: (e) => {
1210
- const n = e.toUpperCase();
1211
- return n.length === 0 ? n : !n.startsWith("P") || !dt.test(n) ? !1 : n;
1212
- },
1213
- completion: {
1214
- mode: "custom",
1215
- isComplete: (e) => {
1216
- const n = e.toUpperCase();
1217
- if (!mt.test(n)) return !1;
1218
- try {
1219
- return t(n), !0;
1220
- } catch {
1221
- return !1;
1222
- }
1223
- }
1224
- }
1225
- };
1226
- }
1227
- const Be = (t, e) => {
1228
- if (t == null) return null;
1229
- try {
1230
- return t.Duration.from(e);
1231
- } catch {
1232
- return null;
1233
- }
1234
- }, Lt = (t) => {
1235
- const { value: e, onChange: n, onInput: s, after: l, disabled: h, onBlur: o } = t, d = () => {
1236
- const f = Ee(e, h, n ?? s);
1237
- return l != null ? N(f, l) : f;
1238
- }, b = t.placeholder != null ? M : r.placeholder("P0DT0H0M0S");
1239
- return Ke(
1240
- (f) => {
1241
- const m = qe(
1242
- t,
1243
- (v) => v?.toString() ?? "",
1244
- (v) => v === "" ? null : f.Duration.from(v)
1245
- );
1246
- return Oe({
1247
- ...m,
1248
- onInput: void 0,
1249
- ...bt(f.Duration.from),
1250
- placeholder: "P0DT0H0M0S",
1251
- after: d()
1252
- });
1253
- },
1254
- { pending: () => {
1255
- const f = (m) => (v) => {
1256
- const u = v.currentTarget?.value ?? "";
1257
- if (u === "") {
1258
- m(null);
1259
- return;
1260
- }
1261
- const D = globalThis.Temporal, S = Be(D, u);
1262
- if (S != null) {
1263
- m(S);
1264
- return;
1265
- }
1266
- he().then((a) => {
1267
- const x = Be(a, u);
1268
- x != null && m(x);
1269
- }).catch(() => {
1270
- });
1271
- };
1272
- return W({
1273
- ...t,
1274
- input: se.text(
1275
- q(t),
1276
- r.value(p.map(e, (m) => m?.toString() ?? "")),
1277
- r.class("bc-input"),
1278
- b,
1279
- o != null ? C.blur(() => o()) : M,
1280
- n != null ? C.change(f(n)) : M,
1281
- s != null ? C.input(f(s)) : M
1282
- ),
1283
- after: d()
1284
- });
1285
- } }
1286
- );
1287
- }, Ut = (t) => {
1288
- const { value: e, onBlur: n, onChange: s, onInput: l } = t;
1289
- return W({
1290
- ...t,
1291
- input: se.url(
1292
- q(t),
1293
- r.value(e),
1294
- r.class("bc-input"),
1295
- n != null ? C.blur(P(n)) : M,
1296
- s != null ? C.change(P(s)) : M,
1297
- l != null ? C.input(P(l)) : M
1298
- )
1299
- });
1300
- };
1301
- function ht(t, e) {
1302
- const {
1303
- onMove: n,
1304
- cannotMoveUp: s,
1305
- cannotMoveDown: l,
1306
- onRemove: h,
1307
- showMove: o = !0,
1308
- showRemove: d = !0,
1309
- removeDisabled: b,
1310
- showMoveButtons: w = !0,
1311
- layout: f = "aside"
1312
- } = t, m = p.toSignal(f).map((u) => u === "aside"), v = U(
1313
- o,
1314
- () => g.div(
1315
- r.class("bc-list-item-controls__move"),
1316
- be(
1317
- {
1318
- size: "xs",
1319
- roundedness: "full",
1320
- variant: "text",
1321
- onClick: () => n("up"),
1322
- disabled: s
1323
- },
1324
- F(
1325
- O,
1326
- (u) => E({
1327
- size: "xs",
1328
- icon: "line-md:arrow-up",
1329
- title: u.$.incrementValue
1330
- })
1331
- )
1332
- ),
1333
- be(
1334
- {
1335
- size: "xs",
1336
- roundedness: "full",
1337
- variant: "text",
1338
- onClick: () => n("down"),
1339
- disabled: l
1340
- },
1341
- F(
1342
- O,
1343
- (u) => E({
1344
- size: "xs",
1345
- icon: "line-md:arrow-down",
1346
- title: u.$.decrementValue
1347
- })
1348
- )
1349
- )
1350
- )
1351
- ), i = U(
1352
- d,
1353
- () => F(
1354
- O,
1355
- (u) => oe({
1356
- size: "xs",
1357
- label: p.map(u.$.removeItem, (D) => D.toLowerCase()),
1358
- color: "danger",
1359
- disabled: b,
1360
- onClick: h
1361
- })
1362
- )
1363
- );
1364
- return U(
1365
- m,
1366
- () => g.div(
1367
- r.class("bc-list-item-controls bc-list-item-controls--aside"),
1368
- g.div(r.class("bc-list-item-controls__content"), e),
1369
- g.div(
1370
- r.class("bc-list-item-controls__actions"),
1371
- U(w, () => v),
1372
- i
1373
- )
1374
- ),
1375
- () => g.div(
1376
- r.class("bc-list-item-controls bc-list-item-controls--below"),
1377
- g.div(r.class("bc-list-item-controls__content"), e),
1378
- g.div(
1379
- r.class("bc-list-item-controls__actions"),
1380
- U(
1381
- w,
1382
- () => v,
1383
- () => g.div()
1384
- ),
1385
- i
1386
- )
1387
- )
1388
- );
1389
- }
1390
- const gt = (t) => {
1391
- const {
1392
- controller: e,
1393
- element: n,
1394
- separator: s,
1395
- showMove: l = !0,
1396
- showRemove: h = !0,
1397
- showAdd: o = !0,
1398
- createItem: d,
1399
- addLabel: b,
1400
- controlsLayout: w = "aside",
1401
- removeDisabled: f,
1402
- addDisabled: m
1403
- } = t, v = U(
1404
- A(o, d)((i, u) => i && u != null),
1405
- () => Me(
1406
- r.class(
1407
- "bc-group--gap-2 bc-group--align-center bc-group--justify-center"
1408
- ),
1409
- be(
1410
- {
1411
- size: "sm",
1412
- variant: "filled",
1413
- onClick: () => e.push(d()),
1414
- disabled: A(
1415
- e.disabled,
1416
- m ?? !1
1417
- )(
1418
- (i, u) => i || u
1419
- )
1420
- },
1421
- F(
1422
- O,
1423
- (i) => Me(
1424
- r.class("bc-group--gap-2"),
1425
- E({ icon: "line-md:plus" }),
1426
- b ?? i.$.addLabel
1427
- )
1428
- )
1429
- )
1430
- )
1431
- );
1432
- return N(
1433
- at(
1434
- e,
1435
- (i) => ht(
1436
- {
1437
- onMove: i.move,
1438
- cannotMoveUp: i.cannotMove("up"),
1439
- cannotMoveDown: i.cannotMove("down"),
1440
- onRemove: i.remove,
1441
- showMove: l,
1442
- showRemove: h,
1443
- removeDisabled: f,
1444
- showMoveButtons: e.signal.map((u) => u.length > 1),
1445
- layout: w
1446
- },
1447
- n(i)
1448
- ),
1449
- s
1450
- ),
1451
- v
1452
- );
1453
- }, Et = (t, ...e) => {
1454
- const {
1455
- controller: n,
1456
- element: s,
1457
- separator: l,
1458
- showMove: h,
1459
- showRemove: o,
1460
- showAdd: d,
1461
- createItem: b,
1462
- addLabel: w,
1463
- controlsLayout: f,
1464
- removeDisabled: m,
1465
- addDisabled: v,
1466
- ...i
1467
- } = t;
1468
- return Ae(
1469
- {
1470
- ...i,
1471
- content: gt({
1472
- controller: n,
1473
- element: s,
1474
- separator: l,
1475
- showMove: h,
1476
- showRemove: o,
1477
- showAdd: d,
1478
- createItem: b,
1479
- addLabel: w,
1480
- controlsLayout: f,
1481
- removeDisabled: m,
1482
- addDisabled: v
1483
- })
1484
- },
1485
- ...e
1486
- );
1487
- };
1488
- class Ft extends fe {
1489
- /** The immutable list of branch definitions for this union */
1490
- branches;
1491
- /** Reactive signal containing the key of the currently active branch */
1492
- activeBranch;
1493
- /** @internal Reactive signal containing the controller for the active branch */
1494
- #t;
1495
- /** @internal Cache of lazily-created branch controllers */
1496
- #e = /* @__PURE__ */ new Map();
1497
- /**
1498
- * Creates a new UnionController.
1499
- *
1500
- * @param path - The path segments identifying this controller in the form tree
1501
- * @param change - Callback to propagate value changes to the parent
1502
- * @param signal - Reactive signal holding the current union value
1503
- * @param status - Reactive signal holding the current validation status
1504
- * @param parent - Parent context providing disabled state and optional validation mode
1505
- * @param branches - Array of branch definitions describing the possible value types
1506
- * @param equals - Optional equality function for comparing values. Defaults to `strictEqual`.
1507
- */
1508
- constructor(e, n, s, l, h, o, d = K) {
1509
- super(e, n, s, l, h, d), this.branches = o;
1510
- const b = (f) => {
1511
- for (const m of o)
1512
- if (m.detect(f))
1513
- return m.key;
1514
- return o[0]?.key ?? "unknown";
1515
- };
1516
- this.activeBranch = s.map(b, K);
1517
- const w = (f) => {
1518
- if (this.#e.has(f))
1519
- return this.#e.get(f);
1520
- const m = o.find((i) => i.key === f);
1521
- if (!m)
1522
- throw new Error(`Unknown branch: ${f}`);
1523
- const v = new fe(
1524
- [...e, f],
1525
- (i) => {
1526
- this.change(i);
1527
- },
1528
- this.signal.map(
1529
- (i) => m.detect(i) ? i : m.defaultValue(),
1530
- d
1531
- ),
1532
- l.map(Ce([f])),
1533
- {
1534
- disabled: this.disabled,
1535
- validationMode: this.parent.validationMode
1536
- },
1537
- d
1538
- );
1539
- return this.#e.set(f, v), v;
1540
- };
1541
- this.#t = this.activeBranch.map(
1542
- (f) => w(f),
1543
- K
1544
- ), this.onDispose(() => {
1545
- for (const f of this.#e.values())
1546
- f.dispose();
1547
- this.#e.clear(), this.activeBranch.dispose(), this.#t.dispose();
1548
- });
1549
- }
1550
- /**
1551
- * Gets the controller for the currently active branch.
1552
- *
1553
- * The returned controller's value and type correspond to the branch that
1554
- * matches the current union value.
1555
- *
1556
- * @returns The `Controller<unknown>` for the active branch
1557
- */
1558
- get activeController() {
1559
- return p.get(this.#t);
1560
- }
1561
- /**
1562
- * Gets or creates a controller for a specific branch by key.
1563
- *
1564
- * Controllers are created lazily and cached for subsequent calls.
1565
- *
1566
- * @param branchKey - The unique key of the branch to get a controller for
1567
- * @returns The `Controller<unknown>` for the specified branch
1568
- * @throws Error if the branch key is not found in the branches array
1569
- */
1570
- getBranchController(e) {
1571
- const n = this.branches.find((l) => l.key === e);
1572
- if (!n)
1573
- throw new Error(`Unknown branch: ${e}`);
1574
- if (this.#e.has(e))
1575
- return this.#e.get(e);
1576
- const s = new fe(
1577
- [...this.path, e],
1578
- (l) => {
1579
- this.change(l);
1580
- },
1581
- this.signal.map(
1582
- (l) => n.detect(l) ? l : n.defaultValue(),
1583
- K
1584
- ),
1585
- this.status.map(Ce([e])),
1586
- {
1587
- disabled: this.disabled,
1588
- validationMode: this.parent.validationMode
1589
- },
1590
- K
1591
- );
1592
- return this.#e.set(e, s), s;
1593
- }
1594
- /**
1595
- * Switches the union value to a different branch.
1596
- *
1597
- * Attempts the following in order:
1598
- * 1. If already on the target branch, returns `true` immediately
1599
- * 2. If the branch has a `convert` function, tries to convert the current value
1600
- * 3. If conversion fails and `confirmChange` is true, prompts the user with `window.confirm`
1601
- * 4. Sets the value to the branch's default value
1602
- *
1603
- * @param branchKey - The key of the branch to switch to
1604
- * @param confirmChange - If true, prompts the user before losing the current value when conversion fails
1605
- * @returns `true` if the switch was successful, `false` if the user cancelled
1606
- * @throws Error if the branch key is not found in the branches array
1607
- */
1608
- switchToBranch(e, n = !1) {
1609
- const s = this.branches.find((o) => o.key === e);
1610
- if (!s)
1611
- throw new Error(`Unknown branch: ${e}`);
1612
- const l = p.get(this.signal);
1613
- if (s.detect(l))
1614
- return !0;
1615
- if (s.convert) {
1616
- const o = s.convert(l);
1617
- if (o.ok)
1618
- return this.change(o.value), !0;
1619
- }
1620
- if (n && typeof window == "object" && typeof window.confirm == "function" && !window.confirm(ce.changeTypeConfirmation))
1621
- return !1;
1622
- const h = s.defaultValue();
1623
- return this.change(h), !0;
1624
- }
1625
- /**
1626
- * Gets the {@link UnionBranch} definition for the currently active branch.
1627
- *
1628
- * @returns The active branch definition, or `undefined` if no branch matches
1629
- */
1630
- get activeBranchDefinition() {
1631
- const e = p.get(this.activeBranch);
1632
- return this.branches.find((n) => n.key === e);
1633
- }
1634
- }
1635
- function Ot(t) {
1636
- return t.transform(
1637
- (e) => e ?? null,
1638
- (e) => e ?? void 0
1639
- );
1640
- }
1641
- function Rt(t) {
1642
- return t.transform(
1643
- (e) => e ?? "",
1644
- (e) => e === "" ? void 0 : e
1645
- );
1646
- }
1647
- function Nt(t) {
1648
- return t.transform(
1649
- (e) => e ?? void 0,
1650
- (e) => e ?? null
1651
- );
1652
- }
1653
- function re(t) {
1654
- return t !== null && typeof t == "object" && !Array.isArray(t) && Object.prototype.toString.call(t) === "[object Object]";
1655
- }
1656
- function vt(t, e) {
1657
- if (e == null)
1658
- return Ve(t);
1659
- if (t == null)
1660
- return e;
1661
- if (re(t) && re(e)) {
1662
- const n = { ...e };
1663
- for (const s of Object.keys(t))
1664
- n[s] === void 0 ? n[s] = Ve(t[s]) : re(t[s]) && re(n[s]) && (n[s] = vt(t[s], n[s]));
1665
- return n;
1666
- }
1667
- return e;
1668
- }
1669
- function Ve(t) {
1670
- return typeof structuredClone == "function" ? structuredClone(t) : JSON.parse(JSON.stringify(t));
1671
- }
1672
- export {
1673
- gt as B,
1674
- et as E,
1675
- zt as F,
1676
- Me as G,
1677
- Et as L,
1678
- Oe as M,
1679
- Ee as N,
1680
- Tt as S,
1681
- Bt as T,
1682
- At as U,
1683
- Ke as W,
1684
- Ut as a,
1685
- tt as b,
1686
- Lt as c,
1687
- bt as d,
1688
- Rt as e,
1689
- Vt as f,
1690
- St as g,
1691
- Mt as h,
1692
- Ft as i,
1693
- vt as j,
1694
- nt as k,
1695
- at as l,
1696
- ht as m,
1697
- de as n,
1698
- $t as o,
1699
- $e as p,
1700
- he as q,
1701
- G as r,
1702
- Nt as s,
1703
- Ot as t
1704
- };