@bison-lab/ui 3.43.0 → 4.0.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
@@ -2611,7 +2611,19 @@ const TextContent = React.forwardRef(({ content, className, ...props }, ref) =>
2611
2611
  });
2612
2612
  TextContent.displayName = "TextContent";
2613
2613
  //#endregion
2614
- //#region src/components/checkbox.tsx
2614
+ //#region src/lib/control-glyphs.tsx
2615
+ /**
2616
+ * The glyphs a selection control draws inside its indicator.
2617
+ *
2618
+ * They live here rather than beside one component because two of them draw
2619
+ * the same indicator: `Checkbox` is the box itself, and `Choicebox` in
2620
+ * multiple mode paints a checkbox-shaped indicator on the right of a card.
2621
+ * A tick that differed between the two would read as two products, which is
2622
+ * the same rule the admin kit states for its paired controls — so the shape
2623
+ * is defined once and imported by both.
2624
+ *
2625
+ * Both are `aria-hidden`: the control that owns them carries the state.
2626
+ */
2615
2627
  function CheckIcon({ className }) {
2616
2628
  return /* @__PURE__ */ jsx("svg", {
2617
2629
  viewBox: "0 0 12 12",
@@ -2643,6 +2655,8 @@ function IndeterminateIcon({ className }) {
2643
2655
  })
2644
2656
  });
2645
2657
  }
