@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,133 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useId, useRef, useState } from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { item, popup } from "../../utils/popup.js";
|
|
5
|
+
import { fieldControl } from "../FormField/field-styles.js";
|
|
6
|
+
import { applyMention, findMention } from "./mention-text.js";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/patterns/MentionsInput/MentionsInput.tsx
|
|
9
|
+
/**
|
|
10
|
+
* A text area that suggests people as you type their name after "@": the list filters as you type, the arrow keys
|
|
11
|
+
* move through it, Enter or Tab writes the name into the text and Escape closes the list. The value is plain text,
|
|
12
|
+
* so the app finds the mentions it needs in it. To a screen reader it is a text box whose suggestions are announced as
|
|
13
|
+
* the arrow keys move through them.
|
|
14
|
+
*/
|
|
15
|
+
var MentionsInput = ({ value, onValueChange, suggestions, trigger = "@", onMention, maxSuggestions = 6, placeholder, rows = 4, disabled = false, invalid = false, required = false, size = "medium", id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, onBlur, inputRef, className }) => {
|
|
16
|
+
const listId = useId();
|
|
17
|
+
const area = useRef(null);
|
|
18
|
+
const [caret, setCaret] = useState(0);
|
|
19
|
+
const [active, setActive] = useState(0);
|
|
20
|
+
const [dismissed, setDismissed] = useState(null);
|
|
21
|
+
const [focused, setFocused] = useState(false);
|
|
22
|
+
const mention = findMention(value, caret, trigger);
|
|
23
|
+
const query = mention?.query.toLowerCase() ?? "";
|
|
24
|
+
const matches = mention ? suggestions.filter((item) => item.label.toLowerCase().includes(query) || (item.description?.toLowerCase().includes(query) ?? false)).slice(0, maxSuggestions) : [];
|
|
25
|
+
const isOpen = focused && mention !== null && matches.length > 0 && dismissed !== mention.start;
|
|
26
|
+
const current = Math.min(active, Math.max(matches.length - 1, 0));
|
|
27
|
+
const optionId = (index) => `${listId}-${String(index)}`;
|
|
28
|
+
const choose = (item_0) => {
|
|
29
|
+
if (!mention) return;
|
|
30
|
+
const next = applyMention(value, mention, item_0.label, caret, trigger);
|
|
31
|
+
onValueChange(next.text);
|
|
32
|
+
onMention?.(item_0);
|
|
33
|
+
setCaret(next.caret);
|
|
34
|
+
setActive(0);
|
|
35
|
+
requestAnimationFrame(() => {
|
|
36
|
+
area.current?.setSelectionRange(next.caret, next.caret);
|
|
37
|
+
area.current?.focus();
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
41
|
+
className: cn("relative", className),
|
|
42
|
+
children: [/* @__PURE__ */ jsx("textarea", {
|
|
43
|
+
ref: (element) => {
|
|
44
|
+
area.current = element;
|
|
45
|
+
if (typeof inputRef === "function") inputRef(element);
|
|
46
|
+
else if (inputRef) inputRef.current = element;
|
|
47
|
+
},
|
|
48
|
+
...id ? { id } : {},
|
|
49
|
+
...ariaLabel ? { "aria-label": ariaLabel } : {},
|
|
50
|
+
...ariaLabelledBy ? { "aria-labelledby": ariaLabelledBy } : {},
|
|
51
|
+
...ariaDescribedBy ? { "aria-describedby": ariaDescribedBy } : {},
|
|
52
|
+
"aria-autocomplete": "list",
|
|
53
|
+
...isOpen ? {
|
|
54
|
+
"aria-controls": listId,
|
|
55
|
+
"aria-activedescendant": optionId(current)
|
|
56
|
+
} : {},
|
|
57
|
+
"aria-invalid": invalid || void 0,
|
|
58
|
+
"aria-required": required || void 0,
|
|
59
|
+
rows,
|
|
60
|
+
placeholder,
|
|
61
|
+
disabled,
|
|
62
|
+
value,
|
|
63
|
+
"data-invalid": invalid || void 0,
|
|
64
|
+
"data-disabled": disabled || void 0,
|
|
65
|
+
className: cn(fieldControl({ size }), "block min-h-19 resize-y py-2.5 placeholder:text-fg-tertiary"),
|
|
66
|
+
onChange: (event) => {
|
|
67
|
+
const nextCaret = event.target.selectionStart;
|
|
68
|
+
if (dismissed !== null && findMention(event.target.value, nextCaret, trigger)?.start !== dismissed) setDismissed(null);
|
|
69
|
+
setCaret(nextCaret);
|
|
70
|
+
setActive(0);
|
|
71
|
+
onValueChange(event.target.value);
|
|
72
|
+
},
|
|
73
|
+
onSelect: (event_0) => {
|
|
74
|
+
setCaret(event_0.currentTarget.selectionStart);
|
|
75
|
+
},
|
|
76
|
+
onKeyDown: (event_1) => {
|
|
77
|
+
if (event_1.key === "Escape" && isOpen && mention) {
|
|
78
|
+
event_1.preventDefault();
|
|
79
|
+
setDismissed(mention.start);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (!isOpen) return;
|
|
83
|
+
if (event_1.key === "ArrowDown") {
|
|
84
|
+
event_1.preventDefault();
|
|
85
|
+
setActive((current + 1) % matches.length);
|
|
86
|
+
} else if (event_1.key === "ArrowUp") {
|
|
87
|
+
event_1.preventDefault();
|
|
88
|
+
setActive((current - 1 + matches.length) % matches.length);
|
|
89
|
+
} else if (event_1.key === "Enter" || event_1.key === "Tab") {
|
|
90
|
+
const item_1 = matches[current];
|
|
91
|
+
if (item_1) {
|
|
92
|
+
event_1.preventDefault();
|
|
93
|
+
choose(item_1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
onFocus: () => {
|
|
98
|
+
setFocused(true);
|
|
99
|
+
},
|
|
100
|
+
onBlur: () => {
|
|
101
|
+
setFocused(false);
|
|
102
|
+
onBlur?.();
|
|
103
|
+
}
|
|
104
|
+
}), /* @__PURE__ */ jsx("ul", {
|
|
105
|
+
id: listId,
|
|
106
|
+
role: "listbox",
|
|
107
|
+
...ariaLabelledBy ? { "aria-labelledby": ariaLabelledBy } : ariaLabel ? { "aria-label": ariaLabel } : {},
|
|
108
|
+
hidden: !isOpen,
|
|
109
|
+
className: cn(popup, "absolute inset-x-0 top-full z-1200 mt-1 m-0 list-none", !isOpen && "hidden"),
|
|
110
|
+
onMouseDown: (event_2) => {
|
|
111
|
+
event_2.preventDefault();
|
|
112
|
+
},
|
|
113
|
+
children: matches.map((item_2, index_0) => /* @__PURE__ */ jsxs("li", {
|
|
114
|
+
id: optionId(index_0),
|
|
115
|
+
role: "option",
|
|
116
|
+
"aria-selected": index_0 === current,
|
|
117
|
+
className: cn(item, "flex-col items-start gap-0 data-[active]:bg-primary-light"),
|
|
118
|
+
...index_0 === current ? {
|
|
119
|
+
"data-active": "",
|
|
120
|
+
"data-highlighted": ""
|
|
121
|
+
} : {},
|
|
122
|
+
onClick: () => {
|
|
123
|
+
choose(item_2);
|
|
124
|
+
},
|
|
125
|
+
children: [/* @__PURE__ */ jsx("span", { children: item_2.label }), item_2.description ? /* @__PURE__ */ jsx("span", {
|
|
126
|
+
className: "text-caption text-fg-secondary",
|
|
127
|
+
children: item_2.description
|
|
128
|
+
}) : null]
|
|
129
|
+
}, item_2.id))
|
|
130
|
+
})]
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
export { MentionsInput };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The text side of a mentions input, as pure functions so they are tested in Node: finding the mention being typed
|
|
3
|
+
* at the caret, and putting a chosen person in its place.
|
|
4
|
+
*/
|
|
5
|
+
/** A mention being typed: where its trigger character is, and the text typed after it. */
|
|
6
|
+
export interface ActiveMention {
|
|
7
|
+
/** The index of the trigger character, e.g. the "@". */
|
|
8
|
+
start: number;
|
|
9
|
+
/** What follows the trigger up to the caret: "ja" in "Ask @ja". */
|
|
10
|
+
query: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The mention the caret is in, or null. A mention starts at `trigger` that begins the text or follows white space (so
|
|
14
|
+
* an address like "me@example.com" is not one) and runs to the caret with no white space in it.
|
|
15
|
+
*/
|
|
16
|
+
export declare const findMention: (text: string, caret: number, trigger?: string) => ActiveMention | null;
|
|
17
|
+
/**
|
|
18
|
+
* The text with the mention replaced by the chosen person ("Ask @ja" and "Jane Doe" make "Ask @Jane Doe "), and
|
|
19
|
+
* where the caret goes: after the space that follows it.
|
|
20
|
+
*/
|
|
21
|
+
export declare const applyMention: (text: string, mention: ActiveMention, label: string, caret: number, trigger?: string) => {
|
|
22
|
+
text: string;
|
|
23
|
+
caret: number;
|
|
24
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/patterns/MentionsInput/mention-text.ts
|
|
2
|
+
/**
|
|
3
|
+
* The mention the caret is in, or null. A mention starts at `trigger` that begins the text or follows white space (so
|
|
4
|
+
* an address like "me@example.com" is not one) and runs to the caret with no white space in it.
|
|
5
|
+
*/
|
|
6
|
+
var findMention = (text, caret, trigger = "@") => {
|
|
7
|
+
const before = text.slice(0, caret);
|
|
8
|
+
const start = before.lastIndexOf(trigger);
|
|
9
|
+
if (start === -1) return null;
|
|
10
|
+
const preceding = start === 0 ? "" : before.charAt(start - 1);
|
|
11
|
+
if (preceding !== "" && !/\s/.test(preceding)) return null;
|
|
12
|
+
const query = before.slice(start + trigger.length);
|
|
13
|
+
if (/\s/.test(query)) return null;
|
|
14
|
+
return {
|
|
15
|
+
start,
|
|
16
|
+
query
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The text with the mention replaced by the chosen person ("Ask @ja" and "Jane Doe" make "Ask @Jane Doe "), and
|
|
21
|
+
* where the caret goes: after the space that follows it.
|
|
22
|
+
*/
|
|
23
|
+
var applyMention = (text, mention, label, caret, trigger = "@") => {
|
|
24
|
+
const inserted = `${trigger}${label} `;
|
|
25
|
+
const after = text.slice(caret);
|
|
26
|
+
return {
|
|
27
|
+
text: `${text.slice(0, mention.start)}${inserted}${after}`,
|
|
28
|
+
caret: mention.start + inserted.length
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export { applyMention, findMention };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface MenubarProps {
|
|
3
|
+
/** The menus: one MenubarMenu each. */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** Accessible name of the bar, e.g. "Application". */
|
|
6
|
+
"aria-label": string;
|
|
7
|
+
className?: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* An application's menu bar (File, Edit, View): a row of menus that is one stop in the Tab order. The left and
|
|
11
|
+
* right arrow keys move between the menus (the other way in right to left), and while one is open, moving to
|
|
12
|
+
* another opens it at once. Each menu's items are Menu's.
|
|
13
|
+
*/
|
|
14
|
+
export declare const Menubar: ({ children, "aria-label": ariaLabel, className }: MenubarProps) => import("react").JSX.Element;
|
|
15
|
+
export interface MenubarMenuProps {
|
|
16
|
+
/** The button on the bar that opens the menu. */
|
|
17
|
+
label: string;
|
|
18
|
+
/** The menu's items: MenuItem, MenuSeparator, MenuSubmenu and the rest of Menu's parts. */
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
/** One menu of a Menubar. */
|
|
22
|
+
export declare const MenubarMenu: ({ label, children }: MenubarMenuProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Menu } from "@base-ui/react/menu";
|
|
4
|
+
import { Menubar as Menubar$1 } from "@base-ui/react/menubar";
|
|
5
|
+
import { cn } from "../../utils/cn.js";
|
|
6
|
+
import { positioner } from "../../utils/popup.js";
|
|
7
|
+
import { MENU_POPUP } from "../../components/Menu/Menu.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
// src/patterns/Menubar/Menubar.tsx
|
|
10
|
+
/**
|
|
11
|
+
* An application's menu bar (File, Edit, View): a row of menus that is one stop in the Tab order. The left and
|
|
12
|
+
* right arrow keys move between the menus (the other way in right to left), and while one is open, moving to
|
|
13
|
+
* another opens it at once. Each menu's items are Menu's.
|
|
14
|
+
*/
|
|
15
|
+
var Menubar = (t0) => {
|
|
16
|
+
const $ = c(6);
|
|
17
|
+
const { children, "aria-label": ariaLabel, className } = t0;
|
|
18
|
+
let t1;
|
|
19
|
+
if ($[0] !== className) {
|
|
20
|
+
t1 = cn("inline-flex items-center gap-0.5 rounded-md border border-line bg-surface p-0.75", className);
|
|
21
|
+
$[0] = className;
|
|
22
|
+
$[1] = t1;
|
|
23
|
+
} else t1 = $[1];
|
|
24
|
+
let t2;
|
|
25
|
+
if ($[2] !== ariaLabel || $[3] !== children || $[4] !== t1) {
|
|
26
|
+
t2 = /* @__PURE__ */ jsx(Menubar$1, {
|
|
27
|
+
"aria-label": ariaLabel,
|
|
28
|
+
className: t1,
|
|
29
|
+
children
|
|
30
|
+
});
|
|
31
|
+
$[2] = ariaLabel;
|
|
32
|
+
$[3] = children;
|
|
33
|
+
$[4] = t1;
|
|
34
|
+
$[5] = t2;
|
|
35
|
+
} else t2 = $[5];
|
|
36
|
+
return t2;
|
|
37
|
+
};
|
|
38
|
+
/** One menu of a Menubar. */
|
|
39
|
+
var MenubarMenu = (t0) => {
|
|
40
|
+
const $ = c(8);
|
|
41
|
+
const { label, children } = t0;
|
|
42
|
+
let t1;
|
|
43
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
44
|
+
t1 = cn("inline-flex h-8 cursor-pointer items-center rounded-sm border-0 bg-transparent px-3 text-caption font-medium text-fg-body outline-none", "transition-colors duration-150 ease-standard hover:bg-subtle focus-visible:ring-2 focus-visible:ring-focus", "data-popup-open:bg-primary-light data-popup-open:text-primary-text");
|
|
45
|
+
$[0] = t1;
|
|
46
|
+
} else t1 = $[0];
|
|
47
|
+
let t2;
|
|
48
|
+
if ($[1] !== label) {
|
|
49
|
+
t2 = /* @__PURE__ */ jsx(Menu.Trigger, {
|
|
50
|
+
className: t1,
|
|
51
|
+
children: label
|
|
52
|
+
});
|
|
53
|
+
$[1] = label;
|
|
54
|
+
$[2] = t2;
|
|
55
|
+
} else t2 = $[2];
|
|
56
|
+
let t3;
|
|
57
|
+
if ($[3] !== children) {
|
|
58
|
+
t3 = /* @__PURE__ */ jsx(Menu.Portal, { children: /* @__PURE__ */ jsx(Menu.Positioner, {
|
|
59
|
+
className: positioner,
|
|
60
|
+
sideOffset: 6,
|
|
61
|
+
align: "start",
|
|
62
|
+
children: /* @__PURE__ */ jsx(Menu.Popup, {
|
|
63
|
+
className: MENU_POPUP,
|
|
64
|
+
children
|
|
65
|
+
})
|
|
66
|
+
}) });
|
|
67
|
+
$[3] = children;
|
|
68
|
+
$[4] = t3;
|
|
69
|
+
} else t3 = $[4];
|
|
70
|
+
let t4;
|
|
71
|
+
if ($[5] !== t2 || $[6] !== t3) {
|
|
72
|
+
t4 = /* @__PURE__ */ jsxs(Menu.Root, { children: [t2, t3] });
|
|
73
|
+
$[5] = t2;
|
|
74
|
+
$[6] = t3;
|
|
75
|
+
$[7] = t4;
|
|
76
|
+
} else t4 = $[7];
|
|
77
|
+
return t4;
|
|
78
|
+
};
|
|
79
|
+
export { Menubar, MenubarMenu };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
export interface NavigationMenuLink {
|
|
3
|
+
label: string;
|
|
4
|
+
/** What the link says about where it goes, in smaller type under the label. */
|
|
5
|
+
description?: string | undefined;
|
|
6
|
+
href?: string | undefined;
|
|
7
|
+
/** The app's router link, `<RouterLink to="/docs" />`, to render in place of the plain `<a>`. */
|
|
8
|
+
render?: ReactElement | undefined;
|
|
9
|
+
/** This is the page the person is on: it gets `aria-current="page"`. */
|
|
10
|
+
current?: boolean | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface NavigationMenuItem extends NavigationMenuLink {
|
|
13
|
+
/** Makes the item a button that opens a panel of these links. Without it the item is a link itself. */
|
|
14
|
+
links?: readonly NavigationMenuLink[] | undefined;
|
|
15
|
+
}
|
|
16
|
+
export interface NavigationMenuProps {
|
|
17
|
+
items: readonly NavigationMenuItem[];
|
|
18
|
+
/** Accessible name of the navigation, e.g. "Main". */
|
|
19
|
+
"aria-label": string;
|
|
20
|
+
className?: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The top navigation of a site: links, and buttons that open a panel of more links. The panels open on hover and
|
|
24
|
+
* on click, and the arrow keys move between the items and into a panel; Escape closes one. For navigation down
|
|
25
|
+
* the side of the page, see SideNav.
|
|
26
|
+
*/
|
|
27
|
+
export declare const NavigationMenu: ({ items, "aria-label": ariaLabel, className }: NavigationMenuProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { NavigationMenu as NavigationMenu$1 } from "@base-ui/react/navigation-menu";
|
|
4
|
+
import { ChevronDown } from "lucide-react";
|
|
5
|
+
import { cn } from "../../utils/cn.js";
|
|
6
|
+
import { popup, positioner } from "../../utils/popup.js";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/patterns/NavigationMenu/NavigationMenu.tsx
|
|
9
|
+
var TOP_LEVEL = cn("inline-flex h-9 cursor-pointer items-center gap-1 rounded-md border-0 bg-transparent px-3 text-body-sm font-medium text-fg-body no-underline outline-none", "transition-colors duration-150 ease-standard hover:bg-subtle hover:text-fg focus-visible:ring-2 focus-visible:ring-focus", "data-popup-open:bg-primary-light data-popup-open:text-primary-text aria-[current=page]:text-primary-text");
|
|
10
|
+
var PANEL_LINK = cn("flex flex-col gap-0.5 rounded-sm px-3 py-2 text-body-sm no-underline outline-none", "hover:bg-primary-light focus-visible:bg-primary-light aria-[current=page]:bg-primary-light");
|
|
11
|
+
/**
|
|
12
|
+
* The top navigation of a site: links, and buttons that open a panel of more links. The panels open on hover and
|
|
13
|
+
* on click, and the arrow keys move between the items and into a panel; Escape closes one. For navigation down
|
|
14
|
+
* the side of the page, see SideNav.
|
|
15
|
+
*/
|
|
16
|
+
var NavigationMenu = (t0) => {
|
|
17
|
+
const $ = c(11);
|
|
18
|
+
const { items, "aria-label": ariaLabel, className } = t0;
|
|
19
|
+
let t1;
|
|
20
|
+
if ($[0] !== className) {
|
|
21
|
+
t1 = cn("min-w-0", className);
|
|
22
|
+
$[0] = className;
|
|
23
|
+
$[1] = t1;
|
|
24
|
+
} else t1 = $[1];
|
|
25
|
+
let t2;
|
|
26
|
+
if ($[2] !== items) {
|
|
27
|
+
t2 = items.map(_temp2);
|
|
28
|
+
$[2] = items;
|
|
29
|
+
$[3] = t2;
|
|
30
|
+
} else t2 = $[3];
|
|
31
|
+
let t3;
|
|
32
|
+
if ($[4] !== t2) {
|
|
33
|
+
t3 = /* @__PURE__ */ jsx(NavigationMenu$1.List, {
|
|
34
|
+
className: "m-0 flex list-none items-center gap-0.5 p-0",
|
|
35
|
+
children: t2
|
|
36
|
+
});
|
|
37
|
+
$[4] = t2;
|
|
38
|
+
$[5] = t3;
|
|
39
|
+
} else t3 = $[5];
|
|
40
|
+
let t4;
|
|
41
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
42
|
+
t4 = /* @__PURE__ */ jsx(NavigationMenu$1.Portal, { children: /* @__PURE__ */ jsx(NavigationMenu$1.Positioner, {
|
|
43
|
+
className: positioner,
|
|
44
|
+
sideOffset: 8,
|
|
45
|
+
align: "start",
|
|
46
|
+
collisionPadding: 8,
|
|
47
|
+
children: /* @__PURE__ */ jsx(NavigationMenu$1.Popup, {
|
|
48
|
+
className: cn(popup, "p-1.5"),
|
|
49
|
+
children: /* @__PURE__ */ jsx(NavigationMenu$1.Viewport, {})
|
|
50
|
+
})
|
|
51
|
+
}) });
|
|
52
|
+
$[6] = t4;
|
|
53
|
+
} else t4 = $[6];
|
|
54
|
+
let t5;
|
|
55
|
+
if ($[7] !== ariaLabel || $[8] !== t1 || $[9] !== t3) {
|
|
56
|
+
t5 = /* @__PURE__ */ jsxs(NavigationMenu$1.Root, {
|
|
57
|
+
"aria-label": ariaLabel,
|
|
58
|
+
className: t1,
|
|
59
|
+
children: [t3, t4]
|
|
60
|
+
});
|
|
61
|
+
$[7] = ariaLabel;
|
|
62
|
+
$[8] = t1;
|
|
63
|
+
$[9] = t3;
|
|
64
|
+
$[10] = t5;
|
|
65
|
+
} else t5 = $[10];
|
|
66
|
+
return t5;
|
|
67
|
+
};
|
|
68
|
+
function _temp(link) {
|
|
69
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(NavigationMenu$1.Link, {
|
|
70
|
+
...link.href ? { href: link.href } : {},
|
|
71
|
+
...link.render ? { render: link.render } : {},
|
|
72
|
+
...link.current ? { active: true } : {},
|
|
73
|
+
className: PANEL_LINK,
|
|
74
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
75
|
+
className: "font-medium text-fg",
|
|
76
|
+
children: link.label
|
|
77
|
+
}), link.description ? /* @__PURE__ */ jsx("span", {
|
|
78
|
+
className: "text-caption text-fg-secondary",
|
|
79
|
+
children: link.description
|
|
80
|
+
}) : null]
|
|
81
|
+
}) }, link.label);
|
|
82
|
+
}
|
|
83
|
+
function _temp2(item) {
|
|
84
|
+
return /* @__PURE__ */ jsx(NavigationMenu$1.Item, { children: item.links ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(NavigationMenu$1.Trigger, {
|
|
85
|
+
className: TOP_LEVEL,
|
|
86
|
+
children: [item.label, /* @__PURE__ */ jsx(NavigationMenu$1.Icon, {
|
|
87
|
+
className: "inline-flex text-fg-secondary transition-transform duration-150 data-popup-open:rotate-180 motion-reduce:transition-none [&_svg]:size-3.5",
|
|
88
|
+
children: /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": "true" })
|
|
89
|
+
})]
|
|
90
|
+
}), /* @__PURE__ */ jsx(NavigationMenu$1.Content, {
|
|
91
|
+
className: "w-72 max-w-(--available-width)",
|
|
92
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
93
|
+
className: "m-0 grid list-none gap-0.5 p-0",
|
|
94
|
+
children: item.links.map(_temp)
|
|
95
|
+
})
|
|
96
|
+
})] }) : /* @__PURE__ */ jsx(NavigationMenu$1.Link, {
|
|
97
|
+
...item.href ? { href: item.href } : {},
|
|
98
|
+
...item.render ? { render: item.render } : {},
|
|
99
|
+
...item.current ? { active: true } : {},
|
|
100
|
+
className: TOP_LEVEL,
|
|
101
|
+
children: item.label
|
|
102
|
+
}) }, item.label);
|
|
103
|
+
}
|
|
104
|
+
export { NavigationMenu };
|
|
@@ -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 NumberFieldProps } from "./NumberField.js";
|
|
4
|
+
export type { NumberFieldLabels } from "./NumberField.js";
|
|
5
|
+
export interface FormNumberFieldProps<TValues extends FieldValues> extends Omit<NumberFieldProps, "name" | "value" | "onValueChange" | "onBlur" | "invalid" | "inputRef" | "id" | "aria-label" | "aria-labelledby"> {
|
|
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 NumberField in a field, bound to a react-hook-form field holding a number, or null while the field is empty. */
|
|
18
|
+
export declare const FormNumberField: <TValues extends FieldValues>({ control, name, label, hint, orientation, rules, formatError, required, disabled, size, ...numberFieldProps }: FormNumberFieldProps<TValues>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { Controller } from "react-hook-form";
|
|
5
|
+
import { toErrorText } from "../FormField/error-message.js";
|
|
6
|
+
import { FieldFrame } from "../FormField/FieldFrame.js";
|
|
7
|
+
import { NumberField } from "./NumberField.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
// src/patterns/NumberField/FormNumberField.tsx
|
|
10
|
+
/** A NumberField in a field, bound to a react-hook-form field holding a number, or null while the field is empty. */
|
|
11
|
+
var FormNumberField = (t0) => {
|
|
12
|
+
const $ = c(29);
|
|
13
|
+
let control;
|
|
14
|
+
let formatError;
|
|
15
|
+
let hint;
|
|
16
|
+
let label;
|
|
17
|
+
let name;
|
|
18
|
+
let numberFieldProps;
|
|
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, ...numberFieldProps} = t0);
|
|
26
|
+
$[0] = t0;
|
|
27
|
+
$[1] = control;
|
|
28
|
+
$[2] = formatError;
|
|
29
|
+
$[3] = hint;
|
|
30
|
+
$[4] = label;
|
|
31
|
+
$[5] = name;
|
|
32
|
+
$[6] = numberFieldProps;
|
|
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
|
+
name = $[5];
|
|
44
|
+
numberFieldProps = $[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 = useId();
|
|
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] !== disabled || $[15] !== formatError || $[16] !== hint || $[17] !== label || $[18] !== labelId || $[19] !== numberFieldProps || $[20] !== orientation || $[21] !== required || $[22] !== size) {
|
|
62
|
+
t4 = (t5) => {
|
|
63
|
+
const { field, fieldState } = t5;
|
|
64
|
+
const errorMessage = toErrorText(fieldState.error?.message, formatError);
|
|
65
|
+
return /* @__PURE__ */ jsx(FieldFrame, {
|
|
66
|
+
name: field.name,
|
|
67
|
+
label,
|
|
68
|
+
labelId,
|
|
69
|
+
disabled,
|
|
70
|
+
invalid: fieldState.invalid,
|
|
71
|
+
touched: fieldState.isTouched,
|
|
72
|
+
dirty: fieldState.isDirty,
|
|
73
|
+
size,
|
|
74
|
+
...hint ? { hint } : {},
|
|
75
|
+
...required ? { required } : {},
|
|
76
|
+
...orientation ? { orientation } : {},
|
|
77
|
+
...errorMessage === void 0 ? {} : { errorMessage },
|
|
78
|
+
children: /* @__PURE__ */ jsx(NumberField, {
|
|
79
|
+
...numberFieldProps,
|
|
80
|
+
inputRef: field.ref,
|
|
81
|
+
"aria-labelledby": labelId,
|
|
82
|
+
value: typeof field.value === "number" ? field.value : null,
|
|
83
|
+
onValueChange: field.onChange,
|
|
84
|
+
onBlur: field.onBlur,
|
|
85
|
+
invalid: fieldState.invalid,
|
|
86
|
+
required: required ?? false,
|
|
87
|
+
disabled,
|
|
88
|
+
size
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
$[14] = disabled;
|
|
93
|
+
$[15] = formatError;
|
|
94
|
+
$[16] = hint;
|
|
95
|
+
$[17] = label;
|
|
96
|
+
$[18] = labelId;
|
|
97
|
+
$[19] = numberFieldProps;
|
|
98
|
+
$[20] = orientation;
|
|
99
|
+
$[21] = required;
|
|
100
|
+
$[22] = size;
|
|
101
|
+
$[23] = t4;
|
|
102
|
+
} else t4 = $[23];
|
|
103
|
+
let t5;
|
|
104
|
+
if ($[24] !== control || $[25] !== name || $[26] !== t3 || $[27] !== t4) {
|
|
105
|
+
t5 = /* @__PURE__ */ jsx(Controller, {
|
|
106
|
+
control,
|
|
107
|
+
name,
|
|
108
|
+
...t3,
|
|
109
|
+
render: t4
|
|
110
|
+
});
|
|
111
|
+
$[24] = control;
|
|
112
|
+
$[25] = name;
|
|
113
|
+
$[26] = t3;
|
|
114
|
+
$[27] = t4;
|
|
115
|
+
$[28] = t5;
|
|
116
|
+
} else t5 = $[28];
|
|
117
|
+
return t5;
|
|
118
|
+
};
|
|
119
|
+
export { FormNumberField };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ReactNode, Ref } from "react";
|
|
2
|
+
import type { FieldSize } from "../FormField/field-types.js";
|
|
3
|
+
/** The texts of the field. The design system has no i18n, so the caller supplies them. */
|
|
4
|
+
export interface NumberFieldLabels {
|
|
5
|
+
/** Accessible name of the button that adds a step, e.g. "Increase quantity". */
|
|
6
|
+
increment: string;
|
|
7
|
+
/** Accessible name of the button that takes a step away, e.g. "Decrease quantity". */
|
|
8
|
+
decrement: string;
|
|
9
|
+
}
|
|
10
|
+
export interface NumberFieldProps {
|
|
11
|
+
/** The number, or null for an empty field. */
|
|
12
|
+
value: number | null;
|
|
13
|
+
/** Called with the new number as the person types or steps, and with null when the field is emptied. */
|
|
14
|
+
onValueChange: (value: number | null) => void;
|
|
15
|
+
labels: NumberFieldLabels;
|
|
16
|
+
min?: number | undefined;
|
|
17
|
+
max?: number | undefined;
|
|
18
|
+
/** What the buttons and the up and down arrow keys change. Default 1. */
|
|
19
|
+
step?: number | undefined;
|
|
20
|
+
/** What Shift with the arrow keys (or Page Up and Page Down) change. Default 10. */
|
|
21
|
+
largeStep?: number | undefined;
|
|
22
|
+
/** How the number is written: `{ style: "currency", currency: "USD" }`, `{ maximumFractionDigits: 1 }`. */
|
|
23
|
+
format?: Intl.NumberFormatOptions | undefined;
|
|
24
|
+
/** The locale that writes and reads the number. The page's if omitted. */
|
|
25
|
+
locale?: Intl.LocalesArgument | undefined;
|
|
26
|
+
placeholder?: string | undefined;
|
|
27
|
+
disabled?: boolean | undefined;
|
|
28
|
+
readOnly?: boolean | undefined;
|
|
29
|
+
/** Draws the box red and marks the input invalid for assistive technology. */
|
|
30
|
+
invalid?: boolean | undefined;
|
|
31
|
+
/** Marks the input required for assistive technology; the label shows the asterisk. */
|
|
32
|
+
required?: boolean | undefined;
|
|
33
|
+
/** "small" is the compact density. */
|
|
34
|
+
size?: FieldSize | undefined;
|
|
35
|
+
/** A decorative icon or unit at the start of the box. */
|
|
36
|
+
contentBefore?: ReactNode | undefined;
|
|
37
|
+
/** The field's name in a submitted form. */
|
|
38
|
+
name?: string | undefined;
|
|
39
|
+
/** For a `<label htmlFor>` that names the input. */
|
|
40
|
+
id?: string | undefined;
|
|
41
|
+
/** The accessible name of the input, for a number with no label element of its own. */
|
|
42
|
+
"aria-label"?: string | undefined;
|
|
43
|
+
/** The id of the element that names the input, such as a field's label. */
|
|
44
|
+
"aria-labelledby"?: string | undefined;
|
|
45
|
+
/** The field was left. */
|
|
46
|
+
onBlur?: (() => void) | undefined;
|
|
47
|
+
/** The `<input>`, for a form library to focus the first invalid field. */
|
|
48
|
+
inputRef?: Ref<HTMLInputElement> | undefined;
|
|
49
|
+
className?: string | undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A number input with a button at each end to step it. Typing is free and checked on leaving (a number out of
|
|
53
|
+
* `min` and `max` snaps back), the up and down arrow keys step, and `format` and `locale` write the number the
|
|
54
|
+
* way the user reads it. The number reads left to right in a right-to-left language too, while the buttons follow
|
|
55
|
+
* the page. Inside a FormNumberField it is labelled and described by the field.
|
|
56
|
+
*/
|
|
57
|
+
export declare const NumberField: ({ value, onValueChange, labels, min, max, step, largeStep, format, locale, placeholder, disabled, readOnly, invalid, required, size, contentBefore, name, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, onBlur, inputRef, className, }: NumberFieldProps) => import("react").JSX.Element;
|