@bison-lab/ui 5.9.1 → 5.12.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
@@ -420,6 +420,142 @@ const ThemeScope = React.forwardRef(({ overrides, className, style, children, ..
420
420
  });
421
421
  ThemeScope.displayName = "ThemeScope";
422
422
  //#endregion
423
+ //#region src/form/field-context.tsx
424
+ const FieldContext = React.createContext(void 0);
425
+ const FieldProvider = FieldContext.Provider;
426
+ /**
427
+ * Marks a field wrapper's root element (`FormField`, `OutlinedField`,
428
+ * `InputGroup`). `Form`'s blur check treats focus moving to anything inside
429
+ * the same box (a password's show/hide toggle) as still inside the field.
430
+ */
431
+ const FIELD_BOX_ATTRIBUTE = "data-bison-field";
432
+ /** Spread onto a field wrapper's root element. */
433
+ const fieldBoxProps = { "data-bison-field": "" };
434
+ /** Read the surrounding field, if there is one. */
435
+ function useField() {
436
+ return React.useContext(FieldContext);
437
+ }
438
+ /**
439
+ * Build one `aria-describedby` out of the field's ids and whatever the consumer
440
+ * already set.
441
+ *
442
+ * Deduplicates, and splits on whitespace first so an incoming multi-id value is
443
+ * handled. `FormField` renders its own `description` as a `FieldNote`, so the
444
+ * description id arrives twice — once as `descriptionId`, once through the
445
+ * registry — and repeating it makes a screen reader read the hint twice.
446
+ */
447
+ function describedBy(...parts) {
448
+ const ids = parts.filter((part) => Boolean(part)).flatMap((part) => part.split(/\s+/)).filter(Boolean);
449
+ return Array.from(new Set(ids)).join(" ") || void 0;
450
+ }
451
+ /**
452
+ * The note registry a field wrapper owns.
453
+ *
454
+ * Every wrapper that publishes a {@link FieldContextValue} calls this and
455
+ * passes both halves through the context: `noteIds` so the control's (or the
456
+ * `<fieldset>`'s) `aria-describedby` reaches each note, `registerNote` so the
457
+ * notes can get themselves in there.
458
+ */
459
+ function useFieldNotes() {
460
+ const [noteIds, setNoteIds] = React.useState([]);
461
+ return {
462
+ noteIds,
463
+ registerNote: React.useCallback((id) => {
464
+ setNoteIds((ids) => ids.includes(id) ? ids : [...ids, id]);
465
+ return () => setNoteIds((ids) => ids.includes(id) ? ids.filter((other) => other !== id) : ids);
466
+ }, [])
467
+ };
468
+ }
469
+ /**
470
+ * Merge the surrounding field's ARIA wiring into a control's own props.
471
+ *
472
+ * Call it in every control that accepts user input and spread the result onto
473
+ * the DOM node.
474
+ *
475
+ * Inside a field the wrapper OWNS the control's `id`, and a consumer-supplied
476
+ * one is deliberately overridden. The wrapper has already rendered its
477
+ * `<label for>` pointing at the id it published, and it cannot see the child's
478
+ * props to follow it anywhere else — so honouring an override here would leave
479
+ * the label resolving to nothing, which is precisely the defect this context
480
+ * exists to remove. Set the id through the wrapper's `name` / `htmlFor`
481
+ * instead. `aria-invalid` and `aria-required` do defer to an explicit prop,
482
+ * and the field's description ids are APPENDED to any `aria-describedby` the
483
+ * consumer set rather than replacing it.
484
+ *
485
+ * Returns `props` unchanged when there is no field, or when the field is a
486
+ * group.
487
+ */
488
+ function useFieldControl(props) {
489
+ const field = useField();
490
+ if (!field || field.group) return props;
491
+ return {
492
+ ...props,
493
+ id: field.controlId,
494
+ "aria-invalid": props["aria-invalid"] ?? (field.invalid || void 0),
495
+ "aria-required": props["aria-required"] ?? (field.required || void 0),
496
+ "aria-describedby": describedBy(field.descriptionId, ...field.noteIds ?? [], field.errorId, props["aria-describedby"])
497
+ };
498
+ }
499
+ /**
500
+ * The composite-control counterpart to {@link useFieldControl}.
501
+ *
502
+ * `TimePicker` is three selects and `CodeInput` is six inputs; neither has a
503
+ * single element for the field's label to point at, and a `<label for>` naming
504
+ * a `<div>` names nothing at all. These wrap their children in a labelled
505
+ * `role="group"` instead, so the whole composite is announced once with its
506
+ * error and hint attached.
507
+ *
508
+ * Returns `{}` outside a field wrapper, leaving standalone usage untouched.
509
+ */
510
+ function useFieldGroup() {
511
+ const field = useField();
512
+ if (!field) return {};
513
+ return {
514
+ role: "group",
515
+ "aria-labelledby": field.labelId,
516
+ "aria-describedby": describedBy(field.descriptionId, ...field.noteIds ?? [], field.errorId),
517
+ "aria-invalid": field.invalid || void 0,
518
+ "aria-required": field.required || void 0
519
+ };
520
+ }
521
+ /**
522
+ * Seals a composite control against the field it sits in.
523
+ *
524
+ * `CodeInput` renders six `<Input>`s and `TimePicker` renders three
525
+ * `<SelectTrigger>`s. Each of those calls {@link useFieldControl}, so without
526
+ * this they would every one of them adopt the SAME field id — six elements
527
+ * sharing `id="code"`, which is worse than the missing wiring this whole
528
+ * mechanism set out to fix. Re-providing the field in group mode turns the
529
+ * hook into a no-op for everything below, leaving the composite's own wrapper
530
+ * ({@link useFieldGroup}) as the single labelled thing.
531
+ */
532
+ function FieldGroupScope({ children }) {
533
+ const field = useField();
534
+ return /* @__PURE__ */ jsx(FieldProvider, {
535
+ value: React.useMemo(() => field ? {
536
+ ...field,
537
+ group: true
538
+ } : void 0, [field]),
539
+ children
540
+ });
541
+ }
542
+ /**
543
+ * Build the ids a wrapper publishes.
544
+ *
545
+ * `useId()` supplies the hint/error ids because nothing outside the wrapper
546
+ * references them, so uniqueness costs nothing. The control id stays
547
+ * caller-derived — see {@link FieldContextValue.controlId}.
548
+ */
549
+ function useFieldIds({ controlId, hasDescription, hasError }) {
550
+ const reactId = React.useId();
551
+ return {
552
+ controlId,
553
+ descriptionId: hasDescription ? `${reactId}-description` : void 0,
554
+ errorId: hasError ? `${reactId}-error` : void 0,
555
+ labelId: `${reactId}-label`
556
+ };
557
+ }
558
+ //#endregion
423
559
  //#region src/form/form.tsx
424
560
  const FormContext = React.createContext(void 0);
425
561
  function useFormContext() {
@@ -488,10 +624,44 @@ function controlName(target) {
488
624
  const name = target?.name;
489
625
  return typeof name === "string" && name ? name : void 0;
490
626
  }
627
+ /** The field wrapper (`FormField` and kin) an element sits in, if any. */
628
+ function fieldBoxOf(el) {
629
+ return el instanceof Element ? el.closest(`[${FIELD_BOX_ATTRIBUTE}]`) : null;
630
+ }
631
+ /**
632
+ * The field focus is leaving: the control's own name, or, for an unnamed
633
+ * part of a field (a password's show/hide toggle, a Radix checkbox's button),
634
+ * the one name its field box submits. A box holding several names is not
635
+ * one field, so an unnamed part there resolves to nothing.
636
+ */
637
+ function leftFieldName(target) {
638
+ const own = controlName(target);
639
+ if (own) return own;
640
+ const box = fieldBoxOf(target);
641
+ if (!box) return void 0;
642
+ const names = new Set(Array.from(box.querySelectorAll("[name]"), (el) => controlName(el)).filter(Boolean));
643
+ return names.size === 1 ? Array.from(names)[0] : void 0;
644
+ }
645
+ /**
646
+ * Whether focus moved into a popup the field box owns: a Select's list or a
647
+ * picker's calendar, portaled outside the box and named by an
648
+ * `aria-controls` inside it. Opening one is not leaving the field.
649
+ */
650
+ function inOwnedPopup(box, related) {
651
+ for (const el of Array.from(box.querySelectorAll("[aria-controls]"))) for (const id of (el.getAttribute("aria-controls") ?? "").split(/\s+/)) if (id && box.ownerDocument.getElementById(id)?.contains(related)) return true;
652
+ return false;
653
+ }
654
+ /**
655
+ * How long a press may go without a click before held blur checks run
656
+ * anyway (the pointer was dragged off, or the press was a scroll).
657
+ */
658
+ const PRESS_RELEASE_FALLBACK_MS = 500;
659
+ /** The same, from the press itself, for a release that never arrives. */
660
+ const PRESS_SAFETY_MS = 1500;
491
661
  function defaultErrorSummary(count) {
492
662
  return count === 1 ? "1 field needs attention." : `${count} fields need attention.`;
493
663
  }
494
- const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", errors: externalErrors, focusOnError = true, errorSummary = defaultErrorSummary, validateOn = "submit", children, className, noValidate, onBlur, onChange, ...props }, ref) => {
664
+ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", errors: externalErrors, focusOnError = true, errorSummary = defaultErrorSummary, validateOn = "submit", validateUntouched = true, children, className, noValidate, onBlur, onChange, ...props }, ref) => {
495
665
  const [errors, setErrors] = React.useState({});
496
666
  const [touched, setTouched] = React.useState({});
497
667
  const [isSubmitting, setIsSubmitting] = React.useState(false);
@@ -521,29 +691,102 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", errors:
521
691
  const editedRef = React.useRef(/* @__PURE__ */ new Set());
522
692
  const shownRef = React.useRef(/* @__PURE__ */ new Set());
523
693
  const judgeBlur = validateOn === "blur" && Boolean(schema);
524
- /** Re-judge one field against the whole form's current values. */
694
+ /**
695
+ * Re-judge one field against the whole form's current values, and with it
696
+ * every other field already showing an error. A cross-field rule (a
697
+ * confirmation that must match) reports on one field but is fixed by
698
+ * editing another, so a fix elsewhere has to clear it. Fields not showing
699
+ * an error are left alone: a neighbour's edit never raises a new one.
700
+ */
525
701
  const judgeField = React.useCallback((form, name) => {
526
702
  if (!schema) return;
527
- const message = schemaErrors(schema, readForm(form))[name];
528
- if (message) {
529
- shownRef.current.add(name);
530
- setFieldError(name, message);
531
- } else if (shownRef.current.has(name)) {
532
- shownRef.current.delete(name);
533
- clearFieldError(name);
534
- }
703
+ const found = schemaErrors(schema, readForm(form));
704
+ const judge = (field) => {
705
+ const message = found[field];
706
+ if (message) {
707
+ shownRef.current.add(field);
708
+ setFieldError(field, message);
709
+ } else if (shownRef.current.has(field)) {
710
+ shownRef.current.delete(field);
711
+ clearFieldError(field);
712
+ }
713
+ };
714
+ judge(name);
715
+ for (const other of Array.from(shownRef.current)) if (other !== name) judge(other);
535
716
  }, [
536
717
  schema,
537
718
  setFieldError,
538
719
  clearFieldError
539
720
  ]);
721
+ const pressingRef = React.useRef(false);
722
+ const heldRef = React.useRef(/* @__PURE__ */ new Set());
723
+ const judgeFieldRef = React.useRef(judgeField);
724
+ judgeFieldRef.current = judgeField;
725
+ React.useEffect(() => {
726
+ if (!judgeBlur) return;
727
+ const doc = innerRef.current?.ownerDocument;
728
+ if (!doc) return;
729
+ let fallback;
730
+ let afterClick;
731
+ const release = () => {
732
+ clearTimeout(fallback);
733
+ clearTimeout(afterClick);
734
+ pressingRef.current = false;
735
+ const form = innerRef.current;
736
+ const held = Array.from(heldRef.current);
737
+ heldRef.current.clear();
738
+ if (form) for (const name of held) judgeFieldRef.current(form, name);
739
+ };
740
+ const onPointerDown = (e) => {
741
+ if (e.button !== 0) return;
742
+ clearTimeout(fallback);
743
+ pressingRef.current = true;
744
+ fallback = setTimeout(release, PRESS_SAFETY_MS);
745
+ };
746
+ const onPointerUp = () => {
747
+ clearTimeout(fallback);
748
+ fallback = setTimeout(release, PRESS_RELEASE_FALLBACK_MS);
749
+ };
750
+ const onClick = () => {
751
+ if (!pressingRef.current) return;
752
+ clearTimeout(afterClick);
753
+ afterClick = setTimeout(release, 0);
754
+ };
755
+ doc.addEventListener("pointerdown", onPointerDown, true);
756
+ doc.addEventListener("pointerup", onPointerUp, true);
757
+ doc.addEventListener("pointercancel", onPointerUp, true);
758
+ doc.addEventListener("click", onClick, true);
759
+ return () => {
760
+ clearTimeout(fallback);
761
+ clearTimeout(afterClick);
762
+ pressingRef.current = false;
763
+ heldRef.current.clear();
764
+ doc.removeEventListener("pointerdown", onPointerDown, true);
765
+ doc.removeEventListener("pointerup", onPointerUp, true);
766
+ doc.removeEventListener("pointercancel", onPointerUp, true);
767
+ doc.removeEventListener("click", onClick, true);
768
+ };
769
+ }, [judgeBlur]);
540
770
  const handleBlur = React.useCallback((e) => {
541
771
  onBlur?.(e);
542
- const name = controlName(e.target);
543
- if (judgeBlur && name && (editedRef.current.has(name) || shownRef.current.has(name))) judgeField(e.currentTarget, name);
772
+ if (!judgeBlur) return;
773
+ const name = leftFieldName(e.target);
774
+ if (!name) return;
775
+ const box = fieldBoxOf(e.target);
776
+ const related = e.relatedTarget instanceof Node ? e.relatedTarget : null;
777
+ if (box && related && (box.contains(related) || inOwnedPopup(box, related))) return;
778
+ if (controlName(e.relatedTarget) === name) return;
779
+ if (e.target.ownerDocument.activeElement === e.target) return;
780
+ if (!(editedRef.current.has(name) || shownRef.current.has(name)) && !validateUntouched) return;
781
+ if (pressingRef.current) {
782
+ heldRef.current.add(name);
783
+ return;
784
+ }
785
+ judgeField(e.currentTarget, name);
544
786
  }, [
545
787
  onBlur,
546
788
  judgeBlur,
789
+ validateUntouched,
547
790
  judgeField
548
791
  ]);
549
792
  const handleChange = React.useCallback((e) => {
@@ -559,6 +802,7 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", errors:
559
802
  ]);
560
803
  const handleSubmit = React.useCallback(async (e) => {
561
804
  e.preventDefault();
805
+ heldRef.current.clear();
562
806
  setIsSubmitting(true);
563
807
  setErrors({});
564
808
  const data = readForm(e.currentTarget);
@@ -731,134 +975,6 @@ const Label = React.forwardRef(({ className, layout, as = "label", required, chi
731
975
  });
732
976
  Label.displayName = "Label";
733
977
  //#endregion
734
- //#region src/form/field-context.tsx
735
- const FieldContext = React.createContext(void 0);
736
- const FieldProvider = FieldContext.Provider;
737
- /** Read the surrounding field, if there is one. */
738
- function useField() {
739
- return React.useContext(FieldContext);
740
- }
741
- /**
742
- * Build one `aria-describedby` out of the field's ids and whatever the consumer
743
- * already set.
744
- *
745
- * Deduplicates, and splits on whitespace first so an incoming multi-id value is
746
- * handled. `FormField` renders its own `description` as a `FieldNote`, so the
747
- * description id arrives twice — once as `descriptionId`, once through the
748
- * registry — and repeating it makes a screen reader read the hint twice.
749
- */
750
- function describedBy(...parts) {
751
- const ids = parts.filter((part) => Boolean(part)).flatMap((part) => part.split(/\s+/)).filter(Boolean);
752
- return Array.from(new Set(ids)).join(" ") || void 0;
753
- }
754
- /**
755
- * The note registry a field wrapper owns.
756
- *
757
- * Every wrapper that publishes a {@link FieldContextValue} calls this and
758
- * passes both halves through the context: `noteIds` so the control's (or the
759
- * `<fieldset>`'s) `aria-describedby` reaches each note, `registerNote` so the
760
- * notes can get themselves in there.
761
- */
762
- function useFieldNotes() {
763
- const [noteIds, setNoteIds] = React.useState([]);
764
- return {
765
- noteIds,
766
- registerNote: React.useCallback((id) => {
767
- setNoteIds((ids) => ids.includes(id) ? ids : [...ids, id]);
768
- return () => setNoteIds((ids) => ids.includes(id) ? ids.filter((other) => other !== id) : ids);
769
- }, [])
770
- };
771
- }
772
- /**
773
- * Merge the surrounding field's ARIA wiring into a control's own props.
774
- *
775
- * Call it in every control that accepts user input and spread the result onto
776
- * the DOM node.
777
- *
778
- * Inside a field the wrapper OWNS the control's `id`, and a consumer-supplied
779
- * one is deliberately overridden. The wrapper has already rendered its
780
- * `<label for>` pointing at the id it published, and it cannot see the child's
781
- * props to follow it anywhere else — so honouring an override here would leave
782
- * the label resolving to nothing, which is precisely the defect this context
783
- * exists to remove. Set the id through the wrapper's `name` / `htmlFor`
784
- * instead. `aria-invalid` and `aria-required` do defer to an explicit prop,
785
- * and the field's description ids are APPENDED to any `aria-describedby` the
786
- * consumer set rather than replacing it.
787
- *
788
- * Returns `props` unchanged when there is no field, or when the field is a
789
- * group.
790
- */
791
- function useFieldControl(props) {
792
- const field = useField();
793
- if (!field || field.group) return props;
794
- return {
795
- ...props,
796
- id: field.controlId,
797
- "aria-invalid": props["aria-invalid"] ?? (field.invalid || void 0),
798
- "aria-required": props["aria-required"] ?? (field.required || void 0),
799
- "aria-describedby": describedBy(field.descriptionId, ...field.noteIds ?? [], field.errorId, props["aria-describedby"])
800
- };
801
- }
802
- /**
803
- * The composite-control counterpart to {@link useFieldControl}.
804
- *
805
- * `TimePicker` is three selects and `CodeInput` is six inputs; neither has a
806
- * single element for the field's label to point at, and a `<label for>` naming
807
- * a `<div>` names nothing at all. These wrap their children in a labelled
808
- * `role="group"` instead, so the whole composite is announced once with its
809
- * error and hint attached.
810
- *
811
- * Returns `{}` outside a field wrapper, leaving standalone usage untouched.
812
- */
813
- function useFieldGroup() {
814
- const field = useField();
815
- if (!field) return {};
816
- return {
817
- role: "group",
818
- "aria-labelledby": field.labelId,
819
- "aria-describedby": describedBy(field.descriptionId, ...field.noteIds ?? [], field.errorId),
820
- "aria-invalid": field.invalid || void 0,
821
- "aria-required": field.required || void 0
822
- };
823
- }
824
- /**
825
- * Seals a composite control against the field it sits in.
826
- *
827
- * `CodeInput` renders six `<Input>`s and `TimePicker` renders three
828
- * `<SelectTrigger>`s. Each of those calls {@link useFieldControl}, so without
829
- * this they would every one of them adopt the SAME field id — six elements
830
- * sharing `id="code"`, which is worse than the missing wiring this whole
831
- * mechanism set out to fix. Re-providing the field in group mode turns the
832
- * hook into a no-op for everything below, leaving the composite's own wrapper
833
- * ({@link useFieldGroup}) as the single labelled thing.
834
- */
835
- function FieldGroupScope({ children }) {
836
- const field = useField();
837
- return /* @__PURE__ */ jsx(FieldProvider, {
838
- value: React.useMemo(() => field ? {
839
- ...field,
840
- group: true
841
- } : void 0, [field]),
842
- children
843
- });
844
- }
845
- /**
846
- * Build the ids a wrapper publishes.
847
- *
848
- * `useId()` supplies the hint/error ids because nothing outside the wrapper
849
- * references them, so uniqueness costs nothing. The control id stays
850
- * caller-derived — see {@link FieldContextValue.controlId}.
851
- */
852
- function useFieldIds({ controlId, hasDescription, hasError }) {
853
- const reactId = React.useId();
854
- return {
855
- controlId,
856
- descriptionId: hasDescription ? `${reactId}-description` : void 0,
857
- errorId: hasError ? `${reactId}-error` : void 0,
858
- labelId: `${reactId}-label`
859
- };
860
- }
861
- //#endregion
862
978
  //#region src/form/field-note.tsx
863
979
  /**
864
980
  * `md` pins the exact type of the hint paragraph `FormField` shipped, so
@@ -1042,6 +1158,7 @@ const OutlinedField = React.forwardRef(({ label, htmlFor, error, errorVersion =
1042
1158
  value: field,
1043
1159
  children: /* @__PURE__ */ jsxs("div", {
1044
1160
  ref,
1161
+ ...fieldBoxProps,
1045
1162
  className: cn("flex flex-col", className),
1046
1163
  children: [
1047
1164
  /* @__PURE__ */ jsxs("div", {
@@ -1157,6 +1274,7 @@ function FormField({ name, id, label, description, required, labelLayout = "stac
1157
1274
  value: field,
1158
1275
  children: /* @__PURE__ */ jsxs("fieldset", {
1159
1276
  ref: wrapRef,
1277
+ ...fieldBoxProps,
1160
1278
  className: cn("flex flex-col", errorMessage && "bison-shake", className),
1161
1279
  "aria-describedby": describedBy$1,
1162
1280
  children: [
@@ -1175,6 +1293,7 @@ function FormField({ name, id, label, description, required, labelLayout = "stac
1175
1293
  value: field,
1176
1294
  children: /* @__PURE__ */ jsxs("div", {
1177
1295
  ref: wrapRef,
1296
+ ...fieldBoxProps,
1178
1297
  className: cn("flex flex-col", errorMessage && "bison-shake", className),
1179
1298
  children: [
1180
1299
  label && /* @__PURE__ */ jsx(Label, {
@@ -1194,7 +1313,7 @@ function FormField({ name, id, label, description, required, labelLayout = "stac
1194
1313
  function FormError({ message, className }) {
1195
1314
  if (!message) return null;
1196
1315
  return /* @__PURE__ */ jsx("div", {
1197
- className: cn("rounded-md border border-destructive-300 bg-destructive-50 px-4 py-3 text-sm text-destructive-700", className),
1316
+ className: cn("rounded-md border border-destructive-300 bg-destructive-50 px-4 py-3 text-sm text-destructive-700", "dark:border-destructive/50 dark:bg-destructive/12 dark:text-foreground", className),
1198
1317
  role: "alert",
1199
1318
  children: message
1200
1319
  });
@@ -1204,11 +1323,11 @@ function FormError({ message, className }) {
1204
1323
  const buttonVariants = cva("relative inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-[color,background-color,border-color,box-shadow] duration-fast ease-default focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer pointer-coarse:min-h-11 pointer-coarse:min-w-11", {
1205
1324
  variants: {
1206
1325
  variant: {
1207
- default: "bg-primary text-primary-foreground hover:bg-primary-700 hover:shadow-md",
1326
+ default: "bg-primary text-primary-foreground hover:bg-[hsl(var(--primary-hover,var(--primary-700)))] hover:shadow-md",
1208
1327
  secondary: "bg-secondary text-secondary-foreground hover:bg-secondary-700 hover:shadow-md",
1209
1328
  accent: "bg-brand-accent text-brand-accent-foreground hover:bg-brand-accent-600 hover:shadow-md",
1210
1329
  highlight: "bg-highlight text-highlight-foreground hover:bg-highlight-600 hover:shadow-md",
1211
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive-700 hover:shadow-md",
1330
+ destructive: "bg-destructive text-destructive-foreground hover:bg-[hsl(var(--destructive-hover,var(--destructive-700,0_74%_42%)))] hover:shadow-md",
1212
1331
  outline: "border border-border-strong bg-background text-foreground hover:bg-accent hover:text-accent-foreground hover:shadow-sm",
1213
1332
  ghost: "hover:bg-accent hover:text-accent-foreground",
1214
1333
  actionNeutral: actionNeutralToneClasses,
@@ -1326,6 +1445,15 @@ const inputSurfaceClasses = "flex w-full rounded-md border border-input bg-backg
1326
1445
  */
1327
1446
  const inputFocusClasses = "focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/30 focus-visible:ring-offset-0";
1328
1447
  /**
1448
+ * The destructive border on a control in error. Keyed on the `aria-invalid`
1449
+ * a field wrapper already sets, so a stacked field (label above) turns red the
1450
+ * way the outlined layout's shell does. Inside an outlined shell the control's
1451
+ * own border is reset to zero width, so the two never stack.
1452
+ *
1453
+ * Used by: Input, PasswordInput, Checkbox.
1454
+ */
1455
+ const invalidBorderClasses = "aria-invalid:border-destructive";
1456
+ /**
1329
1457
  * Standard single-line input sizing per size: density height + horizontal
1330
1458
  * padding + vertical padding, scaled per size. Textarea uses `min-h-[80px]`
1331
1459
  * instead of any of these.
@@ -1389,10 +1517,20 @@ const touchTargetClasses = "pointer-coarse:min-h-11 pointer-coarse:min-w-11";
1389
1517
  * (dense tables, tight forms) stay pixel-identical. Includes `relative`; the
1390
1518
  * host element must not be `overflow-hidden` or the pseudo is clipped.
1391
1519
  *
1392
- * Used by: Checkbox, Radio, Switch, Slider thumb.
1520
+ * Used by: Switch, Slider thumb. Checkbox and Radio use `minHitAreaClasses`.
1393
1521
  */
1394
1522
  const coarseHitAreaClasses = "relative before:absolute before:left-1/2 before:top-1/2 before:hidden before:size-11 before:-translate-x-1/2 before:-translate-y-1/2 before:content-[''] pointer-coarse:before:block";
1395
1523
  /**
1524
+ * `coarseHitAreaClasses` plus a 24x24 target on fine pointers too, for a
1525
+ * control drawn under 24px (WCAG 2.2, 2.5.8 Target Size (Minimum)). The
1526
+ * same transparent pseudo-element is shown on every pointer at 24px and
1527
+ * grows to 44px on touch; the drawn control and its layout box are
1528
+ * unchanged. Same caveat: the host must not be `overflow-hidden`.
1529
+ *
1530
+ * Used by: Checkbox, Radio.
1531
+ */
1532
+ const minHitAreaClasses = "relative before:absolute before:left-1/2 before:top-1/2 before:block before:size-6 before:-translate-x-1/2 before:-translate-y-1/2 before:content-[''] pointer-coarse:before:size-11";
1533
+ /**
1396
1534
  * Menu surface chrome shared by floating menus and popovers:
1397
1535
  * Select Content, DropdownMenu Content, ContextMenu Content, Command.
1398
1536
  *
@@ -1430,9 +1568,17 @@ const floatingAnimationClasses = "origin-[var(--radix-popper-transform-origin)]
1430
1568
  */
1431
1569
  const tooltipAnimationClasses = "origin-[var(--radix-popper-transform-origin)] data-[state=delayed-open]:bison-tooltip-in data-[state=instant-open]:bison-tooltip-in data-[state=closed]:bison-tooltip-out";
1432
1570
  /**
1433
- * Scrim (backdrop) shared by Dialog, AlertDialog, Sheet.
1571
+ * Scrim (backdrop) shared by Dialog, AlertDialog, Sheet. Painted in the
1572
+ * theme's `--overlay` (its grey-950), not `bg-black`: pure black is off
1573
+ * every grey scale (#374).
1574
+ *
1575
+ * The derived-token colors in ui (this scrim, the `--primary-hover` /
1576
+ * `--destructive-hover` fills, `--control-border`) are written as arbitrary
1577
+ * values carrying their own fallback, not as the preset's `bg-overlay` and
1578
+ * friends: a site may run this ui on an older tailwind-preset that does not
1579
+ * define those utilities, and on a theme generated before the variables.
1434
1580
  */
1435
- const overlayScrimClasses = "fixed inset-0 z-[var(--z-modal-backdrop)] bg-black/80 data-[state=open]:bison-scrim-in data-[state=closed]:bison-scrim-out";
1581
+ const overlayScrimClasses = "fixed inset-0 z-[var(--z-modal-backdrop)] bg-[hsl(var(--overlay,229_84%_5%)/0.8)] data-[state=open]:bison-scrim-in data-[state=closed]:bison-scrim-out";
1436
1582
  /**
1437
1583
  * Centered modal content positioning + chrome (Dialog, AlertDialog).
1438
1584
  * Sheet has its own side-anchored variants in `sheet.tsx`.
@@ -1444,7 +1590,7 @@ const Input = React.forwardRef(({ className, type, size = "md", ...props }, ref)
1444
1590
  const fieldProps = useFieldControl(props);
1445
1591
  return /* @__PURE__ */ jsx("input", {
1446
1592
  type,
1447
- className: cn(inputSurfaceClasses, inputSizingClasses(size), inputFocusClasses, "file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
1593
+ className: cn(inputSurfaceClasses, inputSizingClasses(size), inputFocusClasses, invalidBorderClasses, "file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
1448
1594
  ref,
1449
1595
  ...fieldProps
1450
1596
  });
@@ -1454,14 +1600,18 @@ Input.displayName = "Input";
1454
1600
  //#region src/components/password-input.tsx
1455
1601
  const PasswordInput = React.forwardRef(({ className, toggleLabel = "Show or hide password", size = "md", ...props }, ref) => {
1456
1602
  const fieldProps = useFieldControl(props);
1603
+ const autoId = React.useId();
1604
+ const inputId = fieldProps.id ?? autoId;
1457
1605
  return /* @__PURE__ */ jsx(unstable_PasswordToggleField.Root, { children: /* @__PURE__ */ jsxs("div", {
1458
1606
  className: "relative",
1459
1607
  children: [/* @__PURE__ */ jsx(unstable_PasswordToggleField.Input, {
1460
- className: cn(inputSurfaceClasses, inputSizingClasses(size), inputFocusClasses, "pr-10 file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
1608
+ className: cn(inputSurfaceClasses, inputSizingClasses(size), inputFocusClasses, invalidBorderClasses, "pr-10 file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
1461
1609
  ref,
1462
- ...fieldProps
1610
+ ...fieldProps,
1611
+ id: inputId
1463
1612
  }), /* @__PURE__ */ jsx(unstable_PasswordToggleField.Toggle, {
1464
1613
  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",
1614
+ id: `${inputId}-toggle`,
1465
1615
  disabled: props.disabled,
1466
1616
  "aria-label": toggleLabel,
1467
1617
  children: /* @__PURE__ */ jsx(unstable_PasswordToggleField.Icon, {
@@ -1526,7 +1676,7 @@ const CodeInput = React.forwardRef(({ length = 6, onComplete, onChange, loading
1526
1676
  onChange: (e) => handleChange(index, e.target.value),
1527
1677
  onKeyDown: (e) => handleKeyDown(index, e),
1528
1678
  disabled: loading || disabled,
1529
- className: "h-12 w-12 text-center text-lg font-semibold",
1679
+ className: "h-12 min-w-0 flex-1 max-w-12 text-center text-lg font-semibold",
1530
1680
  autoFocus: index === 0,
1531
1681
  "aria-label": digitLabel(index + 1, length)
1532
1682
  }, index)) })
@@ -1695,6 +1845,7 @@ const InputGroup = React.forwardRef(({ label, htmlFor, error, hint, required, la
1695
1845
  value: field,
1696
1846
  children: /* @__PURE__ */ jsxs("div", {
1697
1847
  ref,
1848
+ ...fieldBoxProps,
1698
1849
  className: cn("flex flex-col", className),
1699
1850
  children: [
1700
1851
  /* @__PURE__ */ jsx(Label, {
@@ -1998,7 +2149,10 @@ const DatePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a da
1998
2149
  disabled,
1999
2150
  className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground", className),
2000
2151
  ...fieldProps,
2001
- children: [/* @__PURE__ */ jsx(Calendar$1, { className: "mr-2 h-4 w-4" }), value ? format(value, dateFormat) : /* @__PURE__ */ jsx("span", { children: placeholder })]
2152
+ children: [/* @__PURE__ */ jsx("span", {
2153
+ className: "min-w-0 flex-1 truncate text-left",
2154
+ children: value ? format(value, dateFormat) : placeholder
2155
+ }), /* @__PURE__ */ jsx(Calendar$1, { className: "ml-2 h-4 w-4 shrink-0" })]
2002
2156
  })
2003
2157
  }), /* @__PURE__ */ jsx(PopoverContent, {
2004
2158
  className: "w-auto p-0",
@@ -2260,6 +2414,16 @@ const dateRangePresets = {
2260
2414
  }
2261
2415
  })
2262
2416
  };
2417
+ /**
2418
+ * Where the clear button sits: the trigger's right padding, the 16px icon and
2419
+ * the 8px gap before it, so it lands exactly on the reserved slot. Follows
2420
+ * Button's padding per size (px-3, px-4, px-8).
2421
+ */
2422
+ const clearOffset = {
2423
+ sm: "right-9",
2424
+ md: "right-10",
2425
+ lg: "right-14"
2426
+ };
2263
2427
  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", calendarLabel = "Choose a date range", size = "md" }, ref) => {
2264
2428
  const fieldProps = useFieldControl({});
2265
2429
  const [open, setOpen] = React.useState(false);
@@ -2285,14 +2449,20 @@ const DateRangePicker = React.forwardRef(({ value, onChange, placeholder = "Pick
2285
2449
  variant: "outline",
2286
2450
  size,
2287
2451
  disabled,
2288
- className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground", showClear && "pr-9", className),
2452
+ className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground", className),
2289
2453
  ...fieldProps,
2290
- children: [/* @__PURE__ */ jsx(Calendar$1, { className: "mr-2 h-4 w-4" }), value?.from ? value.to ? /* @__PURE__ */ jsxs(Fragment, { children: [
2291
- format(value.from, dateFormat),
2292
- " –",
2293
- " ",
2294
- format(value.to, dateFormat)
2295
- ] }) : format(value.from, dateFormat) : /* @__PURE__ */ jsx("span", { children: placeholder })]
2454
+ children: [
2455
+ /* @__PURE__ */ jsx("span", {
2456
+ className: "min-w-0 flex-1 truncate text-left",
2457
+ children: value?.from ? value.to ? `${format(value.from, dateFormat)} – ${format(value.to, dateFormat)}` : format(value.from, dateFormat) : placeholder
2458
+ }),
2459
+ showClear && /* @__PURE__ */ jsx("span", {
2460
+ "aria-hidden": "true",
2461
+ "data-clear-slot": "",
2462
+ className: "ml-2 h-4 w-4 shrink-0"
2463
+ }),
2464
+ /* @__PURE__ */ jsx(Calendar$1, { className: "ml-2 h-4 w-4 shrink-0" })
2465
+ ]
2296
2466
  })
2297
2467
  }), showClear && /* @__PURE__ */ jsx("button", {
2298
2468
  type: "button",
@@ -2302,7 +2472,7 @@ const DateRangePicker = React.forwardRef(({ value, onChange, placeholder = "Pick
2302
2472
  onKeyDown: (e) => {
2303
2473
  if (e.key === "Enter" || e.key === " ") handleClear(e);
2304
2474
  },
2305
- className: "absolute right-2 top-1/2 -translate-y-1/2 rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
2475
+ className: cn("absolute top-1/2", clearOffset[size], "-translate-y-1/2 rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1"),
2306
2476
  children: /* @__PURE__ */ jsx(CircleX, { className: "h-4 w-4" })
2307
2477
  })]
2308
2478
  }), /* @__PURE__ */ jsx(PopoverContent, {
@@ -2737,7 +2907,7 @@ const Checkbox = React.forwardRef(({ className, checked, ...props }, ref) => {
2737
2907
  return /* @__PURE__ */ jsx(Checkbox$1.Root, {
2738
2908
  ref,
2739
2909
  checked,
2740
- 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),
2910
+ className: cn("peer h-4 w-4 shrink-0 cursor-pointer rounded-[2px] border border-[hsl(var(--control-border,215_16%_47%))] 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", minHitAreaClasses, invalidBorderClasses, className),
2741
2911
  ...fieldProps,
2742
2912
  children: /* @__PURE__ */ jsx(Checkbox$1.Indicator, {
2743
2913
  className: cn("flex h-full w-full items-center justify-center text-current"),
@@ -2942,7 +3112,7 @@ const RadioGroup = React.forwardRef(({ className, ...props }, ref) => {
2942
3112
  RadioGroup.displayName = RadioGroup$1.Root.displayName;
2943
3113
  const RadioGroupItem = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(RadioGroup$1.Item, {
2944
3114
  ref,
2945
- className: cn("inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-primary bg-background text-primary ring-offset-background focus: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", coarseHitAreaClasses, className),
3115
+ className: cn("inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[hsl(var(--control-border,215_16%_47%))] bg-background text-primary ring-offset-background focus: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", minHitAreaClasses, className),
2946
3116
  ...props,
2947
3117
  children: /* @__PURE__ */ jsx(RadioGroup$1.Indicator, {
2948
3118
  className: "flex h-full w-full items-center justify-center",
@@ -3063,7 +3233,7 @@ const defaultIcons = {
3063
3233
  danger: /* @__PURE__ */ jsx(CircleAlert, { className: "size-4" }),
3064
3234
  info: /* @__PURE__ */ jsx(Info, { className: "size-4" })
3065
3235
  };
3066
- const Alert = React.forwardRef(({ className, variant = "default", showIcon = false, icon, dismissable = false, onDismiss, children, ...props }, ref) => {
3236
+ const Alert = React.forwardRef(({ className, variant = "default", showIcon = false, icon, dismissable = false, onDismiss, action, children, ...props }, ref) => {
3067
3237
  const [dismissed, setDismissed] = React.useState(false);
3068
3238
  if (dismissed) return null;
3069
3239
  const resolvedIcon = icon ?? (showIcon ? defaultIcons[variant ?? "default"] : null);
@@ -3084,7 +3254,17 @@ const Alert = React.forwardRef(({ className, variant = "default", showIcon = fal
3084
3254
  ...props,
3085
3255
  children: [
3086
3256
  leading,
3087
- /* @__PURE__ */ jsx("div", {
3257
+ action != null && action !== false ? /* @__PURE__ */ jsxs("div", {
3258
+ className: "flex min-w-0 flex-1 flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",
3259
+ children: [/* @__PURE__ */ jsx("div", {
3260
+ className: "min-w-0 flex-1",
3261
+ children
3262
+ }), /* @__PURE__ */ jsx("div", {
3263
+ "data-alert-action": "",
3264
+ className: "shrink-0 whitespace-nowrap font-medium [&_a:not([class])]:underline [&_a:not([class])]:underline-offset-4",
3265
+ children: action
3266
+ })]
3267
+ }) : /* @__PURE__ */ jsx("div", {
3088
3268
  className: "min-w-0 flex-1",
3089
3269
  children
3090
3270
  }),
@@ -3139,7 +3319,7 @@ const badgeVariants = cva("inline-flex h-6 items-center justify-center rounded-m
3139
3319
  secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary-700",
3140
3320
  accent: "border-transparent bg-brand-accent text-brand-accent-foreground hover:bg-brand-accent-600",
3141
3321
  highlight: "border-transparent bg-highlight text-highlight-foreground hover:bg-highlight-600",
3142
- destructive: "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive-700",
3322
+ destructive: "border-transparent bg-destructive text-destructive-foreground hover:bg-[hsl(var(--destructive-hover,var(--destructive-700,0_74%_42%)))]",
3143
3323
  outline: "text-foreground",
3144
3324
  success: tintToneSuccess,
3145
3325
  warning: tintToneWarning,
@@ -3750,7 +3930,7 @@ const FilterButton = React.forwardRef(({ groups, value, onValueChange, apply = f
3750
3930
  },
3751
3931
  children: clearLabel
3752
3932
  }), apply ? /* @__PURE__ */ jsx(DropdownMenuItem, {
3753
- className: "flex-1 justify-center bg-primary font-medium text-primary-foreground focus:bg-primary-700 focus:text-primary-foreground",
3933
+ className: "flex-1 justify-center bg-primary font-medium text-primary-foreground focus:bg-[hsl(var(--primary-hover,var(--primary-700)))] focus:text-primary-foreground",
3754
3934
  onSelect: () => onValueChange(draft),
3755
3935
  children: applyLabel
3756
3936
  }) : null]
@@ -3767,7 +3947,7 @@ function Toaster({ position = "bottom-right", richColors = true, closeButton = t
3767
3947
  richColors,
3768
3948
  closeButton,
3769
3949
  toastOptions: { classNames: {
3770
- toast: "group border-border bg-background text-foreground shadow-lg",
3950
+ toast: "group border-border bg-background text-foreground shadow-lg motion-safe:[&[data-sonner-toast]:not([data-swiping=true])]:[transition:transform_400ms,opacity_400ms,box-shadow_200ms]!",
3771
3951
  description: "text-muted-foreground",
3772
3952
  actionButton: "bg-primary text-primary-foreground",
3773
3953
  cancelButton: "bg-muted text-muted-foreground"
@@ -4364,7 +4544,7 @@ function DataTableColumnHeader({ column, title, className }) {
4364
4544
  size: "sm",
4365
4545
  className: cn("-ml-3 h-8 data-[state=open]:bg-accent", className),
4366
4546
  onClick: () => column.toggleSorting(sorted === "asc"),
4367
- children: [title, sorted === "asc" ? /* @__PURE__ */ jsx(ArrowUp, { className: "ml-2 h-3.5 w-3.5" }) : sorted === "desc" ? /* @__PURE__ */ jsx(ArrowDown, { className: "ml-2 h-3.5 w-3.5" }) : /* @__PURE__ */ jsx(ArrowUpDown, { className: "ml-2 h-3.5 w-3.5 text-muted-foreground/50" })]
4547
+ children: [title, sorted === "asc" ? /* @__PURE__ */ jsx(ArrowUp, { className: "ml-2 h-3.5 w-3.5" }) : sorted === "desc" ? /* @__PURE__ */ jsx(ArrowDown, { className: "ml-2 h-3.5 w-3.5" }) : /* @__PURE__ */ jsx(ArrowUpDown, { className: "ml-2 h-3.5 w-3.5 text-muted-foreground" })]
4368
4548
  });
4369
4549
  }
4370
4550
  DataTableColumnHeader.displayName = "DataTableColumnHeader";
@@ -5609,10 +5789,10 @@ function Sidebar({ side = "left", variant = "sidebar", collapsible = "offcanvas"
5609
5789
  "data-slot": "sidebar",
5610
5790
  children: [/* @__PURE__ */ jsx("div", {
5611
5791
  "data-slot": "sidebar-gap",
5612
- className: cn("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear", "group-data-[collapsible=offcanvas]:w-0", "group-data-[side=right]:rotate-180", variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)")
5792
+ className: cn("relative w-(--sidebar-width) bg-transparent", "group-data-[collapsible=offcanvas]:w-0", "group-data-[side=right]:rotate-180", variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)")
5613
5793
  }), /* @__PURE__ */ jsx("div", {
5614
5794
  "data-slot": "sidebar-container",
5615
- className: cn("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex", side === "left" ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]", variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l", className),
5795
+ className: cn("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-transform duration-200 ease-linear md:flex", side === "left" ? "left-0 group-data-[collapsible=offcanvas]:-translate-x-full" : "right-0 group-data-[collapsible=offcanvas]:translate-x-full", variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l", className),
5616
5796
  ...props,
5617
5797
  children: /* @__PURE__ */ jsx("div", {
5618
5798
  "data-sidebar": "sidebar",
@@ -5651,7 +5831,7 @@ function SidebarRail({ className, ...props }) {
5651
5831
  tabIndex: -1,
5652
5832
  onClick: toggleSidebar,
5653
5833
  title: "Toggle Sidebar",
5654
- className: cn("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex", "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize", "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize", "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar", "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2", "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2", className),
5834
+ className: cn("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-transform ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex", "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize", "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize", "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar", "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2", "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2", className),
5655
5835
  ...props
5656
5836
  });
5657
5837
  }
@@ -5714,7 +5894,7 @@ function SidebarGroupLabel({ className, asChild = false, ...props }) {
5714
5894
  return /* @__PURE__ */ jsx(asChild ? Slot.Slot : "div", {
5715
5895
  "data-slot": "sidebar-group-label",
5716
5896
  "data-sidebar": "group-label",
5717
- className: cn("flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0", "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0", className),
5897
+ className: cn("flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-opacity duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0", "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0", className),
5718
5898
  ...props
5719
5899
  });
5720
5900
  }
@@ -5750,7 +5930,7 @@ function SidebarMenuItem({ className, ...props }) {
5750
5930
  ...props
5751
5931
  });
5752
5932
  }
5753
- const sidebarMenuButtonVariants = cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0", {
5933
+ const sidebarMenuButtonVariants = cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0", {
5754
5934
  variants: {
5755
5935
  variant: {
5756
5936
  default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
@@ -5855,6 +6035,83 @@ function SidebarMenuSubButton({ asChild = false, size = "md", isActive = false,
5855
6035
  });
5856
6036
  }
5857
6037
  //#endregion
6038
+ //#region src/form/validators.ts
6039
+ /**
6040
+ * A trimmed, non-empty string.
6041
+ *
6042
+ * Trimming happens before the emptiness check, so a field holding only spaces
6043
+ * fails rather than passing as "filled".
6044
+ */
6045
+ function requiredText({ requiredMessage = "This field is required." } = {}) {
6046
+ return z.string().trim().min(1, { message: requiredMessage });
6047
+ }
6048
+ /** An email address. Trimmed, and empty-tolerant when `optional`. */
6049
+ function emailField({ requiredMessage = "Email address is required.", message = "Enter a valid email address.", optional = false } = {}) {
6050
+ const base = z.string().trim();
6051
+ if (optional) return base.refine((value) => value === "" || z.string().email().safeParse(value).success, { message });
6052
+ return base.min(1, { message: requiredMessage }).email({ message });
6053
+ }
6054
+ /**
6055
+ * A US (NANP) phone number, counted in digits rather than matched by shape.
6056
+ *
6057
+ * Accepts anything `PhoneInput` can produce or a human can paste:
6058
+ * `(555) 123-4567`, `555-123-4567`, `5551234567`, `+1 555 123 4567`. What it
6059
+ * checks is that exactly ten digits are present, which is the only part that
6060
+ * carries meaning — `PhoneInput` already owns the presentation.
6061
+ */
6062
+ function usPhoneField({ requiredMessage = "Phone number is required.", message = "Enter a 10-digit US phone number.", required = false } = {}) {
6063
+ const base = z.string().trim();
6064
+ const hasTenDigits = (value) => parseUsPhoneDigits(value).length === 10;
6065
+ if (required) return base.min(1, { message: requiredMessage }).refine(hasTenDigits, { message });
6066
+ return base.refine((value) => value === "" || hasTenDigits(value), { message });
6067
+ }
6068
+ /** A value the browser did not post reads as empty, not as a type error. */
6069
+ const posted = (schema) => z.preprocess((value) => value ?? "", schema);
6070
+ /**
6071
+ * A password that only has to be present. Not trimmed: spaces are characters
6072
+ * in a password, and trimming would turn " " into "missing".
6073
+ */
6074
+ function presentPassword(requiredMessage) {
6075
+ return z.string().min(1, { message: requiredMessage });
6076
+ }
6077
+ /**
6078
+ * The default schema of `SignInBlock`: an email and a password that is
6079
+ * present. Whether the pair is right is the server's call, reported through
6080
+ * the block's `error`.
6081
+ */
6082
+ function signInSchema() {
6083
+ return z.object({
6084
+ email: posted(emailField()),
6085
+ password: posted(presentPassword("Password is required."))
6086
+ });
6087
+ }
6088
+ /**
6089
+ * The default schema of `SignUpBlock`: first and last name, an email, a
6090
+ * password of at least `minPasswordLength` characters, and a confirmation
6091
+ * that matches it. A site with stricter password rules (an identity
6092
+ * provider's policy, say) passes its own schema to the block.
6093
+ *
6094
+ * The match is reported on `confirmPassword` even while other fields are
6095
+ * still empty, because `validateOn="blur"` judges one field against the
6096
+ * whole form as the person leaves it.
6097
+ */
6098
+ function signUpSchema({ minPasswordLength = 8 } = {}) {
6099
+ return z.object({
6100
+ firstName: posted(requiredText({ requiredMessage: "First name is required." })),
6101
+ lastName: posted(requiredText({ requiredMessage: "Last name is required." })),
6102
+ email: posted(emailField()),
6103
+ password: posted(presentPassword("Password is required.").min(minPasswordLength, { message: `Use at least ${minPasswordLength} characters.` })),
6104
+ confirmPassword: posted(presentPassword("Confirm your password."))
6105
+ }).refine((data) => !data.confirmPassword || data.password === data.confirmPassword, {
6106
+ message: "Passwords do not match.",
6107
+ path: ["confirmPassword"],
6108
+ when: (payload) => {
6109
+ const value = payload.value;
6110
+ return typeof value?.password === "string" && typeof value?.confirmPassword === "string";
6111
+ }
6112
+ });
6113
+ }
6114
+ //#endregion
5858
6115
  //#region src/blocks/auth/social-providers.tsx
5859
6116
  const providerConfig = {
5860
6117
  google: {
@@ -5931,7 +6188,17 @@ function SocialProviders({ providers, onSocialLogin, loading, disabled, classNam
5931
6188
  });
5932
6189
  }
5933
6190
  //#endregion
6191
+ //#region src/blocks/auth/auth-link.ts
6192
+ /**
6193
+ * A link-styled control in the auth blocks. Underlined, not only colored:
6194
+ * `text-primary` can match the body text in some themes, and a link has to
6195
+ * read as a link without relying on color (WCAG 1.4.1).
6196
+ */
6197
+ const authLinkClasses = "text-primary underline underline-offset-4 hover:decoration-2";
6198
+ //#endregion
5934
6199
  //#region src/blocks/auth/sign-in-block.tsx
6200
+ const DEFAULT_SCHEMA$1 = signInSchema();
6201
+ const OTP_EMAIL_SCHEMA = z.object({ "otp-email": z.preprocess((value) => value ?? "", emailField()) });
5935
6202
  const AUTH_TABS = {
5936
6203
  PASSWORD: "password",
5937
6204
  OTP: "otp"
@@ -5972,9 +6239,8 @@ function OtpForm({ onOtpRequest, onOtpVerify, loading = false, disabled = false
5972
6239
  const [otpError, setOtpError] = React.useState();
5973
6240
  const isLoading = loading || otpLoading;
5974
6241
  const displayError = otpError;
5975
- const handleEmailSubmit = async (e) => {
5976
- e.preventDefault();
5977
- const emailValue = new FormData(e.currentTarget).get("otp-email");
6242
+ const handleEmailSubmit = async (data) => {
6243
+ const emailValue = String(data["otp-email"] ?? "");
5978
6244
  setOtpError(void 0);
5979
6245
  setOtpLoading(true);
5980
6246
  try {
@@ -6015,7 +6281,7 @@ function OtpForm({ onOtpRequest, onOtpVerify, loading = false, disabled = false
6015
6281
  }),
6016
6282
  /* @__PURE__ */ jsx("button", {
6017
6283
  type: "button",
6018
- className: "w-full text-center text-sm text-muted-foreground hover:text-foreground",
6284
+ className: cn("w-full text-center text-sm", authLinkClasses),
6019
6285
  onClick: () => {
6020
6286
  setStep("email");
6021
6287
  setOtpError(void 0);
@@ -6024,14 +6290,15 @@ function OtpForm({ onOtpRequest, onOtpVerify, loading = false, disabled = false
6024
6290
  })
6025
6291
  ]
6026
6292
  })] });
6027
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FormError, { message: displayError }), /* @__PURE__ */ jsxs("form", {
6293
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FormError, { message: displayError }), /* @__PURE__ */ jsxs(Form, {
6294
+ schema: OTP_EMAIL_SCHEMA,
6295
+ validateOn: "blur",
6028
6296
  onSubmit: handleEmailSubmit,
6029
6297
  className: "space-y-4",
6030
- children: [/* @__PURE__ */ jsx(InputGroup, {
6298
+ children: [/* @__PURE__ */ jsx(FormField, {
6299
+ name: "otp-email",
6031
6300
  label: "Email",
6032
- htmlFor: "otp-email",
6033
6301
  children: /* @__PURE__ */ jsx(Input, {
6034
- id: "otp-email",
6035
6302
  name: "otp-email",
6036
6303
  type: "email",
6037
6304
  placeholder: "name@example.com",
@@ -6049,7 +6316,22 @@ function OtpForm({ onOtpRequest, onOtpVerify, loading = false, disabled = false
6049
6316
  })]
6050
6317
  })] });
6051
6318
  }
6052
- function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProviders = [], loading = false, error, disabled = false, title = "Sign in", description = "Enter your credentials to access your account", signUpHref, onSignUp, className, children, onOtpRequest, onOtpVerify, otpLabel = "Email me a code", onTabChange }) {
6319
+ /**
6320
+ * Email and password sign-in in a card, with optional social providers and a
6321
+ * one-time-code tab. The fields are a `Form` with `FormField`s, so they get
6322
+ * what every library form gets: the error under the field, a check as the
6323
+ * person leaves a field (`validateOn="blur"`), the shake and focus on the
6324
+ * first wrong field after a failed submit, and a screen-reader summary.
6325
+ *
6326
+ * **Requires `zod` ^4.** The default schema (`signInSchema()` from
6327
+ * `@bison-lab/ui/validators`) is built with it. `zod` is a peer dependency of
6328
+ * `@bison-lab/ui`; install it in the app (`pnpm add zod`) even if the app
6329
+ * writes no schema of its own.
6330
+ *
6331
+ * Server results go in two props: `error` for a message that belongs to no
6332
+ * field (shown in the box above the form), `errors` for one that does.
6333
+ */
6334
+ function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProviders = [], loading = false, error, errors, schema = DEFAULT_SCHEMA$1, validateOn = "blur", validateUntouched = true, disabled = false, title = "Sign in", description = "Enter your credentials to access your account", signUpHref, onSignUp, className, children, onOtpRequest, onOtpVerify, otpLabel = "Email me a code", onTabChange }) {
6053
6335
  const [activeTab, setActiveTab] = React.useState(AUTH_TABS.PASSWORD);
6054
6336
  const otpEnabled = Boolean(onOtpRequest && onOtpVerify);
6055
6337
  const handleTabChange = React.useCallback((tab) => {
@@ -6065,23 +6347,24 @@ function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProvider
6065
6347
  }
6066
6348
  }, [error, activeTab]);
6067
6349
  const visibleError = errorTab === activeTab ? error : void 0;
6068
- const handleSubmit = async (e) => {
6069
- e.preventDefault();
6070
- const formData = new FormData(e.currentTarget);
6350
+ const handleSubmit = async (data) => {
6071
6351
  await onSubmit({
6072
- email: formData.get("email"),
6073
- password: formData.get("password")
6352
+ email: typeof data.email === "string" ? data.email : "",
6353
+ password: typeof data.password === "string" ? data.password : ""
6074
6354
  });
6075
6355
  };
6076
- const passwordForm = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FormError, { message: visibleError }), /* @__PURE__ */ jsxs("form", {
6356
+ const passwordForm = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FormError, { message: visibleError }), /* @__PURE__ */ jsxs(Form, {
6357
+ schema,
6358
+ validateOn,
6359
+ validateUntouched,
6360
+ errors,
6077
6361
  onSubmit: handleSubmit,
6078
6362
  className: "space-y-4",
6079
6363
  children: [
6080
- /* @__PURE__ */ jsx(InputGroup, {
6364
+ /* @__PURE__ */ jsx(FormField, {
6365
+ name: "email",
6081
6366
  label: "Email",
6082
- htmlFor: "email",
6083
6367
  children: /* @__PURE__ */ jsx(Input, {
6084
- id: "email",
6085
6368
  name: "email",
6086
6369
  type: "email",
6087
6370
  placeholder: "name@example.com",
@@ -6090,26 +6373,25 @@ function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProvider
6090
6373
  autoComplete: "email"
6091
6374
  })
6092
6375
  }),
6093
- /* @__PURE__ */ jsxs(InputGroup, {
6376
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(FormField, {
6377
+ name: "password",
6094
6378
  label: "Password",
6095
- htmlFor: "password",
6096
- children: [/* @__PURE__ */ jsx(PasswordInput, {
6097
- id: "password",
6379
+ children: /* @__PURE__ */ jsx(PasswordInput, {
6098
6380
  name: "password",
6099
6381
  required: true,
6100
6382
  disabled: loading || disabled,
6101
6383
  autoComplete: "current-password"
6102
- }), onForgotPassword && /* @__PURE__ */ jsx("div", {
6103
- className: "flex justify-end",
6104
- children: /* @__PURE__ */ jsx("button", {
6105
- type: "button",
6106
- onClick: onForgotPassword,
6107
- className: "text-sm text-primary hover:underline",
6108
- tabIndex: -1,
6109
- children: "Forgot password?"
6110
- })
6111
- })]
6112
- }),
6384
+ })
6385
+ }), onForgotPassword && /* @__PURE__ */ jsx("div", {
6386
+ className: "mt-2 flex justify-end",
6387
+ children: /* @__PURE__ */ jsx("button", {
6388
+ type: "button",
6389
+ onClick: onForgotPassword,
6390
+ className: cn("text-sm", "text-primary underline underline-offset-4 hover:decoration-2"),
6391
+ tabIndex: -1,
6392
+ children: "Forgot password?"
6393
+ })
6394
+ })] }),
6113
6395
  /* @__PURE__ */ jsx(Button, {
6114
6396
  type: "submit",
6115
6397
  variant: "default",
@@ -6146,11 +6428,11 @@ function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProvider
6146
6428
  onSignUp ? /* @__PURE__ */ jsx("button", {
6147
6429
  type: "button",
6148
6430
  onClick: onSignUp,
6149
- className: "text-primary hover:underline font-medium",
6431
+ className: cn("font-medium", "text-primary underline underline-offset-4 hover:decoration-2"),
6150
6432
  children: "Sign up"
6151
6433
  }) : /* @__PURE__ */ jsx("a", {
6152
6434
  href: signUpHref,
6153
- className: "text-primary hover:underline font-medium",
6435
+ className: cn("font-medium", "text-primary underline underline-offset-4 hover:decoration-2"),
6154
6436
  children: "Sign up"
6155
6437
  })
6156
6438
  ]
@@ -6208,17 +6490,32 @@ function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProvider
6208
6490
  }
6209
6491
  //#endregion
6210
6492
  //#region src/blocks/auth/sign-up-block.tsx
6211
- function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading = false, error, disabled = false, title = "Create an account", description = "Enter your details to get started", signInHref, onSignIn, termsHref = "#", privacyHref = "#", className }) {
6493
+ const DEFAULT_SCHEMA = signUpSchema();
6494
+ /**
6495
+ * Registration in a card: first and last name, email, password and its
6496
+ * confirmation, and a terms tick, with optional social providers. The fields
6497
+ * are a `Form` with `FormField`s, so errors sit under their field, a field is
6498
+ * checked as the person leaves it (`validateOn="blur"`), and a failed submit
6499
+ * shakes the wrong fields, focuses the first and announces the count.
6500
+ *
6501
+ * **Requires `zod` ^4.** The default schema (`signUpSchema()` from
6502
+ * `@bison-lab/ui/validators`) is built with it. `zod` is a peer dependency of
6503
+ * `@bison-lab/ui`; install it in the app (`pnpm add zod`) even if the app
6504
+ * writes no schema of its own.
6505
+ *
6506
+ * Server results go in two props: `error` for a message that belongs to no
6507
+ * field (shown in the box above the form), `errors` for one that does.
6508
+ */
6509
+ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading = false, error, errors, schema = DEFAULT_SCHEMA, validateOn = "blur", validateUntouched = true, disabled = false, title = "Create an account", description = "Enter your details to get started", signInHref, onSignIn, termsHref = "#", privacyHref = "#", className }) {
6212
6510
  const [termsAccepted, setTermsAccepted] = React.useState(false);
6213
- const handleSubmit = async (e) => {
6214
- e.preventDefault();
6215
- const formData = new FormData(e.currentTarget);
6511
+ const handleSubmit = async (data) => {
6512
+ const text = (key) => typeof data[key] === "string" ? data[key] : "";
6216
6513
  await onSubmit({
6217
- firstName: formData.get("firstName") ?? "",
6218
- lastName: formData.get("lastName") ?? "",
6219
- email: formData.get("email"),
6220
- password: formData.get("password"),
6221
- confirmPassword: formData.get("confirmPassword"),
6514
+ firstName: text("firstName"),
6515
+ lastName: text("lastName"),
6516
+ email: text("email"),
6517
+ password: text("password"),
6518
+ confirmPassword: text("confirmPassword"),
6222
6519
  termsAccepted
6223
6520
  });
6224
6521
  };
@@ -6249,15 +6546,18 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
6249
6546
  })]
6250
6547
  })] }),
6251
6548
  /* @__PURE__ */ jsx(FormError, { message: error }),
6252
- /* @__PURE__ */ jsxs("form", {
6549
+ /* @__PURE__ */ jsxs(Form, {
6550
+ schema,
6551
+ validateOn,
6552
+ validateUntouched,
6553
+ errors,
6253
6554
  onSubmit: handleSubmit,
6254
6555
  className: "space-y-4",
6255
6556
  children: [
6256
- /* @__PURE__ */ jsx(InputGroup, {
6557
+ /* @__PURE__ */ jsx(FormField, {
6558
+ name: "firstName",
6257
6559
  label: "First name",
6258
- htmlFor: "firstName",
6259
6560
  children: /* @__PURE__ */ jsx(Input, {
6260
- id: "firstName",
6261
6561
  name: "firstName",
6262
6562
  placeholder: "Jane",
6263
6563
  required: true,
@@ -6265,11 +6565,10 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
6265
6565
  autoComplete: "given-name"
6266
6566
  })
6267
6567
  }),
6268
- /* @__PURE__ */ jsx(InputGroup, {
6568
+ /* @__PURE__ */ jsx(FormField, {
6569
+ name: "lastName",
6269
6570
  label: "Last name",
6270
- htmlFor: "lastName",
6271
6571
  children: /* @__PURE__ */ jsx(Input, {
6272
- id: "lastName",
6273
6572
  name: "lastName",
6274
6573
  placeholder: "Doe",
6275
6574
  required: true,
@@ -6277,11 +6576,10 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
6277
6576
  autoComplete: "family-name"
6278
6577
  })
6279
6578
  }),
6280
- /* @__PURE__ */ jsx(InputGroup, {
6579
+ /* @__PURE__ */ jsx(FormField, {
6580
+ name: "email",
6281
6581
  label: "Email",
6282
- htmlFor: "email",
6283
6582
  children: /* @__PURE__ */ jsx(Input, {
6284
- id: "email",
6285
6583
  name: "email",
6286
6584
  type: "email",
6287
6585
  placeholder: "name@example.com",
@@ -6290,22 +6588,20 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
6290
6588
  autoComplete: "email"
6291
6589
  })
6292
6590
  }),
6293
- /* @__PURE__ */ jsx(InputGroup, {
6591
+ /* @__PURE__ */ jsx(FormField, {
6592
+ name: "password",
6294
6593
  label: "Password",
6295
- htmlFor: "password",
6296
6594
  children: /* @__PURE__ */ jsx(PasswordInput, {
6297
- id: "password",
6298
6595
  name: "password",
6299
6596
  required: true,
6300
6597
  disabled: loading || disabled,
6301
6598
  autoComplete: "new-password"
6302
6599
  })
6303
6600
  }),
6304
- /* @__PURE__ */ jsx(InputGroup, {
6601
+ /* @__PURE__ */ jsx(FormField, {
6602
+ name: "confirmPassword",
6305
6603
  label: "Confirm password",
6306
- htmlFor: "confirmPassword",
6307
6604
  children: /* @__PURE__ */ jsx(PasswordInput, {
6308
- id: "confirmPassword",
6309
6605
  name: "confirmPassword",
6310
6606
  required: true,
6311
6607
  disabled: loading || disabled,
@@ -6328,7 +6624,7 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
6328
6624
  " ",
6329
6625
  /* @__PURE__ */ jsx("a", {
6330
6626
  href: termsHref,
6331
- className: "text-primary hover:underline",
6627
+ className: authLinkClasses,
6332
6628
  children: "terms of service"
6333
6629
  }),
6334
6630
  " ",
@@ -6336,7 +6632,7 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
6336
6632
  " ",
6337
6633
  /* @__PURE__ */ jsx("a", {
6338
6634
  href: privacyHref,
6339
- className: "text-primary hover:underline",
6635
+ className: authLinkClasses,
6340
6636
  children: "privacy policy"
6341
6637
  })
6342
6638
  ]
@@ -6359,11 +6655,11 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
6359
6655
  onSignIn ? /* @__PURE__ */ jsx("button", {
6360
6656
  type: "button",
6361
6657
  onClick: onSignIn,
6362
- className: "text-primary hover:underline font-medium",
6658
+ className: cn("font-medium", "text-primary underline underline-offset-4 hover:decoration-2"),
6363
6659
  children: "Sign in"
6364
6660
  }) : /* @__PURE__ */ jsx("a", {
6365
6661
  href: signInHref,
6366
- className: "text-primary hover:underline font-medium",
6662
+ className: cn("font-medium", "text-primary underline underline-offset-4 hover:decoration-2"),
6367
6663
  children: "Sign in"
6368
6664
  })
6369
6665
  ]
@@ -6544,7 +6840,7 @@ function VerifyBlock({ onVerify, onResend, codeLength = 6, loading = false, erro
6544
6840
  onChange: (e) => handleChange(index, e.target.value),
6545
6841
  onKeyDown: (e) => handleKeyDown(index, e),
6546
6842
  disabled: loading || disabled,
6547
- className: "h-12 w-12 text-center text-lg font-semibold",
6843
+ className: "h-12 min-w-0 flex-1 max-w-12 text-center text-lg font-semibold",
6548
6844
  autoFocus: index === 0,
6549
6845
  "aria-label": `Digit ${index + 1} of ${codeLength}`
6550
6846
  }, index))
@@ -8294,37 +8590,6 @@ const VideoBlock = React.forwardRef(({ eyebrow, title, description, headingLevel
8294
8590
  });
8295
8591
  VideoBlock.displayName = "VideoBlock";
8296
8592
  //#endregion
8297
- //#region src/form/validators.ts
8298
- /**
8299
- * A trimmed, non-empty string.
8300
- *
8301
- * Trimming happens before the emptiness check, so a field holding only spaces
8302
- * fails rather than passing as "filled".
8303
- */
8304
- function requiredText({ requiredMessage = "This field is required." } = {}) {
8305
- return z.string().trim().min(1, { message: requiredMessage });
8306
- }
8307
- /** An email address. Trimmed, and empty-tolerant when `optional`. */
8308
- function emailField({ requiredMessage = "Email address is required.", message = "Enter a valid email address.", optional = false } = {}) {
8309
- const base = z.string().trim();
8310
- if (optional) return base.refine((value) => value === "" || z.string().email().safeParse(value).success, { message });
8311
- return base.min(1, { message: requiredMessage }).email({ message });
8312
- }
8313
- /**
8314
- * A US (NANP) phone number, counted in digits rather than matched by shape.
8315
- *
8316
- * Accepts anything `PhoneInput` can produce or a human can paste:
8317
- * `(555) 123-4567`, `555-123-4567`, `5551234567`, `+1 555 123 4567`. What it
8318
- * checks is that exactly ten digits are present, which is the only part that
8319
- * carries meaning — `PhoneInput` already owns the presentation.
8320
- */
8321
- function usPhoneField({ requiredMessage = "Phone number is required.", message = "Enter a 10-digit US phone number.", required = false } = {}) {
8322
- const base = z.string().trim();
8323
- const hasTenDigits = (value) => parseUsPhoneDigits(value).length === 10;
8324
- if (required) return base.min(1, { message: requiredMessage }).refine(hasTenDigits, { message });
8325
- return base.refine((value) => value === "" || hasTenDigits(value), { message });
8326
- }
8327
- //#endregion
8328
8593
  //#region src/blocks/marketing/inquiry-form-block.tsx
8329
8594
  const AUTOCOMPLETE = {
8330
8595
  name: "name",
@@ -8424,7 +8689,7 @@ function toValues(fields, data) {
8424
8689
  * `success` are the three states of a send; on success the form is replaced
8425
8690
  * by a status message that takes focus, so a screen reader hears the result.
8426
8691
  */
8427
- const InquiryFormBlock = React.forwardRef(({ eyebrow, title, description, headingLevel = "h2", fields, submitLabel = "Send", beforeSubmit, onSubmit, loading = false, error, errors, disabled = false, success = false, successTitle = "Thanks, your message is on its way", successMessage = "We will get back to you soon.", formMode = "native", register, trigger, containerClassName, className, ...props }, ref) => {
8692
+ const InquiryFormBlock = React.forwardRef(({ eyebrow, title, description, headingLevel = "h2", fields, submitLabel = "Send", beforeSubmit, onSubmit, loading = false, error, errors, disabled = false, success = false, successTitle = "Thanks, your message is on its way", successMessage = "We will get back to you soon.", formMode = "native", register, trigger, validateUntouched = true, containerClassName, className, ...props }, ref) => {
8428
8693
  const headingId = React.useId();
8429
8694
  const formId = React.useId();
8430
8695
  const statusRef = React.useRef(null);
@@ -8497,6 +8762,7 @@ const InquiryFormBlock = React.forwardRef(({ eyebrow, title, description, headin
8497
8762
  formMode,
8498
8763
  schema,
8499
8764
  validateOn: "blur",
8765
+ validateUntouched,
8500
8766
  errors: fieldErrors,
8501
8767
  onSubmit: handleSubmit,
8502
8768
  className: "flex flex-col gap-5",