@primecoderin/fast-ui-react 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -0
- package/LICENSE +21 -0
- package/README.md +180 -3
- package/dist/_virtual/_rolldown/runtime.js +12 -0
- package/dist/charts.d.ts +7 -0
- package/dist/charts.js +7 -0
- package/dist/components/Avatar/Avatar.d.ts +12 -0
- package/dist/components/Avatar/Avatar.js +92 -0
- package/dist/components/Button/Button.d.ts +44 -0
- package/dist/components/Button/Button.js +221 -0
- package/dist/components/Checkbox/CheckboxBox.d.ts +33 -0
- package/dist/components/Checkbox/CheckboxBox.js +148 -0
- package/dist/components/CodeSnippet/CodeSnippet.d.ts +26 -0
- package/dist/components/CodeSnippet/CodeSnippet.js +153 -0
- package/dist/components/Collapsible/Collapsible.d.ts +20 -0
- package/dist/components/Collapsible/Collapsible.js +97 -0
- package/dist/components/Container/Container.d.ts +301 -0
- package/dist/components/Container/Container.js +20 -0
- package/dist/components/FloatingActionButton/FloatingActionButton.d.ts +22 -0
- package/dist/components/FloatingActionButton/FloatingActionButton.js +141 -0
- package/dist/components/Grid/Grid.d.ts +311 -0
- package/dist/components/Grid/Grid.js +30 -0
- package/dist/components/IconTile/IconTile.d.ts +12 -0
- package/dist/components/IconTile/IconTile.js +70 -0
- package/dist/components/InlineError/InlineError.d.ts +9 -0
- package/dist/components/InlineError/InlineError.js +62 -0
- package/dist/components/Kbd/Kbd.d.ts +11 -0
- package/dist/components/Kbd/Kbd.js +31 -0
- package/dist/components/Link/Link.d.ts +18 -0
- package/dist/components/Link/Link.js +68 -0
- package/dist/components/Menu/ContextMenu.d.ts +18 -0
- package/dist/components/Menu/ContextMenu.js +68 -0
- package/dist/components/Menu/Menu.d.ts +86 -0
- package/dist/components/Menu/Menu.js +394 -0
- package/dist/components/OtpInput/OtpInput.d.ts +32 -0
- package/dist/components/OtpInput/OtpInput.js +177 -0
- package/dist/components/Popover/HoverPopover.d.ts +22 -0
- package/dist/components/Popover/HoverPopover.js +74 -0
- package/dist/components/Popover/Popover.d.ts +21 -0
- package/dist/components/Popover/Popover.js +64 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +17 -0
- package/dist/components/ProgressBar/ProgressBar.js +44 -0
- package/dist/components/Rating/Rating.d.ts +49 -0
- package/dist/components/Rating/Rating.js +241 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts +23 -0
- package/dist/components/ScrollArea/ScrollArea.js +90 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +29 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +99 -0
- package/dist/components/Separator/Separator.d.ts +9 -0
- package/dist/components/Separator/Separator.js +34 -0
- package/dist/components/Skeleton/Skeleton.d.ts +31 -0
- package/dist/components/Skeleton/Skeleton.js +152 -0
- package/dist/components/Slider/Slider.d.ts +54 -0
- package/dist/components/Slider/Slider.js +178 -0
- package/dist/components/Spinner/Spinner.d.ts +17 -0
- package/dist/components/Spinner/Spinner.js +118 -0
- package/dist/components/Stack/Stack.d.ts +302 -0
- package/dist/components/Stack/Stack.js +14 -0
- package/dist/components/StateIcon/StateIcon.d.ts +11 -0
- package/dist/components/StateIcon/StateIcon.js +65 -0
- package/dist/components/StatusBadge/StatusBadge.d.ts +19 -0
- package/dist/components/StatusBadge/StatusBadge.js +82 -0
- package/dist/components/Tabs/Tabs.d.ts +28 -0
- package/dist/components/Tabs/Tabs.js +109 -0
- package/dist/components/Tag/Tag.d.ts +11 -0
- package/dist/components/Tag/Tag.js +66 -0
- package/dist/components/Toast/AppToaster.d.ts +8 -0
- package/dist/components/Toast/AppToaster.js +135 -0
- package/dist/components/Toast/toast-manager.d.ts +28 -0
- package/dist/components/Toast/toast-manager.js +47 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +26 -0
- package/dist/components/ToggleButton/ToggleButton.js +106 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +32 -0
- package/dist/components/ToggleGroup/ToggleGroup.js +79 -0
- package/dist/components/Tooltip/Tooltip.d.ts +16 -0
- package/dist/components/Tooltip/Tooltip.js +58 -0
- package/dist/components/Tooltip/TooltipGroup.d.ts +22 -0
- package/dist/components/Tooltip/TooltipGroup.js +65 -0
- package/dist/components/Typography/Typography.d.ts +17 -0
- package/dist/components/Typography/Typography.js +100 -0
- package/dist/editor-forms.d.ts +1 -0
- package/dist/editor-forms.js +1 -0
- package/dist/editor.d.ts +1 -0
- package/dist/editor.js +1 -0
- package/dist/fonts/LICENSE +93 -0
- package/dist/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
- package/dist/fonts.css +69 -0
- package/dist/forms.d.ts +22 -0
- package/dist/forms.js +23 -0
- package/dist/foundation.css +23 -0
- package/dist/global.css +116 -0
- package/dist/hooks/useAppToast.d.ts +12 -0
- package/dist/hooks/useAppToast.js +29 -0
- package/dist/icons/icons.d.ts +43 -0
- package/dist/icons/icons.js +44 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.js +101 -0
- package/dist/patterns/Accordion/Accordion.d.ts +35 -0
- package/dist/patterns/Accordion/Accordion.js +139 -0
- package/dist/patterns/Alert/Alert.d.ts +38 -0
- package/dist/patterns/Alert/Alert.js +151 -0
- package/dist/patterns/AppShell/AppShell.d.ts +39 -0
- package/dist/patterns/AppShell/AppShell.js +218 -0
- package/dist/patterns/Breadcrumbs/Breadcrumbs.d.ts +21 -0
- package/dist/patterns/Breadcrumbs/Breadcrumbs.js +73 -0
- package/dist/patterns/Calendar/Calendar.d.ts +59 -0
- package/dist/patterns/Calendar/Calendar.js +283 -0
- package/dist/patterns/Calendar/DateRangePicker.d.ts +53 -0
- package/dist/patterns/Calendar/DateRangePicker.js +266 -0
- package/dist/patterns/Calendar/FormDateRangeField.d.ts +24 -0
- package/dist/patterns/Calendar/FormDateRangeField.js +138 -0
- package/dist/patterns/Card/Card.d.ts +26 -0
- package/dist/patterns/Card/Card.js +125 -0
- package/dist/patterns/Carousel/Carousel.d.ts +33 -0
- package/dist/patterns/Carousel/Carousel.js +127 -0
- package/dist/patterns/Cascader/Cascader.d.ts +53 -0
- package/dist/patterns/Cascader/Cascader.js +371 -0
- package/dist/patterns/Cascader/FormCascaderField.d.ts +21 -0
- package/dist/patterns/Cascader/FormCascaderField.js +130 -0
- package/dist/patterns/Charts/AreaChart.d.ts +13 -0
- package/dist/patterns/Charts/AreaChart.js +220 -0
- package/dist/patterns/Charts/BarChart.d.ts +11 -0
- package/dist/patterns/Charts/BarChart.js +220 -0
- package/dist/patterns/Charts/DonutChart.d.ts +37 -0
- package/dist/patterns/Charts/DonutChart.js +215 -0
- package/dist/patterns/Charts/GaugeChart.d.ts +44 -0
- package/dist/patterns/Charts/GaugeChart.js +210 -0
- package/dist/patterns/Charts/LineChart.d.ts +14 -0
- package/dist/patterns/Charts/LineChart.js +222 -0
- package/dist/patterns/Charts/Sparkline.d.ts +24 -0
- package/dist/patterns/Charts/Sparkline.js +81 -0
- package/dist/patterns/Charts/chart-parts.d.ts +139 -0
- package/dist/patterns/Charts/chart-parts.js +385 -0
- package/dist/patterns/Charts/gauge-math.d.ts +20 -0
- package/dist/patterns/Charts/gauge-math.js +21 -0
- package/dist/patterns/Charts/sparkline-path.d.ts +11 -0
- package/dist/patterns/Charts/sparkline-path.js +24 -0
- package/dist/patterns/ColorPicker/ColorPicker.d.ts +50 -0
- package/dist/patterns/ColorPicker/ColorPicker.js +590 -0
- package/dist/patterns/ColorPicker/FormColorField.d.ts +21 -0
- package/dist/patterns/ColorPicker/FormColorField.js +130 -0
- package/dist/patterns/ColorPicker/color-value.d.ts +19 -0
- package/dist/patterns/ColorPicker/color-value.js +72 -0
- package/dist/patterns/Combobox/Autocomplete.d.ts +48 -0
- package/dist/patterns/Combobox/Autocomplete.js +158 -0
- package/dist/patterns/Combobox/Combobox.d.ts +52 -0
- package/dist/patterns/Combobox/Combobox.js +195 -0
- package/dist/patterns/Combobox/ComboboxPopup.d.ts +24 -0
- package/dist/patterns/Combobox/ComboboxPopup.js +107 -0
- package/dist/patterns/Combobox/FormAutocompleteField.d.ts +17 -0
- package/dist/patterns/Combobox/FormAutocompleteField.js +119 -0
- package/dist/patterns/Combobox/FormComboboxField.d.ts +18 -0
- package/dist/patterns/Combobox/FormComboboxField.js +119 -0
- package/dist/patterns/Combobox/FormMultiSelectField.d.ts +18 -0
- package/dist/patterns/Combobox/FormMultiSelectField.js +119 -0
- package/dist/patterns/Combobox/MultiSelect.d.ts +54 -0
- package/dist/patterns/Combobox/MultiSelect.js +175 -0
- package/dist/patterns/CommandPalette/CommandPalette.d.ts +50 -0
- package/dist/patterns/CommandPalette/CommandPalette.js +193 -0
- package/dist/patterns/DataTable/DataTable.d.ts +107 -0
- package/dist/patterns/DataTable/DataTable.js +364 -0
- package/dist/patterns/DateTimePicker/DateTimePanel.d.ts +28 -0
- package/dist/patterns/DateTimePicker/DateTimePanel.js +444 -0
- package/dist/patterns/DateTimePicker/DateTimePicker.d.ts +75 -0
- package/dist/patterns/DateTimePicker/DateTimePicker.js +271 -0
- package/dist/patterns/DateTimePicker/FormDateTimeField.d.ts +32 -0
- package/dist/patterns/DateTimePicker/FormDateTimeField.js +148 -0
- package/dist/patterns/DateTimePicker/TimeSliders.d.ts +14 -0
- package/dist/patterns/DateTimePicker/TimeSliders.js +206 -0
- package/dist/patterns/DateTimePicker/picker-labels.d.ts +30 -0
- package/dist/patterns/DateTimePicker/picker-labels.js +23 -0
- package/dist/patterns/DateTimePicker/picker-values.d.ts +98 -0
- package/dist/patterns/DateTimePicker/picker-values.js +194 -0
- package/dist/patterns/DescriptionList/DescriptionList.d.ts +20 -0
- package/dist/patterns/DescriptionList/DescriptionList.js +57 -0
- package/dist/patterns/Dialog/Dialog.d.ts +26 -0
- package/dist/patterns/Dialog/Dialog.js +212 -0
- package/dist/patterns/Drawer/Drawer.d.ts +33 -0
- package/dist/patterns/Drawer/Drawer.js +153 -0
- package/dist/patterns/EmptyState/EmptyState.d.ts +35 -0
- package/dist/patterns/EmptyState/EmptyState.js +44 -0
- package/dist/patterns/FileUpload/FileUpload.d.ts +87 -0
- package/dist/patterns/FileUpload/FileUpload.js +417 -0
- package/dist/patterns/FileUpload/FormFileUploadField.d.ts +19 -0
- package/dist/patterns/FileUpload/FormFileUploadField.js +117 -0
- package/dist/patterns/FileUpload/add-files.d.ts +26 -0
- package/dist/patterns/FileUpload/add-files.js +35 -0
- package/dist/patterns/FileUpload/file-size.d.ts +14 -0
- package/dist/patterns/FileUpload/file-size.js +44 -0
- package/dist/patterns/FormField/CheckboxField.d.ts +26 -0
- package/dist/patterns/FormField/CheckboxField.js +97 -0
- package/dist/patterns/FormField/FieldFrame.d.ts +85 -0
- package/dist/patterns/FormField/FieldFrame.js +257 -0
- package/dist/patterns/FormField/FormCheckboxField.d.ts +17 -0
- package/dist/patterns/FormField/FormCheckboxField.js +92 -0
- package/dist/patterns/FormField/FormRadioGroupField.d.ts +16 -0
- package/dist/patterns/FormField/FormRadioGroupField.js +97 -0
- package/dist/patterns/FormField/FormRatingField.d.ts +19 -0
- package/dist/patterns/FormField/FormRatingField.js +119 -0
- package/dist/patterns/FormField/FormSelectField.d.ts +16 -0
- package/dist/patterns/FormField/FormSelectField.js +91 -0
- package/dist/patterns/FormField/FormSliderField.d.ts +22 -0
- package/dist/patterns/FormField/FormSliderField.js +128 -0
- package/dist/patterns/FormField/FormSwitchField.d.ts +19 -0
- package/dist/patterns/FormField/FormSwitchField.js +88 -0
- package/dist/patterns/FormField/FormTextAreaField.d.ts +12 -0
- package/dist/patterns/FormField/FormTextAreaField.js +91 -0
- package/dist/patterns/FormField/FormTextField.d.ts +23 -0
- package/dist/patterns/FormField/FormTextField.js +103 -0
- package/dist/patterns/FormField/RadioGroupField.d.ts +38 -0
- package/dist/patterns/FormField/RadioGroupField.js +201 -0
- package/dist/patterns/FormField/SelectField.d.ts +43 -0
- package/dist/patterns/FormField/SelectField.js +211 -0
- package/dist/patterns/FormField/SwitchField.d.ts +27 -0
- package/dist/patterns/FormField/SwitchField.js +105 -0
- package/dist/patterns/FormField/TextAreaField.d.ts +37 -0
- package/dist/patterns/FormField/TextAreaField.js +134 -0
- package/dist/patterns/FormField/TextField.d.ts +51 -0
- package/dist/patterns/FormField/TextField.js +256 -0
- package/dist/patterns/FormField/error-message.d.ts +6 -0
- package/dist/patterns/FormField/error-message.js +8 -0
- package/dist/patterns/FormField/field-styles.d.ts +44 -0
- package/dist/patterns/FormField/field-styles.js +89 -0
- package/dist/patterns/FormField/field-types.d.ts +4 -0
- package/dist/patterns/FormField/use-field-ids.d.ts +18 -0
- package/dist/patterns/FormField/use-field-ids.js +53 -0
- package/dist/patterns/List/List.d.ts +38 -0
- package/dist/patterns/List/List.js +174 -0
- package/dist/patterns/MentionsInput/FormMentionsField.d.ts +18 -0
- package/dist/patterns/MentionsInput/FormMentionsField.js +124 -0
- package/dist/patterns/MentionsInput/MentionsInput.d.ts +57 -0
- package/dist/patterns/MentionsInput/MentionsInput.js +133 -0
- package/dist/patterns/MentionsInput/mention-text.d.ts +24 -0
- package/dist/patterns/MentionsInput/mention-text.js +31 -0
- package/dist/patterns/Menubar/Menubar.d.ts +22 -0
- package/dist/patterns/Menubar/Menubar.js +79 -0
- package/dist/patterns/NavigationMenu/NavigationMenu.d.ts +27 -0
- package/dist/patterns/NavigationMenu/NavigationMenu.js +104 -0
- package/dist/patterns/NumberField/FormNumberField.d.ts +18 -0
- package/dist/patterns/NumberField/FormNumberField.js +119 -0
- package/dist/patterns/NumberField/NumberField.d.ts +57 -0
- package/dist/patterns/NumberField/NumberField.js +242 -0
- package/dist/patterns/Pagination/Pagination.d.ts +31 -0
- package/dist/patterns/Pagination/Pagination.js +275 -0
- package/dist/patterns/Pagination/page-items.d.ts +18 -0
- package/dist/patterns/Pagination/page-items.js +40 -0
- package/dist/patterns/PhoneField/FormPhoneField.d.ts +22 -0
- package/dist/patterns/PhoneField/FormPhoneField.js +97 -0
- package/dist/patterns/PhoneField/PhoneField.d.ts +60 -0
- package/dist/patterns/PhoneField/PhoneField.js +448 -0
- package/dist/patterns/PhoneField/phone-value.d.ts +26 -0
- package/dist/patterns/PhoneField/phone-value.js +38 -0
- package/dist/patterns/QRCode/QRCode.d.ts +37 -0
- package/dist/patterns/QRCode/QRCode.js +120 -0
- package/dist/patterns/QRCode/qr-path.d.ts +7 -0
- package/dist/patterns/QRCode/qr-path.js +25 -0
- package/dist/patterns/ResizablePanels/ResizablePanels.d.ts +34 -0
- package/dist/patterns/ResizablePanels/ResizablePanels.js +175 -0
- package/dist/patterns/ResizablePanels/panel-sizes.d.ts +31 -0
- package/dist/patterns/ResizablePanels/panel-sizes.js +54 -0
- package/dist/patterns/RichTextEditor/FormRichTextField.d.ts +18 -0
- package/dist/patterns/RichTextEditor/FormRichTextField.js +118 -0
- package/dist/patterns/RichTextEditor/RichTextEditor.d.ts +71 -0
- package/dist/patterns/RichTextEditor/RichTextEditor.js +453 -0
- package/dist/patterns/SearchInput/SearchInput.d.ts +26 -0
- package/dist/patterns/SearchInput/SearchInput.js +98 -0
- package/dist/patterns/SideNav/SideNav.d.ts +50 -0
- package/dist/patterns/SideNav/SideNav.js +269 -0
- package/dist/patterns/Stat/Stat.d.ts +51 -0
- package/dist/patterns/Stat/Stat.js +292 -0
- package/dist/patterns/Stepper/Stepper.d.ts +35 -0
- package/dist/patterns/Stepper/Stepper.js +110 -0
- package/dist/patterns/TagGroup/TagGroup.d.ts +44 -0
- package/dist/patterns/TagGroup/TagGroup.js +151 -0
- package/dist/patterns/TagsInput/FormTagsInputField.d.ts +18 -0
- package/dist/patterns/TagsInput/FormTagsInputField.js +124 -0
- package/dist/patterns/TagsInput/TagsInput.d.ts +51 -0
- package/dist/patterns/TagsInput/TagsInput.js +97 -0
- package/dist/patterns/Timeline/Timeline.d.ts +29 -0
- package/dist/patterns/Timeline/Timeline.js +85 -0
- package/dist/patterns/Toolbar/Toolbar.d.ts +31 -0
- package/dist/patterns/Toolbar/Toolbar.js +105 -0
- package/dist/patterns/Tour/Tour.d.ts +38 -0
- package/dist/patterns/Tour/Tour.js +333 -0
- package/dist/patterns/TransferList/FormTransferListField.d.ts +19 -0
- package/dist/patterns/TransferList/FormTransferListField.js +117 -0
- package/dist/patterns/TransferList/TransferList.d.ts +53 -0
- package/dist/patterns/TransferList/TransferList.js +441 -0
- package/dist/patterns/TreeSelect/FormTreeSelectField.d.ts +28 -0
- package/dist/patterns/TreeSelect/FormTreeSelectField.js +88 -0
- package/dist/patterns/TreeSelect/TreeSelect.d.ts +49 -0
- package/dist/patterns/TreeSelect/TreeSelect.js +375 -0
- package/dist/patterns/TreeView/TreeView.d.ts +40 -0
- package/dist/patterns/TreeView/TreeView.js +296 -0
- package/dist/provider/DesignSystemProvider.d.ts +54 -0
- package/dist/provider/DesignSystemProvider.js +270 -0
- package/dist/provider/nonce.d.ts +7 -0
- package/dist/provider/nonce.js +13 -0
- package/dist/styles.css +2 -0
- package/dist/theme/chart-palette.d.ts +51 -0
- package/dist/theme/chart-palette.js +112 -0
- package/dist/theme/create-theme.d.ts +52 -0
- package/dist/theme/create-theme.js +75 -0
- package/dist/theme/style-element.d.ts +28 -0
- package/dist/theme/style-element.js +79 -0
- package/dist/theme/tenant-branding.d.ts +48 -0
- package/dist/theme/tenant-branding.js +65 -0
- package/dist/theme/theme-switch.d.ts +25 -0
- package/dist/theme/theme-switch.js +90 -0
- package/dist/theme/token-names.d.ts +3 -0
- package/dist/theme/token-names.js +166 -0
- package/dist/theme.css +241 -0
- package/dist/tokens.css +383 -0
- package/dist/types/direction.d.ts +4 -0
- package/dist/types/tone.d.ts +7 -0
- package/dist/utils/cn.d.ts +7 -0
- package/dist/utils/cn.js +50 -0
- package/dist/utils/first-field.d.ts +8 -0
- package/dist/utils/first-field.js +10 -0
- package/dist/utils/layout.d.ts +33 -0
- package/dist/utils/layout.js +30 -0
- package/dist/utils/popup.d.ts +12 -0
- package/dist/utils/popup.js +27 -0
- package/docs/accessibility.md +61 -0
- package/docs/advanced-components.md +38 -0
- package/docs/ai-assistants.md +44 -0
- package/docs/architecture.md +65 -0
- package/docs/browser-support.md +30 -0
- package/docs/charts.md +56 -0
- package/docs/components.md +2928 -0
- package/docs/conventions.md +19 -0
- package/docs/customization.md +79 -0
- package/docs/dates-files-data.md +48 -0
- package/docs/design-principles.md +50 -0
- package/docs/faq.md +68 -0
- package/docs/forms.md +114 -0
- package/docs/getting-started.md +64 -0
- package/docs/icons.md +48 -0
- package/docs/internationalization.md +64 -0
- package/docs/layout-and-navigation.md +51 -0
- package/docs/nextjs.md +69 -0
- package/docs/releasing.md +40 -0
- package/docs/testing.md +242 -0
- package/docs/theming.md +118 -0
- package/docs/typescript.md +62 -0
- package/llms-full.txt +4573 -0
- package/llms.txt +52 -0
- package/package.json +193 -6
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import { type RatingProps } from "../../components/Rating/Rating.js";
|
|
3
|
+
import type { FieldOrientation } from "./field-types.js";
|
|
4
|
+
export interface FormRatingFieldProps<TValues extends FieldValues> extends Omit<RatingProps, "name" | "value" | "onValueChange" | "readOnly" | "onBlur" | "invalid" | "inputRef" | "aria-label" | "aria-labelledby" | "aria-describedby" | "className"> {
|
|
5
|
+
control: Control<TValues>;
|
|
6
|
+
name: FieldPath<TValues>;
|
|
7
|
+
label: string;
|
|
8
|
+
hint?: string | undefined;
|
|
9
|
+
/** The label shows the asterisk and the group is announced as required. Validation is the form's (`rules`). */
|
|
10
|
+
required?: boolean | undefined;
|
|
11
|
+
/** Label above the control (default) or in a column beside it. */
|
|
12
|
+
orientation?: FieldOrientation | undefined;
|
|
13
|
+
/** react-hook-form validation rules, for forms that do not use a schema resolver. */
|
|
14
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
15
|
+
/** Turns a stored schema message (an i18n key) into display text. */
|
|
16
|
+
formatError?: ((message: string) => string) | undefined;
|
|
17
|
+
}
|
|
18
|
+
/** A Rating in a field, bound to a react-hook-form field holding a number from 0 (none) to the number of stars. */
|
|
19
|
+
export declare const FormRatingField: <TValues extends FieldValues>({ control, name, label, hint, required, orientation, rules, formatError, disabled, ...ratingProps }: FormRatingFieldProps<TValues>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Controller } from "react-hook-form";
|
|
4
|
+
import { Rating } from "../../components/Rating/Rating.js";
|
|
5
|
+
import { toErrorText } from "./error-message.js";
|
|
6
|
+
import { FieldFrame } from "./FieldFrame.js";
|
|
7
|
+
import { useFieldIds } from "./use-field-ids.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
// src/patterns/FormField/FormRatingField.tsx
|
|
10
|
+
/** A Rating in a field, bound to a react-hook-form field holding a number from 0 (none) to the number of stars. */
|
|
11
|
+
var FormRatingField = (t0) => {
|
|
12
|
+
const $ = c(29);
|
|
13
|
+
let control;
|
|
14
|
+
let formatError;
|
|
15
|
+
let hint;
|
|
16
|
+
let label;
|
|
17
|
+
let name;
|
|
18
|
+
let orientation;
|
|
19
|
+
let ratingProps;
|
|
20
|
+
let required;
|
|
21
|
+
let rules;
|
|
22
|
+
let t1;
|
|
23
|
+
if ($[0] !== t0) {
|
|
24
|
+
({control, name, label, hint, required, orientation, rules, formatError, disabled: t1, ...ratingProps} = t0);
|
|
25
|
+
$[0] = t0;
|
|
26
|
+
$[1] = control;
|
|
27
|
+
$[2] = formatError;
|
|
28
|
+
$[3] = hint;
|
|
29
|
+
$[4] = label;
|
|
30
|
+
$[5] = name;
|
|
31
|
+
$[6] = orientation;
|
|
32
|
+
$[7] = ratingProps;
|
|
33
|
+
$[8] = required;
|
|
34
|
+
$[9] = rules;
|
|
35
|
+
$[10] = t1;
|
|
36
|
+
} else {
|
|
37
|
+
control = $[1];
|
|
38
|
+
formatError = $[2];
|
|
39
|
+
hint = $[3];
|
|
40
|
+
label = $[4];
|
|
41
|
+
name = $[5];
|
|
42
|
+
orientation = $[6];
|
|
43
|
+
ratingProps = $[7];
|
|
44
|
+
required = $[8];
|
|
45
|
+
rules = $[9];
|
|
46
|
+
t1 = $[10];
|
|
47
|
+
}
|
|
48
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
49
|
+
const { labelId, messageIds, describe } = useFieldIds();
|
|
50
|
+
let t2;
|
|
51
|
+
if ($[11] !== rules) {
|
|
52
|
+
t2 = rules ? { rules } : {};
|
|
53
|
+
$[11] = rules;
|
|
54
|
+
$[12] = t2;
|
|
55
|
+
} else t2 = $[12];
|
|
56
|
+
let t3;
|
|
57
|
+
if ($[13] !== describe || $[14] !== disabled || $[15] !== formatError || $[16] !== hint || $[17] !== label || $[18] !== labelId || $[19] !== messageIds || $[20] !== orientation || $[21] !== ratingProps || $[22] !== required) {
|
|
58
|
+
t3 = (t4) => {
|
|
59
|
+
const { field, fieldState } = t4;
|
|
60
|
+
const errorMessage = toErrorText(fieldState.error?.message, formatError);
|
|
61
|
+
const describedBy = describe(errorMessage, hint);
|
|
62
|
+
return /* @__PURE__ */ jsx(FieldFrame, {
|
|
63
|
+
name: field.name,
|
|
64
|
+
label,
|
|
65
|
+
labelId,
|
|
66
|
+
triggerLabel: true,
|
|
67
|
+
messageIds,
|
|
68
|
+
disabled,
|
|
69
|
+
invalid: fieldState.invalid,
|
|
70
|
+
touched: fieldState.isTouched,
|
|
71
|
+
dirty: fieldState.isDirty,
|
|
72
|
+
...hint ? { hint } : {},
|
|
73
|
+
...required ? { required } : {},
|
|
74
|
+
...orientation ? { orientation } : {},
|
|
75
|
+
...errorMessage === void 0 ? {} : { errorMessage },
|
|
76
|
+
children: /* @__PURE__ */ jsx(Rating, {
|
|
77
|
+
...ratingProps,
|
|
78
|
+
inputRef: field.ref,
|
|
79
|
+
"aria-labelledby": labelId,
|
|
80
|
+
...describedBy ? { "aria-describedby": describedBy } : {},
|
|
81
|
+
name: field.name,
|
|
82
|
+
value: typeof field.value === "number" ? field.value : 0,
|
|
83
|
+
onValueChange: field.onChange,
|
|
84
|
+
onBlur: field.onBlur,
|
|
85
|
+
invalid: fieldState.invalid,
|
|
86
|
+
required,
|
|
87
|
+
disabled
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
$[13] = describe;
|
|
92
|
+
$[14] = disabled;
|
|
93
|
+
$[15] = formatError;
|
|
94
|
+
$[16] = hint;
|
|
95
|
+
$[17] = label;
|
|
96
|
+
$[18] = labelId;
|
|
97
|
+
$[19] = messageIds;
|
|
98
|
+
$[20] = orientation;
|
|
99
|
+
$[21] = ratingProps;
|
|
100
|
+
$[22] = required;
|
|
101
|
+
$[23] = t3;
|
|
102
|
+
} else t3 = $[23];
|
|
103
|
+
let t4;
|
|
104
|
+
if ($[24] !== control || $[25] !== name || $[26] !== t2 || $[27] !== t3) {
|
|
105
|
+
t4 = /* @__PURE__ */ jsx(Controller, {
|
|
106
|
+
control,
|
|
107
|
+
name,
|
|
108
|
+
...t2,
|
|
109
|
+
render: t3
|
|
110
|
+
});
|
|
111
|
+
$[24] = control;
|
|
112
|
+
$[25] = name;
|
|
113
|
+
$[26] = t2;
|
|
114
|
+
$[27] = t3;
|
|
115
|
+
$[28] = t4;
|
|
116
|
+
} else t4 = $[28];
|
|
117
|
+
return t4;
|
|
118
|
+
};
|
|
119
|
+
export { FormRatingField };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import { type SelectFieldProps } from "./SelectField.js";
|
|
3
|
+
export type { SelectOption } from "./SelectField.js";
|
|
4
|
+
export interface FormSelectFieldProps<TValues extends FieldValues> extends Omit<SelectFieldProps, "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 SelectField bound to react-hook-form. The field value is the selected option's `value` string. */
|
|
16
|
+
export declare const FormSelectField: <TValues extends FieldValues>({ control, name, rules, formatError, disabled, size, hideLabel, ...selectProps }: FormSelectFieldProps<TValues>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,91 @@
|
|
|
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 { SelectField } from "./SelectField.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// src/patterns/FormField/FormSelectField.tsx
|
|
8
|
+
/** A SelectField bound to react-hook-form. The field value is the selected option's `value` string. */
|
|
9
|
+
var FormSelectField = (t0) => {
|
|
10
|
+
const $ = c(22);
|
|
11
|
+
let control;
|
|
12
|
+
let formatError;
|
|
13
|
+
let name;
|
|
14
|
+
let rules;
|
|
15
|
+
let selectProps;
|
|
16
|
+
let t1;
|
|
17
|
+
let t2;
|
|
18
|
+
let t3;
|
|
19
|
+
if ($[0] !== t0) {
|
|
20
|
+
({control, name, rules, formatError, disabled: t1, size: t2, hideLabel: t3, ...selectProps} = t0);
|
|
21
|
+
$[0] = t0;
|
|
22
|
+
$[1] = control;
|
|
23
|
+
$[2] = formatError;
|
|
24
|
+
$[3] = name;
|
|
25
|
+
$[4] = rules;
|
|
26
|
+
$[5] = selectProps;
|
|
27
|
+
$[6] = t1;
|
|
28
|
+
$[7] = t2;
|
|
29
|
+
$[8] = t3;
|
|
30
|
+
} else {
|
|
31
|
+
control = $[1];
|
|
32
|
+
formatError = $[2];
|
|
33
|
+
name = $[3];
|
|
34
|
+
rules = $[4];
|
|
35
|
+
selectProps = $[5];
|
|
36
|
+
t1 = $[6];
|
|
37
|
+
t2 = $[7];
|
|
38
|
+
t3 = $[8];
|
|
39
|
+
}
|
|
40
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
41
|
+
const size = t2 === void 0 ? "medium" : t2;
|
|
42
|
+
const hideLabel = t3 === void 0 ? false : t3;
|
|
43
|
+
let t4;
|
|
44
|
+
if ($[9] !== rules) {
|
|
45
|
+
t4 = rules ? { rules } : {};
|
|
46
|
+
$[9] = rules;
|
|
47
|
+
$[10] = t4;
|
|
48
|
+
} else t4 = $[10];
|
|
49
|
+
let t5;
|
|
50
|
+
if ($[11] !== disabled || $[12] !== formatError || $[13] !== hideLabel || $[14] !== selectProps || $[15] !== size) {
|
|
51
|
+
t5 = (t6) => {
|
|
52
|
+
const { field, fieldState } = t6;
|
|
53
|
+
const errorMessage = toErrorText(fieldState.error?.message, formatError);
|
|
54
|
+
return /* @__PURE__ */ jsx(SelectField, {
|
|
55
|
+
...selectProps,
|
|
56
|
+
disabled,
|
|
57
|
+
size,
|
|
58
|
+
hideLabel,
|
|
59
|
+
name: field.name,
|
|
60
|
+
inputRef: field.ref,
|
|
61
|
+
value: typeof field.value === "string" ? field.value : "",
|
|
62
|
+
onValueChange: field.onChange,
|
|
63
|
+
onBlur: field.onBlur,
|
|
64
|
+
invalid: fieldState.invalid,
|
|
65
|
+
...errorMessage === void 0 ? {} : { errorMessage }
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
$[11] = disabled;
|
|
69
|
+
$[12] = formatError;
|
|
70
|
+
$[13] = hideLabel;
|
|
71
|
+
$[14] = selectProps;
|
|
72
|
+
$[15] = size;
|
|
73
|
+
$[16] = t5;
|
|
74
|
+
} else t5 = $[16];
|
|
75
|
+
let t6;
|
|
76
|
+
if ($[17] !== control || $[18] !== name || $[19] !== t4 || $[20] !== t5) {
|
|
77
|
+
t6 = /* @__PURE__ */ jsx(Controller, {
|
|
78
|
+
control,
|
|
79
|
+
name,
|
|
80
|
+
...t4,
|
|
81
|
+
render: t5
|
|
82
|
+
});
|
|
83
|
+
$[17] = control;
|
|
84
|
+
$[18] = name;
|
|
85
|
+
$[19] = t4;
|
|
86
|
+
$[20] = t5;
|
|
87
|
+
$[21] = t6;
|
|
88
|
+
} else t6 = $[21];
|
|
89
|
+
return t6;
|
|
90
|
+
};
|
|
91
|
+
export { FormSelectField };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import { type SliderProps } from "../../components/Slider/Slider.js";
|
|
3
|
+
import type { FieldOrientation } from "./field-types.js";
|
|
4
|
+
export interface FormSliderFieldProps<TValues extends FieldValues> extends Omit<SliderProps, "name" | "value" | "onValueChange" | "onValueCommitted" | "onBlur" | "invalid" | "id" | "aria-label" | "aria-labelledby" | "aria-describedby" | "className"> {
|
|
5
|
+
control: Control<TValues>;
|
|
6
|
+
name: FieldPath<TValues>;
|
|
7
|
+
label: string;
|
|
8
|
+
hint?: string | undefined;
|
|
9
|
+
/** Label above the control (default) or in a column beside it. */
|
|
10
|
+
orientation?: FieldOrientation | undefined;
|
|
11
|
+
/** Keep the label for assistive technology only. */
|
|
12
|
+
hideLabel?: boolean | undefined;
|
|
13
|
+
/** react-hook-form validation rules, for forms that do not use a schema resolver. */
|
|
14
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
15
|
+
/** Turns a stored schema message (an i18n key) into display text. */
|
|
16
|
+
formatError?: ((message: string) => string) | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A Slider in a field, bound to a react-hook-form field holding a number, or an array of numbers for a range
|
|
20
|
+
* (a thumb for each; name them with `thumbLabels`). A field with no value starts at `min`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const FormSliderField: <TValues extends FieldValues>({ control, name, label, hint, orientation, hideLabel, rules, formatError, disabled, min, ...sliderProps }: FormSliderFieldProps<TValues>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Controller } from "react-hook-form";
|
|
4
|
+
import { Slider } from "../../components/Slider/Slider.js";
|
|
5
|
+
import { toErrorText } from "./error-message.js";
|
|
6
|
+
import { FieldFrame } from "./FieldFrame.js";
|
|
7
|
+
import { useFieldIds } from "./use-field-ids.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
// src/patterns/FormField/FormSliderField.tsx
|
|
10
|
+
/**
|
|
11
|
+
* A Slider in a field, bound to a react-hook-form field holding a number, or an array of numbers for a range
|
|
12
|
+
* (a thumb for each; name them with `thumbLabels`). A field with no value starts at `min`.
|
|
13
|
+
*/
|
|
14
|
+
var FormSliderField = (t0) => {
|
|
15
|
+
const $ = c(31);
|
|
16
|
+
let control;
|
|
17
|
+
let formatError;
|
|
18
|
+
let hint;
|
|
19
|
+
let label;
|
|
20
|
+
let name;
|
|
21
|
+
let orientation;
|
|
22
|
+
let rules;
|
|
23
|
+
let sliderProps;
|
|
24
|
+
let t1;
|
|
25
|
+
let t2;
|
|
26
|
+
let t3;
|
|
27
|
+
if ($[0] !== t0) {
|
|
28
|
+
({control, name, label, hint, orientation, hideLabel: t1, rules, formatError, disabled: t2, min: t3, ...sliderProps} = t0);
|
|
29
|
+
$[0] = t0;
|
|
30
|
+
$[1] = control;
|
|
31
|
+
$[2] = formatError;
|
|
32
|
+
$[3] = hint;
|
|
33
|
+
$[4] = label;
|
|
34
|
+
$[5] = name;
|
|
35
|
+
$[6] = orientation;
|
|
36
|
+
$[7] = rules;
|
|
37
|
+
$[8] = sliderProps;
|
|
38
|
+
$[9] = t1;
|
|
39
|
+
$[10] = t2;
|
|
40
|
+
$[11] = t3;
|
|
41
|
+
} else {
|
|
42
|
+
control = $[1];
|
|
43
|
+
formatError = $[2];
|
|
44
|
+
hint = $[3];
|
|
45
|
+
label = $[4];
|
|
46
|
+
name = $[5];
|
|
47
|
+
orientation = $[6];
|
|
48
|
+
rules = $[7];
|
|
49
|
+
sliderProps = $[8];
|
|
50
|
+
t1 = $[9];
|
|
51
|
+
t2 = $[10];
|
|
52
|
+
t3 = $[11];
|
|
53
|
+
}
|
|
54
|
+
const hideLabel = t1 === void 0 ? false : t1;
|
|
55
|
+
const disabled = t2 === void 0 ? false : t2;
|
|
56
|
+
const min = t3 === void 0 ? 0 : t3;
|
|
57
|
+
const { labelId, messageIds, describe } = useFieldIds();
|
|
58
|
+
let t4;
|
|
59
|
+
if ($[12] !== rules) {
|
|
60
|
+
t4 = rules ? { rules } : {};
|
|
61
|
+
$[12] = rules;
|
|
62
|
+
$[13] = t4;
|
|
63
|
+
} else t4 = $[13];
|
|
64
|
+
let t5;
|
|
65
|
+
if ($[14] !== describe || $[15] !== disabled || $[16] !== formatError || $[17] !== hideLabel || $[18] !== hint || $[19] !== label || $[20] !== labelId || $[21] !== messageIds || $[22] !== min || $[23] !== orientation || $[24] !== sliderProps) {
|
|
66
|
+
t5 = (t6) => {
|
|
67
|
+
const { field, fieldState } = t6;
|
|
68
|
+
const errorMessage = toErrorText(fieldState.error?.message, formatError);
|
|
69
|
+
const describedBy = describe(errorMessage, hint);
|
|
70
|
+
const value = typeof field.value === "number" ? field.value : Array.isArray(field.value) ? field.value : min;
|
|
71
|
+
return /* @__PURE__ */ jsx(FieldFrame, {
|
|
72
|
+
name: field.name,
|
|
73
|
+
label,
|
|
74
|
+
hideLabel,
|
|
75
|
+
labelId,
|
|
76
|
+
triggerLabel: true,
|
|
77
|
+
messageIds,
|
|
78
|
+
disabled,
|
|
79
|
+
invalid: fieldState.invalid,
|
|
80
|
+
touched: fieldState.isTouched,
|
|
81
|
+
dirty: fieldState.isDirty,
|
|
82
|
+
...hint ? { hint } : {},
|
|
83
|
+
...orientation ? { orientation } : {},
|
|
84
|
+
...errorMessage === void 0 ? {} : { errorMessage },
|
|
85
|
+
children: /* @__PURE__ */ jsx(Slider, {
|
|
86
|
+
...sliderProps,
|
|
87
|
+
min,
|
|
88
|
+
"aria-labelledby": labelId,
|
|
89
|
+
...describedBy ? { "aria-describedby": describedBy } : {},
|
|
90
|
+
name: field.name,
|
|
91
|
+
value,
|
|
92
|
+
onValueChange: field.onChange,
|
|
93
|
+
onBlur: field.onBlur,
|
|
94
|
+
invalid: fieldState.invalid,
|
|
95
|
+
disabled
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
$[14] = describe;
|
|
100
|
+
$[15] = disabled;
|
|
101
|
+
$[16] = formatError;
|
|
102
|
+
$[17] = hideLabel;
|
|
103
|
+
$[18] = hint;
|
|
104
|
+
$[19] = label;
|
|
105
|
+
$[20] = labelId;
|
|
106
|
+
$[21] = messageIds;
|
|
107
|
+
$[22] = min;
|
|
108
|
+
$[23] = orientation;
|
|
109
|
+
$[24] = sliderProps;
|
|
110
|
+
$[25] = t5;
|
|
111
|
+
} else t5 = $[25];
|
|
112
|
+
let t6;
|
|
113
|
+
if ($[26] !== control || $[27] !== name || $[28] !== t4 || $[29] !== t5) {
|
|
114
|
+
t6 = /* @__PURE__ */ jsx(Controller, {
|
|
115
|
+
control,
|
|
116
|
+
name,
|
|
117
|
+
...t4,
|
|
118
|
+
render: t5
|
|
119
|
+
});
|
|
120
|
+
$[26] = control;
|
|
121
|
+
$[27] = name;
|
|
122
|
+
$[28] = t4;
|
|
123
|
+
$[29] = t5;
|
|
124
|
+
$[30] = t6;
|
|
125
|
+
} else t6 = $[30];
|
|
126
|
+
return t6;
|
|
127
|
+
};
|
|
128
|
+
export { FormSliderField };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import { type SwitchFieldProps } from "./SwitchField.js";
|
|
3
|
+
export interface FormSwitchFieldProps<TValues extends FieldValues> extends Omit<SwitchFieldProps, "name" | "checked" | "onCheckedChange" | "onBlur" | "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. `{ validate: ... }`). A
|
|
8
|
+
* switch shows no message: a rule that fails marks the switch invalid for assistive technology only, so say why
|
|
9
|
+
* near it.
|
|
10
|
+
*/
|
|
11
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
12
|
+
/** Called after the value changes, e.g. to clear the fields the switch controls. */
|
|
13
|
+
onCheckedChange?: ((checked: boolean) => void) | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A SwitchField bound to a boolean react-hook-form field. With its label it is a
|
|
17
|
+
* settings row: the label at the start, the switch at the far end.
|
|
18
|
+
*/
|
|
19
|
+
export declare const FormSwitchField: <TValues extends FieldValues>({ control, name, rules, onCheckedChange, hideLabel, disabled, ...switchProps }: FormSwitchFieldProps<TValues>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Controller } from "react-hook-form";
|
|
4
|
+
import { SwitchField } from "./SwitchField.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/patterns/FormField/FormSwitchField.tsx
|
|
7
|
+
/**
|
|
8
|
+
* A SwitchField bound to a boolean react-hook-form field. With its label it is a
|
|
9
|
+
* settings row: the label at the start, the switch at the far end.
|
|
10
|
+
*/
|
|
11
|
+
var FormSwitchField = (t0) => {
|
|
12
|
+
const $ = c(20);
|
|
13
|
+
let control;
|
|
14
|
+
let name;
|
|
15
|
+
let onCheckedChange;
|
|
16
|
+
let rules;
|
|
17
|
+
let switchProps;
|
|
18
|
+
let t1;
|
|
19
|
+
let t2;
|
|
20
|
+
if ($[0] !== t0) {
|
|
21
|
+
({control, name, rules, onCheckedChange, hideLabel: t1, disabled: t2, ...switchProps} = t0);
|
|
22
|
+
$[0] = t0;
|
|
23
|
+
$[1] = control;
|
|
24
|
+
$[2] = name;
|
|
25
|
+
$[3] = onCheckedChange;
|
|
26
|
+
$[4] = rules;
|
|
27
|
+
$[5] = switchProps;
|
|
28
|
+
$[6] = t1;
|
|
29
|
+
$[7] = t2;
|
|
30
|
+
} else {
|
|
31
|
+
control = $[1];
|
|
32
|
+
name = $[2];
|
|
33
|
+
onCheckedChange = $[3];
|
|
34
|
+
rules = $[4];
|
|
35
|
+
switchProps = $[5];
|
|
36
|
+
t1 = $[6];
|
|
37
|
+
t2 = $[7];
|
|
38
|
+
}
|
|
39
|
+
const hideLabel = t1 === void 0 ? false : t1;
|
|
40
|
+
const disabled = t2 === void 0 ? false : t2;
|
|
41
|
+
let t3;
|
|
42
|
+
if ($[8] !== rules) {
|
|
43
|
+
t3 = rules ? { rules } : {};
|
|
44
|
+
$[8] = rules;
|
|
45
|
+
$[9] = t3;
|
|
46
|
+
} else t3 = $[9];
|
|
47
|
+
let t4;
|
|
48
|
+
if ($[10] !== disabled || $[11] !== hideLabel || $[12] !== onCheckedChange || $[13] !== switchProps) {
|
|
49
|
+
t4 = (t5) => {
|
|
50
|
+
const { field, fieldState } = t5;
|
|
51
|
+
return /* @__PURE__ */ jsx(SwitchField, {
|
|
52
|
+
...switchProps,
|
|
53
|
+
hideLabel,
|
|
54
|
+
disabled,
|
|
55
|
+
name: field.name,
|
|
56
|
+
inputRef: field.ref,
|
|
57
|
+
checked: field.value === true,
|
|
58
|
+
onCheckedChange: (checked) => {
|
|
59
|
+
field.onChange(checked);
|
|
60
|
+
onCheckedChange?.(checked);
|
|
61
|
+
},
|
|
62
|
+
onBlur: field.onBlur,
|
|
63
|
+
invalid: fieldState.invalid
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
$[10] = disabled;
|
|
67
|
+
$[11] = hideLabel;
|
|
68
|
+
$[12] = onCheckedChange;
|
|
69
|
+
$[13] = switchProps;
|
|
70
|
+
$[14] = t4;
|
|
71
|
+
} else t4 = $[14];
|
|
72
|
+
let t5;
|
|
73
|
+
if ($[15] !== control || $[16] !== name || $[17] !== t3 || $[18] !== t4) {
|
|
74
|
+
t5 = /* @__PURE__ */ jsx(Controller, {
|
|
75
|
+
control,
|
|
76
|
+
name,
|
|
77
|
+
...t3,
|
|
78
|
+
render: t4
|
|
79
|
+
});
|
|
80
|
+
$[15] = control;
|
|
81
|
+
$[16] = name;
|
|
82
|
+
$[17] = t3;
|
|
83
|
+
$[18] = t4;
|
|
84
|
+
$[19] = t5;
|
|
85
|
+
} else t5 = $[19];
|
|
86
|
+
return t5;
|
|
87
|
+
};
|
|
88
|
+
export { FormSwitchField };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import { type TextAreaFieldProps } from "./TextAreaField.js";
|
|
3
|
+
export interface FormTextAreaFieldProps<TValues extends FieldValues> extends Omit<TextAreaFieldProps, "name" | "value" | "onValueChange" | "onBlur" | "errorMessage" | "invalid" | "inputRef"> {
|
|
4
|
+
control: Control<TValues>;
|
|
5
|
+
name: FieldPath<TValues>;
|
|
6
|
+
/** react-hook-form validation rules, for forms that do not use a schema resolver. */
|
|
7
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
8
|
+
/** Turns a stored schema message (an i18n key) into display text. */
|
|
9
|
+
formatError?: ((message: string) => string) | undefined;
|
|
10
|
+
}
|
|
11
|
+
/** A TextAreaField bound to react-hook-form, with consistent error display. */
|
|
12
|
+
export declare const FormTextAreaField: <TValues extends FieldValues>({ control, name, rules, formatError, disabled, size, resize, ...textAreaProps }: FormTextAreaFieldProps<TValues>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,91 @@
|
|
|
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 { TextAreaField } from "./TextAreaField.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// src/patterns/FormField/FormTextAreaField.tsx
|
|
8
|
+
/** A TextAreaField bound to react-hook-form, with consistent error display. */
|
|
9
|
+
var FormTextAreaField = (t0) => {
|
|
10
|
+
const $ = c(22);
|
|
11
|
+
let control;
|
|
12
|
+
let formatError;
|
|
13
|
+
let name;
|
|
14
|
+
let rules;
|
|
15
|
+
let t1;
|
|
16
|
+
let t2;
|
|
17
|
+
let t3;
|
|
18
|
+
let textAreaProps;
|
|
19
|
+
if ($[0] !== t0) {
|
|
20
|
+
({control, name, rules, formatError, disabled: t1, size: t2, resize: t3, ...textAreaProps} = t0);
|
|
21
|
+
$[0] = t0;
|
|
22
|
+
$[1] = control;
|
|
23
|
+
$[2] = formatError;
|
|
24
|
+
$[3] = name;
|
|
25
|
+
$[4] = rules;
|
|
26
|
+
$[5] = t1;
|
|
27
|
+
$[6] = t2;
|
|
28
|
+
$[7] = t3;
|
|
29
|
+
$[8] = textAreaProps;
|
|
30
|
+
} else {
|
|
31
|
+
control = $[1];
|
|
32
|
+
formatError = $[2];
|
|
33
|
+
name = $[3];
|
|
34
|
+
rules = $[4];
|
|
35
|
+
t1 = $[5];
|
|
36
|
+
t2 = $[6];
|
|
37
|
+
t3 = $[7];
|
|
38
|
+
textAreaProps = $[8];
|
|
39
|
+
}
|
|
40
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
41
|
+
const size = t2 === void 0 ? "medium" : t2;
|
|
42
|
+
const resize = t3 === void 0 ? "vertical" : t3;
|
|
43
|
+
let t4;
|
|
44
|
+
if ($[9] !== rules) {
|
|
45
|
+
t4 = rules ? { rules } : {};
|
|
46
|
+
$[9] = rules;
|
|
47
|
+
$[10] = t4;
|
|
48
|
+
} else t4 = $[10];
|
|
49
|
+
let t5;
|
|
50
|
+
if ($[11] !== disabled || $[12] !== formatError || $[13] !== resize || $[14] !== size || $[15] !== textAreaProps) {
|
|
51
|
+
t5 = (t6) => {
|
|
52
|
+
const { field, fieldState } = t6;
|
|
53
|
+
const errorMessage = toErrorText(fieldState.error?.message, formatError);
|
|
54
|
+
return /* @__PURE__ */ jsx(TextAreaField, {
|
|
55
|
+
...textAreaProps,
|
|
56
|
+
disabled,
|
|
57
|
+
size,
|
|
58
|
+
resize,
|
|
59
|
+
name: field.name,
|
|
60
|
+
inputRef: field.ref,
|
|
61
|
+
value: field.value == null ? "" : String(field.value),
|
|
62
|
+
onValueChange: field.onChange,
|
|
63
|
+
onBlur: field.onBlur,
|
|
64
|
+
invalid: fieldState.invalid,
|
|
65
|
+
...errorMessage === void 0 ? {} : { errorMessage }
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
$[11] = disabled;
|
|
69
|
+
$[12] = formatError;
|
|
70
|
+
$[13] = resize;
|
|
71
|
+
$[14] = size;
|
|
72
|
+
$[15] = textAreaProps;
|
|
73
|
+
$[16] = t5;
|
|
74
|
+
} else t5 = $[16];
|
|
75
|
+
let t6;
|
|
76
|
+
if ($[17] !== control || $[18] !== name || $[19] !== t4 || $[20] !== t5) {
|
|
77
|
+
t6 = /* @__PURE__ */ jsx(Controller, {
|
|
78
|
+
control,
|
|
79
|
+
name,
|
|
80
|
+
...t4,
|
|
81
|
+
render: t5
|
|
82
|
+
});
|
|
83
|
+
$[17] = control;
|
|
84
|
+
$[18] = name;
|
|
85
|
+
$[19] = t4;
|
|
86
|
+
$[20] = t5;
|
|
87
|
+
$[21] = t6;
|
|
88
|
+
} else t6 = $[21];
|
|
89
|
+
return t6;
|
|
90
|
+
};
|
|
91
|
+
export { FormTextAreaField };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import { type TextFieldProps } from "./TextField.js";
|
|
3
|
+
export interface FormTextFieldProps<TValues extends FieldValues> extends Omit<TextFieldProps, "name" | "value" | "onValueChange" | "onBlur" | "errorMessage" | "invalid" | "inputRef"> {
|
|
4
|
+
control: Control<TValues>;
|
|
5
|
+
name: FieldPath<TValues>;
|
|
6
|
+
/**
|
|
7
|
+
* Shown in green, with a check, once the field has been left with a value
|
|
8
|
+
* that passes validation. For confirmations such as "Name is available".
|
|
9
|
+
*/
|
|
10
|
+
successMessage?: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* react-hook-form validation rules, for forms that do not use a schema
|
|
13
|
+
* resolver (e.g. `{ required: "namespace:key" }`).
|
|
14
|
+
*/
|
|
15
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Validation messages are i18n keys. This turns the stored message into
|
|
18
|
+
* display text; without it the message is shown as is.
|
|
19
|
+
*/
|
|
20
|
+
formatError?: ((message: string) => string) | undefined;
|
|
21
|
+
}
|
|
22
|
+
/** A TextField bound to react-hook-form, with consistent error display. */
|
|
23
|
+
export declare const FormTextField: <TValues extends FieldValues>({ control, name, rules, formatError, successMessage, hideLabel, size, type, disabled, ...textFieldProps }: FormTextFieldProps<TValues>) => import("react").JSX.Element;
|