@primecoderin/fast-ui-react 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -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 +41 -0
- package/docs/testing.md +242 -0
- package/docs/theming.md +118 -0
- package/docs/typescript.md +62 -0
- package/llms-full.txt +4574 -0
- package/llms.txt +52 -0
- package/package.json +166 -6
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Controller } from "react-hook-form";
|
|
4
|
+
import { toErrorText } from "../FormField/error-message.js";
|
|
5
|
+
import { FieldFrame } from "../FormField/FieldFrame.js";
|
|
6
|
+
import { useFieldIds } from "../FormField/use-field-ids.js";
|
|
7
|
+
import { ColorPicker } from "./ColorPicker.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
// src/patterns/ColorPicker/FormColorField.tsx
|
|
10
|
+
/** A ColorPicker in a field, bound to a react-hook-form string field holding the colour as "#rrggbb" (or "" for none). */
|
|
11
|
+
var FormColorField = (t0) => {
|
|
12
|
+
const $ = c(33);
|
|
13
|
+
let control;
|
|
14
|
+
let formatError;
|
|
15
|
+
let hint;
|
|
16
|
+
let label;
|
|
17
|
+
let name;
|
|
18
|
+
let orientation;
|
|
19
|
+
let pickerProps;
|
|
20
|
+
let required;
|
|
21
|
+
let rules;
|
|
22
|
+
let t1;
|
|
23
|
+
let t2;
|
|
24
|
+
let t3;
|
|
25
|
+
if ($[0] !== t0) {
|
|
26
|
+
({control, name, label, hint, required, orientation, hideLabel: t1, rules, formatError, disabled: t2, size: t3, ...pickerProps} = t0);
|
|
27
|
+
$[0] = t0;
|
|
28
|
+
$[1] = control;
|
|
29
|
+
$[2] = formatError;
|
|
30
|
+
$[3] = hint;
|
|
31
|
+
$[4] = label;
|
|
32
|
+
$[5] = name;
|
|
33
|
+
$[6] = orientation;
|
|
34
|
+
$[7] = pickerProps;
|
|
35
|
+
$[8] = required;
|
|
36
|
+
$[9] = rules;
|
|
37
|
+
$[10] = t1;
|
|
38
|
+
$[11] = t2;
|
|
39
|
+
$[12] = t3;
|
|
40
|
+
} else {
|
|
41
|
+
control = $[1];
|
|
42
|
+
formatError = $[2];
|
|
43
|
+
hint = $[3];
|
|
44
|
+
label = $[4];
|
|
45
|
+
name = $[5];
|
|
46
|
+
orientation = $[6];
|
|
47
|
+
pickerProps = $[7];
|
|
48
|
+
required = $[8];
|
|
49
|
+
rules = $[9];
|
|
50
|
+
t1 = $[10];
|
|
51
|
+
t2 = $[11];
|
|
52
|
+
t3 = $[12];
|
|
53
|
+
}
|
|
54
|
+
const hideLabel = t1 === void 0 ? false : t1;
|
|
55
|
+
const disabled = t2 === void 0 ? false : t2;
|
|
56
|
+
const size = t3 === void 0 ? "medium" : t3;
|
|
57
|
+
const { labelId, messageIds, describe } = useFieldIds();
|
|
58
|
+
let t4;
|
|
59
|
+
if ($[13] !== rules) {
|
|
60
|
+
t4 = rules ? { rules } : {};
|
|
61
|
+
$[13] = rules;
|
|
62
|
+
$[14] = t4;
|
|
63
|
+
} else t4 = $[14];
|
|
64
|
+
let t5;
|
|
65
|
+
if ($[15] !== describe || $[16] !== disabled || $[17] !== formatError || $[18] !== hideLabel || $[19] !== hint || $[20] !== label || $[21] !== labelId || $[22] !== messageIds || $[23] !== orientation || $[24] !== pickerProps || $[25] !== required || $[26] !== size) {
|
|
66
|
+
t5 = (t6) => {
|
|
67
|
+
const { field, fieldState } = t6;
|
|
68
|
+
const errorMessage = toErrorText(fieldState.error?.message, formatError);
|
|
69
|
+
const describedBy = describe(errorMessage, hint);
|
|
70
|
+
return /* @__PURE__ */ jsx(FieldFrame, {
|
|
71
|
+
name: field.name,
|
|
72
|
+
label,
|
|
73
|
+
hideLabel,
|
|
74
|
+
disabled,
|
|
75
|
+
invalid: fieldState.invalid,
|
|
76
|
+
touched: fieldState.isTouched,
|
|
77
|
+
dirty: fieldState.isDirty,
|
|
78
|
+
size,
|
|
79
|
+
triggerLabel: true,
|
|
80
|
+
labelId,
|
|
81
|
+
messageIds,
|
|
82
|
+
...hint ? { hint } : {},
|
|
83
|
+
...required ? { required } : {},
|
|
84
|
+
...orientation ? { orientation } : {},
|
|
85
|
+
...errorMessage === void 0 ? {} : { errorMessage },
|
|
86
|
+
children: /* @__PURE__ */ jsx(ColorPicker, {
|
|
87
|
+
...pickerProps,
|
|
88
|
+
value: typeof field.value === "string" ? field.value : "",
|
|
89
|
+
onValueChange: field.onChange,
|
|
90
|
+
onBlur: field.onBlur,
|
|
91
|
+
triggerRef: field.ref,
|
|
92
|
+
"aria-labelledby": labelId,
|
|
93
|
+
...describedBy ? { "aria-describedby": describedBy } : {},
|
|
94
|
+
invalid: fieldState.invalid,
|
|
95
|
+
disabled,
|
|
96
|
+
size
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
$[15] = describe;
|
|
101
|
+
$[16] = disabled;
|
|
102
|
+
$[17] = formatError;
|
|
103
|
+
$[18] = hideLabel;
|
|
104
|
+
$[19] = hint;
|
|
105
|
+
$[20] = label;
|
|
106
|
+
$[21] = labelId;
|
|
107
|
+
$[22] = messageIds;
|
|
108
|
+
$[23] = orientation;
|
|
109
|
+
$[24] = pickerProps;
|
|
110
|
+
$[25] = required;
|
|
111
|
+
$[26] = size;
|
|
112
|
+
$[27] = t5;
|
|
113
|
+
} else t5 = $[27];
|
|
114
|
+
let t6;
|
|
115
|
+
if ($[28] !== control || $[29] !== name || $[30] !== t4 || $[31] !== t5) {
|
|
116
|
+
t6 = /* @__PURE__ */ jsx(Controller, {
|
|
117
|
+
control,
|
|
118
|
+
name,
|
|
119
|
+
...t4,
|
|
120
|
+
render: t5
|
|
121
|
+
});
|
|
122
|
+
$[28] = control;
|
|
123
|
+
$[29] = name;
|
|
124
|
+
$[30] = t4;
|
|
125
|
+
$[31] = t5;
|
|
126
|
+
$[32] = t6;
|
|
127
|
+
} else t6 = $[32];
|
|
128
|
+
return t6;
|
|
129
|
+
};
|
|
130
|
+
export { FormColorField };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colours as the picker holds them: a hex text ("#6d28d9") outside, hue / saturation / brightness inside. Pure
|
|
3
|
+
* functions, so the conversions are tested in Node and a Server Component may call them.
|
|
4
|
+
*/
|
|
5
|
+
/** A colour as the picker's two controls set it: hue 0 to 360, saturation and brightness 0 to 100. */
|
|
6
|
+
export interface Hsv {
|
|
7
|
+
h: number;
|
|
8
|
+
s: number;
|
|
9
|
+
v: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A hex colour written the way it is stored: "#rrggbb" in lower case, from "#6D28D9", "6d28d9", "#6d2" (each digit
|
|
13
|
+
* doubled) or "6d2". Returns null for anything else, including the empty string.
|
|
14
|
+
*/
|
|
15
|
+
export declare const parseHex: (text: string) => string | null;
|
|
16
|
+
/** The hue, saturation and brightness of a hex colour; null if `hex` is not one. Not rounded, so it converts back exactly. */
|
|
17
|
+
export declare const hexToHsv: (hex: string) => Hsv | null;
|
|
18
|
+
/** The hex colour ("#rrggbb") of a hue, saturation and brightness; each is kept within its range. */
|
|
19
|
+
export declare const hsvToHex: ({ h, s, v }: Hsv) => string;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// src/patterns/ColorPicker/color-value.ts
|
|
2
|
+
/**
|
|
3
|
+
* A hex colour written the way it is stored: "#rrggbb" in lower case, from "#6D28D9", "6d28d9", "#6d2" (each digit
|
|
4
|
+
* doubled) or "6d2". Returns null for anything else, including the empty string.
|
|
5
|
+
*/
|
|
6
|
+
var parseHex = (text) => {
|
|
7
|
+
const digits = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(text.trim())?.[1];
|
|
8
|
+
if (!digits) return null;
|
|
9
|
+
return `#${(digits.length === 3 ? [...digits].map((digit) => digit + digit).join("") : digits).toLowerCase()}`;
|
|
10
|
+
};
|
|
11
|
+
var clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
12
|
+
/** The hue, saturation and brightness of a hex colour; null if `hex` is not one. Not rounded, so it converts back exactly. */
|
|
13
|
+
var hexToHsv = (hex) => {
|
|
14
|
+
const parsed = parseHex(hex);
|
|
15
|
+
if (!parsed) return null;
|
|
16
|
+
const r = parseInt(parsed.slice(1, 3), 16) / 255;
|
|
17
|
+
const g = parseInt(parsed.slice(3, 5), 16) / 255;
|
|
18
|
+
const b = parseInt(parsed.slice(5, 7), 16) / 255;
|
|
19
|
+
const max = Math.max(r, g, b);
|
|
20
|
+
const delta = max - Math.min(r, g, b);
|
|
21
|
+
let h = 0;
|
|
22
|
+
if (delta !== 0) {
|
|
23
|
+
if (max === r) h = (g - b) / delta % 6;
|
|
24
|
+
else if (max === g) h = (b - r) / delta + 2;
|
|
25
|
+
else h = (r - g) / delta + 4;
|
|
26
|
+
h *= 60;
|
|
27
|
+
if (h < 0) h += 360;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
h,
|
|
31
|
+
s: max === 0 ? 0 : delta / max * 100,
|
|
32
|
+
v: max * 100
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/** The hex colour ("#rrggbb") of a hue, saturation and brightness; each is kept within its range. */
|
|
36
|
+
var hsvToHex = ({ h, s, v }) => {
|
|
37
|
+
const hue = (h % 360 + 360) % 360;
|
|
38
|
+
const saturation = clamp(s, 0, 100) / 100;
|
|
39
|
+
const value = clamp(v, 0, 100) / 100;
|
|
40
|
+
const chroma = value * saturation;
|
|
41
|
+
const x = chroma * (1 - Math.abs(hue / 60 % 2 - 1));
|
|
42
|
+
const m = value - chroma;
|
|
43
|
+
const sector = Math.floor(hue / 60);
|
|
44
|
+
const [r, g, b] = sector === 0 ? [
|
|
45
|
+
chroma,
|
|
46
|
+
x,
|
|
47
|
+
0
|
|
48
|
+
] : sector === 1 ? [
|
|
49
|
+
x,
|
|
50
|
+
chroma,
|
|
51
|
+
0
|
|
52
|
+
] : sector === 2 ? [
|
|
53
|
+
0,
|
|
54
|
+
chroma,
|
|
55
|
+
x
|
|
56
|
+
] : sector === 3 ? [
|
|
57
|
+
0,
|
|
58
|
+
x,
|
|
59
|
+
chroma
|
|
60
|
+
] : sector === 4 ? [
|
|
61
|
+
x,
|
|
62
|
+
0,
|
|
63
|
+
chroma
|
|
64
|
+
] : [
|
|
65
|
+
chroma,
|
|
66
|
+
0,
|
|
67
|
+
x
|
|
68
|
+
];
|
|
69
|
+
const channel = (n) => Math.round((n + m) * 255).toString(16).padStart(2, "0");
|
|
70
|
+
return `#${channel(r ?? 0)}${channel(g ?? 0)}${channel(b ?? 0)}`;
|
|
71
|
+
};
|
|
72
|
+
export { hexToHsv, hsvToHex, parseHex };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ReactNode, Ref } from "react";
|
|
2
|
+
import type { FieldSize } from "../FormField/field-types.js";
|
|
3
|
+
export interface AutocompleteProps {
|
|
4
|
+
/** The suggestions: the ones that contain the typed text are listed. */
|
|
5
|
+
suggestions: readonly string[];
|
|
6
|
+
/** The text in the field: what was typed, or the suggestion that was chosen. */
|
|
7
|
+
value: string;
|
|
8
|
+
/** Called with the new text as the person types, and with a suggestion's text when one is chosen. */
|
|
9
|
+
onValueChange: (value: string) => void;
|
|
10
|
+
/** Shown when the typed text matches no suggestion. If omitted the list is hidden while nothing matches. */
|
|
11
|
+
noMatchesLabel?: string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* The number of suggestions the typed text matches, as a screen reader announces it (politely, as it changes):
|
|
14
|
+
* `(count) => `${count} suggestions``. Nothing is announced if omitted.
|
|
15
|
+
*/
|
|
16
|
+
resultsLabel?: ((count: number) => string) | undefined;
|
|
17
|
+
placeholder?: string | undefined;
|
|
18
|
+
disabled?: boolean | undefined;
|
|
19
|
+
/** Draws the box red and marks the input invalid for assistive technology. */
|
|
20
|
+
invalid?: boolean | undefined;
|
|
21
|
+
/** Marks the input required for assistive technology; the label shows the asterisk. */
|
|
22
|
+
required?: boolean | undefined;
|
|
23
|
+
/** "small" is the compact density. */
|
|
24
|
+
size?: FieldSize | undefined;
|
|
25
|
+
/** A decorative icon at the start of the box. */
|
|
26
|
+
contentBefore?: ReactNode | undefined;
|
|
27
|
+
/** The field's name in a submitted form. */
|
|
28
|
+
name?: string | undefined;
|
|
29
|
+
/** For a `<label htmlFor>` that names the input. */
|
|
30
|
+
id?: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The accessible name of the input and of its list of suggestions, for a field with no label element of its
|
|
33
|
+
* own. Give this or `aria-labelledby`.
|
|
34
|
+
*/
|
|
35
|
+
"aria-label"?: string | undefined;
|
|
36
|
+
/** The id of the element that names the input and its list, such as a field's label. */
|
|
37
|
+
"aria-labelledby"?: string | undefined;
|
|
38
|
+
/** The field was left. */
|
|
39
|
+
onBlur?: (() => void) | undefined;
|
|
40
|
+
/** The `<input>`, for a form library to focus the first invalid field. */
|
|
41
|
+
inputRef?: Ref<HTMLInputElement> | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A text input with suggestions: the value is whatever is typed, and a list of the suggestions that contain it
|
|
45
|
+
* offers to complete it. Unlike Combobox the text need not be one of the suggestions. The arrow keys move through
|
|
46
|
+
* the list and Enter takes the suggestion.
|
|
47
|
+
*/
|
|
48
|
+
export declare const Autocomplete: ({ suggestions, value, onValueChange, noMatchesLabel, resultsLabel, placeholder, disabled, invalid, required, size, contentBefore, name, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, onBlur, inputRef, }: AutocompleteProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Autocomplete as Autocomplete$1 } from "@base-ui/react/autocomplete";
|
|
4
|
+
import { item } from "../../utils/popup.js";
|
|
5
|
+
import { fieldControl, fieldInput } from "../FormField/field-styles.js";
|
|
6
|
+
import { ComboboxPopup } from "./ComboboxPopup.js";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/patterns/Combobox/Autocomplete.tsx
|
|
9
|
+
/**
|
|
10
|
+
* A text input with suggestions: the value is whatever is typed, and a list of the suggestions that contain it
|
|
11
|
+
* offers to complete it. Unlike Combobox the text need not be one of the suggestions. The arrow keys move through
|
|
12
|
+
* the list and Enter takes the suggestion.
|
|
13
|
+
*/
|
|
14
|
+
var Autocomplete = (t0) => {
|
|
15
|
+
const $ = c(44);
|
|
16
|
+
const { suggestions, value, onValueChange, noMatchesLabel, resultsLabel, placeholder, disabled: t1, invalid: t2, required: t3, size: t4, contentBefore, name, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, onBlur, inputRef } = t0;
|
|
17
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
18
|
+
const invalid = t2 === void 0 ? false : t2;
|
|
19
|
+
const required = t3 === void 0 ? false : t3;
|
|
20
|
+
const size = t4 === void 0 ? "medium" : t4;
|
|
21
|
+
let t5;
|
|
22
|
+
if ($[0] !== onValueChange) {
|
|
23
|
+
t5 = (next) => {
|
|
24
|
+
onValueChange(next);
|
|
25
|
+
};
|
|
26
|
+
$[0] = onValueChange;
|
|
27
|
+
$[1] = t5;
|
|
28
|
+
} else t5 = $[1];
|
|
29
|
+
let t6;
|
|
30
|
+
if ($[2] !== name) {
|
|
31
|
+
t6 = name ? { name } : {};
|
|
32
|
+
$[2] = name;
|
|
33
|
+
$[3] = t6;
|
|
34
|
+
} else t6 = $[3];
|
|
35
|
+
let t7;
|
|
36
|
+
if ($[4] !== size) {
|
|
37
|
+
t7 = fieldControl({ size });
|
|
38
|
+
$[4] = size;
|
|
39
|
+
$[5] = t7;
|
|
40
|
+
} else t7 = $[5];
|
|
41
|
+
const t8 = invalid || void 0;
|
|
42
|
+
const t9 = disabled || void 0;
|
|
43
|
+
let t10;
|
|
44
|
+
if ($[6] !== id) {
|
|
45
|
+
t10 = id ? { id } : {};
|
|
46
|
+
$[6] = id;
|
|
47
|
+
$[7] = t10;
|
|
48
|
+
} else t10 = $[7];
|
|
49
|
+
let t11;
|
|
50
|
+
if ($[8] !== ariaLabel) {
|
|
51
|
+
t11 = ariaLabel ? { "aria-label": ariaLabel } : {};
|
|
52
|
+
$[8] = ariaLabel;
|
|
53
|
+
$[9] = t11;
|
|
54
|
+
} else t11 = $[9];
|
|
55
|
+
let t12;
|
|
56
|
+
if ($[10] !== ariaLabelledBy) {
|
|
57
|
+
t12 = ariaLabelledBy ? { "aria-labelledby": ariaLabelledBy } : {};
|
|
58
|
+
$[10] = ariaLabelledBy;
|
|
59
|
+
$[11] = t12;
|
|
60
|
+
} else t12 = $[11];
|
|
61
|
+
let t13;
|
|
62
|
+
if ($[12] !== invalid) {
|
|
63
|
+
t13 = invalid ? { "aria-invalid": true } : {};
|
|
64
|
+
$[12] = invalid;
|
|
65
|
+
$[13] = t13;
|
|
66
|
+
} else t13 = $[13];
|
|
67
|
+
const t14 = required || void 0;
|
|
68
|
+
let t15;
|
|
69
|
+
if ($[14] !== inputRef || $[15] !== onBlur || $[16] !== placeholder || $[17] !== t10 || $[18] !== t11 || $[19] !== t12 || $[20] !== t13 || $[21] !== t14) {
|
|
70
|
+
t15 = /* @__PURE__ */ jsx(Autocomplete$1.Input, {
|
|
71
|
+
ref: inputRef,
|
|
72
|
+
...t10,
|
|
73
|
+
...t11,
|
|
74
|
+
...t12,
|
|
75
|
+
...t13,
|
|
76
|
+
"aria-required": t14,
|
|
77
|
+
className: fieldInput,
|
|
78
|
+
placeholder,
|
|
79
|
+
onBlur
|
|
80
|
+
});
|
|
81
|
+
$[14] = inputRef;
|
|
82
|
+
$[15] = onBlur;
|
|
83
|
+
$[16] = placeholder;
|
|
84
|
+
$[17] = t10;
|
|
85
|
+
$[18] = t11;
|
|
86
|
+
$[19] = t12;
|
|
87
|
+
$[20] = t13;
|
|
88
|
+
$[21] = t14;
|
|
89
|
+
$[22] = t15;
|
|
90
|
+
} else t15 = $[22];
|
|
91
|
+
let t16;
|
|
92
|
+
if ($[23] !== contentBefore || $[24] !== t15 || $[25] !== t7 || $[26] !== t8 || $[27] !== t9) {
|
|
93
|
+
t16 = /* @__PURE__ */ jsxs("div", {
|
|
94
|
+
className: t7,
|
|
95
|
+
"data-invalid": t8,
|
|
96
|
+
"data-disabled": t9,
|
|
97
|
+
children: [contentBefore, t15]
|
|
98
|
+
});
|
|
99
|
+
$[23] = contentBefore;
|
|
100
|
+
$[24] = t15;
|
|
101
|
+
$[25] = t7;
|
|
102
|
+
$[26] = t8;
|
|
103
|
+
$[27] = t9;
|
|
104
|
+
$[28] = t16;
|
|
105
|
+
} else t16 = $[28];
|
|
106
|
+
let t17;
|
|
107
|
+
if ($[29] !== ariaLabel || $[30] !== ariaLabelledBy) {
|
|
108
|
+
t17 = {
|
|
109
|
+
"aria-label": ariaLabel,
|
|
110
|
+
"aria-labelledby": ariaLabelledBy
|
|
111
|
+
};
|
|
112
|
+
$[29] = ariaLabel;
|
|
113
|
+
$[30] = ariaLabelledBy;
|
|
114
|
+
$[31] = t17;
|
|
115
|
+
} else t17 = $[31];
|
|
116
|
+
let t18;
|
|
117
|
+
if ($[32] !== noMatchesLabel || $[33] !== resultsLabel || $[34] !== t17) {
|
|
118
|
+
t18 = /* @__PURE__ */ jsx(ComboboxPopup, {
|
|
119
|
+
noMatchesLabel,
|
|
120
|
+
resultsLabel,
|
|
121
|
+
naming: t17,
|
|
122
|
+
children: _temp
|
|
123
|
+
});
|
|
124
|
+
$[32] = noMatchesLabel;
|
|
125
|
+
$[33] = resultsLabel;
|
|
126
|
+
$[34] = t17;
|
|
127
|
+
$[35] = t18;
|
|
128
|
+
} else t18 = $[35];
|
|
129
|
+
let t19;
|
|
130
|
+
if ($[36] !== disabled || $[37] !== suggestions || $[38] !== t16 || $[39] !== t18 || $[40] !== t5 || $[41] !== t6 || $[42] !== value) {
|
|
131
|
+
t19 = /* @__PURE__ */ jsxs(Autocomplete$1.Root, {
|
|
132
|
+
items: suggestions,
|
|
133
|
+
value,
|
|
134
|
+
onValueChange: t5,
|
|
135
|
+
mode: "list",
|
|
136
|
+
...t6,
|
|
137
|
+
disabled,
|
|
138
|
+
children: [t16, t18]
|
|
139
|
+
});
|
|
140
|
+
$[36] = disabled;
|
|
141
|
+
$[37] = suggestions;
|
|
142
|
+
$[38] = t16;
|
|
143
|
+
$[39] = t18;
|
|
144
|
+
$[40] = t5;
|
|
145
|
+
$[41] = t6;
|
|
146
|
+
$[42] = value;
|
|
147
|
+
$[43] = t19;
|
|
148
|
+
} else t19 = $[43];
|
|
149
|
+
return t19;
|
|
150
|
+
};
|
|
151
|
+
function _temp(suggestion) {
|
|
152
|
+
return /* @__PURE__ */ jsx(Autocomplete$1.Item, {
|
|
153
|
+
value: suggestion,
|
|
154
|
+
className: item,
|
|
155
|
+
children: suggestion
|
|
156
|
+
}, suggestion);
|
|
157
|
+
}
|
|
158
|
+
export { Autocomplete };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ReactNode, Ref } from "react";
|
|
2
|
+
import type { FieldSize } from "../FormField/field-types.js";
|
|
3
|
+
export interface ComboboxOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
disabled?: boolean | undefined;
|
|
7
|
+
}
|
|
8
|
+
export interface ComboboxProps {
|
|
9
|
+
options: readonly ComboboxOption[];
|
|
10
|
+
/** The chosen option's `value`; an empty string for none. */
|
|
11
|
+
value: string;
|
|
12
|
+
/** Called with the chosen option's `value`. */
|
|
13
|
+
onValueChange: (value: string) => void;
|
|
14
|
+
/** Shown when the typed text matches no option. */
|
|
15
|
+
noMatchesLabel: string;
|
|
16
|
+
/**
|
|
17
|
+
* The number of options the typed text matches, as a screen reader announces it (politely, as it changes):
|
|
18
|
+
* `(count) => `${count} results``. Nothing is announced if omitted.
|
|
19
|
+
*/
|
|
20
|
+
resultsLabel?: ((count: number) => string) | undefined;
|
|
21
|
+
placeholder?: string | undefined;
|
|
22
|
+
disabled?: boolean | undefined;
|
|
23
|
+
/** Draws the box red and marks the input invalid for assistive technology. */
|
|
24
|
+
invalid?: boolean | undefined;
|
|
25
|
+
/** Marks the input required for assistive technology; the label shows the asterisk. */
|
|
26
|
+
required?: boolean | undefined;
|
|
27
|
+
/** "small" is the compact density. */
|
|
28
|
+
size?: FieldSize | undefined;
|
|
29
|
+
/** A decorative icon at the start of the box. */
|
|
30
|
+
contentBefore?: ReactNode | undefined;
|
|
31
|
+
/** The field's name in a submitted form. */
|
|
32
|
+
name?: string | undefined;
|
|
33
|
+
/** For a `<label htmlFor>` that names the input. */
|
|
34
|
+
id?: string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* The accessible name of the input and of its list of options, for a combobox with no label element of its
|
|
37
|
+
* own. Give this or `aria-labelledby`: a `<label htmlFor>` alone names the input but not the list.
|
|
38
|
+
*/
|
|
39
|
+
"aria-label"?: string | undefined;
|
|
40
|
+
/** The id of the element that names the input and its list of options, such as a field's label. */
|
|
41
|
+
"aria-labelledby"?: string | undefined;
|
|
42
|
+
/** The combobox was left. */
|
|
43
|
+
onBlur?: (() => void) | undefined;
|
|
44
|
+
/** The `<input>`, for a form library to focus the first invalid field. */
|
|
45
|
+
inputRef?: Ref<HTMLInputElement> | undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A select you can type into: the box shows the chosen option, typing filters the list to the options that
|
|
49
|
+
* contain the text, and the arrow keys and Enter choose. For a short list that needs no typing, see
|
|
50
|
+
* SelectField; for several choices, MultiSelect; for free text with suggestions, Autocomplete.
|
|
51
|
+
*/
|
|
52
|
+
export declare const Combobox: ({ options, value, onValueChange, noMatchesLabel, resultsLabel, placeholder, disabled, invalid, required, size, contentBefore, name, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, onBlur, inputRef, }: ComboboxProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Combobox as Combobox$1 } from "@base-ui/react/combobox";
|
|
4
|
+
import { Check, ChevronDown } from "lucide-react";
|
|
5
|
+
import { indicator, item } from "../../utils/popup.js";
|
|
6
|
+
import { fieldControl, fieldInput } from "../FormField/field-styles.js";
|
|
7
|
+
import { ComboboxPopup } from "./ComboboxPopup.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
// src/patterns/Combobox/Combobox.tsx
|
|
10
|
+
/**
|
|
11
|
+
* A select you can type into: the box shows the chosen option, typing filters the list to the options that
|
|
12
|
+
* contain the text, and the arrow keys and Enter choose. For a short list that needs no typing, see
|
|
13
|
+
* SelectField; for several choices, MultiSelect; for free text with suggestions, Autocomplete.
|
|
14
|
+
*/
|
|
15
|
+
var Combobox = (t0) => {
|
|
16
|
+
const $ = c(48);
|
|
17
|
+
const { options, value, onValueChange, noMatchesLabel, resultsLabel, placeholder, disabled: t1, invalid: t2, required: t3, size: t4, contentBefore, name, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, onBlur, inputRef } = t0;
|
|
18
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
19
|
+
const invalid = t2 === void 0 ? false : t2;
|
|
20
|
+
const required = t3 === void 0 ? false : t3;
|
|
21
|
+
const size = t4 === void 0 ? "medium" : t4;
|
|
22
|
+
let t5;
|
|
23
|
+
if ($[0] !== options || $[1] !== value) {
|
|
24
|
+
t5 = options.find((option) => option.value === value) ?? null;
|
|
25
|
+
$[0] = options;
|
|
26
|
+
$[1] = value;
|
|
27
|
+
$[2] = t5;
|
|
28
|
+
} else t5 = $[2];
|
|
29
|
+
let t6;
|
|
30
|
+
if ($[3] !== onValueChange) {
|
|
31
|
+
t6 = (next) => {
|
|
32
|
+
onValueChange(next?.value ?? "");
|
|
33
|
+
};
|
|
34
|
+
$[3] = onValueChange;
|
|
35
|
+
$[4] = t6;
|
|
36
|
+
} else t6 = $[4];
|
|
37
|
+
let t7;
|
|
38
|
+
if ($[5] !== name) {
|
|
39
|
+
t7 = name ? { name } : {};
|
|
40
|
+
$[5] = name;
|
|
41
|
+
$[6] = t7;
|
|
42
|
+
} else t7 = $[6];
|
|
43
|
+
let t8;
|
|
44
|
+
if ($[7] !== size) {
|
|
45
|
+
t8 = fieldControl({ size });
|
|
46
|
+
$[7] = size;
|
|
47
|
+
$[8] = t8;
|
|
48
|
+
} else t8 = $[8];
|
|
49
|
+
const t9 = invalid || void 0;
|
|
50
|
+
const t10 = disabled || void 0;
|
|
51
|
+
let t11;
|
|
52
|
+
if ($[9] !== id) {
|
|
53
|
+
t11 = id ? { id } : {};
|
|
54
|
+
$[9] = id;
|
|
55
|
+
$[10] = t11;
|
|
56
|
+
} else t11 = $[10];
|
|
57
|
+
let t12;
|
|
58
|
+
if ($[11] !== ariaLabel) {
|
|
59
|
+
t12 = ariaLabel ? { "aria-label": ariaLabel } : {};
|
|
60
|
+
$[11] = ariaLabel;
|
|
61
|
+
$[12] = t12;
|
|
62
|
+
} else t12 = $[12];
|
|
63
|
+
let t13;
|
|
64
|
+
if ($[13] !== ariaLabelledBy) {
|
|
65
|
+
t13 = ariaLabelledBy ? { "aria-labelledby": ariaLabelledBy } : {};
|
|
66
|
+
$[13] = ariaLabelledBy;
|
|
67
|
+
$[14] = t13;
|
|
68
|
+
} else t13 = $[14];
|
|
69
|
+
let t14;
|
|
70
|
+
if ($[15] !== invalid) {
|
|
71
|
+
t14 = invalid ? { "aria-invalid": true } : {};
|
|
72
|
+
$[15] = invalid;
|
|
73
|
+
$[16] = t14;
|
|
74
|
+
} else t14 = $[16];
|
|
75
|
+
const t15 = required || void 0;
|
|
76
|
+
let t16;
|
|
77
|
+
if ($[17] !== inputRef || $[18] !== onBlur || $[19] !== placeholder || $[20] !== t11 || $[21] !== t12 || $[22] !== t13 || $[23] !== t14 || $[24] !== t15) {
|
|
78
|
+
t16 = /* @__PURE__ */ jsx(Combobox$1.Input, {
|
|
79
|
+
ref: inputRef,
|
|
80
|
+
...t11,
|
|
81
|
+
...t12,
|
|
82
|
+
...t13,
|
|
83
|
+
...t14,
|
|
84
|
+
"aria-required": t15,
|
|
85
|
+
className: fieldInput,
|
|
86
|
+
placeholder,
|
|
87
|
+
onFocus: _temp3,
|
|
88
|
+
onBlur
|
|
89
|
+
});
|
|
90
|
+
$[17] = inputRef;
|
|
91
|
+
$[18] = onBlur;
|
|
92
|
+
$[19] = placeholder;
|
|
93
|
+
$[20] = t11;
|
|
94
|
+
$[21] = t12;
|
|
95
|
+
$[22] = t13;
|
|
96
|
+
$[23] = t14;
|
|
97
|
+
$[24] = t15;
|
|
98
|
+
$[25] = t16;
|
|
99
|
+
} else t16 = $[25];
|
|
100
|
+
let t17;
|
|
101
|
+
if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
|
|
102
|
+
t17 = /* @__PURE__ */ jsx(Combobox$1.Trigger, {
|
|
103
|
+
className: "-me-1 inline-flex w-6 shrink-0 cursor-pointer items-center justify-center self-stretch border-0 bg-transparent p-0 text-fg-secondary outline-none disabled:cursor-not-allowed [&_svg]:size-3.5",
|
|
104
|
+
"aria-hidden": "true",
|
|
105
|
+
tabIndex: -1,
|
|
106
|
+
children: /* @__PURE__ */ jsx(ChevronDown, {})
|
|
107
|
+
});
|
|
108
|
+
$[26] = t17;
|
|
109
|
+
} else t17 = $[26];
|
|
110
|
+
let t18;
|
|
111
|
+
if ($[27] !== contentBefore || $[28] !== t10 || $[29] !== t16 || $[30] !== t8 || $[31] !== t9) {
|
|
112
|
+
t18 = /* @__PURE__ */ jsxs(Combobox$1.InputGroup, {
|
|
113
|
+
className: t8,
|
|
114
|
+
"data-invalid": t9,
|
|
115
|
+
"data-disabled": t10,
|
|
116
|
+
children: [
|
|
117
|
+
contentBefore,
|
|
118
|
+
t16,
|
|
119
|
+
t17
|
|
120
|
+
]
|
|
121
|
+
});
|
|
122
|
+
$[27] = contentBefore;
|
|
123
|
+
$[28] = t10;
|
|
124
|
+
$[29] = t16;
|
|
125
|
+
$[30] = t8;
|
|
126
|
+
$[31] = t9;
|
|
127
|
+
$[32] = t18;
|
|
128
|
+
} else t18 = $[32];
|
|
129
|
+
let t19;
|
|
130
|
+
if ($[33] !== ariaLabel || $[34] !== ariaLabelledBy) {
|
|
131
|
+
t19 = {
|
|
132
|
+
"aria-label": ariaLabel,
|
|
133
|
+
"aria-labelledby": ariaLabelledBy
|
|
134
|
+
};
|
|
135
|
+
$[33] = ariaLabel;
|
|
136
|
+
$[34] = ariaLabelledBy;
|
|
137
|
+
$[35] = t19;
|
|
138
|
+
} else t19 = $[35];
|
|
139
|
+
let t20;
|
|
140
|
+
if ($[36] !== noMatchesLabel || $[37] !== resultsLabel || $[38] !== t19) {
|
|
141
|
+
t20 = /* @__PURE__ */ jsx(ComboboxPopup, {
|
|
142
|
+
noMatchesLabel,
|
|
143
|
+
resultsLabel,
|
|
144
|
+
naming: t19,
|
|
145
|
+
children: _temp4
|
|
146
|
+
});
|
|
147
|
+
$[36] = noMatchesLabel;
|
|
148
|
+
$[37] = resultsLabel;
|
|
149
|
+
$[38] = t19;
|
|
150
|
+
$[39] = t20;
|
|
151
|
+
} else t20 = $[39];
|
|
152
|
+
let t21;
|
|
153
|
+
if ($[40] !== disabled || $[41] !== options || $[42] !== t18 || $[43] !== t20 || $[44] !== t5 || $[45] !== t6 || $[46] !== t7) {
|
|
154
|
+
t21 = /* @__PURE__ */ jsxs(Combobox$1.Root, {
|
|
155
|
+
items: options,
|
|
156
|
+
value: t5,
|
|
157
|
+
onValueChange: t6,
|
|
158
|
+
itemToStringLabel: _temp,
|
|
159
|
+
isItemEqualToValue: _temp2,
|
|
160
|
+
...t7,
|
|
161
|
+
disabled,
|
|
162
|
+
children: [t18, t20]
|
|
163
|
+
});
|
|
164
|
+
$[40] = disabled;
|
|
165
|
+
$[41] = options;
|
|
166
|
+
$[42] = t18;
|
|
167
|
+
$[43] = t20;
|
|
168
|
+
$[44] = t5;
|
|
169
|
+
$[45] = t6;
|
|
170
|
+
$[46] = t7;
|
|
171
|
+
$[47] = t21;
|
|
172
|
+
} else t21 = $[47];
|
|
173
|
+
return t21;
|
|
174
|
+
};
|
|
175
|
+
function _temp(option_0) {
|
|
176
|
+
return option_0.label;
|
|
177
|
+
}
|
|
178
|
+
function _temp2(a, b) {
|
|
179
|
+
return a.value === b.value;
|
|
180
|
+
}
|
|
181
|
+
function _temp3(event) {
|
|
182
|
+
event.currentTarget.select();
|
|
183
|
+
}
|
|
184
|
+
function _temp4(option_1) {
|
|
185
|
+
return /* @__PURE__ */ jsxs(Combobox$1.Item, {
|
|
186
|
+
value: option_1,
|
|
187
|
+
disabled: option_1.disabled,
|
|
188
|
+
className: item,
|
|
189
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
190
|
+
className: indicator,
|
|
191
|
+
children: /* @__PURE__ */ jsx(Combobox$1.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { "aria-hidden": "true" }) })
|
|
192
|
+
}), option_1.label]
|
|
193
|
+
}, option_1.value);
|
|
194
|
+
}
|
|
195
|
+
export { Combobox };
|