2658
+ //#endregion
2659
+ //#region src/components/checkbox.tsx
2646
2660
  const Checkbox = React.forwardRef(({ className, checked, ...props }, ref) => {
2647
2661
  const fieldProps = useFieldControl(props);
2648
2662
  return /* @__PURE__ */ jsx(Checkbox$1.Root, {
@@ -2658,6 +2672,189 @@ const Checkbox = React.forwardRef(({ className, checked, ...props }, ref) => {
2658
2672
  });
2659
2673
  Checkbox.displayName = Checkbox$1.Root.displayName;
2660
2674
  //#endregion
2675
+ //#region src/components/choicebox.tsx
2676
+ const ChoiceboxContext = React.createContext(void 0);
2677
+ function useChoicebox(component) {
2678
+ const context = React.useContext(ChoiceboxContext);
2679
+ if (!context) throw new Error(`${component} must be rendered inside a ChoiceboxGroup.`);
2680
+ return context;
2681
+ }
2682
+ const ChoiceboxGroup = React.forwardRef((props, ref) => {
2683
+ const { role: groupRole, ...groupAria } = useFieldGroup();
2684
+ if (props.multiple) {
2685
+ const { multiple: _multiple, className, value, defaultValue, onValueChange, name, disabled, ...rest } = props;
2686
+ return /* @__PURE__ */ jsx(MultipleChoiceboxGroup, {
2687
+ ...rest,
2688
+ ref,
2689
+ className,
2690
+ value,
2691
+ defaultValue,
2692
+ onValueChange,
2693
+ name,
2694
+ disabled,
2695
+ groupRole,
2696
+ groupAria
2697
+ });
2698
+ }
2699
+ const { multiple: _multiple, className, value, defaultValue, onValueChange, name, disabled, ...rest } = props;
2700
+ return /* @__PURE__ */ jsx(SingleChoiceboxGroup, {
2701
+ ...rest,
2702
+ ref,
2703
+ className,
2704
+ value,
2705
+ defaultValue,
2706
+ onValueChange,
2707
+ name,
2708
+ disabled,
2709
+ groupAria
2710
+ });
2711
+ });
2712
+ ChoiceboxGroup.displayName = "ChoiceboxGroup";
2713
+ const groupLayoutClasses = "grid gap-3";
2714
+ const SingleChoiceboxGroup = React.forwardRef(({ className, value, defaultValue, onValueChange, name, disabled, groupAria, children, ...rest }, ref) => {
2715
+ const [selected, setSelected] = React.useState(defaultValue);
2716
+ const current = value ?? selected;
2717
+ const handleChange = React.useCallback((next) => {
2718
+ if (value === void 0) setSelected(next);
2719
+ onValueChange?.(next);
2720
+ }, [onValueChange, value]);
2721
+ const context = React.useMemo(() => ({
2722
+ multiple: false,
2723
+ selected: current ? [current] : [],
2724
+ toggle: (next) => handleChange(next),
2725
+ disabled
2726
+ }), [
2727
+ current,
2728
+ disabled,
2729
+ handleChange
2730
+ ]);
2731
+ return /* @__PURE__ */ jsx(ChoiceboxContext.Provider, {
2732
+ value: context,
2733
+ children: /* @__PURE__ */ jsx(FieldGroupScope, { children: /* @__PURE__ */ jsx(RadioGroup$1.Root, {
2734
+ ...rest,
2735
+ ...groupAria,
2736
+ ref,
2737
+ className: cn(groupLayoutClasses, className),
2738
+ value: current,
2739
+ onValueChange: handleChange,
2740
+ name,
2741
+ disabled,
2742
+ children
2743
+ }) })
2744
+ });
2745
+ });
2746
+ SingleChoiceboxGroup.displayName = "SingleChoiceboxGroup";
2747
+ const MultipleChoiceboxGroup = React.forwardRef(({ className, value, defaultValue, onValueChange, name, disabled, groupRole, groupAria, children, ...rest }, ref) => {
2748
+ const [selected, setSelected] = React.useState(defaultValue ?? []);
2749
+ const current = value ?? selected;
2750
+ const toggle = React.useCallback((item, next) => {
2751
+ const updated = next ? current.includes(item) ? [...current] : [...current, item] : current.filter((entry) => entry !== item);
2752
+ if (value === void 0) setSelected(updated);
2753
+ onValueChange?.(updated);
2754
+ }, [
2755
+ current,
2756
+ onValueChange,
2757
+ value
2758
+ ]);
2759
+ const context = React.useMemo(() => ({
2760
+ multiple: true,
2761
+ selected: current,
2762
+ toggle,
2763
+ name,
2764
+ disabled
2765
+ }), [
2766
+ current,
2767
+ disabled,
2768
+ name,
2769
+ toggle
2770
+ ]);
2771
+ return /* @__PURE__ */ jsx(ChoiceboxContext.Provider, {
2772
+ value: context,
2773
+ children: /* @__PURE__ */ jsx(FieldGroupScope, { children: /* @__PURE__ */ jsx("div", {
2774
+ ...rest,
2775
+ ...groupAria,
2776
+ role: groupRole ?? "group",
2777
+ ref,
2778
+ className: cn(groupLayoutClasses, className),
2779
+ "data-disabled": disabled || void 0,
2780
+ children
2781
+ }) })
2782
+ });
2783
+ });
2784
+ MultipleChoiceboxGroup.displayName = "MultipleChoiceboxGroup";
2785
+ const choiceboxItemVariants = cva("group/choicebox relative flex w-full items-start gap-3 rounded-md border bg-background p-4 text-left transition-[color,background-color,border-color,box-shadow] duration-fast ease-default hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/35 focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-background data-[state=checked]:border-primary data-[state=checked]:bg-primary/5", {
2786
+ variants: { size: {
2787
+ sm: "gap-2.5 p-3",
2788
+ md: "gap-3 p-4",
2789
+ lg: "gap-4 p-5"
2790
+ } },
2791
+ defaultVariants: { size: "md" }
2792
+ });
2793
+ const ChoiceboxItem = React.forwardRef(({ value, title, description, icon, size, className, children, disabled, ...props }, ref) => {
2794
+ const { multiple, selected, toggle, name, disabled: groupDisabled } = useChoicebox("ChoiceboxItem");
2795
+ const checked = selected.includes(value);
2796
+ const isDisabled = disabled ?? groupDisabled;
2797
+ const body = /* @__PURE__ */ jsxs(Fragment, { children: [
2798
+ icon ? /* @__PURE__ */ jsx("span", {
2799
+ "data-choicebox-icon": "",
2800
+ "aria-hidden": true,
2801
+ className: "mt-0.5 inline-flex shrink-0 text-muted-foreground [&>svg]:size-5",
2802
+ children: icon
2803
+ }) : null,
2804
+ /* @__PURE__ */ jsxs("span", {
2805
+ className: "flex min-w-0 flex-1 flex-col gap-1",
2806
+ children: [
2807
+ title !== void 0 ? /* @__PURE__ */ jsx("span", {
2808
+ className: "block text-sm font-medium leading-none",
2809
+ children: title
2810
+ }) : null,
2811
+ description !== void 0 ? /* @__PURE__ */ jsx("span", {
2812
+ className: "block text-sm text-muted-foreground",
2813
+ children: description
2814
+ }) : null,
2815
+ children
2816
+ ]
2817
+ }),
2818
+ /* @__PURE__ */ jsx(ChoiceboxIndicator, {
2819
+ multiple,
2820
+ checked
2821
+ })
2822
+ ] });
2823
+ if (multiple) return /* @__PURE__ */ jsx(Checkbox$1.Root, {
2824
+ ...props,
2825
+ ref,
2826
+ className: cn(choiceboxItemVariants({ size }), className),
2827
+ checked,
2828
+ onCheckedChange: (next) => toggle(value, next === true),
2829
+ disabled: isDisabled,
2830
+ name,
2831
+ value,
2832
+ children: body
2833
+ });
2834
+ return /* @__PURE__ */ jsx(RadioGroup$1.Item, {
2835
+ ...props,
2836
+ ref,
2837
+ className: cn(choiceboxItemVariants({ size }), className),
2838
+ value,
2839
+ disabled: isDisabled,
2840
+ children: body
2841
+ });
2842
+ });
2843
+ ChoiceboxItem.displayName = "ChoiceboxItem";
2844
+ /**
2845
+ * The card's selection mark. Presentational by construction — see the note at
2846
+ * the top of this file — so it is `aria-hidden` and the card carries the state.
2847
+ */
2848
+ function ChoiceboxIndicator({ multiple, checked }) {
2849
+ return /* @__PURE__ */ jsx("span", {
2850
+ "data-choicebox-indicator": "",
2851
+ "data-state": checked ? "checked" : "unchecked",
2852
+ "aria-hidden": true,
2853
+ className: cn("mt-0.5 inline-flex size-4 shrink-0 items-center justify-center border border-primary bg-background text-primary transition-[background-color,border-color] duration-fast ease-default", multiple ? "rounded-[2px] data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground" : "rounded-full"),
2854
+ children: checked ? multiple ? /* @__PURE__ */ jsx(CheckIcon, { className: "h-[10px] w-[10px]" }) : /* @__PURE__ */ jsx("span", { className: "block size-2 rounded-full bg-current" }) : null
2855
+ });
2856
+ }
2857
+ //#endregion
2661
2858
  //#region src/components/radio-group.tsx
2662
2859
  const RadioGroup = React.forwardRef(({ className, ...props }, ref) => {
2663
2860
  const fieldProps = useFieldControl(props);
@@ -9718,6 +9915,6 @@ const ContrastStrip = React.forwardRef(({ checks, mode = "both", failingOnly = f
9718
9915
  });
9719
9916
  ContrastStrip.displayName = "ContrastStrip";
9720
9917
  //#endregion
9721
- 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 };
9918
+ 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, ChoiceboxGroup, ChoiceboxItem, 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 };
9722
9919
 
9723
9920
  //# sourceMappingURL=index.mjs.map