@spark-ui/components 10.0.2 → 10.0.3

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 (44) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/checkbox/index.js +117 -478
  3. package/dist/checkbox/index.js.map +1 -1
  4. package/dist/checkbox/index.mjs +3 -4
  5. package/dist/checkbox/index.mjs.map +1 -1
  6. package/dist/{chunk-JC6KKYUQ.mjs → chunk-7BTJUYP3.mjs} +6 -5
  7. package/dist/{chunk-JC6KKYUQ.mjs.map → chunk-7BTJUYP3.mjs.map} +1 -1
  8. package/dist/combobox/index.js +301 -710
  9. package/dist/combobox/index.js.map +1 -1
  10. package/dist/combobox/index.mjs +3 -5
  11. package/dist/combobox/index.mjs.map +1 -1
  12. package/dist/dropdown/index.js +252 -662
  13. package/dist/dropdown/index.js.map +1 -1
  14. package/dist/dropdown/index.mjs +1 -4
  15. package/dist/dropdown/index.mjs.map +1 -1
  16. package/dist/form-field/index.mjs +373 -7
  17. package/dist/form-field/index.mjs.map +1 -1
  18. package/dist/input/index.js +47 -454
  19. package/dist/input/index.js.map +1 -1
  20. package/dist/input/index.mjs +1 -3
  21. package/dist/radio-group/index.js +47 -553
  22. package/dist/radio-group/index.js.map +1 -1
  23. package/dist/radio-group/index.mjs +3 -9
  24. package/dist/radio-group/index.mjs.map +1 -1
  25. package/dist/select/index.js +159 -569
  26. package/dist/select/index.js.map +1 -1
  27. package/dist/select/index.mjs +1 -4
  28. package/dist/select/index.mjs.map +1 -1
  29. package/dist/stepper/index.js +110 -516
  30. package/dist/stepper/index.js.map +1 -1
  31. package/dist/stepper/index.mjs +2 -5
  32. package/dist/stepper/index.mjs.map +1 -1
  33. package/dist/switch/index.js +96 -545
  34. package/dist/switch/index.js.map +1 -1
  35. package/dist/switch/index.mjs +3 -6
  36. package/dist/switch/index.mjs.map +1 -1
  37. package/dist/textarea/index.js +58 -465
  38. package/dist/textarea/index.js.map +1 -1
  39. package/dist/textarea/index.mjs +1 -3
  40. package/dist/textarea/index.mjs.map +1 -1
  41. package/package.json +16 -6
  42. package/tsup.config.ts +2 -1
  43. package/dist/chunk-7PMPYEHJ.mjs +0 -379
  44. package/dist/chunk-7PMPYEHJ.mjs.map +0 -1
@@ -24,9 +24,17 @@ __export(switch_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(switch_exports);
26
26
 
27
- // src/form-field/FormField.tsx
28
- var import_class_variance_authority = require("class-variance-authority");
29
- var import_react4 = require("react");
27
+ // src/switch/Switch.tsx
28
+ var import_form_field2 = require("@spark-ui/components/form-field");
29
+ var import_class_variance_authority5 = require("class-variance-authority");
30
+ var import_react2 = require("react");
31
+
32
+ // src/switch/SwitchInput.tsx
33
+ var import_form_field = require("@spark-ui/components/form-field");
34
+ var import_Check = require("@spark-ui/icons/Check");
35
+ var import_Close = require("@spark-ui/icons/Close");
36
+ var import_use_combined_state = require("@spark-ui/use-combined-state");
37
+ var import_radix_ui2 = require("radix-ui");
30
38
 
31
39
  // src/slot/Slot.tsx
32
40
  var import_radix_ui = require("radix-ui");
@@ -37,516 +45,11 @@ var Slot = ({ ref, ...props }) => {
37
45
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Slot.Root, { ref, ...props });
38
46
  };
39
47
 
