@bison-lab/ui 1.6.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -297,11 +297,45 @@ const FormContext = React.createContext(void 0);
297
297
  function useFormContext() {
298
298
  return React.useContext(FormContext);
299
299
  }
300
- const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", children, className, ...props }, ref) => {
300
+ /**
301
+ * Anything that can take focus. Hidden and disabled controls are excluded —
302
+ * focusing either is a no-op that would strand the user mid-form.
303
+ */
304
+ const FOCUSABLE_SELECTOR = [
305
+ "input:not([type=\"hidden\"]):not([disabled])",
306
+ "select:not([disabled])",
307
+ "textarea:not([disabled])",
308
+ "button:not([disabled])",
309
+ "[tabindex]:not([tabindex=\"-1\"])"
310
+ ].join(", ");
311
+ /**
312
+ * Move focus to the first control the schema rejected (WCAG technique G139).
313
+ *
314
+ * Dives inside the invalid element when the element itself cannot hold focus:
315
+ * a checkbox group marks the `<fieldset>` invalid, and a fieldset is not
316
+ * focusable, so the first checkbox inside it is the right landing point.
317
+ */
318
+ function focusFirstInvalid(form) {
319
+ const invalids = form.querySelectorAll("[aria-invalid=\"true\"]");
320
+ for (const el of Array.from(invalids)) {
321
+ const target = el.matches(FOCUSABLE_SELECTOR) ? el : el.querySelector(FOCUSABLE_SELECTOR);
322
+ if (target) {
323
+ target.focus();
324
+ return;
325
+ }
326
+ }
327
+ }
328
+ function defaultErrorSummary(count) {
329
+ return count === 1 ? "1 field needs attention." : `${count} fields need attention.`;
330
+ }
331
+ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", errors: externalErrors, focusOnError = true, errorSummary = defaultErrorSummary, children, className, noValidate, ...props }, ref) => {
301
332
  const [errors, setErrors] = React.useState({});
302
333
  const [touched, setTouched] = React.useState({});
303
334
  const [isSubmitting, setIsSubmitting] = React.useState(false);
304
335
  const [errorVersion, setErrorVersion] = React.useState(0);
336
+ const [announcement, setAnnouncement] = React.useState("");
337
+ const innerRef = React.useRef(null);
338
+ React.useImperativeHandle(ref, () => innerRef.current);
305
339
  const setFieldError = React.useCallback((name, error) => {
306
340
  setErrors((prev) => ({
307
341
  ...prev,
@@ -326,7 +360,11 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", children
326
360
  setIsSubmitting(true);
327
361
  setErrors({});
328
362
  const formData = new FormData(e.currentTarget);
329
- const data = Object.fromEntries(formData.entries());
363
+ const data = {};
364
+ for (const key of Array.from(new Set(formData.keys()))) {
365
+ const values = formData.getAll(key);
366
+ data[key] = values.length > 1 ? values : values[0];
367
+ }
330
368
  if (schema) try {
331
369
  schema.parse(data);
332
370
  } catch (err) {
@@ -338,17 +376,32 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", children
338
376
  }
339
377
  setErrors(fieldErrors);
340
378
  setErrorVersion((v) => v + 1);
379
+ setAnnouncement(errorSummary(Object.keys(fieldErrors).length));
341
380
  setIsSubmitting(false);
342
381
  return;
343
382
  }
383
+ setAnnouncement("");
344
384
  try {
345
385
  await onSubmit?.(data);
346
386
  } finally {
347
387
  setIsSubmitting(false);
348
388
  }
349
- }, [onSubmit, schema]);
389
+ }, [
390
+ onSubmit,
391
+ schema,
392
+ errorSummary
393
+ ]);
394
+ React.useEffect(() => {
395
+ if (!focusOnError || errorVersion === 0) return;
396
+ const form = innerRef.current;
397
+ if (form) focusFirstInvalid(form);
398
+ }, [errorVersion, focusOnError]);
399
+ const mergedErrors = React.useMemo(() => ({
400
+ ...externalErrors,
401
+ ...errors
402
+ }), [externalErrors, errors]);
350
403
  const contextValue = React.useMemo(() => ({
351
- errors,
404
+ errors: mergedErrors,
352
405
  touched,
353
406
  setFieldError,
354
407
  clearFieldError,
@@ -357,7 +410,7 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", children
357
410
  formMode,
358
411
  errorVersion
359
412
  }), [
360
- errors,
413
+ mergedErrors,
361
414
  touched,
362
415
  setFieldError,
363
416
  clearFieldError,
@@ -368,17 +421,127 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", children
368
421
  ]);
369
422
  return /* @__PURE__ */ jsx(FormContext.Provider, {
370
423
  value: contextValue,
371
- children: /* @__PURE__ */ jsx("form", {
372
- ref,
424
+ children: /* @__PURE__ */ jsxs("form", {
425
+ ref: innerRef,
373
426
  onSubmit: handleSubmit,
374
427
  className,
428
+ noValidate: noValidate ?? Boolean(schema),
375
429
  ...props,
376
- children
430
+ children: [children, /* @__PURE__ */ jsx("div", {
431
+ "aria-live": "polite",
432
+ "aria-atomic": "true",
433
+ className: "sr-only",
434
+ "data-slot": "form-status",
435
+ children: announcement ? /* @__PURE__ */ jsx("span", { children: announcement }, errorVersion) : null
436
+ })]
377
437
  })
378
438
  });
379
439
  });
380
440
  Form.displayName = "Form";
381
441
  //#endregion
