@primecoderin/fast-ui-react 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/LICENSE +21 -0
- package/README.md +180 -3
- package/dist/_virtual/_rolldown/runtime.js +12 -0
- package/dist/charts.d.ts +7 -0
- package/dist/charts.js +7 -0
- package/dist/components/Avatar/Avatar.d.ts +12 -0
- package/dist/components/Avatar/Avatar.js +92 -0
- package/dist/components/Button/Button.d.ts +44 -0
- package/dist/components/Button/Button.js +221 -0
- package/dist/components/Checkbox/CheckboxBox.d.ts +33 -0
- package/dist/components/Checkbox/CheckboxBox.js +148 -0
- package/dist/components/CodeSnippet/CodeSnippet.d.ts +26 -0
- package/dist/components/CodeSnippet/CodeSnippet.js +153 -0
- package/dist/components/Collapsible/Collapsible.d.ts +20 -0
- package/dist/components/Collapsible/Collapsible.js +97 -0
- package/dist/components/Container/Container.d.ts +301 -0
- package/dist/components/Container/Container.js +20 -0
- package/dist/components/FloatingActionButton/FloatingActionButton.d.ts +22 -0
- package/dist/components/FloatingActionButton/FloatingActionButton.js +141 -0
- package/dist/components/Grid/Grid.d.ts +311 -0
- package/dist/components/Grid/Grid.js +30 -0
- package/dist/components/IconTile/IconTile.d.ts +12 -0
- package/dist/components/IconTile/IconTile.js +70 -0
- package/dist/components/InlineError/InlineError.d.ts +9 -0
- package/dist/components/InlineError/InlineError.js +62 -0
- package/dist/components/Kbd/Kbd.d.ts +11 -0
- package/dist/components/Kbd/Kbd.js +31 -0
- package/dist/components/Link/Link.d.ts +18 -0
- package/dist/components/Link/Link.js +68 -0
- package/dist/components/Menu/ContextMenu.d.ts +18 -0
- package/dist/components/Menu/ContextMenu.js +68 -0
- package/dist/components/Menu/Menu.d.ts +86 -0
- package/dist/components/Menu/Menu.js +394 -0
- package/dist/components/OtpInput/OtpInput.d.ts +32 -0
- package/dist/components/OtpInput/OtpInput.js +177 -0
- package/dist/components/Popover/HoverPopover.d.ts +22 -0
- package/dist/components/Popover/HoverPopover.js +74 -0
- package/dist/components/Popover/Popover.d.ts +21 -0
- package/dist/components/Popover/Popover.js +64 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +17 -0
- package/dist/components/ProgressBar/ProgressBar.js +44 -0
- package/dist/components/Rating/Rating.d.ts +49 -0
- package/dist/components/Rating/Rating.js +241 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts +23 -0
- package/dist/components/ScrollArea/ScrollArea.js +90 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +29 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +99 -0
- package/dist/components/Separator/Separator.d.ts +9 -0
- package/dist/components/Separator/Separator.js +34 -0
- package/dist/components/Skeleton/Skeleton.d.ts +31 -0
- package/dist/components/Skeleton/Skeleton.js +152 -0
- package/dist/components/Slider/Slider.d.ts +54 -0
- package/dist/components/Slider/Slider.js +178 -0
- package/dist/components/Spinner/Spinner.d.ts +17 -0
- package/dist/components/Spinner/Spinner.js +118 -0
- package/dist/components/Stack/Stack.d.ts +302 -0
- package/dist/components/Stack/Stack.js +14 -0
- package/dist/components/StateIcon/StateIcon.d.ts +11 -0
- package/dist/components/StateIcon/StateIcon.js +65 -0
- package/dist/components/StatusBadge/StatusBadge.d.ts +19 -0
- package/dist/components/StatusBadge/StatusBadge.js +82 -0
- package/dist/components/Tabs/Tabs.d.ts +28 -0
- package/dist/components/Tabs/Tabs.js +109 -0
- package/dist/components/Tag/Tag.d.ts +11 -0
- package/dist/components/Tag/Tag.js +66 -0
- package/dist/components/Toast/AppToaster.d.ts +8 -0
- package/dist/components/Toast/AppToaster.js +135 -0
- package/dist/components/Toast/toast-manager.d.ts +28 -0
- package/dist/components/Toast/toast-manager.js +47 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +26 -0
- package/dist/components/ToggleButton/ToggleButton.js +106 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +32 -0
- package/dist/components/ToggleGroup/ToggleGroup.js +79 -0
- package/dist/components/Tooltip/Tooltip.d.ts +16 -0
- package/dist/components/Tooltip/Tooltip.js +58 -0
- package/dist/components/Tooltip/TooltipGroup.d.ts +22 -0
- package/dist/components/Tooltip/TooltipGroup.js +65 -0
- package/dist/components/Typography/Typography.d.ts +17 -0
- package/dist/components/Typography/Typography.js +100 -0
- package/dist/editor-forms.d.ts +1 -0
- package/dist/editor-forms.js +1 -0
- package/dist/editor.d.ts +1 -0
- package/dist/editor.js +1 -0
- package/dist/fonts/LICENSE +93 -0
- package/dist/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
- package/dist/fonts.css +69 -0
- package/dist/forms.d.ts +22 -0
- package/dist/forms.js +23 -0
- package/dist/foundation.css +23 -0
- package/dist/global.css +116 -0
- package/dist/hooks/useAppToast.d.ts +12 -0
- package/dist/hooks/useAppToast.js +29 -0
- package/dist/icons/icons.d.ts +43 -0
- package/dist/icons/icons.js +44 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.js +101 -0
- package/dist/patterns/Accordion/Accordion.d.ts +35 -0
- package/dist/patterns/Accordion/Accordion.js +139 -0
- package/dist/patterns/Alert/Alert.d.ts +38 -0
- package/dist/patterns/Alert/Alert.js +151 -0
- package/dist/patterns/AppShell/AppShell.d.ts +39 -0
- package/dist/patterns/AppShell/AppShell.js +218 -0
- package/dist/patterns/Breadcrumbs/Breadcrumbs.d.ts +21 -0
- package/dist/patterns/Breadcrumbs/Breadcrumbs.js +73 -0
- package/dist/patterns/Calendar/Calendar.d.ts +59 -0
- package/dist/patterns/Calendar/Calendar.js +283 -0
- package/dist/patterns/Calendar/DateRangePicker.d.ts +53 -0
- package/dist/patterns/Calendar/DateRangePicker.js +266 -0
- package/dist/patterns/Calendar/FormDateRangeField.d.ts +24 -0
- package/dist/patterns/Calendar/FormDateRangeField.js +138 -0
- package/dist/patterns/Card/Card.d.ts +26 -0
- package/dist/patterns/Card/Card.js +125 -0
- package/dist/patterns/Carousel/Carousel.d.ts +33 -0
- package/dist/patterns/Carousel/Carousel.js +127 -0
- package/dist/patterns/Cascader/Cascader.d.ts +53 -0
- package/dist/patterns/Cascader/Cascader.js +371 -0
- package/dist/patterns/Cascader/FormCascaderField.d.ts +21 -0
- package/dist/patterns/Cascader/FormCascaderField.js +130 -0
- package/dist/patterns/Charts/AreaChart.d.ts +13 -0
- package/dist/patterns/Charts/AreaChart.js +220 -0
- package/dist/patterns/Charts/BarChart.d.ts +11 -0
- package/dist/patterns/Charts/BarChart.js +220 -0
- package/dist/patterns/Charts/DonutChart.d.ts +37 -0
- package/dist/patterns/Charts/DonutChart.js +215 -0
- package/dist/patterns/Charts/GaugeChart.d.ts +44 -0
- package/dist/patterns/Charts/GaugeChart.js +210 -0
- package/dist/patterns/Charts/LineChart.d.ts +14 -0
- package/dist/patterns/Charts/LineChart.js +222 -0
- package/dist/patterns/Charts/Sparkline.d.ts +24 -0
- package/dist/patterns/Charts/Sparkline.js +81 -0
- package/dist/patterns/Charts/chart-parts.d.ts +139 -0
- package/dist/patterns/Charts/chart-parts.js +385 -0
- package/dist/patterns/Charts/gauge-math.d.ts +20 -0
- package/dist/patterns/Charts/gauge-math.js +21 -0
- package/dist/patterns/Charts/sparkline-path.d.ts +11 -0
- package/dist/patterns/Charts/sparkline-path.js +24 -0
- package/dist/patterns/ColorPicker/ColorPicker.d.ts +50 -0
- package/dist/patterns/ColorPicker/ColorPicker.js +590 -0
- package/dist/patterns/ColorPicker/FormColorField.d.ts +21 -0
- package/dist/patterns/ColorPicker/FormColorField.js +130 -0
- package/dist/patterns/ColorPicker/color-value.d.ts +19 -0
- package/dist/patterns/ColorPicker/color-value.js +72 -0
- package/dist/patterns/Combobox/Autocomplete.d.ts +48 -0
- package/dist/patterns/Combobox/Autocomplete.js +158 -0
- package/dist/patterns/Combobox/Combobox.d.ts +52 -0
- package/dist/patterns/Combobox/Combobox.js +195 -0
- package/dist/patterns/Combobox/ComboboxPopup.d.ts +24 -0
- package/dist/patterns/Combobox/ComboboxPopup.js +107 -0
- package/dist/patterns/Combobox/FormAutocompleteField.d.ts +17 -0
- package/dist/patterns/Combobox/FormAutocompleteField.js +119 -0
- package/dist/patterns/Combobox/FormComboboxField.d.ts +18 -0
- package/dist/patterns/Combobox/FormComboboxField.js +119 -0
- package/dist/patterns/Combobox/FormMultiSelectField.d.ts +18 -0
- package/dist/patterns/Combobox/FormMultiSelectField.js +119 -0
- package/dist/patterns/Combobox/MultiSelect.d.ts +54 -0
- package/dist/patterns/Combobox/MultiSelect.js +175 -0
- package/dist/patterns/CommandPalette/CommandPalette.d.ts +50 -0
- package/dist/patterns/CommandPalette/CommandPalette.js +193 -0
- package/dist/patterns/DataTable/DataTable.d.ts +107 -0
- package/dist/patterns/DataTable/DataTable.js +364 -0
- package/dist/patterns/DateTimePicker/DateTimePanel.d.ts +28 -0
- package/dist/patterns/DateTimePicker/DateTimePanel.js +444 -0
- package/dist/patterns/DateTimePicker/DateTimePicker.d.ts +75 -0
- package/dist/patterns/DateTimePicker/DateTimePicker.js +271 -0
- package/dist/patterns/DateTimePicker/FormDateTimeField.d.ts +32 -0
- package/dist/patterns/DateTimePicker/FormDateTimeField.js +148 -0
- package/dist/patterns/DateTimePicker/TimeSliders.d.ts +14 -0
- package/dist/patterns/DateTimePicker/TimeSliders.js +206 -0
- package/dist/patterns/DateTimePicker/picker-labels.d.ts +30 -0
- package/dist/patterns/DateTimePicker/picker-labels.js +23 -0
- package/dist/patterns/DateTimePicker/picker-values.d.ts +98 -0
- package/dist/patterns/DateTimePicker/picker-values.js +194 -0
- package/dist/patterns/DescriptionList/DescriptionList.d.ts +20 -0
- package/dist/patterns/DescriptionList/DescriptionList.js +57 -0
- package/dist/patterns/Dialog/Dialog.d.ts +26 -0
- package/dist/patterns/Dialog/Dialog.js +212 -0
- package/dist/patterns/Drawer/Drawer.d.ts +33 -0
- package/dist/patterns/Drawer/Drawer.js +153 -0
- package/dist/patterns/EmptyState/EmptyState.d.ts +35 -0
- package/dist/patterns/EmptyState/EmptyState.js +44 -0
- package/dist/patterns/FileUpload/FileUpload.d.ts +87 -0
- package/dist/patterns/FileUpload/FileUpload.js +417 -0
- package/dist/patterns/FileUpload/FormFileUploadField.d.ts +19 -0
- package/dist/patterns/FileUpload/FormFileUploadField.js +117 -0
- package/dist/patterns/FileUpload/add-files.d.ts +26 -0
- package/dist/patterns/FileUpload/add-files.js +35 -0
- package/dist/patterns/FileUpload/file-size.d.ts +14 -0
- package/dist/patterns/FileUpload/file-size.js +44 -0
- package/dist/patterns/FormField/CheckboxField.d.ts +26 -0
- package/dist/patterns/FormField/CheckboxField.js +97 -0
- package/dist/patterns/FormField/FieldFrame.d.ts +85 -0
- package/dist/patterns/FormField/FieldFrame.js +257 -0
- package/dist/patterns/FormField/FormCheckboxField.d.ts +17 -0
- package/dist/patterns/FormField/FormCheckboxField.js +92 -0
- package/dist/patterns/FormField/FormRadioGroupField.d.ts +16 -0
- package/dist/patterns/FormField/FormRadioGroupField.js +97 -0
- package/dist/patterns/FormField/FormRatingField.d.ts +19 -0
- package/dist/patterns/FormField/FormRatingField.js +119 -0
- package/dist/patterns/FormField/FormSelectField.d.ts +16 -0
- package/dist/patterns/FormField/FormSelectField.js +91 -0
- package/dist/patterns/FormField/FormSliderField.d.ts +22 -0
- package/dist/patterns/FormField/FormSliderField.js +128 -0
- package/dist/patterns/FormField/FormSwitchField.d.ts +19 -0
- package/dist/patterns/FormField/FormSwitchField.js +88 -0
- package/dist/patterns/FormField/FormTextAreaField.d.ts +12 -0
- package/dist/patterns/FormField/FormTextAreaField.js +91 -0
- package/dist/patterns/FormField/FormTextField.d.ts +23 -0
- package/dist/patterns/FormField/FormTextField.js +103 -0
- package/dist/patterns/FormField/RadioGroupField.d.ts +38 -0
- package/dist/patterns/FormField/RadioGroupField.js +201 -0
- package/dist/patterns/FormField/SelectField.d.ts +43 -0
- package/dist/patterns/FormField/SelectField.js +211 -0
- package/dist/patterns/FormField/SwitchField.d.ts +27 -0
- package/dist/patterns/FormField/SwitchField.js +105 -0
- package/dist/patterns/FormField/TextAreaField.d.ts +37 -0
- package/dist/patterns/FormField/TextAreaField.js +134 -0
- package/dist/patterns/FormField/TextField.d.ts +51 -0
- package/dist/patterns/FormField/TextField.js +256 -0
- package/dist/patterns/FormField/error-message.d.ts +6 -0
- package/dist/patterns/FormField/error-message.js +8 -0
- package/dist/patterns/FormField/field-styles.d.ts +44 -0
- package/dist/patterns/FormField/field-styles.js +89 -0
- package/dist/patterns/FormField/field-types.d.ts +4 -0
- package/dist/patterns/FormField/use-field-ids.d.ts +18 -0
- package/dist/patterns/FormField/use-field-ids.js +53 -0
- package/dist/patterns/List/List.d.ts +38 -0
- package/dist/patterns/List/List.js +174 -0
- package/dist/patterns/MentionsInput/FormMentionsField.d.ts +18 -0
- package/dist/patterns/MentionsInput/FormMentionsField.js +124 -0
- package/dist/patterns/MentionsInput/MentionsInput.d.ts +57 -0
- package/dist/patterns/MentionsInput/MentionsInput.js +133 -0
- package/dist/patterns/MentionsInput/mention-text.d.ts +24 -0
- package/dist/patterns/MentionsInput/mention-text.js +31 -0
- package/dist/patterns/Menubar/Menubar.d.ts +22 -0
- package/dist/patterns/Menubar/Menubar.js +79 -0
- package/dist/patterns/NavigationMenu/NavigationMenu.d.ts +27 -0
- package/dist/patterns/NavigationMenu/NavigationMenu.js +104 -0
- package/dist/patterns/NumberField/FormNumberField.d.ts +18 -0
- package/dist/patterns/NumberField/FormNumberField.js +119 -0
- package/dist/patterns/NumberField/NumberField.d.ts +57 -0
- package/dist/patterns/NumberField/NumberField.js +242 -0
- package/dist/patterns/Pagination/Pagination.d.ts +31 -0
- package/dist/patterns/Pagination/Pagination.js +275 -0
- package/dist/patterns/Pagination/page-items.d.ts +18 -0
- package/dist/patterns/Pagination/page-items.js +40 -0
- package/dist/patterns/PhoneField/FormPhoneField.d.ts +22 -0
- package/dist/patterns/PhoneField/FormPhoneField.js +97 -0
- package/dist/patterns/PhoneField/PhoneField.d.ts +60 -0
- package/dist/patterns/PhoneField/PhoneField.js +448 -0
- package/dist/patterns/PhoneField/phone-value.d.ts +26 -0
- package/dist/patterns/PhoneField/phone-value.js +38 -0
- package/dist/patterns/QRCode/QRCode.d.ts +37 -0
- package/dist/patterns/QRCode/QRCode.js +120 -0
- package/dist/patterns/QRCode/qr-path.d.ts +7 -0
- package/dist/patterns/QRCode/qr-path.js +25 -0
- package/dist/patterns/ResizablePanels/ResizablePanels.d.ts +34 -0
- package/dist/patterns/ResizablePanels/ResizablePanels.js +175 -0
- package/dist/patterns/ResizablePanels/panel-sizes.d.ts +31 -0
- package/dist/patterns/ResizablePanels/panel-sizes.js +54 -0
- package/dist/patterns/RichTextEditor/FormRichTextField.d.ts +18 -0
- package/dist/patterns/RichTextEditor/FormRichTextField.js +118 -0
- package/dist/patterns/RichTextEditor/RichTextEditor.d.ts +71 -0
- package/dist/patterns/RichTextEditor/RichTextEditor.js +453 -0
- package/dist/patterns/SearchInput/SearchInput.d.ts +26 -0
- package/dist/patterns/SearchInput/SearchInput.js +98 -0
- package/dist/patterns/SideNav/SideNav.d.ts +50 -0
- package/dist/patterns/SideNav/SideNav.js +269 -0
- package/dist/patterns/Stat/Stat.d.ts +51 -0
- package/dist/patterns/Stat/Stat.js +292 -0
- package/dist/patterns/Stepper/Stepper.d.ts +35 -0
- package/dist/patterns/Stepper/Stepper.js +110 -0
- package/dist/patterns/TagGroup/TagGroup.d.ts +44 -0
- package/dist/patterns/TagGroup/TagGroup.js +151 -0
- package/dist/patterns/TagsInput/FormTagsInputField.d.ts +18 -0
- package/dist/patterns/TagsInput/FormTagsInputField.js +124 -0
- package/dist/patterns/TagsInput/TagsInput.d.ts +51 -0
- package/dist/patterns/TagsInput/TagsInput.js +97 -0
- package/dist/patterns/Timeline/Timeline.d.ts +29 -0
- package/dist/patterns/Timeline/Timeline.js +85 -0
- package/dist/patterns/Toolbar/Toolbar.d.ts +31 -0
- package/dist/patterns/Toolbar/Toolbar.js +105 -0
- package/dist/patterns/Tour/Tour.d.ts +38 -0
- package/dist/patterns/Tour/Tour.js +333 -0
- package/dist/patterns/TransferList/FormTransferListField.d.ts +19 -0
- package/dist/patterns/TransferList/FormTransferListField.js +117 -0
- package/dist/patterns/TransferList/TransferList.d.ts +53 -0
- package/dist/patterns/TransferList/TransferList.js +441 -0
- package/dist/patterns/TreeSelect/FormTreeSelectField.d.ts +28 -0
- package/dist/patterns/TreeSelect/FormTreeSelectField.js +88 -0
- package/dist/patterns/TreeSelect/TreeSelect.d.ts +49 -0
- package/dist/patterns/TreeSelect/TreeSelect.js +375 -0
- package/dist/patterns/TreeView/TreeView.d.ts +40 -0
- package/dist/patterns/TreeView/TreeView.js +296 -0
- package/dist/provider/DesignSystemProvider.d.ts +54 -0
- package/dist/provider/DesignSystemProvider.js +270 -0
- package/dist/provider/nonce.d.ts +7 -0
- package/dist/provider/nonce.js +13 -0
- package/dist/styles.css +2 -0
- package/dist/theme/chart-palette.d.ts +51 -0
- package/dist/theme/chart-palette.js +112 -0
- package/dist/theme/create-theme.d.ts +52 -0
- package/dist/theme/create-theme.js +75 -0
- package/dist/theme/style-element.d.ts +28 -0
- package/dist/theme/style-element.js +79 -0
- package/dist/theme/tenant-branding.d.ts +48 -0
- package/dist/theme/tenant-branding.js +65 -0
- package/dist/theme/theme-switch.d.ts +25 -0
- package/dist/theme/theme-switch.js +90 -0
- package/dist/theme/token-names.d.ts +3 -0
- package/dist/theme/token-names.js +166 -0
- package/dist/theme.css +241 -0
- package/dist/tokens.css +383 -0
- package/dist/types/direction.d.ts +4 -0
- package/dist/types/tone.d.ts +7 -0
- package/dist/utils/cn.d.ts +7 -0
- package/dist/utils/cn.js +50 -0
- package/dist/utils/first-field.d.ts +8 -0
- package/dist/utils/first-field.js +10 -0
- package/dist/utils/layout.d.ts +33 -0
- package/dist/utils/layout.js +30 -0
- package/dist/utils/popup.d.ts +12 -0
- package/dist/utils/popup.js +27 -0
- package/docs/accessibility.md +61 -0
- package/docs/advanced-components.md +38 -0
- package/docs/ai-assistants.md +44 -0
- package/docs/architecture.md +65 -0
- package/docs/browser-support.md +30 -0
- package/docs/charts.md +56 -0
- package/docs/components.md +2928 -0
- package/docs/conventions.md +19 -0
- package/docs/customization.md +79 -0
- package/docs/dates-files-data.md +48 -0
- package/docs/design-principles.md +50 -0
- package/docs/faq.md +68 -0
- package/docs/forms.md +114 -0
- package/docs/getting-started.md +64 -0
- package/docs/icons.md +48 -0
- package/docs/internationalization.md +64 -0
- package/docs/layout-and-navigation.md +51 -0
- package/docs/nextjs.md +69 -0
- package/docs/releasing.md +41 -0
- package/docs/testing.md +242 -0
- package/docs/theming.md +118 -0
- package/docs/typescript.md +62 -0
- package/llms-full.txt +4574 -0
- package/llms.txt +52 -0
- package/package.json +166 -6
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/OtpInput/OtpInput.tsx
|
|
7
|
+
var NON_DIGITS = /\D/g;
|
|
8
|
+
/** The keys the input handles itself, by their `KeyboardEvent.key` names. */
|
|
9
|
+
var KEY = {
|
|
10
|
+
backspace: "Backspace",
|
|
11
|
+
arrowLeft: "ArrowLeft",
|
|
12
|
+
arrowRight: "ArrowRight"
|
|
13
|
+
};
|
|
14
|
+
/** The clipboard format that holds plain text. */
|
|
15
|
+
var CLIPBOARD_TEXT = "text/plain";
|
|
16
|
+
var DEFAULT_LENGTH = 6;
|
|
17
|
+
/**
|
|
18
|
+
* A code entered one digit per box, for the codes emailed to a user. Typing moves on to the next box,
|
|
19
|
+
* Backspace on an empty box steps back, the arrow keys move between boxes. A pasted code (Ctrl/Cmd+V, the
|
|
20
|
+
* context menu, a long press on a phone) or one the browser fills in from a message fills all the boxes at
|
|
21
|
+
* once, wherever it lands, with anything that is not a digit left out. Copy and cut take the whole code, not
|
|
22
|
+
* one box of it. The boxes read left to right in every language, as the digits of a number do.
|
|
23
|
+
*/
|
|
24
|
+
var OtpInput = (t0) => {
|
|
25
|
+
const $ = c(13);
|
|
26
|
+
const { value, onValueChange, length: t1, label, getDigitLabel, invalid: t2, disabled: t3, readOnly: t4, autoFocus: t5, "aria-describedby": describedBy, className } = t0;
|
|
27
|
+
const length = t1 === void 0 ? DEFAULT_LENGTH : t1;
|
|
28
|
+
const invalid = t2 === void 0 ? false : t2;
|
|
29
|
+
const disabled = t3 === void 0 ? false : t3;
|
|
30
|
+
const readOnly = t4 === void 0 ? false : t4;
|
|
31
|
+
const autoFocus = t5 === void 0 ? false : t5;
|
|
32
|
+
let t6;
|
|
33
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
34
|
+
t6 = [];
|
|
35
|
+
$[0] = t6;
|
|
36
|
+
} else t6 = $[0];
|
|
37
|
+
const boxes = useRef(t6);
|
|
38
|
+
const focusBox = (index) => {
|
|
39
|
+
const box = boxes.current[index];
|
|
40
|
+
box?.focus();
|
|
41
|
+
box?.select();
|
|
42
|
+
};
|
|
43
|
+
let t7;
|
|
44
|
+
let t8;
|
|
45
|
+
if ($[1] !== autoFocus || $[2] !== disabled) {
|
|
46
|
+
t7 = () => {
|
|
47
|
+
if (autoFocus && !disabled) boxes.current[0]?.focus();
|
|
48
|
+
};
|
|
49
|
+
t8 = [autoFocus, disabled];
|
|
50
|
+
$[1] = autoFocus;
|
|
51
|
+
$[2] = disabled;
|
|
52
|
+
$[3] = t7;
|
|
53
|
+
$[4] = t8;
|
|
54
|
+
} else {
|
|
55
|
+
t7 = $[3];
|
|
56
|
+
t8 = $[4];
|
|
57
|
+
}
|
|
58
|
+
useEffect(t7, t8);
|
|
59
|
+
const writeDigits = (index_0, digits) => {
|
|
60
|
+
const start = Math.min(index_0, value.length);
|
|
61
|
+
onValueChange((value.slice(0, start) + digits + value.slice(start + digits.length)).slice(0, length));
|
|
62
|
+
focusBox(Math.min(start + digits.length, length - 1));
|
|
63
|
+
};
|
|
64
|
+
const removeDigit = (index_1) => {
|
|
65
|
+
onValueChange(value.slice(0, index_1) + value.slice(index_1 + 1));
|
|
66
|
+
focusBox(index_1);
|
|
67
|
+
};
|
|
68
|
+
const handleChange = (event, index_2) => {
|
|
69
|
+
let typed = event.target.value.replace(NON_DIGITS, "");
|
|
70
|
+
if (typed === "") {
|
|
71
|
+
if (index_2 < value.length) removeDigit(index_2);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const held = value[index_2];
|
|
75
|
+
if (held !== void 0 && typed.length === 2) typed = typed.replace(held, "");
|
|
76
|
+
writeDigits(index_2, typed);
|
|
77
|
+
};
|
|
78
|
+
const handleKeyDown = (event_0, index_3) => {
|
|
79
|
+
if (event_0.nativeEvent.isComposing || event_0.keyCode === 229) return;
|
|
80
|
+
if (event_0.key === KEY.backspace && !readOnly && index_3 >= value.length && index_3 > 0) {
|
|
81
|
+
event_0.preventDefault();
|
|
82
|
+
removeDigit(index_3 - 1);
|
|
83
|
+
} else if (event_0.key === KEY.arrowLeft && index_3 > 0) {
|
|
84
|
+
event_0.preventDefault();
|
|
85
|
+
focusBox(index_3 - 1);
|
|
86
|
+
} else if (event_0.key === KEY.arrowRight && index_3 < length - 1) {
|
|
87
|
+
event_0.preventDefault();
|
|
88
|
+
focusBox(index_3 + 1);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const handlePaste = (event_1, index_4) => {
|
|
92
|
+
event_1.preventDefault();
|
|
93
|
+
if (readOnly) return;
|
|
94
|
+
const pasted = event_1.clipboardData.getData(CLIPBOARD_TEXT).replace(NON_DIGITS, "");
|
|
95
|
+
if (pasted === "") return;
|
|
96
|
+
if (pasted.length >= length) {
|
|
97
|
+
onValueChange(pasted.slice(0, length));
|
|
98
|
+
focusBox(length - 1);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
writeDigits(index_4, pasted);
|
|
102
|
+
};
|
|
103
|
+
let t9;
|
|
104
|
+
if ($[5] !== value) {
|
|
105
|
+
t9 = (event_2) => {
|
|
106
|
+
if (value === "") return;
|
|
107
|
+
event_2.preventDefault();
|
|
108
|
+
event_2.clipboardData.setData(CLIPBOARD_TEXT, value);
|
|
109
|
+
};
|
|
110
|
+
$[5] = value;
|
|
111
|
+
$[6] = t9;
|
|
112
|
+
} else t9 = $[6];
|
|
113
|
+
const handleCopy = t9;
|
|
114
|
+
const handleCut = (event_3) => {
|
|
115
|
+
if (value === "") return;
|
|
116
|
+
event_3.preventDefault();
|
|
117
|
+
if (readOnly) return;
|
|
118
|
+
event_3.clipboardData.setData(CLIPBOARD_TEXT, value);
|
|
119
|
+
onValueChange("");
|
|
120
|
+
focusBox(0);
|
|
121
|
+
};
|
|
122
|
+
const t10 = "group";
|
|
123
|
+
const t11 = "ltr";
|
|
124
|
+
let t12;
|
|
125
|
+
if ($[7] !== className) {
|
|
126
|
+
t12 = cn("flex justify-center gap-2.5", className);
|
|
127
|
+
$[7] = className;
|
|
128
|
+
$[8] = t12;
|
|
129
|
+
} else t12 = $[8];
|
|
130
|
+
const t13 = Array.from({ length }, (_, index_5) => /* @__PURE__ */ jsx("input", {
|
|
131
|
+
ref: (box_0) => {
|
|
132
|
+
boxes.current[index_5] = box_0;
|
|
133
|
+
},
|
|
134
|
+
type: "text",
|
|
135
|
+
inputMode: "numeric",
|
|
136
|
+
pattern: "[0-9]*",
|
|
137
|
+
autoComplete: index_5 === 0 ? "one-time-code" : "off",
|
|
138
|
+
value: value[index_5] ?? "",
|
|
139
|
+
disabled,
|
|
140
|
+
readOnly,
|
|
141
|
+
"aria-label": getDigitLabel(index_5 + 1, length),
|
|
142
|
+
"aria-invalid": invalid || void 0,
|
|
143
|
+
"aria-describedby": describedBy,
|
|
144
|
+
className: cn("size-12 min-w-0 rounded-lg border border-line-strong bg-surface p-0 text-center text-h3 font-semibold text-fg", "transition-[border-color,box-shadow] duration-150 ease-standard", "hover:not-focus:not-aria-invalid:not-disabled:border-fg-disabled", "focus:border-primary-active focus:ring-1 focus:ring-primary-active focus:outline-none", "aria-invalid:border-error-solid aria-invalid:focus:border-error-solid aria-invalid:focus:ring-error-solid", "disabled:cursor-not-allowed disabled:opacity-48"),
|
|
145
|
+
onChange: (event_4) => {
|
|
146
|
+
handleChange(event_4, index_5);
|
|
147
|
+
},
|
|
148
|
+
onKeyDown: (event_5) => {
|
|
149
|
+
handleKeyDown(event_5, index_5);
|
|
150
|
+
},
|
|
151
|
+
onPaste: (event_6) => {
|
|
152
|
+
handlePaste(event_6, index_5);
|
|
153
|
+
},
|
|
154
|
+
onCopy: handleCopy,
|
|
155
|
+
onCut: handleCut,
|
|
156
|
+
onFocus: _temp
|
|
157
|
+
}, index_5));
|
|
158
|
+
let t14;
|
|
159
|
+
if ($[9] !== label || $[10] !== t12 || $[11] !== t13) {
|
|
160
|
+
t14 = /* @__PURE__ */ jsx("div", {
|
|
161
|
+
role: t10,
|
|
162
|
+
"aria-label": label,
|
|
163
|
+
dir: t11,
|
|
164
|
+
className: t12,
|
|
165
|
+
children: t13
|
|
166
|
+
});
|
|
167
|
+
$[9] = label;
|
|
168
|
+
$[10] = t12;
|
|
169
|
+
$[11] = t13;
|
|
170
|
+
$[12] = t14;
|
|
171
|
+
} else t14 = $[12];
|
|
172
|
+
return t14;
|
|
173
|
+
};
|
|
174
|
+
function _temp(event_7) {
|
|
175
|
+
event_7.target.select();
|
|
176
|
+
}
|
|
177
|
+
export { OtpInput };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
interface HoverPopoverProps {
|
|
3
|
+
/** The element that opens the popover. It is the trigger itself, so it keeps its own props. */
|
|
4
|
+
trigger: ReactElement;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** Accessible name of the popover. */
|
|
7
|
+
"aria-label": string;
|
|
8
|
+
/** `inline-end` follows the text direction. */
|
|
9
|
+
side?: "top" | "bottom" | "left" | "right" | "inline-start" | "inline-end" | undefined;
|
|
10
|
+
align?: "start" | "center" | "end" | undefined;
|
|
11
|
+
/** Set to false when the trigger is not a `<button>`, e.g. a `<span>`; Base UI then adds the button role itself. */
|
|
12
|
+
nativeButton?: boolean | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A panel that opens while the pointer is over its trigger, and stays open while
|
|
16
|
+
* it is over the panel. The trigger is a button, so Enter or Space opens it from
|
|
17
|
+
* the keyboard and Escape closes it. Focus is not moved into it, so a keyboard
|
|
18
|
+
* user stays on the trigger; for a panel that should take focus, use a menu or
|
|
19
|
+
* dialog instead.
|
|
20
|
+
*/
|
|
21
|
+
export declare const HoverPopover: ({ trigger, children, "aria-label": ariaLabel, side, align, nativeButton, }: HoverPopoverProps) => import("react").JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Popover } from "@base-ui/react/popover";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import { popup, positioner } from "../../utils/popup.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/components/Popover/HoverPopover.tsx
|
|
8
|
+
/**
|
|
9
|
+
* A panel that opens while the pointer is over its trigger, and stays open while
|
|
10
|
+
* it is over the panel. The trigger is a button, so Enter or Space opens it from
|
|
11
|
+
* the keyboard and Escape closes it. Focus is not moved into it, so a keyboard
|
|
12
|
+
* user stays on the trigger; for a panel that should take focus, use a menu or
|
|
13
|
+
* dialog instead.
|
|
14
|
+
*/
|
|
15
|
+
var HoverPopover = (t0) => {
|
|
16
|
+
const $ = c(14);
|
|
17
|
+
const { trigger, children, "aria-label": ariaLabel, side: t1, align: t2, nativeButton: t3 } = t0;
|
|
18
|
+
const side = t1 === void 0 ? "bottom" : t1;
|
|
19
|
+
const align = t2 === void 0 ? "center" : t2;
|
|
20
|
+
const nativeButton = t3 === void 0 ? true : t3;
|
|
21
|
+
let t4;
|
|
22
|
+
if ($[0] !== nativeButton || $[1] !== trigger) {
|
|
23
|
+
t4 = /* @__PURE__ */ jsx(Popover.Trigger, {
|
|
24
|
+
render: trigger,
|
|
25
|
+
nativeButton,
|
|
26
|
+
openOnHover: true,
|
|
27
|
+
delay: 100,
|
|
28
|
+
closeDelay: 150
|
|
29
|
+
});
|
|
30
|
+
$[0] = nativeButton;
|
|
31
|
+
$[1] = trigger;
|
|
32
|
+
$[2] = t4;
|
|
33
|
+
} else t4 = $[2];
|
|
34
|
+
let t5;
|
|
35
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
36
|
+
t5 = cn(popup, "rounded-lg p-1.5");
|
|
37
|
+
$[3] = t5;
|
|
38
|
+
} else t5 = $[3];
|
|
39
|
+
let t6;
|
|
40
|
+
if ($[4] !== ariaLabel || $[5] !== children) {
|
|
41
|
+
t6 = /* @__PURE__ */ jsx(Popover.Popup, {
|
|
42
|
+
"aria-label": ariaLabel,
|
|
43
|
+
initialFocus: false,
|
|
44
|
+
className: t5,
|
|
45
|
+
children
|
|
46
|
+
});
|
|
47
|
+
$[4] = ariaLabel;
|
|
48
|
+
$[5] = children;
|
|
49
|
+
$[6] = t6;
|
|
50
|
+
} else t6 = $[6];
|
|
51
|
+
let t7;
|
|
52
|
+
if ($[7] !== align || $[8] !== side || $[9] !== t6) {
|
|
53
|
+
t7 = /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, {
|
|
54
|
+
className: positioner,
|
|
55
|
+
side,
|
|
56
|
+
align,
|
|
57
|
+
sideOffset: 4,
|
|
58
|
+
children: t6
|
|
59
|
+
}) });
|
|
60
|
+
$[7] = align;
|
|
61
|
+
$[8] = side;
|
|
62
|
+
$[9] = t6;
|
|
63
|
+
$[10] = t7;
|
|
64
|
+
} else t7 = $[10];
|
|
65
|
+
let t8;
|
|
66
|
+
if ($[11] !== t4 || $[12] !== t7) {
|
|
67
|
+
t8 = /* @__PURE__ */ jsxs(Popover.Root, { children: [t4, t7] });
|
|
68
|
+
$[11] = t4;
|
|
69
|
+
$[12] = t7;
|
|
70
|
+
$[13] = t8;
|
|
71
|
+
} else t8 = $[13];
|
|
72
|
+
return t8;
|
|
73
|
+
};
|
|
74
|
+
export { HoverPopover };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
interface PopoverProps {
|
|
3
|
+
/** The button that opens the panel. It is the trigger itself, so it keeps its own look and props. */
|
|
4
|
+
trigger: ReactElement;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** Accessible name of the panel. */
|
|
7
|
+
"aria-label": string;
|
|
8
|
+
/** Which edge of the trigger the panel lines up with. */
|
|
9
|
+
align?: "start" | "center" | "end" | undefined;
|
|
10
|
+
/** Extra classes for the panel, e.g. its width. */
|
|
11
|
+
className?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A panel that opens from a button and holds controls the person works in,
|
|
15
|
+
* such as a column chooser: a heading, a few rows of checkboxes, a link.
|
|
16
|
+
* Focus moves into it when it opens, Escape or a click outside closes it, and
|
|
17
|
+
* focus returns to the button. For a list of actions use Menu; for a panel that
|
|
18
|
+
* only explains, HoverPopover.
|
|
19
|
+
*/
|
|
20
|
+
export declare const Popover: ({ trigger, children, "aria-label": ariaLabel, align, className }: PopoverProps) => import("react").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Popover as Popover$1 } from "@base-ui/react/popover";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import { popup, positioner } from "../../utils/popup.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/components/Popover/Popover.tsx
|
|
8
|
+
/**
|
|
9
|
+
* A panel that opens from a button and holds controls the person works in,
|
|
10
|
+
* such as a column chooser: a heading, a few rows of checkboxes, a link.
|
|
11
|
+
* Focus moves into it when it opens, Escape or a click outside closes it, and
|
|
12
|
+
* focus returns to the button. For a list of actions use Menu; for a panel that
|
|
13
|
+
* only explains, HoverPopover.
|
|
14
|
+
*/
|
|
15
|
+
var Popover = (t0) => {
|
|
16
|
+
const $ = c(14);
|
|
17
|
+
const { trigger, children, "aria-label": ariaLabel, align: t1, className } = t0;
|
|
18
|
+
const align = t1 === void 0 ? "end" : t1;
|
|
19
|
+
let t2;
|
|
20
|
+
if ($[0] !== trigger) {
|
|
21
|
+
t2 = /* @__PURE__ */ jsx(Popover$1.Trigger, { render: trigger });
|
|
22
|
+
$[0] = trigger;
|
|
23
|
+
$[1] = t2;
|
|
24
|
+
} else t2 = $[1];
|
|
25
|
+
let t3;
|
|
26
|
+
if ($[2] !== className) {
|
|
27
|
+
t3 = cn(popup, "p-2", className);
|
|
28
|
+
$[2] = className;
|
|
29
|
+
$[3] = t3;
|
|
30
|
+
} else t3 = $[3];
|
|
31
|
+
let t4;
|
|
32
|
+
if ($[4] !== ariaLabel || $[5] !== children || $[6] !== t3) {
|
|
33
|
+
t4 = /* @__PURE__ */ jsx(Popover$1.Popup, {
|
|
34
|
+
"aria-label": ariaLabel,
|
|
35
|
+
className: t3,
|
|
36
|
+
children
|
|
37
|
+
});
|
|
38
|
+
$[4] = ariaLabel;
|
|
39
|
+
$[5] = children;
|
|
40
|
+
$[6] = t3;
|
|
41
|
+
$[7] = t4;
|
|
42
|
+
} else t4 = $[7];
|
|
43
|
+
let t5;
|
|
44
|
+
if ($[8] !== align || $[9] !== t4) {
|
|
45
|
+
t5 = /* @__PURE__ */ jsx(Popover$1.Portal, { children: /* @__PURE__ */ jsx(Popover$1.Positioner, {
|
|
46
|
+
className: positioner,
|
|
47
|
+
align,
|
|
48
|
+
sideOffset: 6,
|
|
49
|
+
children: t4
|
|
50
|
+
}) });
|
|
51
|
+
$[8] = align;
|
|
52
|
+
$[9] = t4;
|
|
53
|
+
$[10] = t5;
|
|
54
|
+
} else t5 = $[10];
|
|
55
|
+
let t6;
|
|
56
|
+
if ($[11] !== t2 || $[12] !== t5) {
|
|
57
|
+
t6 = /* @__PURE__ */ jsxs(Popover$1.Root, { children: [t2, t5] });
|
|
58
|
+
$[11] = t2;
|
|
59
|
+
$[12] = t5;
|
|
60
|
+
$[13] = t6;
|
|
61
|
+
} else t6 = $[13];
|
|
62
|
+
return t6;
|
|
63
|
+
};
|
|
64
|
+
export { Popover };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ProgressBarProps {
|
|
2
|
+
/** What is in progress, e.g. "Loading". */
|
|
3
|
+
label: string;
|
|
4
|
+
/**
|
|
5
|
+
* What a screen reader says in place of a value, after the label, e.g. "Loading the list". The bar has no value
|
|
6
|
+
* (it cannot say how far), so without this it has no value text at all and a screen reader announces the label
|
|
7
|
+
* and the progress bar.
|
|
8
|
+
*/
|
|
9
|
+
valueText?: string | undefined;
|
|
10
|
+
/** Classes for the bar, e.g. a margin. */
|
|
11
|
+
className?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A thin bar with a block sliding across it: something is loading, with no way to say how far. For a visitor who
|
|
15
|
+
* asks for reduced motion the block does not move: the whole bar shows, faded.
|
|
16
|
+
*/
|
|
17
|
+
export declare const ProgressBar: ({ label, valueText, className }: ProgressBarProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Progress } from "@base-ui/react/progress";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/ProgressBar/ProgressBar.tsx
|
|
7
|
+
/**
|
|
8
|
+
* A thin bar with a block sliding across it: something is loading, with no way to say how far. For a visitor who
|
|
9
|
+
* asks for reduced motion the block does not move: the whole bar shows, faded.
|
|
10
|
+
*/
|
|
11
|
+
var ProgressBar = (t0) => {
|
|
12
|
+
const $ = c(7);
|
|
13
|
+
const { label, valueText, className } = t0;
|
|
14
|
+
let t1;
|
|
15
|
+
if ($[0] !== className) {
|
|
16
|
+
t1 = cn("block w-full", className);
|
|
17
|
+
$[0] = className;
|
|
18
|
+
$[1] = t1;
|
|
19
|
+
} else t1 = $[1];
|
|
20
|
+
let t2;
|
|
21
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
22
|
+
t2 = /* @__PURE__ */ jsx(Progress.Track, {
|
|
23
|
+
className: "relative block h-0.5 overflow-hidden bg-primary-light",
|
|
24
|
+
children: /* @__PURE__ */ jsx(Progress.Indicator, { className: "absolute inset-y-0 inset-s-[-40%] w-2/5 animate-slide bg-primary motion-reduce:inset-s-0 motion-reduce:w-full motion-reduce:animate-none motion-reduce:opacity-50" })
|
|
25
|
+
});
|
|
26
|
+
$[2] = t2;
|
|
27
|
+
} else t2 = $[2];
|
|
28
|
+
let t3;
|
|
29
|
+
if ($[3] !== label || $[4] !== t1 || $[5] !== valueText) {
|
|
30
|
+
t3 = /* @__PURE__ */ jsx(Progress.Root, {
|
|
31
|
+
value: null,
|
|
32
|
+
"aria-label": label,
|
|
33
|
+
"aria-valuetext": valueText,
|
|
34
|
+
className: t1,
|
|
35
|
+
children: t2
|
|
36
|
+
});
|
|
37
|
+
$[3] = label;
|
|
38
|
+
$[4] = t1;
|
|
39
|
+
$[5] = valueText;
|
|
40
|
+
$[6] = t3;
|
|
41
|
+
} else t3 = $[6];
|
|
42
|
+
return t3;
|
|
43
|
+
};
|
|
44
|
+
export { ProgressBar };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type Ref } from "react";
|
|
2
|
+
export interface RatingProps {
|
|
3
|
+
/** The rating, from 0 (none) to `max`. */
|
|
4
|
+
value: number;
|
|
5
|
+
/** Called with the new rating. Leave it out, or set `readOnly`, to only show a rating. */
|
|
6
|
+
onValueChange?: ((value: number) => void) | undefined;
|
|
7
|
+
/** How many stars. Default 5. */
|
|
8
|
+
max?: number | undefined;
|
|
9
|
+
/** Show the rating without letting it change: the stars are an image, not controls. */
|
|
10
|
+
readOnly?: boolean | undefined;
|
|
11
|
+
/** Dims the stars, which cannot be chosen or focused. */
|
|
12
|
+
disabled?: boolean | undefined;
|
|
13
|
+
/** Pressing the chosen star again sets the rating back to 0. */
|
|
14
|
+
clearable?: boolean | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The stars' size: small 16px, medium 20px (the default), large 26px. Small and medium stars that can be chosen
|
|
17
|
+
* each sit in a 24px box, the least size of a target, so they stand further apart than read-only ones.
|
|
18
|
+
*/
|
|
19
|
+
size?: "small" | "medium" | "large" | undefined;
|
|
20
|
+
/** Marks the group invalid for assistive technology. */
|
|
21
|
+
invalid?: boolean | undefined;
|
|
22
|
+
/** Marks the group required for assistive technology; a field's label shows the asterisk. */
|
|
23
|
+
required?: boolean | undefined;
|
|
24
|
+
/** What a rating of `value` out of `max` is called, e.g. `(n, max) => "3 of 5 stars"`. It names each star and the shown rating. */
|
|
25
|
+
getValueLabel: (value: number, max: number) => string;
|
|
26
|
+
/** The field's name in a submitted form. */
|
|
27
|
+
name?: string | undefined;
|
|
28
|
+
/** Accessible name of the group, e.g. "Rate this order". */
|
|
29
|
+
"aria-label"?: string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* The id of the element that names the group, such as a field's label. A read-only rating adds the rating shown
|
|
32
|
+
* to that name.
|
|
33
|
+
*/
|
|
34
|
+
"aria-labelledby"?: string | undefined;
|
|
35
|
+
/** The ids of the field's message and hint, read after the name. */
|
|
36
|
+
"aria-describedby"?: string | undefined;
|
|
37
|
+
/** The group was left. */
|
|
38
|
+
onBlur?: (() => void) | undefined;
|
|
39
|
+
/** The first star's radio input, for a form library to focus the first invalid field. */
|
|
40
|
+
inputRef?: Ref<HTMLInputElement> | undefined;
|
|
41
|
+
/** Classes for the row of stars, merged last. */
|
|
42
|
+
className?: string | undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A rating of stars. Each star is a radio button, so the arrow keys move and choose, Tab enters the group once,
|
|
46
|
+
* and a screen reader announces each star by `getValueLabel`. The stars under the pointer preview the choice.
|
|
47
|
+
* With `readOnly` it is an image that shows the rating. Whole stars only.
|
|
48
|
+
*/
|
|
49
|
+
export declare const Rating: ({ value, onValueChange, max, readOnly, disabled, clearable, size, invalid, required, getValueLabel, name, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, onBlur, inputRef, className, }: RatingProps) => import("react").JSX.Element;
|