@arolariu/components 1.0.0 → 1.1.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/CHANGELOG.md +57 -0
- package/EXAMPLES.md +2510 -0
- package/dist/components/ui/alert-dialog.d.ts +4 -16
- package/dist/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog.js +18 -14
- package/dist/components/ui/alert-dialog.js.map +1 -1
- package/dist/components/ui/avatar.d.ts +3 -12
- package/dist/components/ui/avatar.d.ts.map +1 -1
- package/dist/components/ui/avatar.js +18 -15
- package/dist/components/ui/avatar.js.map +1 -1
- package/dist/components/ui/button-group.d.ts +1 -1
- package/dist/components/ui/button-group.d.ts.map +1 -1
- package/dist/components/ui/calendar.d.ts +1 -4
- package/dist/components/ui/calendar.d.ts.map +1 -1
- package/dist/components/ui/calendar.js +7 -7
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/carousel.d.ts.map +1 -1
- package/dist/components/ui/carousel.js.map +1 -1
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/chart.js +125 -59
- package/dist/components/ui/chart.js.map +1 -1
- package/dist/components/ui/checkbox-group.d.ts +2 -6
- package/dist/components/ui/checkbox-group.d.ts.map +1 -1
- package/dist/components/ui/checkbox-group.js +8 -7
- package/dist/components/ui/checkbox-group.js.map +1 -1
- package/dist/components/ui/checkbox.d.ts +3 -1
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox.js +4 -1
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/collapsible.d.ts.map +1 -1
- package/dist/components/ui/collapsible.js.map +1 -1
- package/dist/components/ui/combobox.d.ts +335 -0
- package/dist/components/ui/combobox.d.ts.map +1 -0
- package/dist/components/ui/combobox.js +206 -0
- package/dist/components/ui/combobox.js.map +1 -0
- package/dist/components/ui/combobox.module.js +23 -0
- package/dist/components/ui/combobox.module.js.map +1 -0
- package/dist/components/ui/combobox_module.css +142 -0
- package/dist/components/ui/combobox_module.css.map +1 -0
- package/dist/components/ui/command.d.ts.map +1 -1
- package/dist/components/ui/command.js +25 -16
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/context-menu.d.ts.map +1 -1
- package/dist/components/ui/context-menu.js.map +1 -1
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer.js.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/dropdrawer.d.ts +10 -16
- package/dist/components/ui/dropdrawer.d.ts.map +1 -1
- package/dist/components/ui/dropdrawer.js +28 -20
- package/dist/components/ui/dropdrawer.js.map +1 -1
- package/dist/components/ui/item.d.ts +1 -1
- package/dist/components/ui/item.d.ts.map +1 -1
- package/dist/components/ui/menubar.d.ts +11 -13
- package/dist/components/ui/menubar.d.ts.map +1 -1
- package/dist/components/ui/menubar.js.map +1 -1
- package/dist/components/ui/meter.d.ts +8 -24
- package/dist/components/ui/meter.d.ts.map +1 -1
- package/dist/components/ui/meter.js +23 -19
- package/dist/components/ui/meter.js.map +1 -1
- package/dist/components/ui/navigation-menu.d.ts +3 -12
- package/dist/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu.js +14 -11
- package/dist/components/ui/navigation-menu.js.map +1 -1
- package/dist/components/ui/number-field.d.ts +6 -12
- package/dist/components/ui/number-field.d.ts.map +1 -1
- package/dist/components/ui/number-field.js.map +1 -1
- package/dist/components/ui/progress.d.ts +1 -4
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/progress.js +10 -9
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/radio-group.d.ts +2 -4
- package/dist/components/ui/radio-group.d.ts.map +1 -1
- package/dist/components/ui/radio-group.js.map +1 -1
- package/dist/components/ui/resizable.d.ts +3 -3
- package/dist/components/ui/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable.js.map +1 -1
- package/dist/components/ui/scratcher.d.ts +1 -1
- package/dist/components/ui/scratcher.d.ts.map +1 -1
- package/dist/components/ui/scratcher.js +5 -4
- package/dist/components/ui/scratcher.js.map +1 -1
- package/dist/components/ui/scroll-area.d.ts +2 -4
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.js.map +1 -1
- package/dist/components/ui/separator.d.ts +1 -4
- package/dist/components/ui/separator.d.ts.map +1 -1
- package/dist/components/ui/separator.js +9 -8
- package/dist/components/ui/separator.js.map +1 -1
- package/dist/components/ui/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.d.ts.map +1 -1
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/sonner.d.ts +5 -4
- package/dist/components/ui/sonner.d.ts.map +1 -1
- package/dist/components/ui/sonner.js +7 -6
- package/dist/components/ui/sonner.js.map +1 -1
- package/dist/components/ui/toggle-group.d.ts +2 -8
- package/dist/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/components/ui/toggle-group.js +12 -10
- package/dist/components/ui/toggle-group.js.map +1 -1
- package/dist/components/ui/toolbar.d.ts +10 -30
- package/dist/components/ui/toolbar.d.ts.map +1 -1
- package/dist/components/ui/toolbar.js +28 -23
- package/dist/components/ui/toolbar.js.map +1 -1
- package/dist/hooks/useClipboard.d.ts +77 -0
- package/dist/hooks/useClipboard.d.ts.map +1 -0
- package/dist/hooks/useClipboard.js +42 -0
- package/dist/hooks/useClipboard.js.map +1 -0
- package/dist/hooks/useControllableState.d.ts +54 -0
- package/dist/hooks/useControllableState.d.ts.map +1 -0
- package/dist/hooks/useControllableState.js +29 -0
- package/dist/hooks/useControllableState.js.map +1 -0
- package/dist/hooks/useDebounce.d.ts +33 -0
- package/dist/hooks/useDebounce.d.ts.map +1 -0
- package/dist/hooks/useDebounce.js +20 -0
- package/dist/hooks/useDebounce.js.map +1 -0
- package/dist/hooks/useEventCallback.d.ts +34 -0
- package/dist/hooks/useEventCallback.d.ts.map +1 -0
- package/dist/hooks/useEventCallback.js +12 -0
- package/dist/hooks/useEventCallback.js.map +1 -0
- package/dist/hooks/useId.d.ts +30 -0
- package/dist/hooks/useId.d.ts.map +1 -0
- package/dist/hooks/useId.js +9 -0
- package/dist/hooks/useId.js.map +1 -0
- package/dist/hooks/useIntersectionObserver.d.ts +51 -0
- package/dist/hooks/useIntersectionObserver.d.ts.map +1 -0
- package/dist/hooks/useIntersectionObserver.js +25 -0
- package/dist/hooks/useIntersectionObserver.js.map +1 -0
- package/dist/hooks/useInterval.d.ts +55 -0
- package/dist/hooks/useInterval.d.ts.map +1 -0
- package/dist/hooks/useInterval.js +24 -0
- package/dist/hooks/useInterval.js.map +1 -0
- package/dist/hooks/useLocalStorage.d.ts +43 -0
- package/dist/hooks/useLocalStorage.d.ts.map +1 -0
- package/dist/hooks/useLocalStorage.js +53 -0
- package/dist/hooks/useLocalStorage.js.map +1 -0
- package/dist/hooks/useMergedRefs.d.ts +27 -0
- package/dist/hooks/useMergedRefs.d.ts.map +1 -0
- package/dist/hooks/useMergedRefs.js +11 -0
- package/dist/hooks/useMergedRefs.js.map +1 -0
- package/dist/hooks/useOnClickOutside.d.ts +32 -0
- package/dist/hooks/useOnClickOutside.d.ts.map +1 -0
- package/dist/hooks/useOnClickOutside.js +23 -0
- package/dist/hooks/useOnClickOutside.js.map +1 -0
- package/dist/hooks/usePrevious.d.ts +33 -0
- package/dist/hooks/usePrevious.d.ts.map +1 -0
- package/dist/hooks/usePrevious.js +14 -0
- package/dist/hooks/usePrevious.js.map +1 -0
- package/dist/hooks/useThrottle.d.ts +37 -0
- package/dist/hooks/useThrottle.d.ts.map +1 -0
- package/dist/hooks/useThrottle.js +34 -0
- package/dist/hooks/useThrottle.js.map +1 -0
- package/dist/hooks/useTimeout.d.ts +28 -0
- package/dist/hooks/useTimeout.d.ts.map +1 -0
- package/dist/hooks/useTimeout.js +24 -0
- package/dist/hooks/useTimeout.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/lib/utilities.d.ts +2 -3
- package/dist/lib/utilities.d.ts.map +1 -1
- package/dist/lib/utilities.js.map +1 -1
- package/dist/motion/tokens.js +5 -5
- package/dist/motion/tokens.js.map +1 -1
- package/dist/rslib-runtime.js +39 -0
- package/dist/rslib-runtime.js.map +1 -0
- package/package.json +82 -3
- package/src/components/ui/alert-dialog.tsx +15 -8
- package/src/components/ui/avatar.tsx +9 -6
- package/src/components/ui/calendar.tsx +7 -13
- package/src/components/ui/carousel.tsx +2 -0
- package/src/components/ui/chart.tsx +63 -60
- package/src/components/ui/checkbox-group.tsx +4 -5
- package/src/components/ui/checkbox.tsx +10 -2
- package/src/components/ui/collapsible.tsx +1 -0
- package/src/components/ui/combobox.module.css +158 -0
- package/src/components/ui/combobox.tsx +569 -0
- package/src/components/ui/command.tsx +31 -15
- package/src/components/ui/context-menu.tsx +3 -0
- package/src/components/ui/drawer.tsx +2 -0
- package/src/components/ui/dropdown-menu.tsx +3 -0
- package/src/components/ui/dropdrawer.tsx +80 -62
- package/src/components/ui/menubar.tsx +9 -10
- package/src/components/ui/meter.tsx +16 -17
- package/src/components/ui/navigation-menu.tsx +41 -33
- package/src/components/ui/number-field.tsx +6 -13
- package/src/components/ui/progress.tsx +3 -2
- package/src/components/ui/radio-group.tsx +2 -5
- package/src/components/ui/resizable.tsx +2 -2
- package/src/components/ui/scratcher.tsx +6 -10
- package/src/components/ui/scroll-area.tsx +2 -5
- package/src/components/ui/separator.tsx +4 -3
- package/src/components/ui/sheet.tsx +3 -0
- package/src/components/ui/sidebar.tsx +1 -0
- package/src/components/ui/sonner.tsx +20 -12
- package/src/components/ui/toggle-group.tsx +6 -4
- package/src/components/ui/toolbar.tsx +20 -21
- package/src/hooks/useClipboard.tsx +137 -0
- package/src/hooks/useControllableState.tsx +81 -0
- package/src/hooks/useDebounce.tsx +50 -0
- package/src/hooks/useEventCallback.tsx +47 -0
- package/src/hooks/useId.tsx +36 -0
- package/src/hooks/useIntersectionObserver.tsx +81 -0
- package/src/hooks/useInterval.tsx +80 -0
- package/src/hooks/useLocalStorage.tsx +111 -0
- package/src/hooks/useMergedRefs.tsx +48 -0
- package/src/hooks/useOnClickOutside.tsx +55 -0
- package/src/hooks/usePrevious.tsx +44 -0
- package/src/hooks/useThrottle.tsx +78 -0
- package/src/hooks/useTimeout.tsx +51 -0
- package/src/index.ts +23 -0
- package/src/lib/utilities.ts +4 -4
- package/src/motion/tokens.ts +4 -4
- package/src/stories/DesignPrinciples.mdx +48 -0
- package/src/stories/GettingStarted.mdx +92 -0
- package/src/stories/Welcome.mdx +44 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Checkbox as BaseCheckbox } from "@base-ui/react/checkbox";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
type BaseCheckboxCheckedChange = NonNullable<React.ComponentPropsWithRef<typeof BaseCheckbox.Root>["onCheckedChange"]>;
|
|
4
|
+
type CheckboxChangeEventDetails = Parameters<BaseCheckboxCheckedChange>[1];
|
|
3
5
|
/**
|
|
4
6
|
* Props for the shared checkbox wrapper.
|
|
5
7
|
*/
|
|
@@ -9,7 +11,7 @@ interface CheckboxProps extends Omit<React.ComponentPropsWithRef<typeof BaseChec
|
|
|
9
11
|
/** The current checked state, including support for the legacy `"indeterminate"` value. @default undefined */
|
|
10
12
|
checked?: boolean | "indeterminate";
|
|
11
13
|
/** Called whenever the checked state changes. @default undefined */
|
|
12
|
-
onCheckedChange?: (checked: boolean | "indeterminate") => void;
|
|
14
|
+
onCheckedChange?: (checked: boolean | "indeterminate", eventDetails: CheckboxChangeEventDetails) => void;
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
17
|
* Renders a selectable checkbox control with checked and indeterminate support.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/ui/checkbox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAGjE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B;;GAEG;AACH,UAAU,aAAc,SAAQ,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,iBAAiB,CAAC;IACtI,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8GAA8G;IAC9G,OAAO,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;IACpC,oEAAoE;IACpE,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/ui/checkbox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAGjE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,KAAK,yBAAyB,GAAG,WAAW,CAAC,KAAK,CAAC,qBAAqB,CAAC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;AACvH,KAAK,0BAA0B,GAAG,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3E;;GAEG;AACH,UAAU,aAAc,SAAQ,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,iBAAiB,CAAC;IACtI,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8GAA8G;IAC9G,OAAO,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;IACpC,oEAAoE;IACpE,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,EAAE,YAAY,EAAE,0BAA0B,KAAK,IAAI,CAAC;CAC1G;AAED;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,QAAQ,gGAsCb,CAAC;AAIF,kBAAU,QAAQ,CAAC;IACjB,KAAY,KAAK,GAAG,aAAa,CAAC;IAClC,KAAY,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;CAC7C;AAED,OAAO,EAAC,QAAQ,EAAC,CAAC"}
|
|
@@ -10,11 +10,14 @@ const checkbox_Checkbox = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
10
10
|
const { checked, className, onCheckedChange, render, ...otherProps } = props;
|
|
11
11
|
const baseChecked = "indeterminate" === checked ? true : checked;
|
|
12
12
|
const indeterminate = "indeterminate" === checked;
|
|
13
|
+
const handleCheckedChange = onCheckedChange ? (nextChecked, eventDetails)=>{
|
|
14
|
+
onCheckedChange(nextChecked, eventDetails);
|
|
15
|
+
} : void 0;
|
|
13
16
|
return /*#__PURE__*/ jsx(Checkbox.Root, {
|
|
14
17
|
ref: ref,
|
|
15
18
|
checked: baseChecked,
|
|
16
19
|
indeterminate: indeterminate,
|
|
17
|
-
onCheckedChange:
|
|
20
|
+
onCheckedChange: handleCheckedChange,
|
|
18
21
|
...otherProps,
|
|
19
22
|
render: useRender({
|
|
20
23
|
defaultTagName: "button",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/ui/checkbox.js","sources":["../../../src/components/ui/checkbox.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport {Checkbox as BaseCheckbox} from \"@base-ui/react/checkbox\";\r\nimport {mergeProps} from \"@base-ui/react/merge-props\";\r\nimport {useRender} from \"@base-ui/react/use-render\";\r\nimport * as React from \"react\";\r\n\r\nimport {cn} from \"@/lib/utilities\";\r\nimport styles from \"./checkbox.module.css\";\r\n\r\n/**\r\n * Props for the shared checkbox wrapper.\r\n */\r\ninterface CheckboxProps extends Omit<React.ComponentPropsWithRef<typeof BaseCheckbox.Root>, \"checked\" | \"className\" | \"onCheckedChange\"> {\r\n /** Additional CSS classes merged with the checkbox control styles. @default undefined */\r\n className?: string;\r\n /** The current checked state, including support for the legacy `\"indeterminate\"` value. @default undefined */\r\n checked?: boolean | \"indeterminate\";\r\n /** Called whenever the checked state changes. @default undefined */\r\n onCheckedChange?: (checked: boolean | \"indeterminate\") => void;\r\n}\r\n\r\n/**\r\n * Renders a selectable checkbox control with checked and indeterminate support.\r\n *\r\n * @remarks\r\n * - Renders a `<button>` element by default\r\n * - Built on {@link https://base-ui.com/react/components/checkbox | Base UI Checkbox}\r\n * - Supports the `render` prop for element composition\r\n * - Styling via CSS Modules with `--ac-*` custom properties\r\n *\r\n * @example Basic usage\r\n * ```tsx\r\n * <Checkbox checked />\r\n * ```\r\n *\r\n * @see {@link https://base-ui.com/react/components/checkbox | Base UI Documentation}\r\n */\r\nconst Checkbox = React.forwardRef<React.ComponentRef<typeof BaseCheckbox.Root>, Checkbox.Props>(\r\n (props: Readonly<Checkbox.Props>, ref): React.ReactElement => {\r\n const {checked, className, onCheckedChange, render, ...otherProps} = props;\r\n const baseChecked = checked === \"indeterminate\" ? true : checked;\r\n const indeterminate = checked === \"indeterminate\";\r\n\r\n return (\r\n <BaseCheckbox.Root\r\n ref={ref}\r\n checked={baseChecked}\r\n indeterminate={indeterminate}\r\n onCheckedChange={
|
|
1
|
+
{"version":3,"file":"components/ui/checkbox.js","sources":["../../../src/components/ui/checkbox.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport {Checkbox as BaseCheckbox} from \"@base-ui/react/checkbox\";\r\nimport {mergeProps} from \"@base-ui/react/merge-props\";\r\nimport {useRender} from \"@base-ui/react/use-render\";\r\nimport * as React from \"react\";\r\n\r\nimport {cn} from \"@/lib/utilities\";\r\nimport styles from \"./checkbox.module.css\";\r\n\r\ntype BaseCheckboxCheckedChange = NonNullable<React.ComponentPropsWithRef<typeof BaseCheckbox.Root>[\"onCheckedChange\"]>;\r\ntype CheckboxChangeEventDetails = Parameters<BaseCheckboxCheckedChange>[1];\r\n\r\n/**\r\n * Props for the shared checkbox wrapper.\r\n */\r\ninterface CheckboxProps extends Omit<React.ComponentPropsWithRef<typeof BaseCheckbox.Root>, \"checked\" | \"className\" | \"onCheckedChange\"> {\r\n /** Additional CSS classes merged with the checkbox control styles. @default undefined */\r\n className?: string;\r\n /** The current checked state, including support for the legacy `\"indeterminate\"` value. @default undefined */\r\n checked?: boolean | \"indeterminate\";\r\n /** Called whenever the checked state changes. @default undefined */\r\n onCheckedChange?: (checked: boolean | \"indeterminate\", eventDetails: CheckboxChangeEventDetails) => void;\r\n}\r\n\r\n/**\r\n * Renders a selectable checkbox control with checked and indeterminate support.\r\n *\r\n * @remarks\r\n * - Renders a `<button>` element by default\r\n * - Built on {@link https://base-ui.com/react/components/checkbox | Base UI Checkbox}\r\n * - Supports the `render` prop for element composition\r\n * - Styling via CSS Modules with `--ac-*` custom properties\r\n *\r\n * @example Basic usage\r\n * ```tsx\r\n * <Checkbox checked />\r\n * ```\r\n *\r\n * @see {@link https://base-ui.com/react/components/checkbox | Base UI Documentation}\r\n */\r\nconst Checkbox = React.forwardRef<React.ComponentRef<typeof BaseCheckbox.Root>, Checkbox.Props>(\r\n (props: Readonly<Checkbox.Props>, ref): React.ReactElement => {\r\n const {checked, className, onCheckedChange, render, ...otherProps} = props;\r\n const baseChecked = checked === \"indeterminate\" ? true : checked;\r\n const indeterminate = checked === \"indeterminate\";\r\n const handleCheckedChange: BaseCheckboxCheckedChange | undefined = onCheckedChange\r\n ? (nextChecked, eventDetails) => {\r\n onCheckedChange(nextChecked, eventDetails);\r\n }\r\n : undefined;\r\n\r\n return (\r\n <BaseCheckbox.Root\r\n ref={ref}\r\n checked={baseChecked}\r\n indeterminate={indeterminate}\r\n onCheckedChange={handleCheckedChange}\r\n {...otherProps}\r\n render={useRender({\r\n defaultTagName: \"button\",\r\n render: render as never,\r\n props: mergeProps({className: cn(styles.checkbox, className)}, {}),\r\n })}>\r\n <BaseCheckbox.Indicator className={styles.indicator}>\r\n <svg\r\n xmlns='http://www.w3.org/2000/svg'\r\n viewBox='0 0 24 24'\r\n fill='none'\r\n stroke='currentColor'\r\n strokeWidth='3'\r\n strokeLinecap='round'\r\n strokeLinejoin='round'>\r\n <polyline points='20 6 9 17 4 12' />\r\n </svg>\r\n </BaseCheckbox.Indicator>\r\n </BaseCheckbox.Root>\r\n );\r\n },\r\n);\r\nCheckbox.displayName = \"Checkbox\";\r\n\r\n// eslint-disable-next-line no-redeclare -- required for the canonical component namespace typing API\r\nnamespace Checkbox {\r\n export type Props = CheckboxProps;\r\n export type State = BaseCheckbox.Root.State;\r\n}\r\n\r\nexport {Checkbox};\r\n"],"names":["Checkbox","React","props","ref","checked","className","onCheckedChange","render","otherProps","baseChecked","indeterminate","handleCheckedChange","nextChecked","eventDetails","undefined","BaseCheckbox","useRender","mergeProps","cn","styles"],"mappings":";;;;;;;;AAyCA,MAAMA,oBAAW,WAAHA,GAAGC,WACf,CAACC,OAAiCC;IAChC,MAAM,EAACC,OAAO,EAAEC,SAAS,EAAEC,eAAe,EAAEC,MAAM,EAAE,GAAGC,YAAW,GAAGN;IACrE,MAAMO,cAAcL,AAAY,oBAAZA,UAA8B,OAAOA;IACzD,MAAMM,gBAAgBN,AAAY,oBAAZA;IACtB,MAAMO,sBAA6DL,kBAC/D,CAACM,aAAaC;QACZP,gBAAgBM,aAAaC;IAC/B,IACAC;IAEJ,OAAO,WAAP,GACE,IAACC,SAAAA,IAAiB;QAChB,KAAKZ;QACL,SAASM;QACT,eAAeC;QACf,iBAAiBC;QAChB,GAAGH,UAAU;QACd,QAAQQ,UAAU;YAChB,gBAAgB;YAChB,QAAQT;YACR,OAAOU,WAAW;gBAAC,WAAWC,GAAGC,gBAAAA,QAAe,EAAEd;YAAU,GAAG,CAAC;QAClE;kBACA,kBAACU,SAAAA,SAAsB;YAAC,WAAWI,gBAAAA,SAAgB;sBACjD,kBAAC;gBACC,OAAM;gBACN,SAAQ;gBACR,MAAK;gBACL,QAAO;gBACP,aAAY;gBACZ,eAAc;gBACd,gBAAe;0BACf,kBAAC;oBAAS,QAAO;;;;;AAK3B;AAEFnB,kBAAS,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collapsible.d.ts","sourceRoot":"","sources":["../../../src/components/ui/collapsible.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,IAAI,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAG1E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,UAAU,gBAAiB,SAAQ,KAAK,CAAC,qBAAqB,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC;CAAG;AAE9F,UAAU,uBAAwB,SAAQ,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtH;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,uBAAwB,SAAQ,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpH;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;GAcG;AACH,iBAAS,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,YAAY,CAE3E;kBAFQ,WAAW;;;AAIpB;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"collapsible.d.ts","sourceRoot":"","sources":["../../../src/components/ui/collapsible.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,IAAI,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAG1E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,UAAU,gBAAiB,SAAQ,KAAK,CAAC,qBAAqB,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC;CAAG;AAE9F,UAAU,uBAAwB,SAAQ,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtH;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,uBAAwB,SAAQ,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpH;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;GAcG;AACH,iBAAS,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,YAAY,CAE3E;kBAFQ,WAAW;;;AAIpB;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,kBAAkB,gHAmBvB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,kBAAkB,6GAiBvB,CAAC;AAGF,kBAAU,WAAW,CAAC;IACpB,KAAY,KAAK,GAAG,gBAAgB,CAAC;IACrC,KAAY,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC;CAChD;AAGD,kBAAU,kBAAkB,CAAC;IAC3B,KAAY,KAAK,GAAG,uBAAuB,CAAC;IAC5C,KAAY,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC;CACnD;AAGD,kBAAU,kBAAkB,CAAC;IAC3B,KAAY,KAAK,GAAG,uBAAuB,CAAC;IAC5C,KAAY,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC;CACjD;AAMD,OAAO,EAAC,WAAW,EAAE,kBAAkB,EAAE,kBAAkB,EAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/ui/collapsible.js","sources":["../../../src/components/ui/collapsible.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport {Collapsible as BaseCollapsible} from \"@base-ui/react/collapsible\";\r\nimport {mergeProps} from \"@base-ui/react/merge-props\";\r\nimport {useRender} from \"@base-ui/react/use-render\";\r\nimport * as React from \"react\";\r\n\r\nimport {cn} from \"@/lib/utilities\";\r\nimport styles from \"./collapsible.module.css\";\r\n\r\ninterface CollapsibleProps extends React.ComponentPropsWithRef<typeof BaseCollapsible.Root> {}\r\n\r\ninterface CollapsibleTriggerProps extends Omit<React.ComponentPropsWithRef<typeof BaseCollapsible.Trigger>, \"className\"> {\r\n /**\r\n * Applies additional CSS classes to the component root element.\r\n * @default undefined\r\n */\r\n className?: string;\r\n /**\r\n * Enables child element composition instead of rendering the default wrapper.\r\n * @default false\r\n * @deprecated Prefer Base UI's `render` prop.\r\n */\r\n asChild?: boolean;\r\n}\r\n\r\ninterface CollapsibleContentProps extends Omit<React.ComponentPropsWithRef<typeof BaseCollapsible.Panel>, \"className\"> {\r\n /**\r\n * Applies additional CSS classes to the component root element.\r\n * @default undefined\r\n */\r\n className?: string;\r\n}\r\n\r\n/**\r\n * Coordinates collapsible state and accessibility behavior.\r\n *\r\n * @remarks\r\n * - Delegates structure and state to the underlying Base UI primitive\r\n * - Built on {@link https://base-ui.com/react/components/collapsible | Base UI Collapsible}\r\n * - Preserves the underlying primitive API for advanced composition\r\n *\r\n * @example\r\n * ```tsx\r\n * <Collapsible>Content</Collapsible>\r\n * ```\r\n *\r\n * @see {@link https://base-ui.com/react/components/collapsible | Base UI Documentation}\r\n */\r\nfunction Collapsible(props: Readonly<Collapsible.Props>): React.ReactElement {\r\n return <BaseCollapsible.Root {...props} />;\r\n}\r\n\r\n/**\r\n * Renders the collapsible trigger.\r\n *\r\n * @remarks\r\n * - Renders a `<button>` element by default\r\n * - Built on {@link https://base-ui.com/react/components/collapsible | Base UI Collapsible}\r\n * - Supports the `render` prop for element composition\r\n *\r\n * @example\r\n * ```tsx\r\n * <CollapsibleTrigger>Content</CollapsibleTrigger>\r\n * ```\r\n *\r\n * @see {@link https://base-ui.com/react/components/collapsible | Base UI Documentation}\r\n */\r\nconst CollapsibleTrigger = React.forwardRef<React.ComponentRef<typeof BaseCollapsible.Trigger>, CollapsibleTrigger.Props>(\r\n (props: Readonly<CollapsibleTrigger.Props>, ref): React.ReactElement => {\r\n const {asChild = false, children, className, render, ...otherProps} = props;\r\n const renderProp = asChild && React.isValidElement(children) ? children : render;\r\n\r\n return (\r\n <BaseCollapsible.Trigger\r\n ref={ref}\r\n {...otherProps}\r\n render={useRender({\r\n defaultTagName: \"button\",\r\n render: renderProp as never,\r\n props: mergeProps({className: cn(styles.trigger, className)}, {}),\r\n })}>\r\n {renderProp ? undefined : children}\r\n </BaseCollapsible.Trigger>\r\n );\r\n },\r\n);\r\n\r\n/**\r\n * Renders the collapsible content.\r\n *\r\n * @remarks\r\n * - Renders a `<div>` element by default\r\n * - Built on {@link https://base-ui.com/react/components/collapsible | Base UI Collapsible}\r\n * - Supports the `render` prop for element composition\r\n *\r\n * @example\r\n * ```tsx\r\n * <CollapsibleContent>Content</CollapsibleContent>\r\n * ```\r\n *\r\n * @see {@link https://base-ui.com/react/components/collapsible | Base UI Documentation}\r\n */\r\nconst CollapsibleContent = React.forwardRef<React.ComponentRef<typeof BaseCollapsible.Panel>, CollapsibleContent.Props>(\r\n (props: Readonly<CollapsibleContent.Props>, ref): React.ReactElement => {\r\n const {className, children, render, ...otherProps} = props;\r\n\r\n return (\r\n <BaseCollapsible.Panel\r\n ref={ref}\r\n {...otherProps}\r\n render={useRender({\r\n defaultTagName: \"div\",\r\n render: render as never,\r\n props: mergeProps({className: cn(styles.panel, className)}, {}),\r\n })}>\r\n {children}\r\n </BaseCollapsible.Panel>\r\n );\r\n },\r\n);\r\n\r\n// eslint-disable-next-line no-redeclare -- required for the canonical component namespace typing API\r\nnamespace Collapsible {\r\n export type Props = CollapsibleProps;\r\n export type State = BaseCollapsible.Root.State;\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare -- required for the canonical component namespace typing API\r\nnamespace CollapsibleTrigger {\r\n export type Props = CollapsibleTriggerProps;\r\n export type State = BaseCollapsible.Trigger.State;\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare -- required for the canonical component namespace typing API\r\nnamespace CollapsibleContent {\r\n export type Props = CollapsibleContentProps;\r\n export type State = BaseCollapsible.Panel.State;\r\n}\r\n\r\nCollapsible.displayName = \"Collapsible\";\r\nCollapsibleTrigger.displayName = \"CollapsibleTrigger\";\r\nCollapsibleContent.displayName = \"CollapsibleContent\";\r\n\r\nexport {Collapsible, CollapsibleContent, CollapsibleTrigger};\r\n"],"names":["Collapsible","props","BaseCollapsible","CollapsibleTrigger","React","ref","asChild","children","className","render","otherProps","renderProp","useRender","mergeProps","cn","styles","undefined","CollapsibleContent"],"mappings":";;;;;;;;AAiDA,SAASA,wBAAYC,KAAkC;IACrD,OAAO,WAAP,GAAO,IAACC,YAAAA,IAAoB;QAAE,GAAGD,KAAK;;AACxC;AAiBA,MAAME,qBAAqB,WAAHA,GAAGC,WACzB,CAACH,OAA2CI;
|
|
1
|
+
{"version":3,"file":"components/ui/collapsible.js","sources":["../../../src/components/ui/collapsible.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport {Collapsible as BaseCollapsible} from \"@base-ui/react/collapsible\";\r\nimport {mergeProps} from \"@base-ui/react/merge-props\";\r\nimport {useRender} from \"@base-ui/react/use-render\";\r\nimport * as React from \"react\";\r\n\r\nimport {cn} from \"@/lib/utilities\";\r\nimport styles from \"./collapsible.module.css\";\r\n\r\ninterface CollapsibleProps extends React.ComponentPropsWithRef<typeof BaseCollapsible.Root> {}\r\n\r\ninterface CollapsibleTriggerProps extends Omit<React.ComponentPropsWithRef<typeof BaseCollapsible.Trigger>, \"className\"> {\r\n /**\r\n * Applies additional CSS classes to the component root element.\r\n * @default undefined\r\n */\r\n className?: string;\r\n /**\r\n * Enables child element composition instead of rendering the default wrapper.\r\n * @default false\r\n * @deprecated Prefer Base UI's `render` prop.\r\n */\r\n asChild?: boolean;\r\n}\r\n\r\ninterface CollapsibleContentProps extends Omit<React.ComponentPropsWithRef<typeof BaseCollapsible.Panel>, \"className\"> {\r\n /**\r\n * Applies additional CSS classes to the component root element.\r\n * @default undefined\r\n */\r\n className?: string;\r\n}\r\n\r\n/**\r\n * Coordinates collapsible state and accessibility behavior.\r\n *\r\n * @remarks\r\n * - Delegates structure and state to the underlying Base UI primitive\r\n * - Built on {@link https://base-ui.com/react/components/collapsible | Base UI Collapsible}\r\n * - Preserves the underlying primitive API for advanced composition\r\n *\r\n * @example\r\n * ```tsx\r\n * <Collapsible>Content</Collapsible>\r\n * ```\r\n *\r\n * @see {@link https://base-ui.com/react/components/collapsible | Base UI Documentation}\r\n */\r\nfunction Collapsible(props: Readonly<Collapsible.Props>): React.ReactElement {\r\n return <BaseCollapsible.Root {...props} />;\r\n}\r\n\r\n/**\r\n * Renders the collapsible trigger.\r\n *\r\n * @remarks\r\n * - Renders a `<button>` element by default\r\n * - Built on {@link https://base-ui.com/react/components/collapsible | Base UI Collapsible}\r\n * - Supports the `render` prop for element composition\r\n *\r\n * @example\r\n * ```tsx\r\n * <CollapsibleTrigger>Content</CollapsibleTrigger>\r\n * ```\r\n *\r\n * @see {@link https://base-ui.com/react/components/collapsible | Base UI Documentation}\r\n */\r\nconst CollapsibleTrigger = React.forwardRef<React.ComponentRef<typeof BaseCollapsible.Trigger>, CollapsibleTrigger.Props>(\r\n (props: Readonly<CollapsibleTrigger.Props>, ref): React.ReactElement => {\r\n // eslint-disable-next-line sonarjs/deprecation -- backward-compatible asChild API\r\n const {asChild = false, children, className, render, ...otherProps} = props;\r\n const renderProp = asChild && React.isValidElement(children) ? children : render;\r\n\r\n return (\r\n <BaseCollapsible.Trigger\r\n ref={ref}\r\n {...otherProps}\r\n render={useRender({\r\n defaultTagName: \"button\",\r\n render: renderProp as never,\r\n props: mergeProps({className: cn(styles.trigger, className)}, {}),\r\n })}>\r\n {renderProp ? undefined : children}\r\n </BaseCollapsible.Trigger>\r\n );\r\n },\r\n);\r\n\r\n/**\r\n * Renders the collapsible content.\r\n *\r\n * @remarks\r\n * - Renders a `<div>` element by default\r\n * - Built on {@link https://base-ui.com/react/components/collapsible | Base UI Collapsible}\r\n * - Supports the `render` prop for element composition\r\n *\r\n * @example\r\n * ```tsx\r\n * <CollapsibleContent>Content</CollapsibleContent>\r\n * ```\r\n *\r\n * @see {@link https://base-ui.com/react/components/collapsible | Base UI Documentation}\r\n */\r\nconst CollapsibleContent = React.forwardRef<React.ComponentRef<typeof BaseCollapsible.Panel>, CollapsibleContent.Props>(\r\n (props: Readonly<CollapsibleContent.Props>, ref): React.ReactElement => {\r\n const {className, children, render, ...otherProps} = props;\r\n\r\n return (\r\n <BaseCollapsible.Panel\r\n ref={ref}\r\n {...otherProps}\r\n render={useRender({\r\n defaultTagName: \"div\",\r\n render: render as never,\r\n props: mergeProps({className: cn(styles.panel, className)}, {}),\r\n })}>\r\n {children}\r\n </BaseCollapsible.Panel>\r\n );\r\n },\r\n);\r\n\r\n// eslint-disable-next-line no-redeclare -- required for the canonical component namespace typing API\r\nnamespace Collapsible {\r\n export type Props = CollapsibleProps;\r\n export type State = BaseCollapsible.Root.State;\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare -- required for the canonical component namespace typing API\r\nnamespace CollapsibleTrigger {\r\n export type Props = CollapsibleTriggerProps;\r\n export type State = BaseCollapsible.Trigger.State;\r\n}\r\n\r\n// eslint-disable-next-line no-redeclare -- required for the canonical component namespace typing API\r\nnamespace CollapsibleContent {\r\n export type Props = CollapsibleContentProps;\r\n export type State = BaseCollapsible.Panel.State;\r\n}\r\n\r\nCollapsible.displayName = \"Collapsible\";\r\nCollapsibleTrigger.displayName = \"CollapsibleTrigger\";\r\nCollapsibleContent.displayName = \"CollapsibleContent\";\r\n\r\nexport {Collapsible, CollapsibleContent, CollapsibleTrigger};\r\n"],"names":["Collapsible","props","BaseCollapsible","CollapsibleTrigger","React","ref","asChild","children","className","render","otherProps","renderProp","useRender","mergeProps","cn","styles","undefined","CollapsibleContent"],"mappings":";;;;;;;;AAiDA,SAASA,wBAAYC,KAAkC;IACrD,OAAO,WAAP,GAAO,IAACC,YAAAA,IAAoB;QAAE,GAAGD,KAAK;;AACxC;AAiBA,MAAME,qBAAqB,WAAHA,GAAGC,WACzB,CAACH,OAA2CI;IAE1C,MAAM,EAACC,UAAU,KAAK,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,MAAM,EAAE,GAAGC,YAAW,GAAGT;IACtE,MAAMU,aAAaL,WAAW,WAAXA,GAAWF,eAAqBG,YAAYA,WAAWE;IAE1E,OAAO,WAAP,GACE,IAACP,YAAAA,OAAuB;QACtB,KAAKG;QACJ,GAAGK,UAAU;QACd,QAAQE,UAAU;YAChB,gBAAgB;YAChB,QAAQD;YACR,OAAOE,WAAW;gBAAC,WAAWC,GAAGC,mBAAAA,OAAc,EAAEP;YAAU,GAAG,CAAC;QACjE;kBACCG,aAAaK,SAAYT;;AAGhC;AAkBF,MAAMU,qBAAqB,WAAHA,GAAGb,WACzB,CAACH,OAA2CI;IAC1C,MAAM,EAACG,SAAS,EAAED,QAAQ,EAAEE,MAAM,EAAE,GAAGC,YAAW,GAAGT;IAErD,OAAO,WAAP,GACE,IAACC,YAAAA,KAAqB;QACpB,KAAKG;QACJ,GAAGK,UAAU;QACd,QAAQE,UAAU;YAChB,gBAAgB;YAChB,QAAQH;YACR,OAAOI,WAAW;gBAAC,WAAWC,GAAGC,mBAAAA,KAAY,EAAEP;YAAU,GAAG,CAAC;QAC/D;kBACCD;;AAGP;AAqBFP,wBAAY,WAAW,GAAG;AAC1BG,mBAAmB,WAAW,GAAG;AACjCc,mBAAmB,WAAW,GAAG"}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
interface ComboboxProps {
|
|
3
|
+
/**
|
|
4
|
+
* The controlled selected value.
|
|
5
|
+
* @default undefined
|
|
6
|
+
*/
|
|
7
|
+
value?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The default value when uncontrolled.
|
|
10
|
+
* @default ""
|
|
11
|
+
*/
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Callback fired when the selected value changes.
|
|
15
|
+
* @default undefined
|
|
16
|
+
*/
|
|
17
|
+
onValueChange?: (value: string) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the popover is controlled open state.
|
|
20
|
+
* @default undefined
|
|
21
|
+
*/
|
|
22
|
+
open?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the popover is open by default (uncontrolled).
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
defaultOpen?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Callback fired when the open state changes.
|
|
30
|
+
* @default undefined
|
|
31
|
+
*/
|
|
32
|
+
onOpenChange?: (open: boolean) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Placeholder text shown when no value is selected.
|
|
35
|
+
* @default "Select an item..."
|
|
36
|
+
*/
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Placeholder text shown in the search input.
|
|
40
|
+
* @default "Search..."
|
|
41
|
+
*/
|
|
42
|
+
searchPlaceholder?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Message shown when no items match the search.
|
|
45
|
+
* @default "No items found."
|
|
46
|
+
*/
|
|
47
|
+
emptyMessage?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Whether the combobox is disabled.
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
disabled?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Additional CSS classes merged with the combobox styles.
|
|
55
|
+
* @default undefined
|
|
56
|
+
*/
|
|
57
|
+
className?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Combobox content and items.
|
|
60
|
+
* @default undefined
|
|
61
|
+
*/
|
|
62
|
+
children?: React.ReactNode;
|
|
63
|
+
}
|
|
64
|
+
interface ComboboxTriggerProps {
|
|
65
|
+
/**
|
|
66
|
+
* Additional CSS classes merged with the trigger styles.
|
|
67
|
+
* @default undefined
|
|
68
|
+
*/
|
|
69
|
+
className?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Trigger content. If not provided, shows selected item label or placeholder.
|
|
72
|
+
* @default undefined
|
|
73
|
+
*/
|
|
74
|
+
children?: React.ReactNode;
|
|
75
|
+
}
|
|
76
|
+
interface ComboboxContentProps {
|
|
77
|
+
/**
|
|
78
|
+
* Additional CSS classes merged with the content styles.
|
|
79
|
+
* @default undefined
|
|
80
|
+
*/
|
|
81
|
+
className?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Content children (typically ComboboxItem components).
|
|
84
|
+
* @default undefined
|
|
85
|
+
*/
|
|
86
|
+
children?: React.ReactNode;
|
|
87
|
+
}
|
|
88
|
+
interface ComboboxItemProps {
|
|
89
|
+
/**
|
|
90
|
+
* The value associated with this item.
|
|
91
|
+
*/
|
|
92
|
+
value: string;
|
|
93
|
+
/**
|
|
94
|
+
* Additional CSS classes merged with the item styles.
|
|
95
|
+
* @default undefined
|
|
96
|
+
*/
|
|
97
|
+
className?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Item content (label).
|
|
100
|
+
* @default undefined
|
|
101
|
+
*/
|
|
102
|
+
children?: React.ReactNode;
|
|
103
|
+
/**
|
|
104
|
+
* Whether the item is disabled.
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
107
|
+
disabled?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Callback fired when the item is selected.
|
|
110
|
+
* @default undefined
|
|
111
|
+
*/
|
|
112
|
+
onSelect?: (value: string) => void;
|
|
113
|
+
/**
|
|
114
|
+
* Additional search keywords for filtering.
|
|
115
|
+
* @default []
|
|
116
|
+
*/
|
|
117
|
+
keywords?: string[];
|
|
118
|
+
}
|
|
119
|
+
interface ComboboxEmptyProps {
|
|
120
|
+
/**
|
|
121
|
+
* Additional CSS classes merged with the empty state styles.
|
|
122
|
+
* @default undefined
|
|
123
|
+
*/
|
|
124
|
+
className?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Content shown when no items match. Defaults to context emptyMessage.
|
|
127
|
+
* @default undefined
|
|
128
|
+
*/
|
|
129
|
+
children?: React.ReactNode;
|
|
130
|
+
}
|
|
131
|
+
interface ComboboxGroupProps {
|
|
132
|
+
/**
|
|
133
|
+
* Group heading text.
|
|
134
|
+
* @default undefined
|
|
135
|
+
*/
|
|
136
|
+
heading?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Additional CSS classes merged with the group styles.
|
|
139
|
+
* @default undefined
|
|
140
|
+
*/
|
|
141
|
+
className?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Group items.
|
|
144
|
+
* @default undefined
|
|
145
|
+
*/
|
|
146
|
+
children?: React.ReactNode;
|
|
147
|
+
}
|
|
148
|
+
interface ComboboxSeparatorProps {
|
|
149
|
+
/**
|
|
150
|
+
* Additional CSS classes merged with the separator styles.
|
|
151
|
+
* @default undefined
|
|
152
|
+
*/
|
|
153
|
+
className?: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* A searchable select component combining Command, Popover, and Button.
|
|
157
|
+
*
|
|
158
|
+
* @remarks
|
|
159
|
+
* - Composes Command (search), Popover (positioning), and Button (trigger)
|
|
160
|
+
* - Supports both controlled and uncontrolled modes
|
|
161
|
+
* - Provides keyboard navigation and filtering
|
|
162
|
+
* - Built with Base UI primitives and CSS Modules
|
|
163
|
+
*
|
|
164
|
+
* @example Basic usage
|
|
165
|
+
* ```tsx
|
|
166
|
+
* <Combobox value={value} onValueChange={setValue}>
|
|
167
|
+
* <ComboboxTrigger />
|
|
168
|
+
* <ComboboxContent>
|
|
169
|
+
* <ComboboxItem value="apple">Apple</ComboboxItem>
|
|
170
|
+
* <ComboboxItem value="banana">Banana</ComboboxItem>
|
|
171
|
+
* </ComboboxContent>
|
|
172
|
+
* </Combobox>
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @example With groups
|
|
176
|
+
* ```tsx
|
|
177
|
+
* <Combobox>
|
|
178
|
+
* <ComboboxTrigger />
|
|
179
|
+
* <ComboboxContent>
|
|
180
|
+
* <ComboboxGroup heading="Fruits">
|
|
181
|
+
* <ComboboxItem value="apple">Apple</ComboboxItem>
|
|
182
|
+
* </ComboboxGroup>
|
|
183
|
+
* <ComboboxSeparator />
|
|
184
|
+
* <ComboboxGroup heading="Vegetables">
|
|
185
|
+
* <ComboboxItem value="carrot">Carrot</ComboboxItem>
|
|
186
|
+
* </ComboboxGroup>
|
|
187
|
+
* </ComboboxContent>
|
|
188
|
+
* </Combobox>
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
declare function Combobox(props: Readonly<Combobox.Props>): React.ReactElement;
|
|
192
|
+
declare namespace Combobox {
|
|
193
|
+
var displayName: string;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Button that opens and closes the combobox popover.
|
|
197
|
+
*
|
|
198
|
+
* @remarks
|
|
199
|
+
* - Renders as a Button with trigger behavior
|
|
200
|
+
* - Shows selected item label or placeholder
|
|
201
|
+
* - Supports custom children or auto-display
|
|
202
|
+
*
|
|
203
|
+
* @example Basic usage
|
|
204
|
+
* ```tsx
|
|
205
|
+
* <ComboboxTrigger />
|
|
206
|
+
* ```
|
|
207
|
+
*
|
|
208
|
+
* @example Custom content
|
|
209
|
+
* ```tsx
|
|
210
|
+
* <ComboboxTrigger>
|
|
211
|
+
* {selectedLabel || "Choose..."}
|
|
212
|
+
* </ComboboxTrigger>
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
declare const ComboboxTrigger: React.ForwardRefExoticComponent<ComboboxTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
216
|
+
/**
|
|
217
|
+
* The popover content containing the searchable command list.
|
|
218
|
+
*
|
|
219
|
+
* @remarks
|
|
220
|
+
* - Wraps Command with Popover positioning
|
|
221
|
+
* - Includes search input and items list
|
|
222
|
+
* - Automatically closes on item selection
|
|
223
|
+
*
|
|
224
|
+
* @example Basic usage
|
|
225
|
+
* ```tsx
|
|
226
|
+
* <ComboboxContent>
|
|
227
|
+
* <ComboboxItem value="item1">Item 1</ComboboxItem>
|
|
228
|
+
* </ComboboxContent>
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
declare const ComboboxContent: React.ForwardRefExoticComponent<ComboboxContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
232
|
+
/**
|
|
233
|
+
* A selectable item within the combobox.
|
|
234
|
+
*
|
|
235
|
+
* @remarks
|
|
236
|
+
* - Uses CommandItem internally
|
|
237
|
+
* - Shows check icon when selected
|
|
238
|
+
* - Closes popover on selection
|
|
239
|
+
*
|
|
240
|
+
* @example Basic usage
|
|
241
|
+
* ```tsx
|
|
242
|
+
* <ComboboxItem value="apple">Apple</ComboboxItem>
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @example With custom select handler
|
|
246
|
+
* ```tsx
|
|
247
|
+
* <ComboboxItem
|
|
248
|
+
* value="apple"
|
|
249
|
+
* onSelect={(value) => console.log("Selected:", value)}
|
|
250
|
+
* >
|
|
251
|
+
* Apple
|
|
252
|
+
* </ComboboxItem>
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
declare function ComboboxItem(props: Readonly<ComboboxItem.Props>): React.ReactElement;
|
|
256
|
+
declare namespace ComboboxItem {
|
|
257
|
+
var displayName: string;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Message shown when search returns no results.
|
|
261
|
+
*
|
|
262
|
+
* @remarks
|
|
263
|
+
* - Uses CommandEmpty internally
|
|
264
|
+
* - Defaults to context emptyMessage
|
|
265
|
+
*
|
|
266
|
+
* @example Basic usage
|
|
267
|
+
* ```tsx
|
|
268
|
+
* <ComboboxEmpty />
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* @example Custom message
|
|
272
|
+
* ```tsx
|
|
273
|
+
* <ComboboxEmpty>Nothing found</ComboboxEmpty>
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
declare function ComboboxEmpty(props: Readonly<ComboboxEmpty.Props>): React.ReactElement;
|
|
277
|
+
declare namespace ComboboxEmpty {
|
|
278
|
+
var displayName: string;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Groups related combobox items with an optional heading.
|
|
282
|
+
*
|
|
283
|
+
* @remarks
|
|
284
|
+
* - Uses CommandGroup internally
|
|
285
|
+
* - Supports visual grouping with headings
|
|
286
|
+
*
|
|
287
|
+
* @example Basic usage
|
|
288
|
+
* ```tsx
|
|
289
|
+
* <ComboboxGroup heading="Fruits">
|
|
290
|
+
* <ComboboxItem value="apple">Apple</ComboboxItem>
|
|
291
|
+
* </ComboboxGroup>
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
declare function ComboboxGroup(props: Readonly<ComboboxGroup.Props>): React.ReactElement;
|
|
295
|
+
declare namespace ComboboxGroup {
|
|
296
|
+
var displayName: string;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Visual separator between combobox groups.
|
|
300
|
+
*
|
|
301
|
+
* @remarks
|
|
302
|
+
* - Uses CommandSeparator internally
|
|
303
|
+
*
|
|
304
|
+
* @example Basic usage
|
|
305
|
+
* ```tsx
|
|
306
|
+
* <ComboboxSeparator />
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
declare function ComboboxSeparator(props: Readonly<ComboboxSeparator.Props>): React.ReactElement;
|
|
310
|
+
declare namespace ComboboxSeparator {
|
|
311
|
+
var displayName: string;
|
|
312
|
+
}
|
|
313
|
+
declare namespace Combobox {
|
|
314
|
+
type Props = ComboboxProps;
|
|
315
|
+
}
|
|
316
|
+
declare namespace ComboboxTrigger {
|
|
317
|
+
type Props = ComboboxTriggerProps;
|
|
318
|
+
}
|
|
319
|
+
declare namespace ComboboxContent {
|
|
320
|
+
type Props = ComboboxContentProps;
|
|
321
|
+
}
|
|
322
|
+
declare namespace ComboboxItem {
|
|
323
|
+
type Props = ComboboxItemProps;
|
|
324
|
+
}
|
|
325
|
+
declare namespace ComboboxEmpty {
|
|
326
|
+
type Props = ComboboxEmptyProps;
|
|
327
|
+
}
|
|
328
|
+
declare namespace ComboboxGroup {
|
|
329
|
+
type Props = ComboboxGroupProps;
|
|
330
|
+
}
|
|
331
|
+
declare namespace ComboboxSeparator {
|
|
332
|
+
type Props = ComboboxSeparatorProps;
|
|
333
|
+
}
|
|
334
|
+
export { Combobox, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxItem, ComboboxSeparator, ComboboxTrigger };
|
|
335
|
+
//# sourceMappingURL=combobox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../src/components/ui/combobox.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Check, ChevronsUpDown } from "lucide-react";
|
|
4
|
+
import { createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useReducer, useRef } from "react";
|
|
5
|
+
import { useControllableState } from "../../hooks/useControllableState.js";
|
|
6
|
+
import { cn } from "../../lib/utilities.js";
|
|
7
|
+
import { Button } from "./button.js";
|
|
8
|
+
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from "./command.js";
|
|
9
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
10
|
+
import combobox_module from "./combobox.module.js";
|
|
11
|
+
const ComboboxContext = /*#__PURE__*/ createContext(null);
|
|
12
|
+
function useComboboxContext(componentName) {
|
|
13
|
+
const context = useContext(ComboboxContext);
|
|
14
|
+
if (!context) throw new Error(`${componentName} must be used within Combobox.`);
|
|
15
|
+
return context;
|
|
16
|
+
}
|
|
17
|
+
function Combobox(props) {
|
|
18
|
+
const { value: controlledValue, defaultValue = "", onValueChange, open: controlledOpen, defaultOpen = false, onOpenChange, placeholder = "Select an item...", searchPlaceholder = "Search...", emptyMessage = "No items found.", disabled = false, className, children } = props;
|
|
19
|
+
const [value, setValue] = useControllableState({
|
|
20
|
+
controlled: controlledValue,
|
|
21
|
+
defaultValue,
|
|
22
|
+
onChange: onValueChange
|
|
23
|
+
});
|
|
24
|
+
const [open, setOpen] = useControllableState({
|
|
25
|
+
controlled: controlledOpen,
|
|
26
|
+
defaultValue: defaultOpen,
|
|
27
|
+
onChange: onOpenChange
|
|
28
|
+
});
|
|
29
|
+
const itemLabelsRef = useRef(new Map());
|
|
30
|
+
const registerItem = useCallback((itemValue, label)=>{
|
|
31
|
+
itemLabelsRef.current.set(itemValue, label);
|
|
32
|
+
}, []);
|
|
33
|
+
const unregisterItem = useCallback((itemValue)=>{
|
|
34
|
+
itemLabelsRef.current.delete(itemValue);
|
|
35
|
+
}, []);
|
|
36
|
+
const contextValue = useMemo(()=>({
|
|
37
|
+
value,
|
|
38
|
+
onValueChange: setValue,
|
|
39
|
+
open,
|
|
40
|
+
setOpen,
|
|
41
|
+
placeholder,
|
|
42
|
+
searchPlaceholder,
|
|
43
|
+
emptyMessage,
|
|
44
|
+
disabled,
|
|
45
|
+
itemLabels: itemLabelsRef.current,
|
|
46
|
+
registerItem,
|
|
47
|
+
unregisterItem
|
|
48
|
+
}), [
|
|
49
|
+
value,
|
|
50
|
+
setValue,
|
|
51
|
+
open,
|
|
52
|
+
setOpen,
|
|
53
|
+
placeholder,
|
|
54
|
+
searchPlaceholder,
|
|
55
|
+
emptyMessage,
|
|
56
|
+
disabled,
|
|
57
|
+
registerItem,
|
|
58
|
+
unregisterItem
|
|
59
|
+
]);
|
|
60
|
+
return /*#__PURE__*/ jsx(ComboboxContext.Provider, {
|
|
61
|
+
value: contextValue,
|
|
62
|
+
children: /*#__PURE__*/ jsx(Popover, {
|
|
63
|
+
open: open,
|
|
64
|
+
onOpenChange: setOpen,
|
|
65
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
66
|
+
className: cn(combobox_module.combobox, className),
|
|
67
|
+
children: children
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
Combobox.displayName = "Combobox";
|
|
73
|
+
const ComboboxTrigger = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
74
|
+
const { className, children } = props;
|
|
75
|
+
const { open, setOpen, value, placeholder, disabled, itemLabels } = useComboboxContext("ComboboxTrigger");
|
|
76
|
+
const [, forceUpdate] = useReducer((x)=>x + 1, 0);
|
|
77
|
+
useEffect(()=>{
|
|
78
|
+
forceUpdate();
|
|
79
|
+
}, [
|
|
80
|
+
value
|
|
81
|
+
]);
|
|
82
|
+
const selectedLabel = itemLabels.get(value) || "";
|
|
83
|
+
return /*#__PURE__*/ jsx(PopoverTrigger, {
|
|
84
|
+
asChild: true,
|
|
85
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
86
|
+
ref: ref,
|
|
87
|
+
variant: "outline",
|
|
88
|
+
role: "combobox",
|
|
89
|
+
"aria-expanded": open,
|
|
90
|
+
disabled: disabled,
|
|
91
|
+
className: cn(combobox_module.trigger, className),
|
|
92
|
+
onClick: ()=>setOpen(!open),
|
|
93
|
+
children: children ?? /*#__PURE__*/ jsxs(Fragment, {
|
|
94
|
+
children: [
|
|
95
|
+
/*#__PURE__*/ jsx("span", {
|
|
96
|
+
className: cn(combobox_module.triggerValue, !selectedLabel && combobox_module.triggerPlaceholder),
|
|
97
|
+
children: selectedLabel || placeholder
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ jsx(ChevronsUpDown, {
|
|
100
|
+
className: combobox_module.triggerIcon
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
ComboboxTrigger.displayName = "ComboboxTrigger";
|
|
108
|
+
const ComboboxContent = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
109
|
+
const { className, children } = props;
|
|
110
|
+
const { searchPlaceholder } = useComboboxContext("ComboboxContent");
|
|
111
|
+
return /*#__PURE__*/ jsx(PopoverContent, {
|
|
112
|
+
ref: ref,
|
|
113
|
+
className: cn(combobox_module.content, className),
|
|
114
|
+
sideOffset: 4,
|
|
115
|
+
children: /*#__PURE__*/ jsxs(Command, {
|
|
116
|
+
className: combobox_module.command,
|
|
117
|
+
children: [
|
|
118
|
+
/*#__PURE__*/ jsx(CommandInput, {
|
|
119
|
+
placeholder: searchPlaceholder,
|
|
120
|
+
className: combobox_module.commandInput
|
|
121
|
+
}),
|
|
122
|
+
/*#__PURE__*/ jsxs(CommandList, {
|
|
123
|
+
className: combobox_module.commandList,
|
|
124
|
+
children: [
|
|
125
|
+
/*#__PURE__*/ jsx(ComboboxEmpty, {}),
|
|
126
|
+
children
|
|
127
|
+
]
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
})
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
ComboboxContent.displayName = "ComboboxContent";
|
|
134
|
+
function ComboboxItem(props) {
|
|
135
|
+
const { value: itemValue, className, children, disabled = false, onSelect, keywords = [] } = props;
|
|
136
|
+
const { value: selectedValue, onValueChange, setOpen, registerItem, unregisterItem } = useComboboxContext("ComboboxItem");
|
|
137
|
+
const isSelected = selectedValue === itemValue;
|
|
138
|
+
const label = "string" == typeof children ? children : itemValue;
|
|
139
|
+
useEffect(()=>{
|
|
140
|
+
registerItem(itemValue, label);
|
|
141
|
+
return ()=>{
|
|
142
|
+
unregisterItem(itemValue);
|
|
143
|
+
};
|
|
144
|
+
}, [
|
|
145
|
+
itemValue,
|
|
146
|
+
label,
|
|
147
|
+
registerItem,
|
|
148
|
+
unregisterItem
|
|
149
|
+
]);
|
|
150
|
+
const handleSelect = useCallback((currentValue)=>{
|
|
151
|
+
const newValue = currentValue === selectedValue ? "" : currentValue;
|
|
152
|
+
onValueChange(newValue);
|
|
153
|
+
setOpen(false);
|
|
154
|
+
onSelect?.(newValue);
|
|
155
|
+
}, [
|
|
156
|
+
selectedValue,
|
|
157
|
+
onValueChange,
|
|
158
|
+
setOpen,
|
|
159
|
+
onSelect
|
|
160
|
+
]);
|
|
161
|
+
return /*#__PURE__*/ jsxs(CommandItem, {
|
|
162
|
+
value: itemValue,
|
|
163
|
+
disabled: disabled,
|
|
164
|
+
onSelect: handleSelect,
|
|
165
|
+
keywords: keywords,
|
|
166
|
+
className: cn(combobox_module.item, isSelected && combobox_module.itemSelected, className),
|
|
167
|
+
children: [
|
|
168
|
+
/*#__PURE__*/ jsx(Check, {
|
|
169
|
+
className: cn(combobox_module.itemCheck, isSelected && combobox_module.itemCheckVisible)
|
|
170
|
+
}),
|
|
171
|
+
/*#__PURE__*/ jsx("span", {
|
|
172
|
+
className: combobox_module.itemLabel,
|
|
173
|
+
children: children
|
|
174
|
+
})
|
|
175
|
+
]
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
ComboboxItem.displayName = "ComboboxItem";
|
|
179
|
+
function ComboboxEmpty(props) {
|
|
180
|
+
const { className, children } = props;
|
|
181
|
+
const { emptyMessage } = useComboboxContext("ComboboxEmpty");
|
|
182
|
+
return /*#__PURE__*/ jsx(CommandEmpty, {
|
|
183
|
+
className: cn(combobox_module.empty, className),
|
|
184
|
+
children: children ?? emptyMessage
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
ComboboxEmpty.displayName = "ComboboxEmpty";
|
|
188
|
+
function ComboboxGroup(props) {
|
|
189
|
+
const { heading, className, children } = props;
|
|
190
|
+
return /*#__PURE__*/ jsx(CommandGroup, {
|
|
191
|
+
heading: heading,
|
|
192
|
+
className: cn(combobox_module.group, className),
|
|
193
|
+
children: children
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
ComboboxGroup.displayName = "ComboboxGroup";
|
|
197
|
+
function ComboboxSeparator(props) {
|
|
198
|
+
const { className } = props;
|
|
199
|
+
return /*#__PURE__*/ jsx(CommandSeparator, {
|
|
200
|
+
className: cn(combobox_module.separator, className)
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
ComboboxSeparator.displayName = "ComboboxSeparator";
|
|
204
|
+
export { Combobox, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxItem, ComboboxSeparator, ComboboxTrigger };
|
|
205
|
+
|
|
206
|
+
//# sourceMappingURL=combobox.js.map
|