@bison-lab/ui 3.40.0 → 3.41.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.d.mts +226 -14
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +265 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,9 +4,9 @@ import * as React from "react";
|
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { contrastLevelLabel, contrastVerdict, defaultFontWeights, densityPresets, deriveDarkPalette, deriveLightPalette, generateBrandScales, generateDestructiveScaleCSS, generateScaleCSS, motionPresets, radiusPresets, shadowPresets, typeScale, zIndexTokens } from "@bison-lab/tokens";
|
|
6
6
|
import { fontFaceCss, fontPreloads, fontStack, isFontId } from "@bison-lab/fonts";
|
|
7
|
-
import { AnimatePresence, motion } from "motion/react";
|
|
8
7
|
import { Accordion as Accordion$1, AlertDialog as AlertDialog$1, AspectRatio as AspectRatio$1, Avatar as Avatar$1, Checkbox as Checkbox$1, Collapsible as Collapsible$1, ContextMenu as ContextMenu$1, Dialog as Dialog$1, DropdownMenu as DropdownMenu$1, Label as Label$1, NavigationMenu as NavigationMenu$1, Popover as Popover$1, Progress as Progress$1, RadioGroup as RadioGroup$1, ScrollArea as ScrollArea$1, Select as Select$1, Separator as Separator$1, Slider as Slider$1, Slot, Switch as Switch$1, Tabs as Tabs$1, Tooltip as Tooltip$1, unstable_PasswordToggleField } from "radix-ui";
|
|
9
8
|
import { cva } from "class-variance-authority";
|
|
9
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
10
10
|
import { AlignCenter, AlignLeft, AlignRight, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, Bold, Calendar as Calendar$1, Camera, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, ChevronsLeft, ChevronsRight, ChevronsUpDown, Circle, CircleAlert, CircleCheck, CircleHelp, CircleX, Code, Eye, EyeOff, Facebook, FastForward, FileQuestion, Heading1, Heading2, Heading3, Image, Inbox, Info, Instagram, Italic, Link, Linkedin, List, ListOrdered, LoaderCircle, LogOut, Mail, MapPin, Menu, Minus, MoreHorizontal, MoveUpRight, PanelLeft, Pause, Pencil, Phone, Play, Plus, Quote, Redo, Search, Server, Settings2, ShieldAlert, SlidersHorizontal, Star, Strikethrough, TriangleAlert, Twitter, Underline, Undo, Unlink, Wrench, X, Youtube } from "lucide-react";
|
|
11
11
|
import { DayPicker, getDefaultClassNames } from "react-day-picker";
|
|
12
12
|
import useEmblaCarousel from "embla-carousel-react";
|
|
@@ -566,6 +566,102 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", errors:
|
|
|
566
566
|
});
|
|
567
567
|
Form.displayName = "Form";
|
|
568
568
|
//#endregion
|
|
569
|
+
//#region src/form/field-layout.ts
|
|
570
|
+
/**
|
|
571
|
+
* The vertical rhythm of a field, decided once.
|
|
572
|
+
*
|
|
573
|
+
* A field is a label, a control and some small print, and the three had drifted
|
|
574
|
+
* apart: `FormField` put 6px above and below its control, `InputGroup` put 8px
|
|
575
|
+
* of column gap on top of the `Label`'s own 8px margin, and `OutlinedField` put
|
|
576
|
+
* 6px under the shell. The same form built with two different wrappers did not
|
|
577
|
+
* look like the same form.
|
|
578
|
+
*
|
|
579
|
+
* These are margins on the parts rather than a `gap` on the column on purpose.
|
|
580
|
+
* A `gap` also separates the control slot's own children, so a `FormField
|
|
581
|
+
* as="group"` holding a stack of checkboxes would have every row pushed apart
|
|
582
|
+
* by the same value that spaces the label — the control slot has to keep
|
|
583
|
+
* whatever spacing its own contents ask for.
|
|
584
|
+
*
|
|
585
|
+
* Plain strings, no React: `Label` (a component) and `FieldNote` (a form part)
|
|
586
|
+
* both read them, and neither should have to import the other.
|
|
587
|
+
*/
|
|
588
|
+
/**
|
|
589
|
+
* The two scales, because one value does not read the same in both cases.
|
|
590
|
+
*
|
|
591
|
+
* A bordered input is a solid block, and a label 4px above it is clearly
|
|
592
|
+
* attached to it. A set of checkboxes is bare text and empty boxes with its own
|
|
593
|
+
* internal spacing, and a legend 4px above the first row lands almost on it —
|
|
594
|
+
* the label reads as part of that row rather than as the heading for the set.
|
|
595
|
+
* Set spacing is a step wider so the legend and the note sit outside the rows
|
|
596
|
+
* they bracket.
|
|
597
|
+
*
|
|
598
|
+
* Frozen, not merely `as const`. This is public, and `Label` closes over its
|
|
599
|
+
* value at module evaluation while `FieldNote` and the error paragraphs read it
|
|
600
|
+
* per render — so a consumer writing through the type would move some of the
|
|
601
|
+
* rhythm and leave the rest where it was.
|
|
602
|
+
*/
|
|
603
|
+
const fieldSpacing = Object.freeze({
|
|
604
|
+
control: Object.freeze({
|
|
605
|
+
label: "mb-1",
|
|
606
|
+
note: "mt-1"
|
|
607
|
+
}),
|
|
608
|
+
set: Object.freeze({
|
|
609
|
+
label: "mb-2",
|
|
610
|
+
note: "mt-2"
|
|
611
|
+
})
|
|
612
|
+
});
|
|
613
|
+
/** Space under a stacked field label, before a single bordered control. */
|
|
614
|
+
const FIELD_LABEL_SPACING = fieldSpacing.control.label;
|
|
615
|
+
/**
|
|
616
|
+
* Space above a line of small print — a hint, a note, an error — after a single
|
|
617
|
+
* bordered control. Carried by each line, so consecutive ones are spaced too.
|
|
618
|
+
*/
|
|
619
|
+
const FIELD_NOTE_SPACING = fieldSpacing.control.note;
|
|
620
|
+
//#endregion
|
|
621
|
+
//#region src/components/label.tsx
|
|
622
|
+
const labelVariants = cva("inline-block text-sm font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70", {
|
|
623
|
+
variants: { layout: {
|
|
624
|
+
stack: `${fieldSpacing.control.label} leading-none`,
|
|
625
|
+
inline: "mb-0 leading-snug"
|
|
626
|
+
} },
|
|
627
|
+
defaultVariants: { layout: "stack" }
|
|
628
|
+
});
|
|
629
|
+
/**
|
|
630
|
+
* The one label a field uses, whichever wrapper renders the field.
|
|
631
|
+
*
|
|
632
|
+
* `FormField`, `InputGroup` and a hand-composed field all reach for this, so
|
|
633
|
+
* they cannot drift on type, weight or the space under the label — which they
|
|
634
|
+
* had, each carrying its own copy of the classes.
|
|
635
|
+
*/
|
|
636
|
+
const Label = React.forwardRef(({ className, layout, as = "label", required, children, htmlFor, ...props }, ref) => {
|
|
637
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
638
|
+
children,
|
|
639
|
+
required && as === "legend" ? /* @__PURE__ */ jsx("span", {
|
|
640
|
+
className: "sr-only",
|
|
641
|
+
children: " (required)"
|
|
642
|
+
}) : null,
|
|
643
|
+
required ? /* @__PURE__ */ jsx("span", {
|
|
644
|
+
"aria-hidden": "true",
|
|
645
|
+
className: "ml-0.5 text-destructive",
|
|
646
|
+
children: "*"
|
|
647
|
+
}) : null
|
|
648
|
+
] });
|
|
649
|
+
if (as === "legend") return /* @__PURE__ */ jsx("legend", {
|
|
650
|
+
ref,
|
|
651
|
+
className: cn(labelVariants({ layout }), fieldSpacing.set.label, className),
|
|
652
|
+
...props,
|
|
653
|
+
children: content
|
|
654
|
+
});
|
|
655
|
+
return /* @__PURE__ */ jsx(Label$1.Root, {
|
|
656
|
+
ref,
|
|
657
|
+
htmlFor,
|
|
658
|
+
className: cn(labelVariants({ layout }), className),
|
|
659
|
+
...props,
|
|
660
|
+
children: content
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
Label.displayName = "Label";
|
|
664
|
+
//#endregion
|
|
569
665
|
//#region src/form/field-context.tsx
|
|
570
666
|
const FieldContext = React.createContext(void 0);
|
|
571
667
|
const FieldProvider = FieldContext.Provider;
|
|
@@ -574,6 +670,37 @@ function useField() {
|
|
|
574
670
|
return React.useContext(FieldContext);
|
|
575
671
|
}
|
|
576
672
|
/**
|
|
673
|
+
* Build one `aria-describedby` out of the field's ids and whatever the consumer
|
|
674
|
+
* already set.
|
|
675
|
+
*
|
|
676
|
+
* Deduplicates, and splits on whitespace first so an incoming multi-id value is
|
|
677
|
+
* handled. `FormField` renders its own `description` as a `FieldNote`, so the
|
|
678
|
+
* description id arrives twice — once as `descriptionId`, once through the
|
|
679
|
+
* registry — and repeating it makes a screen reader read the hint twice.
|
|
680
|
+
*/
|
|
681
|
+
function describedBy(...parts) {
|
|
682
|
+
const ids = parts.filter((part) => Boolean(part)).flatMap((part) => part.split(/\s+/)).filter(Boolean);
|
|
683
|
+
return Array.from(new Set(ids)).join(" ") || void 0;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* The note registry a field wrapper owns.
|
|
687
|
+
*
|
|
688
|
+
* Every wrapper that publishes a {@link FieldContextValue} calls this and
|
|
689
|
+
* passes both halves through the context: `noteIds` so the control's (or the
|
|
690
|
+
* `<fieldset>`'s) `aria-describedby` reaches each note, `registerNote` so the
|
|
691
|
+
* notes can get themselves in there.
|
|
692
|
+
*/
|
|
693
|
+
function useFieldNotes() {
|
|
694
|
+
const [noteIds, setNoteIds] = React.useState([]);
|
|
695
|
+
return {
|
|
696
|
+
noteIds,
|
|
697
|
+
registerNote: React.useCallback((id) => {
|
|
698
|
+
setNoteIds((ids) => ids.includes(id) ? ids : [...ids, id]);
|
|
699
|
+
return () => setNoteIds((ids) => ids.includes(id) ? ids.filter((other) => other !== id) : ids);
|
|
700
|
+
}, [])
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
577
704
|
* Merge the surrounding field's ARIA wiring into a control's own props.
|
|
578
705
|
*
|
|
579
706
|
* Call it in every control that accepts user input and spread the result onto
|
|
@@ -595,17 +722,12 @@ function useField() {
|
|
|
595
722
|
function useFieldControl(props) {
|
|
596
723
|
const field = useField();
|
|
597
724
|
if (!field || field.group) return props;
|
|
598
|
-
const describedBy = [
|
|
599
|
-
field.descriptionId,
|
|
600
|
-
field.errorId,
|
|
601
|
-
props["aria-describedby"]
|
|
602
|
-
].filter(Boolean).join(" ");
|
|
603
725
|
return {
|
|
604
726
|
...props,
|
|
605
727
|
id: field.controlId,
|
|
606
728
|
"aria-invalid": props["aria-invalid"] ?? (field.invalid || void 0),
|
|
607
729
|
"aria-required": props["aria-required"] ?? (field.required || void 0),
|
|
608
|
-
"aria-describedby": describedBy
|
|
730
|
+
"aria-describedby": describedBy(field.descriptionId, ...field.noteIds ?? [], field.errorId, props["aria-describedby"])
|
|
609
731
|
};
|
|
610
732
|
}
|
|
611
733
|
/**
|
|
@@ -622,11 +744,10 @@ function useFieldControl(props) {
|
|
|
622
744
|
function useFieldGroup() {
|
|
623
745
|
const field = useField();
|
|
624
746
|
if (!field) return {};
|
|
625
|
-
const describedBy = [field.descriptionId, field.errorId].filter(Boolean).join(" ");
|
|
626
747
|
return {
|
|
627
748
|
role: "group",
|
|
628
749
|
"aria-labelledby": field.labelId,
|
|
629
|
-
"aria-describedby": describedBy
|
|
750
|
+
"aria-describedby": describedBy(field.descriptionId, ...field.noteIds ?? [], field.errorId),
|
|
630
751
|
"aria-invalid": field.invalid || void 0,
|
|
631
752
|
"aria-required": field.required || void 0
|
|
632
753
|
};
|
|
@@ -669,6 +790,79 @@ function useFieldIds({ controlId, hasDescription, hasError }) {
|
|
|
669
790
|
};
|
|
670
791
|
}
|
|
671
792
|
//#endregion
|
|
793
|
+
//#region src/form/field-note.tsx
|
|
794
|
+
/**
|
|
795
|
+
* `md` pins the exact type of the hint paragraph `FormField` shipped, so
|
|
796
|
+
* adopting the component shifts nothing on any existing form. `sm` pairs the
|
|
797
|
+
* smaller step with a looser leading on purpose: a note a size down is the one
|
|
798
|
+
* that carries enough words to wrap, and 12px lines at a 1.0 leading collide.
|
|
799
|
+
*/
|
|
800
|
+
const noteSize = {
|
|
801
|
+
md: "text-sm leading-none",
|
|
802
|
+
sm: "text-xs leading-relaxed"
|
|
803
|
+
};
|
|
804
|
+
/**
|
|
805
|
+
* The small print under a control.
|
|
806
|
+
*
|
|
807
|
+
* A component rather than a `descriptionClassName`-style prop on `FormField`,
|
|
808
|
+
* because a note is a thing on the page with its own size and tone and it turns
|
|
809
|
+
* up in three places: inside a field, under a field group, and beside a control
|
|
810
|
+
* that is not in a field wrapper at all. A prop reaches only the one paragraph
|
|
811
|
+
* `FormField` already renders, which is why consumers ended up selecting on
|
|
812
|
+
* that paragraph's classes from the call site instead.
|
|
813
|
+
*
|
|
814
|
+
* Composed into a field wrapper it keeps everything the `description` prop
|
|
815
|
+
* does — it mints an id, registers it so the control (or, in a group, the
|
|
816
|
+
* `<fieldset>`) names it in `aria-describedby`, and renders nothing while the
|
|
817
|
+
* field is invalid so the error paragraph has the description to itself.
|
|
818
|
+
* Outside a wrapper it is just the paragraph, styled identically.
|
|
819
|
+
*/
|
|
820
|
+
const FieldNote = React.forwardRef(({ size = "md", spacing, className, id: idProp, ...props }, ref) => {
|
|
821
|
+
const field = useField();
|
|
822
|
+
const reactId = React.useId();
|
|
823
|
+
const id = idProp ?? (field ? `${reactId}-note` : void 0);
|
|
824
|
+
const registerNote = field?.registerNote;
|
|
825
|
+
const silenced = Boolean(field?.invalid);
|
|
826
|
+
React.useEffect(() => {
|
|
827
|
+
if (!registerNote || !id || silenced) return;
|
|
828
|
+
return registerNote(id);
|
|
829
|
+
}, [
|
|
830
|
+
registerNote,
|
|
831
|
+
id,
|
|
832
|
+
silenced
|
|
833
|
+
]);
|
|
834
|
+
if (silenced) return null;
|
|
835
|
+
return /* @__PURE__ */ jsx("p", {
|
|
836
|
+
ref,
|
|
837
|
+
id,
|
|
838
|
+
className: cn(fieldSpacing[spacing ?? field?.spacing ?? "control"].note, noteSize[size], "text-muted-foreground", className),
|
|
839
|
+
...props
|
|
840
|
+
});
|
|
841
|
+
});
|
|
842
|
+
FieldNote.displayName = "FieldNote";
|
|
843
|
+
/**
|
|
844
|
+
* Split a field wrapper's `children` into the control and the notes composed
|
|
845
|
+
* beside it.
|
|
846
|
+
*
|
|
847
|
+
* A note belongs in the wrapper's small-print region: under the control, after
|
|
848
|
+
* the `description` / `hint` the wrapper renders itself. Left where the
|
|
849
|
+
* consumer wrote it, it would sit BEFORE that paragraph on the page while
|
|
850
|
+
* `aria-describedby` reads it after — and inside `OutlinedField` it would land
|
|
851
|
+
* inside the bordered shell, drawn over the input.
|
|
852
|
+
*
|
|
853
|
+
* Only direct children are lifted. A note nested inside a consumer's own
|
|
854
|
+
* element stays where it is; it still wires itself up, but its place in the
|
|
855
|
+
* reading order is then the consumer's business.
|
|
856
|
+
*/
|
|
857
|
+
function splitFieldNotes(children) {
|
|
858
|
+
const isNote = (child) => React.isValidElement(child) && child.type === FieldNote;
|
|
859
|
+
const parts = React.Children.toArray(children);
|
|
860
|
+
return {
|
|
861
|
+
control: parts.filter((child) => !isNote(child)),
|
|
862
|
+
notes: parts.filter(isNote)
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
//#endregion
|
|
672
866
|
//#region src/components/outlined-field.tsx
|
|
673
867
|
/**
|
|
674
868
|
* Strips border / ring from nested form controls so the outer outlined shell
|
|
@@ -689,6 +883,7 @@ function detectControlKind(shell) {
|
|
|
689
883
|
const OutlinedField = React.forwardRef(({ label, htmlFor, error, errorVersion = 0, hint, required, className, children }, ref) => {
|
|
690
884
|
const fallbackId = React.useId();
|
|
691
885
|
const controlId = htmlFor ?? `${fallbackId}-control`;
|
|
886
|
+
const { noteIds, registerNote } = useFieldNotes();
|
|
692
887
|
const { descriptionId, errorId, labelId } = useFieldIds({
|
|
693
888
|
controlId,
|
|
694
889
|
hasDescription: Boolean(hint) && !error,
|
|
@@ -697,6 +892,8 @@ const OutlinedField = React.forwardRef(({ label, htmlFor, error, errorVersion =
|
|
|
697
892
|
const field = React.useMemo(() => ({
|
|
698
893
|
controlId,
|
|
699
894
|
descriptionId,
|
|
895
|
+
noteIds,
|
|
896
|
+
registerNote,
|
|
700
897
|
errorId,
|
|
701
898
|
labelId,
|
|
702
899
|
invalid: Boolean(error),
|
|
@@ -705,6 +902,8 @@ const OutlinedField = React.forwardRef(({ label, htmlFor, error, errorVersion =
|
|
|
705
902
|
}), [
|
|
706
903
|
controlId,
|
|
707
904
|
descriptionId,
|
|
905
|
+
noteIds,
|
|
906
|
+
registerNote,
|
|
708
907
|
errorId,
|
|
709
908
|
labelId,
|
|
710
909
|
error,
|
|
@@ -753,6 +952,7 @@ const OutlinedField = React.forwardRef(({ label, htmlFor, error, errorVersion =
|
|
|
753
952
|
if (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement) setHasValue(Boolean(t.value));
|
|
754
953
|
}, []);
|
|
755
954
|
const isTextarea = controlKind === "textarea";
|
|
955
|
+
const { control, notes } = splitFieldNotes(children);
|
|
756
956
|
const labelAnimate = isTextarea && !isFloated ? {
|
|
757
957
|
top: 20,
|
|
758
958
|
left: 12,
|
|
@@ -773,7 +973,7 @@ const OutlinedField = React.forwardRef(({ label, htmlFor, error, errorVersion =
|
|
|
773
973
|
value: field,
|
|
774
974
|
children: /* @__PURE__ */ jsxs("div", {
|
|
775
975
|
ref,
|
|
776
|
-
className: cn("flex flex-col
|
|
976
|
+
className: cn("flex flex-col", className),
|
|
777
977
|
children: [
|
|
778
978
|
/* @__PURE__ */ jsxs("div", {
|
|
779
979
|
ref: shellRef,
|
|
@@ -798,18 +998,18 @@ const OutlinedField = React.forwardRef(({ label, htmlFor, error, errorVersion =
|
|
|
798
998
|
}) : null]
|
|
799
999
|
}), /* @__PURE__ */ jsx("div", {
|
|
800
1000
|
className: cn("box-border flex min-h-0 min-w-0 flex-1", isTextarea ? "items-stretch pt-4 [&>*]:flex [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:flex-1" : "items-stretch [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:flex-1"),
|
|
801
|
-
children
|
|
1001
|
+
children: control
|
|
802
1002
|
})]
|
|
803
1003
|
}),
|
|
1004
|
+
!error && hint ? /* @__PURE__ */ jsx(FieldNote, {
|
|
1005
|
+
id: descriptionId,
|
|
1006
|
+
children: hint
|
|
1007
|
+
}) : null,
|
|
1008
|
+
notes,
|
|
804
1009
|
error ? /* @__PURE__ */ jsx("p", {
|
|
805
1010
|
id: errorId,
|
|
806
|
-
className: "text-sm leading-none text-destructive",
|
|
1011
|
+
className: cn(FIELD_NOTE_SPACING, "text-sm leading-none text-destructive"),
|
|
807
1012
|
children: error
|
|
808
|
-
}) : null,
|
|
809
|
-
!error && hint ? /* @__PURE__ */ jsx("p", {
|
|
810
|
-
id: descriptionId,
|
|
811
|
-
className: "text-sm leading-none text-muted-foreground",
|
|
812
|
-
children: hint
|
|
813
1013
|
}) : null
|
|
814
1014
|
]
|
|
815
1015
|
})
|
|
@@ -823,6 +1023,7 @@ function FormField({ name, label, description, required, labelLayout = "stack",
|
|
|
823
1023
|
const errorMessage = formCtx?.errors[name];
|
|
824
1024
|
const errorVersion = formCtx?.errorVersion ?? 0;
|
|
825
1025
|
const wrapRef = React.useRef(null);
|
|
1026
|
+
const { noteIds, registerNote } = useFieldNotes();
|
|
826
1027
|
const { controlId, descriptionId, errorId, labelId } = useFieldIds({
|
|
827
1028
|
controlId: name,
|
|
828
1029
|
hasDescription: Boolean(description) && !errorMessage,
|
|
@@ -832,14 +1033,19 @@ function FormField({ name, label, description, required, labelLayout = "stack",
|
|
|
832
1033
|
const field = React.useMemo(() => ({
|
|
833
1034
|
controlId,
|
|
834
1035
|
descriptionId,
|
|
1036
|
+
noteIds,
|
|
1037
|
+
registerNote,
|
|
835
1038
|
errorId,
|
|
836
1039
|
labelId: label ? labelId : void 0,
|
|
837
1040
|
invalid: Boolean(errorMessage),
|
|
838
1041
|
required: Boolean(required),
|
|
1042
|
+
spacing: isGroup ? "set" : "control",
|
|
839
1043
|
group: isGroup
|
|
840
1044
|
}), [
|
|
841
1045
|
controlId,
|
|
842
1046
|
descriptionId,
|
|
1047
|
+
noteIds,
|
|
1048
|
+
registerNote,
|
|
843
1049
|
errorId,
|
|
844
1050
|
labelId,
|
|
845
1051
|
label,
|
|
@@ -864,41 +1070,34 @@ function FormField({ name, label, description, required, labelLayout = "stack",
|
|
|
864
1070
|
className,
|
|
865
1071
|
children
|
|
866
1072
|
});
|
|
867
|
-
const describedBy =
|
|
868
|
-
const
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
}) : null;
|
|
1073
|
+
const describedBy$1 = describedBy(descriptionId, ...noteIds, errorId);
|
|
1074
|
+
const { control, notes } = splitFieldNotes(children);
|
|
1075
|
+
const messages = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1076
|
+
description && !errorMessage && /* @__PURE__ */ jsx(FieldNote, {
|
|
1077
|
+
id: descriptionId,
|
|
1078
|
+
children: description
|
|
1079
|
+
}),
|
|
1080
|
+
notes,
|
|
1081
|
+
errorMessage && /* @__PURE__ */ jsx("p", {
|
|
1082
|
+
id: errorId,
|
|
1083
|
+
className: cn(fieldSpacing[isGroup ? "set" : "control"].note, "text-sm leading-none text-destructive"),
|
|
1084
|
+
children: errorMessage
|
|
1085
|
+
})
|
|
1086
|
+
] });
|
|
882
1087
|
if (isGroup) return /* @__PURE__ */ jsx(FieldProvider, {
|
|
883
1088
|
value: field,
|
|
884
1089
|
children: /* @__PURE__ */ jsxs("fieldset", {
|
|
885
1090
|
ref: wrapRef,
|
|
886
1091
|
className: cn("flex flex-col", errorMessage && "bison-shake", className),
|
|
887
|
-
"aria-describedby": describedBy,
|
|
1092
|
+
"aria-describedby": describedBy$1,
|
|
888
1093
|
children: [
|
|
889
|
-
label && /* @__PURE__ */
|
|
1094
|
+
label && /* @__PURE__ */ jsx(Label, {
|
|
1095
|
+
as: "legend",
|
|
890
1096
|
id: labelId,
|
|
891
|
-
|
|
892
|
-
children:
|
|
893
|
-
label,
|
|
894
|
-
required ? /* @__PURE__ */ jsx("span", {
|
|
895
|
-
className: "sr-only",
|
|
896
|
-
children: " (required)"
|
|
897
|
-
}) : null,
|
|
898
|
-
requiredMark
|
|
899
|
-
]
|
|
1097
|
+
required,
|
|
1098
|
+
children: label
|
|
900
1099
|
}),
|
|
901
|
-
|
|
1100
|
+
control,
|
|
902
1101
|
messages
|
|
903
1102
|
]
|
|
904
1103
|
})
|
|
@@ -909,13 +1108,13 @@ function FormField({ name, label, description, required, labelLayout = "stack",
|
|
|
909
1108
|
ref: wrapRef,
|
|
910
1109
|
className: cn("flex flex-col", errorMessage && "bison-shake", className),
|
|
911
1110
|
children: [
|
|
912
|
-
label && /* @__PURE__ */
|
|
1111
|
+
label && /* @__PURE__ */ jsx(Label, {
|
|
913
1112
|
id: labelId,
|
|
914
1113
|
htmlFor: controlId,
|
|
915
|
-
|
|
916
|
-
children:
|
|
1114
|
+
required,
|
|
1115
|
+
children: label
|
|
917
1116
|
}),
|
|
918
|
-
|
|
1117
|
+
control,
|
|
919
1118
|
messages
|
|
920
1119
|
]
|
|
921
1120
|
})
|
|
@@ -1382,25 +1581,11 @@ const PhoneInput = React.forwardRef(function PhoneInput({ value: valueProp, defa
|
|
|
1382
1581
|
});
|
|
1383
1582
|
PhoneInput.displayName = "PhoneInput";
|
|
1384
1583
|
//#endregion
|
|
1385
|
-
//#region src/components/label.tsx
|
|
1386
|
-
const labelVariants = cva("inline-block text-sm font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70", {
|
|
1387
|
-
variants: { layout: {
|
|
1388
|
-
stack: "mb-2 leading-none",
|
|
1389
|
-
inline: "mb-0 leading-snug"
|
|
1390
|
-
} },
|
|
1391
|
-
defaultVariants: { layout: "stack" }
|
|
1392
|
-
});
|
|
1393
|
-
const Label = React.forwardRef(({ className, layout, ...props }, ref) => /* @__PURE__ */ jsx(Label$1.Root, {
|
|
1394
|
-
ref,
|
|
1395
|
-
className: cn(labelVariants({ layout }), className),
|
|
1396
|
-
...props
|
|
1397
|
-
}));
|
|
1398
|
-
Label.displayName = Label$1.Root.displayName;
|
|
1399
|
-
//#endregion
|
|
1400
1584
|
//#region src/components/input-group.tsx
|
|
1401
1585
|
const InputGroup = React.forwardRef(({ label, htmlFor, error, hint, required, labelLayout = "stack", className, children }, ref) => {
|
|
1402
1586
|
const fallbackId = React.useId();
|
|
1403
1587
|
const controlId = htmlFor ?? `${fallbackId}-control`;
|
|
1588
|
+
const { noteIds, registerNote } = useFieldNotes();
|
|
1404
1589
|
const { descriptionId, errorId, labelId } = useFieldIds({
|
|
1405
1590
|
controlId,
|
|
1406
1591
|
hasDescription: Boolean(hint) && !error,
|
|
@@ -1409,6 +1594,8 @@ const InputGroup = React.forwardRef(({ label, htmlFor, error, hint, required, la
|
|
|
1409
1594
|
const field = React.useMemo(() => ({
|
|
1410
1595
|
controlId,
|
|
1411
1596
|
descriptionId,
|
|
1597
|
+
noteIds,
|
|
1598
|
+
registerNote,
|
|
1412
1599
|
errorId,
|
|
1413
1600
|
labelId,
|
|
1414
1601
|
invalid: Boolean(error),
|
|
@@ -1417,11 +1604,14 @@ const InputGroup = React.forwardRef(({ label, htmlFor, error, hint, required, la
|
|
|
1417
1604
|
}), [
|
|
1418
1605
|
controlId,
|
|
1419
1606
|
descriptionId,
|
|
1607
|
+
noteIds,
|
|
1608
|
+
registerNote,
|
|
1420
1609
|
errorId,
|
|
1421
1610
|
labelId,
|
|
1422
1611
|
error,
|
|
1423
1612
|
required
|
|
1424
1613
|
]);
|
|
1614
|
+
const { control, notes } = splitFieldNotes(children);
|
|
1425
1615
|
if (labelLayout === "outlined") return /* @__PURE__ */ jsx(OutlinedField, {
|
|
1426
1616
|
ref,
|
|
1427
1617
|
label,
|
|
@@ -1436,27 +1626,24 @@ const InputGroup = React.forwardRef(({ label, htmlFor, error, hint, required, la
|
|
|
1436
1626
|
value: field,
|
|
1437
1627
|
children: /* @__PURE__ */ jsxs("div", {
|
|
1438
1628
|
ref,
|
|
1439
|
-
className: cn("flex flex-col
|
|
1629
|
+
className: cn("flex flex-col", className),
|
|
1440
1630
|
children: [
|
|
1441
|
-
/* @__PURE__ */
|
|
1631
|
+
/* @__PURE__ */ jsx(Label, {
|
|
1442
1632
|
id: labelId,
|
|
1443
1633
|
htmlFor: controlId,
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
className: "ml-0.5 text-destructive",
|
|
1447
|
-
children: "*"
|
|
1448
|
-
})]
|
|
1634
|
+
required,
|
|
1635
|
+
children: label
|
|
1449
1636
|
}),
|
|
1450
|
-
|
|
1637
|
+
control,
|
|
1638
|
+
!error && hint && /* @__PURE__ */ jsx(FieldNote, {
|
|
1639
|
+
id: descriptionId,
|
|
1640
|
+
children: hint
|
|
1641
|
+
}),
|
|
1642
|
+
notes,
|
|
1451
1643
|
error && /* @__PURE__ */ jsx("p", {
|
|
1452
1644
|
id: errorId,
|
|
1453
|
-
className: "text-sm text-destructive",
|
|
1645
|
+
className: cn(FIELD_NOTE_SPACING, "text-sm leading-none text-destructive"),
|
|
1454
1646
|
children: error
|
|
1455
|
-
}),
|
|
1456
|
-
!error && hint && /* @__PURE__ */ jsx("p", {
|
|
1457
|
-
id: descriptionId,
|
|
1458
|
-
className: "text-sm text-muted-foreground",
|
|
1459
|
-
children: hint
|
|
1460
1647
|
})
|
|
1461
1648
|
]
|
|
1462
1649
|
})
|
|
@@ -9488,6 +9675,6 @@ const ContrastStrip = React.forwardRef(({ checks, mode = "both", failingOnly = f
|
|
|
9488
9675
|
});
|
|
9489
9676
|
ContrastStrip.displayName = "ContrastStrip";
|
|
9490
9677
|
//#endregion
|
|
9491
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountSettingsBlock, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppSidebarBlock, AspectRatio, Avatar, AvatarFallback, AvatarImage, Badge, BisonProvider, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, CHROME_LOOK_CLASSES, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, CodeInput, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, ContrastStrip, CurrencyInput, DataTable, DataTableColumnHeader, DatePicker, DateRangePicker, DensityProvider, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditableTitle, EmptyStateBlock, FAQColumnsBlock, FieldGroupScope, FieldProvider, FilterButton, FloatingNavBlock, FooterBlock, ForgotPasswordBlock, Form, FormError, FormField, HeaderBlock, Input, InputGroup, JsonLd, Kbd, Label, LookSurface, MaintenanceBlock, MediaCard, MegaMenuPanel, NapBlock, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NotFoundBlock, NotificationSettingsBlock, OutlinedField, PageShell, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PasswordInput, PhoneInput, Popover, PopoverContent, PopoverTrigger, ProcessStepsBlock, ProfileSettingsBlock, Progress, ProgressBar, RadioGroup, RadioGroupItem, Rating, ResetPasswordBlock, ResourcesBlock, ReviewsBlock, RotatingBadge, SavedPing, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, ServerErrorBlock, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, ShowcasePanelsBlock, Sidebar, SidebarBlock, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, SignInBlock, SignUpBlock, Skeleton, Slider, SocialFeedBlock, SocialProviders, Spinner, StatsBandBlock, Stepper, StepperDescription, StepperIndicator, StepperItem, StepperLabel, StepperSeparator, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TestimonialCarousel, TestimonialMasonry, TextContent, TextEditor, Textarea, ThemeProvider, ThemeScope, ThemeShowcase, TimePicker, Toaster, Tooltip, TooltipArrow, TooltipContent, TooltipDescription, TooltipMedia, TooltipProvider, TooltipShortcut, TooltipTitle, TooltipTrigger, VerifyBlock, actionNegativeToneClasses, actionNeutralIconChromeClasses, actionNeutralToneClasses, actionPositiveToneClasses, alertVariants, avatarVariants, avgFooter, badgeVariants, buttonVariants, cn, countFooter, dateRangePresets, editableTitleVariants, filterChips, filterCount, formatUsPhone, megaMenuGridColumns, megaMenuToFloatingNavItems, megaMenuVariantsFromLooks, megaMenuVariantsFromTones, napRecordToJsonLd, navigationMenuTriggerStyle, newTabAttributes, outlinedFieldNestResetClasses, parseUsPhoneDigits, progressBarVariants, ratingVariants, renderPlainLink, spinnerVariants, stepperIndicatorVariants, stepperItemVariants, stepperLabelVariants, sumFooter, switchVariants, testimonialInitials, themeShowcaseSections, toColumnFilters, toast, toggleFilter, useCarousel, useDensity, useField, useFieldControl, useFieldGroup, useFieldIds, useFormContext, useHideOnScroll, useIsMobile, useScrollReveal, useSidebar, useTheme };
|
|
9678
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountSettingsBlock, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppSidebarBlock, AspectRatio, Avatar, AvatarFallback, AvatarImage, Badge, BisonProvider, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, CHROME_LOOK_CLASSES, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, CodeInput, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, ContrastStrip, CurrencyInput, DataTable, DataTableColumnHeader, DatePicker, DateRangePicker, DensityProvider, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditableTitle, EmptyStateBlock, FAQColumnsBlock, FIELD_LABEL_SPACING, FIELD_NOTE_SPACING, FieldGroupScope, FieldNote, FieldProvider, FilterButton, FloatingNavBlock, FooterBlock, ForgotPasswordBlock, Form, FormError, FormField, HeaderBlock, Input, InputGroup, JsonLd, Kbd, Label, LookSurface, MaintenanceBlock, MediaCard, MegaMenuPanel, NapBlock, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NotFoundBlock, NotificationSettingsBlock, OutlinedField, PageShell, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PasswordInput, PhoneInput, Popover, PopoverContent, PopoverTrigger, ProcessStepsBlock, ProfileSettingsBlock, Progress, ProgressBar, RadioGroup, RadioGroupItem, Rating, ResetPasswordBlock, ResourcesBlock, ReviewsBlock, RotatingBadge, SavedPing, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, ServerErrorBlock, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, ShowcasePanelsBlock, Sidebar, SidebarBlock, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, SignInBlock, SignUpBlock, Skeleton, Slider, SocialFeedBlock, SocialProviders, Spinner, StatsBandBlock, Stepper, StepperDescription, StepperIndicator, StepperItem, StepperLabel, StepperSeparator, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TestimonialCarousel, TestimonialMasonry, TextContent, TextEditor, Textarea, ThemeProvider, ThemeScope, ThemeShowcase, TimePicker, Toaster, Tooltip, TooltipArrow, TooltipContent, TooltipDescription, TooltipMedia, TooltipProvider, TooltipShortcut, TooltipTitle, TooltipTrigger, VerifyBlock, actionNegativeToneClasses, actionNeutralIconChromeClasses, actionNeutralToneClasses, actionPositiveToneClasses, alertVariants, avatarVariants, avgFooter, badgeVariants, buttonVariants, cn, countFooter, dateRangePresets, editableTitleVariants, describedBy as fieldDescribedBy, fieldSpacing, filterChips, filterCount, formatUsPhone, megaMenuGridColumns, megaMenuToFloatingNavItems, megaMenuVariantsFromLooks, megaMenuVariantsFromTones, napRecordToJsonLd, navigationMenuTriggerStyle, newTabAttributes, outlinedFieldNestResetClasses, parseUsPhoneDigits, progressBarVariants, ratingVariants, renderPlainLink, spinnerVariants, splitFieldNotes, stepperIndicatorVariants, stepperItemVariants, stepperLabelVariants, sumFooter, switchVariants, testimonialInitials, themeShowcaseSections, toColumnFilters, toast, toggleFilter, useCarousel, useDensity, useField, useFieldControl, useFieldGroup, useFieldIds, useFieldNotes, useFormContext, useHideOnScroll, useIsMobile, useScrollReveal, useSidebar, useTheme };
|
|
9492
9679
|
|
|
9493
9680
|
//# sourceMappingURL=index.mjs.map
|