@primecoderin/fast-ui-react 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -0
- package/LICENSE +21 -0
- package/README.md +180 -3
- package/dist/_virtual/_rolldown/runtime.js +12 -0
- package/dist/charts.d.ts +7 -0
- package/dist/charts.js +7 -0
- package/dist/components/Avatar/Avatar.d.ts +12 -0
- package/dist/components/Avatar/Avatar.js +92 -0
- package/dist/components/Button/Button.d.ts +44 -0
- package/dist/components/Button/Button.js +221 -0
- package/dist/components/Checkbox/CheckboxBox.d.ts +33 -0
- package/dist/components/Checkbox/CheckboxBox.js +148 -0
- package/dist/components/CodeSnippet/CodeSnippet.d.ts +26 -0
- package/dist/components/CodeSnippet/CodeSnippet.js +153 -0
- package/dist/components/Collapsible/Collapsible.d.ts +20 -0
- package/dist/components/Collapsible/Collapsible.js +97 -0
- package/dist/components/Container/Container.d.ts +301 -0
- package/dist/components/Container/Container.js +20 -0
- package/dist/components/FloatingActionButton/FloatingActionButton.d.ts +22 -0
- package/dist/components/FloatingActionButton/FloatingActionButton.js +141 -0
- package/dist/components/Grid/Grid.d.ts +311 -0
- package/dist/components/Grid/Grid.js +30 -0
- package/dist/components/IconTile/IconTile.d.ts +12 -0
- package/dist/components/IconTile/IconTile.js +70 -0
- package/dist/components/InlineError/InlineError.d.ts +9 -0
- package/dist/components/InlineError/InlineError.js +62 -0
- package/dist/components/Kbd/Kbd.d.ts +11 -0
- package/dist/components/Kbd/Kbd.js +31 -0
- package/dist/components/Link/Link.d.ts +18 -0
- package/dist/components/Link/Link.js +68 -0
- package/dist/components/Menu/ContextMenu.d.ts +18 -0
- package/dist/components/Menu/ContextMenu.js +68 -0
- package/dist/components/Menu/Menu.d.ts +86 -0
- package/dist/components/Menu/Menu.js +394 -0
- package/dist/components/OtpInput/OtpInput.d.ts +32 -0
- package/dist/components/OtpInput/OtpInput.js +177 -0
- package/dist/components/Popover/HoverPopover.d.ts +22 -0
- package/dist/components/Popover/HoverPopover.js +74 -0
- package/dist/components/Popover/Popover.d.ts +21 -0
- package/dist/components/Popover/Popover.js +64 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +17 -0
- package/dist/components/ProgressBar/ProgressBar.js +44 -0
- package/dist/components/Rating/Rating.d.ts +49 -0
- package/dist/components/Rating/Rating.js +241 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts +23 -0
- package/dist/components/ScrollArea/ScrollArea.js +90 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +29 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +99 -0
- package/dist/components/Separator/Separator.d.ts +9 -0
- package/dist/components/Separator/Separator.js +34 -0
- package/dist/components/Skeleton/Skeleton.d.ts +31 -0
- package/dist/components/Skeleton/Skeleton.js +152 -0
- package/dist/components/Slider/Slider.d.ts +54 -0
- package/dist/components/Slider/Slider.js +178 -0
- package/dist/components/Spinner/Spinner.d.ts +17 -0
- package/dist/components/Spinner/Spinner.js +118 -0
- package/dist/components/Stack/Stack.d.ts +302 -0
- package/dist/components/Stack/Stack.js +14 -0
- package/dist/components/StateIcon/StateIcon.d.ts +11 -0
- package/dist/components/StateIcon/StateIcon.js +65 -0
- package/dist/components/StatusBadge/StatusBadge.d.ts +19 -0
- package/dist/components/StatusBadge/StatusBadge.js +82 -0
- package/dist/components/Tabs/Tabs.d.ts +28 -0
- package/dist/components/Tabs/Tabs.js +109 -0
- package/dist/components/Tag/Tag.d.ts +11 -0
- package/dist/components/Tag/Tag.js +66 -0
- package/dist/components/Toast/AppToaster.d.ts +8 -0
- package/dist/components/Toast/AppToaster.js +135 -0
- package/dist/components/Toast/toast-manager.d.ts +28 -0
- package/dist/components/Toast/toast-manager.js +47 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +26 -0
- package/dist/components/ToggleButton/ToggleButton.js +106 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +32 -0
- package/dist/components/ToggleGroup/ToggleGroup.js +79 -0
- package/dist/components/Tooltip/Tooltip.d.ts +16 -0
- package/dist/components/Tooltip/Tooltip.js +58 -0
- package/dist/components/Tooltip/TooltipGroup.d.ts +22 -0
- package/dist/components/Tooltip/TooltipGroup.js +65 -0
- package/dist/components/Typography/Typography.d.ts +17 -0
- package/dist/components/Typography/Typography.js +100 -0
- package/dist/editor-forms.d.ts +1 -0
- package/dist/editor-forms.js +1 -0
- package/dist/editor.d.ts +1 -0
- package/dist/editor.js +1 -0
- package/dist/fonts/LICENSE +93 -0
- package/dist/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
- package/dist/fonts.css +69 -0
- package/dist/forms.d.ts +22 -0
- package/dist/forms.js +23 -0
- package/dist/foundation.css +23 -0
- package/dist/global.css +116 -0
- package/dist/hooks/useAppToast.d.ts +12 -0
- package/dist/hooks/useAppToast.js +29 -0
- package/dist/icons/icons.d.ts +43 -0
- package/dist/icons/icons.js +44 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.js +101 -0
- package/dist/patterns/Accordion/Accordion.d.ts +35 -0
- package/dist/patterns/Accordion/Accordion.js +139 -0
- package/dist/patterns/Alert/Alert.d.ts +38 -0
- package/dist/patterns/Alert/Alert.js +151 -0
- package/dist/patterns/AppShell/AppShell.d.ts +39 -0
- package/dist/patterns/AppShell/AppShell.js +218 -0
- package/dist/patterns/Breadcrumbs/Breadcrumbs.d.ts +21 -0
- package/dist/patterns/Breadcrumbs/Breadcrumbs.js +73 -0
- package/dist/patterns/Calendar/Calendar.d.ts +59 -0
- package/dist/patterns/Calendar/Calendar.js +283 -0
- package/dist/patterns/Calendar/DateRangePicker.d.ts +53 -0
- package/dist/patterns/Calendar/DateRangePicker.js +266 -0
- package/dist/patterns/Calendar/FormDateRangeField.d.ts +24 -0
- package/dist/patterns/Calendar/FormDateRangeField.js +138 -0
- package/dist/patterns/Card/Card.d.ts +26 -0
- package/dist/patterns/Card/Card.js +125 -0
- package/dist/patterns/Carousel/Carousel.d.ts +33 -0
- package/dist/patterns/Carousel/Carousel.js +127 -0
- package/dist/patterns/Cascader/Cascader.d.ts +53 -0
- package/dist/patterns/Cascader/Cascader.js +371 -0
- package/dist/patterns/Cascader/FormCascaderField.d.ts +21 -0
- package/dist/patterns/Cascader/FormCascaderField.js +130 -0
- package/dist/patterns/Charts/AreaChart.d.ts +13 -0
- package/dist/patterns/Charts/AreaChart.js +220 -0
- package/dist/patterns/Charts/BarChart.d.ts +11 -0
- package/dist/patterns/Charts/BarChart.js +220 -0
- package/dist/patterns/Charts/DonutChart.d.ts +37 -0
- package/dist/patterns/Charts/DonutChart.js +215 -0
- package/dist/patterns/Charts/GaugeChart.d.ts +44 -0
- package/dist/patterns/Charts/GaugeChart.js +210 -0
- package/dist/patterns/Charts/LineChart.d.ts +14 -0
- package/dist/patterns/Charts/LineChart.js +222 -0
- package/dist/patterns/Charts/Sparkline.d.ts +24 -0
- package/dist/patterns/Charts/Sparkline.js +81 -0
- package/dist/patterns/Charts/chart-parts.d.ts +139 -0
- package/dist/patterns/Charts/chart-parts.js +385 -0
- package/dist/patterns/Charts/gauge-math.d.ts +20 -0
- package/dist/patterns/Charts/gauge-math.js +21 -0
- package/dist/patterns/Charts/sparkline-path.d.ts +11 -0
- package/dist/patterns/Charts/sparkline-path.js +24 -0
- package/dist/patterns/ColorPicker/ColorPicker.d.ts +50 -0
- package/dist/patterns/ColorPicker/ColorPicker.js +590 -0
- package/dist/patterns/ColorPicker/FormColorField.d.ts +21 -0
- package/dist/patterns/ColorPicker/FormColorField.js +130 -0
- package/dist/patterns/ColorPicker/color-value.d.ts +19 -0
- package/dist/patterns/ColorPicker/color-value.js +72 -0
- package/dist/patterns/Combobox/Autocomplete.d.ts +48 -0
- package/dist/patterns/Combobox/Autocomplete.js +158 -0
- package/dist/patterns/Combobox/Combobox.d.ts +52 -0
- package/dist/patterns/Combobox/Combobox.js +195 -0
- package/dist/patterns/Combobox/ComboboxPopup.d.ts +24 -0
- package/dist/patterns/Combobox/ComboboxPopup.js +107 -0
- package/dist/patterns/Combobox/FormAutocompleteField.d.ts +17 -0
- package/dist/patterns/Combobox/FormAutocompleteField.js +119 -0
- package/dist/patterns/Combobox/FormComboboxField.d.ts +18 -0
- package/dist/patterns/Combobox/FormComboboxField.js +119 -0
- package/dist/patterns/Combobox/FormMultiSelectField.d.ts +18 -0
- package/dist/patterns/Combobox/FormMultiSelectField.js +119 -0
- package/dist/patterns/Combobox/MultiSelect.d.ts +54 -0
- package/dist/patterns/Combobox/MultiSelect.js +175 -0
- package/dist/patterns/CommandPalette/CommandPalette.d.ts +50 -0
- package/dist/patterns/CommandPalette/CommandPalette.js +193 -0
- package/dist/patterns/DataTable/DataTable.d.ts +107 -0
- package/dist/patterns/DataTable/DataTable.js +364 -0
- package/dist/patterns/DateTimePicker/DateTimePanel.d.ts +28 -0
- package/dist/patterns/DateTimePicker/DateTimePanel.js +444 -0
- package/dist/patterns/DateTimePicker/DateTimePicker.d.ts +75 -0
- package/dist/patterns/DateTimePicker/DateTimePicker.js +271 -0
- package/dist/patterns/DateTimePicker/FormDateTimeField.d.ts +32 -0
- package/dist/patterns/DateTimePicker/FormDateTimeField.js +148 -0
- package/dist/patterns/DateTimePicker/TimeSliders.d.ts +14 -0
- package/dist/patterns/DateTimePicker/TimeSliders.js +206 -0
- package/dist/patterns/DateTimePicker/picker-labels.d.ts +30 -0
- package/dist/patterns/DateTimePicker/picker-labels.js +23 -0
- package/dist/patterns/DateTimePicker/picker-values.d.ts +98 -0
- package/dist/patterns/DateTimePicker/picker-values.js +194 -0
- package/dist/patterns/DescriptionList/DescriptionList.d.ts +20 -0
- package/dist/patterns/DescriptionList/DescriptionList.js +57 -0
- package/dist/patterns/Dialog/Dialog.d.ts +26 -0
- package/dist/patterns/Dialog/Dialog.js +212 -0
- package/dist/patterns/Drawer/Drawer.d.ts +33 -0
- package/dist/patterns/Drawer/Drawer.js +153 -0
- package/dist/patterns/EmptyState/EmptyState.d.ts +35 -0
- package/dist/patterns/EmptyState/EmptyState.js +44 -0
- package/dist/patterns/FileUpload/FileUpload.d.ts +87 -0
- package/dist/patterns/FileUpload/FileUpload.js +417 -0
- package/dist/patterns/FileUpload/FormFileUploadField.d.ts +19 -0
- package/dist/patterns/FileUpload/FormFileUploadField.js +117 -0
- package/dist/patterns/FileUpload/add-files.d.ts +26 -0
- package/dist/patterns/FileUpload/add-files.js +35 -0
- package/dist/patterns/FileUpload/file-size.d.ts +14 -0
- package/dist/patterns/FileUpload/file-size.js +44 -0
- package/dist/patterns/FormField/CheckboxField.d.ts +26 -0
- package/dist/patterns/FormField/CheckboxField.js +97 -0
- package/dist/patterns/FormField/FieldFrame.d.ts +85 -0
- package/dist/patterns/FormField/FieldFrame.js +257 -0
- package/dist/patterns/FormField/FormCheckboxField.d.ts +17 -0
- package/dist/patterns/FormField/FormCheckboxField.js +92 -0
- package/dist/patterns/FormField/FormRadioGroupField.d.ts +16 -0
- package/dist/patterns/FormField/FormRadioGroupField.js +97 -0
- package/dist/patterns/FormField/FormRatingField.d.ts +19 -0
- package/dist/patterns/FormField/FormRatingField.js +119 -0
- package/dist/patterns/FormField/FormSelectField.d.ts +16 -0
- package/dist/patterns/FormField/FormSelectField.js +91 -0
- package/dist/patterns/FormField/FormSliderField.d.ts +22 -0
- package/dist/patterns/FormField/FormSliderField.js +128 -0
- package/dist/patterns/FormField/FormSwitchField.d.ts +19 -0
- package/dist/patterns/FormField/FormSwitchField.js +88 -0
- package/dist/patterns/FormField/FormTextAreaField.d.ts +12 -0
- package/dist/patterns/FormField/FormTextAreaField.js +91 -0
- package/dist/patterns/FormField/FormTextField.d.ts +23 -0
- package/dist/patterns/FormField/FormTextField.js +103 -0
- package/dist/patterns/FormField/RadioGroupField.d.ts +38 -0
- package/dist/patterns/FormField/RadioGroupField.js +201 -0
- package/dist/patterns/FormField/SelectField.d.ts +43 -0
- package/dist/patterns/FormField/SelectField.js +211 -0
- package/dist/patterns/FormField/SwitchField.d.ts +27 -0
- package/dist/patterns/FormField/SwitchField.js +105 -0
- package/dist/patterns/FormField/TextAreaField.d.ts +37 -0
- package/dist/patterns/FormField/TextAreaField.js +134 -0
- package/dist/patterns/FormField/TextField.d.ts +51 -0
- package/dist/patterns/FormField/TextField.js +256 -0
- package/dist/patterns/FormField/error-message.d.ts +6 -0
- package/dist/patterns/FormField/error-message.js +8 -0
- package/dist/patterns/FormField/field-styles.d.ts +44 -0
- package/dist/patterns/FormField/field-styles.js +89 -0
- package/dist/patterns/FormField/field-types.d.ts +4 -0
- package/dist/patterns/FormField/use-field-ids.d.ts +18 -0
- package/dist/patterns/FormField/use-field-ids.js +53 -0
- package/dist/patterns/List/List.d.ts +38 -0
- package/dist/patterns/List/List.js +174 -0
- package/dist/patterns/MentionsInput/FormMentionsField.d.ts +18 -0
- package/dist/patterns/MentionsInput/FormMentionsField.js +124 -0
- package/dist/patterns/MentionsInput/MentionsInput.d.ts +57 -0
- package/dist/patterns/MentionsInput/MentionsInput.js +133 -0
- package/dist/patterns/MentionsInput/mention-text.d.ts +24 -0
- package/dist/patterns/MentionsInput/mention-text.js +31 -0
- package/dist/patterns/Menubar/Menubar.d.ts +22 -0
- package/dist/patterns/Menubar/Menubar.js +79 -0
- package/dist/patterns/NavigationMenu/NavigationMenu.d.ts +27 -0
- package/dist/patterns/NavigationMenu/NavigationMenu.js +104 -0
- package/dist/patterns/NumberField/FormNumberField.d.ts +18 -0
- package/dist/patterns/NumberField/FormNumberField.js +119 -0
- package/dist/patterns/NumberField/NumberField.d.ts +57 -0
- package/dist/patterns/NumberField/NumberField.js +242 -0
- package/dist/patterns/Pagination/Pagination.d.ts +31 -0
- package/dist/patterns/Pagination/Pagination.js +275 -0
- package/dist/patterns/Pagination/page-items.d.ts +18 -0
- package/dist/patterns/Pagination/page-items.js +40 -0
- package/dist/patterns/PhoneField/FormPhoneField.d.ts +22 -0
- package/dist/patterns/PhoneField/FormPhoneField.js +97 -0
- package/dist/patterns/PhoneField/PhoneField.d.ts +60 -0
- package/dist/patterns/PhoneField/PhoneField.js +448 -0
- package/dist/patterns/PhoneField/phone-value.d.ts +26 -0
- package/dist/patterns/PhoneField/phone-value.js +38 -0
- package/dist/patterns/QRCode/QRCode.d.ts +37 -0
- package/dist/patterns/QRCode/QRCode.js +120 -0
- package/dist/patterns/QRCode/qr-path.d.ts +7 -0
- package/dist/patterns/QRCode/qr-path.js +25 -0
- package/dist/patterns/ResizablePanels/ResizablePanels.d.ts +34 -0
- package/dist/patterns/ResizablePanels/ResizablePanels.js +175 -0
- package/dist/patterns/ResizablePanels/panel-sizes.d.ts +31 -0
- package/dist/patterns/ResizablePanels/panel-sizes.js +54 -0
- package/dist/patterns/RichTextEditor/FormRichTextField.d.ts +18 -0
- package/dist/patterns/RichTextEditor/FormRichTextField.js +118 -0
- package/dist/patterns/RichTextEditor/RichTextEditor.d.ts +71 -0
- package/dist/patterns/RichTextEditor/RichTextEditor.js +453 -0
- package/dist/patterns/SearchInput/SearchInput.d.ts +26 -0
- package/dist/patterns/SearchInput/SearchInput.js +98 -0
- package/dist/patterns/SideNav/SideNav.d.ts +50 -0
- package/dist/patterns/SideNav/SideNav.js +269 -0
- package/dist/patterns/Stat/Stat.d.ts +51 -0
- package/dist/patterns/Stat/Stat.js +292 -0
- package/dist/patterns/Stepper/Stepper.d.ts +35 -0
- package/dist/patterns/Stepper/Stepper.js +110 -0
- package/dist/patterns/TagGroup/TagGroup.d.ts +44 -0
- package/dist/patterns/TagGroup/TagGroup.js +151 -0
- package/dist/patterns/TagsInput/FormTagsInputField.d.ts +18 -0
- package/dist/patterns/TagsInput/FormTagsInputField.js +124 -0
- package/dist/patterns/TagsInput/TagsInput.d.ts +51 -0
- package/dist/patterns/TagsInput/TagsInput.js +97 -0
- package/dist/patterns/Timeline/Timeline.d.ts +29 -0
- package/dist/patterns/Timeline/Timeline.js +85 -0
- package/dist/patterns/Toolbar/Toolbar.d.ts +31 -0
- package/dist/patterns/Toolbar/Toolbar.js +105 -0
- package/dist/patterns/Tour/Tour.d.ts +38 -0
- package/dist/patterns/Tour/Tour.js +333 -0
- package/dist/patterns/TransferList/FormTransferListField.d.ts +19 -0
- package/dist/patterns/TransferList/FormTransferListField.js +117 -0
- package/dist/patterns/TransferList/TransferList.d.ts +53 -0
- package/dist/patterns/TransferList/TransferList.js +441 -0
- package/dist/patterns/TreeSelect/FormTreeSelectField.d.ts +28 -0
- package/dist/patterns/TreeSelect/FormTreeSelectField.js +88 -0
- package/dist/patterns/TreeSelect/TreeSelect.d.ts +49 -0
- package/dist/patterns/TreeSelect/TreeSelect.js +375 -0
- package/dist/patterns/TreeView/TreeView.d.ts +40 -0
- package/dist/patterns/TreeView/TreeView.js +296 -0
- package/dist/provider/DesignSystemProvider.d.ts +54 -0
- package/dist/provider/DesignSystemProvider.js +270 -0
- package/dist/provider/nonce.d.ts +7 -0
- package/dist/provider/nonce.js +13 -0
- package/dist/styles.css +2 -0
- package/dist/theme/chart-palette.d.ts +51 -0
- package/dist/theme/chart-palette.js +112 -0
- package/dist/theme/create-theme.d.ts +52 -0
- package/dist/theme/create-theme.js +75 -0
- package/dist/theme/style-element.d.ts +28 -0
- package/dist/theme/style-element.js +79 -0
- package/dist/theme/tenant-branding.d.ts +48 -0
- package/dist/theme/tenant-branding.js +65 -0
- package/dist/theme/theme-switch.d.ts +25 -0
- package/dist/theme/theme-switch.js +90 -0
- package/dist/theme/token-names.d.ts +3 -0
- package/dist/theme/token-names.js +166 -0
- package/dist/theme.css +241 -0
- package/dist/tokens.css +383 -0
- package/dist/types/direction.d.ts +4 -0
- package/dist/types/tone.d.ts +7 -0
- package/dist/utils/cn.d.ts +7 -0
- package/dist/utils/cn.js +50 -0
- package/dist/utils/first-field.d.ts +8 -0
- package/dist/utils/first-field.js +10 -0
- package/dist/utils/layout.d.ts +33 -0
- package/dist/utils/layout.js +30 -0
- package/dist/utils/popup.d.ts +12 -0
- package/dist/utils/popup.js +27 -0
- package/docs/accessibility.md +61 -0
- package/docs/advanced-components.md +38 -0
- package/docs/ai-assistants.md +44 -0
- package/docs/architecture.md +65 -0
- package/docs/browser-support.md +30 -0
- package/docs/charts.md +56 -0
- package/docs/components.md +2928 -0
- package/docs/conventions.md +19 -0
- package/docs/customization.md +79 -0
- package/docs/dates-files-data.md +48 -0
- package/docs/design-principles.md +50 -0
- package/docs/faq.md +68 -0
- package/docs/forms.md +114 -0
- package/docs/getting-started.md +64 -0
- package/docs/icons.md +48 -0
- package/docs/internationalization.md +64 -0
- package/docs/layout-and-navigation.md +51 -0
- package/docs/nextjs.md +69 -0
- package/docs/releasing.md +40 -0
- package/docs/testing.md +242 -0
- package/docs/theming.md +118 -0
- package/docs/typescript.md +62 -0
- package/llms-full.txt +4573 -0
- package/llms.txt +52 -0
- package/package.json +193 -6
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import { Combobox as BaseCombobox } from "@base-ui/react/combobox";
|
|
3
|
+
/** The names a list of options takes from the control that opens it. */
|
|
4
|
+
export interface ComboboxListNaming {
|
|
5
|
+
"aria-label"?: string | undefined;
|
|
6
|
+
"aria-labelledby"?: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
interface ComboboxPopupProps {
|
|
9
|
+
/** Shown when the typed text matches nothing. Without it the box is hidden while nothing matches. */
|
|
10
|
+
noMatchesLabel?: string | undefined;
|
|
11
|
+
/** The number of options the typed text matches, as a screen reader announces it. Nothing is announced without it. */
|
|
12
|
+
resultsLabel?: ((count: number) => string) | undefined;
|
|
13
|
+
/** The list of options is announced under the same name as the input that opens it. */
|
|
14
|
+
naming: ComboboxListNaming;
|
|
15
|
+
/** The options: a function of one option, rendered for each of those the typed text matches. */
|
|
16
|
+
children: ComponentProps<typeof BaseCombobox.List>["children"];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The floating list that Combobox, MultiSelect and Autocomplete share: Base UI's portal, positioner and popup
|
|
20
|
+
* around the list of options, as wide as the box that opens it. Base UI's Autocomplete is built on the same
|
|
21
|
+
* parts, so it works inside either root.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ComboboxPopup: ({ noMatchesLabel, resultsLabel, naming, children }: ComboboxPopupProps) => import("react").JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Combobox } from "@base-ui/react/combobox";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import { popup, positioner } from "../../utils/popup.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/patterns/Combobox/ComboboxPopup.tsx
|
|
8
|
+
/** The number of options the typed text matches, in a polite status: read inside the root, which filters them. */
|
|
9
|
+
var ResultCount = (t0) => {
|
|
10
|
+
const $ = c(5);
|
|
11
|
+
const { label } = t0;
|
|
12
|
+
const count = Combobox.useFilteredItems().length;
|
|
13
|
+
let t1;
|
|
14
|
+
if ($[0] !== count || $[1] !== label) {
|
|
15
|
+
t1 = label(count);
|
|
16
|
+
$[0] = count;
|
|
17
|
+
$[1] = label;
|
|
18
|
+
$[2] = t1;
|
|
19
|
+
} else t1 = $[2];
|
|
20
|
+
let t2;
|
|
21
|
+
if ($[3] !== t1) {
|
|
22
|
+
t2 = /* @__PURE__ */ jsx(Combobox.Status, {
|
|
23
|
+
className: "sr-only",
|
|
24
|
+
children: t1
|
|
25
|
+
});
|
|
26
|
+
$[3] = t1;
|
|
27
|
+
$[4] = t2;
|
|
28
|
+
} else t2 = $[4];
|
|
29
|
+
return t2;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The floating list that Combobox, MultiSelect and Autocomplete share: Base UI's portal, positioner and popup
|
|
33
|
+
* around the list of options, as wide as the box that opens it. Base UI's Autocomplete is built on the same
|
|
34
|
+
* parts, so it works inside either root.
|
|
35
|
+
*/
|
|
36
|
+
var ComboboxPopup = (t0) => {
|
|
37
|
+
const $ = c(18);
|
|
38
|
+
const { noMatchesLabel, resultsLabel, naming, children } = t0;
|
|
39
|
+
const t1 = noMatchesLabel === void 0 && "has-[[data-empty]]:hidden";
|
|
40
|
+
let t2;
|
|
41
|
+
if ($[0] !== t1) {
|
|
42
|
+
t2 = cn(popup, "min-w-(--anchor-width)", t1);
|
|
43
|
+
$[0] = t1;
|
|
44
|
+
$[1] = t2;
|
|
45
|
+
} else t2 = $[1];
|
|
46
|
+
let t3;
|
|
47
|
+
if ($[2] !== resultsLabel) {
|
|
48
|
+
t3 = resultsLabel === void 0 ? null : /* @__PURE__ */ jsx(ResultCount, { label: resultsLabel });
|
|
49
|
+
$[2] = resultsLabel;
|
|
50
|
+
$[3] = t3;
|
|
51
|
+
} else t3 = $[3];
|
|
52
|
+
let t4;
|
|
53
|
+
if ($[4] !== noMatchesLabel) {
|
|
54
|
+
t4 = noMatchesLabel === void 0 ? null : /* @__PURE__ */ jsx(Combobox.Empty, {
|
|
55
|
+
className: "px-2 py-1.5 text-body-sm text-fg-secondary empty:hidden",
|
|
56
|
+
children: noMatchesLabel
|
|
57
|
+
});
|
|
58
|
+
$[4] = noMatchesLabel;
|
|
59
|
+
$[5] = t4;
|
|
60
|
+
} else t4 = $[5];
|
|
61
|
+
let t5;
|
|
62
|
+
let t6;
|
|
63
|
+
if ($[6] !== naming) {
|
|
64
|
+
t5 = naming["aria-labelledby"] ? { "aria-labelledby": naming["aria-labelledby"] } : {};
|
|
65
|
+
t6 = naming["aria-label"] && !naming["aria-labelledby"] ? { "aria-label": naming["aria-label"] } : {};
|
|
66
|
+
$[6] = naming;
|
|
67
|
+
$[7] = t5;
|
|
68
|
+
$[8] = t6;
|
|
69
|
+
} else {
|
|
70
|
+
t5 = $[7];
|
|
71
|
+
t6 = $[8];
|
|
72
|
+
}
|
|
73
|
+
let t7;
|
|
74
|
+
if ($[9] !== children || $[10] !== t5 || $[11] !== t6) {
|
|
75
|
+
t7 = /* @__PURE__ */ jsx(Combobox.List, {
|
|
76
|
+
...t5,
|
|
77
|
+
...t6,
|
|
78
|
+
children
|
|
79
|
+
});
|
|
80
|
+
$[9] = children;
|
|
81
|
+
$[10] = t5;
|
|
82
|
+
$[11] = t6;
|
|
83
|
+
$[12] = t7;
|
|
84
|
+
} else t7 = $[12];
|
|
85
|
+
let t8;
|
|
86
|
+
if ($[13] !== t2 || $[14] !== t3 || $[15] !== t4 || $[16] !== t7) {
|
|
87
|
+
t8 = /* @__PURE__ */ jsx(Combobox.Portal, { children: /* @__PURE__ */ jsx(Combobox.Positioner, {
|
|
88
|
+
className: positioner,
|
|
89
|
+
sideOffset: 4,
|
|
90
|
+
children: /* @__PURE__ */ jsxs(Combobox.Popup, {
|
|
91
|
+
className: t2,
|
|
92
|
+
children: [
|
|
93
|
+
t3,
|
|
94
|
+
t4,
|
|
95
|
+
t7
|
|
96
|
+
]
|
|
97
|
+
})
|
|
98
|
+
}) });
|
|
99
|
+
$[13] = t2;
|
|
100
|
+
$[14] = t3;
|
|
101
|
+
$[15] = t4;
|
|
102
|
+
$[16] = t7;
|
|
103
|
+
$[17] = t8;
|
|
104
|
+
} else t8 = $[17];
|
|
105
|
+
return t8;
|
|
106
|
+
};
|
|
107
|
+
export { ComboboxPopup };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import type { FieldOrientation } from "../FormField/field-types.js";
|
|
3
|
+
import { type AutocompleteProps } from "./Autocomplete.js";
|
|
4
|
+
export interface FormAutocompleteFieldProps<TValues extends FieldValues> extends Omit<AutocompleteProps, "name" | "value" | "onValueChange" | "onBlur" | "invalid" | "inputRef" | "id" | "aria-label" | "aria-labelledby"> {
|
|
5
|
+
control: Control<TValues>;
|
|
6
|
+
name: FieldPath<TValues>;
|
|
7
|
+
label: string;
|
|
8
|
+
hint?: string | undefined;
|
|
9
|
+
/** Label above the control (default) or in a column beside it. */
|
|
10
|
+
orientation?: FieldOrientation | undefined;
|
|
11
|
+
/** react-hook-form validation rules, for forms that do not use a schema resolver. */
|
|
12
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
13
|
+
/** Turns a stored schema message (an i18n key) into display text. */
|
|
14
|
+
formatError?: ((message: string) => string) | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** An Autocomplete in a field, bound to a react-hook-form string field holding the text. */
|
|
17
|
+
export declare const FormAutocompleteField: <TValues extends FieldValues>({ control, name, label, hint, orientation, rules, formatError, required, disabled, size, ...autocompleteProps }: FormAutocompleteFieldProps<TValues>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { Controller } from "react-hook-form";
|
|
5
|
+
import { toErrorText } from "../FormField/error-message.js";
|
|
6
|
+
import { FieldFrame } from "../FormField/FieldFrame.js";
|
|
7
|
+
import { Autocomplete } from "./Autocomplete.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
// src/patterns/Combobox/FormAutocompleteField.tsx
|
|
10
|
+
/** An Autocomplete in a field, bound to a react-hook-form string field holding the text. */
|
|
11
|
+
var FormAutocompleteField = (t0) => {
|
|
12
|
+
const $ = c(29);
|
|
13
|
+
let autocompleteProps;
|
|
14
|
+
let control;
|
|
15
|
+
let formatError;
|
|
16
|
+
let hint;
|
|
17
|
+
let label;
|
|
18
|
+
let name;
|
|
19
|
+
let orientation;
|
|
20
|
+
let required;
|
|
21
|
+
let rules;
|
|
22
|
+
let t1;
|
|
23
|
+
let t2;
|
|
24
|
+
if ($[0] !== t0) {
|
|
25
|
+
({control, name, label, hint, orientation, rules, formatError, required, disabled: t1, size: t2, ...autocompleteProps} = t0);
|
|
26
|
+
$[0] = t0;
|
|
27
|
+
$[1] = autocompleteProps;
|
|
28
|
+
$[2] = control;
|
|
29
|
+
$[3] = formatError;
|
|
30
|
+
$[4] = hint;
|
|
31
|
+
$[5] = label;
|
|
32
|
+
$[6] = name;
|
|
33
|
+
$[7] = orientation;
|
|
34
|
+
$[8] = required;
|
|
35
|
+
$[9] = rules;
|
|
36
|
+
$[10] = t1;
|
|
37
|
+
$[11] = t2;
|
|
38
|
+
} else {
|
|
39
|
+
autocompleteProps = $[1];
|
|
40
|
+
control = $[2];
|
|
41
|
+
formatError = $[3];
|
|
42
|
+
hint = $[4];
|
|
43
|
+
label = $[5];
|
|
44
|
+
name = $[6];
|
|
45
|
+
orientation = $[7];
|
|
46
|
+
required = $[8];
|
|
47
|
+
rules = $[9];
|
|
48
|
+
t1 = $[10];
|
|
49
|
+
t2 = $[11];
|
|
50
|
+
}
|
|
51
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
52
|
+
const size = t2 === void 0 ? "medium" : t2;
|
|
53
|
+
const labelId = useId();
|
|
54
|
+
let t3;
|
|
55
|
+
if ($[12] !== rules) {
|
|
56
|
+
t3 = rules ? { rules } : {};
|
|
57
|
+
$[12] = rules;
|
|
58
|
+
$[13] = t3;
|
|
59
|
+
} else t3 = $[13];
|
|
60
|
+
let t4;
|
|
61
|
+
if ($[14] !== autocompleteProps || $[15] !== disabled || $[16] !== formatError || $[17] !== hint || $[18] !== label || $[19] !== labelId || $[20] !== orientation || $[21] !== required || $[22] !== size) {
|
|
62
|
+
t4 = (t5) => {
|
|
63
|
+
const { field, fieldState } = t5;
|
|
64
|
+
const errorMessage = toErrorText(fieldState.error?.message, formatError);
|
|
65
|
+
return /* @__PURE__ */ jsx(FieldFrame, {
|
|
66
|
+
name: field.name,
|
|
67
|
+
label,
|
|
68
|
+
labelId,
|
|
69
|
+
disabled,
|
|
70
|
+
invalid: fieldState.invalid,
|
|
71
|
+
touched: fieldState.isTouched,
|
|
72
|
+
dirty: fieldState.isDirty,
|
|
73
|
+
size,
|
|
74
|
+
...hint ? { hint } : {},
|
|
75
|
+
...required ? { required } : {},
|
|
76
|
+
...orientation ? { orientation } : {},
|
|
77
|
+
...errorMessage === void 0 ? {} : { errorMessage },
|
|
78
|
+
children: /* @__PURE__ */ jsx(Autocomplete, {
|
|
79
|
+
...autocompleteProps,
|
|
80
|
+
inputRef: field.ref,
|
|
81
|
+
"aria-labelledby": labelId,
|
|
82
|
+
value: field.value == null ? "" : String(field.value),
|
|
83
|
+
onValueChange: field.onChange,
|
|
84
|
+
onBlur: field.onBlur,
|
|
85
|
+
invalid: fieldState.invalid,
|
|
86
|
+
required: required ?? false,
|
|
87
|
+
disabled,
|
|
88
|
+
size
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
$[14] = autocompleteProps;
|
|
93
|
+
$[15] = disabled;
|
|
94
|
+
$[16] = formatError;
|
|
95
|
+
$[17] = hint;
|
|
96
|
+
$[18] = label;
|
|
97
|
+
$[19] = labelId;
|
|
98
|
+
$[20] = orientation;
|
|
99
|
+
$[21] = required;
|
|
100
|
+
$[22] = size;
|
|
101
|
+
$[23] = t4;
|
|
102
|
+
} else t4 = $[23];
|
|
103
|
+
let t5;
|
|
104
|
+
if ($[24] !== control || $[25] !== name || $[26] !== t3 || $[27] !== t4) {
|
|
105
|
+
t5 = /* @__PURE__ */ jsx(Controller, {
|
|
106
|
+
control,
|
|
107
|
+
name,
|
|
108
|
+
...t3,
|
|
109
|
+
render: t4
|
|
110
|
+
});
|
|
111
|
+
$[24] = control;
|
|
112
|
+
$[25] = name;
|
|
113
|
+
$[26] = t3;
|
|
114
|
+
$[27] = t4;
|
|
115
|
+
$[28] = t5;
|
|
116
|
+
} else t5 = $[28];
|
|
117
|
+
return t5;
|
|
118
|
+
};
|
|
119
|
+
export { FormAutocompleteField };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import type { FieldOrientation } from "../FormField/field-types.js";
|
|
3
|
+
import { type ComboboxProps } from "./Combobox.js";
|
|
4
|
+
export type { ComboboxOption } from "./Combobox.js";
|
|
5
|
+
export interface FormComboboxFieldProps<TValues extends FieldValues> extends Omit<ComboboxProps, "name" | "value" | "onValueChange" | "onBlur" | "invalid" | "inputRef" | "id" | "aria-label" | "aria-labelledby"> {
|
|
6
|
+
control: Control<TValues>;
|
|
7
|
+
name: FieldPath<TValues>;
|
|
8
|
+
label: string;
|
|
9
|
+
hint?: string | undefined;
|
|
10
|
+
/** Label above the control (default) or in a column beside it. */
|
|
11
|
+
orientation?: FieldOrientation | undefined;
|
|
12
|
+
/** react-hook-form validation rules, for forms that do not use a schema resolver. */
|
|
13
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
14
|
+
/** Turns a stored schema message (an i18n key) into display text. */
|
|
15
|
+
formatError?: ((message: string) => string) | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** A Combobox in a field, bound to a react-hook-form string field holding the chosen option's `value`. */
|
|
18
|
+
export declare const FormComboboxField: <TValues extends FieldValues>({ control, name, label, hint, orientation, rules, formatError, required, disabled, size, ...comboboxProps }: FormComboboxFieldProps<TValues>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { Controller } from "react-hook-form";
|
|
5
|
+
import { toErrorText } from "../FormField/error-message.js";
|
|
6
|
+
import { FieldFrame } from "../FormField/FieldFrame.js";
|
|
7
|
+
import { Combobox } from "./Combobox.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
// src/patterns/Combobox/FormComboboxField.tsx
|
|
10
|
+
/** A Combobox in a field, bound to a react-hook-form string field holding the chosen option's `value`. */
|
|
11
|
+
var FormComboboxField = (t0) => {
|
|
12
|
+
const $ = c(29);
|
|
13
|
+
let comboboxProps;
|
|
14
|
+
let control;
|
|
15
|
+
let formatError;
|
|
16
|
+
let hint;
|
|
17
|
+
let label;
|
|
18
|
+
let name;
|
|
19
|
+
let orientation;
|
|
20
|
+
let required;
|
|
21
|
+
let rules;
|
|
22
|
+
let t1;
|
|
23
|
+
let t2;
|
|
24
|
+
if ($[0] !== t0) {
|
|
25
|
+
({control, name, label, hint, orientation, rules, formatError, required, disabled: t1, size: t2, ...comboboxProps} = t0);
|
|
26
|
+
$[0] = t0;
|
|
27
|
+
$[1] = comboboxProps;
|
|
28
|
+
$[2] = control;
|
|
29
|
+
$[3] = formatError;
|
|
30
|
+
$[4] = hint;
|
|
31
|
+
$[5] = label;
|
|
32
|
+
$[6] = name;
|
|
33
|
+
$[7] = orientation;
|
|
34
|
+
$[8] = required;
|
|
35
|
+
$[9] = rules;
|
|
36
|
+
$[10] = t1;
|
|
37
|
+
$[11] = t2;
|
|
38
|
+
} else {
|
|
39
|
+
comboboxProps = $[1];
|
|
40
|
+
control = $[2];
|
|
41
|
+
formatError = $[3];
|
|
42
|
+
hint = $[4];
|
|
43
|
+
label = $[5];
|
|
44
|
+
name = $[6];
|
|
45
|
+
orientation = $[7];
|
|
46
|
+
required = $[8];
|
|
47
|
+
rules = $[9];
|
|
48
|
+
t1 = $[10];
|
|
49
|
+
t2 = $[11];
|
|
50
|
+
}
|
|
51
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
52
|
+
const size = t2 === void 0 ? "medium" : t2;
|
|
53
|
+
const labelId = useId();
|
|
54
|
+
let t3;
|
|
55
|
+
if ($[12] !== rules) {
|
|
56
|
+
t3 = rules ? { rules } : {};
|
|
57
|
+
$[12] = rules;
|
|
58
|
+
$[13] = t3;
|
|
59
|
+
} else t3 = $[13];
|
|
60
|
+
let t4;
|
|
61
|
+
if ($[14] !== comboboxProps || $[15] !== disabled || $[16] !== formatError || $[17] !== hint || $[18] !== label || $[19] !== labelId || $[20] !== orientation || $[21] !== required || $[22] !== size) {
|
|
62
|
+
t4 = (t5) => {
|
|
63
|
+
const { field, fieldState } = t5;
|
|
64
|
+
const errorMessage = toErrorText(fieldState.error?.message, formatError);
|
|
65
|
+
return /* @__PURE__ */ jsx(FieldFrame, {
|
|
66
|
+
name: field.name,
|
|
67
|
+
label,
|
|
68
|
+
labelId,
|
|
69
|
+
disabled,
|
|
70
|
+
invalid: fieldState.invalid,
|
|
71
|
+
touched: fieldState.isTouched,
|
|
72
|
+
dirty: fieldState.isDirty,
|
|
73
|
+
size,
|
|
74
|
+
...hint ? { hint } : {},
|
|
75
|
+
...required ? { required } : {},
|
|
76
|
+
...orientation ? { orientation } : {},
|
|
77
|
+
...errorMessage === void 0 ? {} : { errorMessage },
|
|
78
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
79
|
+
...comboboxProps,
|
|
80
|
+
inputRef: field.ref,
|
|
81
|
+
"aria-labelledby": labelId,
|
|
82
|
+
value: typeof field.value === "string" ? field.value : "",
|
|
83
|
+
onValueChange: field.onChange,
|
|
84
|
+
onBlur: field.onBlur,
|
|
85
|
+
invalid: fieldState.invalid,
|
|
86
|
+
required: required ?? false,
|
|
87
|
+
disabled,
|
|
88
|
+
size
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
$[14] = comboboxProps;
|
|
93
|
+
$[15] = disabled;
|
|
94
|
+
$[16] = formatError;
|
|
95
|
+
$[17] = hint;
|
|
96
|
+
$[18] = label;
|
|
97
|
+
$[19] = labelId;
|
|
98
|
+
$[20] = orientation;
|
|
99
|
+
$[21] = required;
|
|
100
|
+
$[22] = size;
|
|
101
|
+
$[23] = t4;
|
|
102
|
+
} else t4 = $[23];
|
|
103
|
+
let t5;
|
|
104
|
+
if ($[24] !== control || $[25] !== name || $[26] !== t3 || $[27] !== t4) {
|
|
105
|
+
t5 = /* @__PURE__ */ jsx(Controller, {
|
|
106
|
+
control,
|
|
107
|
+
name,
|
|
108
|
+
...t3,
|
|
109
|
+
render: t4
|
|
110
|
+
});
|
|
111
|
+
$[24] = control;
|
|
112
|
+
$[25] = name;
|
|
113
|
+
$[26] = t3;
|
|
114
|
+
$[27] = t4;
|
|
115
|
+
$[28] = t5;
|
|
116
|
+
} else t5 = $[28];
|
|
117
|
+
return t5;
|
|
118
|
+
};
|
|
119
|
+
export { FormComboboxField };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import type { FieldOrientation } from "../FormField/field-types.js";
|
|
3
|
+
import { type MultiSelectProps } from "./MultiSelect.js";
|
|
4
|
+
export type { MultiSelectLabels } from "./MultiSelect.js";
|
|
5
|
+
export interface FormMultiSelectFieldProps<TValues extends FieldValues> extends Omit<MultiSelectProps, "name" | "value" | "onValueChange" | "onBlur" | "invalid" | "inputRef" | "id" | "aria-label" | "aria-labelledby"> {
|
|
6
|
+
control: Control<TValues>;
|
|
7
|
+
name: FieldPath<TValues>;
|
|
8
|
+
label: string;
|
|
9
|
+
hint?: string | undefined;
|
|
10
|
+
/** Label above the control (default) or in a column beside it. */
|
|
11
|
+
orientation?: FieldOrientation | undefined;
|
|
12
|
+
/** react-hook-form validation rules, for forms that do not use a schema resolver. */
|
|
13
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
14
|
+
/** Turns a stored schema message (an i18n key) into display text. */
|
|
15
|
+
formatError?: ((message: string) => string) | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** A MultiSelect in a field, bound to a react-hook-form field holding an array of the chosen options' `value`s. */
|
|
18
|
+
export declare const FormMultiSelectField: <TValues extends FieldValues>({ control, name, label, hint, orientation, rules, formatError, required, disabled, size, ...multiSelectProps }: FormMultiSelectFieldProps<TValues>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { Controller } from "react-hook-form";
|
|
5
|
+
import { toErrorText } from "../FormField/error-message.js";
|
|
6
|
+
import { FieldFrame } from "../FormField/FieldFrame.js";
|
|
7
|
+
import { MultiSelect } from "./MultiSelect.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
// src/patterns/Combobox/FormMultiSelectField.tsx
|
|
10
|
+
/** A MultiSelect in a field, bound to a react-hook-form field holding an array of the chosen options' `value`s. */
|
|
11
|
+
var FormMultiSelectField = (t0) => {
|
|
12
|
+
const $ = c(29);
|
|
13
|
+
let control;
|
|
14
|
+
let formatError;
|
|
15
|
+
let hint;
|
|
16
|
+
let label;
|
|
17
|
+
let multiSelectProps;
|
|
18
|
+
let name;
|
|
19
|
+
let orientation;
|
|
20
|
+
let required;
|
|
21
|
+
let rules;
|
|
22
|
+
let t1;
|
|
23
|
+
let t2;
|
|
24
|
+
if ($[0] !== t0) {
|
|
25
|
+
({control, name, label, hint, orientation, rules, formatError, required, disabled: t1, size: t2, ...multiSelectProps} = t0);
|
|
26
|
+
$[0] = t0;
|
|
27
|
+
$[1] = control;
|
|
28
|
+
$[2] = formatError;
|
|
29
|
+
$[3] = hint;
|
|
30
|
+
$[4] = label;
|
|
31
|
+
$[5] = multiSelectProps;
|
|
32
|
+
$[6] = name;
|
|
33
|
+
$[7] = orientation;
|
|
34
|
+
$[8] = required;
|
|
35
|
+
$[9] = rules;
|
|
36
|
+
$[10] = t1;
|
|
37
|
+
$[11] = t2;
|
|
38
|
+
} else {
|
|
39
|
+
control = $[1];
|
|
40
|
+
formatError = $[2];
|
|
41
|
+
hint = $[3];
|
|
42
|
+
label = $[4];
|
|
43
|
+
multiSelectProps = $[5];
|
|
44
|
+
name = $[6];
|
|
45
|
+
orientation = $[7];
|
|
46
|
+
required = $[8];
|
|
47
|
+
rules = $[9];
|
|
48
|
+
t1 = $[10];
|
|
49
|
+
t2 = $[11];
|
|
50
|
+
}
|
|
51
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
52
|
+
const size = t2 === void 0 ? "medium" : t2;
|
|
53
|
+
const labelId = useId();
|
|
54
|
+
let t3;
|
|
55
|
+
if ($[12] !== rules) {
|
|
56
|
+
t3 = rules ? { rules } : {};
|
|
57
|
+
$[12] = rules;
|
|
58
|
+
$[13] = t3;
|
|
59
|
+
} else t3 = $[13];
|
|
60
|
+
let t4;
|
|
61
|
+
if ($[14] !== disabled || $[15] !== formatError || $[16] !== hint || $[17] !== label || $[18] !== labelId || $[19] !== multiSelectProps || $[20] !== orientation || $[21] !== required || $[22] !== size) {
|
|
62
|
+
t4 = (t5) => {
|
|
63
|
+
const { field, fieldState } = t5;
|
|
64
|
+
const errorMessage = toErrorText(fieldState.error?.message, formatError);
|
|
65
|
+
return /* @__PURE__ */ jsx(FieldFrame, {
|
|
66
|
+
name: field.name,
|
|
67
|
+
label,
|
|
68
|
+
labelId,
|
|
69
|
+
disabled,
|
|
70
|
+
invalid: fieldState.invalid,
|
|
71
|
+
touched: fieldState.isTouched,
|
|
72
|
+
dirty: fieldState.isDirty,
|
|
73
|
+
size,
|
|
74
|
+
...hint ? { hint } : {},
|
|
75
|
+
...required ? { required } : {},
|
|
76
|
+
...orientation ? { orientation } : {},
|
|
77
|
+
...errorMessage === void 0 ? {} : { errorMessage },
|
|
78
|
+
children: /* @__PURE__ */ jsx(MultiSelect, {
|
|
79
|
+
...multiSelectProps,
|
|
80
|
+
inputRef: field.ref,
|
|
81
|
+
"aria-labelledby": labelId,
|
|
82
|
+
value: Array.isArray(field.value) ? field.value : [],
|
|
83
|
+
onValueChange: field.onChange,
|
|
84
|
+
onBlur: field.onBlur,
|
|
85
|
+
invalid: fieldState.invalid,
|
|
86
|
+
required: required ?? false,
|
|
87
|
+
disabled,
|
|
88
|
+
size
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
$[14] = disabled;
|
|
93
|
+
$[15] = formatError;
|
|
94
|
+
$[16] = hint;
|
|
95
|
+
$[17] = label;
|
|
96
|
+
$[18] = labelId;
|
|
97
|
+
$[19] = multiSelectProps;
|
|
98
|
+
$[20] = orientation;
|
|
99
|
+
$[21] = required;
|
|
100
|
+
$[22] = size;
|
|
101
|
+
$[23] = t4;
|
|
102
|
+
} else t4 = $[23];
|
|
103
|
+
let t5;
|
|
104
|
+
if ($[24] !== control || $[25] !== name || $[26] !== t3 || $[27] !== t4) {
|
|
105
|
+
t5 = /* @__PURE__ */ jsx(Controller, {
|
|
106
|
+
control,
|
|
107
|
+
name,
|
|
108
|
+
...t3,
|
|
109
|
+
render: t4
|
|
110
|
+
});
|
|
111
|
+
$[24] = control;
|
|
112
|
+
$[25] = name;
|
|
113
|
+
$[26] = t3;
|
|
114
|
+
$[27] = t4;
|
|
115
|
+
$[28] = t5;
|
|
116
|
+
} else t5 = $[28];
|
|
117
|
+
return t5;
|
|
118
|
+
};
|
|
119
|
+
export { FormMultiSelectField };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ReactNode, Ref } from "react";
|
|
2
|
+
import type { FieldSize } from "../FormField/field-types.js";
|
|
3
|
+
import type { ComboboxOption } from "./Combobox.js";
|
|
4
|
+
/** The texts of the field. The design system has no i18n, so the caller supplies them. */
|
|
5
|
+
export interface MultiSelectLabels {
|
|
6
|
+
/** Shown when the typed text matches no option. */
|
|
7
|
+
noMatches: string;
|
|
8
|
+
/** Accessible name of the button that removes a chosen option, from the option's label: `(label) => `Remove ${label}``. */
|
|
9
|
+
remove: (label: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* The number of options the typed text matches, as a screen reader announces it (politely, as it changes):
|
|
12
|
+
* `(count) => `${count} results``. Nothing is announced if omitted.
|
|
13
|
+
*/
|
|
14
|
+
results?: ((count: number) => string) | undefined;
|
|
15
|
+
}
|
|
16
|
+
export interface MultiSelectProps {
|
|
17
|
+
options: readonly ComboboxOption[];
|
|
18
|
+
/** The `value`s of the chosen options, in the order they were chosen. */
|
|
19
|
+
value: readonly string[];
|
|
20
|
+
/** Called with the `value`s of the chosen options. */
|
|
21
|
+
onValueChange: (value: string[]) => void;
|
|
22
|
+
labels: MultiSelectLabels;
|
|
23
|
+
placeholder?: string | undefined;
|
|
24
|
+
disabled?: boolean | undefined;
|
|
25
|
+
/** Draws the box red and marks the input invalid for assistive technology. */
|
|
26
|
+
invalid?: boolean | undefined;
|
|
27
|
+
/** Marks the input required for assistive technology; the label shows the asterisk. */
|
|
28
|
+
required?: boolean | undefined;
|
|
29
|
+
/** "small" is the compact density. */
|
|
30
|
+
size?: FieldSize | undefined;
|
|
31
|
+
/** A decorative icon at the start of the box. */
|
|
32
|
+
contentBefore?: ReactNode | undefined;
|
|
33
|
+
/** The field's name in a submitted form. */
|
|
34
|
+
name?: string | undefined;
|
|
35
|
+
/** For a `<label htmlFor>` that names the input. */
|
|
36
|
+
id?: string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The accessible name of the input and of its list of options, for a control with no label element of its own.
|
|
39
|
+
* Give this or `aria-labelledby`.
|
|
40
|
+
*/
|
|
41
|
+
"aria-label"?: string | undefined;
|
|
42
|
+
/** The id of the element that names the input and its list of options, such as a field's label. */
|
|
43
|
+
"aria-labelledby"?: string | undefined;
|
|
44
|
+
/** The control was left. */
|
|
45
|
+
onBlur?: (() => void) | undefined;
|
|
46
|
+
/** The `<input>`, for a form library to focus the first invalid field. */
|
|
47
|
+
inputRef?: Ref<HTMLInputElement> | undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A select for several options. The chosen ones are chips in the box, each with a button that removes it, and
|
|
51
|
+
* the box grows onto more lines as chips are added. Typing filters the list, the arrow keys and Enter add an
|
|
52
|
+
* option and the list stays open for the next; Backspace in the empty input removes the last chip.
|
|
53
|
+
*/
|
|
54
|
+
export declare const MultiSelect: ({ options, value, onValueChange, labels, placeholder, disabled, invalid, required, size, contentBefore, name, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, onBlur, inputRef, }: MultiSelectProps) => import("react").JSX.Element;
|