@brightlocal/ui-components 0.1.3 → 0.2.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.
Files changed (166) hide show
  1. package/README.md +2 -1
  2. package/dist/accordion.cjs +1 -1
  3. package/dist/accordion.js +1 -1
  4. package/dist/alert.cjs +1 -1
  5. package/dist/alert.js +1 -1
  6. package/dist/blocks/data-table.cjs +1 -1
  7. package/dist/blocks/data-table.js +1 -1
  8. package/dist/blocks/sidebar.cjs +1 -1
  9. package/dist/blocks/sidebar.d.ts +37 -306
  10. package/dist/blocks/sidebar.d.ts.map +1 -1
  11. package/dist/blocks/sidebar.js +392 -489
  12. package/dist/breadcrumb.cjs +1 -1
  13. package/dist/breadcrumb.js +1 -1
  14. package/dist/button.cjs +1 -1
  15. package/dist/button.js +1 -1
  16. package/dist/calendar.cjs +1 -1
  17. package/dist/calendar.d.ts +4 -1
  18. package/dist/calendar.d.ts.map +1 -1
  19. package/dist/calendar.js +33 -33
  20. package/dist/centred-layout.cjs +1 -1
  21. package/dist/centred-layout.d.ts +5 -18
  22. package/dist/centred-layout.d.ts.map +1 -1
  23. package/dist/centred-layout.js +21 -23
  24. package/dist/checkbox.cjs +1 -1
  25. package/dist/checkbox.d.ts.map +1 -1
  26. package/dist/checkbox.js +19 -19
  27. package/dist/combobox.cjs +1 -1
  28. package/dist/combobox.d.ts +75 -67
  29. package/dist/combobox.d.ts.map +1 -1
  30. package/dist/combobox.js +241 -194
  31. package/dist/command.cjs +1 -1
  32. package/dist/command.js +1 -1
  33. package/dist/context-menu.cjs +1 -1
  34. package/dist/context-menu.js +1 -1
  35. package/dist/date-picker.cjs +1 -1
  36. package/dist/date-picker.js +1 -1
  37. package/dist/dialog.cjs +1 -1
  38. package/dist/dialog.js +1 -1
  39. package/dist/dropdown-menu.cjs +1 -1
  40. package/dist/dropdown-menu.js +1 -1
  41. package/dist/field.cjs +1 -1
  42. package/dist/field.d.ts +3 -0
  43. package/dist/field.d.ts.map +1 -1
  44. package/dist/field.js +5 -4
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.js +361 -366
  47. package/dist/input-group.cjs +1 -1
  48. package/dist/input-group.d.ts +5 -0
  49. package/dist/input-group.d.ts.map +1 -1
  50. package/dist/input-group.js +47 -39
  51. package/dist/input-otp.cjs +1 -1
  52. package/dist/input-otp.d.ts +6 -0
  53. package/dist/input-otp.d.ts.map +1 -1
  54. package/dist/input-otp.js +79 -76
  55. package/dist/input-password.cjs +1 -1
  56. package/dist/input-password.d.ts +4 -0
  57. package/dist/input-password.d.ts.map +1 -1
  58. package/dist/input-password.js +32 -31
  59. package/dist/input.cjs +1 -1
  60. package/dist/input.d.ts +4 -0
  61. package/dist/input.d.ts.map +1 -1
  62. package/dist/input.js +26 -24
  63. package/dist/link.cjs +1 -1
  64. package/dist/link.js +1 -1
  65. package/dist/logo.cjs +1 -1
  66. package/dist/logo.d.ts +6 -4
  67. package/dist/logo.d.ts.map +1 -1
  68. package/dist/logo.js +17 -20
  69. package/dist/menubar.cjs +1 -1
  70. package/dist/menubar.d.ts +3 -0
  71. package/dist/menubar.d.ts.map +1 -1
  72. package/dist/menubar.js +31 -30
  73. package/dist/navigation-menu.cjs +1 -1
  74. package/dist/navigation-menu.d.ts +6 -54
  75. package/dist/navigation-menu.d.ts.map +1 -1
  76. package/dist/navigation-menu.js +73 -84
  77. package/dist/pagination.cjs +1 -1
  78. package/dist/pagination.d.ts +8 -10
  79. package/dist/pagination.d.ts.map +1 -1
  80. package/dist/pagination.js +78 -86
  81. package/dist/radio-group.cjs +1 -1
  82. package/dist/radio-group.d.ts +10 -23
  83. package/dist/radio-group.d.ts.map +1 -1
  84. package/dist/radio-group.js +47 -55
  85. package/dist/resizable.cjs +1 -1
  86. package/dist/resizable.d.ts +19 -28
  87. package/dist/resizable.d.ts.map +1 -1
  88. package/dist/resizable.js +24 -40
  89. package/dist/select.cjs +1 -1
  90. package/dist/select.d.ts +3 -1
  91. package/dist/select.d.ts.map +1 -1
  92. package/dist/select.js +57 -56
  93. package/dist/separator.cjs +1 -1
  94. package/dist/separator.d.ts +4 -4
  95. package/dist/separator.d.ts.map +1 -1
  96. package/dist/separator.js +19 -21
  97. package/dist/sheet.cjs +1 -1
  98. package/dist/sheet.d.ts +5 -10
  99. package/dist/sheet.d.ts.map +1 -1
  100. package/dist/sheet.js +24 -26
  101. package/dist/sonner.cjs +1 -1
  102. package/dist/sonner.d.ts +17 -20
  103. package/dist/sonner.d.ts.map +1 -1
  104. package/dist/sonner.js +42 -45
  105. package/dist/switch.cjs +1 -1
  106. package/dist/switch.d.ts +2 -12
  107. package/dist/switch.d.ts.map +1 -1
  108. package/dist/switch.js +37 -41
  109. package/dist/table.cjs +1 -1
  110. package/dist/table.d.ts +16 -12
  111. package/dist/table.d.ts.map +1 -1
  112. package/dist/table.js +56 -58
  113. package/dist/tabs.d.ts +27 -3
  114. package/dist/tabs.d.ts.map +1 -1
  115. package/dist/textarea.cjs +1 -1
  116. package/dist/textarea.d.ts +4 -0
  117. package/dist/textarea.d.ts.map +1 -1
  118. package/dist/textarea.js +19 -18
  119. package/dist/toggle-group.cjs +1 -1
  120. package/dist/toggle-group.d.ts +57 -7
  121. package/dist/toggle-group.d.ts.map +1 -1
  122. package/dist/toggle-group.js +60 -67
  123. package/dist/toggle.cjs +1 -1
  124. package/dist/toggle.d.ts +12 -26
  125. package/dist/toggle.d.ts.map +1 -1
  126. package/dist/toggle.js +18 -22
  127. package/package.json +2 -2
  128. package/src/blocks/data-table.tsx +1 -1
  129. package/src/blocks/sidebar.tsx +157 -532
  130. package/src/components/accordion.tsx +1 -1
  131. package/src/components/alert.tsx +1 -1
  132. package/src/components/breadcrumb.tsx +1 -1
  133. package/src/components/button.tsx +1 -1
  134. package/src/components/calendar.tsx +6 -4
  135. package/src/components/centred-layout.tsx +11 -24
  136. package/src/components/checkbox.tsx +5 -6
  137. package/src/components/combobox.tsx +481 -301
  138. package/src/components/command.tsx +1 -1
  139. package/src/components/context-menu.tsx +1 -1
  140. package/src/components/date-picker.tsx +1 -1
  141. package/src/components/dialog.tsx +1 -1
  142. package/src/components/dropdown-menu.tsx +1 -1
  143. package/src/components/field.tsx +2 -0
  144. package/src/components/input-group.tsx +14 -2
  145. package/src/components/input-otp.tsx +17 -2
  146. package/src/components/input-password.tsx +7 -2
  147. package/src/components/input.tsx +11 -3
  148. package/src/components/link.tsx +1 -1
  149. package/src/components/logo.tsx +10 -8
  150. package/src/components/menubar.tsx +3 -1
  151. package/src/components/navigation-menu.tsx +37 -99
  152. package/src/components/pagination.tsx +13 -19
  153. package/src/components/radio-group.tsx +28 -38
  154. package/src/components/resizable.tsx +5 -43
  155. package/src/components/select.tsx +8 -3
  156. package/src/components/separator.tsx +5 -5
  157. package/src/components/sheet.tsx +6 -11
  158. package/src/components/sonner.tsx +24 -27
  159. package/src/components/switch.figma.tsx +7 -11
  160. package/src/components/switch.tsx +9 -19
  161. package/src/components/table.tsx +23 -18
  162. package/src/components/tabs.tsx +27 -3
  163. package/src/components/textarea.tsx +12 -5
  164. package/src/components/toggle-group.tsx +115 -86
  165. package/src/components/toggle.figma.tsx +13 -19
  166. package/src/components/toggle.tsx +32 -48
