@central-ui/react 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +49 -0
- package/dist/components/accordion/index.d.ts +4 -3
- package/dist/components/accordion/index.js +7 -4
- package/dist/components/autocomplete/index.d.ts +14 -25
- package/dist/components/autocomplete/index.js +70 -54
- package/dist/components/avatar/index.d.ts +1 -2
- package/dist/components/avatar/index.js +0 -1
- package/dist/components/badge/index.d.ts +0 -1
- package/dist/components/badge/index.js +2 -2
- package/dist/components/banner/index.d.ts +1 -1
- package/dist/components/banner/index.js +23 -25
- package/dist/components/barchart/index.d.ts +106 -0
- package/dist/components/barchart/index.js +122 -0
- package/dist/components/breadcrumb/index.d.ts +0 -1
- package/dist/components/breadcrumb/index.js +6 -7
- package/dist/components/button/index.d.ts +2 -3
- package/dist/components/button/index.js +11 -12
- package/dist/components/card/index.d.ts +0 -1
- package/dist/components/card/index.js +0 -1
- package/dist/components/checkbox/index.d.ts +13 -11
- package/dist/components/checkbox/index.js +51 -31
- package/dist/components/chip/index.d.ts +1 -1
- package/dist/components/chip/index.js +2 -3
- package/dist/components/combobox/index.d.ts +18 -30
- package/dist/components/combobox/index.js +90 -67
- package/dist/components/datepicker/index.d.ts +18 -31
- package/dist/components/datepicker/index.js +81 -99
- package/dist/components/dialog/index.d.ts +14 -27
- package/dist/components/dialog/index.js +17 -18
- package/dist/components/divider/index.d.ts +0 -1
- package/dist/components/divider/index.js +0 -1
- package/dist/components/donutchart/index.d.ts +100 -0
- package/dist/components/donutchart/index.js +178 -0
- package/dist/components/drawer/index.d.ts +12 -21
- package/dist/components/drawer/index.js +34 -36
- package/dist/components/empty/index.d.ts +1 -2
- package/dist/components/empty/index.js +2 -4
- package/dist/components/fileupload/index.d.ts +4 -9
- package/dist/components/fileupload/index.js +26 -38
- package/dist/components/form/index.d.ts +0 -1
- package/dist/components/form/index.js +0 -1
- package/dist/components/horizontalbarchart/index.d.ts +120 -0
- package/dist/components/horizontalbarchart/index.js +193 -0
- package/dist/components/input/index.d.ts +22 -22
- package/dist/components/input/index.js +76 -105
- package/dist/components/linechart/index.d.ts +114 -0
- package/dist/components/linechart/index.js +139 -0
- package/dist/components/menu/index.d.ts +9 -11
- package/dist/components/menu/index.js +42 -39
- package/dist/components/metric/index.d.ts +0 -1
- package/dist/components/metric/index.js +0 -1
- package/dist/components/numberinput/index.d.ts +14 -21
- package/dist/components/numberinput/index.js +40 -53
- package/dist/components/otpinput/index.d.ts +14 -9
- package/dist/components/otpinput/index.js +25 -18
- package/dist/components/page/index.d.ts +0 -1
- package/dist/components/page/index.js +1 -3
- package/dist/components/passwordinput/index.d.ts +14 -11
- package/dist/components/passwordinput/index.js +36 -45
- package/dist/components/popover/index.d.ts +21 -19
- package/dist/components/popover/index.js +34 -15
- package/dist/components/radio/index.d.ts +13 -9
- package/dist/components/radio/index.js +69 -60
- package/dist/components/ratinginput/index.d.ts +13 -8
- package/dist/components/ratinginput/index.js +37 -17
- package/dist/components/select/index.d.ts +25 -28
- package/dist/components/select/index.js +67 -38
- package/dist/components/skeleton/index.d.ts +0 -1
- package/dist/components/skeleton/index.js +0 -1
- package/dist/components/slider/index.d.ts +14 -9
- package/dist/components/slider/index.js +64 -63
- package/dist/components/spinner/index.d.ts +1 -2
- package/dist/components/spinner/index.js +2 -3
- package/dist/components/splitter/index.d.ts +1 -2
- package/dist/components/splitter/index.js +5 -6
- package/dist/components/stepper/index.d.ts +8 -20
- package/dist/components/stepper/index.js +15 -16
- package/dist/components/switch/index.d.ts +12 -10
- package/dist/components/switch/index.js +46 -30
- package/dist/components/table/index.d.ts +3 -3
- package/dist/components/table/index.js +14 -13
- package/dist/components/tabs/index.d.ts +0 -1
- package/dist/components/tabs/index.js +1 -2
- package/dist/components/textarea/index.d.ts +14 -11
- package/dist/components/textarea/index.js +37 -46
- package/dist/components/textlink/index.d.ts +3 -1
- package/dist/components/textlink/index.js +4 -1
- package/dist/components/toast/index.d.ts +8 -14
- package/dist/components/toast/index.js +48 -48
- package/dist/components/toggle/index.d.ts +0 -1
- package/dist/components/toggle/index.js +17 -24
- package/dist/components/tooltip/index.d.ts +11 -13
- package/dist/components/tooltip/index.js +12 -9
- package/dist/components/tour/index.d.ts +154 -0
- package/dist/components/tour/index.js +280 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -1
- package/dist/types/Icon.d.ts +0 -1
- package/dist/types/Icon.js +0 -1
- package/dist/types/Style.d.ts +0 -1
- package/dist/types/Style.js +0 -1
- package/dist/types/Tone.d.ts +0 -1
- package/dist/types/Tone.js +0 -1
- package/dist/types/Validation.d.ts +12 -0
- package/dist/types/Validation.js +1 -0
- package/dist/utils/ArkStateToDataAttributes.d.ts +0 -1
- package/dist/utils/ArkStateToDataAttributes.js +0 -1
- package/dist/utils/Tone.d.ts +0 -1
- package/dist/utils/Tone.js +0 -1
- package/dist/utils/Validation.d.ts +14 -0
- package/dist/utils/Validation.js +23 -0
- package/dist/utils/asChild.d.ts +41 -0
- package/dist/utils/asChild.js +15 -0
- package/dist/utils/icons.d.ts +24 -0
- package/dist/utils/icons.js +160 -0
- package/dist/utils/useForwardClickToInput.d.ts +0 -1
- package/dist/utils/useForwardClickToInput.js +0 -1
- package/dist/utils/virtualization/useVirtualizedAutocomplete.d.ts +0 -1
- package/dist/utils/virtualization/useVirtualizedAutocomplete.js +0 -1
- package/dist/utils/virtualization/useVirtualizedCombobox.d.ts +0 -1
- package/dist/utils/virtualization/useVirtualizedCombobox.js +0 -1
- package/dist/utils/virtualization/useVirtualizedTable.d.ts +0 -1
- package/dist/utils/virtualization/useVirtualizedTable.js +0 -1
- package/package.json +12 -11
- package/src/presets/shopify-polaris/shopify-polaris-autocomplete.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-barchart.css +64 -0
- package/src/presets/shopify-polaris/shopify-polaris-checkbox.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-combobox.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-datepicker.css +4 -4
- package/src/presets/shopify-polaris/shopify-polaris-dialog.css +16 -0
- package/src/presets/shopify-polaris/shopify-polaris-donutchart.css +172 -0
- package/src/presets/shopify-polaris/shopify-polaris-drawer.css +16 -0
- package/src/presets/shopify-polaris/shopify-polaris-fileupload.css +1 -1
- package/src/presets/shopify-polaris/shopify-polaris-horizontalbarchart.css +60 -0
- package/src/presets/shopify-polaris/shopify-polaris-input.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-linechart.css +68 -0
- package/src/presets/shopify-polaris/shopify-polaris-menu.css +16 -0
- package/src/presets/shopify-polaris/shopify-polaris-numberinput.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-otpinput.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-passwordinput.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-popover.css +29 -0
- package/src/presets/shopify-polaris/shopify-polaris-radio.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-ratinginput.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-select.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-slider.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-stepper.css +16 -0
- package/src/presets/shopify-polaris/shopify-polaris-switch.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-textarea.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-tooltip.css +16 -0
- package/src/presets/shopify-polaris/shopify-polaris.css +4 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-autocomplete.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-barchart.css +64 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-checkbox.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-combobox.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-datepicker.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-dialog.css +9 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-donutchart.css +172 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-drawer.css +9 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-fileupload.css +1 -1
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-horizontalbarchart.css +60 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-input.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-linechart.css +68 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-menu.css +9 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-numberinput.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-otpinput.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-passwordinput.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-popover.css +22 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-radio.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-ratinginput.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-slider.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-stepper.css +9 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-switch.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-textarea.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-tooltip.css +9 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy.css +4 -0
- package/dist/components/accordion/index.d.ts.map +0 -1
- package/dist/components/accordion/index.js.map +0 -1
- package/dist/components/autocomplete/index.d.ts.map +0 -1
- package/dist/components/autocomplete/index.js.map +0 -1
- package/dist/components/avatar/index.d.ts.map +0 -1
- package/dist/components/avatar/index.js.map +0 -1
- package/dist/components/badge/index.d.ts.map +0 -1
- package/dist/components/badge/index.js.map +0 -1
- package/dist/components/banner/index.d.ts.map +0 -1
- package/dist/components/banner/index.js.map +0 -1
- package/dist/components/breadcrumb/index.d.ts.map +0 -1
- package/dist/components/breadcrumb/index.js.map +0 -1
- package/dist/components/button/index.d.ts.map +0 -1
- package/dist/components/button/index.js.map +0 -1
- package/dist/components/card/index.d.ts.map +0 -1
- package/dist/components/card/index.js.map +0 -1
- package/dist/components/checkbox/index.d.ts.map +0 -1
- package/dist/components/checkbox/index.js.map +0 -1
- package/dist/components/chip/index.d.ts.map +0 -1
- package/dist/components/chip/index.js.map +0 -1
- package/dist/components/combobox/index.d.ts.map +0 -1
- package/dist/components/combobox/index.js.map +0 -1
- package/dist/components/datepicker/index.d.ts.map +0 -1
- package/dist/components/datepicker/index.js.map +0 -1
- package/dist/components/dialog/index.d.ts.map +0 -1
- package/dist/components/dialog/index.js.map +0 -1
- package/dist/components/divider/index.d.ts.map +0 -1
- package/dist/components/divider/index.js.map +0 -1
- package/dist/components/drawer/index.d.ts.map +0 -1
- package/dist/components/drawer/index.js.map +0 -1
- package/dist/components/empty/index.d.ts.map +0 -1
- package/dist/components/empty/index.js.map +0 -1
- package/dist/components/fileupload/index.d.ts.map +0 -1
- package/dist/components/fileupload/index.js.map +0 -1
- package/dist/components/form/index.d.ts.map +0 -1
- package/dist/components/form/index.js.map +0 -1
- package/dist/components/input/index.d.ts.map +0 -1
- package/dist/components/input/index.js.map +0 -1
- package/dist/components/menu/index.d.ts.map +0 -1
- package/dist/components/menu/index.js.map +0 -1
- package/dist/components/metric/index.d.ts.map +0 -1
- package/dist/components/metric/index.js.map +0 -1
- package/dist/components/numberinput/index.d.ts.map +0 -1
- package/dist/components/numberinput/index.js.map +0 -1
- package/dist/components/otpinput/index.d.ts.map +0 -1
- package/dist/components/otpinput/index.js.map +0 -1
- package/dist/components/page/index.d.ts.map +0 -1
- package/dist/components/page/index.js.map +0 -1
- package/dist/components/passwordinput/index.d.ts.map +0 -1
- package/dist/components/passwordinput/index.js.map +0 -1
- package/dist/components/popover/index.d.ts.map +0 -1
- package/dist/components/popover/index.js.map +0 -1
- package/dist/components/radio/index.d.ts.map +0 -1
- package/dist/components/radio/index.js.map +0 -1
- package/dist/components/ratinginput/index.d.ts.map +0 -1
- package/dist/components/ratinginput/index.js.map +0 -1
- package/dist/components/select/index.d.ts.map +0 -1
- package/dist/components/select/index.js.map +0 -1
- package/dist/components/skeleton/index.d.ts.map +0 -1
- package/dist/components/skeleton/index.js.map +0 -1
- package/dist/components/slider/index.d.ts.map +0 -1
- package/dist/components/slider/index.js.map +0 -1
- package/dist/components/spinner/index.d.ts.map +0 -1
- package/dist/components/spinner/index.js.map +0 -1
- package/dist/components/splitter/index.d.ts.map +0 -1
- package/dist/components/splitter/index.js.map +0 -1
- package/dist/components/stepper/index.d.ts.map +0 -1
- package/dist/components/stepper/index.js.map +0 -1
- package/dist/components/switch/index.d.ts.map +0 -1
- package/dist/components/switch/index.js.map +0 -1
- package/dist/components/table/index.d.ts.map +0 -1
- package/dist/components/table/index.js.map +0 -1
- package/dist/components/tabs/index.d.ts.map +0 -1
- package/dist/components/tabs/index.js.map +0 -1
- package/dist/components/textarea/index.d.ts.map +0 -1
- package/dist/components/textarea/index.js.map +0 -1
- package/dist/components/textlink/index.d.ts.map +0 -1
- package/dist/components/textlink/index.js.map +0 -1
- package/dist/components/toast/index.d.ts.map +0 -1
- package/dist/components/toast/index.js.map +0 -1
- package/dist/components/toggle/index.d.ts.map +0 -1
- package/dist/components/toggle/index.js.map +0 -1
- package/dist/components/tooltip/index.d.ts.map +0 -1
- package/dist/components/tooltip/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types/Icon.d.ts.map +0 -1
- package/dist/types/Icon.js.map +0 -1
- package/dist/types/Style.d.ts.map +0 -1
- package/dist/types/Style.js.map +0 -1
- package/dist/types/Tone.d.ts.map +0 -1
- package/dist/types/Tone.js.map +0 -1
- package/dist/utils/ArkStateToDataAttributes.d.ts.map +0 -1
- package/dist/utils/ArkStateToDataAttributes.js.map +0 -1
- package/dist/utils/Tone.d.ts.map +0 -1
- package/dist/utils/Tone.js.map +0 -1
- package/dist/utils/useForwardClickToInput.d.ts.map +0 -1
- package/dist/utils/useForwardClickToInput.js.map +0 -1
- package/dist/utils/virtualization/useVirtualizedAutocomplete.d.ts.map +0 -1
- package/dist/utils/virtualization/useVirtualizedAutocomplete.js.map +0 -1
- package/dist/utils/virtualization/useVirtualizedCombobox.d.ts.map +0 -1
- package/dist/utils/virtualization/useVirtualizedCombobox.js.map +0 -1
- package/dist/utils/virtualization/useVirtualizedTable.d.ts.map +0 -1
- package/dist/utils/virtualization/useVirtualizedTable.js.map +0 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Combobox as BaseCombobox } from '@base-ui/react/combobox';
|
|
2
1
|
import type { SVGIconProps } from '../../types/Icon.ts';
|
|
2
|
+
import { Combobox as BaseCombobox } from '@base-ui/react/combobox';
|
|
3
|
+
import type { ValidationProps } from '../../types/Validation.ts';
|
|
3
4
|
import type { ComponentProps, ComponentPropsWithRef, ReactElement, ReactNode } from 'react';
|
|
5
|
+
import type { ValidationMessageChildren } from '../../utils/Validation.ts';
|
|
4
6
|
type StyleProps = {
|
|
5
7
|
/**
|
|
6
8
|
* Disables preset styling for this element.
|
|
@@ -34,7 +36,7 @@ export type GroupType<T extends readonly GroupShape[]> = T[number];
|
|
|
34
36
|
export type ItemType<T extends readonly GroupShape[]> = GroupType<T>['items'][number];
|
|
35
37
|
/** Manually type a ChipsList callback argument with ChipsType<typeof rootItems>, using the exact items variable passed to Root. Also useful for multiple-selection state. */
|
|
36
38
|
export type ChipsType<T extends readonly GroupShape[]> = ItemType<T>[];
|
|
37
|
-
export type RootProps<T extends readonly GroupShape[], Multiple extends boolean | undefined = false> = Omit<BaseCombobox.Root.Props<ItemType<T>, Multiple>, 'items' | 'filteredItems' | 'itemToStringLabel' | 'itemToStringValue' | 'isItemEqualToValue' | 'id'> & {
|
|
39
|
+
export type RootProps<T extends readonly GroupShape[], Multiple extends boolean | undefined = false> = Omit<BaseCombobox.Root.Props<ItemType<T>, Multiple>, 'items' | 'filteredItems' | 'itemToStringLabel' | 'itemToStringValue' | 'isItemEqualToValue' | 'id'> & ValidationProps & {
|
|
38
40
|
/** Input id, also used automatically by Label. Omit to generate a stable id. */
|
|
39
41
|
id?: BaseCombobox.Root.Props<ItemType<T>, Multiple>['id'];
|
|
40
42
|
/**
|
|
@@ -50,8 +52,6 @@ export type RootProps<T extends readonly GroupShape[], Multiple extends boolean
|
|
|
50
52
|
* performs filtering itself, such as filtering results on a server.
|
|
51
53
|
*/
|
|
52
54
|
filteredItems?: readonly GroupType<T>[];
|
|
53
|
-
/** Visual validation tone only; does not validate or change selection. @default 'neutral' */
|
|
54
|
-
tone?: 'neutral' | 'valid' | 'invalid';
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
57
|
* Searchable selection using Base UI's built-in filtering and keyboard handling.
|
|
@@ -206,7 +206,7 @@ export type RootProps<T extends readonly GroupShape[], Multiple extends boolean
|
|
|
206
206
|
* <Combobox.AddonOpenButtonIcon />
|
|
207
207
|
* </Combobox.AddonOpenButton>
|
|
208
208
|
*/
|
|
209
|
-
export declare function Root<T extends readonly GroupShape[], Multiple extends boolean | undefined = false>({ children, id,
|
|
209
|
+
export declare function Root<T extends readonly GroupShape[], Multiple extends boolean | undefined = false>({ children, id, validation, defaultOpen, onOpenChange, ...props }: RootProps<T, Multiple>): import("react").JSX.Element;
|
|
210
210
|
/** Use for the standard stacked layout, or omit when supplying your own layout. */
|
|
211
211
|
export declare const Container: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
212
212
|
/** Labels the input automatically using Root's id. Supply the visible label as children; no htmlFor needed. */
|
|
@@ -271,7 +271,7 @@ export type GroupsListProps<Group extends GroupShape = GroupShape> = Omit<Compon
|
|
|
271
271
|
children: ReactNode | ((group: Group, index: number) => ReactNode);
|
|
272
272
|
} & StyleProps;
|
|
273
273
|
/** Required groups container inside ScrollArea. A children callback receives each automatically filtered group; do not filter or map the original groups again. Manually annotate group with Combobox.GroupType<typeof rootItems>, using the exact items variable passed to Root. */
|
|
274
|
-
export declare function GroupsList<Group extends GroupShape = GroupShape>({ disableStyle, children, className,
|
|
274
|
+
export declare function GroupsList<Group extends GroupShape = GroupShape>({ disableStyle, children, className, ...props }: GroupsListProps<Group>): import("react").JSX.Element;
|
|
275
275
|
export type ItemsListProps<Item extends ItemShape = ItemShape> = Omit<ComponentPropsWithRef<'div'>, 'children' | 'className'> & {
|
|
276
276
|
className?: string;
|
|
277
277
|
/**
|
|
@@ -283,21 +283,21 @@ export type ItemsListProps<Item extends ItemShape = ItemShape> = Omit<ComponentP
|
|
|
283
283
|
children?: ReactNode | ((item: Item, index: number) => ReactNode);
|
|
284
284
|
} & StyleProps;
|
|
285
285
|
/** Required items container inside Group. A children callback receives the filtered items belonging to that Group; do not repeat filtering yourself. Manually annotate item with Combobox.ItemType<typeof rootItems>, using the exact items variable passed to Root. */
|
|
286
|
-
export declare function ItemsList<Item extends ItemShape = ItemShape>({ disableStyle, children, className,
|
|
286
|
+
export declare function ItemsList<Item extends ItemShape = ItemShape>({ disableStyle, children, className, ...props }: ItemsListProps<Item>): import("react").JSX.Element;
|
|
287
287
|
export type GroupProps<Item extends ItemShape = ItemShape> = Omit<ComponentPropsWithRef<typeof BaseCombobox.Group>, 'items' | 'className'> & {
|
|
288
288
|
className?: string;
|
|
289
289
|
/** Items for this group; pass group.items from GroupsList. Required even for a flat list. */
|
|
290
290
|
items: readonly Item[];
|
|
291
291
|
} & StyleProps;
|
|
292
292
|
/** Required wrapper around ItemsList, even for a visually flat list. Pass group.items. A GroupLabel is optional; omit it when the group has an empty label. */
|
|
293
|
-
export declare function Group<Item extends ItemShape = ItemShape>({ disableStyle, className,
|
|
293
|
+
export declare function Group<Item extends ItemShape = ItemShape>({ disableStyle, className, ...props }: GroupProps<Item>): import("react").JSX.Element;
|
|
294
294
|
export type ItemProps<Item extends ItemShape = ItemShape> = Omit<ComponentPropsWithRef<typeof BaseCombobox.Item>, 'value' | 'className'> & {
|
|
295
295
|
className?: string;
|
|
296
296
|
/** Pass the item supplied by ItemsList so selection can match it by item.value. */
|
|
297
297
|
value: Item;
|
|
298
298
|
} & StyleProps;
|
|
299
299
|
/** Required selectable row inside ItemsList. Pass the complete item object as value, with ItemText and ItemIndicator inside. Selection, highlighting, and keyboard behavior are built in. */
|
|
300
|
-
export declare function Item<Item extends ItemShape = ItemShape>({ disableStyle, className,
|
|
300
|
+
export declare function Item<Item extends ItemShape = ItemShape>({ disableStyle, className, ...props }: ItemProps<Item>): import("react").JSX.Element;
|
|
301
301
|
export type PopupProps = Omit<ComponentPropsWithRef<typeof BaseCombobox.Popup>, 'className'> & {
|
|
302
302
|
className?: string;
|
|
303
303
|
} & Pick<BaseCombobox.Portal.Props, 'container' | 'keepMounted'> & Pick<BaseCombobox.Positioner.Props, 'anchor' | 'positionMethod' | 'alignOffset' | 'collisionBoundary' | 'collisionPadding' | 'sticky' | 'arrowPadding' | 'disableAnchorTracking' | 'collisionAvoidance'> & {
|
|
@@ -312,20 +312,6 @@ export type PopupProps = Omit<ComponentPropsWithRef<typeof BaseCombobox.Popup>,
|
|
|
312
312
|
export declare function Popup({ disableStyle, container, keepMounted, anchor, positionMethod, side, sideOffset, align, alignOffset, collisionBoundary, collisionPadding, sticky, arrowPadding, disableAnchorTracking, collisionAvoidance, className, style, ...props }: PopupProps): import("react").JSX.Element;
|
|
313
313
|
/** Optional decorative popup arrow. Place inside Popup; the SVG and direction handling are supplied. No children needed. */
|
|
314
314
|
export declare const Arrow: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").SVGProps<SVGSVGElement>, "children" | "dangerouslySetInnerHTML"> & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
315
|
-
/** Behavior only: turns its single child element into the popup trigger. Adds no preset styling and has no disableStyle prop. Use an accessible button child; pass className to the child for its appearance. */
|
|
316
|
-
export declare const PopupOpenHandler: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ComboboxTriggerProps, "children" | "className" | "render"> & {
|
|
317
|
-
/** Additional classes forwarded to the trigger element. This handler has no preset styles. */
|
|
318
|
-
className?: string;
|
|
319
|
-
/** Single element to receive the behavior. Use a button with an accessible name. */
|
|
320
|
-
children: ReactElement;
|
|
321
|
-
}, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
322
|
-
/** Behavior only: turns its single child element into a removal control for the surrounding Chip. Adds no preset styling and has no disableStyle prop. Use an accessible button child. */
|
|
323
|
-
export declare const ChipRemoveHandler: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ComboboxChipRemoveProps, "children" | "className" | "render"> & {
|
|
324
|
-
/** Additional classes forwarded to the removal element. This handler has no preset styles. */
|
|
325
|
-
className?: string;
|
|
326
|
-
/** Single element to receive the behavior. Use a button with an accessible name. */
|
|
327
|
-
children: ReactElement;
|
|
328
|
-
}, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
329
315
|
/** Optional input adornment container inside InputGroup. Wraps icons, text, or buttons without adding trigger behavior. */
|
|
330
316
|
export declare const Addon: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
331
317
|
/** Preset adornment appearance. Does not add button behavior. @default 'normal' */
|
|
@@ -346,7 +332,7 @@ export declare const AddonButton: import("react").ForwardRefExoticComponent<Omit
|
|
|
346
332
|
/** Disables this button. Root disabled or readOnly also disables it automatically. */
|
|
347
333
|
disabled?: ComponentProps<"button">["disabled"];
|
|
348
334
|
} & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
349
|
-
/** Input control wrapper. Place Input (or ChipsList containing Input) and optional Addon controls inside. Root
|
|
335
|
+
/** Input control wrapper. Place Input (or ChipsList containing Input) and optional Addon controls inside. Root validation controls its preset validation border. */
|
|
350
336
|
export declare const InputGroup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ComboboxInputGroupProps, "className"> & {
|
|
351
337
|
className?: string;
|
|
352
338
|
} & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -384,12 +370,15 @@ export declare const ItemText: import("react").ForwardRefExoticComponent<Omit<im
|
|
|
384
370
|
export declare const AddonText: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
385
371
|
/** Text content inside Empty. Supply your empty-result message; Empty handles its visibility automatically. */
|
|
386
372
|
export declare const EmptyText: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
387
|
-
/** Optional supporting text. Supply its content; it
|
|
373
|
+
/** Optional supporting text. Supply its content; it describes the input to screen readers automatically. */
|
|
388
374
|
export declare const Description: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
375
|
+
type MessageProps = Omit<ComponentProps<'div'>, 'children'> & StyleProps & {
|
|
376
|
+
children?: ValidationMessageChildren;
|
|
377
|
+
};
|
|
378
|
+
/** Shows itself only while Root's validation is `'error'`: with no children it shows the message from `['error', message]`, a function children formats that message, and other children replace it. */
|
|
379
|
+
export declare const Error: import("react").ForwardRefExoticComponent<Omit<MessageProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
380
|
+
/** Shows itself only while Root's validation is `'success'`: with no children it shows the message from `['success', message]`, a function children formats that message, and other children replace it. */
|
|
381
|
+
export declare const Success: import("react").ForwardRefExoticComponent<Omit<MessageProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
393
382
|
/** Built-in decorative open-button icon. Place inside AddonOpenButton; no children needed. Defaults to strokeWidth 1.5. */
|
|
394
383
|
export declare const AddonOpenButtonIcon: import("react").ForwardRefExoticComponent<Omit<Omit<SVGIconProps, "strokeWidth"> & {
|
|
395
384
|
/** @default 1.5 */
|
|
@@ -424,4 +413,3 @@ export declare const LoadingText: import("react").ForwardRefExoticComponent<Omit
|
|
|
424
413
|
/** Built-in decorative spinner for Loading. No children needed; you control when it is rendered. */
|
|
425
414
|
export declare const LoadingIcon: import("react").ForwardRefExoticComponent<Omit<SVGIconProps & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
426
415
|
export {};
|
|
427
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Combobox as BaseCombobox } from '@base-ui/react/combobox';
|
|
3
|
-
import { Check, ChevronsUpDown, LoaderCircle, X } from
|
|
4
|
-
import { cloneElement, createContext, forwardRef, useContext, useId, useState
|
|
3
|
+
import { Check, ChevronsUpDown, LoaderCircle, X } from "../../utils/icons.js";
|
|
4
|
+
import { cloneElement, createContext, forwardRef, useContext, useEffect, useId, useState } from 'react';
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
6
|
-
import {
|
|
6
|
+
import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
|
|
7
7
|
/**
|
|
8
8
|
* Searchable selection using Base UI's built-in filtering and keyboard handling.
|
|
9
9
|
* Does not render an element. Keep all parts inside Root.
|
|
@@ -157,21 +157,28 @@ import { ToneProvider, useToneContext } from "../../utils/Tone.js";
|
|
|
157
157
|
* <Combobox.AddonOpenButtonIcon />
|
|
158
158
|
* </Combobox.AddonOpenButton>
|
|
159
159
|
*/
|
|
160
|
-
export function Root({ children, id,
|
|
160
|
+
export function Root({ children, id, validation, defaultOpen = false, onOpenChange, ...props }) {
|
|
161
|
+
//1. Tracking the open state even when uncontrolled, so parts can carry data-open
|
|
162
|
+
const [openInternalState, setOpenInternalState] = useState(defaultOpen);
|
|
163
|
+
//2. Holding the ids of Description, Error and Success, so Input announces them to screen readers through aria-describedby
|
|
164
|
+
const [describedByIds, setDescribedByIds] = useState([]);
|
|
165
|
+
//3. Sharing everything with the parts
|
|
161
166
|
const generatedId = useId();
|
|
162
167
|
const inputId = id ?? generatedId;
|
|
163
|
-
|
|
164
|
-
return (_jsx(BaseCombobox.Root, { ...props, id: inputId, open: open, defaultOpen: defaultOpen, onItemHighlighted: onItemHighlighted, isItemEqualToValue: (item, selected) => item.value === selected.value, onOpenChange: (nextOpen, details) => {
|
|
168
|
+
return (_jsx(BaseCombobox.Root, { ...props, id: inputId, defaultOpen: defaultOpen, isItemEqualToValue: (item, selected) => item.value === selected.value, onOpenChange: (nextOpen, details) => {
|
|
165
169
|
onOpenChange?.(nextOpen, details);
|
|
166
170
|
if (!details.isCanceled)
|
|
167
171
|
setOpenInternalState(nextOpen);
|
|
168
172
|
}, children: _jsx(ComboboxContext.Provider, { value: {
|
|
169
173
|
inputId,
|
|
170
|
-
open: open ?? openInternalState,
|
|
174
|
+
open: props.open ?? openInternalState,
|
|
171
175
|
disabled: props.disabled ?? false,
|
|
172
176
|
readOnly: props.readOnly ?? false,
|
|
173
177
|
required: props.required ?? false,
|
|
174
|
-
|
|
178
|
+
validation: readValidation(validation),
|
|
179
|
+
describedByIds,
|
|
180
|
+
setDescribedByIds,
|
|
181
|
+
}, children: children }) }));
|
|
175
182
|
}
|
|
176
183
|
/** Use for the standard stacked layout, or omit when supplying your own layout. */
|
|
177
184
|
export const Container = /* @__PURE__ */ forwardRef(function Container({ disableStyle, className, ...props }, ref) {
|
|
@@ -179,15 +186,15 @@ export const Container = /* @__PURE__ */ forwardRef(function Container({ disable
|
|
|
179
186
|
});
|
|
180
187
|
/** Labels the input automatically using Root's id. Supply the visible label as children; no htmlFor needed. */
|
|
181
188
|
export const Label = /* @__PURE__ */ forwardRef(function Label({ disableStyle, className, ...props }, ref) {
|
|
182
|
-
const
|
|
189
|
+
const context = useComboboxContext();
|
|
183
190
|
const attributes = usePartAttributes();
|
|
184
|
-
return (_jsx("label", { ...attributes, ...props, ref: ref, htmlFor: inputId, "data-component": "combobox-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
191
|
+
return (_jsx("label", { ...attributes, ...props, ref: ref, htmlFor: context.inputId, "data-component": "combobox-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
185
192
|
});
|
|
186
193
|
/** Search input with built-in filtering and selected-label display. Its id is managed by Root. Inside ChipsList, the preset automatically uses the compact chip-input sizing. */
|
|
187
|
-
export const Input = /* @__PURE__ */ forwardRef(function Input({ disableStyle, className, ...props }, ref) {
|
|
188
|
-
const
|
|
194
|
+
export const Input = /* @__PURE__ */ forwardRef(function Input({ disableStyle, className, 'aria-describedby': describedBy, ...props }, ref) {
|
|
195
|
+
const context = useComboboxContext();
|
|
189
196
|
const inChips = useContext(ChipsContext);
|
|
190
|
-
return (_jsx(BaseCombobox.Input, { ...props, ref: ref, id: inputId, "data-component": "combobox-input", "data-style-disabled": disableStyle ? '' : undefined, "data-in-chips": inChips ? '' : undefined, className: className }));
|
|
197
|
+
return (_jsx(BaseCombobox.Input, { "aria-invalid": context.validation.state === 'error' || undefined, "aria-describedby": [describedBy, ...context.describedByIds].filter(Boolean).join(' ') || undefined, ...props, ref: ref, id: context.inputId, "data-component": "combobox-input", "data-style-disabled": disableStyle ? '' : undefined, "data-in-chips": inChips ? '' : undefined, className: className }));
|
|
191
198
|
});
|
|
192
199
|
function ChipsListInner({ disableStyle, children, className, ...props }, ref) {
|
|
193
200
|
return (_jsx(BaseCombobox.Value, { children: (selected) => (_jsx(ChipsContext.Provider, { value: true, children: _jsx(BaseCombobox.Chips, { ...props, ref: ref, "data-slot": "chips-list", "data-component": "combobox-chipslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: typeof children === 'function' ? children(selected) : children }) })) }));
|
|
@@ -222,24 +229,24 @@ export const ChipsList = /* @__PURE__ */ forwardRef(ChipsListInner);
|
|
|
222
229
|
/** Reads Base UI selection without rendering its own element. Use its children callback only when you need a custom selection display; Input already displays the selected label automatically. */
|
|
223
230
|
export const Value = BaseCombobox.Value;
|
|
224
231
|
/** Required listbox and scroll viewport inside Popup. Place GroupsList inside it. Owns keyboard/listbox semantics; do not nest another listbox primitive. */
|
|
225
|
-
export const ScrollArea = /* @__PURE__ */ forwardRef(function ScrollArea({ disableStyle, className,
|
|
226
|
-
return (_jsx(BaseCombobox.List, { ...props, ref: ref,
|
|
232
|
+
export const ScrollArea = /* @__PURE__ */ forwardRef(function ScrollArea({ disableStyle, className, ...props }, ref) {
|
|
233
|
+
return (_jsx(BaseCombobox.List, { ...props, ref: ref, "data-component": "combobox-scrollarea", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
227
234
|
});
|
|
228
235
|
/** Required groups container inside ScrollArea. A children callback receives each automatically filtered group; do not filter or map the original groups again. Manually annotate group with Combobox.GroupType<typeof rootItems>, using the exact items variable passed to Root. */
|
|
229
|
-
export function GroupsList({ disableStyle, children, className,
|
|
230
|
-
return (_jsx("div", { ...props,
|
|
236
|
+
export function GroupsList({ disableStyle, children, className, ...props }) {
|
|
237
|
+
return (_jsx("div", { ...props, "data-component": "combobox-groupslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: typeof children === 'function' ? (_jsx(BaseCombobox.Collection, { children: children })) : (children) }));
|
|
231
238
|
}
|
|
232
239
|
/** Required items container inside Group. A children callback receives the filtered items belonging to that Group; do not repeat filtering yourself. Manually annotate item with Combobox.ItemType<typeof rootItems>, using the exact items variable passed to Root. */
|
|
233
|
-
export function ItemsList({ disableStyle, children, className,
|
|
234
|
-
return (_jsx("div", { ...props,
|
|
240
|
+
export function ItemsList({ disableStyle, children, className, ...props }) {
|
|
241
|
+
return (_jsx("div", { ...props, "data-component": "combobox-itemslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: typeof children === 'function' ? (_jsx(BaseCombobox.Collection, { children: children })) : (children) }));
|
|
235
242
|
}
|
|
236
243
|
/** Required wrapper around ItemsList, even for a visually flat list. Pass group.items. A GroupLabel is optional; omit it when the group has an empty label. */
|
|
237
|
-
export function Group({ disableStyle, className,
|
|
238
|
-
return (_jsx(BaseCombobox.Group, { ...props,
|
|
244
|
+
export function Group({ disableStyle, className, ...props }) {
|
|
245
|
+
return (_jsx(BaseCombobox.Group, { ...props, "data-component": "combobox-group", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
239
246
|
}
|
|
240
247
|
/** Required selectable row inside ItemsList. Pass the complete item object as value, with ItemText and ItemIndicator inside. Selection, highlighting, and keyboard behavior are built in. */
|
|
241
|
-
export function Item({ disableStyle, className,
|
|
242
|
-
return (_jsx(BaseCombobox.Item, { ...props,
|
|
248
|
+
export function Item({ disableStyle, className, ...props }) {
|
|
249
|
+
return (_jsx(BaseCombobox.Item, { ...props, "data-component": "combobox-item", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
243
250
|
}
|
|
244
251
|
/** Popup containing Empty, an optional Loading message, and ScrollArea, in that order. Already includes the portal and positioner: do not add either yourself. Defaults to bottom/start with a 5px gap. Core available-space and anchor-width inline styles stay active when preset styling is disabled. */
|
|
245
252
|
export function Popup({ disableStyle, container, keepMounted, anchor, positionMethod, side = 'bottom', sideOffset = 5, align = 'start', alignOffset, collisionBoundary, collisionPadding, sticky, arrowPadding, disableAnchorTracking, collisionAvoidance, className, style, ...props }) {
|
|
@@ -255,14 +262,6 @@ export function Popup({ disableStyle, container, keepMounted, anchor, positionMe
|
|
|
255
262
|
export const Arrow = /* @__PURE__ */ forwardRef(function Arrow({ disableStyle, className, style, ...props }, ref) {
|
|
256
263
|
return (_jsxs(BaseCombobox.Arrow, { style: style, render: _jsx("svg", { ...props, ref: ref, "aria-hidden": true, width: "20", height: "10", viewBox: "0 0 20 10" }), "data-component": "combobox-arrow", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: [_jsx("path", { d: "M9.66437 2.60207L4.80758 6.97318C4.07308 7.63423 3.11989 8 2.13172 8H0V10H20V8H18.5349C17.5468 8 16.5936 7.63423 15.8591 6.97318L11.0023 2.60207C10.622 2.2598 10.0447 2.25979 9.66437 2.60207Z", "data-component": "combobox-arrow-1" }), _jsx("path", { d: "M8.99542 1.85876C9.75604 1.17425 10.9106 1.17422 11.6713 1.85878L16.5281 6.22989C17.0789 6.72568 17.7938 7.00001 18.5349 7.00001L15.89 7L11.0023 2.60207C10.622 2.2598 10.0447 2.2598 9.66436 2.60207L4.77734 7L2.13171 7.00001C2.87284 7.00001 3.58774 6.72568 4.13861 6.22989L8.99542 1.85876Z", "data-component": "combobox-arrow-2" }), _jsx("path", { d: "M10.3333 3.34539L5.47654 7.71648C4.55842 8.54279 3.36693 9 2.13172 9H0V8H2.13172C3.11989 8 4.07308 7.63423 4.80758 6.97318L9.66437 2.60207C10.0447 2.25979 10.622 2.2598 11.0023 2.60207L15.8591 6.97318C16.5936 7.63423 17.5468 8 18.5349 8H20V9H18.5349C17.2998 9 16.1083 8.54278 15.1901 7.71648L10.3333 3.34539Z", "data-component": "combobox-arrow-3" })] }));
|
|
257
264
|
});
|
|
258
|
-
/** Behavior only: turns its single child element into the popup trigger. Adds no preset styling and has no disableStyle prop. Use an accessible button child; pass className to the child for its appearance. */
|
|
259
|
-
export const PopupOpenHandler = /* @__PURE__ */ forwardRef(function PopupOpenHandler({ children, ...props }, ref) {
|
|
260
|
-
return _jsx(BaseCombobox.Trigger, { ...props, ref: ref, render: children });
|
|
261
|
-
});
|
|
262
|
-
/** Behavior only: turns its single child element into a removal control for the surrounding Chip. Adds no preset styling and has no disableStyle prop. Use an accessible button child. */
|
|
263
|
-
export const ChipRemoveHandler = /* @__PURE__ */ forwardRef(function ChipRemoveHandler({ children, ...props }, ref) {
|
|
264
|
-
return _jsx(BaseCombobox.ChipRemove, { ...props, ref: ref, render: children });
|
|
265
|
-
});
|
|
266
265
|
/** Optional input adornment container inside InputGroup. Wraps icons, text, or buttons without adding trigger behavior. */
|
|
267
266
|
export const Addon = /* @__PURE__ */ forwardRef(function Addon({ disableStyle, variant = 'normal', className, ...props }, ref) {
|
|
268
267
|
return (_jsx("div", { ...props, ref: ref, "data-variant": variant, "data-component": "combobox-addon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
@@ -287,10 +286,10 @@ export const AddonButton = /* @__PURE__ */ forwardRef(function AddonButton({ dis
|
|
|
287
286
|
const attributes = usePartAttributes();
|
|
288
287
|
return (_jsx("button", { ...attributes, ...props, ref: ref, type: type, disabled: disabled || context.disabled || context.readOnly, "data-component": "combobox-addonbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
289
288
|
});
|
|
290
|
-
/** Input control wrapper. Place Input (or ChipsList containing Input) and optional Addon controls inside. Root
|
|
289
|
+
/** Input control wrapper. Place Input (or ChipsList containing Input) and optional Addon controls inside. Root validation controls its preset validation border. */
|
|
291
290
|
export const InputGroup = /* @__PURE__ */ forwardRef(function InputGroup({ disableStyle, className, ...props }, ref) {
|
|
292
|
-
const
|
|
293
|
-
return (_jsx(BaseCombobox.InputGroup, { "data-
|
|
291
|
+
const attributes = usePartAttributes();
|
|
292
|
+
return (_jsx(BaseCombobox.InputGroup, { "data-validation": attributes['data-validation'], ...props, ref: ref, "data-component": "combobox-inputgroup", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
294
293
|
});
|
|
295
294
|
/** Displays one selected item inside ChipsList. Keep chips in selected-item order so Base UI can remove the matching item. Supply the item label and an optional removal control. */
|
|
296
295
|
export const Chip = /* @__PURE__ */ forwardRef(function Chip({ disableStyle, className, ...props }, ref) {
|
|
@@ -335,40 +334,54 @@ export const EmptyText = /* @__PURE__ */ forwardRef(function EmptyText({ disable
|
|
|
335
334
|
const attributes = usePartAttributes();
|
|
336
335
|
return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "combobox-emptytext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
337
336
|
});
|
|
338
|
-
/** Optional supporting text. Supply its content; it
|
|
339
|
-
export const Description = /* @__PURE__ */ forwardRef(function Description({ disableStyle, className, ...props }, ref) {
|
|
337
|
+
/** Optional supporting text. Supply its content; it describes the input to screen readers automatically. */
|
|
338
|
+
export const Description = /* @__PURE__ */ forwardRef(function Description({ disableStyle, className, id, ...props }, ref) {
|
|
339
|
+
const describedById = useDescribedById(id);
|
|
340
340
|
const attributes = usePartAttributes();
|
|
341
|
-
return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "combobox-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
341
|
+
return (_jsx("div", { ...attributes, ...props, id: describedById, ref: ref, "data-component": "combobox-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
342
342
|
});
|
|
343
|
-
/**
|
|
344
|
-
export const Error = /* @__PURE__ */ forwardRef(function Error({
|
|
345
|
-
const
|
|
346
|
-
|
|
343
|
+
/** Shows itself only while Root's validation is `'error'`: with no children it shows the message from `['error', message]`, a function children formats that message, and other children replace it. */
|
|
344
|
+
export const Error = /* @__PURE__ */ forwardRef(function Error({ children, ...props }, ref) {
|
|
345
|
+
const context = useComboboxContext();
|
|
346
|
+
const content = validationMessageContent(context.validation, 'error', children);
|
|
347
|
+
if (content === undefined)
|
|
348
|
+
return null;
|
|
349
|
+
return _jsx(Message, { ...props, ref: ref, role: "alert", component: "combobox-error", children: content });
|
|
347
350
|
});
|
|
348
|
-
/**
|
|
349
|
-
export const Success = /* @__PURE__ */ forwardRef(function Success({
|
|
351
|
+
/** Shows itself only while Root's validation is `'success'`: with no children it shows the message from `['success', message]`, a function children formats that message, and other children replace it. */
|
|
352
|
+
export const Success = /* @__PURE__ */ forwardRef(function Success({ children, ...props }, ref) {
|
|
353
|
+
const context = useComboboxContext();
|
|
354
|
+
const content = validationMessageContent(context.validation, 'success', children);
|
|
355
|
+
if (content === undefined)
|
|
356
|
+
return null;
|
|
357
|
+
return _jsx(Message, { ...props, ref: ref, role: "status", component: "combobox-success", children: content });
|
|
358
|
+
});
|
|
359
|
+
// The shared body of Error and Success, mounted only while they show, so only visible messages describe the input
|
|
360
|
+
const Message = /* @__PURE__ */ forwardRef(function Message({ disableStyle, className, id, component, ...props }, ref) {
|
|
361
|
+
const describedById = useDescribedById(id);
|
|
350
362
|
const attributes = usePartAttributes();
|
|
351
|
-
return
|
|
363
|
+
return _jsx("div", { "aria-atomic": "true", ...attributes, ...props, id: describedById, ref: ref, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
|
|
352
364
|
});
|
|
353
365
|
/** Built-in decorative open-button icon. Place inside AddonOpenButton; no children needed. Defaults to strokeWidth 1.5. */
|
|
354
|
-
export const AddonOpenButtonIcon = /* @__PURE__ */ forwardRef(function AddonOpenButtonIcon(
|
|
355
|
-
|
|
356
|
-
return (_jsx(ChevronsUpDown, { ...attributes, "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "combobox-addonopenbuttonicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
366
|
+
export const AddonOpenButtonIcon = /* @__PURE__ */ forwardRef(function AddonOpenButtonIcon(props, ref) {
|
|
367
|
+
return _jsx(BuiltInIcon, { ...props, ref: ref, icon: ChevronsUpDown, component: "combobox-addonopenbuttonicon" });
|
|
357
368
|
});
|
|
358
369
|
/** Built-in decorative clear icon. Place inside AddonClearButton; no children needed. Defaults to strokeWidth 1.5. */
|
|
359
|
-
export const AddonClearButtonIcon = /* @__PURE__ */ forwardRef(function AddonClearButtonIcon(
|
|
360
|
-
|
|
361
|
-
return (_jsx(X, { ...attributes, "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "combobox-addonclearbuttonicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
370
|
+
export const AddonClearButtonIcon = /* @__PURE__ */ forwardRef(function AddonClearButtonIcon(props, ref) {
|
|
371
|
+
return _jsx(BuiltInIcon, { ...props, ref: ref, icon: X, component: "combobox-addonclearbuttonicon" });
|
|
362
372
|
});
|
|
363
373
|
/** Built-in decorative removal icon. Place inside ChipRemoveButton; no children needed. Defaults to strokeWidth 1.5. */
|
|
364
|
-
export const ChipRemoveButtonIcon = /* @__PURE__ */ forwardRef(function ChipRemoveButtonIcon(
|
|
365
|
-
|
|
366
|
-
return (_jsx(X, { ...attributes, "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "combobox-chipremovebuttonicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
374
|
+
export const ChipRemoveButtonIcon = /* @__PURE__ */ forwardRef(function ChipRemoveButtonIcon(props, ref) {
|
|
375
|
+
return _jsx(BuiltInIcon, { ...props, ref: ref, icon: X, component: "combobox-chipremovebuttonicon" });
|
|
367
376
|
});
|
|
368
377
|
/** Optional spinner inside Addon. Does not detect requests: you decide when to render it. Defaults to strokeWidth 1.5. */
|
|
369
|
-
export const AddonLoadingIcon = /* @__PURE__ */ forwardRef(function AddonLoadingIcon(
|
|
378
|
+
export const AddonLoadingIcon = /* @__PURE__ */ forwardRef(function AddonLoadingIcon(props, ref) {
|
|
379
|
+
return _jsx(BuiltInIcon, { ...props, ref: ref, icon: LoaderCircle, component: "combobox-addonloadingicon" });
|
|
380
|
+
});
|
|
381
|
+
// The shared body of the built-in decorative icons above, which only differ by their icon and component name
|
|
382
|
+
const BuiltInIcon = /* @__PURE__ */ forwardRef(function BuiltInIcon({ disableStyle, className, strokeWidth = 1.5, icon: Icon, component, ...props }, ref) {
|
|
370
383
|
const attributes = usePartAttributes();
|
|
371
|
-
return
|
|
384
|
+
return _jsx(Icon, { ...attributes, "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
|
|
372
385
|
});
|
|
373
386
|
/** Required selection indicator inside Item. Visibility is automatic and a checkmark is supplied: no children or selection condition needed. Pass children only to replace the built-in checkmark. */
|
|
374
387
|
export const ItemIndicator = /* @__PURE__ */ forwardRef(function ItemIndicator({ disableStyle, children, keepMounted, ...props }, ref) {
|
|
@@ -391,11 +404,11 @@ export const LoadingText = /* @__PURE__ */ forwardRef(function LoadingText({ dis
|
|
|
391
404
|
return (_jsx("div", { ...props, ref: ref, "data-component": "combobox-loadingtext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
392
405
|
});
|
|
393
406
|
/** Built-in decorative spinner for Loading. No children needed; you control when it is rendered. */
|
|
394
|
-
export const LoadingIcon = /* @__PURE__ */ forwardRef(function LoadingIcon({ disableStyle, className, ...props }, ref) {
|
|
395
|
-
return (_jsx(LoaderCircle, { "aria-hidden": true,
|
|
407
|
+
export const LoadingIcon = /* @__PURE__ */ forwardRef(function LoadingIcon({ disableStyle, className, strokeWidth = 2, ...props }, ref) {
|
|
408
|
+
return (_jsx(LoaderCircle, { "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "combobox-loadingicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
396
409
|
});
|
|
397
|
-
const ComboboxContext =
|
|
398
|
-
|
|
410
|
+
const ComboboxContext = /* @__PURE__ */ createContext(null);
|
|
411
|
+
// Telling Input it sits inside ChipsList, so the preset uses the compact chip-input sizing
|
|
399
412
|
const ChipsContext = /* @__PURE__ */ createContext(false);
|
|
400
413
|
function useComboboxContext() {
|
|
401
414
|
const context = useContext(ComboboxContext);
|
|
@@ -403,15 +416,25 @@ function useComboboxContext() {
|
|
|
403
416
|
throw new globalThis.Error('Combobox parts must be inside Combobox.Root');
|
|
404
417
|
return context;
|
|
405
418
|
}
|
|
419
|
+
// The state attributes every part carries, so presets can style any part from Root's state
|
|
406
420
|
function usePartAttributes() {
|
|
407
|
-
const
|
|
408
|
-
const tone = useToneContext();
|
|
421
|
+
const context = useComboboxContext();
|
|
409
422
|
return {
|
|
410
|
-
'data-open': open ? '' : undefined,
|
|
411
|
-
'data-disabled': disabled ? '' : undefined,
|
|
412
|
-
'data-readonly': readOnly ? '' : undefined,
|
|
413
|
-
'data-required': required ? '' : undefined,
|
|
414
|
-
|
|
423
|
+
'data-open': context.open ? '' : undefined,
|
|
424
|
+
'data-disabled': context.disabled ? '' : undefined,
|
|
425
|
+
'data-readonly': context.readOnly ? '' : undefined,
|
|
426
|
+
'data-required': context.required ? '' : undefined,
|
|
427
|
+
...validationAttributes(context.validation),
|
|
415
428
|
};
|
|
416
429
|
}
|
|
417
|
-
|
|
430
|
+
// Registering a part's id in Input's aria-describedby while the part is mounted
|
|
431
|
+
function useDescribedById(id) {
|
|
432
|
+
const context = useComboboxContext();
|
|
433
|
+
const generatedId = useId();
|
|
434
|
+
const describedById = id ?? generatedId;
|
|
435
|
+
useEffect(() => {
|
|
436
|
+
context.setDescribedByIds((current) => [...current, describedById]);
|
|
437
|
+
return () => context.setDescribedByIds((current) => current.filter((currentId) => currentId !== describedById));
|
|
438
|
+
}, [describedById, context.setDescribedByIds]);
|
|
439
|
+
return describedById;
|
|
440
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StyleProps } from '../../types/Style.ts';
|
|
2
|
+
import type { AsChildProps } from '../../utils/asChild.ts';
|
|
2
3
|
import type { DatePickerProps } from 'react-aria-components/DatePicker';
|
|
3
4
|
import type { DateRangePickerProps } from 'react-aria-components/DateRangePicker';
|
|
4
5
|
import { Label as AriaLabel } from 'react-aria-components/Label';
|
|
@@ -16,6 +17,8 @@ import { FieldError } from 'react-aria-components/FieldError';
|
|
|
16
17
|
import type { CalendarDate } from '@internationalized/date';
|
|
17
18
|
import type { ComponentProps, ReactElement, ReactNode } from 'react';
|
|
18
19
|
import type { SVGIconProps } from '../../types/Icon.ts';
|
|
20
|
+
import type { Validation } from '../../types/Validation.ts';
|
|
21
|
+
import type { ValidationMessageChildren } from '../../utils/Validation.ts';
|
|
19
22
|
type DateRange = {
|
|
20
23
|
start: string;
|
|
21
24
|
end: string;
|
|
@@ -35,8 +38,6 @@ type SharedRootProps = {
|
|
|
35
38
|
readOnly?: DatePickerProps<CalendarDate>['isReadOnly'];
|
|
36
39
|
/** Require a date when validating a surrounding form. */
|
|
37
40
|
required?: DatePickerProps<CalendarDate>['isRequired'];
|
|
38
|
-
/** Mark the picker invalid for accessibility and validation; use tone for a separate visual tone. */
|
|
39
|
-
invalid?: DatePickerProps<CalendarDate>['isInvalid'];
|
|
40
41
|
/** Control the popup from application state. Omit to let trigger interactions manage it. */
|
|
41
42
|
open?: DatePickerProps<CalendarDate>['isOpen'];
|
|
42
43
|
/** Prevent selection before this ISO calendar date (YYYY-MM-DD). Omit for no lower limit. */
|
|
@@ -47,8 +48,11 @@ type SharedRootProps = {
|
|
|
47
48
|
placeholderValue?: string | null;
|
|
48
49
|
/** Choose date formatting and language. Omit to use the inherited application locale. */
|
|
49
50
|
locale?: string;
|
|
50
|
-
/**
|
|
51
|
-
|
|
51
|
+
/**
|
|
52
|
+
* The picker's validation state, with an optional message: `'error'` marks it invalid, `['error', 'Pick a later date']` also shows that message in Error. Same for `'success'` and Success.
|
|
53
|
+
* Omit it to keep only the picker's own validation, like a required or out-of-range date.
|
|
54
|
+
*/
|
|
55
|
+
validation?: Validation;
|
|
52
56
|
};
|
|
53
57
|
type SingleRootProps = Pick<DatePickerProps<CalendarDate>, CoreKeys | 'name' | 'autoComplete'> & SharedRootProps & {
|
|
54
58
|
/** Use range for a start/end selection; single is the default. Choose the corresponding field composition. */
|
|
@@ -200,17 +204,8 @@ export declare function AddonOpenButtonIcon({ disableStyle, children, className,
|
|
|
200
204
|
/** Omit for the supplied default icon; pass a child only to replace it. */
|
|
201
205
|
children?: ReactElement<SVGIconProps>;
|
|
202
206
|
}) & StyleProps): ReactElement<SVGIconProps, string | import("react").JSXElementConstructor<any>>;
|
|
203
|
-
/**
|
|
204
|
-
export declare function
|
|
205
|
-
/** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
|
|
206
|
-
children: ReactElement<ComponentProps<'button'>>;
|
|
207
|
-
}): import("react").JSX.Element;
|
|
208
|
-
export declare function OpenButton({ disableStyle, className, isDisabled, ...props }: StyledButtonProps & StyleProps): import("react").JSX.Element;
|
|
209
|
-
/** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
|
|
210
|
-
export declare function OpenHandler({ children, isDisabled, ...props }: Omit<StyledButtonProps, 'children' | 'render'> & {
|
|
211
|
-
/** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
|
|
212
|
-
children: ReactElement<ComponentProps<'button'>>;
|
|
213
|
-
}): import("react").JSX.Element;
|
|
207
|
+
/** Opens the calendar popup. Pass asChild to give this behavior to your own button, like a "Choose appointment" Button; it keeps the state data attributes but none of this part's styling. */
|
|
208
|
+
export declare function OpenButton({ asChild, disableStyle, isDisabled, children, ...props }: StyledButtonProps & AsChildProps & StyleProps): import("react").JSX.Element;
|
|
214
209
|
/** Formats the selected date or range automatically. Omit children for the usual display; supply children only to replace it. Placeholder appears before selection. */
|
|
215
210
|
export declare function OpenButtonValue({ disableStyle, children, placeholder, className, ...props }: (ComponentProps<'span'> & {
|
|
216
211
|
/** Shown before a date is selected. Omit children to keep the automatic formatted date display. */
|
|
@@ -226,7 +221,7 @@ export type PopupProps = Omit<PopoverProps, 'className' | 'style' | 'render' | '
|
|
|
226
221
|
style?: ComponentProps<'div'>['style'];
|
|
227
222
|
} & StyleProps;
|
|
228
223
|
/** Use the same calendar composition for both trigger choices. Opening and focus management are handled by the picker; do not add your own popup visibility condition. */
|
|
229
|
-
export declare const Popup: import("react").ForwardRefExoticComponent<Omit<PopoverProps, "
|
|
224
|
+
export declare const Popup: import("react").ForwardRefExoticComponent<Omit<PopoverProps, "className" | "slot" | "style" | "render" | "onOpenChange" | "defaultOpen" | "isOpen" | "trigger"> & {
|
|
230
225
|
className?: string;
|
|
231
226
|
style?: ComponentProps<"div">["style"];
|
|
232
227
|
} & StyleProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -268,16 +263,6 @@ export declare function Actions({ disableStyle, className, ...props }: Component
|
|
|
268
263
|
export declare function ViewDateValue({ disableStyle, className, level, ...props }: (Omit<ComponentProps<'h2'>, 'children'> & Pick<ComponentProps<typeof Heading>, 'level'>) & StyleProps): import("react").JSX.Element;
|
|
269
264
|
export declare function PreviousButton({ disableStyle, className, isDisabled, ...props }: StyledButtonProps & StyleProps): import("react").JSX.Element;
|
|
270
265
|
export declare function NextButton({ disableStyle, className, isDisabled, ...props }: StyledButtonProps & StyleProps): import("react").JSX.Element;
|
|
271
|
-
/** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
|
|
272
|
-
export declare function PreviousHandler({ children, isDisabled, ...props }: Omit<StyledButtonProps, 'children' | 'render'> & {
|
|
273
|
-
/** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
|
|
274
|
-
children: ReactElement<ComponentProps<'button'>>;
|
|
275
|
-
}): import("react").JSX.Element;
|
|
276
|
-
/** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
|
|
277
|
-
export declare function NextHandler({ children, isDisabled, ...props }: Omit<StyledButtonProps, 'children' | 'render'> & {
|
|
278
|
-
/** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
|
|
279
|
-
children: ReactElement<ComponentProps<'button'>>;
|
|
280
|
-
}): import("react").JSX.Element;
|
|
281
266
|
/** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
|
|
282
267
|
export declare function PreviousButtonIcon({ disableStyle, children, className, ...props }: (Omit<SVGIconProps, 'children'> & {
|
|
283
268
|
/** Omit for the supplied default icon; pass a child only to replace it. */
|
|
@@ -299,11 +284,13 @@ export declare function Table({ disableStyle, index, className, ...props }: (Omi
|
|
|
299
284
|
index?: number;
|
|
300
285
|
}) & StyleProps): import("react").JSX.Element;
|
|
301
286
|
export declare function Description({ disableStyle, className, ...props }: Omit<ComponentProps<typeof Text>, 'slot' | 'render'> & StyleProps): import("react").JSX.Element;
|
|
302
|
-
/** Keep mounted
|
|
303
|
-
export declare function Error({ disableStyle, className, ...props }: (Omit<ComponentProps<typeof FieldError>, 'className' | 'render'> & {
|
|
287
|
+
/** Keep mounted: it shows while the picker is invalid. With no children it shows Root's message from `['error', message]`, or else the picker's own validation text, like a required or out-of-range date. A function children formats Root's message, and other children replace it. */
|
|
288
|
+
export declare function Error({ disableStyle, className, children, ...props }: (Omit<ComponentProps<typeof FieldError>, 'className' | 'render' | 'children'> & {
|
|
304
289
|
className?: string;
|
|
290
|
+
children?: ValidationMessageChildren;
|
|
305
291
|
}) & StyleProps): import("react").JSX.Element;
|
|
306
|
-
/**
|
|
307
|
-
export declare function Success({ disableStyle, className, ...props }: Omit<ComponentProps<typeof Text>, 'slot' | 'render'> &
|
|
292
|
+
/** Shows itself only while Root's validation is `'success'`: with no children it shows the message from `['success', message]`, a function children formats that message, and other children replace it. */
|
|
293
|
+
export declare function Success({ disableStyle, className, children, ...props }: Omit<ComponentProps<typeof Text>, 'slot' | 'render' | 'children'> & {
|
|
294
|
+
children?: ValidationMessageChildren;
|
|
295
|
+
} & StyleProps): import("react").JSX.Element | null;
|
|
308
296
|
export {};
|
|
309
|
-
//# sourceMappingURL=index.d.ts.map
|