@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,105 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Field } from "@base-ui/react/field";
|
|
4
|
+
import { Switch } from "@base-ui/react/switch";
|
|
5
|
+
import { cn } from "../../utils/cn.js";
|
|
6
|
+
import { fieldChoice } from "./field-styles.js";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/patterns/FormField/SwitchField.tsx
|
|
9
|
+
/** Figma: a 36x20 track with a 14px thumb, 2px in from the edges, so it travels 18px (the other way in RTL). */
|
|
10
|
+
var SWITCH_TRACK = [
|
|
11
|
+
"box-border inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-pill border-0 bg-line p-0.5 outline-none",
|
|
12
|
+
"transition-colors duration-150 ease-standard",
|
|
13
|
+
"not-data-disabled:data-checked:bg-primary",
|
|
14
|
+
"focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-page",
|
|
15
|
+
"data-disabled:cursor-not-allowed data-disabled:bg-subtle"
|
|
16
|
+
].join(" ");
|
|
17
|
+
var SWITCH_THUMB = [
|
|
18
|
+
"block size-3.5 rounded-full bg-white shadow-sm transition-transform duration-150 ease-standard",
|
|
19
|
+
"ltr:data-checked:translate-x-4.5 rtl:data-checked:-translate-x-4.5",
|
|
20
|
+
"data-disabled:bg-fg-disabled data-disabled:shadow-none"
|
|
21
|
+
].join(" ");
|
|
22
|
+
/**
|
|
23
|
+
* A switch with its label: a settings row, the label at the start and the switch at the far end. It is
|
|
24
|
+
* controlled: it shows `checked` and reports a change through `onCheckedChange`. Bound to react-hook-form, it is
|
|
25
|
+
* FormSwitchField.
|
|
26
|
+
*/
|
|
27
|
+
var SwitchField = (t0) => {
|
|
28
|
+
const $ = c(23);
|
|
29
|
+
const { label, checked, onCheckedChange, name, onBlur, inputRef, invalid: t1, hideLabel: t2, disabled: t3 } = t0;
|
|
30
|
+
const invalid = t1 === void 0 ? false : t1;
|
|
31
|
+
const hideLabel = t2 === void 0 ? false : t2;
|
|
32
|
+
const disabled = t3 === void 0 ? false : t3;
|
|
33
|
+
let t4;
|
|
34
|
+
if ($[0] !== onCheckedChange) {
|
|
35
|
+
t4 = (next) => {
|
|
36
|
+
onCheckedChange(next);
|
|
37
|
+
};
|
|
38
|
+
$[0] = onCheckedChange;
|
|
39
|
+
$[1] = t4;
|
|
40
|
+
} else t4 = $[1];
|
|
41
|
+
let t5;
|
|
42
|
+
if ($[2] !== hideLabel || $[3] !== label) {
|
|
43
|
+
t5 = hideLabel ? { "aria-label": label } : {};
|
|
44
|
+
$[2] = hideLabel;
|
|
45
|
+
$[3] = label;
|
|
46
|
+
$[4] = t5;
|
|
47
|
+
} else t5 = $[4];
|
|
48
|
+
let t6;
|
|
49
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
50
|
+
t6 = /* @__PURE__ */ jsx(Switch.Thumb, { className: SWITCH_THUMB });
|
|
51
|
+
$[5] = t6;
|
|
52
|
+
} else t6 = $[5];
|
|
53
|
+
let t7;
|
|
54
|
+
if ($[6] !== checked || $[7] !== inputRef || $[8] !== onBlur || $[9] !== t4 || $[10] !== t5) {
|
|
55
|
+
t7 = /* @__PURE__ */ jsx(Switch.Root, {
|
|
56
|
+
className: SWITCH_TRACK,
|
|
57
|
+
checked,
|
|
58
|
+
inputRef,
|
|
59
|
+
onCheckedChange: t4,
|
|
60
|
+
onBlur,
|
|
61
|
+
...t5,
|
|
62
|
+
children: t6
|
|
63
|
+
});
|
|
64
|
+
$[6] = checked;
|
|
65
|
+
$[7] = inputRef;
|
|
66
|
+
$[8] = onBlur;
|
|
67
|
+
$[9] = t4;
|
|
68
|
+
$[10] = t5;
|
|
69
|
+
$[11] = t7;
|
|
70
|
+
} else t7 = $[11];
|
|
71
|
+
const toggle = t7;
|
|
72
|
+
let t8;
|
|
73
|
+
if ($[12] !== name) {
|
|
74
|
+
t8 = name ? { name } : {};
|
|
75
|
+
$[12] = name;
|
|
76
|
+
$[13] = t8;
|
|
77
|
+
} else t8 = $[13];
|
|
78
|
+
let t9;
|
|
79
|
+
if ($[14] !== hideLabel || $[15] !== label || $[16] !== toggle) {
|
|
80
|
+
t9 = hideLabel ? toggle : /* @__PURE__ */ jsxs(Field.Label, {
|
|
81
|
+
className: cn(fieldChoice, "flex justify-between gap-3"),
|
|
82
|
+
children: [label, toggle]
|
|
83
|
+
});
|
|
84
|
+
$[14] = hideLabel;
|
|
85
|
+
$[15] = label;
|
|
86
|
+
$[16] = toggle;
|
|
87
|
+
$[17] = t9;
|
|
88
|
+
} else t9 = $[17];
|
|
89
|
+
let t10;
|
|
90
|
+
if ($[18] !== disabled || $[19] !== invalid || $[20] !== t8 || $[21] !== t9) {
|
|
91
|
+
t10 = /* @__PURE__ */ jsx(Field.Root, {
|
|
92
|
+
...t8,
|
|
93
|
+
invalid,
|
|
94
|
+
disabled,
|
|
95
|
+
children: t9
|
|
96
|
+
});
|
|
97
|
+
$[18] = disabled;
|
|
98
|
+
$[19] = invalid;
|
|
99
|
+
$[20] = t8;
|
|
100
|
+
$[21] = t9;
|
|
101
|
+
$[22] = t10;
|
|
102
|
+
} else t10 = $[22];
|
|
103
|
+
return t10;
|
|
104
|
+
};
|
|
105
|
+
export { SwitchField };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, Ref } from "react";
|
|
2
|
+
import type { FieldOrientation, FieldSize } from "./field-types.js";
|
|
3
|
+
export interface TextAreaFieldProps {
|
|
4
|
+
label: string;
|
|
5
|
+
/** The text in the field. */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Called with the new text as the person types. */
|
|
8
|
+
onValueChange: (value: string) => void;
|
|
9
|
+
/** The field's name in a submitted form. */
|
|
10
|
+
name?: string | undefined;
|
|
11
|
+
hint?: string | undefined;
|
|
12
|
+
/** The validation message, in the user's language: shown in red under the field, which it marks invalid. */
|
|
13
|
+
errorMessage?: string | undefined;
|
|
14
|
+
/** Marks the field invalid without a message to show. */
|
|
15
|
+
invalid?: boolean | undefined;
|
|
16
|
+
required?: boolean | undefined;
|
|
17
|
+
disabled?: boolean | undefined;
|
|
18
|
+
placeholder?: string | undefined;
|
|
19
|
+
maxLength?: number | undefined;
|
|
20
|
+
rows?: number | undefined;
|
|
21
|
+
autoComplete?: ComponentPropsWithoutRef<"textarea">["autoComplete"] | undefined;
|
|
22
|
+
/** "small" is the compact density. */
|
|
23
|
+
size?: FieldSize | undefined;
|
|
24
|
+
/** Which way the user can drag the corner to resize. Defaults to vertical. */
|
|
25
|
+
resize?: "none" | "vertical" | "horizontal" | "both" | undefined;
|
|
26
|
+
/** Label above the control (default) or in a column beside it. */
|
|
27
|
+
orientation?: FieldOrientation | undefined;
|
|
28
|
+
/** The text area was left. */
|
|
29
|
+
onBlur?: (() => void) | undefined;
|
|
30
|
+
/** The `<textarea>`, e.g. for a form library to focus the first invalid field. */
|
|
31
|
+
inputRef?: Ref<HTMLTextAreaElement> | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A labelled multi-line input with the design system's hint and error. It is controlled: it shows `value` and
|
|
35
|
+
* reports each change through `onValueChange`. Bound to react-hook-form, it is FormTextAreaField.
|
|
36
|
+
*/
|
|
37
|
+
export declare const TextAreaField: ({ label, value, onValueChange, name, hint, errorMessage, invalid, required, placeholder, maxLength, rows, autoComplete, orientation, onBlur, inputRef, disabled, size, resize, }: TextAreaFieldProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Field } from "@base-ui/react/field";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import { FieldFrame } from "./FieldFrame.js";
|
|
6
|
+
import { fieldControl } from "./field-styles.js";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
// src/patterns/FormField/TextAreaField.tsx
|
|
9
|
+
/**
|
|
10
|
+
* A labelled multi-line input with the design system's hint and error. It is controlled: it shows `value` and
|
|
11
|
+
* reports each change through `onValueChange`. Bound to react-hook-form, it is FormTextAreaField.
|
|
12
|
+
*/
|
|
13
|
+
var TextAreaField = (t0) => {
|
|
14
|
+
const $ = c(41);
|
|
15
|
+
const { label, value, onValueChange, name, hint, errorMessage, invalid: t1, required, placeholder, maxLength, rows, autoComplete, orientation, onBlur, inputRef, disabled: t2, size: t3, resize: t4 } = t0;
|
|
16
|
+
const invalid = t1 === void 0 ? false : t1;
|
|
17
|
+
const disabled = t2 === void 0 ? false : t2;
|
|
18
|
+
const size = t3 === void 0 ? "medium" : t3;
|
|
19
|
+
const resize = t4 === void 0 ? "vertical" : t4;
|
|
20
|
+
const isInvalid = invalid || errorMessage !== void 0;
|
|
21
|
+
let t5;
|
|
22
|
+
if ($[0] !== name) {
|
|
23
|
+
t5 = name ? { name } : {};
|
|
24
|
+
$[0] = name;
|
|
25
|
+
$[1] = t5;
|
|
26
|
+
} else t5 = $[1];
|
|
27
|
+
let t6;
|
|
28
|
+
if ($[2] !== hint) {
|
|
29
|
+
t6 = hint ? { hint } : {};
|
|
30
|
+
$[2] = hint;
|
|
31
|
+
$[3] = t6;
|
|
32
|
+
} else t6 = $[3];
|
|
33
|
+
let t7;
|
|
34
|
+
if ($[4] !== required) {
|
|
35
|
+
t7 = required ? { required } : {};
|
|
36
|
+
$[4] = required;
|
|
37
|
+
$[5] = t7;
|
|
38
|
+
} else t7 = $[5];
|
|
39
|
+
let t8;
|
|
40
|
+
if ($[6] !== orientation) {
|
|
41
|
+
t8 = orientation ? { orientation } : {};
|
|
42
|
+
$[6] = orientation;
|
|
43
|
+
$[7] = t8;
|
|
44
|
+
} else t8 = $[7];
|
|
45
|
+
let t9;
|
|
46
|
+
if ($[8] !== errorMessage) {
|
|
47
|
+
t9 = errorMessage === void 0 ? {} : { errorMessage };
|
|
48
|
+
$[8] = errorMessage;
|
|
49
|
+
$[9] = t9;
|
|
50
|
+
} else t9 = $[9];
|
|
51
|
+
const t10 = inputRef;
|
|
52
|
+
let t11;
|
|
53
|
+
if ($[10] !== rows) {
|
|
54
|
+
t11 = /* @__PURE__ */ jsx("textarea", { rows });
|
|
55
|
+
$[10] = rows;
|
|
56
|
+
$[11] = t11;
|
|
57
|
+
} else t11 = $[11];
|
|
58
|
+
let t12;
|
|
59
|
+
if ($[12] !== size) {
|
|
60
|
+
t12 = cn(fieldControl({ size }), "block min-h-19 resize-y py-2.5 placeholder:text-fg-tertiary", "data-[resize=none]:resize-none data-[resize=horizontal]:resize-x data-[resize=both]:resize");
|
|
61
|
+
$[12] = size;
|
|
62
|
+
$[13] = t12;
|
|
63
|
+
} else t12 = $[13];
|
|
64
|
+
const t13 = isInvalid || void 0;
|
|
65
|
+
const t14 = required || void 0;
|
|
66
|
+
let t15;
|
|
67
|
+
if ($[14] !== onValueChange) {
|
|
68
|
+
t15 = (next) => {
|
|
69
|
+
onValueChange(next);
|
|
70
|
+
};
|
|
71
|
+
$[14] = onValueChange;
|
|
72
|
+
$[15] = t15;
|
|
73
|
+
} else t15 = $[15];
|
|
74
|
+
let t16;
|
|
75
|
+
if ($[16] !== autoComplete || $[17] !== disabled || $[18] !== maxLength || $[19] !== onBlur || $[20] !== placeholder || $[21] !== resize || $[22] !== t10 || $[23] !== t11 || $[24] !== t12 || $[25] !== t13 || $[26] !== t14 || $[27] !== t15 || $[28] !== value) {
|
|
76
|
+
t16 = /* @__PURE__ */ jsx(Field.Control, {
|
|
77
|
+
ref: t10,
|
|
78
|
+
render: t11,
|
|
79
|
+
className: t12,
|
|
80
|
+
"data-resize": resize,
|
|
81
|
+
"data-invalid": t13,
|
|
82
|
+
disabled,
|
|
83
|
+
placeholder,
|
|
84
|
+
maxLength,
|
|
85
|
+
autoComplete,
|
|
86
|
+
"aria-required": t14,
|
|
87
|
+
value,
|
|
88
|
+
onValueChange: t15,
|
|
89
|
+
onBlur
|
|
90
|
+
});
|
|
91
|
+
$[16] = autoComplete;
|
|
92
|
+
$[17] = disabled;
|
|
93
|
+
$[18] = maxLength;
|
|
94
|
+
$[19] = onBlur;
|
|
95
|
+
$[20] = placeholder;
|
|
96
|
+
$[21] = resize;
|
|
97
|
+
$[22] = t10;
|
|
98
|
+
$[23] = t11;
|
|
99
|
+
$[24] = t12;
|
|
100
|
+
$[25] = t13;
|
|
101
|
+
$[26] = t14;
|
|
102
|
+
$[27] = t15;
|
|
103
|
+
$[28] = value;
|
|
104
|
+
$[29] = t16;
|
|
105
|
+
} else t16 = $[29];
|
|
106
|
+
let t17;
|
|
107
|
+
if ($[30] !== disabled || $[31] !== isInvalid || $[32] !== label || $[33] !== size || $[34] !== t16 || $[35] !== t5 || $[36] !== t6 || $[37] !== t7 || $[38] !== t8 || $[39] !== t9) {
|
|
108
|
+
t17 = /* @__PURE__ */ jsx(FieldFrame, {
|
|
109
|
+
label,
|
|
110
|
+
disabled,
|
|
111
|
+
invalid: isInvalid,
|
|
112
|
+
size,
|
|
113
|
+
...t5,
|
|
114
|
+
...t6,
|
|
115
|
+
...t7,
|
|
116
|
+
...t8,
|
|
117
|
+
...t9,
|
|
118
|
+
children: t16
|
|
119
|
+
});
|
|
120
|
+
$[30] = disabled;
|
|
121
|
+
$[31] = isInvalid;
|
|
122
|
+
$[32] = label;
|
|
123
|
+
$[33] = size;
|
|
124
|
+
$[34] = t16;
|
|
125
|
+
$[35] = t5;
|
|
126
|
+
$[36] = t6;
|
|
127
|
+
$[37] = t7;
|
|
128
|
+
$[38] = t8;
|
|
129
|
+
$[39] = t9;
|
|
130
|
+
$[40] = t17;
|
|
131
|
+
} else t17 = $[40];
|
|
132
|
+
return t17;
|
|
133
|
+
};
|
|
134
|
+
export { TextAreaField };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ReactNode, type Ref } from "react";
|
|
2
|
+
import type { FieldOrientation, FieldSize } from "./field-types.js";
|
|
3
|
+
interface PasswordToggleLabels {
|
|
4
|
+
show: string;
|
|
5
|
+
hide: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TextFieldProps extends Omit<ComponentPropsWithoutRef<"input">, "value" | "defaultValue" | "onChange" | "size" | "children"> {
|
|
8
|
+
label: string;
|
|
9
|
+
/** The text in the field. */
|
|
10
|
+
value: string;
|
|
11
|
+
/** Called with the new text as the person types. A change `acceptInput` refuses never arrives. */
|
|
12
|
+
onValueChange: (value: string) => void;
|
|
13
|
+
hint?: string | undefined;
|
|
14
|
+
/** The validation message, in the user's language: shown in red under the field, which it marks invalid. */
|
|
15
|
+
errorMessage?: string | undefined;
|
|
16
|
+
/** Marks the field invalid without a message to show. */
|
|
17
|
+
invalid?: boolean | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Shown in green, with a check, while the field is valid: a confirmation such as "Name is available". The
|
|
20
|
+
* caller decides when it applies; FormTextField shows it once the field has been left with a valid value.
|
|
21
|
+
*/
|
|
22
|
+
successMessage?: string | undefined;
|
|
23
|
+
required?: boolean | undefined;
|
|
24
|
+
/** "small" is the compact density; "large" is for sign-in style screens. */
|
|
25
|
+
size?: FieldSize | undefined;
|
|
26
|
+
/** Label above the control (default) or in a column beside it. */
|
|
27
|
+
orientation?: FieldOrientation | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Keep the label out of the layout and give it to assistive technology only.
|
|
30
|
+
* For inputs whose meaning is clear from a placeholder or their neighbours.
|
|
31
|
+
*/
|
|
32
|
+
hideLabel?: boolean | undefined;
|
|
33
|
+
/** Content inside the box, before and after the text. Decorative icons, units. */
|
|
34
|
+
contentBefore?: ReactNode | undefined;
|
|
35
|
+
contentAfter?: ReactNode | undefined;
|
|
36
|
+
/** Adds a show/hide button when type is "password". Texts come from the caller. */
|
|
37
|
+
passwordToggleLabels?: PasswordToggleLabels | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Keystroke filter: a change is ignored when this returns false for the new
|
|
40
|
+
* value, so the field never holds invalid text (e.g. numeric masks).
|
|
41
|
+
*/
|
|
42
|
+
acceptInput?: ((value: string) => boolean) | undefined;
|
|
43
|
+
/** The `<input>`, e.g. for a form library to focus the first invalid field. */
|
|
44
|
+
inputRef?: Ref<HTMLInputElement> | undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A labelled text input with the design system's hint, error and confirmation. It is controlled: it shows
|
|
48
|
+
* `value` and reports each change through `onValueChange`. Bound to react-hook-form, it is FormTextField.
|
|
49
|
+
*/
|
|
50
|
+
export declare const TextField: ({ label, value, onValueChange, hint, errorMessage, invalid, successMessage, required, acceptInput, passwordToggleLabels, contentBefore, contentAfter, orientation, inputRef, name, hideLabel, size, type, disabled, ...inputProps }: TextFieldProps) => import("react").JSX.Element;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Field } from "@base-ui/react/field";
|
|
5
|
+
import { CircleCheck, Eye, EyeOff } from "lucide-react";
|
|
6
|
+
import { Button } from "../../components/Button/Button.js";
|
|
7
|
+
import { FieldFrame } from "./FieldFrame.js";
|
|
8
|
+
import { fieldControl, fieldInput } from "./field-styles.js";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
// src/patterns/FormField/TextField.tsx
|
|
11
|
+
/**
|
|
12
|
+
* A labelled text input with the design system's hint, error and confirmation. It is controlled: it shows
|
|
13
|
+
* `value` and reports each change through `onValueChange`. Bound to react-hook-form, it is FormTextField.
|
|
14
|
+
*/
|
|
15
|
+
var TextField = (t0) => {
|
|
16
|
+
const $ = c(75);
|
|
17
|
+
let acceptInput;
|
|
18
|
+
let contentAfter;
|
|
19
|
+
let contentBefore;
|
|
20
|
+
let errorMessage;
|
|
21
|
+
let hint;
|
|
22
|
+
let inputProps;
|
|
23
|
+
let inputRef;
|
|
24
|
+
let label;
|
|
25
|
+
let name;
|
|
26
|
+
let onValueChange;
|
|
27
|
+
let orientation;
|
|
28
|
+
let passwordToggleLabels;
|
|
29
|
+
let required;
|
|
30
|
+
let successMessage;
|
|
31
|
+
let t1;
|
|
32
|
+
let t2;
|
|
33
|
+
let t3;
|
|
34
|
+
let t4;
|
|
35
|
+
let t5;
|
|
36
|
+
let value;
|
|
37
|
+
if ($[0] !== t0) {
|
|
38
|
+
({label, value, onValueChange, hint, errorMessage, invalid: t1, successMessage, required, acceptInput, passwordToggleLabels, contentBefore, contentAfter, orientation, inputRef, name, hideLabel: t2, size: t3, type: t4, disabled: t5, ...inputProps} = t0);
|
|
39
|
+
$[0] = t0;
|
|
40
|
+
$[1] = acceptInput;
|
|
41
|
+
$[2] = contentAfter;
|
|
42
|
+
$[3] = contentBefore;
|
|
43
|
+
$[4] = errorMessage;
|
|
44
|
+
$[5] = hint;
|
|
45
|
+
$[6] = inputProps;
|
|
46
|
+
$[7] = inputRef;
|
|
47
|
+
$[8] = label;
|
|
48
|
+
$[9] = name;
|
|
49
|
+
$[10] = onValueChange;
|
|
50
|
+
$[11] = orientation;
|
|
51
|
+
$[12] = passwordToggleLabels;
|
|
52
|
+
$[13] = required;
|
|
53
|
+
$[14] = successMessage;
|
|
54
|
+
$[15] = t1;
|
|
55
|
+
$[16] = t2;
|
|
56
|
+
$[17] = t3;
|
|
57
|
+
$[18] = t4;
|
|
58
|
+
$[19] = t5;
|
|
59
|
+
$[20] = value;
|
|
60
|
+
} else {
|
|
61
|
+
acceptInput = $[1];
|
|
62
|
+
contentAfter = $[2];
|
|
63
|
+
contentBefore = $[3];
|
|
64
|
+
errorMessage = $[4];
|
|
65
|
+
hint = $[5];
|
|
66
|
+
inputProps = $[6];
|
|
67
|
+
inputRef = $[7];
|
|
68
|
+
label = $[8];
|
|
69
|
+
name = $[9];
|
|
70
|
+
onValueChange = $[10];
|
|
71
|
+
orientation = $[11];
|
|
72
|
+
passwordToggleLabels = $[12];
|
|
73
|
+
required = $[13];
|
|
74
|
+
successMessage = $[14];
|
|
75
|
+
t1 = $[15];
|
|
76
|
+
t2 = $[16];
|
|
77
|
+
t3 = $[17];
|
|
78
|
+
t4 = $[18];
|
|
79
|
+
t5 = $[19];
|
|
80
|
+
value = $[20];
|
|
81
|
+
}
|
|
82
|
+
const invalid = t1 === void 0 ? false : t1;
|
|
83
|
+
const hideLabel = t2 === void 0 ? false : t2;
|
|
84
|
+
const size = t3 === void 0 ? "medium" : t3;
|
|
85
|
+
const type = t4 === void 0 ? "text" : t4;
|
|
86
|
+
const disabled = t5 === void 0 ? false : t5;
|
|
87
|
+
const [isRevealed, setIsRevealed] = useState(false);
|
|
88
|
+
const isPassword = type === "password";
|
|
89
|
+
const isInvalid = invalid || errorMessage !== void 0;
|
|
90
|
+
const isConfirmed = !isInvalid && successMessage !== void 0;
|
|
91
|
+
let t6;
|
|
92
|
+
if ($[21] !== isPassword || $[22] !== isRevealed || $[23] !== passwordToggleLabels) {
|
|
93
|
+
t6 = isPassword && passwordToggleLabels ? /* @__PURE__ */ jsx(Button, {
|
|
94
|
+
variant: "subtle",
|
|
95
|
+
size: "small",
|
|
96
|
+
className: "-me-1.5",
|
|
97
|
+
"aria-label": isRevealed ? passwordToggleLabels.hide : passwordToggleLabels.show,
|
|
98
|
+
icon: isRevealed ? /* @__PURE__ */ jsx(EyeOff, {}) : /* @__PURE__ */ jsx(Eye, {}),
|
|
99
|
+
onClick: () => {
|
|
100
|
+
setIsRevealed(_temp);
|
|
101
|
+
}
|
|
102
|
+
}) : null;
|
|
103
|
+
$[21] = isPassword;
|
|
104
|
+
$[22] = isRevealed;
|
|
105
|
+
$[23] = passwordToggleLabels;
|
|
106
|
+
$[24] = t6;
|
|
107
|
+
} else t6 = $[24];
|
|
108
|
+
const after = t6 ?? contentAfter;
|
|
109
|
+
let t7;
|
|
110
|
+
if ($[25] !== name) {
|
|
111
|
+
t7 = name ? { name } : {};
|
|
112
|
+
$[25] = name;
|
|
113
|
+
$[26] = t7;
|
|
114
|
+
} else t7 = $[26];
|
|
115
|
+
let t8;
|
|
116
|
+
if ($[27] !== hint) {
|
|
117
|
+
t8 = hint ? { hint } : {};
|
|
118
|
+
$[27] = hint;
|
|
119
|
+
$[28] = t8;
|
|
120
|
+
} else t8 = $[28];
|
|
121
|
+
let t9;
|
|
122
|
+
if ($[29] !== required) {
|
|
123
|
+
t9 = required ? { required } : {};
|
|
124
|
+
$[29] = required;
|
|
125
|
+
$[30] = t9;
|
|
126
|
+
} else t9 = $[30];
|
|
127
|
+
let t10;
|
|
128
|
+
if ($[31] !== orientation) {
|
|
129
|
+
t10 = orientation ? { orientation } : {};
|
|
130
|
+
$[31] = orientation;
|
|
131
|
+
$[32] = t10;
|
|
132
|
+
} else t10 = $[32];
|
|
133
|
+
let t11;
|
|
134
|
+
if ($[33] !== errorMessage) {
|
|
135
|
+
t11 = errorMessage === void 0 ? {} : { errorMessage };
|
|
136
|
+
$[33] = errorMessage;
|
|
137
|
+
$[34] = t11;
|
|
138
|
+
} else t11 = $[34];
|
|
139
|
+
let t12;
|
|
140
|
+
if ($[35] !== isConfirmed || $[36] !== successMessage) {
|
|
141
|
+
t12 = isConfirmed ? { successMessage } : {};
|
|
142
|
+
$[35] = isConfirmed;
|
|
143
|
+
$[36] = successMessage;
|
|
144
|
+
$[37] = t12;
|
|
145
|
+
} else t12 = $[37];
|
|
146
|
+
let t13;
|
|
147
|
+
if ($[38] !== size) {
|
|
148
|
+
t13 = fieldControl({ size });
|
|
149
|
+
$[38] = size;
|
|
150
|
+
$[39] = t13;
|
|
151
|
+
} else t13 = $[39];
|
|
152
|
+
const t14 = isInvalid || void 0;
|
|
153
|
+
const t15 = isConfirmed || void 0;
|
|
154
|
+
const t16 = disabled || void 0;
|
|
155
|
+
const t17 = required || void 0;
|
|
156
|
+
let t18;
|
|
157
|
+
if ($[40] !== acceptInput || $[41] !== onValueChange) {
|
|
158
|
+
t18 = (next) => {
|
|
159
|
+
if (acceptInput && !acceptInput(next)) return;
|
|
160
|
+
onValueChange(next);
|
|
161
|
+
};
|
|
162
|
+
$[40] = acceptInput;
|
|
163
|
+
$[41] = onValueChange;
|
|
164
|
+
$[42] = t18;
|
|
165
|
+
} else t18 = $[42];
|
|
166
|
+
const t19 = isPassword && isRevealed ? "text" : type;
|
|
167
|
+
let t20;
|
|
168
|
+
if ($[43] !== disabled || $[44] !== inputProps || $[45] !== inputRef || $[46] !== t17 || $[47] !== t18 || $[48] !== t19 || $[49] !== value) {
|
|
169
|
+
t20 = /* @__PURE__ */ jsx(Field.Control, {
|
|
170
|
+
...inputProps,
|
|
171
|
+
ref: inputRef,
|
|
172
|
+
className: fieldInput,
|
|
173
|
+
disabled,
|
|
174
|
+
"aria-required": t17,
|
|
175
|
+
value,
|
|
176
|
+
onValueChange: t18,
|
|
177
|
+
type: t19
|
|
178
|
+
});
|
|
179
|
+
$[43] = disabled;
|
|
180
|
+
$[44] = inputProps;
|
|
181
|
+
$[45] = inputRef;
|
|
182
|
+
$[46] = t17;
|
|
183
|
+
$[47] = t18;
|
|
184
|
+
$[48] = t19;
|
|
185
|
+
$[49] = value;
|
|
186
|
+
$[50] = t20;
|
|
187
|
+
} else t20 = $[50];
|
|
188
|
+
let t21;
|
|
189
|
+
if ($[51] !== isConfirmed) {
|
|
190
|
+
t21 = isConfirmed ? /* @__PURE__ */ jsx("span", {
|
|
191
|
+
className: "inline-flex shrink-0 text-success-solid [&_svg]:size-3.5",
|
|
192
|
+
children: /* @__PURE__ */ jsx(CircleCheck, { "aria-hidden": "true" })
|
|
193
|
+
}) : null;
|
|
194
|
+
$[51] = isConfirmed;
|
|
195
|
+
$[52] = t21;
|
|
196
|
+
} else t21 = $[52];
|
|
197
|
+
let t22;
|
|
198
|
+
if ($[53] !== after || $[54] !== contentBefore || $[55] !== t13 || $[56] !== t14 || $[57] !== t15 || $[58] !== t16 || $[59] !== t20 || $[60] !== t21) {
|
|
199
|
+
t22 = /* @__PURE__ */ jsxs("div", {
|
|
200
|
+
className: t13,
|
|
201
|
+
"data-invalid": t14,
|
|
202
|
+
"data-success": t15,
|
|
203
|
+
"data-disabled": t16,
|
|
204
|
+
children: [
|
|
205
|
+
contentBefore,
|
|
206
|
+
t20,
|
|
207
|
+
t21,
|
|
208
|
+
after
|
|
209
|
+
]
|
|
210
|
+
});
|
|
211
|
+
$[53] = after;
|
|
212
|
+
$[54] = contentBefore;
|
|
213
|
+
$[55] = t13;
|
|
214
|
+
$[56] = t14;
|
|
215
|
+
$[57] = t15;
|
|
216
|
+
$[58] = t16;
|
|
217
|
+
$[59] = t20;
|
|
218
|
+
$[60] = t21;
|
|
219
|
+
$[61] = t22;
|
|
220
|
+
} else t22 = $[61];
|
|
221
|
+
let t23;
|
|
222
|
+
if ($[62] !== disabled || $[63] !== hideLabel || $[64] !== isInvalid || $[65] !== label || $[66] !== size || $[67] !== t10 || $[68] !== t11 || $[69] !== t12 || $[70] !== t22 || $[71] !== t7 || $[72] !== t8 || $[73] !== t9) {
|
|
223
|
+
t23 = /* @__PURE__ */ jsx(FieldFrame, {
|
|
224
|
+
label,
|
|
225
|
+
hideLabel,
|
|
226
|
+
disabled,
|
|
227
|
+
invalid: isInvalid,
|
|
228
|
+
size,
|
|
229
|
+
...t7,
|
|
230
|
+
...t8,
|
|
231
|
+
...t9,
|
|
232
|
+
...t10,
|
|
233
|
+
...t11,
|
|
234
|
+
...t12,
|
|
235
|
+
children: t22
|
|
236
|
+
});
|
|
237
|
+
$[62] = disabled;
|
|
238
|
+
$[63] = hideLabel;
|
|
239
|
+
$[64] = isInvalid;
|
|
240
|
+
$[65] = label;
|
|
241
|
+
$[66] = size;
|
|
242
|
+
$[67] = t10;
|
|
243
|
+
$[68] = t11;
|
|
244
|
+
$[69] = t12;
|
|
245
|
+
$[70] = t22;
|
|
246
|
+
$[71] = t7;
|
|
247
|
+
$[72] = t8;
|
|
248
|
+
$[73] = t9;
|
|
249
|
+
$[74] = t23;
|
|
250
|
+
} else t23 = $[74];
|
|
251
|
+
return t23;
|
|
252
|
+
};
|
|
253
|
+
function _temp(previous) {
|
|
254
|
+
return !previous;
|
|
255
|
+
}
|
|
256
|
+
export { TextField };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation messages are stored as i18n keys (the design system has no i18n),
|
|
3
|
+
* so the caller supplies `formatError` to turn one into display text. Without
|
|
4
|
+
* it the stored message is shown as is.
|
|
5
|
+
*/
|
|
6
|
+
export declare const toErrorText: (message: string | undefined, formatError?: (message: string) => string) => string | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// src/patterns/FormField/error-message.ts
|
|
2
|
+
/**
|
|
3
|
+
* Validation messages are stored as i18n keys (the design system has no i18n),
|
|
4
|
+
* so the caller supplies `formatError` to turn one into display text. Without
|
|
5
|
+
* it the stored message is shown as is.
|
|
6
|
+
*/
|
|
7
|
+
var toErrorText = (message, formatError) => message === void 0 || message === "" ? void 0 : formatError?.(message) ?? message;
|
|
8
|
+
export { toErrorText };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The field shell. Vertical is one column; horizontal puts the label in a 260px
|
|
3
|
+
* column beside a 183px control, with the messages under the control. The
|
|
4
|
+
* `group/field` name lets the messages find their column. `content-start` keeps
|
|
5
|
+
* the rows at their own height when a taller neighbour stretches the field.
|
|
6
|
+
*/
|
|
7
|
+
export declare const fieldRoot: (props?: ({
|
|
8
|
+
orientation?: "vertical" | "horizontal" | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
10
|
+
/**
|
|
11
|
+
* The label of a field (or the legend of a group). It turns red when the field
|
|
12
|
+
* is invalid. Above the control it is Figma's field label: 13px medium ink, 7px
|
|
13
|
+
* above the box. Beside the control, in the 260px column of an Add/Edit form,
|
|
14
|
+
* it keeps the app's 14px regular label.
|
|
15
|
+
*/
|
|
16
|
+
export declare const fieldLabel: (props?: ({
|
|
17
|
+
orientation?: "vertical" | "horizontal" | null | undefined;
|
|
18
|
+
size?: "small" | "medium" | "large" | null | undefined;
|
|
19
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
20
|
+
/** The clickable label that wraps a checkbox, radio or switch and its text. */
|
|
21
|
+
export declare const 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";
|
|
22
|
+
/**
|
|
23
|
+
* The box around a text input, a text area or a select trigger. It is the box,
|
|
24
|
+
* not the inner input, that shows focus, error, success and disabled, so an
|
|
25
|
+
* input with an icon beside it is outlined as one. Figma: a 1px grey border on
|
|
26
|
+
* white; focused, a 3px teal ring at 12% (the border is `primary-active`, which
|
|
27
|
+
* holds 3:1 on white, where Figma's teal does not); invalid, the red border and a
|
|
28
|
+
* 3px red ring at 8%. Read-only and disabled boxes are the soft grey.
|
|
29
|
+
*/
|
|
30
|
+
export declare const fieldControl: (props?: ({
|
|
31
|
+
size?: "small" | "medium" | "large" | null | undefined;
|
|
32
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
33
|
+
/** The `<input>` inside a control box: no chrome of its own, it fills the box. */
|
|
34
|
+
export declare const 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";
|
|
35
|
+
/**
|
|
36
|
+
* A removable value inside a field's box: a chosen option of a multi-select, a tag of a tags input. A grey pill
|
|
37
|
+
* with the text and, at the end, the button that removes it. A chip that has the keyboard focus (or is
|
|
38
|
+
* highlighted by the arrow keys) turns teal.
|
|
39
|
+
*/
|
|
40
|
+
export declare const 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";
|
|
41
|
+
/** The button at the end of a chip that removes it. */
|
|
42
|
+
export declare const 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";
|
|
43
|
+
/** The box of a field that holds chips and an input: it wraps onto more lines instead of scrolling. */
|
|
44
|
+
export declare const fieldChipsBox = "h-auto flex-wrap gap-1.5 py-1.5 cursor-text";
|