@@ -1,83 +1,91 @@
1
- import { LucideIcon } from 'lucide-react';
2
1
  import { VariantProps } from 'class-variance-authority';
2
+ import { CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from '../command';
3
3
  import * as React from "react";
4
- /**
5
- * Visual style variants for Combobox
6
- */
7
- export declare enum ComboboxVariant {
8
- /** Default variant with standard combobox styling */
9
- DEFAULT = "default",
10
- /** Variant with group label showing category above selection */
11
- WITH_GROUP_LABEL = "withGroupLabel"
12
- }
13
- /**
14
- * Menu item type variants for Combobox dropdown items
15
- */
16
- export declare enum ComboboxMenuItemType {
17
- /** Simple text-only menu item */
18
- SIMPLE = "simple",
19
- /** Menu item with checkbox */
20
- CHECKBOX = "checkbox",
21
- /** Menu item with icon */
22
- ICON = "icon",
23
- /** Menu item with avatar */
24
- AVATAR = "avatar"
25
- }
26
- export interface ComboboxItem {
27
- /** Unique value for the item */
28
- value: string;
29
- /** Display label for the item */
30
- label: string;
31
- /** Optional group/category for the item */
32
- group?: string;
33
- /** Icon component for icon menu item type */
34
- icon?: LucideIcon;
35
- /** Avatar image source URL for avatar menu item type */
36
- avatarSrc?: string;
37
- /** Avatar fallback text/initials for avatar menu item type */
38
- avatarFallback?: string;
4
+ export interface ComboboxProps {
5
+ /** Controlled selected value */
6
+ value?: string;
7
+ /** Callback when value changes */
8
+ onValueChange?: (value: string) => void;
9
+ /** Controlled open state */
10
+ open?: boolean;
11
+ /** Callback when open state changes */
12
+ onOpenChange?: (open: boolean) => void;
13
+ /** Whether to use cmdk's built-in filtering. Set to false for async search. */
14
+ shouldFilter?: boolean;
15
+ /** Disabled state */
16
+ disabled?: boolean;
17
+ /** Children */
18
+ children: React.ReactNode;
39
19
  }
20
+ declare function Combobox({ value: controlledValue, onValueChange: controlledOnValueChange, open: controlledOpen, onOpenChange: controlledOnOpenChange, shouldFilter, disabled, children, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
40
21
  declare const comboboxTriggerVariants: (props?: ({
41
- variant?: "default" | "withGroupLabel" | null | undefined;
22
+ variant?: "default" | null | undefined;
42
23
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
43
- interface ComboboxProps extends VariantProps<typeof comboboxTriggerVariants> {
44
- /** Optional id for the combobox trigger, used with FieldLabel htmlFor */
45
- id?: string;
24
+ export interface ComboboxTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof comboboxTriggerVariants> {
46
25
  /** Data hook for automated testing (REQUIRED) */
47
26
  dataHook: string;
27
+ /** Accessible label for the combobox trigger. Use either aria-label or aria-labelledby for accessibility. */
28
+ "aria-label"?: string;
29
+ /** ID reference to a label element that provides the accessible name */
30
+ "aria-labelledby"?: string;
48
31
  /** Tracking element identifier for analytics */
49
32
  trackingEl?: string;
50
33
  /** Tracking label for analytics context */
51
34
  trackingLabel?: string;
52
- /** Array of items to display in the combobox */
53
- items: ComboboxItem[];
54
- /** Currently selected value */
55
- value?: string;
56
- /** Callback when selection changes */
57
- onValueChange?: (value: string) => void;
35
+ }
36
+ declare const ComboboxTrigger: React.ForwardRefExoticComponent<ComboboxTriggerProps & React.RefAttributes<HTMLButtonElement>>;
37
+ export interface ComboboxValueProps {
58
38
  /** Placeholder text when no value is selected */
59
39
  placeholder?: string;
60
- /** Group label text (only for withGroupLabel variant) */
61
- groupLabel?: string;
62
- /** Disabled state */
63
- disabled?: boolean;
64
- /** Empty state message when no results found */
65
- emptyMessage?: string;
66
- /** Search placeholder text */
67
- searchPlaceholder?: string;
68
- /** Whether to show the avatar */
69
- showAvatar?: boolean;
70
- /** Avatar image source URL */
71
- avatarSrc?: string;
72
- /** Avatar fallback text/initials */
73
- avatarFallback?: string;
74
- /** Custom className for the trigger button */
40
+ /** Custom className */
75
41
  className?: string;
76
- /** Menu item type for dropdown items */
77
- menuItemType?: ComboboxMenuItemType;
78
- /** Accessible label for the combobox (used when no visible label is provided) */
79
- "aria-label"?: string;
80
42
  }
81
- declare const Combobox: React.ForwardRefExoticComponent<ComboboxProps & React.RefAttributes<HTMLButtonElement>>;
82
- export { Combobox, type ComboboxProps };
43
+ declare function ComboboxValue({ placeholder, className }: ComboboxValueProps): import("react/jsx-runtime").JSX.Element;
44
+ export interface ComboboxContentProps {
45
+ /** Data hook for automated testing */
46
+ dataHook?: string;
47
+ /** Custom className */
48
+ className?: string;
49
+ /** Children */
50
+ children: React.ReactNode;
51
+ /** Alignment of the popover relative to trigger */
52
+ align?: "start" | "center" | "end";
53
+ }
54
+ declare function ComboboxContent({ dataHook, className, children, align, }: ComboboxContentProps): import("react/jsx-runtime").JSX.Element;
55
+ export interface ComboboxInputProps extends React.ComponentProps<typeof CommandInput> {
56
+ /** Current input value. Use for controlled/async search. */
57
+ value?: string;
58
+ /** Called when input value changes. Use to trigger async search requests. */
59
+ onValueChange?: (value: string) => void;
60
+ }
61
+ declare const ComboboxInput: React.ForwardRefExoticComponent<ComboboxInputProps & React.RefAttributes<any>>;
62
+ export type ComboboxListProps = React.ComponentProps<typeof CommandList>;
63
+ declare const ComboboxList: React.ForwardRefExoticComponent<any>;
64
+ export type ComboboxEmptyProps = React.ComponentProps<typeof CommandEmpty>;
65
+ declare const ComboboxEmpty: React.ForwardRefExoticComponent<any>;
66
+ export type ComboboxGroupProps = React.ComponentProps<typeof CommandGroup>;
67
+ declare const ComboboxGroup: React.ForwardRefExoticComponent<any>;
68
+ export interface ComboboxItemProps extends Omit<React.ComponentProps<typeof CommandItem>, "onSelect"> {
69
+ /** The value of the item (required) */
70
+ value: string;
71
+ /** Display label - if not provided, uses children text content */
72
+ label?: string;
73
+ /** Data hook for automated testing */
74
+ dataHook?: string;
75
+ /** Text to highlight in the item (typically the search query) */
76
+ highlight?: string;
77
+ /** Class name for highlighted text */
78
+ highlightClassName?: string;
79
+ }
80
+ declare const ComboboxItem: React.ForwardRefExoticComponent<Omit<ComboboxItemProps, "ref"> & React.RefAttributes<any>>;
81
+ export type ComboboxSeparatorProps = React.ComponentProps<typeof CommandSeparator>;
82
+ declare const ComboboxSeparator: React.ForwardRefExoticComponent<any>;
83
+ export interface ComboboxLoadingProps {
84
+ /** Custom className */
85
+ className?: string;
86
+ /** Children - custom loading content */
87
+ children?: React.ReactNode;
88
+ }
89
+ declare function ComboboxLoading({ className, children }: ComboboxLoadingProps): import("react/jsx-runtime").JSX.Element;
90
+ export { Combobox, ComboboxTrigger, ComboboxValue, ComboboxContent, ComboboxInput, ComboboxList, ComboboxEmpty, ComboboxGroup, ComboboxItem, ComboboxSeparator, ComboboxLoading, };
83
91
  //# sourceMappingURL=combobox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../src/components/combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAIL,KAAK,UAAU,EAChB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;AAOH,MAAM,WAAW,oBAAoB;IACnC,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,iBAAS,eAAe,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,oBAAoB,2CAiBrE;AAMD,OAAO,EACL,QAAQ,EACR,eAAe,EACf,aAAa,EACb,eAAe,EACf,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,eAAe,GAChB,CAAC"}
package/dist/combobox.js CHANGED
@@ -1,17 +1,73 @@
1
- import { jsxs as t, jsx as a, Fragment as c } from "react/jsx-runtime";
2
- import * as m from "react";
3
- import { ChevronDownIcon as U, ChevronsUpDownIcon as B, CheckIcon as D } from "lucide-react";
4
- import { Checkbox as F } from "@brightlocal/ui-components/checkbox";
5
- import { cva as M } from "class-variance-authority";
6
- import { cn as H } from "@brightlocal/ui-components/lib/utils";
7
- import { Popover as K, PopoverTrigger as W, PopoverContent as X } from "@brightlocal/ui-components/popover";
8
- import { Command as q, CommandInput as J, CommandList as Q, CommandEmpty as Y, CommandGroup as A, CommandItem as I } from "@brightlocal/ui-components/command";
9
- var Z = /* @__PURE__ */ ((o) => (o.DEFAULT = "default", o.WITH_GROUP_LABEL = "withGroupLabel", o))(Z || {}), ee = /* @__PURE__ */ ((o) => (o.SIMPLE = "simple", o.CHECKBOX = "checkbox", o.ICON = "icon", o.AVATAR = "avatar", o))(ee || {});
10
- const h = "font-sans text-sm leading-normal font-normal text-foreground", ae = "bg-accent flex size-5 shrink-0 items-center justify-center rounded-full text-xs font-medium", oe = "size-5 rounded-full object-cover", re = M(
1
+ import { jsx as n, jsxs as I, Fragment as j } from "react/jsx-runtime";
2
+ import * as t from "react";
3
+ import { ChevronsUpDownIcon as z, CheckIcon as P, LoaderIcon as M } from "@brightlocal/icons";
4
+ import { cva as G } from "class-variance-authority";
5
+ import { cn as w } from "@brightlocal/ui-components/lib/utils";
6
+ import { Popover as U, PopoverTrigger as _, PopoverContent as $ } from "@brightlocal/ui-components/popover";
7
+ import { Command as F, CommandInput as O, CommandList as D, CommandEmpty as H, CommandGroup as V, CommandItem as q, CommandSeparator as A } from "@brightlocal/ui-components/command";
8
+ const E = t.createContext(null);
9
+ function y() {
10
+ const o = t.useContext(E);
11
+ if (!o)
12
+ throw new Error("Combobox components must be used within a <Combobox>");
13
+ return o;
14
+ }
15
+ function io({
16
+ value: o,
17
+ onValueChange: e,
18
+ open: a,
19
+ onOpenChange: r,
20
+ shouldFilter: s = !0,
21
+ disabled: i = !1,
22
+ children: d
23
+ }) {
24
+ const [f, m] = t.useState(""), [b, x] = t.useState(!1), [u, l] = t.useState(
25
+ () => /* @__PURE__ */ new Map()
26
+ ), g = o !== void 0, p = a !== void 0, C = g ? o : f, v = p ? a : b, h = t.useCallback(
27
+ (c) => {
28
+ p || x(c), r?.(c);
29
+ },
30
+ [p, r]
31
+ ), N = t.useCallback(
32
+ (c) => {
33
+ g || m(c), e?.(c);
34
+ },
35
+ [g, e]
36
+ ), R = t.useCallback((c, S) => {
37
+ l((k) => {
38
+ if (k.get(c) === S) return k;
39
+ const L = new Map(k);
40
+ return L.set(c, S), L;
41
+ });
42
+ }, []), T = t.useMemo(
43
+ () => ({
44
+ open: v,
45
+ setOpen: h,
46
+ value: C,
47
+ onValueChange: N,
48
+ shouldFilter: s,
49
+ disabled: i,
50
+ itemLabels: u,
51
+ registerItem: R
52
+ }),
53
+ [
54
+ v,
55
+ h,
56
+ C,
57
+ N,
58
+ s,
59
+ i,
60
+ u,
61
+ R
62
+ ]
63
+ );
64
+ return /* @__PURE__ */ n(E.Provider, { value: T, children: /* @__PURE__ */ n(U, { open: v, onOpenChange: h, children: d }) });
65
+ }
66
+ const B = G(
11
67
  [
12
68
  // Base layout
13
- "relative flex w-full items-center justify-start gap-2",
14
- "px-4 py-2",
69
+ "relative flex w-full items-center justify-between gap-2",
70
+ "px-4 py-2 h-9",
15
71
  // Base appearance
16
72
  "border border-input rounded-md outline-none",
17
73
  "bg-neutral-50 shadow-xs",
@@ -22,7 +78,7 @@ const h = "font-sans text-sm leading-normal font-normal text-foreground", ae = "
22
78
  "data-[placeholder=true]:text-muted-foreground",
23
79
  // Hover state
24
80
  "hover:bg-accent",
25
- // Focus state (keyboard navigation only - not on click)
81
+ // Focus state
26
82
  "focus-visible:outline-none focus-visible:border-ring dark:focus-visible:border-neutral-500 focus-visible:bg-background",
27
83
  "focus-visible:shadow-default",
28
84
  // Open dropdown state
@@ -30,208 +86,199 @@ const h = "font-sans text-sm leading-normal font-normal text-foreground", ae = "
30
86
  // Disabled state
31
87
  "disabled:cursor-not-allowed disabled:opacity-50",
32
88
  "disabled:hover:bg-neutral-50",
33
- // Transitions - following AGENTS.md guidelines (0.2s-0.3s, ease-out for entering)
89
+ // Transitions
34
90
  "transition-[background-color,border-color,box-shadow] duration-200 ease-out",
35
91
  // Icon styles
36
92
  "[&_svg]:pointer-events-none [&_svg]:shrink-0",
37
- "[&_svg:not([class*='size-'])]:size-4",
38
- "[&_svg:not([class*='text-'])]:text-muted-foreground"
93
+ "[&_svg:not([class*='size-'])]:size-4"
39
94
  ],
40
95
  {
41
96
  variants: {
42
97
  variant: {
43
- default: ["h-9"],
44
- withGroupLabel: [
45
- // Only variant-specific styles (removed duplicates from base)
46
- "self-stretch"
47
- ]
98
+ default: []
48
99
  }
49
100
  },
50
101
  defaultVariants: {
51
102
  variant: "default"
52
103
  }
53
104
  }
54
- );
55
- function S({
56
- src: o,
57
- fallback: n,
58
- alt: l,
59
- dataSlot: f
60
- }) {
61
- return /* @__PURE__ */ a("span", { className: ae, "data-slot": f, children: o ? /* @__PURE__ */ a("img", { alt: l || "", className: oe, src: o }) : n || "?" });
62
- }
63
- const te = m.forwardRef(
105
+ ), J = t.forwardRef(
64
106
  ({
65
- id: o,
66
- variant: n = "default",
67
- dataHook: l,
68
- trackingEl: f,
69
- trackingLabel: L,
70
- items: i,
71
- value: u,
72
- onValueChange: _,
73
- placeholder: g = "Select an option...",
74
- groupLabel: x,
75
- disabled: E,
76
- emptyMessage: $ = "No results found.",
77
- searchPlaceholder: z = "Search",
78
- showAvatar: G = !1,
79
- avatarSrc: O,
80
- avatarFallback: j,
81
- className: R,
82
- menuItemType: y = "simple",
83
- "aria-label": P
84
- }, T) => {
85
- const [p, v] = m.useState(!1), w = m.useId(), d = i.find((e) => e.value === u), V = !d, k = m.useMemo(() => n !== "withGroupLabel" ? { "": i } : i.reduce(
86
- (e, s) => {
87
- const r = s.group || "";
88
- return e[r] || (e[r] = []), e[r].push(s), e;
89
- },
90
- {}
91
- ), [i, n]), N = (e) => {
92
- _?.(e === u ? "" : e), v(!1);
93
- }, C = (e, s) => {
94
- const r = e.icon, b = s ? /* @__PURE__ */ a(D, { className: "text-muted-foreground ml-auto size-4 shrink-0" }) : null;
95
- switch (y) {
96
- case "checkbox":
97
- return /* @__PURE__ */ t(c, { children: [
98
- /* @__PURE__ */ a(
99
- F,
100
- {
101
- checked: s,
102
- className: "pointer-events-none self-center",
103
- dataHook: `${l}-checkbox-${e.value}`
104
- }
105
- ),
106
- /* @__PURE__ */ a("span", { className: h, children: e.label })
107
- ] });
108
- case "icon":
109
- return /* @__PURE__ */ t(c, { children: [
110
- r && /* @__PURE__ */ a(r, { className: "text-muted-foreground size-4 shrink-0" }),
111
- /* @__PURE__ */ a("span", { className: h, children: e.label }),
112
- b
113
- ] });
114
- case "avatar":
115
- return /* @__PURE__ */ t(c, { children: [
116
- /* @__PURE__ */ a(
117
- S,
118
- {
119
- alt: e.label,
120
- dataSlot: "menu-item-avatar",
121
- fallback: e.avatarFallback,
122
- src: e.avatarSrc
123
- }
124
- ),
125
- /* @__PURE__ */ a("span", { className: h, children: e.label }),
126
- b
127
- ] });
128
- case "simple":
129
- default:
130
- return /* @__PURE__ */ t(c, { children: [
131
- /* @__PURE__ */ a("span", { className: h, children: e.label }),
132
- b
133
- ] });
107
+ className: o,
108
+ variant: e,
109
+ dataHook: a,
110
+ trackingEl: r,
111
+ trackingLabel: s,
112
+ children: i,
113
+ ...d
114
+ }, f) => {
115
+ const { open: m, disabled: b, value: x } = y(), u = t.useId(), l = !x;
116
+ return /* @__PURE__ */ n(_, { asChild: !0, children: /* @__PURE__ */ I(
117
+ "button",
118
+ {
119
+ ref: f,
120
+ "aria-controls": m ? u : void 0,
121
+ "aria-expanded": m,
122
+ "aria-haspopup": "listbox",
123
+ className: w(B({ variant: e }), o),
124
+ "data-hook": a,
125
+ "data-placeholder": l,
126
+ "data-slot": "combobox-trigger",
127
+ "data-state": m ? "open" : "closed",
128
+ "data-tracking-el": r || "combobox-trigger",
129
+ "data-tracking-label": s,
130
+ disabled: b || d.disabled,
131
+ role: "combobox",
132
+ type: "button",
133
+ ...d,
134
+ children: [
135
+ i,
136
+ /* @__PURE__ */ n(
137
+ z,
138
+ {
139
+ "aria-hidden": "true",
140
+ className: "text-muted-foreground ml-auto size-4 shrink-0"
141
+ }
142
+ )
143
+ ]
134
144
  }
135
- };
136
- return /* @__PURE__ */ t(K, { open: p, onOpenChange: v, children: [
137
- /* @__PURE__ */ a(W, { asChild: !0, children: /* @__PURE__ */ a(
138
- "button",
145
+ ) });
146
+ }
147
+ );
148
+ J.displayName = "ComboboxTrigger";
149
+ function co({ placeholder: o, className: e }) {
150
+ const { value: a, itemLabels: r } = y(), s = a ? r.get(a) || a : o;
151
+ return /* @__PURE__ */ n(
152
+ "span",
153
+ {
154
+ className: w(
155
+ "text-foreground overflow-hidden text-sm leading-normal font-medium text-ellipsis whitespace-nowrap",
156
+ e
157
+ ),
158
+ "data-slot": "combobox-value",
159
+ children: s
160
+ }
161
+ );
162
+ }
163
+ function mo({
164
+ dataHook: o,
165
+ className: e,
166
+ children: a,
167
+ align: r = "start"
168
+ }) {
169
+ const { shouldFilter: s } = y();
170
+ return /* @__PURE__ */ n(
171
+ $,
172
+ {
173
+ align: r,
174
+ className: w("w-[var(--radix-popover-trigger-width)] p-0", e),
175
+ "data-slot": "combobox-popover",
176
+ children: /* @__PURE__ */ n(
177
+ F,
139
178
  {
140
- ref: T,
141
- "aria-controls": p ? w : void 0,
142
- "aria-expanded": p,
143
- "aria-haspopup": "listbox",
144
- "aria-label": P,
145
- className: H(
146
- re({
147
- variant: n
148
- }),
149
- R
150
- ),
151
- "data-hook": l,
152
- "data-placeholder": V,
153
- "data-slot": "combobox-trigger",
154
- "data-tracking-el": f || `combobox-${n}`,
155
- "data-tracking-label": L,
156
- disabled: E,
157
- id: o,
158
- role: "combobox",
159
- type: "button",
160
- children: n === "withGroupLabel" ? /* @__PURE__ */ t(c, { children: [
161
- /* @__PURE__ */ t("div", { className: "flex w-full flex-col items-start pr-6", children: [
162
- x && /* @__PURE__ */ a("span", { className: "text-muted-foreground overflow-hidden font-sans text-xs leading-4 font-normal text-ellipsis", children: x }),
163
- /* @__PURE__ */ a("span", { className: "text-foreground overflow-hidden font-sans text-sm leading-5 font-medium text-ellipsis whitespace-nowrap", children: d ? d.label : g })
164
- ] }),
165
- /* @__PURE__ */ a(U, { className: "text-muted-foreground absolute top-1/2 right-4 size-4 shrink-0 -translate-y-1/2" })
166
- ] }) : /* @__PURE__ */ t(c, { children: [
167
- G && /* @__PURE__ */ a(
168
- S,
169
- {
170
- alt: d?.label,
171
- dataSlot: "combobox-avatar",
172
- fallback: j,
173
- src: O
174
- }
175
- ),
176
- /* @__PURE__ */ a("span", { className: "text-foreground overflow-hidden text-sm leading-normal font-medium text-ellipsis whitespace-nowrap", children: d ? d.label : g }),
177
- /* @__PURE__ */ a(B, { className: "text-muted-foreground ml-auto size-4 shrink-0" })
178
- ] })
179
+ className: "border-0 shadow-none",
180
+ "data-slot": "combobox-command",
181
+ dataHook: o || "combobox-command",
182
+ shouldFilter: s,
183
+ children: a
179
184
  }
180
- ) }),
181
- /* @__PURE__ */ a(
182
- X,
183
- {
184
- align: "start",
185
- className: "w-[var(--radix-popover-trigger-width)] p-0",
186
- "data-slot": "combobox-popover",
187
- children: /* @__PURE__ */ t(
188
- q,
185
+ )
186
+ }
187
+ );
188
+ }
189
+ const K = t.forwardRef((o, e) => /* @__PURE__ */ n(O, { ref: e, "data-slot": "combobox-input", ...o }));
190
+ K.displayName = "ComboboxInput";
191
+ const Q = t.forwardRef((o, e) => /* @__PURE__ */ n(D, { ref: e, "data-slot": "combobox-list", ...o }));
192
+ Q.displayName = "ComboboxList";
193
+ const W = t.forwardRef((o, e) => /* @__PURE__ */ n(H, { ref: e, "data-slot": "combobox-empty", ...o }));
194
+ W.displayName = "ComboboxEmpty";
195
+ const X = t.forwardRef((o, e) => /* @__PURE__ */ n(V, { ref: e, "data-slot": "combobox-group", ...o }));
196
+ X.displayName = "ComboboxGroup";
197
+ function Y(o, e, a) {
198
+ if (!e || !e.trim())
199
+ return o;
200
+ const r = new RegExp(`(${e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, "gi"), s = o.split(r);
201
+ return /* @__PURE__ */ n("span", { children: s.map(
202
+ (i, d) => d % 2 === 1 ? /* @__PURE__ */ n("span", { className: a, children: i }, d) : /* @__PURE__ */ n(t.Fragment, { children: i }, d)
203
+ ) });
204
+ }
205
+ const Z = t.forwardRef(
206
+ ({
207
+ value: o,
208
+ label: e,
209
+ dataHook: a,
210
+ children: r,
211
+ className: s,
212
+ highlight: i,
213
+ highlightClassName: d,
214
+ ...f
215
+ }, m) => {
216
+ const { value: b, onValueChange: x, setOpen: u, registerItem: l } = y(), g = b === o, p = t.useMemo(() => e || (typeof r == "string" ? r : typeof r == "number" ? String(r) : o), [e, r, o]), C = t.useRef(l);
217
+ t.useEffect(() => {
218
+ C.current = l;
219
+ }, [l]), t.useEffect(() => {
220
+ C.current(o, p);
221
+ }, [o, p]);
222
+ const v = () => {
223
+ x(o === b ? "" : o), u(!1);
224
+ }, h = () => i && typeof r == "string" ? Y(
225
+ r,
226
+ i,
227
+ d || "text-sm leading-normal font-semibold"
228
+ ) : r;
229
+ return /* @__PURE__ */ I(
230
+ q,
231
+ {
232
+ ref: m,
233
+ className: w("justify-between", s),
234
+ "data-slot": "combobox-item",
235
+ dataHook: a,
236
+ value: o,
237
+ onSelect: v,
238
+ ...f,
239
+ children: [
240
+ h(),
241
+ g && /* @__PURE__ */ n(
242
+ P,
189
243
  {
190
- className: "border-0 shadow-none",
191
- "data-slot": "combobox-command",
192
- dataHook: `${l}-command`,
193
- id: w,
194
- children: [
195
- /* @__PURE__ */ a(
196
- J,
197
- {
198
- dataHook: `${l}-search`,
199
- placeholder: z
200
- }
201
- ),
202
- /* @__PURE__ */ t(Q, { children: [
203
- /* @__PURE__ */ a(Y, { children: $ }),
204
- n === "withGroupLabel" && Object.keys(k).length > 1 ? Object.entries(k).map(([e, s]) => /* @__PURE__ */ a(A, { heading: e, children: s.map((r) => /* @__PURE__ */ a(
205
- I,
206
- {
207
- dataHook: `${l}-item-${r.value}`,
208
- value: r.value,
209
- onSelect: N,
210
- children: C(r, u === r.value)
211
- },
212
- r.value
213
- )) }, e)) : /* @__PURE__ */ a(A, { children: i.map((e) => /* @__PURE__ */ a(
214
- I,
215
- {
216
- dataHook: `${l}-item-${e.value}`,
217
- value: e.value,
218
- onSelect: N,
219
- children: C(e, u === e.value)
220
- },
221
- e.value
222
- )) })
223
- ] })
224
- ]
244
+ "aria-hidden": "true",
245
+ className: "text-muted-foreground size-4 shrink-0"
225
246
  }
226
247
  )
227
- }
228
- )
229
- ] });
248
+ ]
249
+ }
250
+ );
230
251
  }
231
252
  );
232
- te.displayName = "Combobox";
253
+ Z.displayName = "ComboboxItem";
254
+ const oo = t.forwardRef((o, e) => /* @__PURE__ */ n(A, { ref: e, "data-slot": "combobox-separator", ...o }));
255
+ oo.displayName = "ComboboxSeparator";
256
+ function lo({ className: o, children: e }) {
257
+ return /* @__PURE__ */ n(
258
+ "div",
259
+ {
260
+ className: w(
261
+ "flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",
262
+ o
263
+ ),
264
+ "data-slot": "combobox-loading",
265
+ children: e || /* @__PURE__ */ I(j, { children: [
266
+ /* @__PURE__ */ n(M, { "aria-hidden": "true", className: "size-4 animate-spin" }),
267
+ "Loading..."
268
+ ] })
269
+ }
270
+ );
271
+ }
233
272
  export {
234
- te as Combobox,
235
- ee as ComboboxMenuItemType,
236
- Z as ComboboxVariant
273
+ io as Combobox,
274
+ mo as ComboboxContent,
275
+ W as ComboboxEmpty,
276
+ X as ComboboxGroup,
277
+ K as ComboboxInput,
278
+ Z as ComboboxItem,
279
+ Q as ComboboxList,
280
+ lo as ComboboxLoading,
281
+ oo as ComboboxSeparator,
282
+ J as ComboboxTrigger,
283
+ co as ComboboxValue
237
284
  };