@versaur/react 1.0.13 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/forms.js CHANGED
@@ -1,475 +1,772 @@
1
- import { jsx as i, jsxs as C } from "react/jsx-runtime";
2
- import { labelStyles as ie, helperTextStyles as ae, errorTextStyles as se, textInputStyles as w, textAreaStyles as D, selectStyles as F, radioStyles as R, checkboxStyles as $, radioGroupStyles as P, checkboxGroupStyles as V, chipInputStyles as j } from "@versaur/core/forms";
3
- import { forwardRef as v, useId as S, createContext as T, useContext as E } from "react";
4
- import { u as I } from "./use-data-attrs-iPFyfiKN.js";
5
- import { c as b } from "./cx-B9vmfsc1.js";
6
- const k = v(
7
- ({ required: e = !1, disabled: n = !1, children: t, className: d, ...a }, o) => {
8
- const c = I({
9
- disabled: n,
1
+ import { jsx as s, jsxs as g } from "react/jsx-runtime";
2
+ import { labelStyles as Oe, helperTextStyles as Se, errorTextStyles as ke, textInputStyles as G, textAreaStyles as K, selectStyles as _, radioStyles as T, checkboxStyles as j, radioGroupStyles as X, checkboxGroupStyles as J, chipInputStyles as M, comboboxInputStyles as v } from "@versaur/core/forms";
3
+ import { forwardRef as f, useId as A, createContext as P, useContext as Q, useState as D, useEffect as $, useCallback as L, useRef as Be } from "react";
4
+ import { u as N, c as Re } from "./helpers-DTL6qrTe.js";
5
+ import { c as y } from "./cx-B9vmfsc1.js";
6
+ import { ChevronDownIcon as Ae, CheckIcon as Ge, XIcon as De } from "@versaur/icons";
7
+ import { D as U } from "./drawer-DRv9k7lp.js";
8
+ const k = f(
9
+ ({ required: e = !1, disabled: c = !1, children: i, className: a, ...n }, t) => {
10
+ const o = N({
11
+ disabled: c,
10
12
  required: e
11
13
  });
12
- return /* @__PURE__ */ i("label", { ref: o, className: b(ie.label, d), ...c, ...a, children: t });
14
+ return /* @__PURE__ */ s("label", { ref: t, className: y(Oe.label, a), ...o, ...n, children: i });
13
15
  }
14
16
  );
15
17
  k.displayName = "Label";
16
- const B = v(({ children: e, className: n, ...t }, d) => /* @__PURE__ */ i("p", { ref: d, className: b(ae.helper, n), ...t, children: e }));
18
+ const B = f(({ children: e, className: c, ...i }, a) => /* @__PURE__ */ s("p", { ref: a, className: y(Se.helper, c), ...i, children: e }));
17
19
  B.displayName = "HelperText";
18
- const O = v(({ children: e, className: n, ...t }, d) => /* @__PURE__ */ i("p", { ref: d, className: b(se.error, n), role: "alert", "aria-live": "polite", ...t, children: e }));
19
- O.displayName = "ErrorText";
20
- const de = v(
20
+ const R = f(({ children: e, className: c, ...i }, a) => /* @__PURE__ */ s("p", { ref: a, className: y(ke.error, c), role: "alert", "aria-live": "polite", ...i, children: e }));
21
+ R.displayName = "ErrorText";
22
+ const $e = f(
21
23
  ({
22
24
  label: e,
23
- helper: n,
24
- error: t,
25
- required: d = !1,
26
- disabled: a = !1,
27
- readOnly: o = !1,
28
- leftIcon: c,
29
- rightIcon: s,
25
+ helper: c,
26
+ error: i,
27
+ required: a = !1,
28
+ disabled: n = !1,
29
+ readOnly: t = !1,
30
+ leftIcon: o,
31
+ rightIcon: r,
30
32
  id: l,
31
- className: f,
32
- ...p
33
- }, x) => {
34
- const m = S(), u = l || m, r = n ? `${u}-helper` : void 0, h = t ? `${u}-error` : void 0, y = [r, h].filter(Boolean).join(" "), N = I({
35
- disabled: a,
36
- hasLeftIcon: !!c,
37
- hasRightIcon: !!s,
38
- invalid: !!t,
39
- readOnly: o
33
+ className: d,
34
+ ...u
35
+ }, h) => {
36
+ const b = A(), m = l || b, p = c ? `${m}-helper` : void 0, x = i ? `${m}-error` : void 0, C = [p, x].filter(Boolean).join(" "), I = N({
37
+ disabled: n,
38
+ hasLeftIcon: !!o,
39
+ hasRightIcon: !!r,
40
+ invalid: !!i,
41
+ readOnly: t
40
42
  });
41
- return /* @__PURE__ */ C("div", { className: b(w.field, f), children: [
42
- e && /* @__PURE__ */ i(k, { htmlFor: u, required: d, disabled: a, children: e }),
43
- /* @__PURE__ */ C("div", { className: w.wrapper, ...N, children: [
44
- c && /* @__PURE__ */ i("span", { className: w["left-icon"], children: c }),
45
- /* @__PURE__ */ i(
43
+ return /* @__PURE__ */ g("div", { className: y(G.field, d), children: [
44
+ e && /* @__PURE__ */ s(k, { htmlFor: m, required: a, disabled: n, children: e }),
45
+ /* @__PURE__ */ g("div", { className: G.wrapper, ...I, children: [
46
+ o && /* @__PURE__ */ s("span", { className: G["left-icon"], children: o }),
47
+ /* @__PURE__ */ s(
46
48
  "input",
47
49
  {
48
- ref: x,
49
- id: u,
50
+ ref: h,
51
+ id: m,
50
52
  type: "text",
51
- className: w.input,
52
- disabled: a,
53
- readOnly: o,
54
- required: d,
55
- "aria-invalid": t ? "true" : void 0,
56
- "aria-disabled": a ? "true" : void 0,
57
- "aria-describedby": y || void 0,
58
- ...p
53
+ className: G.input,
54
+ disabled: n,
55
+ readOnly: t,
56
+ required: a,
57
+ "aria-invalid": i ? "true" : void 0,
58
+ "aria-disabled": n ? "true" : void 0,
59
+ "aria-describedby": C || void 0,
60
+ ...u
59
61
  }
60
62
  ),
61
- s && /* @__PURE__ */ i("span", { className: w["right-icon"], children: s })
63
+ r && /* @__PURE__ */ s("span", { className: G["right-icon"], children: r })
62
64
  ] }),
63
- t && /* @__PURE__ */ i(O, { id: h, children: t }),
64
- !t && n && /* @__PURE__ */ i(B, { id: r, children: n })
65
+ i && /* @__PURE__ */ s(R, { id: x, children: i }),
66
+ !i && c && /* @__PURE__ */ s(B, { id: p, children: c })
65
67
  ] });
66
68
  }
67
69
  );
68
- de.displayName = "TextInput";
69
- const ce = v(
70
+ $e.displayName = "TextInput";
71
+ const Ee = f(
70
72
  ({
71
73
  label: e,
72
- helper: n,
73
- error: t,
74
- required: d = !1,
75
- disabled: a = !1,
76
- readOnly: o = !1,
77
- resizable: c = !0,
78
- minRows: s = 3,
74
+ helper: c,
75
+ error: i,
76
+ required: a = !1,
77
+ disabled: n = !1,
78
+ readOnly: t = !1,
79
+ resizable: o = !0,
80
+ minRows: r = 3,
79
81
  maxRows: l,
80
- id: f,
81
- className: p,
82
- ...x
83
- }, m) => {
84
- const u = S(), r = f || u, h = n ? `${r}-helper` : void 0, y = t ? `${r}-error` : void 0, N = [h, y].filter(Boolean).join(" "), g = I({
85
- disabled: a,
86
- invalid: !!t,
87
- readOnly: o,
88
- resizable: c ? "true" : "false",
82
+ id: d,
83
+ className: u,
84
+ ...h
85
+ }, b) => {
86
+ const m = A(), p = d || m, x = c ? `${p}-helper` : void 0, C = i ? `${p}-error` : void 0, I = [x, C].filter(Boolean).join(" "), w = N({
87
+ disabled: n,
88
+ invalid: !!i,
89
+ readOnly: t,
90
+ resizable: o ? "true" : "false",
89
91
  minRows: "true",
90
92
  ...l && { maxRows: "true" }
91
- }), G = {
92
- "--_min-rows-count": s,
93
+ }), O = {
94
+ "--_min-rows-count": r,
93
95
  ...l && { "--_max-rows-count": l }
94
96
  };
95
- return /* @__PURE__ */ C("div", { className: b(D.field, p), children: [
96
- e && /* @__PURE__ */ i(k, { htmlFor: r, required: d, disabled: a, children: e }),
97
- /* @__PURE__ */ i(
97
+ return /* @__PURE__ */ g("div", { className: y(K.field, u), children: [
98
+ e && /* @__PURE__ */ s(k, { htmlFor: p, required: a, disabled: n, children: e }),
99
+ /* @__PURE__ */ s(
98
100
  "textarea",
99
101
  {
100
- ref: m,
101
- id: r,
102
- className: D.textarea,
103
- disabled: a,
104
- readOnly: o,
105
- required: d,
106
- style: G,
107
- "aria-invalid": t ? "true" : void 0,
108
- "aria-disabled": a ? "true" : void 0,
109
- "aria-describedby": N || void 0,
110
- ...g,
111
- ...x
102
+ ref: b,
103
+ id: p,
104
+ className: K.textarea,
105
+ disabled: n,
106
+ readOnly: t,
107
+ required: a,
108
+ style: O,
109
+ "aria-invalid": i ? "true" : void 0,
110
+ "aria-disabled": n ? "true" : void 0,
111
+ "aria-describedby": I || void 0,
112
+ ...w,
113
+ ...h
112
114
  }
113
115
  ),
114
- t && /* @__PURE__ */ i(O, { id: y, children: t }),
115
- !t && n && /* @__PURE__ */ i(B, { id: h, children: n })
116
+ i && /* @__PURE__ */ s(R, { id: C, children: i }),
117
+ !i && c && /* @__PURE__ */ s(B, { id: x, children: c })
116
118
  ] });
117
119
  }
118
120
  );
119
- ce.displayName = "TextArea";
120
- const H = v(({ children: e, ...n }, t) => /* @__PURE__ */ i("option", { ref: t, ...n, children: e }));
121
- H.displayName = "Select.Option";
122
- const L = v(
123
- ({ label: e, children: n, ...t }, d) => /* @__PURE__ */ i("optgroup", { ref: d, label: e, ...t, children: n })
121
+ Ee.displayName = "TextArea";
122
+ const W = f(({ children: e, ...c }, i) => /* @__PURE__ */ s("option", { ref: i, ...c, children: e }));
123
+ W.displayName = "Select.Option";
124
+ const Y = f(
125
+ ({ label: e, children: c, ...i }, a) => /* @__PURE__ */ s("optgroup", { ref: a, label: e, ...i, children: c })
124
126
  );
125
- L.displayName = "Select.OptionGroup";
126
- const _ = v(
127
+ Y.displayName = "Select.OptionGroup";
128
+ const Z = f(
127
129
  ({
128
130
  label: e,
129
- helper: n,
130
- error: t,
131
- required: d = !1,
132
- disabled: a = !1,
133
- placeholder: o,
134
- children: c,
135
- id: s,
131
+ helper: c,
132
+ error: i,
133
+ required: a = !1,
134
+ disabled: n = !1,
135
+ placeholder: t,
136
+ children: o,
137
+ id: r,
136
138
  className: l,
137
- ...f
138
- }, p) => {
139
- const x = S(), m = s || x, u = n ? `${m}-helper` : void 0, r = t ? `${m}-error` : void 0, h = [u, r].filter(Boolean).join(" "), y = I({
140
- disabled: a,
141
- invalid: !!t
139
+ ...d
140
+ }, u) => {
141
+ const h = A(), b = r || h, m = c ? `${b}-helper` : void 0, p = i ? `${b}-error` : void 0, x = [m, p].filter(Boolean).join(" "), C = N({
142
+ disabled: n,
143
+ invalid: !!i
142
144
  });
143
- return /* @__PURE__ */ C("div", { className: b(F.field, l), children: [
144
- e && /* @__PURE__ */ i(k, { htmlFor: m, required: d, disabled: a, children: e }),
145
- /* @__PURE__ */ C(
145
+ return /* @__PURE__ */ g("div", { className: y(_.field, l), children: [
146
+ e && /* @__PURE__ */ s(k, { htmlFor: b, required: a, disabled: n, children: e }),
147
+ /* @__PURE__ */ g(
146
148
  "select",
147
149
  {
148
- ref: p,
149
- id: m,
150
- className: F.select,
151
- disabled: a,
152
- required: d,
153
- "aria-invalid": t ? "true" : void 0,
154
- "aria-disabled": a ? "true" : void 0,
155
- "aria-describedby": h || void 0,
156
- ...y,
157
- ...f,
150
+ ref: u,
151
+ id: b,
152
+ className: _.select,
153
+ disabled: n,
154
+ required: a,
155
+ "aria-invalid": i ? "true" : void 0,
156
+ "aria-disabled": n ? "true" : void 0,
157
+ "aria-describedby": x || void 0,
158
+ ...C,
159
+ ...d,
158
160
  children: [
159
- o && /* @__PURE__ */ i("option", { value: "", disabled: !0, children: o }),
160
- c
161
+ t && /* @__PURE__ */ s("option", { value: "", disabled: !0, children: t }),
162
+ o
161
163
  ]
162
164
  }
163
165
  ),
164
- t && /* @__PURE__ */ i(O, { id: r, children: t }),
165
- !t && n && /* @__PURE__ */ i(B, { id: u, children: n })
166
+ i && /* @__PURE__ */ s(R, { id: p, children: i }),
167
+ !i && c && /* @__PURE__ */ s(B, { id: m, children: c })
166
168
  ] });
167
169
  }
168
170
  );
169
- _.displayName = "Select";
170
- const z = _;
171
- z.Option = H;
172
- z.OptionGroup = L;
173
- const J = v(
174
- ({ disabled: e = !1, children: n, className: t, ...d }, a) => {
175
- const o = I({
171
+ Z.displayName = "Select";
172
+ const q = Z;
173
+ q.Option = W;
174
+ q.OptionGroup = Y;
175
+ const ee = f(
176
+ ({ disabled: e = !1, children: c, className: i, ...a }, n) => {
177
+ const t = N({
176
178
  disabled: e
177
179
  });
178
- return /* @__PURE__ */ C("label", { className: b(R.radio, t), ...o, children: [
179
- /* @__PURE__ */ i(
180
- "input",
181
- {
182
- ref: a,
183
- type: "radio",
184
- className: R.input,
185
- disabled: e,
186
- ...d
187
- }
188
- ),
189
- /* @__PURE__ */ i("span", { className: R.indicator }),
190
- n && /* @__PURE__ */ i("span", { className: R.label, children: n })
180
+ return /* @__PURE__ */ g("label", { className: y(T.radio, i), ...t, children: [
181
+ /* @__PURE__ */ s("input", { ref: n, type: "radio", className: T.input, disabled: e, ...a }),
182
+ /* @__PURE__ */ s("span", { className: T.indicator }),
183
+ c && /* @__PURE__ */ s("span", { className: T.label, children: c })
191
184
  ] });
192
185
  }
193
186
  );
194
- J.displayName = "Radio";
195
- const K = v(
196
- ({ disabled: e = !1, required: n = !1, children: t, className: d, ...a }, o) => {
197
- const c = I({
187
+ ee.displayName = "Radio";
188
+ const te = f(
189
+ ({ disabled: e = !1, required: c = !1, children: i, className: a, ...n }, t) => {
190
+ const o = N({
198
191
  disabled: e,
199
- required: n
192
+ required: c
200
193
  });
201
- return /* @__PURE__ */ C("label", { className: b($.checkbox, d), ...c, children: [
202
- /* @__PURE__ */ i(
194
+ return /* @__PURE__ */ g("label", { className: y(j.checkbox, a), ...o, children: [
195
+ /* @__PURE__ */ s(
203
196
  "input",
204
197
  {
205
- ref: o,
198
+ ref: t,
206
199
  type: "checkbox",
207
- className: $.input,
200
+ className: j.input,
208
201
  disabled: e,
209
- required: n,
210
- "aria-required": n || void 0,
211
- ...a
202
+ required: c,
203
+ "aria-required": c || void 0,
204
+ ...n
212
205
  }
213
206
  ),
214
- /* @__PURE__ */ i("span", { className: $.indicator }),
215
- t && /* @__PURE__ */ i("span", { className: $.label, "data-required": n || void 0, children: t })
207
+ /* @__PURE__ */ s("span", { className: j.indicator }),
208
+ i && /* @__PURE__ */ s("span", { className: j.label, "data-required": c || void 0, children: i })
216
209
  ] });
217
210
  }
218
211
  );
219
- K.displayName = "Checkbox";
220
- const M = T(void 0);
221
- function le() {
222
- const e = E(M);
212
+ te.displayName = "Checkbox";
213
+ const oe = P(void 0);
214
+ function Te() {
215
+ const e = Q(oe);
223
216
  if (!e)
224
217
  throw new Error("RadioGroup.Option must be used within RadioGroup");
225
218
  return e;
226
219
  }
227
- const Q = v(
220
+ const ne = f(
228
221
  ({
229
222
  value: e,
230
- onChange: n,
231
- name: t,
232
- label: d,
233
- helper: a,
234
- error: o,
235
- required: c = !1,
236
- disabled: s = !1,
223
+ onChange: c,
224
+ name: i,
225
+ label: a,
226
+ helper: n,
227
+ error: t,
228
+ required: o = !1,
229
+ disabled: r = !1,
237
230
  direction: l = "column",
238
- children: f,
239
- className: p,
240
- ...x
241
- }, m) => {
242
- const u = S(), r = x.id || u, h = a ? `${r}-helper` : void 0, y = o ? `${r}-error` : void 0, N = [h, y].filter(Boolean).join(" "), g = (A) => {
243
- !s && n && n(A);
244
- }, G = I({
245
- disabled: s
231
+ children: d,
232
+ className: u,
233
+ ...h
234
+ }, b) => {
235
+ const m = A(), p = h.id || m, x = n ? `${p}-helper` : void 0, C = t ? `${p}-error` : void 0, I = [x, C].filter(Boolean).join(" "), w = (S) => {
236
+ !r && c && c(S);
237
+ }, O = N({
238
+ disabled: r
246
239
  });
247
- return /* @__PURE__ */ C("div", { ref: m, className: b(P.field, p), ...G, ...x, children: [
248
- d && /* @__PURE__ */ i(k, { required: c, disabled: s, children: d }),
249
- /* @__PURE__ */ i(M.Provider, { value: { disabled: s, name: t, onChange: g, value: e }, children: /* @__PURE__ */ i(
240
+ return /* @__PURE__ */ g("div", { ref: b, className: y(X.field, u), ...O, ...h, children: [
241
+ a && /* @__PURE__ */ s(k, { required: o, disabled: r, children: a }),
242
+ /* @__PURE__ */ s(oe.Provider, { value: { disabled: r, name: i, onChange: w, value: e }, children: /* @__PURE__ */ s(
250
243
  "div",
251
244
  {
252
- className: P.options,
245
+ className: X.options,
253
246
  "data-direction": l,
254
247
  role: "radiogroup",
255
- "aria-describedby": N || void 0,
256
- "aria-invalid": o ? "true" : void 0,
257
- children: f
248
+ "aria-describedby": I || void 0,
249
+ "aria-invalid": t ? "true" : void 0,
250
+ children: d
258
251
  }
259
252
  ) }),
260
- o && /* @__PURE__ */ i(O, { id: y, children: o }),
261
- !o && a && /* @__PURE__ */ i(B, { id: h, children: a })
253
+ t && /* @__PURE__ */ s(R, { id: C, children: t }),
254
+ !t && n && /* @__PURE__ */ s(B, { id: x, children: n })
262
255
  ] });
263
256
  }
264
257
  );
265
- Q.displayName = "RadioGroup";
266
- const U = v(
267
- ({ value: e, children: n, disabled: t, ...d }, a) => {
268
- const o = le(), c = o.value === e, s = o.disabled || t, l = () => {
269
- s || o.onChange(e);
258
+ ne.displayName = "RadioGroup";
259
+ const ie = f(
260
+ ({ value: e, children: c, disabled: i, ...a }, n) => {
261
+ const t = Te(), o = t.value === e, r = t.disabled || i, l = () => {
262
+ r || t.onChange(e);
270
263
  };
271
- return /* @__PURE__ */ i(
272
- J,
264
+ return /* @__PURE__ */ s(
265
+ ee,
273
266
  {
274
- ref: a,
275
- name: o.name,
267
+ ref: n,
268
+ name: t.name,
276
269
  value: e,
277
- checked: c,
278
- disabled: s,
270
+ checked: o,
271
+ disabled: r,
279
272
  onChange: l,
280
- ...d,
281
- children: n
273
+ ...a,
274
+ children: c
282
275
  }
283
276
  );
284
277
  }
285
278
  );
286
- U.displayName = "RadioGroup.Option";
287
- const xe = Object.assign(Q, {
288
- Option: U
289
- }), W = T(void 0);
290
- function re() {
291
- const e = E(W);
279
+ ie.displayName = "RadioGroup.Option";
280
+ const Xe = Object.assign(ne, {
281
+ Option: ie
282
+ }), se = P(void 0);
283
+ function je() {
284
+ const e = Q(se);
292
285
  if (!e)
293
286
  throw new Error("CheckboxGroup.Option must be used within CheckboxGroup");
294
287
  return e;
295
288
  }
296
- const X = v(
289
+ const ae = f(
297
290
  ({
298
291
  value: e,
299
- onChange: n,
300
- name: t,
301
- label: d,
302
- helper: a,
303
- error: o,
304
- required: c = !1,
305
- disabled: s = !1,
292
+ onChange: c,
293
+ name: i,
294
+ label: a,
295
+ helper: n,
296
+ error: t,
297
+ required: o = !1,
298
+ disabled: r = !1,
306
299
  direction: l = "column",
307
- children: f,
308
- className: p,
309
- ...x
310
- }, m) => {
311
- const u = S(), r = x.id || u, h = a ? `${r}-helper` : void 0, y = o ? `${r}-error` : void 0, N = [h, y].filter(Boolean).join(" "), g = (A) => {
312
- !s && n && n(A);
313
- }, G = I({
314
- disabled: s
300
+ children: d,
301
+ className: u,
302
+ ...h
303
+ }, b) => {
304
+ const m = A(), p = h.id || m, x = n ? `${p}-helper` : void 0, C = t ? `${p}-error` : void 0, I = [x, C].filter(Boolean).join(" "), w = (S) => {
305
+ !r && c && c(S);
306
+ }, O = N({
307
+ disabled: r
315
308
  });
316
- return /* @__PURE__ */ C("div", { ref: m, className: b(V.field, p), ...G, ...x, children: [
317
- d && /* @__PURE__ */ i(k, { required: c, disabled: s, children: d }),
318
- /* @__PURE__ */ i(W.Provider, { value: { disabled: s, name: t, onChange: g, value: e }, children: /* @__PURE__ */ i(
309
+ return /* @__PURE__ */ g("div", { ref: b, className: y(J.field, u), ...O, ...h, children: [
310
+ a && /* @__PURE__ */ s(k, { required: o, disabled: r, children: a }),
311
+ /* @__PURE__ */ s(se.Provider, { value: { disabled: r, name: i, onChange: w, value: e }, children: /* @__PURE__ */ s(
319
312
  "div",
320
313
  {
321
- className: V.options,
314
+ className: J.options,
322
315
  "data-direction": l,
323
316
  role: "group",
324
- "aria-describedby": N || void 0,
325
- "aria-invalid": o ? "true" : void 0,
326
- children: f
317
+ "aria-describedby": I || void 0,
318
+ "aria-invalid": t ? "true" : void 0,
319
+ children: d
327
320
  }
328
321
  ) }),
329
- o && /* @__PURE__ */ i(O, { id: y, children: o }),
330
- !o && a && /* @__PURE__ */ i(B, { id: h, children: a })
322
+ t && /* @__PURE__ */ s(R, { id: C, children: t }),
323
+ !t && n && /* @__PURE__ */ s(B, { id: x, children: n })
331
324
  ] });
332
325
  }
333
326
  );
334
- X.displayName = "CheckboxGroup";
335
- const Y = v(
336
- ({ value: e, children: n, disabled: t, ...d }, a) => {
337
- const o = re(), c = o.value.includes(e), s = o.disabled || t, l = () => {
338
- if (!s) {
339
- const f = c ? o.value.filter((p) => p !== e) : [...o.value, e];
340
- o.onChange(f);
327
+ ae.displayName = "CheckboxGroup";
328
+ const ce = f(
329
+ ({ value: e, children: c, disabled: i, ...a }, n) => {
330
+ const t = je(), o = t.value.includes(e), r = t.disabled || i, l = () => {
331
+ if (!r) {
332
+ const d = o ? t.value.filter((u) => u !== e) : [...t.value, e];
333
+ t.onChange(d);
341
334
  }
342
335
  };
343
- return /* @__PURE__ */ i(
344
- K,
336
+ return /* @__PURE__ */ s(
337
+ te,
345
338
  {
346
- ref: a,
347
- name: o.name,
339
+ ref: n,
340
+ name: t.name,
348
341
  value: e,
349
- checked: c,
350
- disabled: s,
342
+ checked: o,
343
+ disabled: r,
351
344
  onChange: l,
352
- ...d,
353
- children: n
345
+ ...a,
346
+ children: c
354
347
  }
355
348
  );
356
349
  }
357
350
  );
358
- Y.displayName = "CheckboxGroup.Option";
359
- const ye = Object.assign(X, {
360
- Option: Y
361
- }), Z = T(void 0);
362
- function pe() {
363
- const e = E(Z);
351
+ ce.displayName = "CheckboxGroup.Option";
352
+ const Je = Object.assign(ae, {
353
+ Option: ce
354
+ }), re = P(void 0);
355
+ function Le() {
356
+ const e = Q(re);
364
357
  if (!e)
365
358
  throw new Error("ChipInput.Option must be used within ChipInput");
366
359
  return e;
367
360
  }
368
- const q = v(
361
+ const le = f(
369
362
  ({
370
363
  value: e,
371
- onChange: n,
372
- multiple: t = !1,
373
- name: d,
374
- label: a,
375
- helper: o,
376
- error: c,
377
- required: s = !1,
364
+ onChange: c,
365
+ multiple: i = !1,
366
+ name: a,
367
+ label: n,
368
+ helper: t,
369
+ error: o,
370
+ required: r = !1,
378
371
  disabled: l = !1,
379
- gap: f = "2",
380
- wrap: p = !0,
381
- children: x,
382
- className: m,
383
- ...u
384
- }, r) => {
385
- const h = S(), y = u.id || h, N = o ? `${y}-helper` : void 0, g = c ? `${y}-error` : void 0, G = [N, g].filter(Boolean).join(" "), A = (ne) => {
386
- l || n(ne);
387
- }, te = I({
388
- invalid: !!c
389
- }), oe = t ? "group" : "radiogroup";
390
- return /* @__PURE__ */ C("div", { ref: r, className: b(j.field, m), ...te, ...u, children: [
391
- a && /* @__PURE__ */ i(k, { required: s, disabled: l, children: a }),
392
- /* @__PURE__ */ i(
393
- Z.Provider,
372
+ gap: d = "2",
373
+ wrap: u = !0,
374
+ children: h,
375
+ className: b,
376
+ ...m
377
+ }, p) => {
378
+ const x = A(), C = m.id || x, I = t ? `${C}-helper` : void 0, w = o ? `${C}-error` : void 0, O = [I, w].filter(Boolean).join(" "), S = (z) => {
379
+ l || c(z);
380
+ }, V = N({
381
+ invalid: !!o
382
+ }), F = i ? "group" : "radiogroup";
383
+ return /* @__PURE__ */ g("div", { ref: p, className: y(M.field, b), ...V, ...m, children: [
384
+ n && /* @__PURE__ */ s(k, { required: r, disabled: l, children: n }),
385
+ /* @__PURE__ */ s(
386
+ re.Provider,
394
387
  {
395
388
  value: {
396
389
  disabled: l,
397
- multiple: t,
398
- name: d,
399
- onChange: A,
390
+ multiple: i,
391
+ name: a,
392
+ onChange: S,
400
393
  value: e
401
394
  },
402
- children: /* @__PURE__ */ i(
395
+ children: /* @__PURE__ */ s(
403
396
  "div",
404
397
  {
405
- className: j.options,
406
- "data-gap": f,
407
- "data-wrap": p,
408
- role: oe,
409
- "aria-describedby": G || void 0,
410
- "aria-invalid": c ? "true" : void 0,
411
- children: x
398
+ className: M.options,
399
+ "data-gap": d,
400
+ "data-wrap": u,
401
+ role: F,
402
+ "aria-describedby": O || void 0,
403
+ "aria-invalid": o ? "true" : void 0,
404
+ children: h
412
405
  }
413
406
  )
414
407
  }
415
408
  ),
416
- c && /* @__PURE__ */ i(O, { id: g, children: c }),
417
- !c && o && /* @__PURE__ */ i(B, { id: N, children: o })
409
+ o && /* @__PURE__ */ s(R, { id: w, children: o }),
410
+ !o && t && /* @__PURE__ */ s(B, { id: I, children: t })
418
411
  ] });
419
412
  }
420
413
  );
421
- q.displayName = "ChipInput";
422
- const ee = v(
423
- ({ value: e, children: n, disabled: t, iconLeft: d, iconRight: a, ...o }, c) => {
424
- const s = pe(), l = s.disabled || t, f = !!(d || a);
425
- let p = !1;
426
- s.multiple ? p = Array.isArray(s.value) && s.value.includes(e) : p = s.value === e;
427
- const x = () => {
414
+ le.displayName = "ChipInput";
415
+ const de = f(
416
+ ({ value: e, children: c, disabled: i, iconLeft: a, iconRight: n, ...t }, o) => {
417
+ const r = Le(), l = r.disabled || i, d = !!(a || n);
418
+ let u = !1;
419
+ r.multiple ? u = Array.isArray(r.value) && r.value.includes(e) : u = r.value === e;
420
+ const h = () => {
428
421
  if (!l)
429
- if (s.multiple) {
430
- const u = Array.isArray(s.value) ? s.value : [], r = p ? u.filter((h) => h !== e) : [...u, e];
431
- s.onChange(r);
422
+ if (r.multiple) {
423
+ const m = Array.isArray(r.value) ? r.value : [], p = u ? m.filter((x) => x !== e) : [...m, e];
424
+ r.onChange(p);
432
425
  } else
433
- s.onChange(e);
434
- }, m = I({
426
+ r.onChange(e);
427
+ }, b = N({
435
428
  disabled: l,
436
- selected: p,
437
- ...f && { "has-icon": !0 }
429
+ selected: u,
430
+ ...d && { "has-icon": !0 }
438
431
  });
439
- return /* @__PURE__ */ C(
432
+ return /* @__PURE__ */ g(
440
433
  "button",
441
434
  {
442
- ref: c,
435
+ ref: o,
443
436
  type: "button",
444
- className: j.option,
445
- onClick: x,
437
+ className: M.option,
438
+ onClick: h,
446
439
  disabled: l,
447
- "aria-pressed": p,
448
- ...m,
449
- ...o,
440
+ "aria-pressed": u,
441
+ ...b,
442
+ ...t,
443
+ children: [
444
+ a,
445
+ c,
446
+ n
447
+ ]
448
+ }
449
+ );
450
+ }
451
+ );
452
+ de.displayName = "ChipInput.Option";
453
+ const Ue = Object.assign(le, {
454
+ Option: de
455
+ }), pe = P(void 0);
456
+ function E() {
457
+ const e = Q(pe);
458
+ if (!e)
459
+ throw new Error("ComboboxInput subcomponents must be used within ComboboxInput");
460
+ return e;
461
+ }
462
+ const ue = f(
463
+ ({ children: e, className: c, ...i }, a) => {
464
+ const n = E();
465
+ return /* @__PURE__ */ s(U, { open: n.isOpen, onOpenChange: (t) => !t && n.closeListbox(), placement: "right", children: /* @__PURE__ */ s(U.Body, { children: /* @__PURE__ */ g("div", { className: v["drawer-container"], children: [
466
+ /* @__PURE__ */ s("div", { className: v["drawer-input-wrapper"], children: /* @__PURE__ */ s(
467
+ "input",
468
+ {
469
+ type: "text",
470
+ className: v["drawer-input"],
471
+ placeholder: "Search options...",
472
+ value: n.searchQuery || "",
473
+ onChange: (t) => {
474
+ var o;
475
+ return (o = n.setSearchQuery) == null ? void 0 : o.call(n, t.currentTarget.value);
476
+ },
477
+ "aria-label": "Search options"
478
+ }
479
+ ) }),
480
+ /* @__PURE__ */ s(
481
+ "ul",
482
+ {
483
+ ref: a,
484
+ role: "listbox",
485
+ "aria-multiselectable": "true",
486
+ className: y(v["drawer-listbox"], c),
487
+ ...i,
488
+ children: e
489
+ }
490
+ )
491
+ ] }) }) });
492
+ }
493
+ );
494
+ ue.displayName = "ComboboxInput.Drawer";
495
+ function Pe(e) {
496
+ const [c, i] = D(e), [a, n] = D(!1), [t, o] = D(() => /* @__PURE__ */ new Map());
497
+ $(() => {
498
+ i(e);
499
+ }, [e]);
500
+ const r = L(() => {
501
+ n((h) => !h);
502
+ }, []), l = L(() => {
503
+ n(!1);
504
+ }, []), d = L((h, b) => {
505
+ o((m) => {
506
+ const p = new Map(m);
507
+ return p.set(h, b), p;
508
+ });
509
+ }, []), u = L((h) => {
510
+ o((b) => {
511
+ const m = new Map(b);
512
+ return m.delete(h), m;
513
+ });
514
+ }, []);
515
+ return {
516
+ internalValue: c,
517
+ setInternalValue: i,
518
+ isOpen: a,
519
+ toggleOpen: r,
520
+ closeListbox: l,
521
+ optionRegistry: t,
522
+ registerOption: d,
523
+ unregisterOption: u
524
+ };
525
+ }
526
+ function Qe(e, c) {
527
+ const [i, a] = D("bottom"), n = Be(null);
528
+ return $(() => {
529
+ if (c !== "popup" || !e) return;
530
+ const t = n.current;
531
+ if (!t) return;
532
+ t.matches(":popover-open") || t.showPopover(), requestAnimationFrame(() => {
533
+ const r = t.previousElementSibling;
534
+ if (!r) return;
535
+ const l = r.getBoundingClientRect(), d = t.getBoundingClientRect(), u = {
536
+ width: d.width,
537
+ height: d.height
538
+ }, h = Re(
539
+ l,
540
+ u,
541
+ 100,
542
+ ["top", "bottom"]
543
+ );
544
+ a(h);
545
+ });
546
+ }, [e, c]), { internalRef: n, placement: i };
547
+ }
548
+ const he = f(
549
+ ({ children: e, className: c, ...i }, a) => {
550
+ const n = E(), { internalRef: t, placement: o } = Qe(n.isOpen, n.variant);
551
+ $(() => {
552
+ const l = t.current;
553
+ if (!l) return;
554
+ const d = () => {
555
+ l.matches(":popover-open") || n.closeListbox();
556
+ };
557
+ return l.addEventListener("toggle", d), () => l.removeEventListener("toggle", d);
558
+ }, [n, t]);
559
+ const r = N({ placement: o });
560
+ return /* @__PURE__ */ s(
561
+ "ul",
562
+ {
563
+ ref: (l) => {
564
+ t.current = l, typeof a == "function" ? a(l) : a && (a.current = l);
565
+ },
566
+ role: "listbox",
567
+ "aria-multiselectable": "true",
568
+ className: y(v.listbox, c),
569
+ popover: "auto",
570
+ ...r,
571
+ style: {
572
+ positionAnchor: n.anchorName
573
+ },
574
+ ...i,
575
+ children: /* @__PURE__ */ g("div", { className: v["listbox-inner"], children: [
576
+ /* @__PURE__ */ s("div", { className: v["drawer-input-wrapper"], children: /* @__PURE__ */ s(
577
+ "input",
578
+ {
579
+ type: "text",
580
+ className: v["drawer-input"],
581
+ placeholder: "Search options...",
582
+ value: n.searchQuery || "",
583
+ onChange: (l) => {
584
+ var d;
585
+ return (d = n.setSearchQuery) == null ? void 0 : d.call(n, l.currentTarget.value);
586
+ },
587
+ "aria-label": "Search options"
588
+ }
589
+ ) }),
590
+ e
591
+ ] })
592
+ }
593
+ );
594
+ }
595
+ );
596
+ he.displayName = "ComboboxInput.Listbox";
597
+ const me = f(
598
+ ({
599
+ value: e,
600
+ onChange: c,
601
+ variant: i = "popup",
602
+ disabled: a = !1,
603
+ invalid: n = !1,
604
+ label: t,
605
+ helper: o,
606
+ error: r,
607
+ required: l = !1,
608
+ children: d,
609
+ className: u,
610
+ ...h
611
+ }, b) => {
612
+ const m = A(), p = h.id || m, x = o ? `${p}-helper` : void 0, C = r ? `${p}-error` : void 0, I = [x, C].filter(Boolean).join(" "), w = `--combobox-anchor-${p.replace(/[^a-z0-9-]/gi, "")}`, {
613
+ internalValue: O,
614
+ setInternalValue: S,
615
+ isOpen: V,
616
+ toggleOpen: F,
617
+ closeListbox: z,
618
+ optionRegistry: ve,
619
+ registerOption: Ce,
620
+ unregisterOption: ge
621
+ } = Pe(e), [ye, Ne] = D("");
622
+ $(() => {
623
+ S(e);
624
+ }, [e, S]);
625
+ const Ie = (H) => {
626
+ a || (S(H), c(H));
627
+ }, we = N({
628
+ invalid: !!(r || n),
629
+ disabled: a
630
+ });
631
+ return /* @__PURE__ */ g("div", { ref: b, className: y(v.field, u), ...we, ...h, children: [
632
+ t && /* @__PURE__ */ s(k, { required: l, disabled: a, children: t }),
633
+ /* @__PURE__ */ s(
634
+ pe.Provider,
635
+ {
636
+ value: {
637
+ value: O,
638
+ onChange: Ie,
639
+ isOpen: V,
640
+ toggleOpen: F,
641
+ closeListbox: z,
642
+ variant: i,
643
+ anchorName: w,
644
+ optionRegistry: ve,
645
+ registerOption: Ce,
646
+ unregisterOption: ge,
647
+ disabled: a,
648
+ searchQuery: ye,
649
+ setSearchQuery: Ne
650
+ },
651
+ children: /* @__PURE__ */ s("div", { className: v.root, "aria-describedby": I || void 0, children: d })
652
+ }
653
+ ),
654
+ r && /* @__PURE__ */ s(R, { id: C, children: r }),
655
+ !r && o && /* @__PURE__ */ s(B, { id: x, children: o })
656
+ ] });
657
+ }
658
+ );
659
+ me.displayName = "ComboboxInput";
660
+ const be = f(
661
+ ({ children: e, className: c, iconLeft: i, iconRight: a, ...n }, t) => {
662
+ const o = E(), r = o.value.length === 0, l = N({
663
+ open: o.isOpen,
664
+ disabled: o.disabled,
665
+ "has-left-icon": !!i,
666
+ "has-right-icon": !0
667
+ }), d = {
668
+ anchorName: o.anchorName
669
+ }, u = e || (r ? "Select" : `${o.value.length} selected`);
670
+ return /* @__PURE__ */ g(
671
+ "button",
672
+ {
673
+ ref: t,
674
+ type: "button",
675
+ className: y(v.button, c),
676
+ onClick: () => !o.disabled && o.toggleOpen(),
677
+ disabled: o.disabled,
678
+ "aria-expanded": o.isOpen,
679
+ "aria-haspopup": "listbox",
680
+ style: d,
681
+ ...l,
682
+ ...n,
450
683
  children: [
451
- d,
452
- n,
453
- a
684
+ i && /* @__PURE__ */ s("span", { className: v["left-icon"], children: i }),
685
+ /* @__PURE__ */ s("span", { className: v["button-content"], ...r && { "data-placeholder": "" }, children: u }),
686
+ a ? /* @__PURE__ */ s("span", { className: v["right-icon"], children: a }) : /* @__PURE__ */ s("span", { className: v["right-icon"], "data-chevron": !0, children: /* @__PURE__ */ s(Ae, {}) })
454
687
  ]
455
688
  }
456
689
  );
457
690
  }
458
691
  );
459
- ee.displayName = "ChipInput.Option";
460
- const Ce = Object.assign(q, {
461
- Option: ee
692
+ be.displayName = "ComboboxInput.Button";
693
+ const xe = f(
694
+ ({ value: e, children: c, disabled: i = !1, className: a, ...n }, t) => {
695
+ const o = E(), r = o.disabled || i, l = o.value.includes(e), d = typeof c == "string" ? c : String(e), u = !o.searchQuery || d.toLowerCase().includes(o.searchQuery.toLowerCase()) || e.toLowerCase().includes(o.searchQuery.toLowerCase());
696
+ $(() => (o.registerOption(e, d), () => o.unregisterOption(e)), [e, d, o.registerOption, o.unregisterOption]);
697
+ const h = () => {
698
+ if (r) return;
699
+ const p = l ? o.value.filter((x) => x !== e) : [...o.value, e];
700
+ o.onChange(p);
701
+ }, b = (p) => {
702
+ (p.key === "Enter" || p.key === " ") && (p.preventDefault(), h());
703
+ }, m = N({ selected: l, disabled: r });
704
+ return u ? /* @__PURE__ */ g(
705
+ "li",
706
+ {
707
+ ref: t,
708
+ role: "option",
709
+ className: y(v.option, a),
710
+ onClick: h,
711
+ onKeyDown: b,
712
+ "aria-selected": l,
713
+ tabIndex: r ? -1 : 0,
714
+ ...m,
715
+ ...n,
716
+ children: [
717
+ /* @__PURE__ */ s("span", { className: v["option-check"], children: /* @__PURE__ */ s(Ge, { width: "1em", height: "1em" }) }),
718
+ /* @__PURE__ */ s("span", { children: c })
719
+ ]
720
+ }
721
+ ) : null;
722
+ }
723
+ );
724
+ xe.displayName = "ComboboxInput.Option";
725
+ const fe = f(
726
+ ({ className: e, ...c }, i) => {
727
+ const a = E();
728
+ if (a.value.length === 0) return null;
729
+ const n = (t) => {
730
+ a.onChange(a.value.filter((o) => o !== t));
731
+ };
732
+ return /* @__PURE__ */ s("div", { ref: i, className: y(v.chips, e), role: "group", ...c, children: a.value.map((t) => {
733
+ const o = a.optionRegistry.get(t) ?? t;
734
+ return /* @__PURE__ */ g("div", { className: v.chip, ...N({ disabled: a.disabled }), children: [
735
+ /* @__PURE__ */ s("span", { children: o }),
736
+ /* @__PURE__ */ s(
737
+ "button",
738
+ {
739
+ type: "button",
740
+ className: v["chip-remove"],
741
+ onClick: () => n(t),
742
+ disabled: a.disabled,
743
+ "aria-label": `Remove ${o}`,
744
+ children: /* @__PURE__ */ s(De, { width: "1em", height: "1em" })
745
+ }
746
+ )
747
+ ] }, t);
748
+ }) });
749
+ }
750
+ );
751
+ fe.displayName = "ComboboxInput.SelectionChips";
752
+ const We = Object.assign(me, {
753
+ Button: be,
754
+ Listbox: he,
755
+ Drawer: ue,
756
+ Option: xe,
757
+ SelectionChips: fe
462
758
  });
463
759
  export {
464
- K as Checkbox,
465
- ye as CheckboxGroup,
466
- Ce as ChipInput,
467
- O as ErrorText,
760
+ te as Checkbox,
761
+ Je as CheckboxGroup,
762
+ Ue as ChipInput,
763
+ We as ComboboxInput,
764
+ R as ErrorText,
468
765
  B as HelperText,
469
766
  k as Label,
470
- J as Radio,
471
- xe as RadioGroup,
472
- z as Select,
473
- ce as TextArea,
474
- de as TextInput
767
+ ee as Radio,
768
+ Xe as RadioGroup,
769
+ q as Select,
770
+ Ee as TextArea,
771
+ $e as TextInput
475
772
  };