@baseplate-dev/ui-components 0.6.2 → 1.0.7
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 +9 -0
- package/LICENSE +114 -123
- package/dist/base-styles.css +5 -4
- package/dist/components/ui/async-combobox-field/async-combobox-field.d.ts +7 -5
- package/dist/components/ui/async-combobox-field/async-combobox-field.d.ts.map +1 -1
- package/dist/components/ui/async-combobox-field/async-combobox-field.js +142 -135
- package/dist/components/ui/async-combobox-field/async-combobox-field.js.map +1 -1
- package/dist/components/ui/async-combobox-field/async-combobox-field.unit.test.d.ts +2 -0
- package/dist/components/ui/async-combobox-field/async-combobox-field.unit.test.d.ts.map +1 -0
- package/dist/components/ui/async-combobox-field/async-combobox-field.unit.test.js +147 -0
- package/dist/components/ui/async-combobox-field/async-combobox-field.unit.test.js.map +1 -0
- package/dist/components/ui/autocomplete/autocomplete.d.ts +32 -0
- package/dist/components/ui/autocomplete/autocomplete.d.ts.map +1 -0
- package/dist/components/ui/autocomplete/autocomplete.js +59 -0
- package/dist/components/ui/autocomplete/autocomplete.js.map +1 -0
- package/dist/components/ui/badge/badge.d.ts +4 -11
- package/dist/components/ui/badge/badge.d.ts.map +1 -1
- package/dist/components/ui/badge/badge.js +22 -16
- package/dist/components/ui/badge/badge.js.map +1 -1
- package/dist/components/ui/breadcrumb/breadcrumb.d.ts +8 -4
- package/dist/components/ui/breadcrumb/breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/breadcrumb/breadcrumb.js +24 -9
- package/dist/components/ui/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/components/ui/button/button.d.ts +5 -5
- package/dist/components/ui/button/button.d.ts.map +1 -1
- package/dist/components/ui/button/button.js +4 -5
- package/dist/components/ui/button/button.js.map +1 -1
- package/dist/components/ui/checkbox/checkbox.d.ts +2 -3
- package/dist/components/ui/checkbox/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox/checkbox.js +2 -2
- package/dist/components/ui/checkbox/checkbox.js.map +1 -1
- package/dist/components/ui/checkbox-field/checkbox-field.d.ts +2 -2
- package/dist/components/ui/checkbox-field/checkbox-field.d.ts.map +1 -1
- package/dist/components/ui/checkbox-field/checkbox-field.js +8 -5
- package/dist/components/ui/checkbox-field/checkbox-field.js.map +1 -1
- package/dist/components/ui/code-editor-field/code-editor-field.d.ts.map +1 -1
- package/dist/components/ui/code-editor-field/code-editor-field.js +7 -7
- package/dist/components/ui/code-editor-field/code-editor-field.js.map +1 -1
- package/dist/components/ui/collapsible/collapsible.d.ts +4 -5
- package/dist/components/ui/collapsible/collapsible.d.ts.map +1 -1
- package/dist/components/ui/collapsible/collapsible.js +3 -4
- package/dist/components/ui/collapsible/collapsible.js.map +1 -1
- package/dist/components/ui/color-picker-field/color-picker-field.d.ts.map +1 -1
- package/dist/components/ui/color-picker-field/color-picker-field.js +9 -9
- package/dist/components/ui/color-picker-field/color-picker-field.js.map +1 -1
- package/dist/components/ui/combobox/combobox.d.ts +31 -69
- package/dist/components/ui/combobox/combobox.d.ts.map +1 -1
- package/dist/components/ui/combobox/combobox.js +62 -167
- package/dist/components/ui/combobox/combobox.js.map +1 -1
- package/dist/components/ui/combobox-field/combobox-field.d.ts +7 -3
- package/dist/components/ui/combobox-field/combobox-field.d.ts.map +1 -1
- package/dist/components/ui/combobox-field/combobox-field.js +15 -23
- package/dist/components/ui/combobox-field/combobox-field.js.map +1 -1
- package/dist/components/ui/date-picker-field/date-picker-field.d.ts.map +1 -1
- package/dist/components/ui/date-picker-field/date-picker-field.js +3 -3
- package/dist/components/ui/date-picker-field/date-picker-field.js.map +1 -1
- package/dist/components/ui/date-time-picker-field/date-time-picker-field.d.ts.map +1 -1
- package/dist/components/ui/date-time-picker-field/date-time-picker-field.js +3 -3
- package/dist/components/ui/date-time-picker-field/date-time-picker-field.js.map +1 -1
- package/dist/components/ui/dialog/dialog.d.ts +15 -13
- package/dist/components/ui/dialog/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog/dialog.js +12 -13
- package/dist/components/ui/dialog/dialog.js.map +1 -1
- package/dist/components/ui/dropdown/dropdown.d.ts +24 -16
- package/dist/components/ui/dropdown/dropdown.d.ts.map +1 -1
- package/dist/components/ui/dropdown/dropdown.js +31 -27
- package/dist/components/ui/dropdown/dropdown.js.map +1 -1
- package/dist/components/ui/field/field.d.ts +34 -0
- package/dist/components/ui/field/field.d.ts.map +1 -0
- package/dist/components/ui/field/field.js +77 -0
- package/dist/components/ui/field/field.js.map +1 -0
- package/dist/components/ui/form-action-bar/form-action-bar.d.ts.map +1 -1
- package/dist/components/ui/form-action-bar/form-action-bar.js +1 -1
- package/dist/components/ui/form-action-bar/form-action-bar.js.map +1 -1
- package/dist/components/ui/form-item/form-item.d.ts +6 -4
- package/dist/components/ui/form-item/form-item.d.ts.map +1 -1
- package/dist/components/ui/form-item/form-item.js +17 -3
- package/dist/components/ui/form-item/form-item.js.map +1 -1
- package/dist/components/ui/index.d.ts +5 -3
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +5 -3
- package/dist/components/ui/index.js.map +1 -1
- package/dist/components/ui/input-field/input-field.d.ts.map +1 -1
- package/dist/components/ui/input-field/input-field.js +7 -5
- package/dist/components/ui/input-field/input-field.js.map +1 -1
- package/dist/components/ui/input-group/input-group.d.ts +26 -0
- package/dist/components/ui/input-group/input-group.d.ts.map +1 -0
- package/dist/components/ui/input-group/input-group.js +65 -0
- package/dist/components/ui/input-group/input-group.js.map +1 -0
- package/dist/components/ui/label/label.d.ts +1 -2
- package/dist/components/ui/label/label.d.ts.map +1 -1
- package/dist/components/ui/label/label.js +3 -2
- package/dist/components/ui/label/label.js.map +1 -1
- package/dist/components/ui/multi-combobox-field/multi-combobox-field.d.ts +2 -2
- package/dist/components/ui/multi-combobox-field/multi-combobox-field.d.ts.map +1 -1
- package/dist/components/ui/multi-combobox-field/multi-combobox-field.js +23 -24
- package/dist/components/ui/multi-combobox-field/multi-combobox-field.js.map +1 -1
- package/dist/components/ui/multi-switch-field/multi-switch-field.js +3 -3
- package/dist/components/ui/multi-switch-field/multi-switch-field.js.map +1 -1
- package/dist/components/ui/navigation-menu/navigation-menu.d.ts +16 -15
- package/dist/components/ui/navigation-menu/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu/navigation-menu.js +17 -16
- package/dist/components/ui/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/ui/navigation-tabs/navigation-tabs.d.ts +6 -3
- package/dist/components/ui/navigation-tabs/navigation-tabs.d.ts.map +1 -1
- package/dist/components/ui/navigation-tabs/navigation-tabs.js +16 -4
- package/dist/components/ui/navigation-tabs/navigation-tabs.js.map +1 -1
- package/dist/components/ui/popover/popover.d.ts +8 -10
- package/dist/components/ui/popover/popover.d.ts.map +1 -1
- package/dist/components/ui/popover/popover.js +12 -6
- package/dist/components/ui/popover/popover.js.map +1 -1
- package/dist/components/ui/scroll-area/scroll-area.d.ts +3 -4
- package/dist/components/ui/scroll-area/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/scroll-area/scroll-area.js +2 -4
- package/dist/components/ui/scroll-area/scroll-area.js.map +1 -1
- package/dist/components/ui/select/select.d.ts +12 -17
- package/dist/components/ui/select/select.d.ts.map +1 -1
- package/dist/components/ui/select/select.js +20 -30
- package/dist/components/ui/select/select.js.map +1 -1
- package/dist/components/ui/select-field/select-field.d.ts +1 -0
- package/dist/components/ui/select-field/select-field.d.ts.map +1 -1
- package/dist/components/ui/select-field/select-field.js +6 -12
- package/dist/components/ui/select-field/select-field.js.map +1 -1
- package/dist/components/ui/separator/separator.d.ts +2 -3
- package/dist/components/ui/separator/separator.d.ts.map +1 -1
- package/dist/components/ui/separator/separator.js +3 -3
- package/dist/components/ui/separator/separator.js.map +1 -1
- package/dist/components/ui/sheet/sheet.d.ts +11 -11
- package/dist/components/ui/sheet/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet/sheet.js +7 -10
- package/dist/components/ui/sheet/sheet.js.map +1 -1
- package/dist/components/ui/sidebar/sidebar.d.ts +6 -12
- package/dist/components/ui/sidebar/sidebar.d.ts.map +1 -1
- package/dist/components/ui/sidebar/sidebar.js +79 -28
- package/dist/components/ui/sidebar/sidebar.js.map +1 -1
- package/dist/components/ui/skeleton/skeleton.js +1 -1
- package/dist/components/ui/skeleton/skeleton.js.map +1 -1
- package/dist/components/ui/slider/slider.d.ts +13 -0
- package/dist/components/ui/slider/slider.d.ts.map +1 -0
- package/dist/components/ui/slider/slider.js +22 -0
- package/dist/components/ui/slider/slider.js.map +1 -0
- package/dist/components/ui/spinner/spinner.d.ts +10 -0
- package/dist/components/ui/spinner/spinner.d.ts.map +1 -0
- package/dist/components/ui/spinner/spinner.js +13 -0
- package/dist/components/ui/spinner/spinner.js.map +1 -0
- package/dist/components/ui/switch/switch.d.ts +7 -3
- package/dist/components/ui/switch/switch.d.ts.map +1 -1
- package/dist/components/ui/switch/switch.js +6 -3
- package/dist/components/ui/switch/switch.js.map +1 -1
- package/dist/components/ui/switch-field/switch-field.d.ts +5 -3
- package/dist/components/ui/switch-field/switch-field.d.ts.map +1 -1
- package/dist/components/ui/switch-field/switch-field.js +7 -4
- package/dist/components/ui/switch-field/switch-field.js.map +1 -1
- package/dist/components/ui/tabs/tabs.d.ts +13 -7
- package/dist/components/ui/tabs/tabs.d.ts.map +1 -1
- package/dist/components/ui/tabs/tabs.js +23 -8
- package/dist/components/ui/tabs/tabs.js.map +1 -1
- package/dist/components/ui/textarea/textarea.js +1 -1
- package/dist/components/ui/textarea/textarea.js.map +1 -1
- package/dist/components/ui/textarea-field/textarea-field.d.ts.map +1 -1
- package/dist/components/ui/textarea-field/textarea-field.js +7 -5
- package/dist/components/ui/textarea-field/textarea-field.js.map +1 -1
- package/dist/components/ui/tooltip/tooltip.d.ts +10 -6
- package/dist/components/ui/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip/tooltip.js +11 -6
- package/dist/components/ui/tooltip/tooltip.js.map +1 -1
- package/dist/constants/strings.d.ts +1 -0
- package/dist/constants/strings.d.ts.map +1 -1
- package/dist/constants/strings.js +1 -0
- package/dist/constants/strings.js.map +1 -1
- package/dist/contexts/component-strings.d.ts +1 -0
- package/dist/contexts/component-strings.d.ts.map +1 -1
- package/dist/hooks/use-event-callback.d.ts +2 -2
- package/dist/hooks/use-event-callback.d.ts.map +1 -1
- package/dist/hooks/use-event-callback.js +2 -1
- package/dist/hooks/use-event-callback.js.map +1 -1
- package/dist/styles/button.d.ts +1 -1
- package/dist/styles/button.d.ts.map +1 -1
- package/dist/styles/button.js +15 -11
- package/dist/styles/button.js.map +1 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/index.d.ts.map +1 -1
- package/dist/styles/index.js +0 -1
- package/dist/styles/index.js.map +1 -1
- package/dist/theme.css +8 -0
- package/dist/utilities.css +100 -0
- package/package.json +10 -10
- package/dist/components/ui/color-picker/color-picker.d.ts +0 -16
- package/dist/components/ui/color-picker/color-picker.d.ts.map +0 -1
- package/dist/components/ui/color-picker/color-picker.js +0 -19
- package/dist/components/ui/color-picker/color-picker.js.map +0 -1
- package/dist/components/ui/combobox/combobox.test.d.ts +0 -2
- package/dist/components/ui/combobox/combobox.test.d.ts.map +0 -1
- package/dist/components/ui/combobox/combobox.test.js +0 -148
- package/dist/components/ui/combobox/combobox.test.js.map +0 -1
- package/dist/components/ui/command/command.d.ts +0 -22
- package/dist/components/ui/command/command.d.ts.map +0 -1
- package/dist/components/ui/command/command.js +0 -40
- package/dist/components/ui/command/command.js.map +0 -1
- package/dist/components/ui/multi-combobox/multi-combobox.d.ts +0 -47
- package/dist/components/ui/multi-combobox/multi-combobox.d.ts.map +0 -1
- package/dist/components/ui/multi-combobox/multi-combobox.js +0 -114
- package/dist/components/ui/multi-combobox/multi-combobox.js.map +0 -1
- package/dist/styles/select.d.ts +0 -9
- package/dist/styles/select.d.ts.map +0 -1
- package/dist/styles/select.js +0 -22
- package/dist/styles/select.js.map +0 -1
|
@@ -5,7 +5,7 @@ import { HexColorInput, HexColorPicker } from 'react-colorful';
|
|
|
5
5
|
import { useControllerMerged } from '#src/hooks/use-controller-merged.js';
|
|
6
6
|
import { buttonVariants, inputVariants } from '#src/styles/index.js';
|
|
7
7
|
import { cn } from '#src/utils/index.js';
|
|
8
|
-
import {
|
|
8
|
+
import { Field, FieldDescription, FieldError, FieldLabel, } from '../field/field.js';
|
|
9
9
|
import { Popover, PopoverContent, PopoverTrigger } from '../popover/popover.js';
|
|
10
10
|
/**
|
|
11
11
|
* Field with label and error states that wraps a ColorPicker component.
|
|
@@ -20,15 +20,15 @@ function ColorPickerField({ className, wrapperClassName, disabled, placeholder,
|
|
|
20
20
|
const newColorValue = serializeColor?.(newHexValue) ?? newHexValue;
|
|
21
21
|
onChange?.(newColorValue);
|
|
22
22
|
};
|
|
23
|
-
const inputComponent = (_jsxs(Popover, { children: [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
const inputComponent = (_jsxs(Popover, { children: [_jsxs(PopoverTrigger, { className: cn(buttonVariants({
|
|
24
|
+
variant: 'outline',
|
|
25
|
+
size: 'none',
|
|
26
|
+
justify: 'start',
|
|
27
|
+
}), className, 'flex h-8 items-center gap-2 px-2', hideText ? 'justify-center' : undefined, disabled ? 'opacity-75' : undefined), id: id, ref: ref, disabled: disabled, children: [hexValue && (_jsx("div", { className: "h-4 w-6 rounded-sm border border-border", style: {
|
|
28
|
+
backgroundColor: hexValue,
|
|
29
|
+
} })), hideText ? null : hexValue ? (_jsx("div", { children: formatColorName && value ? formatColorName(value) : hexValue })) : (_jsx("div", { className: "opacity-75", children: placeholder }))] }), _jsxs(PopoverContent, { sideOffset: 5, align: "start", className: "w-auto space-y-2 rounded-md border border-border bg-white p-4", children: [_jsx(HexColorInput, { className: cn(inputVariants(), 'p-2'), prefixed: true, color: hexValue ?? '', onChange: handleChange }), _jsx(HexColorPicker, { color: hexValue ?? '', onChange: handleChange })] })] }));
|
|
30
30
|
if (addWrapper) {
|
|
31
|
-
return (_jsxs(
|
|
31
|
+
return (_jsxs(Field, { "data-invalid": !!error, className: cn('gap-2', wrapperClassName), children: [_jsx(FieldLabel, { htmlFor: id, children: label }), inputComponent, _jsx(FieldDescription, { children: description }), _jsx(FieldError, { children: error })] }));
|
|
32
32
|
}
|
|
33
33
|
return inputComponent;
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-picker-field.js","sourceRoot":"","sources":["../../../../src/components/ui/color-picker-field/color-picker-field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAI/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAEzC,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"color-picker-field.js","sourceRoot":"","sources":["../../../../src/components/ui/color-picker-field/color-picker-field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAI/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAEzC,OAAO,EACL,KAAK,EACL,gBAAgB,EAChB,UAAU,EACV,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,uB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,KAAK,EAAE,OAAO,KAAM,IAAI,KAAM,UAAU,GAAI,CAAC;AAC/E,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -1,73 +1,35 @@
|
|
|
1
|
+
import { Combobox as ComboboxPrimitive } from '@base-ui/react/combobox';
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
interface ComboboxContextValue {
|
|
3
|
-
selectedValue: string | undefined | null;
|
|
4
|
-
selectedLabel: string | undefined | null;
|
|
5
|
-
onSelect: (value: string | null, label: string | undefined) => void;
|
|
6
|
-
searchQuery: string;
|
|
7
|
-
setSearchQuery: (query: string) => void;
|
|
8
|
-
setIsOpen: (open: boolean) => void;
|
|
9
|
-
isOpen: boolean;
|
|
10
|
-
inputId: string;
|
|
11
|
-
listRef: React.RefObject<HTMLDivElement | null>;
|
|
12
|
-
shouldShowItem: (label: string | null) => boolean;
|
|
13
|
-
disabled: boolean;
|
|
14
|
-
}
|
|
15
|
-
interface ComboboxOption {
|
|
16
|
-
label?: string;
|
|
17
|
-
value: string | null;
|
|
18
|
-
}
|
|
19
|
-
export interface ComboboxProps {
|
|
20
|
-
children: React.ReactNode;
|
|
21
|
-
value?: ComboboxOption | null;
|
|
22
|
-
onChange?: (value: ComboboxOption) => void;
|
|
23
|
-
searchQuery?: string;
|
|
24
|
-
onSearchQueryChange?: (query: string) => void;
|
|
25
|
-
label?: string;
|
|
26
|
-
disabled?: boolean;
|
|
27
|
-
}
|
|
28
3
|
/**
|
|
29
|
-
*
|
|
4
|
+
* An autocomplete input that allows users to filter and select from a list of options.
|
|
5
|
+
*
|
|
6
|
+
* ShadCN changes:
|
|
7
|
+
* - ComboboxList shows native scrollbar instead of no-scrollbar for better discoverability
|
|
8
|
+
*
|
|
9
|
+
* https://ui.shadcn.com/docs/components/combobox
|
|
30
10
|
*/
|
|
31
|
-
declare
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
declare function
|
|
44
|
-
|
|
45
|
-
declare function ComboboxEmpty({ className, ...props }:
|
|
46
|
-
|
|
47
|
-
declare function
|
|
48
|
-
declare
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
heading?: React.ReactNode;
|
|
56
|
-
value?: string;
|
|
57
|
-
forceMount?: boolean;
|
|
58
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
59
|
-
interface ComboboxItemProps extends Omit<React.ComponentPropsWithRef<'div'>, 'onSelect'> {
|
|
60
|
-
disabled?: boolean;
|
|
61
|
-
value: string | null;
|
|
62
|
-
label?: string;
|
|
63
|
-
}
|
|
64
|
-
declare function ComboboxItem({ value, className, label, children, ref, ...rest }: ComboboxItemProps): React.ReactElement;
|
|
65
|
-
interface ComboboxActionProps extends Omit<React.ComponentPropsWithRef<'div'>, 'onSelect' | 'onClick'> {
|
|
66
|
-
disabled?: boolean;
|
|
67
|
-
value: string;
|
|
68
|
-
label?: string;
|
|
69
|
-
onClick?: () => void;
|
|
70
|
-
}
|
|
71
|
-
declare function ComboboxAction({ value, className, children, onClick, ref, ...rest }: ComboboxActionProps): React.ReactElement;
|
|
72
|
-
export { Combobox, ComboboxAction, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLoading, };
|
|
11
|
+
declare const Combobox: typeof ComboboxPrimitive.Root;
|
|
12
|
+
declare function ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props): React.ReactElement;
|
|
13
|
+
declare function ComboboxTrigger({ className, children, ...props }: ComboboxPrimitive.Trigger.Props): React.ReactElement;
|
|
14
|
+
declare function ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props): React.ReactElement;
|
|
15
|
+
declare function ComboboxInput({ className, children, disabled, showTrigger, showClear, ...props }: ComboboxPrimitive.Input.Props & {
|
|
16
|
+
showTrigger?: boolean;
|
|
17
|
+
showClear?: boolean;
|
|
18
|
+
}): React.ReactElement;
|
|
19
|
+
declare function ComboboxContent({ className, side, sideOffset, align, alignOffset, anchor, ...props }: ComboboxPrimitive.Popup.Props & Pick<ComboboxPrimitive.Positioner.Props, 'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'>): React.ReactElement;
|
|
20
|
+
declare function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props): React.ReactElement;
|
|
21
|
+
declare function ComboboxItem({ className, children, ...props }: ComboboxPrimitive.Item.Props): React.ReactElement;
|
|
22
|
+
declare function ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props): React.ReactElement;
|
|
23
|
+
declare function ComboboxLabel({ className, ...props }: ComboboxPrimitive.GroupLabel.Props): React.ReactElement;
|
|
24
|
+
declare function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props): React.ReactElement;
|
|
25
|
+
declare function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props): React.ReactElement;
|
|
26
|
+
declare function ComboboxStatus({ className, ...props }: ComboboxPrimitive.Status.Props): React.ReactElement;
|
|
27
|
+
declare function ComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props): React.ReactElement;
|
|
28
|
+
declare function ComboboxChips({ className, ...props }: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> & ComboboxPrimitive.Chips.Props): React.ReactElement;
|
|
29
|
+
declare function ComboboxChip({ className, children, showRemove, ...props }: ComboboxPrimitive.Chip.Props & {
|
|
30
|
+
showRemove?: boolean;
|
|
31
|
+
}): React.ReactElement;
|
|
32
|
+
declare function ComboboxChipsInput({ className, ...props }: ComboboxPrimitive.Input.Props): React.ReactElement;
|
|
33
|
+
declare function useComboboxAnchor(): React.RefObject<HTMLDivElement | null>;
|
|
34
|
+
export { Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxClear, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxStatus, ComboboxTrigger, ComboboxValue, useComboboxAnchor, };
|
|
73
35
|
//# sourceMappingURL=combobox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/combobox/combobox.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/combobox/combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B;;;;;;;GAOG;AACH,QAAA,MAAM,QAAQ,+BAAyB,CAAC;AAExC,iBAAS,aAAa,CAAC,EACrB,GAAG,KAAK,EACT,EAAE,iBAAiB,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,YAAY,CAEpD;AAED,iBAAS,eAAe,CAAC,EACvB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,iBAAiB,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,YAAY,CAWtD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,iBAAiB,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,YAAY,CAWpD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,QAAQ,EACR,QAAgB,EAChB,WAAkB,EAClB,SAAiB,EACjB,GAAG,KAAK,EACT,EAAE,iBAAiB,CAAC,KAAK,CAAC,KAAK,GAAG;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,GAAG,KAAK,CAAC,YAAY,CAuBrB;AAED,iBAAS,eAAe,CAAC,EACvB,SAAS,EACT,IAAe,E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,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC,YAAY,CAQxD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,qBAAqB,CAAC,OAAO,iBAAiB,CAAC,KAAK,CAAC,GAC5D,iBAAiB,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,YAAY,CAWnD;AAED,iBAAS,YAAY,CAAC,EACpB,SAAS,EACT,QAAQ,EACR,UAAiB,EACjB,GAAG,KAAK,EACT,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,GAAG;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,KAAK,CAAC,YAAY,CAsBrB;AAED,iBAAS,kBAAkB,CAAC,EAC1B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,iBAAiB,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,YAAY,CAQpD;AAED,iBAAS,iBAAiB,IAAI,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAEnE;AAED,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,EACb,iBAAiB,GAClB,CAAC"}
|
|
@@ -1,175 +1,70 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
3
|
-
import {
|
|
4
|
-
import { Popover, ScrollArea as ScrollAreaPrimitive } from 'radix-ui';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Combobox as ComboboxPrimitive } from '@base-ui/react/combobox';
|
|
5
4
|
import * as React from 'react';
|
|
6
|
-
import { MdCheck, MdUnfoldMore } from 'react-icons/md';
|
|
7
|
-
import {
|
|
8
|
-
import { inputVariants, selectCheckVariants, selectContentVariants, selectItemVariants, } from '#src/styles/index.js';
|
|
9
|
-
import { cn, mergeRefs } from '#src/utils/index.js';
|
|
5
|
+
import { MdCheck, MdClose, MdUnfoldMore } from 'react-icons/md';
|
|
6
|
+
import { cn } from '#src/utils/index.js';
|
|
10
7
|
import { Button } from '../button/button.js';
|
|
11
|
-
import {
|
|
12
|
-
const ComboboxContext = React.createContext(null);
|
|
13
|
-
const DEFAULT_OPTION = { value: null, label: '' };
|
|
8
|
+
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, } from '../input-group/input-group.js';
|
|
14
9
|
/**
|
|
15
|
-
*
|
|
10
|
+
* An autocomplete input that allows users to filter and select from a list of options.
|
|
11
|
+
*
|
|
12
|
+
* ShadCN changes:
|
|
13
|
+
* - ComboboxList shows native scrollbar instead of no-scrollbar for better discoverability
|
|
14
|
+
*
|
|
15
|
+
* https://ui.shadcn.com/docs/components/combobox
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
setActiveValue(value.value ?? '');
|
|
48
|
-
setSearchQuery('');
|
|
49
|
-
}
|
|
50
|
-
setIsOpen(open);
|
|
51
|
-
},
|
|
52
|
-
isOpen,
|
|
53
|
-
inputId,
|
|
54
|
-
inputRef,
|
|
55
|
-
listRef,
|
|
56
|
-
shouldShowItem: (label) => {
|
|
57
|
-
if (!filterQuery) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
if (!label) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
return label.toLowerCase().includes(filterQuery.toLowerCase());
|
|
64
|
-
},
|
|
65
|
-
disabled,
|
|
66
|
-
}), [
|
|
67
|
-
value,
|
|
68
|
-
inputId,
|
|
69
|
-
searchQuery,
|
|
70
|
-
setSearchQuery,
|
|
71
|
-
setValue,
|
|
72
|
-
isOpen,
|
|
73
|
-
filterQuery,
|
|
74
|
-
disabled,
|
|
75
|
-
]);
|
|
76
|
-
return (_jsx(ComboboxContext.Provider, { value: contextValue, children: _jsx(Popover.Root, { open: isOpen, onOpenChange: contextValue.setIsOpen, children: _jsx(Command, { "aria-disabled": disabled, shouldFilter: false, value: activeValue, onValueChange: (val) => {
|
|
77
|
-
setActiveValue(val);
|
|
78
|
-
}, label: label, children: children }) }) }));
|
|
79
|
-
}
|
|
80
|
-
export function useComboboxContext() {
|
|
81
|
-
const value = React.useContext(ComboboxContext);
|
|
82
|
-
if (!value) {
|
|
83
|
-
throw new Error(`useComboboxContext must be used inside a ComboboxContext provider`);
|
|
84
|
-
}
|
|
85
|
-
return value;
|
|
86
|
-
}
|
|
87
|
-
function ComboboxInput({ className, placeholder, ref, ...rest }) {
|
|
88
|
-
const { setIsOpen, isOpen, inputId, searchQuery, setSearchQuery, selectedLabel, disabled, } = useComboboxContext();
|
|
89
|
-
const selectedLabelId = React.useId();
|
|
90
|
-
const inputRef = React.useRef(null);
|
|
91
|
-
const handleKeydown = React.useCallback((e) => {
|
|
92
|
-
const specialKeys = ['ArrowDown', 'ArrowUp', 'Home', 'End', 'Enter'];
|
|
93
|
-
if (e.key === 'Escape') {
|
|
94
|
-
setIsOpen(false);
|
|
95
|
-
}
|
|
96
|
-
else if (specialKeys.includes(e.key)) {
|
|
97
|
-
setIsOpen(true);
|
|
98
|
-
}
|
|
99
|
-
}, [setIsOpen]);
|
|
100
|
-
return (_jsx(Popover.Anchor, { children: _jsxs("div", { className: "relative", "data-cmdk-input-id": inputId, children: [_jsx(Command.Input, { asChild: true, onKeyDown: handleKeydown, disabled: disabled, onBlur: (e) => {
|
|
101
|
-
if (e.relatedTarget &&
|
|
102
|
-
e.relatedTarget instanceof Element &&
|
|
103
|
-
e.relatedTarget.closest(`[data-combobox-content=""]`)) {
|
|
104
|
-
e.target.focus();
|
|
105
|
-
}
|
|
106
|
-
}, value: searchQuery, onValueChange: setSearchQuery, className: cn(inputVariants(), 'pr-8', className), placeholder: selectedLabel ? undefined : placeholder, onClick: () => {
|
|
107
|
-
if (disabled) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (!isOpen) {
|
|
111
|
-
setIsOpen(true);
|
|
112
|
-
}
|
|
113
|
-
else if (inputRef.current) {
|
|
114
|
-
// avoid closing the combobox if the user is selecting text
|
|
115
|
-
const hasSelectedEnd = inputRef.current.selectionStart ===
|
|
116
|
-
inputRef.current.selectionEnd &&
|
|
117
|
-
inputRef.current.selectionEnd === inputRef.current.value.length;
|
|
118
|
-
if (hasSelectedEnd) {
|
|
119
|
-
setIsOpen(false);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}, ...rest, "aria-describedby": `${rest['aria-describedby'] ?? ''} ${selectedLabelId}`, ref: mergeRefs(ref, inputRef), children: _jsx("input", { ...(rest['aria-labelledby']
|
|
123
|
-
? { 'aria-labelledby': rest['aria-labelledby'] }
|
|
124
|
-
: undefined) }) }), _jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center pr-8", children: _jsx("div", { id: selectedLabelId, className: cn(disabled ? 'opacity-50' : '', searchQuery ? 'hidden' : '', 'pointer-events-none truncate py-1 pl-3 text-base md:text-sm'), children: selectedLabel }) }), _jsx(Button, { className: "absolute top-1/2 right-2 -translate-y-1/2 opacity-50", type: "button", variant: "ghost", size: "icon", disabled: disabled, "aria-label": `${isOpen ? 'Close' : 'Open'} combobox`, onClick: () => {
|
|
125
|
-
if (disabled) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
setIsOpen(!isOpen);
|
|
129
|
-
}, onKeyDown: (e) => {
|
|
130
|
-
if (!isOpen) {
|
|
131
|
-
e.stopPropagation();
|
|
132
|
-
}
|
|
133
|
-
}, children: _jsx(MdUnfoldMore, { className: "size-4" }) })] }) }));
|
|
134
|
-
}
|
|
135
|
-
function ComboboxContent({ children, className, maxHeight = '320px', style, ...rest }) {
|
|
136
|
-
const { inputId, listRef } = useComboboxContext();
|
|
137
|
-
return (_jsx(Popover.Portal, { children: _jsx(Popover.Content, { onOpenAutoFocus: (e) => {
|
|
138
|
-
e.preventDefault();
|
|
139
|
-
}, onInteractOutside: (e) => {
|
|
140
|
-
if (e.target &&
|
|
141
|
-
e.target instanceof Element &&
|
|
142
|
-
e.target.closest(`[data-cmdk-input-id="${inputId}"]`)) {
|
|
143
|
-
e.preventDefault();
|
|
144
|
-
}
|
|
145
|
-
}, className: cn(selectContentVariants({ popper: 'active' }), className), style: {
|
|
146
|
-
'--max-popover-height': maxHeight,
|
|
147
|
-
...style,
|
|
148
|
-
}, "data-combobox-content": "", ...rest, children: _jsxs(ScrollAreaPrimitive.Root, { type: "auto", className: "relative overflow-hidden", children: [_jsx(ScrollAreaPrimitive.Viewport, { className: cn('h-full w-full rounded-[inherit] p-1', 'max-h-[min(var(--max-popover-height),var(--radix-popover-content-available-height))] w-full min-w-(--radix-popover-trigger-width)'), style: {
|
|
149
|
-
'--max-popper-height': maxHeight,
|
|
150
|
-
}, children: _jsx(Command.List, { ref: listRef, children: children }) }), _jsx(ScrollBar, {}), _jsx(ScrollAreaPrimitive.Corner, {})] }) }) }));
|
|
17
|
+
const Combobox = ComboboxPrimitive.Root;
|
|
18
|
+
function ComboboxValue({ ...props }) {
|
|
19
|
+
return _jsx(ComboboxPrimitive.Value, { "data-slot": "combobox-value", ...props });
|
|
20
|
+
}
|
|
21
|
+
function ComboboxTrigger({ className, children, ...props }) {
|
|
22
|
+
return (_jsxs(ComboboxPrimitive.Trigger, { "data-slot": "combobox-trigger", className: cn("[&_svg:not([class*='size-'])]:size-4", className), ...props, children: [children, _jsx(MdUnfoldMore, { className: "pointer-events-none size-4 text-muted-foreground" })] }));
|
|
23
|
+
}
|
|
24
|
+
function ComboboxClear({ className, ...props }) {
|
|
25
|
+
return (_jsx(ComboboxPrimitive.Clear, { "data-slot": "combobox-clear", render: _jsx(InputGroupButton, { variant: "ghost", size: "icon-xs" }), className: cn(className), ...props, children: _jsx(MdClose, { className: "pointer-events-none" }) }));
|
|
26
|
+
}
|
|
27
|
+
function ComboboxInput({ className, children, disabled = false, showTrigger = true, showClear = false, ...props }) {
|
|
28
|
+
return (_jsxs(InputGroup, { className: cn('w-auto', className), children: [_jsx(ComboboxPrimitive.Input, { render: _jsx(InputGroupInput, { disabled: disabled }), ...props }), _jsxs(InputGroupAddon, { align: "inline-end", children: [showTrigger && (_jsx(InputGroupButton, { size: "icon-xs", variant: "ghost", render: _jsx(ComboboxTrigger, {}), "data-slot": "input-group-button", className: "group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent", disabled: disabled })), showClear && _jsx(ComboboxClear, { disabled: disabled })] }), children] }));
|
|
29
|
+
}
|
|
30
|
+
function ComboboxContent({ className, side = 'bottom', sideOffset = 6, align = 'start', alignOffset = 0, anchor, ...props }) {
|
|
31
|
+
return (_jsx(ComboboxPrimitive.Portal, { children: _jsx(ComboboxPrimitive.Positioner, { side: side, sideOffset: sideOffset, align: align, alignOffset: alignOffset, anchor: anchor, className: "isolate z-50", children: _jsx(ComboboxPrimitive.Popup, { "data-slot": "combobox-content", "data-chips": !!anchor, className: cn('group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95', className), ...props }) }) }));
|
|
32
|
+
}
|
|
33
|
+
function ComboboxList({ className, ...props }) {
|
|
34
|
+
return (_jsx(ComboboxPrimitive.List, { "data-slot": "combobox-list", className: cn('max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0', className), ...props }));
|
|
35
|
+
}
|
|
36
|
+
function ComboboxItem({ className, children, ...props }) {
|
|
37
|
+
return (_jsxs(ComboboxPrimitive.Item, { "data-slot": "combobox-item", className: cn("relative flex w-full cursor-default items-center gap-2 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), ...props, children: [children, _jsx(ComboboxPrimitive.ItemIndicator, { render: _jsx("span", { className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center" }), children: _jsx(MdCheck, { className: "pointer-events-none" }) })] }));
|
|
38
|
+
}
|
|
39
|
+
function ComboboxGroup({ className, ...props }) {
|
|
40
|
+
return (_jsx(ComboboxPrimitive.Group, { "data-slot": "combobox-group", className: cn(className), ...props }));
|
|
41
|
+
}
|
|
42
|
+
function ComboboxLabel({ className, ...props }) {
|
|
43
|
+
return (_jsx(ComboboxPrimitive.GroupLabel, { "data-slot": "combobox-label", className: cn('px-2 py-1.5 text-xs text-muted-foreground', className), ...props }));
|
|
44
|
+
}
|
|
45
|
+
function ComboboxCollection({ ...props }) {
|
|
46
|
+
return (_jsx(ComboboxPrimitive.Collection, { "data-slot": "combobox-collection", ...props }));
|
|
151
47
|
}
|
|
152
48
|
function ComboboxEmpty({ className, ...props }) {
|
|
153
|
-
return _jsx(
|
|
154
|
-
}
|
|
155
|
-
function
|
|
156
|
-
return (_jsx(
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
function
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
export { Combobox, ComboboxAction, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLoading, };
|
|
49
|
+
return (_jsx(ComboboxPrimitive.Empty, { "data-slot": "combobox-empty", className: cn('hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex', className), ...props }));
|
|
50
|
+
}
|
|
51
|
+
function ComboboxStatus({ className, ...props }) {
|
|
52
|
+
return (_jsx(ComboboxPrimitive.Status, { "data-slot": "combobox-status", className: cn('flex items-center justify-center p-2 text-sm text-muted-foreground', className), ...props }));
|
|
53
|
+
}
|
|
54
|
+
function ComboboxSeparator({ className, ...props }) {
|
|
55
|
+
return (_jsx(ComboboxPrimitive.Separator, { "data-slot": "combobox-separator", className: cn('-mx-1 my-1 h-px bg-border', className), ...props }));
|
|
56
|
+
}
|
|
57
|
+
function ComboboxChips({ className, ...props }) {
|
|
58
|
+
return (_jsx(ComboboxPrimitive.Chips, { "data-slot": "combobox-chips", className: cn('flex min-h-8 flex-wrap items-center gap-1 rounded-lg border border-input bg-transparent bg-clip-padding px-2.5 py-1 text-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40', className), ...props }));
|
|
59
|
+
}
|
|
60
|
+
function ComboboxChip({ className, children, showRemove = true, ...props }) {
|
|
61
|
+
return (_jsxs(ComboboxPrimitive.Chip, { "data-slot": "combobox-chip", className: cn('flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0', className), ...props, children: [children, showRemove && (_jsx(ComboboxPrimitive.ChipRemove, { render: _jsx(Button, { variant: "ghost", size: "icon-xs" }), className: "-ml-1 opacity-50 hover:opacity-100", "data-slot": "combobox-chip-remove", children: _jsx(MdClose, { className: "pointer-events-none" }) }))] }));
|
|
62
|
+
}
|
|
63
|
+
function ComboboxChipsInput({ className, ...props }) {
|
|
64
|
+
return (_jsx(ComboboxPrimitive.Input, { "data-slot": "combobox-chip-input", className: cn('min-w-16 flex-1 outline-none', className), ...props }));
|
|
65
|
+
}
|
|
66
|
+
function useComboboxAnchor() {
|
|
67
|
+
return React.useRef(null);
|
|
68
|
+
}
|
|
69
|
+
export { Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxClear, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxStatus, ComboboxTrigger, ComboboxValue, useComboboxAnchor, };
|
|
175
70
|
//# sourceMappingURL=combobox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.js","sourceRoot":"","sources":["../../../../src/components/ui/combobox/combobox.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAA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EAAC,SAAS,GAAG,EACjD,SAAS,EAAC,oCAAoC,eACpC,sBAAsB,YAEhC,KAAC,OAAO,IAAC,SAAS,EAAC,qBAAqB,GAAG,GACd,CAChC,IACsB,CAC1B,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,EAC1B,SAAS,EACT,GAAG,KAAK,EACsB;IAC9B,OAAO,CACL,KAAC,iBAAiB,CAAC,KAAK,iBACZ,qBAAqB,EAC/B,SAAS,EAAE,EAAE,CAAC,8BAA8B,EAAE,SAAS,CAAC,KACpD,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB;IACxB,OAAO,KAAK,CAAC,MAAM,CAAwB,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,EACb,iBAAiB,GAClB,CAAC"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import type { Control, FieldPath, FieldValues } from 'react-hook-form';
|
|
3
3
|
import type { AddOptionRequiredFields, FormFieldProps, SelectOptionProps } from '#src/types/form.js';
|
|
4
|
-
|
|
5
|
-
export interface ComboboxFieldProps<OptionType> extends Omit<ComboboxProps, 'value' | 'onChange' | 'label' | 'children'>, SelectOptionProps<OptionType>, FormFieldProps {
|
|
4
|
+
export interface ComboboxFieldProps<OptionType> extends SelectOptionProps<OptionType>, FormFieldProps {
|
|
6
5
|
className?: string;
|
|
7
6
|
noResultsText?: React.ReactNode;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
value?: string | null;
|
|
10
|
+
onChange?: (value: string | null) => void;
|
|
11
|
+
onInputValueChange?: (value: string) => void;
|
|
8
12
|
}
|
|
9
13
|
/**
|
|
10
14
|
* Field with label and error states that wraps a Combobox component.
|
|
11
15
|
*/
|
|
12
|
-
declare function ComboboxField<OptionType>({ label, description, error, value, placeholder, options, renderItemLabel, onChange, getOptionLabel, getOptionValue, className, noResultsText,
|
|
16
|
+
declare function ComboboxField<OptionType>({ label, description, error, value, placeholder, options, renderItemLabel, onChange, onInputValueChange, getOptionLabel, getOptionValue, className, noResultsText, disabled, }: ComboboxFieldProps<OptionType> & AddOptionRequiredFields<OptionType>): React.ReactElement;
|
|
13
17
|
interface ComboboxFieldControllerPropsBase<OptionType, TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<ComboboxFieldProps<OptionType>, 'value'> {
|
|
14
18
|
control: Control<TFieldValues>;
|
|
15
19
|
name: TFieldName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox-field.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/combobox-field/combobox-field.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"combobox-field.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/combobox-field/combobox-field.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAIvE,OAAO,KAAK,EACV,uBAAuB,EACvB,cAAc,EACd,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAoB5B,MAAM,WAAW,kBAAkB,CAAC,UAAU,CAC5C,SAAQ,iBAAiB,CAAC,UAAU,CAAC,EAAE,cAAc;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,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AAC,GAAG,SAAS,CAAC,YAAY,CAAC,EACpE,EACA,IAAI,EACJ,OAAO,EACP,GAAG,IAAI,EACR,EAAE,4BAA4B,CAAC,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,GACnE,uBAAuB,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC,YAAY,CAiBzD;AAED,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -1,34 +1,26 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from 'react';
|
|
3
4
|
import { useComponentStrings } from '#src/contexts/component-strings.js';
|
|
4
5
|
import { useControllerMerged } from '#src/hooks/use-controller-merged.js';
|
|
5
|
-
import { Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, } from '../combobox/combobox.js';
|
|
6
|
-
import {
|
|
6
|
+
import { Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, } from '../combobox/combobox.js';
|
|
7
|
+
import { Field, FieldDescription, FieldError, FieldLabel, } from '../field/field.js';
|
|
7
8
|
/**
|
|
8
9
|
* Field with label and error states that wraps a Combobox component.
|
|
9
10
|
*/
|
|
10
|
-
function ComboboxField({ label, description, error, value, placeholder, options, renderItemLabel, onChange, getOptionLabel = (val) => val.label, getOptionValue = (val) => val.value, className, noResultsText,
|
|
11
|
-
const selectedOption = options.find((o) => getOptionValue(o) === value);
|
|
12
|
-
const selectedComboboxOption = (() => {
|
|
13
|
-
if (value === undefined)
|
|
14
|
-
return;
|
|
15
|
-
if (!selectedOption)
|
|
16
|
-
return null;
|
|
17
|
-
return {
|
|
18
|
-
label: getOptionLabel(selectedOption),
|
|
19
|
-
value: getOptionValue(selectedOption),
|
|
20
|
-
};
|
|
21
|
-
})();
|
|
11
|
+
function ComboboxField({ label, description, error, value, placeholder, options, renderItemLabel, onChange, onInputValueChange, getOptionLabel = (val) => val.label, getOptionValue = (val) => val.value, className, noResultsText, disabled, }) {
|
|
22
12
|
const { comboboxNoResults } = useComponentStrings();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
const id = useId();
|
|
14
|
+
const selectedOption = options.find((o) => getOptionValue(o) === value) ?? null;
|
|
15
|
+
return (_jsxs(Field, { "data-invalid": !!error, className: className, children: [_jsx(FieldLabel, { htmlFor: id, children: label }), _jsxs(Combobox, { value: selectedOption, onValueChange: (option) => {
|
|
16
|
+
onChange?.(option ? getOptionValue(option) : null);
|
|
17
|
+
}, onInputValueChange: onInputValueChange, disabled: disabled, items: options, itemToStringLabel: getOptionLabel, itemToStringValue: (option) => getOptionValue(option) ?? '', autoHighlight: true, children: [_jsx(ComboboxInput, { id: id, placeholder: placeholder }), _jsxs(ComboboxContent, { children: [_jsx(ComboboxEmpty, { children: noResultsText ?? comboboxNoResults }), _jsx(ComboboxList, { children: (option) => {
|
|
18
|
+
const val = getOptionValue(option);
|
|
19
|
+
const optionLabel = getOptionLabel(option);
|
|
20
|
+
return (_jsx(ComboboxItem, { value: option, children: renderItemLabel
|
|
21
|
+
? renderItemLabel(option, { selected: val === value })
|
|
22
|
+
: optionLabel }, val));
|
|
23
|
+
} })] })] }), _jsx(FieldDescription, { children: description }), _jsx(FieldError, { children: error })] }));
|
|
32
24
|
}
|
|
33
25
|
function ComboboxFieldController({ name, control, ...rest }) {
|
|
34
26
|
const { field, fieldState: { error }, } = useControllerMerged({ name, control }, rest);
|