@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,89 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
// src/patterns/FormField/field-styles.ts
|
|
3
|
+
/**
|
|
4
|
+
* The field shell. Vertical is one column; horizontal puts the label in a 260px
|
|
5
|
+
* column beside a 183px control, with the messages under the control. The
|
|
6
|
+
* `group/field` name lets the messages find their column. `content-start` keeps
|
|
7
|
+
* the rows at their own height when a taller neighbour stretches the field.
|
|
8
|
+
*/
|
|
9
|
+
var fieldRoot = cva("group/field grid min-w-0 content-start", {
|
|
10
|
+
variants: { orientation: {
|
|
11
|
+
vertical: "grid-cols-[minmax(0,1fr)]",
|
|
12
|
+
horizontal: "grid-cols-[260px_minmax(0,183px)] items-center"
|
|
13
|
+
} },
|
|
14
|
+
defaultVariants: { orientation: "vertical" }
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* The label of a field (or the legend of a group). It turns red when the field
|
|
18
|
+
* is invalid. Above the control it is Figma's field label: 13px medium ink, 7px
|
|
19
|
+
* above the box. Beside the control, in the 260px column of an Add/Edit form,
|
|
20
|
+
* it keeps the app's 14px regular label.
|
|
21
|
+
*/
|
|
22
|
+
var fieldLabel = cva("block data-invalid:text-error-text", {
|
|
23
|
+
variants: {
|
|
24
|
+
orientation: {
|
|
25
|
+
vertical: "text-body-sm font-medium text-fg",
|
|
26
|
+
horizontal: "text-body text-fg"
|
|
27
|
+
},
|
|
28
|
+
size: {
|
|
29
|
+
small: "",
|
|
30
|
+
medium: "",
|
|
31
|
+
large: ""
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
compoundVariants: [{
|
|
35
|
+
orientation: "vertical",
|
|
36
|
+
size: "small",
|
|
37
|
+
className: "mb-1.5"
|
|
38
|
+
}, {
|
|
39
|
+
orientation: "vertical",
|
|
40
|
+
size: ["medium", "large"],
|
|
41
|
+
className: "mb-1.75"
|
|
42
|
+
}],
|
|
43
|
+
defaultVariants: {
|
|
44
|
+
size: "medium",
|
|
45
|
+
orientation: "vertical"
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
/** The clickable label that wraps a checkbox, radio or switch and its text. */
|
|
49
|
+
var fieldChoice = "inline-flex cursor-pointer items-center gap-2.5 text-body-sm font-normal text-fg-body data-disabled:cursor-not-allowed data-disabled:text-fg-disabled";
|
|
50
|
+
/**
|
|
51
|
+
* The box around a text input, a text area or a select trigger. It is the box,
|
|
52
|
+
* not the inner input, that shows focus, error, success and disabled, so an
|
|
53
|
+
* input with an icon beside it is outlined as one. Figma: a 1px grey border on
|
|
54
|
+
* white; focused, a 3px teal ring at 12% (the border is `primary-active`, which
|
|
55
|
+
* holds 3:1 on white, where Figma's teal does not); invalid, the red border and a
|
|
56
|
+
* 3px red ring at 8%. Read-only and disabled boxes are the soft grey.
|
|
57
|
+
*/
|
|
58
|
+
var fieldControl = cva([
|
|
59
|
+
"box-border flex w-full min-w-0 items-center gap-2 border border-line bg-surface text-start font-normal text-fg outline-none",
|
|
60
|
+
"transition-[border-color,box-shadow] duration-150 ease-standard",
|
|
61
|
+
"focus-within:border-primary-active focus-within:ring-3 focus-within:ring-primary/12",
|
|
62
|
+
"has-[input[readonly]]:bg-subtle",
|
|
63
|
+
"data-success:border-success-solid data-success:ring-3 data-success:ring-success-solid/10",
|
|
64
|
+
"data-success:focus-within:border-success-solid data-success:focus-within:ring-success-solid/20",
|
|
65
|
+
"data-invalid:border-error-solid data-invalid:ring-3 data-invalid:ring-error-solid/8",
|
|
66
|
+
"data-invalid:focus-within:border-error-solid data-invalid:focus-within:ring-error-solid/20",
|
|
67
|
+
"data-disabled:cursor-not-allowed data-disabled:bg-subtle data-disabled:text-fg-secondary",
|
|
68
|
+
"[&>svg]:size-4.25 [&>svg]:text-fg-tertiary data-disabled:[&>svg]:text-fg-disabled"
|
|
69
|
+
], {
|
|
70
|
+
variants: { size: {
|
|
71
|
+
small: "min-h-8 rounded-md px-3 text-caption",
|
|
72
|
+
medium: "min-h-10.5 rounded-md px-3 text-body-sm",
|
|
73
|
+
large: "min-h-11.5 rounded-tile px-3 text-body-sm"
|
|
74
|
+
} },
|
|
75
|
+
defaultVariants: { size: "medium" }
|
|
76
|
+
});
|
|
77
|
+
/** The `<input>` inside a control box: no chrome of its own, it fills the box. */
|
|
78
|
+
var fieldInput = "m-0 min-w-0 flex-1 self-stretch appearance-none border-0 bg-transparent p-0 text-ellipsis outline-none placeholder:text-fg-tertiary disabled:cursor-not-allowed";
|
|
79
|
+
/**
|
|
80
|
+
* A removable value inside a field's box: a chosen option of a multi-select, a tag of a tags input. A grey pill
|
|
81
|
+
* with the text and, at the end, the button that removes it. A chip that has the keyboard focus (or is
|
|
82
|
+
* highlighted by the arrow keys) turns teal.
|
|
83
|
+
*/
|
|
84
|
+
var fieldChip = "box-border inline-flex max-w-full min-w-0 items-center gap-0.5 rounded-pill bg-subtle py-0.5 ps-2.5 pe-0.75 text-caption text-fg-body outline-none data-highlighted:bg-primary-light data-highlighted:text-primary-text focus-visible:ring-2 focus-visible:ring-focus data-disabled:text-fg-disabled";
|
|
85
|
+
/** The button at the end of a chip that removes it. */
|
|
86
|
+
var fieldChipRemove = "inline-flex size-4.5 shrink-0 cursor-pointer items-center justify-center rounded-full border-0 bg-transparent p-0 text-fg-secondary outline-none hover:bg-pressed hover:text-fg focus-visible:ring-2 focus-visible:ring-focus disabled:cursor-not-allowed [&_svg]:size-3";
|
|
87
|
+
/** The box of a field that holds chips and an input: it wraps onto more lines instead of scrolling. */
|
|
88
|
+
var fieldChipsBox = "h-auto flex-wrap gap-1.5 py-1.5 cursor-text";
|
|
89
|
+
export { fieldChip, fieldChipRemove, fieldChipsBox, fieldChoice, fieldControl, fieldInput, fieldLabel, fieldRoot };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** "small" is a compact 32px box, "medium" Figma's 42px field, "large" the 46px field of its dialogs. */
|
|
2
|
+
export type FieldSize = "small" | "medium" | "large";
|
|
3
|
+
/** Label above the control, or in a column beside it. */
|
|
4
|
+
export type FieldOrientation = "vertical" | "horizontal";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ids a form field wires between its label, its message and its hint, for a control that Base UI's Field does
|
|
3
|
+
* not describe by itself (a slider, a rating, a picker's button, an input of chips). Call it once in the field,
|
|
4
|
+
* outside the Controller's render function:
|
|
5
|
+
*
|
|
6
|
+
* - `labelId` goes to the control's `aria-labelledby` and to FieldFrame's `labelId`;
|
|
7
|
+
* - `messageIds` goes to FieldFrame's `messageIds`;
|
|
8
|
+
* - `describe(errorMessage, hint)` gives the control's `aria-describedby`: the message while there is one and the
|
|
9
|
+
* hint while there is one, or an empty string.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useFieldIds: () => {
|
|
12
|
+
labelId: string;
|
|
13
|
+
messageIds: {
|
|
14
|
+
error: string;
|
|
15
|
+
hint: string;
|
|
16
|
+
};
|
|
17
|
+
describe: (errorMessage: string | undefined, hint: string | undefined) => string;
|
|
18
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
// src/patterns/FormField/use-field-ids.ts
|
|
5
|
+
/**
|
|
6
|
+
* The ids a form field wires between its label, its message and its hint, for a control that Base UI's Field does
|
|
7
|
+
* not describe by itself (a slider, a rating, a picker's button, an input of chips). Call it once in the field,
|
|
8
|
+
* outside the Controller's render function:
|
|
9
|
+
*
|
|
10
|
+
* - `labelId` goes to the control's `aria-labelledby` and to FieldFrame's `labelId`;
|
|
11
|
+
* - `messageIds` goes to FieldFrame's `messageIds`;
|
|
12
|
+
* - `describe(errorMessage, hint)` gives the control's `aria-describedby`: the message while there is one and the
|
|
13
|
+
* hint while there is one, or an empty string.
|
|
14
|
+
*/
|
|
15
|
+
var useFieldIds = () => {
|
|
16
|
+
const $ = c(8);
|
|
17
|
+
const labelId = useId();
|
|
18
|
+
const errorId = useId();
|
|
19
|
+
const hintId = useId();
|
|
20
|
+
let t0;
|
|
21
|
+
let t1;
|
|
22
|
+
if ($[0] !== errorId || $[1] !== hintId) {
|
|
23
|
+
t0 = {
|
|
24
|
+
error: errorId,
|
|
25
|
+
hint: hintId
|
|
26
|
+
};
|
|
27
|
+
t1 = (errorMessage, hint) => [errorMessage === void 0 ? null : errorId, hint ? hintId : null].filter(_temp).join(" ");
|
|
28
|
+
$[0] = errorId;
|
|
29
|
+
$[1] = hintId;
|
|
30
|
+
$[2] = t0;
|
|
31
|
+
$[3] = t1;
|
|
32
|
+
} else {
|
|
33
|
+
t0 = $[2];
|
|
34
|
+
t1 = $[3];
|
|
35
|
+
}
|
|
36
|
+
let t2;
|
|
37
|
+
if ($[4] !== labelId || $[5] !== t0 || $[6] !== t1) {
|
|
38
|
+
t2 = {
|
|
39
|
+
labelId,
|
|
40
|
+
messageIds: t0,
|
|
41
|
+
describe: t1
|
|
42
|
+
};
|
|
43
|
+
$[4] = labelId;
|
|
44
|
+
$[5] = t0;
|
|
45
|
+
$[6] = t1;
|
|
46
|
+
$[7] = t2;
|
|
47
|
+
} else t2 = $[7];
|
|
48
|
+
return t2;
|
|
49
|
+
};
|
|
50
|
+
function _temp(id) {
|
|
51
|
+
return id !== null;
|
|
52
|
+
}
|
|
53
|
+
export { useFieldIds };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
export interface ListItem {
|
|
3
|
+
/** Identifies the row: `value` holds the `id`s of the chosen rows. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** The row's main text. */
|
|
6
|
+
primary: ReactNode;
|
|
7
|
+
/** A line under it, in smaller type. */
|
|
8
|
+
secondary?: ReactNode | undefined;
|
|
9
|
+
/** At the start of the row: an Avatar, an IconTile. */
|
|
10
|
+
leading?: ReactNode | undefined;
|
|
11
|
+
/** At the end of the row: a StatusBadge, a menu button. It sits outside the row's own link or choice, so it can be a button. */
|
|
12
|
+
trailing?: ReactNode | undefined;
|
|
13
|
+
/** Makes the row a link. */
|
|
14
|
+
href?: string | undefined;
|
|
15
|
+
/** The app's router link, `<RouterLink to="/orders/1" />`, to render in place of the plain `<a>`. */
|
|
16
|
+
render?: ReactElement | undefined;
|
|
17
|
+
disabled?: boolean | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface ListProps {
|
|
20
|
+
items: readonly ListItem[];
|
|
21
|
+
/** Whether rows can be chosen: none (default), one (a choice, like radio buttons), or several (like checkboxes). */
|
|
22
|
+
selection?: "none" | "single" | "multiple" | undefined;
|
|
23
|
+
/** The `id`s of the chosen rows. For `single` it holds one at most. */
|
|
24
|
+
value?: readonly string[] | undefined;
|
|
25
|
+
/** Called with the `id`s of the chosen rows. */
|
|
26
|
+
onValueChange?: ((value: string[]) => void) | undefined;
|
|
27
|
+
/** A rule between the rows. */
|
|
28
|
+
dividers?: boolean | undefined;
|
|
29
|
+
/** Accessible name of the list (of the group, when rows can be chosen). */
|
|
30
|
+
"aria-label": string;
|
|
31
|
+
className?: string | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Rows of text with an icon or avatar at the start and something at the end: contacts, files, notifications. A
|
|
35
|
+
* row can be a link, or a choice (one, or several, with the arrow keys or Tab and Space). Plain, it is a list a
|
|
36
|
+
* screen reader counts. For many records with columns, see DataTable.
|
|
37
|
+
*/
|
|
38
|
+
export declare const List: ({ items, selection, value, onValueChange, dividers, "aria-label": ariaLabel, className }: ListProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Radio } from "@base-ui/react/radio";
|
|
4
|
+
import { RadioGroup } from "@base-ui/react/radio-group";
|
|
5
|
+
import { Check } from "lucide-react";
|
|
6
|
+
import { cn } from "../../utils/cn.js";
|
|
7
|
+
import { CheckboxBox } from "../../components/Checkbox/CheckboxBox.js";
|
|
8
|
+
import { Link } from "../../components/Link/Link.js";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
// src/patterns/List/List.tsx
|
|
11
|
+
var ROW = "flex min-h-14 min-w-0 flex-1 items-center gap-3 px-3 py-2 text-start";
|
|
12
|
+
var content = (item) => /* @__PURE__ */ jsxs(Fragment, { children: [item.leading ? /* @__PURE__ */ jsx("span", {
|
|
13
|
+
className: "inline-flex shrink-0",
|
|
14
|
+
children: item.leading
|
|
15
|
+
}) : null, /* @__PURE__ */ jsxs("span", {
|
|
16
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
17
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
18
|
+
className: "truncate text-body-sm font-medium text-fg",
|
|
19
|
+
children: item.primary
|
|
20
|
+
}), item.secondary ? /* @__PURE__ */ jsx("span", {
|
|
21
|
+
className: "truncate text-caption text-fg-secondary",
|
|
22
|
+
children: item.secondary
|
|
23
|
+
}) : null]
|
|
24
|
+
})] });
|
|
25
|
+
/**
|
|
26
|
+
* Rows of text with an icon or avatar at the start and something at the end: contacts, files, notifications. A
|
|
27
|
+
* row can be a link, or a choice (one, or several, with the arrow keys or Tab and Space). Plain, it is a list a
|
|
28
|
+
* screen reader counts. For many records with columns, see DataTable.
|
|
29
|
+
*/
|
|
30
|
+
var List = (t0) => {
|
|
31
|
+
const $ = c(36);
|
|
32
|
+
const { items, selection: t1, value: t2, onValueChange, dividers: t3, "aria-label": ariaLabel, className } = t0;
|
|
33
|
+
const selection = t1 === void 0 ? "none" : t1;
|
|
34
|
+
let t4;
|
|
35
|
+
if ($[0] !== t2) {
|
|
36
|
+
t4 = t2 === void 0 ? [] : t2;
|
|
37
|
+
$[0] = t2;
|
|
38
|
+
$[1] = t4;
|
|
39
|
+
} else t4 = $[1];
|
|
40
|
+
const value = t4;
|
|
41
|
+
const t5 = (t3 === void 0 ? true : t3) && "border-b border-line last:border-b-0";
|
|
42
|
+
let t6;
|
|
43
|
+
if ($[2] !== t5) {
|
|
44
|
+
t6 = cn("flex items-center", t5);
|
|
45
|
+
$[2] = t5;
|
|
46
|
+
$[3] = t6;
|
|
47
|
+
} else t6 = $[3];
|
|
48
|
+
const itemClass = t6;
|
|
49
|
+
if (selection === "single") {
|
|
50
|
+
const t7 = value[0] ?? "";
|
|
51
|
+
let t8;
|
|
52
|
+
if ($[4] !== onValueChange) {
|
|
53
|
+
t8 = (next) => {
|
|
54
|
+
onValueChange?.([String(next)]);
|
|
55
|
+
};
|
|
56
|
+
$[4] = onValueChange;
|
|
57
|
+
$[5] = t8;
|
|
58
|
+
} else t8 = $[5];
|
|
59
|
+
let t9;
|
|
60
|
+
if ($[6] !== className) {
|
|
61
|
+
t9 = cn("m-0 flex flex-col p-0", className);
|
|
62
|
+
$[6] = className;
|
|
63
|
+
$[7] = t9;
|
|
64
|
+
} else t9 = $[7];
|
|
65
|
+
let t10;
|
|
66
|
+
if ($[8] !== itemClass || $[9] !== items) {
|
|
67
|
+
let t11;
|
|
68
|
+
if ($[11] !== itemClass) {
|
|
69
|
+
t11 = (item) => /* @__PURE__ */ jsxs("div", {
|
|
70
|
+
className: itemClass,
|
|
71
|
+
children: [/* @__PURE__ */ jsxs(Radio.Root, {
|
|
72
|
+
value: item.id,
|
|
73
|
+
disabled: item.disabled,
|
|
74
|
+
className: cn(ROW, "cursor-pointer border-0 bg-transparent outline-none hover:bg-subtle data-checked:bg-primary-light data-disabled:cursor-not-allowed data-disabled:opacity-48", "focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-inset"),
|
|
75
|
+
children: [content(item), /* @__PURE__ */ jsx(Radio.Indicator, {
|
|
76
|
+
className: "inline-flex shrink-0 text-primary-text [&_svg]:size-4",
|
|
77
|
+
children: /* @__PURE__ */ jsx(Check, { "aria-hidden": "true" })
|
|
78
|
+
})]
|
|
79
|
+
}), item.trailing ? /* @__PURE__ */ jsx("span", {
|
|
80
|
+
className: "inline-flex shrink-0 pe-3",
|
|
81
|
+
children: item.trailing
|
|
82
|
+
}) : null]
|
|
83
|
+
}, item.id);
|
|
84
|
+
$[11] = itemClass;
|
|
85
|
+
$[12] = t11;
|
|
86
|
+
} else t11 = $[12];
|
|
87
|
+
t10 = items.map(t11);
|
|
88
|
+
$[8] = itemClass;
|
|
89
|
+
$[9] = items;
|
|
90
|
+
$[10] = t10;
|
|
91
|
+
} else t10 = $[10];
|
|
92
|
+
let t11;
|
|
93
|
+
if ($[13] !== ariaLabel || $[14] !== t10 || $[15] !== t7 || $[16] !== t8 || $[17] !== t9) {
|
|
94
|
+
t11 = /* @__PURE__ */ jsx(RadioGroup, {
|
|
95
|
+
"aria-label": ariaLabel,
|
|
96
|
+
value: t7,
|
|
97
|
+
onValueChange: t8,
|
|
98
|
+
className: t9,
|
|
99
|
+
children: t10
|
|
100
|
+
});
|
|
101
|
+
$[13] = ariaLabel;
|
|
102
|
+
$[14] = t10;
|
|
103
|
+
$[15] = t7;
|
|
104
|
+
$[16] = t8;
|
|
105
|
+
$[17] = t9;
|
|
106
|
+
$[18] = t11;
|
|
107
|
+
} else t11 = $[18];
|
|
108
|
+
return t11;
|
|
109
|
+
}
|
|
110
|
+
let t7;
|
|
111
|
+
if ($[19] !== className) {
|
|
112
|
+
t7 = cn("m-0 flex list-none flex-col p-0", className);
|
|
113
|
+
$[19] = className;
|
|
114
|
+
$[20] = t7;
|
|
115
|
+
} else t7 = $[20];
|
|
116
|
+
let t8;
|
|
117
|
+
if ($[21] !== itemClass || $[22] !== items || $[23] !== onValueChange || $[24] !== selection || $[25] !== value) {
|
|
118
|
+
let t9;
|
|
119
|
+
if ($[27] !== itemClass || $[28] !== onValueChange || $[29] !== selection || $[30] !== value) {
|
|
120
|
+
t9 = (item_0) => /* @__PURE__ */ jsxs("li", {
|
|
121
|
+
className: itemClass,
|
|
122
|
+
children: [selection === "multiple" ? /* @__PURE__ */ jsxs("label", {
|
|
123
|
+
className: cn(ROW, "cursor-pointer hover:bg-subtle", item_0.disabled && "cursor-not-allowed opacity-48"),
|
|
124
|
+
children: [/* @__PURE__ */ jsx(CheckboxBox, {
|
|
125
|
+
checked: value.includes(item_0.id),
|
|
126
|
+
disabled: item_0.disabled ?? false,
|
|
127
|
+
onCheckedChange: (checked) => {
|
|
128
|
+
onValueChange?.(checked ? [...value, item_0.id] : value.filter((id) => id !== item_0.id));
|
|
129
|
+
}
|
|
130
|
+
}), content(item_0)]
|
|
131
|
+
}) : item_0.href || item_0.render ? /* @__PURE__ */ jsx(Link, {
|
|
132
|
+
tone: "inherit",
|
|
133
|
+
underline: "hover",
|
|
134
|
+
...item_0.href ? { href: item_0.href } : {},
|
|
135
|
+
...item_0.render ? { render: item_0.render } : {},
|
|
136
|
+
className: cn(ROW, "font-normal no-underline hover:bg-subtle hover:no-underline"),
|
|
137
|
+
children: content(item_0)
|
|
138
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
139
|
+
className: ROW,
|
|
140
|
+
children: content(item_0)
|
|
141
|
+
}), item_0.trailing ? /* @__PURE__ */ jsx("span", {
|
|
142
|
+
className: "inline-flex shrink-0 pe-3",
|
|
143
|
+
children: item_0.trailing
|
|
144
|
+
}) : null]
|
|
145
|
+
}, item_0.id);
|
|
146
|
+
$[27] = itemClass;
|
|
147
|
+
$[28] = onValueChange;
|
|
148
|
+
$[29] = selection;
|
|
149
|
+
$[30] = value;
|
|
150
|
+
$[31] = t9;
|
|
151
|
+
} else t9 = $[31];
|
|
152
|
+
t8 = items.map(t9);
|
|
153
|
+
$[21] = itemClass;
|
|
154
|
+
$[22] = items;
|
|
155
|
+
$[23] = onValueChange;
|
|
156
|
+
$[24] = selection;
|
|
157
|
+
$[25] = value;
|
|
158
|
+
$[26] = t8;
|
|
159
|
+
} else t8 = $[26];
|
|
160
|
+
let t9;
|
|
161
|
+
if ($[32] !== ariaLabel || $[33] !== t7 || $[34] !== t8) {
|
|
162
|
+
t9 = /* @__PURE__ */ jsx("ul", {
|
|
163
|
+
"aria-label": ariaLabel,
|
|
164
|
+
className: t7,
|
|
165
|
+
children: t8
|
|
166
|
+
});
|
|
167
|
+
$[32] = ariaLabel;
|
|
168
|
+
$[33] = t7;
|
|
169
|
+
$[34] = t8;
|
|
170
|
+
$[35] = t9;
|
|
171
|
+
} else t9 = $[35];
|
|
172
|
+
return t9;
|
|
173
|
+
};
|
|
174
|
+
export { List };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Control, type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
|
|
2
|
+
import type { FieldOrientation } from "../FormField/field-types.js";
|
|
3
|
+
import { type MentionsInputProps } from "./MentionsInput.js";
|
|
4
|
+
export type { MentionSuggestion } from "./MentionsInput.js";
|
|
5
|
+
export interface FormMentionsFieldProps<TValues extends FieldValues> extends Omit<MentionsInputProps, "value" | "onValueChange" | "onBlur" | "invalid" | "inputRef" | "id" | "aria-label" | "aria-labelledby" | "aria-describedby" | "className"> {
|
|
6
|
+
control: Control<TValues>;
|
|
7
|
+
name: FieldPath<TValues>;
|
|
8
|
+
label: string;
|
|
9
|
+
hint?: string | undefined;
|
|
10
|
+
/** Label above the control (default) or in a column beside it. */
|
|
11
|
+
orientation?: FieldOrientation | undefined;
|
|
12
|
+
/** react-hook-form validation rules, for forms that do not use a schema resolver. */
|
|
13
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
14
|
+
/** Turns a stored schema message (an i18n key) into display text. */
|
|
15
|
+
formatError?: ((message: string) => string) | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** A MentionsInput in a field, bound to a react-hook-form string field holding the text. */
|
|
18
|
+
export declare const FormMentionsField: <TValues extends FieldValues>({ control, name, label, hint, orientation, rules, formatError, required, disabled, size, ...mentionsProps }: FormMentionsFieldProps<TValues>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Controller } from "react-hook-form";
|
|
4
|
+
import { toErrorText } from "../FormField/error-message.js";
|
|
5
|
+
import { FieldFrame } from "../FormField/FieldFrame.js";
|
|
6
|
+
import { useFieldIds } from "../FormField/use-field-ids.js";
|
|
7
|
+
import { MentionsInput } from "./MentionsInput.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
// src/patterns/MentionsInput/FormMentionsField.tsx
|
|
10
|
+
/** A MentionsInput in a field, bound to a react-hook-form string field holding the text. */
|
|
11
|
+
var FormMentionsField = (t0) => {
|
|
12
|
+
const $ = c(31);
|
|
13
|
+
let control;
|
|
14
|
+
let formatError;
|
|
15
|
+
let hint;
|
|
16
|
+
let label;
|
|
17
|
+
let mentionsProps;
|
|
18
|
+
let name;
|
|
19
|
+
let orientation;
|
|
20
|
+
let required;
|
|
21
|
+
let rules;
|
|
22
|
+
let t1;
|
|
23
|
+
let t2;
|
|
24
|
+
if ($[0] !== t0) {
|
|
25
|
+
({control, name, label, hint, orientation, rules, formatError, required, disabled: t1, size: t2, ...mentionsProps} = t0);
|
|
26
|
+
$[0] = t0;
|
|
27
|
+
$[1] = control;
|
|
28
|
+
$[2] = formatError;
|
|
29
|
+
$[3] = hint;
|
|
30
|
+
$[4] = label;
|
|
31
|
+
$[5] = mentionsProps;
|
|
32
|
+
$[6] = name;
|
|
33
|
+
$[7] = orientation;
|
|
34
|
+
$[8] = required;
|
|
35
|
+
$[9] = rules;
|
|
36
|
+
$[10] = t1;
|
|
37
|
+
$[11] = t2;
|
|
38
|
+
} else {
|
|
39
|
+
control = $[1];
|
|
40
|
+
formatError = $[2];
|
|
41
|
+
hint = $[3];
|
|
42
|
+
label = $[4];
|
|
43
|
+
mentionsProps = $[5];
|
|
44
|
+
name = $[6];
|
|
45
|
+
orientation = $[7];
|
|
46
|
+
required = $[8];
|
|
47
|
+
rules = $[9];
|
|
48
|
+
t1 = $[10];
|
|
49
|
+
t2 = $[11];
|
|
50
|
+
}
|
|
51
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
52
|
+
const size = t2 === void 0 ? "medium" : t2;
|
|
53
|
+
const { labelId, messageIds, describe } = useFieldIds();
|
|
54
|
+
let t3;
|
|
55
|
+
if ($[12] !== rules) {
|
|
56
|
+
t3 = rules ? { rules } : {};
|
|
57
|
+
$[12] = rules;
|
|
58
|
+
$[13] = t3;
|
|
59
|
+
} else t3 = $[13];
|
|
60
|
+
let t4;
|
|
61
|
+
if ($[14] !== describe || $[15] !== disabled || $[16] !== formatError || $[17] !== hint || $[18] !== label || $[19] !== labelId || $[20] !== mentionsProps || $[21] !== messageIds || $[22] !== orientation || $[23] !== required || $[24] !== size) {
|
|
62
|
+
t4 = (t5) => {
|
|
63
|
+
const { field, fieldState } = t5;
|
|
64
|
+
const errorMessage = toErrorText(fieldState.error?.message, formatError);
|
|
65
|
+
const describedBy = describe(errorMessage, hint);
|
|
66
|
+
return /* @__PURE__ */ jsx(FieldFrame, {
|
|
67
|
+
name: field.name,
|
|
68
|
+
label,
|
|
69
|
+
labelId,
|
|
70
|
+
messageIds,
|
|
71
|
+
disabled,
|
|
72
|
+
invalid: fieldState.invalid,
|
|
73
|
+
touched: fieldState.isTouched,
|
|
74
|
+
dirty: fieldState.isDirty,
|
|
75
|
+
size,
|
|
76
|
+
...hint ? { hint } : {},
|
|
77
|
+
...required ? { required } : {},
|
|
78
|
+
...orientation ? { orientation } : {},
|
|
79
|
+
...errorMessage === void 0 ? {} : { errorMessage },
|
|
80
|
+
children: /* @__PURE__ */ jsx(MentionsInput, {
|
|
81
|
+
...mentionsProps,
|
|
82
|
+
inputRef: field.ref,
|
|
83
|
+
"aria-labelledby": labelId,
|
|
84
|
+
...describedBy ? { "aria-describedby": describedBy } : {},
|
|
85
|
+
value: field.value == null ? "" : String(field.value),
|
|
86
|
+
onValueChange: field.onChange,
|
|
87
|
+
onBlur: field.onBlur,
|
|
88
|
+
invalid: fieldState.invalid,
|
|
89
|
+
required: required ?? false,
|
|
90
|
+
disabled,
|
|
91
|
+
size
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
$[14] = describe;
|
|
96
|
+
$[15] = disabled;
|
|
97
|
+
$[16] = formatError;
|
|
98
|
+
$[17] = hint;
|
|
99
|
+
$[18] = label;
|
|
100
|
+
$[19] = labelId;
|
|
101
|
+
$[20] = mentionsProps;
|
|
102
|
+
$[21] = messageIds;
|
|
103
|
+
$[22] = orientation;
|
|
104
|
+
$[23] = required;
|
|
105
|
+
$[24] = size;
|
|
106
|
+
$[25] = t4;
|
|
107
|
+
} else t4 = $[25];
|
|
108
|
+
let t5;
|
|
109
|
+
if ($[26] !== control || $[27] !== name || $[28] !== t3 || $[29] !== t4) {
|
|
110
|
+
t5 = /* @__PURE__ */ jsx(Controller, {
|
|
111
|
+
control,
|
|
112
|
+
name,
|
|
113
|
+
...t3,
|
|
114
|
+
render: t4
|
|
115
|
+
});
|
|
116
|
+
$[26] = control;
|
|
117
|
+
$[27] = name;
|
|
118
|
+
$[28] = t3;
|
|
119
|
+
$[29] = t4;
|
|
120
|
+
$[30] = t5;
|
|
121
|
+
} else t5 = $[30];
|
|
122
|
+
return t5;
|
|
123
|
+
};
|
|
124
|
+
export { FormMentionsField };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type Ref } from "react";
|
|
2
|
+
import type { FieldSize } from "../FormField/field-types.js";
|
|
3
|
+
export interface MentionSuggestion {
|
|
4
|
+
/** Identifies the person. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** The name that is written into the text and shown in the list. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** A second line in the list, e.g. an email address. It is also searched. */
|
|
9
|
+
description?: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface MentionsInputProps {
|
|
12
|
+
/** The text, with each mention written as the trigger and the name: "Ask @Jane Doe about it". */
|
|
13
|
+
value: string;
|
|
14
|
+
/** Called with the text as it is typed, and when a person is chosen from the list. */
|
|
15
|
+
onValueChange: (value: string) => void;
|
|
16
|
+
/** The people that can be mentioned. */
|
|
17
|
+
suggestions: readonly MentionSuggestion[];
|
|
18
|
+
/** The character that starts a mention. Default "@". */
|
|
19
|
+
trigger?: string | undefined;
|
|
20
|
+
/** Called with the person when one is chosen from the list. */
|
|
21
|
+
onMention?: ((suggestion: MentionSuggestion) => void) | undefined;
|
|
22
|
+
/** The most suggestions listed. Default 6. */
|
|
23
|
+
maxSuggestions?: number | undefined;
|
|
24
|
+
/** Shown in the empty text area, e.g. "Type @ to mention someone". */
|
|
25
|
+
placeholder?: string | undefined;
|
|
26
|
+
/** The height of the text area in lines. Default 4. */
|
|
27
|
+
rows?: number | undefined;
|
|
28
|
+
/** Makes the text area read only and greyed. */
|
|
29
|
+
disabled?: boolean | undefined;
|
|
30
|
+
/** Draws the box red and marks the text area invalid for assistive technology. */
|
|
31
|
+
invalid?: boolean | undefined;
|
|
32
|
+
/** Marks the text area required for assistive technology; the label shows the asterisk. */
|
|
33
|
+
required?: boolean | undefined;
|
|
34
|
+
/** The field size, as the other inputs have it. Default `medium`. */
|
|
35
|
+
size?: FieldSize | undefined;
|
|
36
|
+
/** For a `<label htmlFor>` that names the text area. The list of suggestions is then named only by `aria-label`. */
|
|
37
|
+
id?: string | undefined;
|
|
38
|
+
/** What names the text area, and its list of suggestions, when there is no visible label. */
|
|
39
|
+
"aria-label"?: string | undefined;
|
|
40
|
+
/** The id of the element that names the text area and its list of suggestions, such as a field's label. */
|
|
41
|
+
"aria-labelledby"?: string | undefined;
|
|
42
|
+
/** The ids of the field's message and hint, read after the name. */
|
|
43
|
+
"aria-describedby"?: string | undefined;
|
|
44
|
+
/** The text area was left. */
|
|
45
|
+
onBlur?: (() => void) | undefined;
|
|
46
|
+
/** The `<textarea>`, for a form library to focus the first invalid field. */
|
|
47
|
+
inputRef?: Ref<HTMLTextAreaElement> | undefined;
|
|
48
|
+
/** Extra classes for the box around the text area and its list. Merged last. */
|
|
49
|
+
className?: string | undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A text area that suggests people as you type their name after "@": the list filters as you type, the arrow keys
|
|
53
|
+
* move through it, Enter or Tab writes the name into the text and Escape closes the list. The value is plain text,
|
|
54
|
+
* so the app finds the mentions it needs in it. To a screen reader it is a text box whose suggestions are announced as
|
|
55
|
+
* the arrow keys move through them.
|
|
56
|
+
*/
|
|
57
|
+
export declare const MentionsInput: ({ value, onValueChange, suggestions, trigger, onMention, maxSuggestions, placeholder, rows, disabled, invalid, required, size, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, onBlur, inputRef, className, }: MentionsInputProps) => import("react").JSX.Element;
|