@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,26 @@
|
|
|
1
|
+
import type { Ref } from "react";
|
|
2
|
+
export interface CheckboxFieldProps {
|
|
3
|
+
label: string;
|
|
4
|
+
checked: boolean;
|
|
5
|
+
/** Called with the new state when the person ticks or clears the box. */
|
|
6
|
+
onCheckedChange: (checked: boolean) => void;
|
|
7
|
+
/** The field's name in a submitted form. */
|
|
8
|
+
name?: string | undefined;
|
|
9
|
+
hint?: string | undefined;
|
|
10
|
+
/** The validation message, in the user's language: shown in red under the box, which it marks invalid. */
|
|
11
|
+
errorMessage?: string | undefined;
|
|
12
|
+
/** Marks the field invalid without a message to show. */
|
|
13
|
+
invalid?: boolean | undefined;
|
|
14
|
+
disabled?: boolean | undefined;
|
|
15
|
+
/** "large" is a 20px box (the default is 17px). */
|
|
16
|
+
size?: "medium" | "large" | undefined;
|
|
17
|
+
/** The checkbox was left. */
|
|
18
|
+
onBlur?: (() => void) | undefined;
|
|
19
|
+
/** The checkbox's hidden input, e.g. for a form library to focus the first invalid field. */
|
|
20
|
+
inputRef?: Ref<HTMLInputElement> | undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A checkbox with its label, hint and error. It is controlled: it shows `checked` and reports a change through
|
|
24
|
+
* `onCheckedChange`. Bound to react-hook-form, it is FormCheckboxField.
|
|
25
|
+
*/
|
|
26
|
+
export declare const CheckboxField: ({ label, checked, onCheckedChange, name, hint, errorMessage, invalid, onBlur, inputRef, disabled, size, }: CheckboxFieldProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Field } from "@base-ui/react/field";
|
|
4
|
+
import { CheckboxBox } from "../../components/Checkbox/CheckboxBox.js";
|
|
5
|
+
import { FieldMessages } from "./FieldFrame.js";
|
|
6
|
+
import { fieldChoice, fieldRoot } from "./field-styles.js";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/patterns/FormField/CheckboxField.tsx
|
|
9
|
+
/**
|
|
10
|
+
* A checkbox with its label, hint and error. It is controlled: it shows `checked` and reports a change through
|
|
11
|
+
* `onCheckedChange`. Bound to react-hook-form, it is FormCheckboxField.
|
|
12
|
+
*/
|
|
13
|
+
var CheckboxField = (t0) => {
|
|
14
|
+
const $ = c(25);
|
|
15
|
+
const { label, checked, onCheckedChange, name, hint, errorMessage, invalid: t1, onBlur, inputRef, disabled: t2, size: t3 } = t0;
|
|
16
|
+
const invalid = t1 === void 0 ? false : t1;
|
|
17
|
+
const disabled = t2 === void 0 ? false : t2;
|
|
18
|
+
const size = t3 === void 0 ? "medium" : t3;
|
|
19
|
+
let t4;
|
|
20
|
+
if ($[0] !== name) {
|
|
21
|
+
t4 = name ? { name } : {};
|
|
22
|
+
$[0] = name;
|
|
23
|
+
$[1] = t4;
|
|
24
|
+
} else t4 = $[1];
|
|
25
|
+
const t5 = invalid || errorMessage !== void 0;
|
|
26
|
+
let t6;
|
|
27
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
28
|
+
t6 = fieldRoot();
|
|
29
|
+
$[2] = t6;
|
|
30
|
+
} else t6 = $[2];
|
|
31
|
+
let t7;
|
|
32
|
+
if ($[3] !== checked || $[4] !== inputRef || $[5] !== onBlur || $[6] !== onCheckedChange || $[7] !== size) {
|
|
33
|
+
t7 = /* @__PURE__ */ jsx(CheckboxBox, {
|
|
34
|
+
size,
|
|
35
|
+
checked,
|
|
36
|
+
inputRef,
|
|
37
|
+
onCheckedChange,
|
|
38
|
+
onBlur
|
|
39
|
+
});
|
|
40
|
+
$[3] = checked;
|
|
41
|
+
$[4] = inputRef;
|
|
42
|
+
$[5] = onBlur;
|
|
43
|
+
$[6] = onCheckedChange;
|
|
44
|
+
$[7] = size;
|
|
45
|
+
$[8] = t7;
|
|
46
|
+
} else t7 = $[8];
|
|
47
|
+
let t8;
|
|
48
|
+
if ($[9] !== label || $[10] !== t7) {
|
|
49
|
+
t8 = /* @__PURE__ */ jsxs(Field.Label, {
|
|
50
|
+
className: fieldChoice,
|
|
51
|
+
children: [t7, label]
|
|
52
|
+
});
|
|
53
|
+
$[9] = label;
|
|
54
|
+
$[10] = t7;
|
|
55
|
+
$[11] = t8;
|
|
56
|
+
} else t8 = $[11];
|
|
57
|
+
let t9;
|
|
58
|
+
if ($[12] !== errorMessage) {
|
|
59
|
+
t9 = errorMessage === void 0 ? {} : { errorMessage };
|
|
60
|
+
$[12] = errorMessage;
|
|
61
|
+
$[13] = t9;
|
|
62
|
+
} else t9 = $[13];
|
|
63
|
+
let t10;
|
|
64
|
+
if ($[14] !== hint) {
|
|
65
|
+
t10 = hint ? { hint } : {};
|
|
66
|
+
$[14] = hint;
|
|
67
|
+
$[15] = t10;
|
|
68
|
+
} else t10 = $[15];
|
|
69
|
+
let t11;
|
|
70
|
+
if ($[16] !== t10 || $[17] !== t9) {
|
|
71
|
+
t11 = /* @__PURE__ */ jsx(FieldMessages, {
|
|
72
|
+
...t9,
|
|
73
|
+
...t10
|
|
74
|
+
});
|
|
75
|
+
$[16] = t10;
|
|
76
|
+
$[17] = t9;
|
|
77
|
+
$[18] = t11;
|
|
78
|
+
} else t11 = $[18];
|
|
79
|
+
let t12;
|
|
80
|
+
if ($[19] !== disabled || $[20] !== t11 || $[21] !== t4 || $[22] !== t5 || $[23] !== t8) {
|
|
81
|
+
t12 = /* @__PURE__ */ jsxs(Field.Root, {
|
|
82
|
+
...t4,
|
|
83
|
+
invalid: t5,
|
|
84
|
+
disabled,
|
|
85
|
+
className: t6,
|
|
86
|
+
children: [t8, t11]
|
|
87
|
+
});
|
|
88
|
+
$[19] = disabled;
|
|
89
|
+
$[20] = t11;
|
|
90
|
+
$[21] = t4;
|
|
91
|
+
$[22] = t5;
|
|
92
|
+
$[23] = t8;
|
|
93
|
+
$[24] = t12;
|
|
94
|
+
} else t12 = $[24];
|
|
95
|
+
return t12;
|
|
96
|
+
};
|
|
97
|
+
export { CheckboxField };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { FieldOrientation, FieldSize } from "./field-types.js";
|
|
3
|
+
export interface FieldFrameProps {
|
|
4
|
+
/** The field's name: it identifies the field to Base UI and in a submitted form. */
|
|
5
|
+
name?: string | undefined;
|
|
6
|
+
/** The field's label, above the control or beside it. It names the control. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Keep the label out of the layout and give it to assistive technology only. */
|
|
9
|
+
hideLabel?: boolean | undefined;
|
|
10
|
+
/** Help under the control, in grey; it describes the control. */
|
|
11
|
+
hint?: string | undefined;
|
|
12
|
+
/** Adds the asterisk to the label. It does not mark the control: give the control `aria-required` too. */
|
|
13
|
+
required?: boolean | undefined;
|
|
14
|
+
/** Disables the field: Base UI controls inside it are disabled with it (a plain `<input>` needs its own `disabled`). */
|
|
15
|
+
disabled?: boolean | undefined;
|
|
16
|
+
/** The validation message, already formatted for display. */
|
|
17
|
+
errorMessage?: string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Shown instead of nothing when there is no error, in green, with a check. It describes the control and is
|
|
20
|
+
* announced when it appears.
|
|
21
|
+
*/
|
|
22
|
+
successMessage?: string | undefined;
|
|
23
|
+
/** Marks the field and its control invalid; the label turns red. */
|
|
24
|
+
invalid: boolean;
|
|
25
|
+
/** The field has been left. Base UI tracks it itself when omitted. */
|
|
26
|
+
touched?: boolean | undefined;
|
|
27
|
+
/** The value differs from the first one. Base UI tracks it itself when omitted. */
|
|
28
|
+
dirty?: boolean | undefined;
|
|
29
|
+
/** Label above the control (default) or in a column beside it. */
|
|
30
|
+
orientation?: FieldOrientation | undefined;
|
|
31
|
+
/** The control's size, which sets the gap under the label. */
|
|
32
|
+
size?: FieldSize | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* The control is a button that opens a popup (select, combobox). Its label
|
|
35
|
+
* must not behave as a native <label>, which would also click the button.
|
|
36
|
+
*/
|
|
37
|
+
triggerLabel?: boolean | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The label's DOM id, for a control that names itself with `aria-labelledby`
|
|
40
|
+
* (a trigger whose button text is the chosen value, so it needs the label and
|
|
41
|
+
* the value both).
|
|
42
|
+
*/
|
|
43
|
+
labelId?: string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* DOM ids for the validation message and the hint, for a control that Base UI
|
|
46
|
+
* does not describe by itself (a button that opens a panel): it lists them in
|
|
47
|
+
* its `aria-describedby`.
|
|
48
|
+
*/
|
|
49
|
+
messageIds?: {
|
|
50
|
+
error: string;
|
|
51
|
+
hint: string;
|
|
52
|
+
} | undefined;
|
|
53
|
+
/** The control. */
|
|
54
|
+
children: ReactNode;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The shared shell of every form field: label, control, validation message and
|
|
58
|
+
* hint, in a column or with the label beside the control. The field's state
|
|
59
|
+
* (invalid, and touched and dirty when a form library tracks them) goes through
|
|
60
|
+
* Base UI's Field, so the control is labelled and described for assistive
|
|
61
|
+
* technology automatically (for a control Base UI does not describe, see
|
|
62
|
+
* `messageIds`). Every field of the design system is built on it.
|
|
63
|
+
*/
|
|
64
|
+
export declare const FieldFrame: ({ name, label, hideLabel, hint, required, disabled, errorMessage, successMessage, invalid, touched, dirty, orientation, size, triggerLabel, labelId, messageIds, children, }: FieldFrameProps) => import("react").JSX.Element;
|
|
65
|
+
interface FieldMessagesProps {
|
|
66
|
+
/** The validation message, shown in red as an alert. */
|
|
67
|
+
errorMessage?: string | undefined;
|
|
68
|
+
/** A confirmation, shown in green while there is no error. */
|
|
69
|
+
successMessage?: string | undefined;
|
|
70
|
+
/** Help under the control, in grey. */
|
|
71
|
+
hint?: string | undefined;
|
|
72
|
+
/** DOM ids for the validation message and the hint (see FieldFrame's `messageIds`). */
|
|
73
|
+
ids?: {
|
|
74
|
+
error: string;
|
|
75
|
+
hint: string;
|
|
76
|
+
} | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Keep a polite live region where the confirmation goes, there (empty) before it is, so a screen reader announces
|
|
79
|
+
* the confirmation when it appears: a live region added together with its text is often not read.
|
|
80
|
+
*/
|
|
81
|
+
announceSuccess?: boolean | undefined;
|
|
82
|
+
}
|
|
83
|
+
/** What goes under a control: the validation message, or a confirmation, and the hint. Inside a Field.Root. */
|
|
84
|
+
export declare const FieldMessages: ({ errorMessage, successMessage, hint, ids, announceSuccess }: FieldMessagesProps) => import("react").JSX.Element;
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Field } from "@base-ui/react/field";
|
|
4
|
+
import { CircleAlert, CircleCheck } from "lucide-react";
|
|
5
|
+
import { cn } from "../../utils/cn.js";
|
|
6
|
+
import { fieldLabel, fieldRoot } from "./field-styles.js";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/patterns/FormField/FieldFrame.tsx
|
|
9
|
+
/** Under a control: 12px, an icon beside the first line, in the second column when the label is beside the control. */
|
|
10
|
+
var MESSAGE = "mt-1 flex items-start gap-1 text-caption font-normal group-data-[orientation=horizontal]/field:col-start-2 [&>svg]:mt-0.5 [&>svg]:size-3.5";
|
|
11
|
+
/**
|
|
12
|
+
* The shared shell of every form field: label, control, validation message and
|
|
13
|
+
* hint, in a column or with the label beside the control. The field's state
|
|
14
|
+
* (invalid, and touched and dirty when a form library tracks them) goes through
|
|
15
|
+
* Base UI's Field, so the control is labelled and described for assistive
|
|
16
|
+
* technology automatically (for a control Base UI does not describe, see
|
|
17
|
+
* `messageIds`). Every field of the design system is built on it.
|
|
18
|
+
*/
|
|
19
|
+
var FieldFrame = (t0) => {
|
|
20
|
+
const $ = c(49);
|
|
21
|
+
const { name, label, hideLabel: t1, hint, required: t2, disabled: t3, errorMessage, successMessage, invalid, touched, dirty, orientation: t4, size: t5, triggerLabel: t6, labelId, messageIds, children } = t0;
|
|
22
|
+
const hideLabel = t1 === void 0 ? false : t1;
|
|
23
|
+
const required = t2 === void 0 ? false : t2;
|
|
24
|
+
const disabled = t3 === void 0 ? false : t3;
|
|
25
|
+
const orientation = t4 === void 0 ? "vertical" : t4;
|
|
26
|
+
const size = t5 === void 0 ? "medium" : t5;
|
|
27
|
+
const triggerLabel = t6 === void 0 ? false : t6;
|
|
28
|
+
let t7;
|
|
29
|
+
if ($[0] !== name) {
|
|
30
|
+
t7 = name === void 0 ? {} : { name };
|
|
31
|
+
$[0] = name;
|
|
32
|
+
$[1] = t7;
|
|
33
|
+
} else t7 = $[1];
|
|
34
|
+
let t8;
|
|
35
|
+
if ($[2] !== touched) {
|
|
36
|
+
t8 = touched === void 0 ? {} : { touched };
|
|
37
|
+
$[2] = touched;
|
|
38
|
+
$[3] = t8;
|
|
39
|
+
} else t8 = $[3];
|
|
40
|
+
let t9;
|
|
41
|
+
if ($[4] !== dirty) {
|
|
42
|
+
t9 = dirty === void 0 ? {} : { dirty };
|
|
43
|
+
$[4] = dirty;
|
|
44
|
+
$[5] = t9;
|
|
45
|
+
} else t9 = $[5];
|
|
46
|
+
let t10;
|
|
47
|
+
if ($[6] !== orientation) {
|
|
48
|
+
t10 = fieldRoot({ orientation });
|
|
49
|
+
$[6] = orientation;
|
|
50
|
+
$[7] = t10;
|
|
51
|
+
} else t10 = $[7];
|
|
52
|
+
let t11;
|
|
53
|
+
if ($[8] !== hideLabel || $[9] !== orientation || $[10] !== size) {
|
|
54
|
+
t11 = hideLabel ? "sr-only" : fieldLabel({
|
|
55
|
+
size,
|
|
56
|
+
orientation
|
|
57
|
+
});
|
|
58
|
+
$[8] = hideLabel;
|
|
59
|
+
$[9] = orientation;
|
|
60
|
+
$[10] = size;
|
|
61
|
+
$[11] = t11;
|
|
62
|
+
} else t11 = $[11];
|
|
63
|
+
let t12;
|
|
64
|
+
if ($[12] !== labelId) {
|
|
65
|
+
t12 = labelId ? { id: labelId } : {};
|
|
66
|
+
$[12] = labelId;
|
|
67
|
+
$[13] = t12;
|
|
68
|
+
} else t12 = $[13];
|
|
69
|
+
let t13;
|
|
70
|
+
if ($[14] !== triggerLabel) {
|
|
71
|
+
t13 = triggerLabel ? {
|
|
72
|
+
nativeLabel: false,
|
|
73
|
+
render: /* @__PURE__ */ jsx("div", {})
|
|
74
|
+
} : {};
|
|
75
|
+
$[14] = triggerLabel;
|
|
76
|
+
$[15] = t13;
|
|
77
|
+
} else t13 = $[15];
|
|
78
|
+
let t14;
|
|
79
|
+
if ($[16] !== required) {
|
|
80
|
+
t14 = required ? /* @__PURE__ */ jsx("span", {
|
|
81
|
+
"aria-hidden": "true",
|
|
82
|
+
className: "ms-0.5 text-error-text",
|
|
83
|
+
children: "*"
|
|
84
|
+
}) : null;
|
|
85
|
+
$[16] = required;
|
|
86
|
+
$[17] = t14;
|
|
87
|
+
} else t14 = $[17];
|
|
88
|
+
let t15;
|
|
89
|
+
if ($[18] !== label || $[19] !== t11 || $[20] !== t12 || $[21] !== t13 || $[22] !== t14) {
|
|
90
|
+
t15 = /* @__PURE__ */ jsxs(Field.Label, {
|
|
91
|
+
className: t11,
|
|
92
|
+
...t12,
|
|
93
|
+
...t13,
|
|
94
|
+
children: [label, t14]
|
|
95
|
+
});
|
|
96
|
+
$[18] = label;
|
|
97
|
+
$[19] = t11;
|
|
98
|
+
$[20] = t12;
|
|
99
|
+
$[21] = t13;
|
|
100
|
+
$[22] = t14;
|
|
101
|
+
$[23] = t15;
|
|
102
|
+
} else t15 = $[23];
|
|
103
|
+
let t16;
|
|
104
|
+
if ($[24] !== errorMessage) {
|
|
105
|
+
t16 = errorMessage === void 0 ? {} : { errorMessage };
|
|
106
|
+
$[24] = errorMessage;
|
|
107
|
+
$[25] = t16;
|
|
108
|
+
} else t16 = $[25];
|
|
109
|
+
let t17;
|
|
110
|
+
if ($[26] !== successMessage) {
|
|
111
|
+
t17 = successMessage === void 0 ? {} : { successMessage };
|
|
112
|
+
$[26] = successMessage;
|
|
113
|
+
$[27] = t17;
|
|
114
|
+
} else t17 = $[27];
|
|
115
|
+
let t18;
|
|
116
|
+
if ($[28] !== hint) {
|
|
117
|
+
t18 = hint ? { hint } : {};
|
|
118
|
+
$[28] = hint;
|
|
119
|
+
$[29] = t18;
|
|
120
|
+
} else t18 = $[29];
|
|
121
|
+
let t19;
|
|
122
|
+
if ($[30] !== messageIds) {
|
|
123
|
+
t19 = messageIds ? { ids: messageIds } : {};
|
|
124
|
+
$[30] = messageIds;
|
|
125
|
+
$[31] = t19;
|
|
126
|
+
} else t19 = $[31];
|
|
127
|
+
let t20;
|
|
128
|
+
if ($[32] !== t16 || $[33] !== t17 || $[34] !== t18 || $[35] !== t19) {
|
|
129
|
+
t20 = /* @__PURE__ */ jsx(FieldMessages, {
|
|
130
|
+
...t16,
|
|
131
|
+
...t17,
|
|
132
|
+
...t18,
|
|
133
|
+
...t19,
|
|
134
|
+
announceSuccess: true
|
|
135
|
+
});
|
|
136
|
+
$[32] = t16;
|
|
137
|
+
$[33] = t17;
|
|
138
|
+
$[34] = t18;
|
|
139
|
+
$[35] = t19;
|
|
140
|
+
$[36] = t20;
|
|
141
|
+
} else t20 = $[36];
|
|
142
|
+
let t21;
|
|
143
|
+
if ($[37] !== children || $[38] !== disabled || $[39] !== invalid || $[40] !== orientation || $[41] !== size || $[42] !== t10 || $[43] !== t15 || $[44] !== t20 || $[45] !== t7 || $[46] !== t8 || $[47] !== t9) {
|
|
144
|
+
t21 = /* @__PURE__ */ jsxs(Field.Root, {
|
|
145
|
+
...t7,
|
|
146
|
+
invalid,
|
|
147
|
+
...t8,
|
|
148
|
+
...t9,
|
|
149
|
+
disabled,
|
|
150
|
+
className: t10,
|
|
151
|
+
"data-orientation": orientation,
|
|
152
|
+
"data-size": size,
|
|
153
|
+
children: [
|
|
154
|
+
t15,
|
|
155
|
+
children,
|
|
156
|
+
t20
|
|
157
|
+
]
|
|
158
|
+
});
|
|
159
|
+
$[37] = children;
|
|
160
|
+
$[38] = disabled;
|
|
161
|
+
$[39] = invalid;
|
|
162
|
+
$[40] = orientation;
|
|
163
|
+
$[41] = size;
|
|
164
|
+
$[42] = t10;
|
|
165
|
+
$[43] = t15;
|
|
166
|
+
$[44] = t20;
|
|
167
|
+
$[45] = t7;
|
|
168
|
+
$[46] = t8;
|
|
169
|
+
$[47] = t9;
|
|
170
|
+
$[48] = t21;
|
|
171
|
+
} else t21 = $[48];
|
|
172
|
+
return t21;
|
|
173
|
+
};
|
|
174
|
+
/** What goes under a control: the validation message, or a confirmation, and the hint. Inside a Field.Root. */
|
|
175
|
+
var FieldMessages = (t0) => {
|
|
176
|
+
const $ = c(21);
|
|
177
|
+
const { errorMessage, successMessage, hint, ids, announceSuccess: t1 } = t0;
|
|
178
|
+
const announceSuccess = t1 === void 0 ? false : t1;
|
|
179
|
+
let t2;
|
|
180
|
+
if ($[0] !== errorMessage || $[1] !== successMessage) {
|
|
181
|
+
t2 = errorMessage === void 0 && successMessage !== void 0 ? /* @__PURE__ */ jsxs(Field.Description, {
|
|
182
|
+
className: cn(MESSAGE, "text-success-text"),
|
|
183
|
+
children: [/* @__PURE__ */ jsx(CircleCheck, { "aria-hidden": "true" }), successMessage]
|
|
184
|
+
}) : null;
|
|
185
|
+
$[0] = errorMessage;
|
|
186
|
+
$[1] = successMessage;
|
|
187
|
+
$[2] = t2;
|
|
188
|
+
} else t2 = $[2];
|
|
189
|
+
const success = t2;
|
|
190
|
+
const t3 = errorMessage !== void 0;
|
|
191
|
+
let t4;
|
|
192
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
193
|
+
t4 = cn(MESSAGE, "text-error-text");
|
|
194
|
+
$[3] = t4;
|
|
195
|
+
} else t4 = $[3];
|
|
196
|
+
let t5;
|
|
197
|
+
if ($[4] !== ids) {
|
|
198
|
+
t5 = ids ? { id: ids.error } : {};
|
|
199
|
+
$[4] = ids;
|
|
200
|
+
$[5] = t5;
|
|
201
|
+
} else t5 = $[5];
|
|
202
|
+
let t6;
|
|
203
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
204
|
+
t6 = /* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": "true" });
|
|
205
|
+
$[6] = t6;
|
|
206
|
+
} else t6 = $[6];
|
|
207
|
+
let t7;
|
|
208
|
+
if ($[7] !== errorMessage || $[8] !== t3 || $[9] !== t5) {
|
|
209
|
+
t7 = /* @__PURE__ */ jsxs(Field.Error, {
|
|
210
|
+
match: t3,
|
|
211
|
+
role: "alert",
|
|
212
|
+
className: t4,
|
|
213
|
+
...t5,
|
|
214
|
+
children: [t6, errorMessage]
|
|
215
|
+
});
|
|
216
|
+
$[7] = errorMessage;
|
|
217
|
+
$[8] = t3;
|
|
218
|
+
$[9] = t5;
|
|
219
|
+
$[10] = t7;
|
|
220
|
+
} else t7 = $[10];
|
|
221
|
+
let t8;
|
|
222
|
+
if ($[11] !== announceSuccess || $[12] !== success) {
|
|
223
|
+
t8 = announceSuccess ? /* @__PURE__ */ jsx("div", {
|
|
224
|
+
role: "status",
|
|
225
|
+
className: "group-data-[orientation=horizontal]/field:col-start-2",
|
|
226
|
+
children: success
|
|
227
|
+
}) : success;
|
|
228
|
+
$[11] = announceSuccess;
|
|
229
|
+
$[12] = success;
|
|
230
|
+
$[13] = t8;
|
|
231
|
+
} else t8 = $[13];
|
|
232
|
+
let t9;
|
|
233
|
+
if ($[14] !== hint || $[15] !== ids) {
|
|
234
|
+
t9 = hint ? /* @__PURE__ */ jsx(Field.Description, {
|
|
235
|
+
className: cn(MESSAGE, "text-fg-secondary"),
|
|
236
|
+
...ids ? { id: ids.hint } : {},
|
|
237
|
+
children: hint
|
|
238
|
+
}) : null;
|
|
239
|
+
$[14] = hint;
|
|
240
|
+
$[15] = ids;
|
|
241
|
+
$[16] = t9;
|
|
242
|
+
} else t9 = $[16];
|
|
243
|
+
let t10;
|
|
244
|
+
if ($[17] !== t7 || $[18] !== t8 || $[19] !== t9) {
|
|
245
|
+
t10 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
246
|
+
t7,
|
|
247
|
+
t8,
|
|
248
|
+
t9
|
|
249
|
+
] });
|
|
250
|
+
$[17] = t7;
|
|
251
|
+
$[18] = t8;
|
|
252
|
+
$[19] = t9;
|
|
253
|
+
$[20] = t10;
|
|
254
|
+
} else t10 = $[20];
|
|
255
|
+
return t10;
|
|
256
|
+
};
|
|
257
|
+
export { FieldFrame, FieldMessages };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import { type CheckboxFieldProps } from "./CheckboxField.js";
|
|
3
|
+
export interface FormCheckboxFieldProps<TValues extends FieldValues> extends Omit<CheckboxFieldProps, "name" | "checked" | "onCheckedChange" | "onBlur" | "errorMessage" | "invalid" | "inputRef"> {
|
|
4
|
+
control: Control<TValues>;
|
|
5
|
+
name: FieldPath<TValues>;
|
|
6
|
+
/**
|
|
7
|
+
* react-hook-form validation rules, for forms that do not use a schema resolver (e.g. `{ required: "namespace:key" }`):
|
|
8
|
+
* the message is shown as the field's error, through `formatError`.
|
|
9
|
+
*/
|
|
10
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
11
|
+
/** Turns a stored schema message (an i18n key) into display text. */
|
|
12
|
+
formatError?: ((message: string) => string) | undefined;
|
|
13
|
+
/** Called after the value changes. */
|
|
14
|
+
onCheckedChange?: ((checked: boolean) => void) | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** A CheckboxField bound to a boolean react-hook-form field, with consistent error display. */
|
|
17
|
+
export declare const FormCheckboxField: <TValues extends FieldValues>({ control, name, rules, formatError, onCheckedChange, disabled, size, ...checkboxProps }: FormCheckboxFieldProps<TValues>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Controller } from "react-hook-form";
|
|
4
|
+
import { toErrorText } from "./error-message.js";
|
|
5
|
+
import { CheckboxField } from "./CheckboxField.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// src/patterns/FormField/FormCheckboxField.tsx
|
|
8
|
+
/** A CheckboxField bound to a boolean react-hook-form field, with consistent error display. */
|
|
9
|
+
var FormCheckboxField = (t0) => {
|
|
10
|
+
const $ = c(22);
|
|
11
|
+
let checkboxProps;
|
|
12
|
+
let control;
|
|
13
|
+
let formatError;
|
|
14
|
+
let name;
|
|
15
|
+
let onCheckedChange;
|
|
16
|
+
let rules;
|
|
17
|
+
let t1;
|
|
18
|
+
let t2;
|
|
19
|
+
if ($[0] !== t0) {
|
|
20
|
+
({control, name, rules, formatError, onCheckedChange, disabled: t1, size: t2, ...checkboxProps} = t0);
|
|
21
|
+
$[0] = t0;
|
|
22
|
+
$[1] = checkboxProps;
|
|
23
|
+
$[2] = control;
|
|
24
|
+
$[3] = formatError;
|
|
25
|
+
$[4] = name;
|
|
26
|
+
$[5] = onCheckedChange;
|
|
27
|
+
$[6] = rules;
|
|
28
|
+
$[7] = t1;
|
|
29
|
+
$[8] = t2;
|
|
30
|
+
} else {
|
|
31
|
+
checkboxProps = $[1];
|
|
32
|
+
control = $[2];
|
|
33
|
+
formatError = $[3];
|
|
34
|
+
name = $[4];
|
|
35
|
+
onCheckedChange = $[5];
|
|
36
|
+
rules = $[6];
|
|
37
|
+
t1 = $[7];
|
|
38
|
+
t2 = $[8];
|
|
39
|
+
}
|
|
40
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
41
|
+
const size = t2 === void 0 ? "medium" : t2;
|
|
42
|
+
let t3;
|
|
43
|
+
if ($[9] !== rules) {
|
|
44
|
+
t3 = rules ? { rules } : {};
|
|
45
|
+
$[9] = rules;
|
|
46
|
+
$[10] = t3;
|
|
47
|
+
} else t3 = $[10];
|
|
48
|
+
let t4;
|
|
49
|
+
if ($[11] !== checkboxProps || $[12] !== disabled || $[13] !== formatError || $[14] !== onCheckedChange || $[15] !== size) {
|
|
50
|
+
t4 = (t5) => {
|
|
51
|
+
const { field, fieldState } = t5;
|
|
52
|
+
const errorMessage = toErrorText(fieldState.error?.message, formatError);
|
|
53
|
+
return /* @__PURE__ */ jsx(CheckboxField, {
|
|
54
|
+
...checkboxProps,
|
|
55
|
+
disabled,
|
|
56
|
+
size,
|
|
57
|
+
name: field.name,
|
|
58
|
+
inputRef: field.ref,
|
|
59
|
+
checked: field.value === true,
|
|
60
|
+
onCheckedChange: (checked) => {
|
|
61
|
+
field.onChange(checked);
|
|
62
|
+
onCheckedChange?.(checked);
|
|
63
|
+
},
|
|
64
|
+
onBlur: field.onBlur,
|
|
65
|
+
invalid: fieldState.invalid,
|
|
66
|
+
...errorMessage === void 0 ? {} : { errorMessage }
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
$[11] = checkboxProps;
|
|
70
|
+
$[12] = disabled;
|
|
71
|
+
$[13] = formatError;
|
|
72
|
+
$[14] = onCheckedChange;
|
|
73
|
+
$[15] = size;
|
|
74
|
+
$[16] = t4;
|
|
75
|
+
} else t4 = $[16];
|
|
76
|
+
let t5;
|
|
77
|
+
if ($[17] !== control || $[18] !== name || $[19] !== t3 || $[20] !== t4) {
|
|
78
|
+
t5 = /* @__PURE__ */ jsx(Controller, {
|
|
79
|
+
control,
|
|
80
|
+
name,
|
|
81
|
+
...t3,
|
|
82
|
+
render: t4
|
|
83
|
+
});
|
|
84
|
+
$[17] = control;
|
|
85
|
+
$[18] = name;
|
|
86
|
+
$[19] = t3;
|
|
87
|
+
$[20] = t4;
|
|
88
|
+
$[21] = t5;
|
|
89
|
+
} else t5 = $[21];
|
|
90
|
+
return t5;
|
|
91
|
+
};
|
|
92
|
+
export { FormCheckboxField };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import { type RadioGroupFieldProps } from "./RadioGroupField.js";
|
|
3
|
+
export type { RadioOption } from "./RadioGroupField.js";
|
|
4
|
+
export interface FormRadioGroupFieldProps<TValues extends FieldValues> extends Omit<RadioGroupFieldProps, "name" | "value" | "onValueChange" | "onBlur" | "errorMessage" | "invalid" | "inputRef"> {
|
|
5
|
+
control: Control<TValues>;
|
|
6
|
+
name: FieldPath<TValues>;
|
|
7
|
+
/**
|
|
8
|
+
* react-hook-form validation rules, for forms that do not use a schema resolver (e.g. `{ required: "namespace:key" }`):
|
|
9
|
+
* the message is shown as the field's error, through `formatError`.
|
|
10
|
+
*/
|
|
11
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
12
|
+
/** Turns a stored schema message (an i18n key) into display text. */
|
|
13
|
+
formatError?: ((message: string) => string) | undefined;
|
|
14
|
+
}
|
|
15
|
+
/** A RadioGroupField bound to react-hook-form. The field value is the chosen option's `value` string. */
|
|
16
|
+
export declare const FormRadioGroupField: <TValues extends FieldValues>({ control, name, rules, formatError, required, disabled, orientation, layout, ...radioGroupProps }: FormRadioGroupFieldProps<TValues>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Controller } from "react-hook-form";
|
|
4
|
+
import { toErrorText } from "./error-message.js";
|
|
5
|
+
import { RadioGroupField } from "./RadioGroupField.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// src/patterns/FormField/FormRadioGroupField.tsx
|
|
8
|
+
/** A RadioGroupField bound to react-hook-form. The field value is the chosen option's `value` string. */
|
|
9
|
+
var FormRadioGroupField = (t0) => {
|
|
10
|
+
const $ = c(24);
|
|
11
|
+
let control;
|
|
12
|
+
let formatError;
|
|
13
|
+
let name;
|
|
14
|
+
let radioGroupProps;
|
|
15
|
+
let rules;
|
|
16
|
+
let t1;
|
|
17
|
+
let t2;
|
|
18
|
+
let t3;
|
|
19
|
+
let t4;
|
|
20
|
+
if ($[0] !== t0) {
|
|
21
|
+
({control, name, rules, formatError, required: t1, disabled: t2, orientation: t3, layout: t4, ...radioGroupProps} = t0);
|
|
22
|
+
$[0] = t0;
|
|
23
|
+
$[1] = control;
|
|
24
|
+
$[2] = formatError;
|
|
25
|
+
$[3] = name;
|
|
26
|
+
$[4] = radioGroupProps;
|
|
27
|
+
$[5] = rules;
|
|
28
|
+
$[6] = t1;
|
|
29
|
+
$[7] = t2;
|
|
30
|
+
$[8] = t3;
|
|
31
|
+
$[9] = t4;
|
|
32
|
+
} else {
|
|
33
|
+
control = $[1];
|
|
34
|
+
formatError = $[2];
|
|
35
|
+
name = $[3];
|
|
36
|
+
radioGroupProps = $[4];
|
|
37
|
+
rules = $[5];
|
|
38
|
+
t1 = $[6];
|
|
39
|
+
t2 = $[7];
|
|
40
|
+
t3 = $[8];
|
|
41
|
+
t4 = $[9];
|
|
42
|
+
}
|
|
43
|
+
const required = t1 === void 0 ? false : t1;
|
|
44
|
+
const disabled = t2 === void 0 ? false : t2;
|
|
45
|
+
const orientation = t3 === void 0 ? "vertical" : t3;
|
|
46
|
+
const layout = t4 === void 0 ? "vertical" : t4;
|
|
47
|
+
let t5;
|
|
48
|
+
if ($[10] !== rules) {
|
|
49
|
+
t5 = rules ? { rules } : {};
|
|
50
|
+
$[10] = rules;
|
|
51
|
+
$[11] = t5;
|
|
52
|
+
} else t5 = $[11];
|
|
53
|
+
let t6;
|
|
54
|
+
if ($[12] !== disabled || $[13] !== formatError || $[14] !== layout || $[15] !== orientation || $[16] !== radioGroupProps || $[17] !== required) {
|
|
55
|
+
t6 = (t7) => {
|
|
56
|
+
const { field, fieldState } = t7;
|
|
57
|
+
const errorMessage = toErrorText(fieldState.error?.message, formatError);
|
|
58
|
+
return /* @__PURE__ */ jsx(RadioGroupField, {
|
|
59
|
+
...radioGroupProps,
|
|
60
|
+
required,
|
|
61
|
+
disabled,
|
|
62
|
+
orientation,
|
|
63
|
+
layout,
|
|
64
|
+
name: field.name,
|
|
65
|
+
inputRef: field.ref,
|
|
66
|
+
value: field.value == null ? "" : String(field.value),
|
|
67
|
+
onValueChange: field.onChange,
|
|
68
|
+
onBlur: field.onBlur,
|
|
69
|
+
invalid: fieldState.invalid,
|
|
70
|
+
...errorMessage === void 0 ? {} : { errorMessage }
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
$[12] = disabled;
|
|
74
|
+
$[13] = formatError;
|
|
75
|
+
$[14] = layout;
|
|
76
|
+
$[15] = orientation;
|
|
77
|
+
$[16] = radioGroupProps;
|
|
78
|
+
$[17] = required;
|
|
79
|
+
$[18] = t6;
|
|
80
|
+
} else t6 = $[18];
|
|
81
|
+
let t7;
|
|
82
|
+
if ($[19] !== control || $[20] !== name || $[21] !== t5 || $[22] !== t6) {
|
|
83
|
+
t7 = /* @__PURE__ */ jsx(Controller, {
|
|
84
|
+
control,
|
|
85
|
+
name,
|
|
86
|
+
...t5,
|
|
87
|
+
render: t6
|
|
88
|
+
});
|
|
89
|
+
$[19] = control;
|
|
90
|
+
$[20] = name;
|
|
91
|
+
$[21] = t5;
|
|
92
|
+
$[22] = t6;
|
|
93
|
+
$[23] = t7;
|
|
94
|
+
} else t7 = $[23];
|
|
95
|
+
return t7;
|
|
96
|
+
};
|
|
97
|
+
export { FormRadioGroupField };
|