40
- // src/form-field/FormFieldContext.tsx
41
- var import_react2 = require("react");
42
- var FormFieldContext = (0, import_react2.createContext)(null);
43
- var ID_PREFIX = ":form-field";
44
- var useFormField = () => {
45
- const context = (0, import_react2.useContext)(FormFieldContext);
46
- if (!context) {
47
- throw Error("useFormField must be used within a FormField provider");
48
- }
49
- return context;
50
- };
51
-
52
- // src/form-field/FormFieldProvider.tsx
53
- var import_react3 = require("react");
54
- var import_jsx_runtime2 = require("react/jsx-runtime");
55
- var FormFieldProvider = ({
56
- id,
57
- name,
58
- disabled = false,
59
- readOnly = false,
60
- state,
61
- isRequired,
62
- children
63
- }) => {
64
- const labelId = `${ID_PREFIX}-label-${(0, import_react3.useId)()}`;
65
- const [messageIds, setMessageIds] = (0, import_react3.useState)([]);
66
- const description = messageIds.length > 0 ? messageIds.join(" ") : void 0;
67
- const handleMessageIdAdd = (0, import_react3.useCallback)((msgId) => {
68
- setMessageIds((ids) => [...ids, msgId]);
69
- }, []);
70
- const handleMessageIdRemove = (0, import_react3.useCallback)((msgId) => {
71
- setMessageIds((ids) => ids.filter((current) => current !== msgId));
72
- }, []);
73
- const value = (0, import_react3.useMemo)(() => {
74
- const isInvalid = state === "error";
75
- return {
76
- id,
77
- labelId,
78
- name,
79
- disabled,
80
- readOnly,
81
- state,
82
- isRequired,
83
- isInvalid,
84
- description,
85
- onMessageIdAdd: handleMessageIdAdd,
86
- onMessageIdRemove: handleMessageIdRemove
87
- };
88
- }, [
89
- id,
90
- labelId,
91
- name,
92
- disabled,
93
- readOnly,
94
- description,
95
- state,
96
- isRequired,
97
- handleMessageIdAdd,
98
- handleMessageIdRemove
99
- ]);
100
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FormFieldContext.Provider, { value, children });
101
- };
102
- FormFieldProvider.displayName = "FormFieldProvider";
103
-
104
- // src/form-field/FormField.tsx
105
- var import_jsx_runtime3 = require("react/jsx-runtime");
106
- var FormField = ({
107
- className,
108
- disabled = false,
109
- readOnly = false,
110
- name,
111
- state,
112
- isRequired = false,
113
- asChild = false,
114
- ref,
115
- ...others
116
- }) => {
117
- const id = `${ID_PREFIX}-${(0, import_react4.useId)()}`;
118
- const Component = asChild ? Slot : "div";
119
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
120
- FormFieldProvider,
121
- {
122
- id,
123
- name,
124
- isRequired,
125
- disabled,
126
- readOnly,
127
- state,
128
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
129
- Component,
130
- {
131
- ref,
132
- "data-spark-component": "form-field",
133
- className: (0, import_class_variance_authority.cx)(className, "gap-sm flex flex-col"),
134
- ...others
135
- }
136
- )
137
- }
138
- );
139
- };
140
- FormField.displayName = "FormField";
141
-
142
- // src/form-field/FormFieldStateMessage.tsx
143
- var import_AlertOutline = require("@spark-ui/icons/AlertOutline");
144
- var import_Check = require("@spark-ui/icons/Check");
145
- var import_WarningOutline = require("@spark-ui/icons/WarningOutline");
146
- var import_class_variance_authority4 = require("class-variance-authority");
147
-
148
- // src/icon/Icon.tsx
149
- var import_react5 = require("react");
150
-
151
- // src/visually-hidden/VisuallyHidden.tsx
152
- var import_jsx_runtime4 = require("react/jsx-runtime");
153
- var VisuallyHidden = ({ asChild = false, ref, ...props }) => {
154
- const Component = asChild ? Slot : "span";
155
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
156
- Component,
157
- {
158
- ...props,
159
- ref,
160
- style: {
161
- // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
162
- position: "absolute",
163
- border: 0,
164
- width: 1,
165
- height: 1,
166
- padding: 0,
167
- margin: -1,
168
- overflow: "hidden",
169
- clip: "rect(0, 0, 0, 0)",
170
- whiteSpace: "nowrap",
171
- wordWrap: "normal",
172
- ...props.style
173
- }
174
- }
175
- );
176
- };
177
- VisuallyHidden.displayName = "VisuallyHidden";
178
-
179
- // src/icon/Icon.styles.tsx
180
- var import_internal_utils = require("@spark-ui/internal-utils");
181
- var import_class_variance_authority2 = require("class-variance-authority");
182
- var iconStyles = (0, import_class_variance_authority2.cva)(["fill-current shrink-0"], {
183
- variants: {
184
- /**
185
- * Color scheme of the icon.
186
- */
187
- intent: (0, import_internal_utils.makeVariants)({
188
- current: ["text-current"],
189
- main: ["text-main"],
190
- support: ["text-support"],
191
- accent: ["text-accent"],
192
- basic: ["text-basic"],
193
- success: ["text-success"],
194
- alert: ["text-alert"],
195
- error: ["text-error"],
196
- info: ["text-info"],
197
- neutral: ["text-neutral"]
198
- }),
199
- /**
200
- * Sets the size of the icon.
201
- */
202
- size: (0, import_internal_utils.makeVariants)({
203
- current: ["u-current-font-size"],
204
- sm: ["w-sz-16", "h-sz-16"],
205
- md: ["w-sz-24", "h-sz-24"],
206
- lg: ["w-sz-32", "h-sz-32"],
207
- xl: ["w-sz-40", "h-sz-40"]
208
- })
209
- }
210
- });
211
-
212
- // src/icon/Icon.tsx
213
- var import_jsx_runtime5 = require("react/jsx-runtime");
214
- var Icon = ({
215
- label,
216
- className,
217
- size = "current",
218
- intent = "current",
219
- children,
220
- ...others
221
- }) => {
222
- const child = import_react5.Children.only(children);
223
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
224
- (0, import_react5.cloneElement)(child, {
225
- className: iconStyles({ className, size, intent }),
226
- "data-spark-component": "icon",
227
- "aria-hidden": "true",
228
- focusable: "false",
229
- ...others
230
- }),
231
- label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(VisuallyHidden, { children: label })
232
- ] });
233
- };
234
- Icon.displayName = "Icon";
235
-
236
- // src/form-field/FormFieldMessage.tsx
237
- var import_class_variance_authority3 = require("class-variance-authority");
238
- var import_react6 = require("react");
239
- var import_jsx_runtime6 = require("react/jsx-runtime");
240
- var FormFieldMessage = ({
241
- id: idProp,
242
- className,
243
- ref,
244
- ...others
245
- }) => {
246
- const { onMessageIdAdd, onMessageIdRemove } = useFormField();
247
- const currentId = `${ID_PREFIX}-message-${(0, import_react6.useId)()}`;
248
- const id = idProp || currentId;
249
- (0, import_react6.useEffect)(() => {
250
- onMessageIdAdd(id);
251
- return () => {
252
- onMessageIdRemove(id);
253
- };
254
- }, [id, onMessageIdAdd, onMessageIdRemove]);
255
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
256
- "span",
257
- {
258
- ref,
259
- id,
260
- "data-spark-component": "form-field-message",
261
- className: (0, import_class_variance_authority3.cx)(className, "text-caption"),
262
- ...others
263
- }
264
- );
265
- };
266
- FormFieldMessage.displayName = "FormField.Message";
267
-
268
- // src/form-field/FormFieldStateMessage.tsx
269
- var import_jsx_runtime7 = require("react/jsx-runtime");
270
- var FormFieldStateMessage = ({
271
- className,
272
- state,
273
- children,
274
- ref,
275
- ...others
276
- }) => {
277
- const field = useFormField();
278
- if (field.state !== state) {
279
- return null;
280
- }
281
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
282
- FormFieldMessage,
283
- {
284
- ref,
285
- "data-spark-component": "form-field-state-message",
286
- "aria-live": "polite",
287
- className: (0, import_class_variance_authority4.cx)(
288
- "gap-sm flex items-center",
289
- state === "error" ? "text-error" : "text-on-surface/dim-1",
290
- className
291
- ),
292
- ...others,
293
- children: [
294
- state === "alert" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_WarningOutline.WarningOutline, {}) }),
295
- state === "error" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: "sm", intent: "error", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_AlertOutline.AlertOutline, {}) }),
296
- state === "success" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_Check.Check, {}) }),
297
- children
298
- ]
299
- }
300
- );
301
- };
302
- FormFieldStateMessage.displayName = "FormField.StateMessage";
303
-
304
- // src/form-field/FormFieldAlertMessage.tsx
305
- var import_jsx_runtime8 = require("react/jsx-runtime");
306
- var FormFieldAlertMessage = ({ ref, ...props }) => {
307
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
308
- FormFieldStateMessage,
309
- {
310
- ref,
311
- "data-spark-component": "form-field-alert-message",
312
- state: "alert",
313
- ...props
314
- }
315
- );
316
- };
317
- FormFieldAlertMessage.displayName = "FormField.AlertMessage";
318
-
319
- // src/form-field/FormFieldCharactersCount.tsx
320
- var import_class_variance_authority5 = require("class-variance-authority");
321
- var import_jsx_runtime9 = require("react/jsx-runtime");
322
- var FormFieldCharactersCount = ({
323
- className,
324
- value = "",
325
- maxLength,
326
- ref,
327
- ...others
328
- }) => {
329
- const displayValue = `${value.length}/${maxLength}`;
330
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
331
- "span",
332
- {
333
- ref,
334
- "data-spark-component": "form-field-characters-count",
335
- className: (0, import_class_variance_authority5.cx)(className, "text-caption", "text-neutral"),
336
- ...others,
337
- children: displayValue
338
- }
339
- );
340
- };
341
- FormFieldCharactersCount.displayName = "FormField.CharactersCount";
342
-
343
- // src/form-field/FormFieldControl.tsx
344
- var import_react7 = require("react");
345
- var import_jsx_runtime10 = require("react/jsx-runtime");
346
- var useFormFieldControl = () => {
347
- const { id, name, description, disabled, readOnly, state, labelId, isInvalid, isRequired } = (0, import_react7.useContext)(FormFieldContext) || {};
348
- return {
349
- id,
350
- name,
351
- description,
352
- disabled,
353
- readOnly,
354
- state,
355
- labelId,
356
- isInvalid,
357
- isRequired
358
- };
359
- };
360
- var FormFieldControl = ({ children }) => {
361
- const props = useFormFieldControl();
362
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: children(props) });
363
- };
364
- FormFieldControl.displayName = "FormField.Control";
365
-
366
- // src/form-field/FormFieldErrorMessage.tsx
367
- var import_jsx_runtime11 = require("react/jsx-runtime");
368
- var FormFieldErrorMessage = ({ ref, ...props }) => {
369
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
370
- FormFieldStateMessage,
371
- {
372
- ref,
373
- "data-spark-component": "form-field-error-message",
374
- state: "error",
375
- ...props
376
- }
377
- );
378
- };
379
- FormFieldErrorMessage.displayName = "FormField.ErrorMessage";
380
-
381
- // src/form-field/FormFieldHelperMessage.tsx
382
- var import_class_variance_authority6 = require("class-variance-authority");
383
- var import_jsx_runtime12 = require("react/jsx-runtime");
384
- var FormFieldHelperMessage = ({
385
- className,
386
- ref,
387
- ...others
388
- }) => {
389
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
390
- FormFieldMessage,
391
- {
392
- ref,
393
- "data-spark-component": "form-field-helper-message",
394
- className: (0, import_class_variance_authority6.cx)("text-on-surface/dim-1", className),
395
- ...others
396
- }
397
- );
398
- };
399
- FormFieldHelperMessage.displayName = "FormField.HelperMessage";
400
-
401
- // src/form-field/FormFieldLabel.tsx
402
- var import_class_variance_authority10 = require("class-variance-authority");
403
-
404
- // src/label/Label.tsx
405
- var import_class_variance_authority7 = require("class-variance-authority");
406
- var import_radix_ui2 = require("radix-ui");
407
- var import_jsx_runtime13 = require("react/jsx-runtime");
408
- var Label = ({ className, ref, ...others }) => {
409
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
410
- import_radix_ui2.Label.Label,
411
- {
412
- ref,
413
- "data-spark-component": "label",
414
- className: (0, import_class_variance_authority7.cx)("text-body-1", className),
415
- ...others
416
- }
417
- );
418
- };
419
- Label.displayName = "Label";
420
-
421
- // src/label/LabelRequiredIndicator.tsx
422
- var import_class_variance_authority8 = require("class-variance-authority");
423
- var import_jsx_runtime14 = require("react/jsx-runtime");
424
- var LabelRequiredIndicator = ({
425
- className,
426
- children = "*",
427
- ref,
428
- ...others
429
- }) => {
430
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
431
- "span",
432
- {
433
- ref,
434
- "data-spark-component": "label-required-indicator",
435
- role: "presentation",
436
- "aria-hidden": "true",
437
- className: (0, import_class_variance_authority8.cx)(className, "text-caption text-on-surface/dim-1"),
438
- ...others,
439
- children
440
- }
441
- );
442
- };
443
- LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
444
-
445
- // src/label/index.ts
446
- var Label2 = Object.assign(Label, {
447
- RequiredIndicator: LabelRequiredIndicator
448
- });
449
- Label2.displayName = "Label";
450
- LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
451
-
452
- // src/form-field/FormFieldRequiredIndicator.tsx
453
- var import_class_variance_authority9 = require("class-variance-authority");
454
- var import_jsx_runtime15 = require("react/jsx-runtime");
455
- var FormFieldRequiredIndicator = ({
456
- className,
457
- ref,
458
- ...props
459
- }) => {
460
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Label2.RequiredIndicator, { ref, className: (0, import_class_variance_authority9.cx)("ml-sm", className), ...props });
461
- };
462
- FormFieldRequiredIndicator.displayName = "FormField.RequiredIndicator";
463
-
464
- // src/form-field/FormFieldLabel.tsx
465
- var import_jsx_runtime16 = require("react/jsx-runtime");
466
- var FormFieldLabel = ({
467
- htmlFor: htmlForProp,
468
- className,
469
- children,
470
- requiredIndicator = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(FormFieldRequiredIndicator, {}),
471
- asChild,
472
- ref,
473
- ...others
474
- }) => {
475
- const control = useFormField();
476
- const { disabled, labelId, isRequired } = control;
477
- const htmlFor = asChild ? void 0 : htmlForProp || control.id;
478
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
479
- Label2,
480
- {
481
- ref,
482
- id: labelId,
483
- "data-spark-component": "form-field-label",
484
- htmlFor,
485
- className: (0, import_class_variance_authority10.cx)(className, disabled ? "text-on-surface/dim-3 pointer-events-none" : void 0),
486
- asChild,
487
- ...others,
488
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
489
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Slottable, { children }),
490
- isRequired && requiredIndicator
491
- ] })
492
- }
493
- );
494
- };
495
- FormFieldLabel.displayName = "FormField.Label";
496
-
497
- // src/form-field/FormFieldSuccessMessage.tsx
498
- var import_jsx_runtime17 = require("react/jsx-runtime");
499
- var FormFieldSuccessMessage = ({ ref, ...props }) => {
500
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
501
- FormFieldStateMessage,
502
- {
503
- ref,
504
- "data-spark-component": "form-field-success-message",
505
- state: "success",
506
- ...props
507
- }
508
- );
509
- };
510
- FormFieldSuccessMessage.displayName = "FormField.SuccessMessage";
511
-
512
- // src/form-field/index.ts
513
- var FormField2 = Object.assign(FormField, {
514
- Label: FormFieldLabel,
515
- Control: FormFieldControl,
516
- StateMessage: FormFieldStateMessage,
517
- SuccessMessage: FormFieldSuccessMessage,
518
- AlertMessage: FormFieldAlertMessage,
519
- ErrorMessage: FormFieldErrorMessage,
520
- HelperMessage: FormFieldHelperMessage,
521
- RequiredIndicator: FormFieldRequiredIndicator,
522
- CharactersCount: FormFieldCharactersCount
523
- });
524
- FormField2.displayName = "FormField";
525
- FormFieldLabel.displayName = "FormField.Label";
526
- FormFieldControl.displayName = "FormField.Control";
527
- FormFieldStateMessage.displayName = "FormField.StateMessage";
528
- FormFieldSuccessMessage.displayName = "FormField.SuccessMessage";
529
- FormFieldAlertMessage.displayName = "FormField.AlertMessage";
530
- FormFieldErrorMessage.displayName = "FormField.ErrorMessage";
531
- FormFieldHelperMessage.displayName = "FormField.HelperMessage";
532
- FormFieldRequiredIndicator.displayName = "FormField.RequiredIndicator";
533
- FormFieldCharactersCount.displayName = "FormField.CharactersCount";
534
-
535
- // src/switch/Switch.tsx
536
- var import_class_variance_authority13 = require("class-variance-authority");
537
- var import_react8 = require("react");
538
-
539
- // src/switch/SwitchInput.tsx
540
- var import_Check2 = require("@spark-ui/icons/Check");
541
- var import_Close = require("@spark-ui/icons/Close");
542
- var import_use_combined_state = require("@spark-ui/use-combined-state");
543
- var import_radix_ui3 = require("radix-ui");
544
-
545
48
  // src/switch/SwitchInput.styles.ts
