@versaur/react 1.0.7 → 1.0.9

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,578 +1,475 @@
1
- import { jsx as n, jsxs as I } from "react/jsx-runtime";
2
- import { labelStyles as ae, helperTextStyles as se, errorTextStyles as de, textInputStyles as $, textAreaStyles as P, selectStyles as H, radioStyles as M, checkboxStyles as T, radioGroupStyles as A, checkboxGroupStyles as j, chipSingleInputStyles as F, chipMultipleInputStyles as L } from "@versaur/core/forms";
3
- import { forwardRef as b, useId as O, createContext as E, useContext as D } from "react";
4
- import { u as y } from "./use-data-attrs-iPFyfiKN.js";
5
- import { c as x } from "./cx-B9vmfsc1.js";
6
- const k = b(
7
- ({ required: e = !1, disabled: o = !1, children: t, className: s, ...a }, i) => {
8
- const c = y({
9
- disabled: o,
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,
10
10
  required: e
11
11
  });
12
- return /* @__PURE__ */ n("label", { ref: i, className: x(ae.label, s), ...c, ...a, children: t });
12
+ return /* @__PURE__ */ i("label", { ref: o, className: b(ie.label, d), ...c, ...a, children: t });
13
13
  }
14
14
  );
15
15
  k.displayName = "Label";
16
- const B = b(({ children: e, className: o, ...t }, s) => /* @__PURE__ */ n("p", { ref: s, className: x(se.helper, o), ...t, children: e }));
16
+ const B = v(({ children: e, className: n, ...t }, d) => /* @__PURE__ */ i("p", { ref: d, className: b(ae.helper, n), ...t, children: e }));
17
17
  B.displayName = "HelperText";
