@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,590 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useId, useRef, useState } from "react";
|
|
4
|
+
import { DirectionProvider } from "@base-ui/react/direction-provider";
|
|
5
|
+
import { Popover } from "@base-ui/react/popover";
|
|
6
|
+
import { Slider } from "@base-ui/react/slider";
|
|
7
|
+
import { cn } from "../../utils/cn.js";
|
|
8
|
+
import { popup, positioner } from "../../utils/popup.js";
|
|
9
|
+
import { SLIDER_THUMB } from "../../components/Slider/Slider.js";
|
|
10
|
+
import { fieldControl, fieldInput } from "../FormField/field-styles.js";
|
|
11
|
+
import { hexToHsv, hsvToHex, parseHex } from "./color-value.js";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
// src/patterns/ColorPicker/ColorPicker.tsx
|
|
14
|
+
var KEY_STEP = 1;
|
|
15
|
+
var KEY_STEP_LARGE = 10;
|
|
16
|
+
var HUE_GRADIENT = "linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)";
|
|
17
|
+
var clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
18
|
+
/**
|
|
19
|
+
* A colour picker: a button showing the colour that opens a panel with an area for saturation (across) and
|
|
20
|
+
* brightness (up), a hue slider, the hex text and, if given, swatches. The value is hex text. The area is one
|
|
21
|
+
* slider for a screen reader, which reads its position through `labels.areaValue`; the arrow keys move it by 1
|
|
22
|
+
* (10 with Shift). The panel is always left to right, like the colours it shows.
|
|
23
|
+
*/
|
|
24
|
+
var ColorPicker = (t0) => {
|
|
25
|
+
const $ = c(59);
|
|
26
|
+
const { value, onValueChange, labels, swatches, placeholder, disabled: t1, invalid: t2, size: t3, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, triggerRef, onBlur } = t0;
|
|
27
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
28
|
+
const invalid = t2 === void 0 ? false : t2;
|
|
29
|
+
const size = t3 === void 0 ? "medium" : t3;
|
|
30
|
+
const [open, setOpen] = useState(false);
|
|
31
|
+
const popupRef = useRef(null);
|
|
32
|
+
const valueId = useId();
|
|
33
|
+
let t4;
|
|
34
|
+
if ($[0] !== value) {
|
|
35
|
+
t4 = parseHex(value);
|
|
36
|
+
$[0] = value;
|
|
37
|
+
$[1] = t4;
|
|
38
|
+
} else t4 = $[1];
|
|
39
|
+
const parsed = t4;
|
|
40
|
+
const isOpen = open && !disabled;
|
|
41
|
+
const shown = parsed ?? placeholder ?? labels.choose;
|
|
42
|
+
let t5;
|
|
43
|
+
if ($[2] !== ariaLabel || $[3] !== ariaLabelledBy || $[4] !== labels.choose || $[5] !== shown || $[6] !== valueId) {
|
|
44
|
+
t5 = ariaLabelledBy ? { "aria-labelledby": `${ariaLabelledBy} ${valueId}` } : { "aria-label": `${ariaLabel ?? labels.choose}: ${shown}` };
|
|
45
|
+
$[2] = ariaLabel;
|
|
46
|
+
$[3] = ariaLabelledBy;
|
|
47
|
+
$[4] = labels.choose;
|
|
48
|
+
$[5] = shown;
|
|
49
|
+
$[6] = valueId;
|
|
50
|
+
$[7] = t5;
|
|
51
|
+
} else t5 = $[7];
|
|
52
|
+
const nameProps = t5;
|
|
53
|
+
let t6;
|
|
54
|
+
if ($[8] !== onBlur) {
|
|
55
|
+
t6 = (next) => {
|
|
56
|
+
setOpen(next);
|
|
57
|
+
if (!next) onBlur?.();
|
|
58
|
+
};
|
|
59
|
+
$[8] = onBlur;
|
|
60
|
+
$[9] = t6;
|
|
61
|
+
} else t6 = $[9];
|
|
62
|
+
let t7;
|
|
63
|
+
if ($[10] !== id) {
|
|
64
|
+
t7 = id ? { id } : {};
|
|
65
|
+
$[10] = id;
|
|
66
|
+
$[11] = t7;
|
|
67
|
+
} else t7 = $[11];
|
|
68
|
+
let t8;
|
|
69
|
+
if ($[12] !== ariaDescribedBy) {
|
|
70
|
+
t8 = ariaDescribedBy ? { "aria-describedby": ariaDescribedBy } : {};
|
|
71
|
+
$[12] = ariaDescribedBy;
|
|
72
|
+
$[13] = t8;
|
|
73
|
+
} else t8 = $[13];
|
|
74
|
+
let t9;
|
|
75
|
+
if ($[14] !== size) {
|
|
76
|
+
t9 = cn(fieldControl({ size }), "cursor-pointer justify-start gap-2.5 data-popup-open:border-primary-active");
|
|
77
|
+
$[14] = size;
|
|
78
|
+
$[15] = t9;
|
|
79
|
+
} else t9 = $[15];
|
|
80
|
+
const t10 = invalid || void 0;
|
|
81
|
+
const t11 = disabled || void 0;
|
|
82
|
+
let t12;
|
|
83
|
+
if ($[16] !== isOpen || $[17] !== onBlur) {
|
|
84
|
+
t12 = () => {
|
|
85
|
+
if (!isOpen) onBlur?.();
|
|
86
|
+
};
|
|
87
|
+
$[16] = isOpen;
|
|
88
|
+
$[17] = onBlur;
|
|
89
|
+
$[18] = t12;
|
|
90
|
+
} else t12 = $[18];
|
|
91
|
+
let t13;
|
|
92
|
+
if ($[19] !== parsed) {
|
|
93
|
+
t13 = parsed ? { backgroundColor: parsed } : void 0;
|
|
94
|
+
$[19] = parsed;
|
|
95
|
+
$[20] = t13;
|
|
96
|
+
} else t13 = $[20];
|
|
97
|
+
let t14;
|
|
98
|
+
if ($[21] !== t13) {
|
|
99
|
+
t14 = /* @__PURE__ */ jsx("span", {
|
|
100
|
+
"aria-hidden": "true",
|
|
101
|
+
className: "box-border size-5 shrink-0 rounded-sm border border-line-strong bg-subtle",
|
|
102
|
+
style: t13
|
|
103
|
+
});
|
|
104
|
+
$[21] = t13;
|
|
105
|
+
$[22] = t14;
|
|
106
|
+
} else t14 = $[22];
|
|
107
|
+
const t15 = !parsed && "text-fg-tertiary";
|
|
108
|
+
let t16;
|
|
109
|
+
if ($[23] !== t15) {
|
|
110
|
+
t16 = cn("min-w-0 flex-1 truncate text-start", t15);
|
|
111
|
+
$[23] = t15;
|
|
112
|
+
$[24] = t16;
|
|
113
|
+
} else t16 = $[24];
|
|
114
|
+
let t17;
|
|
115
|
+
if ($[25] !== parsed || $[26] !== shown) {
|
|
116
|
+
t17 = parsed ? /* @__PURE__ */ jsx("bdi", {
|
|
117
|
+
dir: "ltr",
|
|
118
|
+
children: parsed
|
|
119
|
+
}) : shown;
|
|
120
|
+
$[25] = parsed;
|
|
121
|
+
$[26] = shown;
|
|
122
|
+
$[27] = t17;
|
|
123
|
+
} else t17 = $[27];
|
|
124
|
+
let t18;
|
|
125
|
+
if ($[28] !== t16 || $[29] !== t17 || $[30] !== valueId) {
|
|
126
|
+
t18 = /* @__PURE__ */ jsx("span", {
|
|
127
|
+
id: valueId,
|
|
128
|
+
className: t16,
|
|
129
|
+
children: t17
|
|
130
|
+
});
|
|
131
|
+
$[28] = t16;
|
|
132
|
+
$[29] = t17;
|
|
133
|
+
$[30] = valueId;
|
|
134
|
+
$[31] = t18;
|
|
135
|
+
} else t18 = $[31];
|
|
136
|
+
let t19;
|
|
137
|
+
if ($[32] !== disabled || $[33] !== nameProps || $[34] !== t10 || $[35] !== t11 || $[36] !== t12 || $[37] !== t14 || $[38] !== t18 || $[39] !== t7 || $[40] !== t8 || $[41] !== t9 || $[42] !== triggerRef) {
|
|
138
|
+
t19 = /* @__PURE__ */ jsxs(Popover.Trigger, {
|
|
139
|
+
ref: triggerRef,
|
|
140
|
+
...t7,
|
|
141
|
+
disabled,
|
|
142
|
+
...nameProps,
|
|
143
|
+
...t8,
|
|
144
|
+
className: t9,
|
|
145
|
+
"data-invalid": t10,
|
|
146
|
+
"data-disabled": t11,
|
|
147
|
+
onBlur: t12,
|
|
148
|
+
children: [t14, t18]
|
|
149
|
+
});
|
|
150
|
+
$[32] = disabled;
|
|
151
|
+
$[33] = nameProps;
|
|
152
|
+
$[34] = t10;
|
|
153
|
+
$[35] = t11;
|
|
154
|
+
$[36] = t12;
|
|
155
|
+
$[37] = t14;
|
|
156
|
+
$[38] = t18;
|
|
157
|
+
$[39] = t7;
|
|
158
|
+
$[40] = t8;
|
|
159
|
+
$[41] = t9;
|
|
160
|
+
$[42] = triggerRef;
|
|
161
|
+
$[43] = t19;
|
|
162
|
+
} else t19 = $[43];
|
|
163
|
+
const t20 = labels.choose;
|
|
164
|
+
let t21;
|
|
165
|
+
let t22;
|
|
166
|
+
if ($[44] === Symbol.for("react.memo_cache_sentinel")) {
|
|
167
|
+
t21 = () => popupRef.current?.querySelector("[data-initial-focus]") ?? true;
|
|
168
|
+
t22 = cn(popup, "w-64 p-3");
|
|
169
|
+
$[44] = t21;
|
|
170
|
+
$[45] = t22;
|
|
171
|
+
} else {
|
|
172
|
+
t21 = $[44];
|
|
173
|
+
t22 = $[45];
|
|
174
|
+
}
|
|
175
|
+
let t23;
|
|
176
|
+
if ($[46] !== labels || $[47] !== onValueChange || $[48] !== parsed || $[49] !== swatches) {
|
|
177
|
+
t23 = /* @__PURE__ */ jsx(ColorPanel, {
|
|
178
|
+
value: parsed,
|
|
179
|
+
labels,
|
|
180
|
+
swatches,
|
|
181
|
+
onChange: onValueChange
|
|
182
|
+
});
|
|
183
|
+
$[46] = labels;
|
|
184
|
+
$[47] = onValueChange;
|
|
185
|
+
$[48] = parsed;
|
|
186
|
+
$[49] = swatches;
|
|
187
|
+
$[50] = t23;
|
|
188
|
+
} else t23 = $[50];
|
|
189
|
+
let t24;
|
|
190
|
+
if ($[51] !== labels.choose || $[52] !== t23) {
|
|
191
|
+
t24 = /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, {
|
|
192
|
+
className: positioner,
|
|
193
|
+
align: "start",
|
|
194
|
+
sideOffset: 4,
|
|
195
|
+
collisionPadding: 8,
|
|
196
|
+
children: /* @__PURE__ */ jsx(Popover.Popup, {
|
|
197
|
+
ref: popupRef,
|
|
198
|
+
"aria-label": t20,
|
|
199
|
+
initialFocus: t21,
|
|
200
|
+
className: t22,
|
|
201
|
+
children: t23
|
|
202
|
+
})
|
|
203
|
+
}) });
|
|
204
|
+
$[51] = labels.choose;
|
|
205
|
+
$[52] = t23;
|
|
206
|
+
$[53] = t24;
|
|
207
|
+
} else t24 = $[53];
|
|
208
|
+
let t25;
|
|
209
|
+
if ($[54] !== isOpen || $[55] !== t19 || $[56] !== t24 || $[57] !== t6) {
|
|
210
|
+
t25 = /* @__PURE__ */ jsxs(Popover.Root, {
|
|
211
|
+
open: isOpen,
|
|
212
|
+
onOpenChange: t6,
|
|
213
|
+
children: [t19, t24]
|
|
214
|
+
});
|
|
215
|
+
$[54] = isOpen;
|
|
216
|
+
$[55] = t19;
|
|
217
|
+
$[56] = t24;
|
|
218
|
+
$[57] = t6;
|
|
219
|
+
$[58] = t25;
|
|
220
|
+
} else t25 = $[58];
|
|
221
|
+
return t25;
|
|
222
|
+
};
|
|
223
|
+
var ColorPanel = (t0) => {
|
|
224
|
+
const $ = c(74);
|
|
225
|
+
const { value, labels, swatches, onChange } = t0;
|
|
226
|
+
let t1;
|
|
227
|
+
if ($[0] !== value) {
|
|
228
|
+
t1 = () => (value ? hexToHsv(value) : null) ?? {
|
|
229
|
+
h: 0,
|
|
230
|
+
s: 0,
|
|
231
|
+
v: 100
|
|
232
|
+
};
|
|
233
|
+
$[0] = value;
|
|
234
|
+
$[1] = t1;
|
|
235
|
+
} else t1 = $[1];
|
|
236
|
+
const [state, setState] = useState(t1);
|
|
237
|
+
const view = value && value !== hsvToHex(state) ? hexToHsv(value) ?? state : state;
|
|
238
|
+
const [hexDraft, setHexDraft] = useState(null);
|
|
239
|
+
const area = useRef(null);
|
|
240
|
+
let t2;
|
|
241
|
+
if ($[2] !== onChange || $[3] !== setHexDraft) {
|
|
242
|
+
t2 = (next) => {
|
|
243
|
+
setState(next);
|
|
244
|
+
setHexDraft(null);
|
|
245
|
+
onChange(hsvToHex(next));
|
|
246
|
+
};
|
|
247
|
+
$[2] = onChange;
|
|
248
|
+
$[3] = setHexDraft;
|
|
249
|
+
$[4] = t2;
|
|
250
|
+
} else t2 = $[4];
|
|
251
|
+
const set = t2;
|
|
252
|
+
const moveTo = (event) => {
|
|
253
|
+
const box = area.current?.getBoundingClientRect();
|
|
254
|
+
if (!box || box.width === 0 || box.height === 0) return;
|
|
255
|
+
set({
|
|
256
|
+
h: view.h,
|
|
257
|
+
s: clamp((event.clientX - box.left) / box.width * 100, 0, 100),
|
|
258
|
+
v: clamp((1 - (event.clientY - box.top) / box.height) * 100, 0, 100)
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
const onAreaKey = (event_0) => {
|
|
262
|
+
const step = event_0.shiftKey ? KEY_STEP_LARGE : KEY_STEP;
|
|
263
|
+
const change = {
|
|
264
|
+
ArrowLeft: [-step, 0],
|
|
265
|
+
ArrowRight: [step, 0],
|
|
266
|
+
ArrowUp: [0, step],
|
|
267
|
+
ArrowDown: [0, -step]
|
|
268
|
+
}[event_0.key];
|
|
269
|
+
if (!change) return;
|
|
270
|
+
event_0.preventDefault();
|
|
271
|
+
set({
|
|
272
|
+
h: view.h,
|
|
273
|
+
s: clamp(view.s + change[0], 0, 100),
|
|
274
|
+
v: clamp(view.v + change[1], 0, 100)
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
const hex = hsvToHex(view);
|
|
278
|
+
let t3;
|
|
279
|
+
if ($[5] !== hexDraft) {
|
|
280
|
+
t3 = hexDraft !== null && parseHex(hexDraft) === null;
|
|
281
|
+
$[5] = hexDraft;
|
|
282
|
+
$[6] = t3;
|
|
283
|
+
} else t3 = $[6];
|
|
284
|
+
const hexIsInvalid = t3;
|
|
285
|
+
const commitHex = (text) => {
|
|
286
|
+
const next_0 = parseHex(text);
|
|
287
|
+
if (next_0) {
|
|
288
|
+
const hsv = hexToHsv(next_0);
|
|
289
|
+
if (hsv) set(next_0 === hex ? view : hsv);
|
|
290
|
+
}
|
|
291
|
+
setHexDraft(null);
|
|
292
|
+
};
|
|
293
|
+
let t4;
|
|
294
|
+
if ($[7] !== swatches) {
|
|
295
|
+
t4 = new Set((swatches ?? []).map(_temp).filter(_temp2));
|
|
296
|
+
$[7] = swatches;
|
|
297
|
+
$[8] = t4;
|
|
298
|
+
} else t4 = $[8];
|
|
299
|
+
let t5;
|
|
300
|
+
if ($[9] !== t4) {
|
|
301
|
+
t5 = [...t4];
|
|
302
|
+
$[9] = t4;
|
|
303
|
+
$[10] = t5;
|
|
304
|
+
} else t5 = $[10];
|
|
305
|
+
const swatchColors = t5;
|
|
306
|
+
const T0 = DirectionProvider;
|
|
307
|
+
const t6 = "ltr";
|
|
308
|
+
const t7 = "ltr";
|
|
309
|
+
const t8 = "flex flex-col gap-3";
|
|
310
|
+
const t9 = "slider";
|
|
311
|
+
const t10 = 0;
|
|
312
|
+
const t11 = "";
|
|
313
|
+
const t12 = labels.area;
|
|
314
|
+
const t13 = 0;
|
|
315
|
+
const t14 = 100;
|
|
316
|
+
const t15 = Math.round(view.s);
|
|
317
|
+
const t16 = labels.areaValue(Math.round(view.s), Math.round(view.v));
|
|
318
|
+
const t17 = `hsl(${String(view.h)} 100% 50%)`;
|
|
319
|
+
let t18;
|
|
320
|
+
if ($[11] !== t17) {
|
|
321
|
+
t18 = {
|
|
322
|
+
backgroundColor: t17,
|
|
323
|
+
backgroundImage: "linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)"
|
|
324
|
+
};
|
|
325
|
+
$[11] = t17;
|
|
326
|
+
$[12] = t18;
|
|
327
|
+
} else t18 = $[12];
|
|
328
|
+
let t19;
|
|
329
|
+
let t20;
|
|
330
|
+
if ($[13] !== moveTo) {
|
|
331
|
+
t19 = (event_1) => {
|
|
332
|
+
event_1.currentTarget.setPointerCapture(event_1.pointerId);
|
|
333
|
+
event_1.currentTarget.focus();
|
|
334
|
+
moveTo(event_1);
|
|
335
|
+
};
|
|
336
|
+
t20 = (event_2) => {
|
|
337
|
+
if (event_2.currentTarget.hasPointerCapture(event_2.pointerId)) moveTo(event_2);
|
|
338
|
+
};
|
|
339
|
+
$[13] = moveTo;
|
|
340
|
+
$[14] = t19;
|
|
341
|
+
$[15] = t20;
|
|
342
|
+
} else {
|
|
343
|
+
t19 = $[14];
|
|
344
|
+
t20 = $[15];
|
|
345
|
+
}
|
|
346
|
+
const t21 = `${String(view.s)}%`;
|
|
347
|
+
const t22 = `${String(view.v)}%`;
|
|
348
|
+
let t23;
|
|
349
|
+
if ($[16] !== hex || $[17] !== t21 || $[18] !== t22) {
|
|
350
|
+
t23 = /* @__PURE__ */ jsx("span", {
|
|
351
|
+
"aria-hidden": "true",
|
|
352
|
+
className: "pointer-events-none absolute size-4 -translate-x-1/2 translate-y-1/2 rounded-full border-2 border-white shadow-md ring-1 ring-black/30",
|
|
353
|
+
style: {
|
|
354
|
+
left: t21,
|
|
355
|
+
bottom: t22,
|
|
356
|
+
backgroundColor: hex
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
$[16] = hex;
|
|
360
|
+
$[17] = t21;
|
|
361
|
+
$[18] = t22;
|
|
362
|
+
$[19] = t23;
|
|
363
|
+
} else t23 = $[19];
|
|
364
|
+
let t24;
|
|
365
|
+
if ($[20] !== labels.area || $[21] !== onAreaKey || $[22] !== t15 || $[23] !== t16 || $[24] !== t18 || $[25] !== t19 || $[26] !== t20 || $[27] !== t23) {
|
|
366
|
+
t24 = /* @__PURE__ */ jsx("div", {
|
|
367
|
+
ref: area,
|
|
368
|
+
role: t9,
|
|
369
|
+
tabIndex: t10,
|
|
370
|
+
"data-initial-focus": t11,
|
|
371
|
+
"aria-label": t12,
|
|
372
|
+
"aria-valuemin": t13,
|
|
373
|
+
"aria-valuemax": t14,
|
|
374
|
+
"aria-valuenow": t15,
|
|
375
|
+
"aria-valuetext": t16,
|
|
376
|
+
className: "relative h-36 w-full cursor-crosshair touch-none rounded-md outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-page",
|
|
377
|
+
style: t18,
|
|
378
|
+
onPointerDown: t19,
|
|
379
|
+
onPointerMove: t20,
|
|
380
|
+
onKeyDown: onAreaKey,
|
|
381
|
+
children: t23
|
|
382
|
+
});
|
|
383
|
+
$[20] = labels.area;
|
|
384
|
+
$[21] = onAreaKey;
|
|
385
|
+
$[22] = t15;
|
|
386
|
+
$[23] = t16;
|
|
387
|
+
$[24] = t18;
|
|
388
|
+
$[25] = t19;
|
|
389
|
+
$[26] = t20;
|
|
390
|
+
$[27] = t23;
|
|
391
|
+
$[28] = t24;
|
|
392
|
+
} else t24 = $[28];
|
|
393
|
+
let t25;
|
|
394
|
+
if ($[29] !== view.h) {
|
|
395
|
+
t25 = Math.round(view.h);
|
|
396
|
+
$[29] = view.h;
|
|
397
|
+
$[30] = t25;
|
|
398
|
+
} else t25 = $[30];
|
|
399
|
+
let t26;
|
|
400
|
+
if ($[31] !== set || $[32] !== view) {
|
|
401
|
+
t26 = (next_1) => {
|
|
402
|
+
set({
|
|
403
|
+
...view,
|
|
404
|
+
h: next_1
|
|
405
|
+
});
|
|
406
|
+
};
|
|
407
|
+
$[31] = set;
|
|
408
|
+
$[32] = view;
|
|
409
|
+
$[33] = t26;
|
|
410
|
+
} else t26 = $[33];
|
|
411
|
+
let t27;
|
|
412
|
+
if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
|
|
413
|
+
t27 = { backgroundImage: HUE_GRADIENT };
|
|
414
|
+
$[34] = t27;
|
|
415
|
+
} else t27 = $[34];
|
|
416
|
+
const t28 = labels.hue;
|
|
417
|
+
let t29;
|
|
418
|
+
if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
|
|
419
|
+
t29 = cn(SLIDER_THUMB, "cursor-grab data-dragging:cursor-grabbing");
|
|
420
|
+
$[35] = t29;
|
|
421
|
+
} else t29 = $[35];
|
|
422
|
+
let t30;
|
|
423
|
+
if ($[36] !== labels.hue) {
|
|
424
|
+
t30 = /* @__PURE__ */ jsx(Slider.Control, {
|
|
425
|
+
className: "flex w-full touch-none items-center py-1.5 select-none",
|
|
426
|
+
children: /* @__PURE__ */ jsx(Slider.Track, {
|
|
427
|
+
className: "relative h-2.5 w-full rounded-pill",
|
|
428
|
+
style: t27,
|
|
429
|
+
children: /* @__PURE__ */ jsx(Slider.Thumb, {
|
|
430
|
+
"aria-label": t28,
|
|
431
|
+
className: t29
|
|
432
|
+
})
|
|
433
|
+
})
|
|
434
|
+
});
|
|
435
|
+
$[36] = labels.hue;
|
|
436
|
+
$[37] = t30;
|
|
437
|
+
} else t30 = $[37];
|
|
438
|
+
let t31;
|
|
439
|
+
if ($[38] !== t25 || $[39] !== t26 || $[40] !== t30) {
|
|
440
|
+
t31 = /* @__PURE__ */ jsx(Slider.Root, {
|
|
441
|
+
value: t25,
|
|
442
|
+
onValueChange: t26,
|
|
443
|
+
min: 0,
|
|
444
|
+
max: 360,
|
|
445
|
+
step: 1,
|
|
446
|
+
largeStep: 10,
|
|
447
|
+
children: t30
|
|
448
|
+
});
|
|
449
|
+
$[38] = t25;
|
|
450
|
+
$[39] = t26;
|
|
451
|
+
$[40] = t30;
|
|
452
|
+
$[41] = t31;
|
|
453
|
+
} else t31 = $[41];
|
|
454
|
+
let t32;
|
|
455
|
+
if ($[42] === Symbol.for("react.memo_cache_sentinel")) {
|
|
456
|
+
t32 = fieldControl({ size: "small" });
|
|
457
|
+
$[42] = t32;
|
|
458
|
+
} else t32 = $[42];
|
|
459
|
+
const t33 = hexIsInvalid || void 0;
|
|
460
|
+
const t34 = labels.hex;
|
|
461
|
+
const t35 = hexIsInvalid || void 0;
|
|
462
|
+
let t36;
|
|
463
|
+
if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
|
|
464
|
+
t36 = cn(fieldInput, "font-medium tabular-nums");
|
|
465
|
+
$[43] = t36;
|
|
466
|
+
} else t36 = $[43];
|
|
467
|
+
const t37 = hexDraft ?? hex;
|
|
468
|
+
let t38;
|
|
469
|
+
if ($[44] !== commitHex || $[45] !== setHexDraft) {
|
|
470
|
+
t38 = (event_3) => {
|
|
471
|
+
const text_0 = event_3.target.value;
|
|
472
|
+
setHexDraft(text_0);
|
|
473
|
+
if (/^#?[0-9a-f]{6}$/i.test(text_0.trim())) commitHex(text_0);
|
|
474
|
+
};
|
|
475
|
+
$[44] = commitHex;
|
|
476
|
+
$[45] = setHexDraft;
|
|
477
|
+
$[46] = t38;
|
|
478
|
+
} else t38 = $[46];
|
|
479
|
+
let t39;
|
|
480
|
+
let t40;
|
|
481
|
+
if ($[47] !== commitHex || $[48] !== hex || $[49] !== hexDraft) {
|
|
482
|
+
t39 = (event_4) => {
|
|
483
|
+
if (event_4.nativeEvent.isComposing || event_4.keyCode === 229) return;
|
|
484
|
+
if (event_4.key === "Enter") {
|
|
485
|
+
event_4.preventDefault();
|
|
486
|
+
commitHex(hexDraft ?? hex);
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
t40 = () => {
|
|
490
|
+
commitHex(hexDraft ?? hex);
|
|
491
|
+
};
|
|
492
|
+
$[47] = commitHex;
|
|
493
|
+
$[48] = hex;
|
|
494
|
+
$[49] = hexDraft;
|
|
495
|
+
$[50] = t39;
|
|
496
|
+
$[51] = t40;
|
|
497
|
+
} else {
|
|
498
|
+
t39 = $[50];
|
|
499
|
+
t40 = $[51];
|
|
500
|
+
}
|
|
501
|
+
let t41;
|
|
502
|
+
if ($[52] !== labels.hex || $[53] !== t35 || $[54] !== t37 || $[55] !== t38 || $[56] !== t39 || $[57] !== t40) {
|
|
503
|
+
t41 = /* @__PURE__ */ jsx("input", {
|
|
504
|
+
type: "text",
|
|
505
|
+
"aria-label": t34,
|
|
506
|
+
"aria-invalid": t35,
|
|
507
|
+
spellCheck: false,
|
|
508
|
+
autoComplete: "off",
|
|
509
|
+
className: t36,
|
|
510
|
+
value: t37,
|
|
511
|
+
onChange: t38,
|
|
512
|
+
onKeyDown: t39,
|
|
513
|
+
onBlur: t40
|
|
514
|
+
});
|
|
515
|
+
$[52] = labels.hex;
|
|
516
|
+
$[53] = t35;
|
|
517
|
+
$[54] = t37;
|
|
518
|
+
$[55] = t38;
|
|
519
|
+
$[56] = t39;
|
|
520
|
+
$[57] = t40;
|
|
521
|
+
$[58] = t41;
|
|
522
|
+
} else t41 = $[58];
|
|
523
|
+
let t42;
|
|
524
|
+
if ($[59] !== t33 || $[60] !== t41) {
|
|
525
|
+
t42 = /* @__PURE__ */ jsx("div", {
|
|
526
|
+
className: t32,
|
|
527
|
+
"data-invalid": t33,
|
|
528
|
+
children: t41
|
|
529
|
+
});
|
|
530
|
+
$[59] = t33;
|
|
531
|
+
$[60] = t41;
|
|
532
|
+
$[61] = t42;
|
|
533
|
+
} else t42 = $[61];
|
|
534
|
+
let t43;
|
|
535
|
+
if ($[62] !== commitHex || $[63] !== hex || $[64] !== swatchColors) {
|
|
536
|
+
t43 = swatchColors.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
537
|
+
className: "flex flex-wrap gap-1.5",
|
|
538
|
+
children: swatchColors.map((color_0) => /* @__PURE__ */ jsx("button", {
|
|
539
|
+
type: "button",
|
|
540
|
+
"aria-label": color_0,
|
|
541
|
+
"aria-pressed": color_0 === hex,
|
|
542
|
+
className: "box-border size-6 cursor-pointer rounded-sm border border-line-strong p-0 outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-page aria-pressed:ring-2 aria-pressed:ring-primary aria-pressed:ring-offset-2 aria-pressed:ring-offset-surface",
|
|
543
|
+
style: { backgroundColor: color_0 },
|
|
544
|
+
onClick: () => {
|
|
545
|
+
commitHex(color_0);
|
|
546
|
+
}
|
|
547
|
+
}, color_0))
|
|
548
|
+
}) : null;
|
|
549
|
+
$[62] = commitHex;
|
|
550
|
+
$[63] = hex;
|
|
551
|
+
$[64] = swatchColors;
|
|
552
|
+
$[65] = t43;
|
|
553
|
+
} else t43 = $[65];
|
|
554
|
+
let t44;
|
|
555
|
+
if ($[66] !== t24 || $[67] !== t31 || $[68] !== t42 || $[69] !== t43) {
|
|
556
|
+
t44 = /* @__PURE__ */ jsxs("div", {
|
|
557
|
+
dir: t7,
|
|
558
|
+
className: t8,
|
|
559
|
+
children: [
|
|
560
|
+
t24,
|
|
561
|
+
t31,
|
|
562
|
+
t42,
|
|
563
|
+
t43
|
|
564
|
+
]
|
|
565
|
+
});
|
|
566
|
+
$[66] = t24;
|
|
567
|
+
$[67] = t31;
|
|
568
|
+
$[68] = t42;
|
|
569
|
+
$[69] = t43;
|
|
570
|
+
$[70] = t44;
|
|
571
|
+
} else t44 = $[70];
|
|
572
|
+
let t45;
|
|
573
|
+
if ($[71] !== T0 || $[72] !== t44) {
|
|
574
|
+
t45 = /* @__PURE__ */ jsx(T0, {
|
|
575
|
+
direction: t6,
|
|
576
|
+
children: t44
|
|
577
|
+
});
|
|
578
|
+
$[71] = T0;
|
|
579
|
+
$[72] = t44;
|
|
580
|
+
$[73] = t45;
|
|
581
|
+
} else t45 = $[73];
|
|
582
|
+
return t45;
|
|
583
|
+
};
|
|
584
|
+
function _temp(swatch) {
|
|
585
|
+
return parseHex(swatch);
|
|
586
|
+
}
|
|
587
|
+
function _temp2(color) {
|
|
588
|
+
return color !== null;
|
|
589
|
+
}
|
|
590
|
+
export { ColorPicker };
|
|
@@ -0,0 +1,21 @@
|
|
|
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 ColorPickerProps } from "./ColorPicker.js";
|
|
4
|
+
export type { ColorPickerLabels } from "./ColorPicker.js";
|
|
5
|
+
export interface FormColorFieldProps<TValues extends FieldValues> extends Omit<ColorPickerProps, "value" | "onValueChange" | "onBlur" | "invalid" | "triggerRef" | "id" | "aria-label" | "aria-labelledby" | "aria-describedby"> {
|
|
6
|
+
control: Control<TValues>;
|
|
7
|
+
name: FieldPath<TValues>;
|
|
8
|
+
label: string;
|
|
9
|
+
hint?: string | undefined;
|
|
10
|
+
required?: boolean | undefined;
|
|
11
|
+
/** Label above the control (default) or in a column beside it. */
|
|
12
|
+
orientation?: FieldOrientation | undefined;
|
|
13
|
+
/** Keep the label for assistive technology only. */
|
|
14
|
+
hideLabel?: boolean | undefined;
|
|
15
|
+
/** react-hook-form validation rules, for forms that do not use a schema resolver. */
|
|
16
|
+
rules?: ControllerProps<TValues, FieldPath<TValues>>["rules"] | undefined;
|
|
17
|
+
/** Turns a stored schema message (an i18n key) into display text. */
|
|
18
|
+
formatError?: ((message: string) => string) | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** A ColorPicker in a field, bound to a react-hook-form string field holding the colour as "#rrggbb" (or "" for none). */
|
|
21
|
+
export declare const FormColorField: <TValues extends FieldValues>({ control, name, label, hint, required, orientation, hideLabel, rules, formatError, disabled, size, ...pickerProps }: FormColorFieldProps<TValues>) => import("react").JSX.Element;
|