546
- var import_internal_utils2 = require("@spark-ui/internal-utils");
547
- var import_class_variance_authority11 = require("class-variance-authority");
548
- var styles = (0, import_class_variance_authority11.cva)(
549
- (0, import_internal_utils2.tw)([
49
+ var import_internal_utils = require("@spark-ui/internal-utils");
50
+ var import_class_variance_authority = require("class-variance-authority");
51
+ var styles = (0, import_class_variance_authority.cva)(
52
+ (0, import_internal_utils.tw)([
550
53
  "relative shrink-0 self-baseline",
551
54
  "cursor-pointer",
552
55
  "rounded-full border-transparent",
@@ -563,14 +66,14 @@ var styles = (0, import_class_variance_authority11.cva)(
563
66
  /**
564
67
  * Size of the switch input.
565
68
  */
566
- size: (0, import_internal_utils2.makeVariants)({
567
- sm: (0, import_internal_utils2.tw)(["h-sz-24", "w-sz-40", "border-md"]),
568
- md: (0, import_internal_utils2.tw)(["h-sz-32", "w-sz-56", "border-[4px]"])
69
+ size: (0, import_internal_utils.makeVariants)({
70
+ sm: (0, import_internal_utils.tw)(["h-sz-24", "w-sz-40", "border-md"]),
71
+ md: (0, import_internal_utils.tw)(["h-sz-32", "w-sz-56", "border-[4px]"])
569
72
  }),
570
73
  /**
571
74
  * Color scheme of the switch input.
572
75
  */
573
- intent: (0, import_internal_utils2.makeVariants)({
76
+ intent: (0, import_internal_utils.makeVariants)({
574
77
  main: ["data-[state=checked]:bg-main", "hover:ring-main-container", "text-main"],
575
78
  support: [
576
79
  "data-[state=checked]:bg-support",
@@ -600,7 +103,7 @@ var styles = (0, import_class_variance_authority11.cva)(
600
103
  }
601
104
  }
602
105
  );
603
- var thumbWrapperStyles = (0, import_class_variance_authority11.cva)(
106
+ var thumbWrapperStyles = (0, import_class_variance_authority.cva)(
604
107
  [
605
108
  "pointer-events-none absolute inset-0 flex items-center",
606
109
  "transition-all duration-200 ease-in-out"
@@ -614,7 +117,7 @@ var thumbWrapperStyles = (0, import_class_variance_authority11.cva)(
614
117
  }
615
118
  }
616
119
  );
617
- var thumbStyles = (0, import_class_variance_authority11.cva)(
120
+ var thumbStyles = (0, import_class_variance_authority.cva)(
618
121
  [
619
122
  "absolute left-0 top-0 flex items-center justify-center",
620
123
  "bg-surface",
@@ -624,7 +127,7 @@ var thumbStyles = (0, import_class_variance_authority11.cva)(
624
127
  ],
625
128
  {
626
129
  variants: {
627
- size: (0, import_internal_utils2.makeVariants)({
130
+ size: (0, import_internal_utils.makeVariants)({
628
131
  sm: ["h-sz-20", "w-sz-20"],
629
132
  md: ["h-sz-24", "w-sz-24"]
630
133
  }),
@@ -639,9 +142,9 @@ var thumbStyles = (0, import_class_variance_authority11.cva)(
639
142
  }
640
143
  }
641
144
  );
642
- var thumbCheckSVGStyles = (0, import_class_variance_authority11.cva)(["transition-opacity duration-200"], {
145
+ var thumbCheckSVGStyles = (0, import_class_variance_authority.cva)(["transition-opacity duration-200"], {
643
146
  variants: {
644
- size: (0, import_internal_utils2.makeVariants)({
147
+ size: (0, import_internal_utils.makeVariants)({
645
148
  sm: ["h-sz-10 w-sz-10"],
646
149
  md: ["h-sz-12 w-sz-12"]
647
150
  })
@@ -652,13 +155,13 @@ var thumbCheckSVGStyles = (0, import_class_variance_authority11.cva)(["transitio
652
155
  });
653
156
 
654
157
  // src/switch/SwitchInput.tsx
655
- var import_jsx_runtime18 = require("react/jsx-runtime");
158
+ var import_jsx_runtime2 = require("react/jsx-runtime");
656
159
  var SwitchInput = ({
657
160
  checked,
658
- checkedIcon = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_Check2.Check, {}),
161
+ checkedIcon = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_Check.Check, {}),
659
162
  defaultChecked,
660
163
  intent: intentProp,
661
- uncheckedIcon = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_Close.Close, {}),
164
+ uncheckedIcon = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_Close.Close, {}),
662
165
  size = "md",
663
166
  value = "on",
664
167
  onCheckedChange,
@@ -668,14 +171,14 @@ var SwitchInput = ({
668
171
  ...rest
669
172
  }) => {
670
173
  const [isChecked, setIsChecked] = (0, import_use_combined_state.useCombinedState)(checked, defaultChecked);
671
- const { name, description, state, isRequired, isInvalid } = useFormFieldControl();
174
+ const { name, description, state, isRequired, isInvalid } = (0, import_form_field.useFormFieldControl)();
672
175
  const intent = state ?? intentProp;
673
176
  const handleCheckedChange = (updatedValue) => {
674
177
  setIsChecked(updatedValue);
675
178
  onCheckedChange?.(updatedValue);
676
179
  };
677
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
678
- import_radix_ui3.Switch.Root,
180
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
181
+ import_radix_ui2.Switch.Root,
679
182
  {
680
183
  ref,
681
184
  className: styles({ intent, size, className }),
@@ -688,18 +191,66 @@ var SwitchInput = ({
688
191
  "aria-invalid": isInvalid,
689
192
  "aria-describedby": description,
690
193
  ...rest,
691
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: thumbWrapperStyles({ checked: isChecked }), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_radix_ui3.Switch.Thumb, { className: thumbStyles({ size, checked: isChecked }), children: [
692
- isChecked && checkedIcon && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Slot, { className: thumbCheckSVGStyles({ size }), children: checkedIcon }),
693
- !isChecked && uncheckedIcon && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Slot, { className: thumbCheckSVGStyles({ size }), children: uncheckedIcon })
194
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: thumbWrapperStyles({ checked: isChecked }), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_radix_ui2.Switch.Thumb, { className: thumbStyles({ size, checked: isChecked }), children: [
195
+ isChecked && checkedIcon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Slot, { className: thumbCheckSVGStyles({ size }), children: checkedIcon }),
196
+ !isChecked && uncheckedIcon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Slot, { className: thumbCheckSVGStyles({ size }), children: uncheckedIcon })
694
197
  ] }) })
695
198
  }
696
199
  );
697
200
  };
698
201
  SwitchInput.displayName = "SwitchInput";
699
202
 
203
+ // src/label/Label.tsx
204
+ var import_class_variance_authority2 = require("class-variance-authority");
205
+ var import_radix_ui3 = require("radix-ui");
206
+ var import_jsx_runtime3 = require("react/jsx-runtime");
207
+ var Label = ({ className, ref, ...others }) => {
208
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
209
+ import_radix_ui3.Label.Label,
210
+ {
211
+ ref,
212
+ "data-spark-component": "label",
213
+ className: (0, import_class_variance_authority2.cx)("text-body-1", className),
214
+ ...others
215
+ }
216
+ );
217
+ };
218
+ Label.displayName = "Label";
219
+
220
+ // src/label/LabelRequiredIndicator.tsx
221
+ var import_class_variance_authority3 = require("class-variance-authority");
222
+ var import_jsx_runtime4 = require("react/jsx-runtime");
223
+ var LabelRequiredIndicator = ({
224
+ className,
225
+ children = "*",
226
+ ref,
227
+ ...others
228
+ }) => {
229
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
230
+ "span",
231
+ {
232
+ ref,
233
+ "data-spark-component": "label-required-indicator",
234
+ role: "presentation",
235
+ "aria-hidden": "true",
236
+ className: (0, import_class_variance_authority3.cx)(className, "text-caption text-on-surface/dim-1"),
237
+ ...others,
238
+ children
239
+ }
240
+ );
241
+ };
242
+ LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
243
+
244
+ // src/label/index.ts
245
+ var Label2 = Object.assign(Label, {
246
+ RequiredIndicator: LabelRequiredIndicator
247
+ });
248
+ Label2.displayName = "Label";
249
+ LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
250
+
700
251
  // src/switch/SwitchLabel.styles.ts
701
- var import_class_variance_authority12 = require("class-variance-authority");
702
- var labelStyles = (0, import_class_variance_authority12.cva)("", {
252
+ var import_class_variance_authority4 = require("class-variance-authority");
253
+ var labelStyles = (0, import_class_variance_authority4.cva)("", {
703
254
  variants: {
704
255
  disabled: {
705
256
  true: ["text-neutral/dim-2", "cursor-not-allowed"],
@@ -712,12 +263,12 @@ var labelStyles = (0, import_class_variance_authority12.cva)("", {
712
263
  });
713
264
 
714
265
  // src/switch/SwitchLabel.tsx
715
- var import_jsx_runtime19 = require("react/jsx-runtime");
716
- var SwitchLabel = ({ className, disabled, ...others }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Label2, { className: labelStyles({ disabled, className }), ...others });
266
+ var import_jsx_runtime5 = require("react/jsx-runtime");
267
+ var SwitchLabel = ({ className, disabled, ...others }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label2, { className: labelStyles({ disabled, className }), ...others });
717
268
 
718
269
  // src/switch/Switch.tsx
719
- var import_jsx_runtime20 = require("react/jsx-runtime");
720
- var ID_PREFIX2 = ":switch";
270
+ var import_jsx_runtime6 = require("react/jsx-runtime");
271
+ var ID_PREFIX = ":switch";
721
272
  var Switch = ({
722
273
  size = "md",
723
274
  children,
@@ -728,12 +279,12 @@ var Switch = ({
728
279
  ref,
729
280
  ...rest
730
281
  }) => {
731
- const field = useFormFieldControl();
732
- const labelID = `${ID_PREFIX2}-label-${(0, import_react8.useId)()}`;
733
- const innerID = `${ID_PREFIX2}-input-${(0, import_react8.useId)()}`;
282
+ const field = (0, import_form_field2.useFormFieldControl)();
283
+ const labelID = `${ID_PREFIX}-label-${(0, import_react2.useId)()}`;
284
+ const innerID = `${ID_PREFIX}-input-${(0, import_react2.useId)()}`;
734
285
  const fieldID = field.id || id || innerID;
735
- const switchLabel = children && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SwitchLabel, { disabled, htmlFor: fieldID, id: labelID, children });
736
- const switchInput = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
286
+ const switchLabel = children && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SwitchLabel, { disabled, htmlFor: fieldID, id: labelID, children });
287
+ const switchInput = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
737
288
  SwitchInput,
738
289
  {
739
290
  ref,
@@ -744,18 +295,18 @@ var Switch = ({
744
295
  ...rest
745
296
  }
746
297
  );
747
- const content = reverse ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
298
+ const content = reverse ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
748
299
  switchLabel,
749
300
  switchInput
750
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
301
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
751
302
  switchInput,
752
303
  switchLabel
753
304
  ] });
754
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
305
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
755
306
  "div",
756
307
  {
757
308
  "data-spark-component": "switch",
758
- className: (0, import_class_variance_authority13.cx)("gap-md text-body-1 flex items-center", className),
309
+ className: (0, import_class_variance_authority5.cx)("gap-md text-body-1 flex items-center", className),
759
310
  children: content
760
311
  }
761
312
  );