18
- const G = b(({ children: e, className: o, ...t }, s) => /* @__PURE__ */ n("p", { ref: s, className: x(de.error, o), role: "alert", "aria-live": "polite", ...t, children: e }));
19
- G.displayName = "ErrorText";
20
- const ce = b(
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(
21
21
  ({
22
22
  label: e,
23
- helper: o,
23
+ helper: n,
24
24
  error: t,
25
- required: s = !1,
25
+ required: d = !1,
26
26
  disabled: a = !1,
27
- readOnly: i = !1,
27
+ readOnly: o = !1,
28
28
  leftIcon: c,
29
- rightIcon: d,
29
+ rightIcon: s,
30
30
  id: l,
31
- className: r,
32
- ...u
33
- }, v) => {
34
- const h = O(), m = l || h, p = o ? `${m}-helper` : void 0, f = t ? `${m}-error` : void 0, C = [p, f].filter(Boolean).join(" "), N = y({
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
35
  disabled: a,
36
36
  hasLeftIcon: !!c,
37
- hasRightIcon: !!d,
37
+ hasRightIcon: !!s,
38
38
  invalid: !!t,
39
- readOnly: i
39
+ readOnly: o
40
40
  });
41
- return /* @__PURE__ */ I("div", { className: x($.field, r), children: [
42
- e && /* @__PURE__ */ n(k, { htmlFor: m, required: s, disabled: a, children: e }),
43
- /* @__PURE__ */ I("div", { className: $.wrapper, ...N, children: [
44
- c && /* @__PURE__ */ n("span", { className: $["left-icon"], children: c }),
45
- /* @__PURE__ */ n(
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(
46
46
  "input",
47
47
  {
48
- ref: v,
49
- id: m,
48
+ ref: x,
49
+ id: u,
50
50
  type: "text",
51
- className: $.input,
51
+ className: w.input,
52
52
  disabled: a,
53
- readOnly: i,
54
- required: s,
53
+ readOnly: o,
54
+ required: d,
55
55
  "aria-invalid": t ? "true" : void 0,
56
56
  "aria-disabled": a ? "true" : void 0,
57
- "aria-describedby": C || void 0,
58
- ...u
57
+ "aria-describedby": y || void 0,
58
+ ...p
59
59
  }
60
60
  ),
61
- d && /* @__PURE__ */ n("span", { className: $["right-icon"], children: d })
61
+ s && /* @__PURE__ */ i("span", { className: w["right-icon"], children: s })
62
62
  ] }),
63
- t && /* @__PURE__ */ n(G, { id: f, children: t }),
64
- !t && o && /* @__PURE__ */ n(B, { id: p, children: o })
63
+ t && /* @__PURE__ */ i(O, { id: h, children: t }),
64
+ !t && n && /* @__PURE__ */ i(B, { id: r, children: n })
65
65
  ] });
66
66
  }
67
67
  );
68
- ce.displayName = "TextInput";
69
- const le = b(
68
+ de.displayName = "TextInput";
69
+ const ce = v(
70
70
  ({
71
71
  label: e,
72
- helper: o,
72
+ helper: n,
73
73
  error: t,
74
- required: s = !1,
74
+ required: d = !1,
75
75
  disabled: a = !1,
76
- readOnly: i = !1,
76
+ readOnly: o = !1,
77
77
  resizable: c = !0,
78
- minRows: d = 3,
78
+ minRows: s = 3,
79
79
  maxRows: l,
80
- id: r,
81
- className: u,
82
- ...v
83
- }, h) => {
84
- const m = O(), p = r || m, f = o ? `${p}-helper` : void 0, C = t ? `${p}-error` : void 0, N = [f, C].filter(Boolean).join(" "), g = y({
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
85
  disabled: a,
86
86
  invalid: !!t,
87
- readOnly: i,
87
+ readOnly: o,
88
88
  resizable: c ? "true" : "false",
89
89
  minRows: "true",
90
90
  ...l && { maxRows: "true" }
91
- }), S = {
92
- "--_min-rows-count": d,
91
+ }), G = {
92
+ "--_min-rows-count": s,
93
93
  ...l && { "--_max-rows-count": l }
94
94
  };
95
- return /* @__PURE__ */ I("div", { className: x(P.field, u), children: [
96
- e && /* @__PURE__ */ n(k, { htmlFor: p, required: s, disabled: a, children: e }),
97
- /* @__PURE__ */ n(
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(
98
98
  "textarea",
99
99
  {
100
- ref: h,
101
- id: p,
102
- className: P.textarea,
100
+ ref: m,
101
+ id: r,
102
+ className: D.textarea,
103
103
  disabled: a,
104
- readOnly: i,
105
- required: s,
106
- style: S,
104
+ readOnly: o,
105
+ required: d,
106
+ style: G,
107
107
  "aria-invalid": t ? "true" : void 0,
108
108
  "aria-disabled": a ? "true" : void 0,
109
109
  "aria-describedby": N || void 0,
110
110
  ...g,
111
- ...v
111
+ ...x
112
112
  }
113
113
  ),
114
- t && /* @__PURE__ */ n(G, { id: C, children: t }),
115
- !t && o && /* @__PURE__ */ n(B, { id: f, children: o })
114
+ t && /* @__PURE__ */ i(O, { id: y, children: t }),
115
+ !t && n && /* @__PURE__ */ i(B, { id: h, children: n })
116
116
  ] });
117
117
  }
118
118
  );
119
- le.displayName = "TextArea";
120
- const V = b(({ children: e, ...o }, t) => /* @__PURE__ */ n("option", { ref: t, ...o, children: e }));
121
- V.displayName = "Select.Option";
122
- const _ = b(
123
- ({ label: e, children: o, ...t }, s) => /* @__PURE__ */ n("optgroup", { ref: s, label: e, ...t, children: o })
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 })
124
124
  );
125
- _.displayName = "Select.OptionGroup";
126
- const z = b(
125
+ L.displayName = "Select.OptionGroup";
126
+ const _ = v(
127
127
  ({
128
128
  label: e,
129
- helper: o,
129
+ helper: n,
130
130
  error: t,
131
- required: s = !1,
131
+ required: d = !1,
132
132
  disabled: a = !1,
133
- placeholder: i,
133
+ placeholder: o,
134
134
  children: c,
135
- id: d,
135
+ id: s,
136
136
  className: l,
137
- ...r
138
- }, u) => {
139
- const v = O(), h = d || v, m = o ? `${h}-helper` : void 0, p = t ? `${h}-error` : void 0, f = [m, p].filter(Boolean).join(" "), C = y({
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
140
  disabled: a,
141
141
  invalid: !!t
142
142
  });
143
- return /* @__PURE__ */ I("div", { className: x(H.field, l), children: [
144
- e && /* @__PURE__ */ n(k, { htmlFor: h, required: s, disabled: a, children: e }),
145
- /* @__PURE__ */ I(
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(
146
146
  "select",
147
147
  {
148
- ref: u,
149
- id: h,
150
- className: H.select,
148
+ ref: p,
149
+ id: m,
150
+ className: F.select,
151
151
  disabled: a,
152
- required: s,
152
+ required: d,
153
153
  "aria-invalid": t ? "true" : void 0,
154
154
  "aria-disabled": a ? "true" : void 0,
155
- "aria-describedby": f || void 0,
156
- ...C,
157
- ...r,
155
+ "aria-describedby": h || void 0,
156
+ ...y,
157
+ ...f,
158
158
  children: [
159
- i && /* @__PURE__ */ n("option", { value: "", disabled: !0, children: i }),
159
+ o && /* @__PURE__ */ i("option", { value: "", disabled: !0, children: o }),
160
160
  c
161
161
  ]
162
162
  }
163
163
  ),
164
- t && /* @__PURE__ */ n(G, { id: p, children: t }),
165
- !t && o && /* @__PURE__ */ n(B, { id: m, children: o })
164
+ t && /* @__PURE__ */ i(O, { id: r, children: t }),
165
+ !t && n && /* @__PURE__ */ i(B, { id: u, children: n })
166
166
  ] });
167
167
  }
168
168
  );
169
- z.displayName = "Select";
170
- const J = z;
171
- J.Option = V;
172
- J.OptionGroup = _;
173
- const re = b(
174
- ({ variant: e = "outline", size: o = "medium", invalid: t = !1, disabled: s = !1, children: a, className: i, ...c }, d) => {
175
- const l = y({
176
- disabled: s,
177
- invalid: t,
178
- size: o,
179
- variant: e
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({
176
+ disabled: e
180
177
  });
181
- return /* @__PURE__ */ I("label", { className: x(M.radio, i), ...l, children: [
182
- /* @__PURE__ */ n(
178
+ return /* @__PURE__ */ C("label", { className: b(R.radio, t), ...o, children: [
179
+ /* @__PURE__ */ i(
183
180
  "input",
184
181
  {
185
- ref: d,
182
+ ref: a,
186
183
  type: "radio",
187
- className: M.input,
188
- disabled: s,
189
- "aria-invalid": t || void 0,
190
- ...c
184
+ className: R.input,
185
+ disabled: e,
186
+ ...d
191
187
  }
192
188
  ),
193
- /* @__PURE__ */ n("span", { className: M.indicator }),
194
- a && /* @__PURE__ */ n("span", { className: M.label, children: a })
189
+ /* @__PURE__ */ i("span", { className: R.indicator }),
190
+ n && /* @__PURE__ */ i("span", { className: R.label, children: n })
195
191
  ] });
196
192
  }
197
193
  );
198
- re.displayName = "Radio";
199
- const pe = b(
200
- ({ invalid: e = !1, disabled: o = !1, required: t = !1, children: s, className: a, ...i }, c) => {
201
- const d = y({
202
- disabled: o,
203
- invalid: e,
204
- required: t
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({
198
+ disabled: e,
199
+ required: n
205
200
  });
206
- return /* @__PURE__ */ I("label", { className: x(T.checkbox, a), ...d, children: [
207
- /* @__PURE__ */ n(
201
+ return /* @__PURE__ */ C("label", { className: b($.checkbox, d), ...c, children: [
202
+ /* @__PURE__ */ i(
208
203
  "input",
209
204
  {
210
- ref: c,
205
+ ref: o,
211
206
  type: "checkbox",
212
- className: T.input,
213
- disabled: o,
214
- required: t,
215
- "aria-invalid": e || void 0,
216
- "aria-required": t || void 0,
217
- ...i
207
+ className: $.input,
208
+ disabled: e,
209
+ required: n,
210
+ "aria-required": n || void 0,
211
+ ...a
218
212
  }
219
213
  ),
220
- /* @__PURE__ */ n("span", { className: T.indicator }),
221
- s && /* @__PURE__ */ n("span", { className: T.label, "data-required": t || void 0, children: s })
214
+ /* @__PURE__ */ i("span", { className: $.indicator }),
215
+ t && /* @__PURE__ */ i("span", { className: $.label, "data-required": n || void 0, children: t })
222
216
  ] });
223
217
  }
224
218
  );
225
- pe.displayName = "Checkbox";
226
- const K = E(void 0);
227
- function ue() {
228
- const e = D(K);
219
+ K.displayName = "Checkbox";
220
+ const M = T(void 0);
221
+ function le() {
222
+ const e = E(M);
229
223
  if (!e)
230
224
  throw new Error("RadioGroup.Option must be used within RadioGroup");
231
225
  return e;
232
226
  }
233
- const Q = b(
227
+ const Q = v(
234
228
  ({
235
229
  value: e,
236
- onChange: o,
230
+ onChange: n,
237
231
  name: t,
238
- variant: s = "outline",
239
- size: a = "medium",
240
- label: i,
241
- helper: c,
242
- error: d,
243
- required: l = !1,
244
- disabled: r = !1,
245
- direction: u = "column",
246
- children: v,
247
- className: h,
248
- ...m
249
- }, p) => {
250
- const f = O(), C = m.id || f, N = c ? `${C}-helper` : void 0, g = d ? `${C}-error` : void 0, S = [N, g].filter(Boolean).join(" "), w = (oe) => {
251
- !r && o && o(oe);
252
- }, R = y({
253
- disabled: r,
254
- invalid: !!d,
255
- size: a === "medium" ? void 0 : a,
256
- variant: a === "medium" ? s : void 0
232
+ label: d,
233
+ helper: a,
234
+ error: o,
235
+ required: c = !1,
236
+ disabled: s = !1,
237
+ 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
257
246
  });
258
- return /* @__PURE__ */ I("div", { ref: p, className: x(A.field, h), ...R, ...m, children: [
259
- i && /* @__PURE__ */ n(k, { required: l, disabled: r, children: i }),
260
- /* @__PURE__ */ n(K.Provider, { value: { disabled: r, name: t, onChange: w, value: e }, children: /* @__PURE__ */ n(
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(
261
250
  "div",
262
251
  {
263
- className: A.options,
264
- "data-direction": u,
252
+ className: P.options,
253
+ "data-direction": l,
265
254
  role: "radiogroup",
266
- "aria-describedby": S || void 0,
267
- "aria-invalid": d ? "true" : void 0,
268
- children: v
255
+ "aria-describedby": N || void 0,
256
+ "aria-invalid": o ? "true" : void 0,
257
+ children: f
269
258
  }
270
259
  ) }),
271
- d && /* @__PURE__ */ n(G, { id: g, children: d }),
272
- !d && c && /* @__PURE__ */ n(B, { id: N, children: c })
260
+ o && /* @__PURE__ */ i(O, { id: y, children: o }),
261
+ !o && a && /* @__PURE__ */ i(B, { id: h, children: a })
273
262
  ] });
274
263
  }
275
264
  );
276
265
  Q.displayName = "RadioGroup";
277
- const U = b(
278
- ({ value: e, children: o, disabled: t, className: s, ...a }, i) => {
279
- const c = ue(), d = c.value === e, l = c.disabled || t, r = () => {
280
- l || c.onChange(e);
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);
281
270
  };
282
- return /* @__PURE__ */ I("label", { className: x(A.option, s), children: [
283
- /* @__PURE__ */ n(
284
- "input",
285
- {
286
- ref: i,
287
- type: "radio",
288
- name: c.name,
289
- value: e,
290
- checked: d,
291
- disabled: l,
292
- onChange: r,
293
- className: A.input,
294
- ...a
295
- }
296
- ),
297
- /* @__PURE__ */ n("span", { className: A.indicator }),
298
- o && /* @__PURE__ */ n("span", { className: A.optionLabel, children: o })
299
- ] });
271
+ return /* @__PURE__ */ i(
272
+ J,
273
+ {
274
+ ref: a,
275
+ name: o.name,
276
+ value: e,
277
+ checked: c,
278
+ disabled: s,
279
+ onChange: l,
280
+ ...d,
281
+ children: n
282
+ }
283
+ );
300
284
  }
301
285
  );
302
286
  U.displayName = "RadioGroup.Option";
303
- const Ie = Object.assign(Q, {
287
+ const xe = Object.assign(Q, {
304
288
  Option: U
305
- }), W = E(void 0);
306
- function he() {
307
- const e = D(W);
289
+ }), W = T(void 0);
290
+ function re() {
291
+ const e = E(W);
308
292
  if (!e)
309
293
  throw new Error("CheckboxGroup.Option must be used within CheckboxGroup");
310
294
  return e;
311
295
  }
312
- const X = b(
296
+ const X = v(
313
297
  ({
314
298
  value: e,
315
- onChange: o,
299
+ onChange: n,
316
300
  name: t,
317
- label: s,
301
+ label: d,
318
302
  helper: a,
319
- error: i,
303
+ error: o,
320
304
  required: c = !1,
321
- disabled: d = !1,
305
+ disabled: s = !1,
322
306
  direction: l = "column",
323
- children: r,
324
- className: u,
325
- ...v
326
- }, h) => {
327
- const m = O(), p = v.id || m, f = a ? `${p}-helper` : void 0, C = i ? `${p}-error` : void 0, N = [f, C].filter(Boolean).join(" "), g = (w) => {
328
- !d && o && o(w);
329
- }, S = y({
330
- disabled: d,
331
- invalid: !!i
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
332
315
  });
333
- return /* @__PURE__ */ I("div", { ref: h, className: x(j.field, u), ...S, ...v, children: [
334
- s && /* @__PURE__ */ n(k, { required: c, disabled: d, children: s }),
335
- /* @__PURE__ */ n(W.Provider, { value: { disabled: d, name: t, onChange: g, value: e }, children: /* @__PURE__ */ n(
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(
336
319
  "div",
337
320
  {
338
- className: j.options,
321
+ className: V.options,
339
322
  "data-direction": l,
340
323
  role: "group",
341
324
  "aria-describedby": N || void 0,
342
- "aria-invalid": i ? "true" : void 0,
343
- children: r
325
+ "aria-invalid": o ? "true" : void 0,
326
+ children: f
344
327
  }
345
328
  ) }),
346
- i && /* @__PURE__ */ n(G, { id: C, children: i }),
347
- !i && a && /* @__PURE__ */ n(B, { id: f, children: a })
329
+ o && /* @__PURE__ */ i(O, { id: y, children: o }),
330
+ !o && a && /* @__PURE__ */ i(B, { id: h, children: a })
348
331
  ] });
349
332
  }
350
333
  );
351
334
  X.displayName = "CheckboxGroup";
352
- const Y = b(
353
- ({ value: e, children: o, disabled: t, required: s = !1, className: a, ...i }, c) => {
354
- const d = O(), l = he(), r = l.value.includes(e), u = l.disabled || t, v = () => {
355
- if (!u) {
356
- const m = r ? l.value.filter((p) => p !== e) : [...l.value, e];
357
- l.onChange(m);
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);
358
341
  }
359
- }, h = y({
360
- disabled: u,
361
- required: s
362
- });
363
- return /* @__PURE__ */ I("label", { className: x(j.option, a), ...h, children: [
364
- /* @__PURE__ */ n(
365
- "input",
366
- {
367
- ref: c,
368
- type: "checkbox",
369
- name: l.name,
370
- value: e,
371
- checked: r,
372
- disabled: u,
373
- required: s,
374
- onChange: v,
375
- className: j.input,
376
- "aria-required": s || void 0,
377
- ...i,
378
- id: d
379
- }
380
- ),
381
- /* @__PURE__ */ n("span", { className: j.indicator }),
382
- o && /* @__PURE__ */ n(k, { required: s, disabled: u, htmlFor: d, children: o })
383
- ] });
342
+ };
343
+ return /* @__PURE__ */ i(
344
+ K,
345
+ {
346
+ ref: a,
347
+ name: o.name,
348
+ value: e,
349
+ checked: c,
350
+ disabled: s,
351
+ onChange: l,
352
+ ...d,
353
+ children: n
354
+ }
355
+ );
384
356
  }
385
357
  );
386
358
  Y.displayName = "CheckboxGroup.Option";
387
359
  const ye = Object.assign(X, {
388
360
  Option: Y
389
- }), Z = E(void 0);
390
- function me() {
391
- const e = D(Z);
361
+ }), Z = T(void 0);
362
+ function pe() {
363
+ const e = E(Z);
392
364
  if (!e)
393
- throw new Error("ChipSingleInput.Option must be used within ChipSingleInput");
365
+ throw new Error("ChipInput.Option must be used within ChipInput");
394
366
  return e;
395
367
  }
396
- const q = b(
368
+ const q = v(
397
369
  ({
398
370
  value: e,
399
- onChange: o,
400
- name: t,
401
- label: s,
402
- helper: a,
403
- error: i,
404
- required: c = !1,
405
- disabled: d = !1,
406
- gap: l = "2",
407
- wrap: r = !0,
408
- children: u,
409
- className: v,
410
- ...h
411
- }, m) => {
412
- const p = O(), f = h.id || p, C = a ? `${f}-helper` : void 0, N = i ? `${f}-error` : void 0, g = [C, N].filter(Boolean).join(" "), S = (R) => {
413
- !d && o && o(R);
414
- }, w = y({
415
- invalid: !!i
416
- });
417
- return /* @__PURE__ */ I("div", { ref: m, className: x(F.field, v), ...w, ...h, children: [
418
- s && /* @__PURE__ */ n(k, { required: c, disabled: d, children: s }),
419
- /* @__PURE__ */ n(
371
+ onChange: n,
372
+ multiple: t = !1,
373
+ name: d,
374
+ label: a,
375
+ helper: o,
376
+ error: c,
377
+ required: s = !1,
378
+ 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(
420
393
  Z.Provider,
421
394
  {
422
395
  value: {
423
- disabled: d,
424
- name: t,
425
- onChange: S,
396
+ disabled: l,
397
+ multiple: t,
398
+ name: d,
399
+ onChange: A,
426
400
  value: e
427
401
  },
428
- children: /* @__PURE__ */ n(
402
+ children: /* @__PURE__ */ i(
429
403
  "div",
430
404
  {
431
- className: F.options,
432
- "data-gap": l,
433
- "data-wrap": r,
434
- role: "radiogroup",
435
- "aria-describedby": g || void 0,
436
- "aria-invalid": i ? "true" : void 0,
437
- children: u
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
438
412
  }
439
413
  )
440
414
  }
441
415
  ),
442
- i && /* @__PURE__ */ n(G, { id: N, children: i }),
443
- !i && a && /* @__PURE__ */ n(B, { id: C, children: a })
416
+ c && /* @__PURE__ */ i(O, { id: g, children: c }),
417
+ !c && o && /* @__PURE__ */ i(B, { id: N, children: o })
444
418
  ] });
445
419
  }
446
420
  );
447
- q.displayName = "ChipSingleInput";
448
- const ee = b(
449
- ({ value: e, children: o, disabled: t, ...s }, a) => {
450
- const i = me(), c = i.value === e, d = i.disabled || t, l = () => {
451
- !d && i.onChange && i.onChange(e);
452
- }, r = y({
453
- disabled: d,
454
- selected: c
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 = () => {
428
+ 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);
432
+ } else
433
+ s.onChange(e);
434
+ }, m = I({
435
+ disabled: l,
436
+ selected: p,
437
+ ...f && { "has-icon": !0 }
455
438
  });
456
- return /* @__PURE__ */ n(
439
+ return /* @__PURE__ */ C(
457
440
  "button",
458
441
  {
459
- ref: a,
442
+ ref: c,
460
443
  type: "button",
461
- className: F.option,
462
- onClick: l,
463
- disabled: d,
464
- "aria-pressed": c,
465
- ...r,
466
- ...s,
467
- children: o
444
+ className: j.option,
445
+ onClick: x,
446
+ disabled: l,
447
+ "aria-pressed": p,
448
+ ...m,
449
+ ...o,
450
+ children: [
451
+ d,
452
+ n,
453
+ a
454
+ ]
468
455
  }
469
456
  );
470
457
  }
471
458
  );
472
- ee.displayName = "ChipSingleInput.Option";
473
- const ge = Object.assign(q, {
459
+ ee.displayName = "ChipInput.Option";
460
+ const Ce = Object.assign(q, {
474
461
  Option: ee
475
- }), te = E(void 0);
476
- function ve() {
477
- const e = D(te);
478
- if (!e)
479
- throw new Error("ChipMultipleInput.Option must be used within ChipMultipleInput");
480
- return e;
481
- }
482
- const ie = b(
483
- ({
484
- value: e,
485
- onChange: o,
486
- name: t,
487
- label: s,
488
- helper: a,
489
- error: i,
490
- required: c = !1,
491
- disabled: d = !1,
492
- gap: l = "2",
493
- wrap: r = !0,
494
- children: u,
495
- className: v,
496
- ...h
497
- }, m) => {
498
- const p = O(), f = h.id || p, C = a ? `${f}-helper` : void 0, N = i ? `${f}-error` : void 0, g = [C, N].filter(Boolean).join(" "), S = (R) => {
499
- !d && o && o(R);
500
- }, w = y({
501
- invalid: !!i
502
- });
503
- return /* @__PURE__ */ I("div", { ref: m, className: x(L.field, v), ...w, ...h, children: [
504
- s && /* @__PURE__ */ n(k, { required: c, disabled: d, children: s }),
505
- /* @__PURE__ */ n(
506
- te.Provider,
507
- {
508
- value: {
509
- disabled: d,
510
- name: t,
511
- onChange: S,
512
- value: e
513
- },
514
- children: /* @__PURE__ */ n(
515
- "div",
516
- {
517
- className: L.options,
518
- "data-gap": l,
519
- "data-wrap": r,
520
- role: "group",
521
- "aria-describedby": g || void 0,
522
- "aria-invalid": i ? "true" : void 0,
523
- children: u
524
- }
525
- )
526
- }
527
- ),
528
- i && /* @__PURE__ */ n(G, { id: N, children: i }),
529
- !i && a && /* @__PURE__ */ n(B, { id: C, children: a })
530
- ] });
531
- }
532
- );
533
- ie.displayName = "ChipMultipleInput";
534
- const ne = b(
535
- ({ value: e, children: o, disabled: t, ...s }, a) => {
536
- const i = ve(), c = i.value.includes(e), d = i.disabled || t, l = () => {
537
- if (!d && i.onChange) {
538
- const u = c ? i.value.filter((v) => v !== e) : [...i.value, e];
539
- i.onChange(u);
540
- }
541
- }, r = y({
542
- disabled: d,
543
- selected: c
544
- });
545
- return /* @__PURE__ */ n(
546
- "button",
547
- {
548
- ref: a,
549
- type: "button",
550
- className: L.option,
551
- onClick: l,
552
- disabled: d,
553
- "aria-pressed": c,
554
- ...r,
555
- ...s,
556
- children: o
557
- }
558
- );
559
- }
560
- );
561
- ne.displayName = "ChipMultipleInput.Option";
562
- const Se = Object.assign(ie, {
563
- Option: ne
564
462
  });
565
463
  export {
566
- pe as Checkbox,
464
+ K as Checkbox,
567
465
  ye as CheckboxGroup,
568
- Se as ChipMultipleInput,
569
- ge as ChipSingleInput,
570
- G as ErrorText,
466
+ Ce as ChipInput,
467
+ O as ErrorText,
571
468
  B as HelperText,
572
469
  k as Label,
573
- re as Radio,
574
- Ie as RadioGroup,
575
- J as Select,
576
- le as TextArea,
577
- ce as TextInput
470
+ J as Radio,
471
+ xe as RadioGroup,
472
+ z as Select,
473
+ ce as TextArea,
474
+ de as TextInput
578
475
  };