442
+ //#region src/form/field-context.tsx
443
+ const FieldContext = React.createContext(void 0);
444
+ const FieldProvider = FieldContext.Provider;
445
+ /** Read the surrounding field, if there is one. */
446
+ function useField() {
447
+ return React.useContext(FieldContext);
448
+ }
449
+ /**
450
+ * Merge the surrounding field's ARIA wiring into a control's own props.
451
+ *
452
+ * Call it in every control that accepts user input and spread the result onto
453
+ * the DOM node.
454
+ *
455
+ * Inside a field the wrapper OWNS the control's `id`, and a consumer-supplied
456
+ * one is deliberately overridden. The wrapper has already rendered its
457
+ * `<label for>` pointing at the id it published, and it cannot see the child's
458
+ * props to follow it anywhere else — so honouring an override here would leave
459
+ * the label resolving to nothing, which is precisely the defect this context
460
+ * exists to remove. Set the id through the wrapper's `name` / `htmlFor`
461
+ * instead. `aria-invalid` and `aria-required` do defer to an explicit prop,
462
+ * and the field's description ids are APPENDED to any `aria-describedby` the
463
+ * consumer set rather than replacing it.
464
+ *
465
+ * Returns `props` unchanged when there is no field, or when the field is a
466
+ * group.
467
+ */
468
+ function useFieldControl(props) {
469
+ const field = useField();
470
+ if (!field || field.group) return props;
471
+ const describedBy = [
472
+ field.descriptionId,
473
+ field.errorId,
474
+ props["aria-describedby"]
475
+ ].filter(Boolean).join(" ");
476
+ return {
477
+ ...props,
478
+ id: field.controlId,
479
+ "aria-invalid": props["aria-invalid"] ?? (field.invalid || void 0),
480
+ "aria-required": props["aria-required"] ?? (field.required || void 0),
481
+ "aria-describedby": describedBy || void 0
482
+ };
483
+ }
484
+ /**
485
+ * The composite-control counterpart to {@link useFieldControl}.
486
+ *
487
+ * `TimePicker` is three selects and `CodeInput` is six inputs; neither has a
488
+ * single element for the field's label to point at, and a `<label for>` naming
489
+ * a `<div>` names nothing at all. These wrap their children in a labelled
490
+ * `role="group"` instead, so the whole composite is announced once with its
491
+ * error and hint attached.
492
+ *
493
+ * Returns `{}` outside a field wrapper, leaving standalone usage untouched.
494
+ */
495
+ function useFieldGroup() {
496
+ const field = useField();
497
+ if (!field) return {};
498
+ const describedBy = [field.descriptionId, field.errorId].filter(Boolean).join(" ");
499
+ return {
500
+ role: "group",
501
+ "aria-labelledby": field.labelId,
502
+ "aria-describedby": describedBy || void 0,
503
+ "aria-invalid": field.invalid || void 0,
504
+ "aria-required": field.required || void 0
505
+ };
506
+ }
507
+ /**
508
+ * Seals a composite control against the field it sits in.
509
+ *
510
+ * `CodeInput` renders six `<Input>`s and `TimePicker` renders three
511
+ * `<SelectTrigger>`s. Each of those calls {@link useFieldControl}, so without
512
+ * this they would every one of them adopt the SAME field id — six elements
513
+ * sharing `id="code"`, which is worse than the missing wiring this whole
514
+ * mechanism set out to fix. Re-providing the field in group mode turns the
515
+ * hook into a no-op for everything below, leaving the composite's own wrapper
516
+ * ({@link useFieldGroup}) as the single labelled thing.
517
+ */
518
+ function FieldGroupScope({ children }) {
519
+ const field = useField();
520
+ return /* @__PURE__ */ jsx(FieldProvider, {
521
+ value: React.useMemo(() => field ? {
522
+ ...field,
523
+ group: true
524
+ } : void 0, [field]),
525
+ children
526
+ });
527
+ }
528
+ /**
529
+ * Build the ids a wrapper publishes.
530
+ *
531
+ * `useId()` supplies the hint/error ids because nothing outside the wrapper
532
+ * references them, so uniqueness costs nothing. The control id stays
533
+ * caller-derived — see {@link FieldContextValue.controlId}.
534
+ */
535
+ function useFieldIds({ controlId, hasDescription, hasError }) {
536
+ const reactId = React.useId();
537
+ return {
538
+ controlId,
539
+ descriptionId: hasDescription ? `${reactId}-description` : void 0,
540
+ errorId: hasError ? `${reactId}-error` : void 0,
541
+ labelId: `${reactId}-label`
542
+ };
543
+ }
544
+ //#endregion
382
545
  //#region src/components/outlined-field.tsx
383
546
  /**
384
547
  * Strips border / ring from nested form controls so the outer outlined shell
@@ -397,6 +560,29 @@ function detectControlKind(shell) {
397
560
  return "other";
398
561
  }
399
562
  const OutlinedField = React.forwardRef(({ label, htmlFor, error, errorVersion = 0, hint, required, className, children }, ref) => {
563
+ const fallbackId = React.useId();
564
+ const controlId = htmlFor ?? `${fallbackId}-control`;
565
+ const { descriptionId, errorId, labelId } = useFieldIds({
566
+ controlId,
567
+ hasDescription: Boolean(hint) && !error,
568
+ hasError: Boolean(error)
569
+ });
570
+ const field = React.useMemo(() => ({
571
+ controlId,
572
+ descriptionId,
573
+ errorId,
574
+ labelId,
575
+ invalid: Boolean(error),
576
+ required: Boolean(required),
577
+ group: false
578
+ }), [
579
+ controlId,
580
+ descriptionId,
581
+ errorId,
582
+ labelId,
583
+ error,
584
+ required
585
+ ]);
400
586
  const shellRef = React.useRef(null);
401
587
  const [focused, setFocused] = React.useState(false);
402
588
  const [hasValue, setHasValue] = React.useState(false);
@@ -456,53 +642,84 @@ const OutlinedField = React.forwardRef(({ label, htmlFor, error, errorVersion =
456
642
  x: 0,
457
643
  y: "-50%"
458
644
  };
459
- return /* @__PURE__ */ jsxs("div", {
460
- ref,
461
- className: cn("flex flex-col gap-1.5", className),
462
- children: [
463
- /* @__PURE__ */ jsxs("div", {
464
- ref: shellRef,
465
- className: cn("group/outlined relative w-full min-w-0 rounded-md border border-input bg-background", "ring-offset-background", "focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/30 focus-within:ring-offset-0", error && "border-destructive bison-shake", outlinedFieldNestResetClasses, isTextarea ? "flex min-h-[80px] flex-col py-2" : "flex h-[var(--density-height-md)] items-stretch pointer-coarse:min-h-11", !isFloated && !focused && "[&_input]:placeholder:text-transparent [&_textarea]:placeholder:text-transparent"),
466
- onInputCapture: handleInputCapture,
467
- children: [/* @__PURE__ */ jsxs(motion.label, {
468
- htmlFor,
469
- className: cn("pointer-events-none absolute z-10 bg-background px-1 font-medium leading-none text-muted-foreground", isFloated ? "text-xs" : "text-base", focused && "text-primary"),
470
- style: { transformOrigin: "left center" },
471
- initial: false,
472
- animate: labelAnimate,
473
- transition: {
474
- type: "spring",
475
- stiffness: 520,
476
- damping: 34
477
- },
478
- children: [label, required ? /* @__PURE__ */ jsx("span", {
479
- className: "ml-0.5 text-destructive",
480
- children: "*"
481
- }) : null]
482
- }), /* @__PURE__ */ jsx("div", {
483
- className: cn("box-border flex min-h-0 min-w-0 flex-1", isTextarea ? "items-stretch pt-4 [&>*]:flex [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:flex-1" : "items-stretch [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:flex-1"),
484
- children
485
- })]
486
- }),
487
- error ? /* @__PURE__ */ jsx("p", {
488
- className: "text-sm leading-none text-destructive",
489
- children: error
490
- }) : null,
491
- !error && hint ? /* @__PURE__ */ jsx("p", {
492
- className: "text-sm leading-none text-muted-foreground",
493
- children: hint
494
- }) : null
495
- ]
645
+ return /* @__PURE__ */ jsx(FieldProvider, {
646
+ value: field,
647
+ children: /* @__PURE__ */ jsxs("div", {
648
+ ref,
649
+ className: cn("flex flex-col gap-1.5", className),
650
+ children: [
651
+ /* @__PURE__ */ jsxs("div", {
652
+ ref: shellRef,
653
+ className: cn("group/outlined relative w-full min-w-0 rounded-md border border-input bg-background", "ring-offset-background", "focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/30 focus-within:ring-offset-0", error && "border-destructive bison-shake", outlinedFieldNestResetClasses, isTextarea ? "flex min-h-[80px] flex-col py-2" : "flex h-[var(--density-height-md)] items-stretch pointer-coarse:min-h-11", !isFloated && !focused && "[&_input]:placeholder:text-transparent [&_textarea]:placeholder:text-transparent"),
654
+ onInputCapture: handleInputCapture,
655
+ children: [/* @__PURE__ */ jsxs(motion.label, {
656
+ id: labelId,
657
+ htmlFor: controlId,
658
+ className: cn("pointer-events-none absolute z-10 bg-background px-1 font-medium leading-none text-muted-foreground", isFloated ? "text-xs" : "text-base", focused && "text-primary"),
659
+ style: { transformOrigin: "left center" },
660
+ initial: false,
661
+ animate: labelAnimate,
662
+ transition: {
663
+ type: "spring",
664
+ stiffness: 520,
665
+ damping: 34
666
+ },
667
+ children: [label, required ? /* @__PURE__ */ jsx("span", {
668
+ "aria-hidden": "true",
669
+ className: "ml-0.5 text-destructive",
670
+ children: "*"
671
+ }) : null]
672
+ }), /* @__PURE__ */ jsx("div", {
673
+ className: cn("box-border flex min-h-0 min-w-0 flex-1", isTextarea ? "items-stretch pt-4 [&>*]:flex [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:flex-1" : "items-stretch [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:flex-1"),
674
+ children
675
+ })]
676
+ }),
677
+ error ? /* @__PURE__ */ jsx("p", {
678
+ id: errorId,
679
+ className: "text-sm leading-none text-destructive",
680
+ children: error
681
+ }) : null,
682
+ !error && hint ? /* @__PURE__ */ jsx("p", {
683
+ id: descriptionId,
684
+ className: "text-sm leading-none text-muted-foreground",
685
+ children: hint
686
+ }) : null
687
+ ]
688
+ })
496
689
  });
497
690
  });
