@bison-lab/ui 5.11.0 → 5.13.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/charts.d.mts +157 -4
- package/dist/charts.d.mts.map +1 -1
- package/dist/charts.mjs +751 -149
- package/dist/charts.mjs.map +1 -1
- package/dist/index.d.mts +53 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +288 -157
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
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);
|
|
@@ -548,13 +718,75 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", errors:
|
|
|
548
718
|
setFieldError,
|
|
549
719
|
clearFieldError
|
|
550
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]);
|
|
551
770
|
const handleBlur = React.useCallback((e) => {
|
|
552
771
|
onBlur?.(e);
|
|
553
|
-
|
|
554
|
-
|
|
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);
|
|
555
786
|
}, [
|
|
556
787
|
onBlur,
|
|
557
788
|
judgeBlur,
|
|
789
|
+
validateUntouched,
|
|
558
790
|
judgeField
|
|
559
791
|
]);
|
|
560
792
|
const handleChange = React.useCallback((e) => {
|
|
@@ -570,6 +802,7 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", errors:
|
|
|
570
802
|
]);
|
|
571
803
|
const handleSubmit = React.useCallback(async (e) => {
|
|
572
804
|
e.preventDefault();
|
|
805
|
+
heldRef.current.clear();
|
|
573
806
|
setIsSubmitting(true);
|
|
574
807
|
setErrors({});
|
|
575
808
|
const data = readForm(e.currentTarget);
|
|
@@ -742,134 +975,6 @@ const Label = React.forwardRef(({ className, layout, as = "label", required, chi
|
|
|
742
975
|
});
|
|
743
976
|
Label.displayName = "Label";
|
|
744
977
|
//#endregion
|
|
745
|
-
//#region src/form/field-context.tsx
|
|
746
|
-
const FieldContext = React.createContext(void 0);
|
|
747
|
-
const FieldProvider = FieldContext.Provider;
|
|
748
|
-
/** Read the surrounding field, if there is one. */
|
|
749
|
-
function useField() {
|
|
750
|
-
return React.useContext(FieldContext);
|
|
751
|
-
}
|
|
752
|
-
/**
|
|
753
|
-
* Build one `aria-describedby` out of the field's ids and whatever the consumer
|
|
754
|
-
* already set.
|
|
755
|
-
*
|
|
756
|
-
* Deduplicates, and splits on whitespace first so an incoming multi-id value is
|
|
757
|
-
* handled. `FormField` renders its own `description` as a `FieldNote`, so the
|
|
758
|
-
* description id arrives twice — once as `descriptionId`, once through the
|
|
759
|
-
* registry — and repeating it makes a screen reader read the hint twice.
|
|
760
|
-
*/
|
|
761
|
-
function describedBy(...parts) {
|
|
762
|
-
const ids = parts.filter((part) => Boolean(part)).flatMap((part) => part.split(/\s+/)).filter(Boolean);
|
|
763
|
-
return Array.from(new Set(ids)).join(" ") || void 0;
|
|
764
|
-
}
|
|
765
|
-
/**
|
|
766
|
-
* The note registry a field wrapper owns.
|
|
767
|
-
*
|
|
768
|
-
* Every wrapper that publishes a {@link FieldContextValue} calls this and
|
|
769
|
-
* passes both halves through the context: `noteIds` so the control's (or the
|
|
770
|
-
* `<fieldset>`'s) `aria-describedby` reaches each note, `registerNote` so the
|
|
771
|
-
* notes can get themselves in there.
|
|
772
|
-
*/
|
|
773
|
-
function useFieldNotes() {
|
|
774
|
-
const [noteIds, setNoteIds] = React.useState([]);
|
|
775
|
-
return {
|
|
776
|
-
noteIds,
|
|
777
|
-
registerNote: React.useCallback((id) => {
|
|
778
|
-
setNoteIds((ids) => ids.includes(id) ? ids : [...ids, id]);
|
|
779
|
-
return () => setNoteIds((ids) => ids.includes(id) ? ids.filter((other) => other !== id) : ids);
|
|
780
|
-
}, [])
|
|
781
|
-
};
|
|
782
|
-
}
|
|
783
|
-
/**
|
|
784
|
-
* Merge the surrounding field's ARIA wiring into a control's own props.
|
|
785
|
-
*
|
|
786
|
-
* Call it in every control that accepts user input and spread the result onto
|
|
787
|
-
* the DOM node.
|
|
788
|
-
*
|
|
789
|
-
* Inside a field the wrapper OWNS the control's `id`, and a consumer-supplied
|
|
790
|
-
* one is deliberately overridden. The wrapper has already rendered its
|
|
791
|
-
* `<label for>` pointing at the id it published, and it cannot see the child's
|
|
792
|
-
* props to follow it anywhere else — so honouring an override here would leave
|
|
793
|
-
* the label resolving to nothing, which is precisely the defect this context
|
|
794
|
-
* exists to remove. Set the id through the wrapper's `name` / `htmlFor`
|
|
795
|
-
* instead. `aria-invalid` and `aria-required` do defer to an explicit prop,
|
|
796
|
-
* and the field's description ids are APPENDED to any `aria-describedby` the
|
|
797
|
-
* consumer set rather than replacing it.
|
|
798
|
-
*
|
|
799
|
-
* Returns `props` unchanged when there is no field, or when the field is a
|
|
800
|
-
* group.
|
|
801
|
-
*/
|
|
802
|
-
function useFieldControl(props) {
|
|
803
|
-
const field = useField();
|
|
804
|
-
if (!field || field.group) return props;
|
|
805
|
-
return {
|
|
806
|
-
...props,
|
|
807
|
-
id: field.controlId,
|
|
808
|
-
"aria-invalid": props["aria-invalid"] ?? (field.invalid || void 0),
|
|
809
|
-
"aria-required": props["aria-required"] ?? (field.required || void 0),
|
|
810
|
-
"aria-describedby": describedBy(field.descriptionId, ...field.noteIds ?? [], field.errorId, props["aria-describedby"])
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
/**
|
|
814
|
-
* The composite-control counterpart to {@link useFieldControl}.
|
|
815
|
-
*
|
|
816
|
-
* `TimePicker` is three selects and `CodeInput` is six inputs; neither has a
|
|
817
|
-
* single element for the field's label to point at, and a `<label for>` naming
|
|
818
|
-
* a `<div>` names nothing at all. These wrap their children in a labelled
|
|
819
|
-
* `role="group"` instead, so the whole composite is announced once with its
|
|
820
|
-
* error and hint attached.
|
|
821
|
-
*
|
|
822
|
-
* Returns `{}` outside a field wrapper, leaving standalone usage untouched.
|
|
823
|
-
*/
|
|
824
|
-
function useFieldGroup() {
|
|
825
|
-
const field = useField();
|
|
826
|
-
if (!field) return {};
|
|
827
|
-
return {
|
|
828
|
-
role: "group",
|
|
829
|
-
"aria-labelledby": field.labelId,
|
|
830
|
-
"aria-describedby": describedBy(field.descriptionId, ...field.noteIds ?? [], field.errorId),
|
|
831
|
-
"aria-invalid": field.invalid || void 0,
|
|
832
|
-
"aria-required": field.required || void 0
|
|
833
|
-
};
|
|
834
|
-
}
|
|
835
|
-
/**
|
|
836
|
-
* Seals a composite control against the field it sits in.
|
|
837
|
-
*
|
|
838
|
-
* `CodeInput` renders six `<Input>`s and `TimePicker` renders three
|
|
839
|
-
* `<SelectTrigger>`s. Each of those calls {@link useFieldControl}, so without
|
|
840
|
-
* this they would every one of them adopt the SAME field id — six elements
|
|
841
|
-
* sharing `id="code"`, which is worse than the missing wiring this whole
|
|
842
|
-
* mechanism set out to fix. Re-providing the field in group mode turns the
|
|
843
|
-
* hook into a no-op for everything below, leaving the composite's own wrapper
|
|
844
|
-
* ({@link useFieldGroup}) as the single labelled thing.
|
|
845
|
-
*/
|
|
846
|
-
function FieldGroupScope({ children }) {
|
|
847
|
-
const field = useField();
|
|
848
|
-
return /* @__PURE__ */ jsx(FieldProvider, {
|
|
849
|
-
value: React.useMemo(() => field ? {
|
|
850
|
-
...field,
|
|
851
|
-
group: true
|
|
852
|
-
} : void 0, [field]),
|
|
853
|
-
children
|
|
854
|
-
});
|
|
855
|
-
}
|
|
856
|
-
/**
|
|
857
|
-
* Build the ids a wrapper publishes.
|
|
858
|
-
*
|
|
859
|
-
* `useId()` supplies the hint/error ids because nothing outside the wrapper
|
|
860
|
-
* references them, so uniqueness costs nothing. The control id stays
|
|
861
|
-
* caller-derived — see {@link FieldContextValue.controlId}.
|
|
862
|
-
*/
|
|
863
|
-
function useFieldIds({ controlId, hasDescription, hasError }) {
|
|
864
|
-
const reactId = React.useId();
|
|
865
|
-
return {
|
|
866
|
-
controlId,
|
|
867
|
-
descriptionId: hasDescription ? `${reactId}-description` : void 0,
|
|
868
|
-
errorId: hasError ? `${reactId}-error` : void 0,
|
|
869
|
-
labelId: `${reactId}-label`
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
//#endregion
|
|
873
978
|
//#region src/form/field-note.tsx
|
|
874
979
|
/**
|
|
875
980
|
* `md` pins the exact type of the hint paragraph `FormField` shipped, so
|
|
@@ -1053,6 +1158,7 @@ const OutlinedField = React.forwardRef(({ label, htmlFor, error, errorVersion =
|
|
|
1053
1158
|
value: field,
|
|
1054
1159
|
children: /* @__PURE__ */ jsxs("div", {
|
|
1055
1160
|
ref,
|
|
1161
|
+
...fieldBoxProps,
|
|
1056
1162
|
className: cn("flex flex-col", className),
|
|
1057
1163
|
children: [
|
|
1058
1164
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -1168,6 +1274,7 @@ function FormField({ name, id, label, description, required, labelLayout = "stac
|
|
|
1168
1274
|
value: field,
|
|
1169
1275
|
children: /* @__PURE__ */ jsxs("fieldset", {
|
|
1170
1276
|
ref: wrapRef,
|
|
1277
|
+
...fieldBoxProps,
|
|
1171
1278
|
className: cn("flex flex-col", errorMessage && "bison-shake", className),
|
|
1172
1279
|
"aria-describedby": describedBy$1,
|
|
1173
1280
|
children: [
|
|
@@ -1186,6 +1293,7 @@ function FormField({ name, id, label, description, required, labelLayout = "stac
|
|
|
1186
1293
|
value: field,
|
|
1187
1294
|
children: /* @__PURE__ */ jsxs("div", {
|
|
1188
1295
|
ref: wrapRef,
|
|
1296
|
+
...fieldBoxProps,
|
|
1189
1297
|
className: cn("flex flex-col", errorMessage && "bison-shake", className),
|
|
1190
1298
|
children: [
|
|
1191
1299
|
label && /* @__PURE__ */ jsx(Label, {
|
|
@@ -1205,7 +1313,7 @@ function FormField({ name, id, label, description, required, labelLayout = "stac
|
|
|
1205
1313
|
function FormError({ message, className }) {
|
|
1206
1314
|
if (!message) return null;
|
|
1207
1315
|
return /* @__PURE__ */ jsx("div", {
|
|
1208
|
-
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),
|
|
1209
1317
|
role: "alert",
|
|
1210
1318
|
children: message
|
|
1211
1319
|
});
|
|
@@ -1215,11 +1323,11 @@ function FormError({ message, className }) {
|
|
|
1215
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", {
|
|
1216
1324
|
variants: {
|
|
1217
1325
|
variant: {
|
|
1218
|
-
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",
|
|
1219
1327
|
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary-700 hover:shadow-md",
|
|
1220
1328
|
accent: "bg-brand-accent text-brand-accent-foreground hover:bg-brand-accent-600 hover:shadow-md",
|
|
1221
1329
|
highlight: "bg-highlight text-highlight-foreground hover:bg-highlight-600 hover:shadow-md",
|
|
1222
|
-
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",
|
|
1223
1331
|
outline: "border border-border-strong bg-background text-foreground hover:bg-accent hover:text-accent-foreground hover:shadow-sm",
|
|
1224
1332
|
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
1225
1333
|
actionNeutral: actionNeutralToneClasses,
|
|
@@ -1409,10 +1517,20 @@ const touchTargetClasses = "pointer-coarse:min-h-11 pointer-coarse:min-w-11";
|
|
|
1409
1517
|
* (dense tables, tight forms) stay pixel-identical. Includes `relative`; the
|
|
1410
1518
|
* host element must not be `overflow-hidden` or the pseudo is clipped.
|
|
1411
1519
|
*
|
|
1412
|
-
* Used by:
|
|
1520
|
+
* Used by: Switch, Slider thumb. Checkbox and Radio use `minHitAreaClasses`.
|
|
1413
1521
|
*/
|
|
1414
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";
|
|
1415
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
|
+
/**
|
|
1416
1534
|
* Menu surface chrome shared by floating menus and popovers:
|
|
1417
1535
|
* Select Content, DropdownMenu Content, ContextMenu Content, Command.
|
|
1418
1536
|
*
|
|
@@ -1450,9 +1568,17 @@ const floatingAnimationClasses = "origin-[var(--radix-popper-transform-origin)]
|
|
|
1450
1568
|
*/
|
|
1451
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";
|
|
1452
1570
|
/**
|
|
1453
|
-
* 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.
|
|
1454
1580
|
*/
|
|
1455
|
-
const overlayScrimClasses = "fixed inset-0 z-[var(--z-modal-backdrop)] bg-
|
|
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";
|
|
1456
1582
|
/**
|
|
1457
1583
|
* Centered modal content positioning + chrome (Dialog, AlertDialog).
|
|
1458
1584
|
* Sheet has its own side-anchored variants in `sheet.tsx`.
|
|
@@ -1474,16 +1600,18 @@ Input.displayName = "Input";
|
|
|
1474
1600
|
//#region src/components/password-input.tsx
|
|
1475
1601
|
const PasswordInput = React.forwardRef(({ className, toggleLabel = "Show or hide password", size = "md", ...props }, ref) => {
|
|
1476
1602
|
const fieldProps = useFieldControl(props);
|
|
1477
|
-
const
|
|
1603
|
+
const autoId = React.useId();
|
|
1604
|
+
const inputId = fieldProps.id ?? autoId;
|
|
1478
1605
|
return /* @__PURE__ */ jsx(unstable_PasswordToggleField.Root, { children: /* @__PURE__ */ jsxs("div", {
|
|
1479
1606
|
className: "relative",
|
|
1480
1607
|
children: [/* @__PURE__ */ jsx(unstable_PasswordToggleField.Input, {
|
|
1481
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),
|
|
1482
1609
|
ref,
|
|
1483
|
-
...fieldProps
|
|
1610
|
+
...fieldProps,
|
|
1611
|
+
id: inputId
|
|
1484
1612
|
}), /* @__PURE__ */ jsx(unstable_PasswordToggleField.Toggle, {
|
|
1485
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",
|
|
1486
|
-
id:
|
|
1614
|
+
id: `${inputId}-toggle`,
|
|
1487
1615
|
disabled: props.disabled,
|
|
1488
1616
|
"aria-label": toggleLabel,
|
|
1489
1617
|
children: /* @__PURE__ */ jsx(unstable_PasswordToggleField.Icon, {
|
|
@@ -1548,7 +1676,7 @@ const CodeInput = React.forwardRef(({ length = 6, onComplete, onChange, loading
|
|
|
1548
1676
|
onChange: (e) => handleChange(index, e.target.value),
|
|
1549
1677
|
onKeyDown: (e) => handleKeyDown(index, e),
|
|
1550
1678
|
disabled: loading || disabled,
|
|
1551
|
-
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",
|
|
1552
1680
|
autoFocus: index === 0,
|
|
1553
1681
|
"aria-label": digitLabel(index + 1, length)
|
|
1554
1682
|
}, index)) })
|
|
@@ -1717,6 +1845,7 @@ const InputGroup = React.forwardRef(({ label, htmlFor, error, hint, required, la
|
|
|
1717
1845
|
value: field,
|
|
1718
1846
|
children: /* @__PURE__ */ jsxs("div", {
|
|
1719
1847
|
ref,
|
|
1848
|
+
...fieldBoxProps,
|
|
1720
1849
|
className: cn("flex flex-col", className),
|
|
1721
1850
|
children: [
|
|
1722
1851
|
/* @__PURE__ */ jsx(Label, {
|
|
@@ -2778,7 +2907,7 @@ const Checkbox = React.forwardRef(({ className, checked, ...props }, ref) => {
|
|
|
2778
2907
|
return /* @__PURE__ */ jsx(Checkbox$1.Root, {
|
|
2779
2908
|
ref,
|
|
2780
2909
|
checked,
|
|
2781
|
-
className: cn("peer h-4 w-4 shrink-0 cursor-pointer rounded-[2px] border border-
|
|
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),
|
|
2782
2911
|
...fieldProps,
|
|
2783
2912
|
children: /* @__PURE__ */ jsx(Checkbox$1.Indicator, {
|
|
2784
2913
|
className: cn("flex h-full w-full items-center justify-center text-current"),
|
|
@@ -2983,7 +3112,7 @@ const RadioGroup = React.forwardRef(({ className, ...props }, ref) => {
|
|
|
2983
3112
|
RadioGroup.displayName = RadioGroup$1.Root.displayName;
|
|
2984
3113
|
const RadioGroupItem = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(RadioGroup$1.Item, {
|
|
2985
3114
|
ref,
|
|
2986
|
-
className: cn("inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-
|
|
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),
|
|
2987
3116
|
...props,
|
|
2988
3117
|
children: /* @__PURE__ */ jsx(RadioGroup$1.Indicator, {
|
|
2989
3118
|
className: "flex h-full w-full items-center justify-center",
|
|
@@ -3190,7 +3319,7 @@ const badgeVariants = cva("inline-flex h-6 items-center justify-center rounded-m
|
|
|
3190
3319
|
secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary-700",
|
|
3191
3320
|
accent: "border-transparent bg-brand-accent text-brand-accent-foreground hover:bg-brand-accent-600",
|
|
3192
3321
|
highlight: "border-transparent bg-highlight text-highlight-foreground hover:bg-highlight-600",
|
|
3193
|
-
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%)))]",
|
|
3194
3323
|
outline: "text-foreground",
|
|
3195
3324
|
success: tintToneSuccess,
|
|
3196
3325
|
warning: tintToneWarning,
|
|
@@ -3801,7 +3930,7 @@ const FilterButton = React.forwardRef(({ groups, value, onValueChange, apply = f
|
|
|
3801
3930
|
},
|
|
3802
3931
|
children: clearLabel
|
|
3803
3932
|
}), apply ? /* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
3804
|
-
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",
|
|
3805
3934
|
onSelect: () => onValueChange(draft),
|
|
3806
3935
|
children: applyLabel
|
|
3807
3936
|
}) : null]
|
|
@@ -3818,7 +3947,7 @@ function Toaster({ position = "bottom-right", richColors = true, closeButton = t
|
|
|
3818
3947
|
richColors,
|
|
3819
3948
|
closeButton,
|
|
3820
3949
|
toastOptions: { classNames: {
|
|
3821
|
-
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]!",
|
|
3822
3951
|
description: "text-muted-foreground",
|
|
3823
3952
|
actionButton: "bg-primary text-primary-foreground",
|
|
3824
3953
|
cancelButton: "bg-muted text-muted-foreground"
|
|
@@ -4415,7 +4544,7 @@ function DataTableColumnHeader({ column, title, className }) {
|
|
|
4415
4544
|
size: "sm",
|
|
4416
4545
|
className: cn("-ml-3 h-8 data-[state=open]:bg-accent", className),
|
|
4417
4546
|
onClick: () => column.toggleSorting(sorted === "asc"),
|
|
4418
|
-
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
|
|
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" })]
|
|
4419
4548
|
});
|
|
4420
4549
|
}
|
|
4421
4550
|
DataTableColumnHeader.displayName = "DataTableColumnHeader";
|
|
@@ -5660,10 +5789,10 @@ function Sidebar({ side = "left", variant = "sidebar", collapsible = "offcanvas"
|
|
|
5660
5789
|
"data-slot": "sidebar",
|
|
5661
5790
|
children: [/* @__PURE__ */ jsx("div", {
|
|
5662
5791
|
"data-slot": "sidebar-gap",
|
|
5663
|
-
className: cn("relative w-(--sidebar-width) bg-transparent
|
|
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)")
|
|
5664
5793
|
}), /* @__PURE__ */ jsx("div", {
|
|
5665
5794
|
"data-slot": "sidebar-container",
|
|
5666
|
-
className: cn("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-
|
|
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),
|
|
5667
5796
|
...props,
|
|
5668
5797
|
children: /* @__PURE__ */ jsx("div", {
|
|
5669
5798
|
"data-sidebar": "sidebar",
|
|
@@ -5702,7 +5831,7 @@ function SidebarRail({ className, ...props }) {
|
|
|
5702
5831
|
tabIndex: -1,
|
|
5703
5832
|
onClick: toggleSidebar,
|
|
5704
5833
|
title: "Toggle Sidebar",
|
|
5705
|
-
className: cn("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-
|
|
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),
|
|
5706
5835
|
...props
|
|
5707
5836
|
});
|
|
5708
5837
|
}
|
|
@@ -5765,7 +5894,7 @@ function SidebarGroupLabel({ className, asChild = false, ...props }) {
|
|
|
5765
5894
|
return /* @__PURE__ */ jsx(asChild ? Slot.Slot : "div", {
|
|
5766
5895
|
"data-slot": "sidebar-group-label",
|
|
5767
5896
|
"data-sidebar": "group-label",
|
|
5768
|
-
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-
|
|
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),
|
|
5769
5898
|
...props
|
|
5770
5899
|
});
|
|
5771
5900
|
}
|
|
@@ -5801,7 +5930,7 @@ function SidebarMenuItem({ className, ...props }) {
|
|
|
5801
5930
|
...props
|
|
5802
5931
|
});
|
|
5803
5932
|
}
|
|
5804
|
-
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
|
|
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", {
|
|
5805
5934
|
variants: {
|
|
5806
5935
|
variant: {
|
|
5807
5936
|
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
@@ -6202,7 +6331,7 @@ function OtpForm({ onOtpRequest, onOtpVerify, loading = false, disabled = false
|
|
|
6202
6331
|
* Server results go in two props: `error` for a message that belongs to no
|
|
6203
6332
|
* field (shown in the box above the form), `errors` for one that does.
|
|
6204
6333
|
*/
|
|
6205
|
-
function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProviders = [], loading = false, error, errors, schema = DEFAULT_SCHEMA$1, validateOn = "blur", 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 }) {
|
|
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 }) {
|
|
6206
6335
|
const [activeTab, setActiveTab] = React.useState(AUTH_TABS.PASSWORD);
|
|
6207
6336
|
const otpEnabled = Boolean(onOtpRequest && onOtpVerify);
|
|
6208
6337
|
const handleTabChange = React.useCallback((tab) => {
|
|
@@ -6227,6 +6356,7 @@ function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProvider
|
|
|
6227
6356
|
const passwordForm = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FormError, { message: visibleError }), /* @__PURE__ */ jsxs(Form, {
|
|
6228
6357
|
schema,
|
|
6229
6358
|
validateOn,
|
|
6359
|
+
validateUntouched,
|
|
6230
6360
|
errors,
|
|
6231
6361
|
onSubmit: handleSubmit,
|
|
6232
6362
|
className: "space-y-4",
|
|
@@ -6258,7 +6388,6 @@ function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProvider
|
|
|
6258
6388
|
type: "button",
|
|
6259
6389
|
onClick: onForgotPassword,
|
|
6260
6390
|
className: cn("text-sm", "text-primary underline underline-offset-4 hover:decoration-2"),
|
|
6261
|
-
tabIndex: -1,
|
|
6262
6391
|
children: "Forgot password?"
|
|
6263
6392
|
})
|
|
6264
6393
|
})] }),
|
|
@@ -6376,7 +6505,7 @@ const DEFAULT_SCHEMA = signUpSchema();
|
|
|
6376
6505
|
* Server results go in two props: `error` for a message that belongs to no
|
|
6377
6506
|
* field (shown in the box above the form), `errors` for one that does.
|
|
6378
6507
|
*/
|
|
6379
|
-
function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading = false, error, errors, schema = DEFAULT_SCHEMA, validateOn = "blur", disabled = false, title = "Create an account", description = "Enter your details to get started", signInHref, onSignIn, termsHref = "#", privacyHref = "#", className }) {
|
|
6508
|
+
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 }) {
|
|
6380
6509
|
const [termsAccepted, setTermsAccepted] = React.useState(false);
|
|
6381
6510
|
const handleSubmit = async (data) => {
|
|
6382
6511
|
const text = (key) => typeof data[key] === "string" ? data[key] : "";
|
|
@@ -6419,6 +6548,7 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
|
|
|
6419
6548
|
/* @__PURE__ */ jsxs(Form, {
|
|
6420
6549
|
schema,
|
|
6421
6550
|
validateOn,
|
|
6551
|
+
validateUntouched,
|
|
6422
6552
|
errors,
|
|
6423
6553
|
onSubmit: handleSubmit,
|
|
6424
6554
|
className: "space-y-4",
|
|
@@ -6709,7 +6839,7 @@ function VerifyBlock({ onVerify, onResend, codeLength = 6, loading = false, erro
|
|
|
6709
6839
|
onChange: (e) => handleChange(index, e.target.value),
|
|
6710
6840
|
onKeyDown: (e) => handleKeyDown(index, e),
|
|
6711
6841
|
disabled: loading || disabled,
|
|
6712
|
-
className: "h-12 w-12 text-center text-lg font-semibold",
|
|
6842
|
+
className: "h-12 min-w-0 flex-1 max-w-12 text-center text-lg font-semibold",
|
|
6713
6843
|
autoFocus: index === 0,
|
|
6714
6844
|
"aria-label": `Digit ${index + 1} of ${codeLength}`
|
|
6715
6845
|
}, index))
|
|
@@ -8558,7 +8688,7 @@ function toValues(fields, data) {
|
|
|
8558
8688
|
* `success` are the three states of a send; on success the form is replaced
|
|
8559
8689
|
* by a status message that takes focus, so a screen reader hears the result.
|
|
8560
8690
|
*/
|
|
8561
|
-
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) => {
|
|
8691
|
+
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) => {
|
|
8562
8692
|
const headingId = React.useId();
|
|
8563
8693
|
const formId = React.useId();
|
|
8564
8694
|
const statusRef = React.useRef(null);
|
|
@@ -8631,6 +8761,7 @@ const InquiryFormBlock = React.forwardRef(({ eyebrow, title, description, headin
|
|
|
8631
8761
|
formMode,
|
|
8632
8762
|
schema,
|
|
8633
8763
|
validateOn: "blur",
|
|
8764
|
+
validateUntouched,
|
|
8634
8765
|
errors: fieldErrors,
|
|
8635
8766
|
onSubmit: handleSubmit,
|
|
8636
8767
|
className: "flex flex-col gap-5",
|