498
691
  OutlinedField.displayName = "OutlinedField";
499
692
  //#endregion
500
693
  //#region src/form/form-field.tsx
501
- function FormField({ name, label, description, required, labelLayout = "stack", className, children }) {
694
+ function FormField({ name, label, description, required, labelLayout = "stack", as = "field", className, children }) {
502
695
  const formCtx = useFormContext();
503
696
  const errorMessage = formCtx?.errors[name];
504
697
  const errorVersion = formCtx?.errorVersion ?? 0;
505
698
  const wrapRef = React.useRef(null);
699
+ const { controlId, descriptionId, errorId, labelId } = useFieldIds({
700
+ controlId: name,
701
+ hasDescription: Boolean(description) && !errorMessage,
702
+ hasError: Boolean(errorMessage)
703
+ });
704
+ const isGroup = as === "group";
705
+ const field = React.useMemo(() => ({
706
+ controlId,
707
+ descriptionId,
708
+ errorId,
709
+ labelId: label ? labelId : void 0,
710
+ invalid: Boolean(errorMessage),
711
+ required: Boolean(required),
712
+ group: isGroup
713
+ }), [
714
+ controlId,
715
+ descriptionId,
716
+ errorId,
717
+ labelId,
718
+ label,
719
+ errorMessage,
720
+ required,
721
+ isGroup
722
+ ]);
506
723
  React.useEffect(() => {
507
724
  const el = wrapRef.current;
508
725
  if (!el || !errorMessage) return;
@@ -510,7 +727,7 @@ function FormField({ name, label, description, required, labelLayout = "stack",
510
727
  el.offsetWidth;
511
728
  el.style.animation = "";
512
729
  }, [errorVersion, errorMessage]);
513
- if (label && labelLayout === "outlined") return /* @__PURE__ */ jsx(OutlinedField, {
730
+ if (!isGroup && label && labelLayout === "outlined") return /* @__PURE__ */ jsx(OutlinedField, {
514
731
  label,
515
732
  htmlFor: name,
516
733
  required,
@@ -520,28 +737,56 @@ function FormField({ name, label, description, required, labelLayout = "stack",
520
737
  className,
521
738
  children
522
739
  });
523
- return /* @__PURE__ */ jsxs("div", {
524
- ref: wrapRef,
525
- className: cn("flex flex-col", errorMessage && "bison-shake", className),
526
- children: [
527
- label && /* @__PURE__ */ jsxs("label", {
528
- htmlFor: name,
529
- className: "mb-1.5 text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
530
- children: [label, required && /* @__PURE__ */ jsx("span", {
531
- className: "text-destructive ml-1",
532
- children: "*"
533
- })]
534
- }),
535
- children,
536
- description && !errorMessage && /* @__PURE__ */ jsx("p", {
537
- className: "mt-1.5 text-sm leading-none text-muted-foreground",
538
- children: description
539
- }),
540
- errorMessage && /* @__PURE__ */ jsx("p", {
541
- className: "mt-1.5 text-sm leading-none text-destructive",
542
- children: errorMessage
543
- })
544
- ]
740
+ const describedBy = [descriptionId, errorId].filter(Boolean).join(" ") || void 0;
741
+ const messages = /* @__PURE__ */ jsxs(Fragment, { children: [description && !errorMessage && /* @__PURE__ */ jsx("p", {
742
+ id: descriptionId,
743
+ className: "mt-1.5 text-sm leading-none text-muted-foreground",
744
+ children: description
745
+ }), errorMessage && /* @__PURE__ */ jsx("p", {
746
+ id: errorId,
747
+ className: "mt-1.5 text-sm leading-none text-destructive",
748
+ children: errorMessage
749
+ })] });
750
+ const requiredMark = required ? /* @__PURE__ */ jsx("span", {
751
+ "aria-hidden": "true",
752
+ className: "text-destructive ml-1",
753
+ children: "*"
754
+ }) : null;
755
+ if (isGroup) return /* @__PURE__ */ jsx(FieldProvider, {
756
+ value: field,
757
+ children: /* @__PURE__ */ jsxs("fieldset", {
758
+ ref: wrapRef,
759
+ className: cn("flex flex-col", errorMessage && "bison-shake", className),
760
+ "aria-describedby": describedBy,
761
+ "aria-invalid": errorMessage ? true : void 0,
762
+ "aria-required": required || void 0,
763
+ children: [
764
+ label && /* @__PURE__ */ jsxs("legend", {
765
+ id: labelId,
766
+ className: "mb-1.5 text-sm font-medium leading-none",
767
+ children: [label, requiredMark]
768
+ }),
769
+ children,
770
+ messages
771
+ ]
772
+ })
773
+ });
774
+ return /* @__PURE__ */ jsx(FieldProvider, {
775
+ value: field,
776
+ children: /* @__PURE__ */ jsxs("div", {
777
+ ref: wrapRef,
778
+ className: cn("flex flex-col", errorMessage && "bison-shake", className),
779
+ children: [
780
+ label && /* @__PURE__ */ jsxs("label", {
781
+ id: labelId,
782
+ htmlFor: controlId,
783
+ className: "mb-1.5 text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
784
+ children: [label, requiredMark]
785
+ }),
786
+ children,
787
+ messages
788
+ ]
789
+ })
545
790
  });
546
791
  }
547
792
  //#endregion
@@ -654,15 +899,28 @@ const inputSurfaceClasses = "flex w-full rounded-md border border-input bg-backg
654
899
  */
655
900
  const inputFocusClasses = "focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/30 focus-visible:ring-offset-0";
656
901
  /**
657
- * Standard single-line input sizing: md-density height + 12px padding-x + 8px padding-y.
658
- * Textarea uses `min-h-[80px]` instead.
902
+ * Standard single-line input sizing per size: density height + horizontal
903
+ * padding + vertical padding, scaled per size. Textarea uses `min-h-[80px]`
904
+ * instead of any of these.
905
+ *
906
+ * `pointer-coarse:min-h-11` floors the height at 44px on touch pointers on
907
+ * every size, matching the Button primitive (and Button-based DatePicker /
908
+ * DateRangePicker triggers) so inputs, selects, and buttons stay the same
909
+ * height when combined in a form. Fine (mouse) pointers keep the exact
910
+ * density height for the chosen size.
659
911
  *
660
- * `pointer-coarse:min-h-11` floors the height at 44px on touch pointers, matching
661
- * the Button primitive (and Button-based DatePicker / DateRangePicker triggers)
662
- * so inputs, selects, and buttons stay the same height when combined in a form.
663
- * Fine (mouse) pointers keep the exact density height.
912
+ * `'md'` (the default) is byte-identical to the original fixed sizing this
913
+ * function replaced — every existing caller passes `'md'` explicitly and
914
+ * renders unchanged.
664
915
  */
665
- const inputSizingClasses = "h-[var(--density-height-md)] px-3 py-2 pointer-coarse:min-h-11";
916
+ const inputSizingClassesBySize = {
917
+ sm: "h-[var(--density-height-sm)] px-3 py-1 text-sm pointer-coarse:min-h-11",
918
+ md: "h-[var(--density-height-md)] px-3 py-2 pointer-coarse:min-h-11",
919
+ lg: "h-[var(--density-height-lg)] px-3 py-2.5 text-base pointer-coarse:min-h-11"
920
+ };
921
+ function inputSizingClasses(size = "md") {
922
+ return inputSizingClassesBySize[size];
923
+ }
666
924
  /**
667
925
  * Minimum 44px tap target on touch (coarse) pointers, applied to the element
668
926
  * itself. For standalone icon buttons that can safely grow their box on touch
@@ -734,26 +992,29 @@ const centeredModalContentClasses = "fixed left-[50%] top-[50%] z-[var(--z-modal
734
992
  //#endregion
735
993
  //#region src/components/input.tsx
736
994
  const Input = React.forwardRef(({ className, type, ...props }, ref) => {
995
+ const fieldProps = useFieldControl(props);
737
996
  return /* @__PURE__ */ jsx("input", {
738
997
  type,
739
- className: cn(inputSurfaceClasses, inputSizingClasses, inputFocusClasses, "file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
998
+ className: cn(inputSurfaceClasses, inputSizingClasses("md"), inputFocusClasses, "file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
740
999
  ref,
741
- ...props
1000
+ ...fieldProps
742
1001
  });
743
1002
  });
744
1003
  Input.displayName = "Input";
745
1004
  //#endregion
746
1005
  //#region src/components/password-input.tsx
747
- const PasswordInput = React.forwardRef(({ className, ...props }, ref) => {
1006
+ const PasswordInput = React.forwardRef(({ className, toggleLabel = "Show or hide password", ...props }, ref) => {
1007
+ const fieldProps = useFieldControl(props);
748
1008
  return /* @__PURE__ */ jsx(unstable_PasswordToggleField.Root, { children: /* @__PURE__ */ jsxs("div", {
749
1009
  className: "relative",
750
1010
  children: [/* @__PURE__ */ jsx(unstable_PasswordToggleField.Input, {
751
- className: cn(inputSurfaceClasses, inputSizingClasses, inputFocusClasses, "pr-10 file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
1011
+ className: cn(inputSurfaceClasses, inputSizingClasses("md"), inputFocusClasses, "pr-10 file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
752
1012
  ref,
753
- ...props
1013
+ ...fieldProps
754
1014
  }), /* @__PURE__ */ jsx(unstable_PasswordToggleField.Toggle, {
755
1015
  className: "absolute right-0 top-0 flex h-full w-10 items-center justify-center text-muted-foreground hover:text-foreground transition-colors disabled:pointer-events-none disabled:opacity-50",
756
1016
  disabled: props.disabled,
1017
+ "aria-label": toggleLabel,
757
1018
  children: /* @__PURE__ */ jsx(unstable_PasswordToggleField.Icon, {
758
1019
  visible: /* @__PURE__ */ jsx(EyeOff, { className: "h-4 w-4" }),
759
1020
  hidden: /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" })
@@ -764,7 +1025,8 @@ const PasswordInput = React.forwardRef(({ className, ...props }, ref) => {
764
1025
  PasswordInput.displayName = "PasswordInput";
765
1026
  //#endregion
766
1027
  //#region src/components/code-input.tsx
767
- const CodeInput = React.forwardRef(({ length = 6, onComplete, onChange, loading = false, disabled = false, className }, ref) => {
1028
+ const CodeInput = React.forwardRef(({ length = 6, onComplete, onChange, loading = false, disabled = false, className, digitLabel = (position, total) => `Digit ${position} of ${total}` }, ref) => {
1029
+ const groupProps = useFieldGroup();
768
1030
  const [code, setCode] = React.useState(Array(length).fill(""));
769
1031
  const inputRefs = React.useRef([]);
770
1032
  const updateCode = React.useCallback((newCode) => {
@@ -803,7 +1065,8 @@ const CodeInput = React.forwardRef(({ length = 6, onComplete, onChange, loading
803
1065
  ref,
804
1066
  className: cn("flex justify-center gap-2", className),
805
1067
  onPaste: handlePaste,
806
- children: code.map((digit, index) => /* @__PURE__ */ jsx(Input, {
1068
+ ...groupProps,
1069
+ children: /* @__PURE__ */ jsx(FieldGroupScope, { children: code.map((digit, index) => /* @__PURE__ */ jsx(Input, {
807
1070
  ref: (el) => {
808
1071
  inputRefs.current[index] = el;
809
1072
  },
@@ -815,8 +1078,9 @@ const CodeInput = React.forwardRef(({ length = 6, onComplete, onChange, loading
815
1078
  onKeyDown: (e) => handleKeyDown(index, e),
816
1079
  disabled: loading || disabled,
817
1080
  className: "h-12 w-12 text-center text-lg font-semibold",
818
- autoFocus: index === 0
819
- }, index))
1081
+ autoFocus: index === 0,
1082
+ "aria-label": digitLabel(index + 1, length)
1083
+ }, index)) })
820
1084
  });
821
1085
  });
822
1086
  CodeInput.displayName = "CodeInput";
@@ -843,6 +1107,7 @@ function fromCents(cents) {
843
1107
  return (cents / 100).toFixed(2);
844
1108
  }
845
1109
  const CurrencyInput = React.forwardRef(({ className, value, onChange, symbol = "$", ...props }, ref) => {
1110
+ const fieldProps = useFieldControl(props);
846
1111
  const [display, setDisplay] = React.useState(() => fromCents(value));
847
1112
  const prevValue = React.useRef(value);
848
1113
  if (value !== prevValue.current) {
@@ -872,16 +1137,15 @@ const CurrencyInput = React.forwardRef(({ className, value, onChange, symbol = "
872
1137
  value: display,
873
1138
  onChange: handleChange,
874
1139
  onBlur: handleBlur,
875
- className: cn(inputSurfaceClasses, inputSizingClasses, inputFocusClasses, "pl-7 pr-3 text-sm", className),
876
- ...props
1140
+ className: cn(inputSurfaceClasses, inputSizingClasses("md"), inputFocusClasses, "pl-7 pr-3 text-sm", className),
1141
+ ...fieldProps
877
1142
  })]
878
1143
  });
879
1144
  });
880
1145
  CurrencyInput.displayName = "CurrencyInput";
881
1146
  //#endregion
882
- //#region src/components/phone-input.tsx
1147
+ //#region src/lib/us-phone.ts
883
1148
  const PHONE_MAX_DIGITS = 10;
884
- const PHONE_MAX_LENGTH = 14;
885
1149
  /** Strips non-digits and caps at 10 (US NANP). */
886
1150
  function parseUsPhoneDigits(value) {
887
1151
  return value.replace(/\D/g, "").slice(0, PHONE_MAX_DIGITS);
@@ -893,6 +1157,22 @@ function formatUsPhone(value) {
893
1157
  if (d.length <= 6) return `(${d.slice(0, 3)}) ${d.slice(3)}`;
894
1158
  return `(${d.slice(0, 3)}) ${d.slice(3, 6)}-${d.slice(6)}`;
895
1159
  }
1160
+ /**
1161
+ * Deliberately NOT a `'use client'` module, and deliberately not living in
1162
+ * `phone-input.tsx` any more.
1163
+ *
1164
+ * `validators.ts` needs `parseUsPhoneDigits`, and it is consumed from Server
1165
+ * Actions. Importing it from the component file dragged the whole client
1166
+ * component in behind it, and every output of the main entry carries a
1167
+ * `"use client"` banner — so calling the validator on the server failed with
1168
+ * "Attempted to call … from the server but … is on the client".
1169
+ *
1170
+ * Keep this file free of React, and free of imports from anything holding a
1171
+ * `'use client'` directive.
1172
+ */
1173
+ //#endregion
1174
+ //#region src/components/phone-input.tsx
1175
+ const PHONE_MAX_LENGTH = 14;
896
1176
  const PhoneInput = React.forwardRef(function PhoneInput({ value: valueProp, defaultValue = "", onChange, autoComplete = "tel", ...props }, ref) {
897
1177
  const isControlled = valueProp !== void 0;
898
1178
  const [uncontrolledDigits, setUncontrolledDigits] = React.useState(() => parseUsPhoneDigits(defaultValue));
@@ -932,47 +1212,78 @@ Label.displayName = Label$1.Root.displayName;
932
1212
  //#endregion
933
1213
  //#region src/components/input-group.tsx
934
1214
  const InputGroup = React.forwardRef(({ label, htmlFor, error, hint, required, labelLayout = "stack", className, children }, ref) => {
1215
+ const fallbackId = React.useId();
1216
+ const controlId = htmlFor ?? `${fallbackId}-control`;
1217
+ const { descriptionId, errorId, labelId } = useFieldIds({
1218
+ controlId,
1219
+ hasDescription: Boolean(hint) && !error,
1220
+ hasError: Boolean(error)
1221
+ });
1222
+ const field = React.useMemo(() => ({
1223
+ controlId,
1224
+ descriptionId,
1225
+ errorId,
1226
+ labelId,
1227
+ invalid: Boolean(error),
1228
+ required: Boolean(required),
1229
+ group: false
1230
+ }), [
1231
+ controlId,
1232
+ descriptionId,
1233
+ errorId,
1234
+ labelId,
1235
+ error,
1236
+ required
1237
+ ]);
935
1238
  if (labelLayout === "outlined") return /* @__PURE__ */ jsx(OutlinedField, {
936
1239
  ref,
937
1240
  label,
938
- htmlFor,
1241
+ htmlFor: controlId,
939
1242
  error,
940
1243
  hint,
941
1244
  required,
942
1245
  className,
943
1246
  children
944
1247
  });
945
- return /* @__PURE__ */ jsxs("div", {
946
- ref,
947
- className: cn("flex flex-col gap-2", className),
948
- children: [
949
- /* @__PURE__ */ jsxs(Label, {
950
- htmlFor,
951
- children: [label, required && /* @__PURE__ */ jsx("span", {
952
- className: "ml-0.5 text-destructive",
953
- children: "*"
954
- })]
955
- }),
956
- children,
957
- error && /* @__PURE__ */ jsx("p", {
958
- className: "text-sm text-destructive",
959
- children: error
960
- }),
961
- !error && hint && /* @__PURE__ */ jsx("p", {
962
- className: "text-sm text-muted-foreground",
963
- children: hint
964
- })
965
- ]
1248
+ return /* @__PURE__ */ jsx(FieldProvider, {
1249
+ value: field,
1250
+ children: /* @__PURE__ */ jsxs("div", {
1251
+ ref,
1252
+ className: cn("flex flex-col gap-2", className),
1253
+ children: [
1254
+ /* @__PURE__ */ jsxs(Label, {
1255
+ id: labelId,
1256
+ htmlFor: controlId,
1257
+ children: [label, required && /* @__PURE__ */ jsx("span", {
1258
+ "aria-hidden": "true",
1259
+ className: "ml-0.5 text-destructive",
1260
+ children: "*"
1261
+ })]
1262
+ }),
1263
+ children,
1264
+ error && /* @__PURE__ */ jsx("p", {
1265
+ id: errorId,
1266
+ className: "text-sm text-destructive",
1267
+ children: error
1268
+ }),
1269
+ !error && hint && /* @__PURE__ */ jsx("p", {
1270
+ id: descriptionId,
1271
+ className: "text-sm text-muted-foreground",
1272
+ children: hint
1273
+ })
1274
+ ]
1275
+ })
966
1276
  });
967
1277
  });
968
1278
  InputGroup.displayName = "InputGroup";
969
1279
  //#endregion
970
1280
  //#region src/components/textarea.tsx
971
1281
  const Textarea = React.forwardRef(({ className, ...props }, ref) => {
1282
+ const fieldProps = useFieldControl(props);
972
1283
  return /* @__PURE__ */ jsx("textarea", {
973
1284
  className: cn(inputSurfaceClasses, "min-h-[80px] px-3 py-2", inputFocusClasses, className),
974
1285
  ref,
975
- ...props
1286
+ ...fieldProps
976
1287
  });
977
1288
  });
978
1289
  Textarea.displayName = "Textarea";
@@ -981,15 +1292,18 @@ Textarea.displayName = "Textarea";
981
1292
  const Select = Select$1.Root;
982
1293
  const SelectGroup = Select$1.Group;
983
1294
  const SelectValue = Select$1.Value;
984
- const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(Select$1.Trigger, {
985
- ref,
986
- className: cn(inputSurfaceClasses, inputSizingClasses, inputFocusClasses, "items-center justify-between [&>span]:line-clamp-1", className),
987
- ...props,
988
- children: [children, /* @__PURE__ */ jsx(Select$1.Icon, {
989
- asChild: true,
990
- children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 opacity-50" })
991
- })]
992
- }));
1295
+ const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => {
1296
+ const fieldProps = useFieldControl(props);
1297
+ return /* @__PURE__ */ jsxs(Select$1.Trigger, {
1298
+ ref,
1299
+ className: cn(inputSurfaceClasses, inputSizingClasses("md"), inputFocusClasses, "items-center justify-between [&>span]:line-clamp-1", className),
1300
+ ...fieldProps,
1301
+ children: [children, /* @__PURE__ */ jsx(Select$1.Icon, {
1302
+ asChild: true,
1303
+ children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 opacity-50" })
1304
+ })]
1305
+ });
1306
+ });
993
1307
  SelectTrigger.displayName = Select$1.Trigger.displayName;
994
1308
  const SelectScrollUpButton = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Select$1.ScrollUpButton, {
995
1309
  ref,
@@ -1092,6 +1406,7 @@ PopoverContent.displayName = Popover$1.Content.displayName;
1092
1406
  //#endregion
1093
1407
  //#region src/components/date-picker.tsx
1094
1408
  const DatePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a date", dateFormat = "PPP", disabled = false, className, fromDate, toDate, disabledDates }, ref) => {
1409
+ const fieldProps = useFieldControl({});
1095
1410
  const [open, setOpen] = React.useState(false);
1096
1411
  const handleSelect = (date) => {
1097
1412
  onChange?.(date);
@@ -1107,6 +1422,7 @@ const DatePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a da
1107
1422
  variant: "outline",
1108
1423
  disabled,
1109
1424
  className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground", className),
1425
+ ...fieldProps,
1110
1426
  children: [/* @__PURE__ */ jsx(Calendar$1, { className: "mr-2 h-4 w-4" }), value ? format(value, dateFormat) : /* @__PURE__ */ jsx("span", { children: placeholder })]
1111
1427
  })
1112
1428
  }), /* @__PURE__ */ jsx(PopoverContent, {
@@ -1126,6 +1442,144 @@ const DatePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a da
1126
1442
  });
1127
1443
  DatePicker.displayName = "DatePicker";
1128
1444
  //#endregion
1445
+ //#region src/components/time-picker.tsx
1446
+ const useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
1447
+ /** Zero-pads a number to a 2-digit string ("5" → "05"). */
1448
+ function pad2(n) {
1449
+ return String(n).padStart(2, "0");
1450
+ }
1451
+ /**
1452
+ * A segment's controlled Select value: zero-padded, or `''` when unset.
1453
+ *
1454
+ * Radix's Select.Root treats `''` as "clear the selection and show the
1455
+ * placeholder" (see @radix-ui/react-select's own SelectItem invariant: a
1456
+ * SelectItem's value may never be `''` for exactly this reason) while still
1457
+ * remaining fully controlled by us. Passing `undefined` instead would leave
1458
+ * Select.Root uncontrolled whenever a segment is unset, and Radix's internal
1459
+ * uncontrolled fallback state -- populated only by the user's own picks via
1460
+ * onValueChange -- does not reset just because our `value` prop returns to
1461
+ * `undefined`, so a cleared, previously-picked trigger would keep showing
1462
+ * its last value. Always passing a defined string avoids that entirely.
1463
+ */
1464
+ function toSegmentValue(n) {
1465
+ return n === void 0 ? "" : pad2(n);
1466
+ }
1467
+ const HOUR_OPTIONS = Array.from({ length: 12 }, (_, i) => pad2(i + 1));
1468
+ /** Generates zero-padded minute option strings ("00", "05", ...) stepped by `step`. */
1469
+ function getMinuteOptions(step) {
1470
+ const options = [];
1471
+ for (let minute = 0; minute < 60; minute += step) options.push(pad2(minute));
1472
+ return options;
1473
+ }
1474
+ /** Parses a 24-hour "HH:mm" string into 12-hour parts. Returns {} for undefined/malformed input. */
1475
+ function parseTimeValue(value) {
1476
+ if (!value) return {};
1477
+ const match = /^([01]\d|2[0-3]):([0-5]\d)$/.exec(value);
1478
+ if (!match) return {};
1479
+ const hour24 = Number(match[1]);
1480
+ const minute = Number(match[2]);
1481
+ const period = hour24 >= 12 ? "PM" : "AM";
1482
+ return {
1483
+ hour12: hour24 % 12 === 0 ? 12 : hour24 % 12,
1484
+ minute,
1485
+ period
1486
+ };
1487
+ }
1488
+ /** Formats 12-hour parts back into a 24-hour "HH:mm" string. */
1489
+ function formatTimeValue(parts) {
1490
+ let hour24 = parts.hour12 % 12;
1491
+ if (parts.period === "PM") hour24 += 12;
1492
+ return `${pad2(hour24)}:${pad2(parts.minute)}`;
1493
+ }
1494
+ const TimePicker = React.forwardRef(({ value, onChange, minuteStep = 5, size = "md", disabled = false, placeholder, className }, ref) => {
1495
+ const groupProps = useFieldGroup();
1496
+ const [partial, setPartial] = React.useState({});
1497
+ const parsedValue = parseTimeValue(value);
1498
+ const isControlled = parsedValue.hour12 !== void 0;
1499
+ const parts = isControlled ? parsedValue : partial;
1500
+ const wasControlledRef = React.useRef(isControlled);
1501
+ useIsomorphicLayoutEffect$1(() => {
1502
+ if (wasControlledRef.current && !isControlled) setPartial({});
1503
+ wasControlledRef.current = isControlled;
1504
+ }, [isControlled]);
1505
+ const minuteOptions = React.useMemo(() => {
1506
+ const options = getMinuteOptions(minuteStep);
1507
+ if (parts.minute !== void 0) {
1508
+ const minuteStr = pad2(parts.minute);
1509
+ if (!options.includes(minuteStr)) return [...options, minuteStr].sort();
1510
+ }
1511
+ return options;
1512
+ }, [minuteStep, parts.minute]);
1513
+ function commit(next) {
1514
+ if (!isControlled) setPartial(next);
1515
+ if (next.hour12 !== void 0 && next.minute !== void 0 && next.period !== void 0) onChange?.(formatTimeValue({
1516
+ hour12: next.hour12,
1517
+ minute: next.minute,
1518
+ period: next.period
1519
+ }));
1520
+ }
1521
+ const triggerClassName = cn(inputSizingClasses(size), "w-auto min-w-0");
1522
+ return /* @__PURE__ */ jsx("div", {
1523
+ ref,
1524
+ className: cn("flex gap-2", className),
1525
+ ...groupProps,
1526
+ children: /* @__PURE__ */ jsxs(FieldGroupScope, { children: [
1527
+ /* @__PURE__ */ jsxs(Select, {
1528
+ disabled,
1529
+ value: toSegmentValue(parts.hour12),
1530
+ onValueChange: (hour) => commit({
1531
+ ...parts,
1532
+ hour12: Number(hour)
1533
+ }),
1534
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
1535
+ "aria-label": "Hour",
1536
+ className: triggerClassName,
1537
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: placeholder?.hour ?? "HH" })
1538
+ }), /* @__PURE__ */ jsx(SelectContent, { children: HOUR_OPTIONS.map((hour) => /* @__PURE__ */ jsx(SelectItem, {
1539
+ value: hour,
1540
+ children: hour
1541
+ }, hour)) })]
1542
+ }),
1543
+ /* @__PURE__ */ jsxs(Select, {
1544
+ disabled,
1545
+ value: toSegmentValue(parts.minute),
1546
+ onValueChange: (minute) => commit({
1547
+ ...parts,
1548
+ minute: Number(minute)
1549
+ }),
1550
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
1551
+ "aria-label": "Minute",
1552
+ className: triggerClassName,
1553
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: placeholder?.minute ?? "MM" })
1554
+ }), /* @__PURE__ */ jsx(SelectContent, { children: minuteOptions.map((minute) => /* @__PURE__ */ jsx(SelectItem, {
1555
+ value: minute,
1556
+ children: minute
1557
+ }, minute)) })]
1558
+ }),
1559
+ /* @__PURE__ */ jsxs(Select, {
1560
+ disabled,
1561
+ value: parts.period ?? "",
1562
+ onValueChange: (period) => commit({
1563
+ ...parts,
1564
+ period
1565
+ }),
1566
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
1567
+ "aria-label": "AM or PM",
1568
+ className: triggerClassName,
1569
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: placeholder?.period ?? "AM" })
1570
+ }), /* @__PURE__ */ jsxs(SelectContent, { children: [/* @__PURE__ */ jsx(SelectItem, {
1571
+ value: "AM",
1572
+ children: "AM"
1573
+ }), /* @__PURE__ */ jsx(SelectItem, {
1574
+ value: "PM",
1575
+ children: "PM"
1576
+ })] })]
1577
+ })
1578
+ ] })
1579
+ });
1580
+ });
1581
+ TimePicker.displayName = "TimePicker";
1582
+ //#endregion
1129
1583
  //#region src/components/date-range-picker.tsx
1130
1584
  /** Built-in preset range generators */
1131
1585
  const dateRangePresets = {
@@ -1229,6 +1683,7 @@ const dateRangePresets = {
1229
1683
  })
1230
1684
  };
1231
1685
  const DateRangePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a date range", dateFormat = "LLL dd, y", disabled = false, className, presets, numberOfMonths = 2, fromDate, toDate, clearable = true, clearLabel = "Clear date range" }, ref) => {
1686
+ const fieldProps = useFieldControl({});
1232
1687
  const [open, setOpen] = React.useState(false);
1233
1688
  const handlePresetClick = (preset) => {
1234
1689
  const range = preset.range();
@@ -1252,6 +1707,7 @@ const DateRangePicker = React.forwardRef(({ value, onChange, placeholder = "Pick
1252
1707
  variant: "outline",
1253
1708
  disabled,
1254
1709
  className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground", showClear && "pr-9", className),
1710
+ ...fieldProps,
1255
1711
  children: [/* @__PURE__ */ jsx(Calendar$1, { className: "mr-2 h-4 w-4" }), value?.from ? value.to ? /* @__PURE__ */ jsxs(Fragment, { children: [
1256
1712
  format(value.from, dateFormat),
1257
1713
  " –",
@@ -1593,24 +2049,30 @@ function IndeterminateIcon({ className }) {
1593
2049
  })
1594
2050
  });
1595
2051
  }
1596
- const Checkbox = React.forwardRef(({ className, checked, ...props }, ref) => /* @__PURE__ */ jsx(Checkbox$1.Root, {
1597
- ref,
1598
- checked,
1599
- className: cn("peer h-4 w-4 shrink-0 cursor-pointer rounded-[2px] border border-primary bg-background ring-offset-background transition-[color,background-color,border-color] duration-fast ease-default focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/35 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground", coarseHitAreaClasses, className),
1600
- ...props,
1601
- children: /* @__PURE__ */ jsx(Checkbox$1.Indicator, {
1602
- className: cn("flex h-full w-full items-center justify-center text-current"),
1603
- children: checked === "indeterminate" ? /* @__PURE__ */ jsx(IndeterminateIcon, { className: "h-[10px] w-[10px]" }) : /* @__PURE__ */ jsx(CheckIcon, { className: "h-[10px] w-[10px]" })
1604
- })
1605
- }));
2052
+ const Checkbox = React.forwardRef(({ className, checked, ...props }, ref) => {
2053
+ const fieldProps = useFieldControl(props);
2054
+ return /* @__PURE__ */ jsx(Checkbox$1.Root, {
2055
+ ref,
2056
+ checked,
2057
+ className: cn("peer h-4 w-4 shrink-0 cursor-pointer rounded-[2px] border border-primary bg-background ring-offset-background transition-[color,background-color,border-color] duration-fast ease-default focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/35 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground", coarseHitAreaClasses, className),
2058
+ ...fieldProps,
2059
+ children: /* @__PURE__ */ jsx(Checkbox$1.Indicator, {
2060
+ className: cn("flex h-full w-full items-center justify-center text-current"),
2061
+ children: checked === "indeterminate" ? /* @__PURE__ */ jsx(IndeterminateIcon, { className: "h-[10px] w-[10px]" }) : /* @__PURE__ */ jsx(CheckIcon, { className: "h-[10px] w-[10px]" })
2062
+ })
2063
+ });
2064
+ });
1606
2065
  Checkbox.displayName = Checkbox$1.Root.displayName;
1607
2066
  //#endregion
1608
2067
  //#region src/components/radio-group.tsx
1609
- const RadioGroup = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(RadioGroup$1.Root, {
1610
- className: cn("grid gap-2", className),
1611
- ...props,
1612
- ref
1613
- }));
2068
+ const RadioGroup = React.forwardRef(({ className, ...props }, ref) => {
2069
+ const fieldProps = useFieldControl(props);
2070
+ return /* @__PURE__ */ jsx(RadioGroup$1.Root, {
2071
+ className: cn("grid gap-2", className),
2072
+ ...fieldProps,
2073
+ ref
2074
+ });
2075
+ });
1614
2076
  RadioGroup.displayName = RadioGroup$1.Root.displayName;
1615
2077
  const RadioGroupItem = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(RadioGroup$1.Item, {
1616
2078
  ref,
@@ -1643,24 +2105,36 @@ const switchThumbVariants = cva("pointer-events-none block rounded-full bg-backg
1643
2105
  } },
1644
2106
  defaultVariants: { size: "md" }
1645
2107
  });
1646
- const Switch = React.forwardRef(({ className, size, ...props }, ref) => /* @__PURE__ */ jsx(Switch$1.Root, {
1647
- className: cn(switchVariants({ size }), coarseHitAreaClasses, className),
1648
- ...props,
1649
- ref,
1650
- children: /* @__PURE__ */ jsx(Switch$1.Thumb, { className: cn(switchThumbVariants({ size })) })
1651
- }));
2108
+ const Switch = React.forwardRef(({ className, size, ...props }, ref) => {
2109
+ const fieldProps = useFieldControl(props);
2110
+ return /* @__PURE__ */ jsx(Switch$1.Root, {
2111
+ className: cn(switchVariants({ size }), coarseHitAreaClasses, className),
2112
+ ...fieldProps,
2113
+ ref,
2114
+ children: /* @__PURE__ */ jsx(Switch$1.Thumb, { className: cn(switchThumbVariants({ size })) })
2115
+ });
2116
+ });
1652
2117
  Switch.displayName = Switch$1.Root.displayName;
1653
2118
  //#endregion
1654
2119
  //#region src/components/slider.tsx
1655
- const Slider = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs(Slider$1.Root, {
1656
- ref,
1657
- className: cn("relative flex w-full touch-none select-none items-center", className),
1658
- ...props,
1659
- children: [/* @__PURE__ */ jsx(Slider$1.Track, {
1660
- className: "relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",
1661
- children: /* @__PURE__ */ jsx(Slider$1.Range, { className: "absolute h-full bg-primary" })
1662
- }), /* @__PURE__ */ jsx(Slider$1.Thumb, { className: cn("block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", coarseHitAreaClasses) })]
1663
- }));
2120
+ const Slider = React.forwardRef(({ className, ...props }, ref) => {
2121
+ const { id, "aria-describedby": describedBy, "aria-invalid": invalid, "aria-required": ariaRequired, ...rootProps } = useFieldControl(props);
2122
+ return /* @__PURE__ */ jsxs(Slider$1.Root, {
2123
+ ref,
2124
+ className: cn("relative flex w-full touch-none select-none items-center", className),
2125
+ ...rootProps,
2126
+ children: [/* @__PURE__ */ jsx(Slider$1.Track, {
2127
+ className: "relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",
2128
+ children: /* @__PURE__ */ jsx(Slider$1.Range, { className: "absolute h-full bg-primary" })
2129
+ }), /* @__PURE__ */ jsx(Slider$1.Thumb, {
2130
+ id,
2131
+ "aria-describedby": describedBy,
2132
+ "aria-invalid": invalid,
2133
+ "aria-required": ariaRequired,
2134
+ className: cn("block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", coarseHitAreaClasses)
2135
+ })]
2136
+ });
2137
+ });
1664
2138
  Slider.displayName = Slider$1.Root.displayName;
1665
2139
  //#endregion
1666
2140
  //#region src/components/card.tsx
@@ -5708,6 +6182,6 @@ function NotificationSettingsBlock({ groups, onSave, loading = false, error, dis
5708
6182
  });
5709
6183
  }
5710
6184
  //#endregion
5711
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountSettingsBlock, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppSidebarBlock, AspectRatio, Avatar, AvatarFallback, AvatarImage, Badge, BisonProvider, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CodeInput, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CurrencyInput, DataTable, DataTableColumnHeader, DatePicker, DateRangePicker, DensityProvider, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditableTitle, EmptyStateBlock, FooterBlock, ForgotPasswordBlock, Form, FormError, FormField, HeaderBlock, Input, InputGroup, Label, MaintenanceBlock, MediaCard, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NotFoundBlock, NotificationSettingsBlock, OutlinedField, PageShell, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PasswordInput, PhoneInput, Popover, PopoverContent, PopoverTrigger, ProfileSettingsBlock, Progress, ProgressBar, RadioGroup, RadioGroupItem, Rating, ResetPasswordBlock, ReviewsBlock, SavedPing, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, ServerErrorBlock, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Sidebar, SidebarBlock, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, SignInBlock, SignUpBlock, Skeleton, Slider, SocialProviders, Spinner, Stepper, StepperDescription, StepperIndicator, StepperItem, StepperLabel, StepperSeparator, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TextContent, TextEditor, Textarea, ThemeProvider, ThemeScope, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, VerifyBlock, actionNegativeToneClasses, actionNeutralIconChromeClasses, actionNeutralToneClasses, actionPositiveToneClasses, alertVariants, avatarVariants, badgeVariants, buttonVariants, cn, dateRangePresets, editableTitleVariants, formatUsPhone, navigationMenuTriggerStyle, outlinedFieldNestResetClasses, parseUsPhoneDigits, progressBarVariants, ratingVariants, spinnerVariants, stepperIndicatorVariants, stepperItemVariants, stepperLabelVariants, switchVariants, toast, useDensity, useFormContext, useIsMobile, useScrollReveal, useSidebar, useTheme };
6185
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountSettingsBlock, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppSidebarBlock, AspectRatio, Avatar, AvatarFallback, AvatarImage, Badge, BisonProvider, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CodeInput, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CurrencyInput, DataTable, DataTableColumnHeader, DatePicker, DateRangePicker, DensityProvider, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditableTitle, EmptyStateBlock, FieldGroupScope, FieldProvider, FooterBlock, ForgotPasswordBlock, Form, FormError, FormField, HeaderBlock, Input, InputGroup, Label, MaintenanceBlock, MediaCard, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NotFoundBlock, NotificationSettingsBlock, OutlinedField, PageShell, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PasswordInput, PhoneInput, Popover, PopoverContent, PopoverTrigger, ProfileSettingsBlock, Progress, ProgressBar, RadioGroup, RadioGroupItem, Rating, ResetPasswordBlock, ReviewsBlock, SavedPing, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, ServerErrorBlock, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Sidebar, SidebarBlock, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, SignInBlock, SignUpBlock, Skeleton, Slider, SocialProviders, Spinner, Stepper, StepperDescription, StepperIndicator, StepperItem, StepperLabel, StepperSeparator, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TextContent, TextEditor, Textarea, ThemeProvider, ThemeScope, TimePicker, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, VerifyBlock, actionNegativeToneClasses, actionNeutralIconChromeClasses, actionNeutralToneClasses, actionPositiveToneClasses, alertVariants, avatarVariants, badgeVariants, buttonVariants, cn, dateRangePresets, editableTitleVariants, formatUsPhone, navigationMenuTriggerStyle, outlinedFieldNestResetClasses, parseUsPhoneDigits, progressBarVariants, ratingVariants, spinnerVariants, stepperIndicatorVariants, stepperItemVariants, stepperLabelVariants, switchVariants, toast, useDensity, useField, useFieldControl, useFieldGroup, useFieldIds, useFormContext, useIsMobile, useScrollReveal, useSidebar, useTheme };
5712
6186
 
5713
6187
  //# sourceMappingURL=index.mjs.map