@forte-ui/react 1.0.0-alpha.1
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/README.md +240 -0
- package/dist/Accordion-9JunkjgY.js +111 -0
- package/dist/Alert-Cn_WUF3L.js +183 -0
- package/dist/AspectRatio-gSjpTVk-.js +39 -0
- package/dist/Avatar-BuitDluH.js +87 -0
- package/dist/Badge-sArNWMre.js +33 -0
- package/dist/Breadcrumb-Cq7tFtMX.js +170 -0
- package/dist/Button-AiyKnx5I.js +42 -0
- package/dist/ButtonGroup-C-CrwPXP.js +54 -0
- package/dist/Calendar-D7Q-QJ_e.js +503 -0
- package/dist/Checkbox-DfNbmOed.js +56 -0
- package/dist/Collapsible-D8UKiGip.js +86 -0
- package/dist/ColorPicker-B-eCI31W.js +612 -0
- package/dist/Combobox-D-BN-Tvp.js +302 -0
- package/dist/ContextMenu-D81uDaMG.js +44 -0
- package/dist/DatePicker-CfkMsaI-.js +192 -0
- package/dist/Dialog-_n8FpFs5.js +432 -0
- package/dist/Drawer-DKQF3OO7.js +158 -0
- package/dist/Field-FLFEO70D.js +58 -0
- package/dist/Fieldset-CYhh71Qt.js +28 -0
- package/dist/Form-DVPmW9XV.js +17 -0
- package/dist/Input-BgGWhO2q.js +18 -0
- package/dist/InputGroup-DsZyDXNn.js +89 -0
- package/dist/Menu-CKu9xE2h.js +261 -0
- package/dist/Menubar-Dax027Db.js +19 -0
- package/dist/NavList-DGvcIoJm.js +176 -0
- package/dist/NavigationMenu-BayQkUUb.js +209 -0
- package/dist/NumberField-P55SA8T7.js +191 -0
- package/dist/OTPField-CjHvBNSN.js +55 -0
- package/dist/Popover-BXhn2Wwt.js +142 -0
- package/dist/PreviewCard-Dnitrky0.js +99 -0
- package/dist/Progress-BlomDp-X.js +81 -0
- package/dist/ProgressCircle-j6XBl0fk.js +112 -0
- package/dist/Radio-BIcX4INJ.js +37 -0
- package/dist/Resizable-7nJJM97e.js +609 -0
- package/dist/ScrollArea-CBMGJ6hh.js +83 -0
- package/dist/Select-BP-zvdXm.js +237 -0
- package/dist/Separator-DewJBzaJ.js +21 -0
- package/dist/Skeleton-zr6ObCCq.js +79 -0
- package/dist/Slider-Bh8_cti1.js +104 -0
- package/dist/Spinner-BF0uD4hR.js +53 -0
- package/dist/Switch-OBewMMvM.js +39 -0
- package/dist/Tabs-LgkSbPSF.js +132 -0
- package/dist/Textarea-CqZJL41e.js +51 -0
- package/dist/Toast-BWayxAcd.js +304 -0
- package/dist/Toggle-BrhMnkF5.js +45 -0
- package/dist/Toolbar-OmOVCk3i.js +88 -0
- package/dist/Tooltip-CI4chsRw.js +101 -0
- package/dist/clsx-By2n9mTe.js +16 -0
- package/dist/cn.d.ts +8 -0
- package/dist/cn.js +11 -0
- package/dist/components/accordion/Accordion.d.ts +117 -0
- package/dist/components/accordion/Accordion.js +3 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/accordion/index.js +2 -0
- package/dist/components/alert/Alert.d.ts +167 -0
- package/dist/components/alert/Alert.js +3 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +2 -0
- package/dist/components/aspect-ratio/AspectRatio.d.ts +128 -0
- package/dist/components/aspect-ratio/AspectRatio.js +3 -0
- package/dist/components/aspect-ratio/index.d.ts +2 -0
- package/dist/components/aspect-ratio/index.js +2 -0
- package/dist/components/avatar/Avatar.d.ts +176 -0
- package/dist/components/avatar/Avatar.js +3 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +2 -0
- package/dist/components/badge/Badge.d.ts +117 -0
- package/dist/components/badge/Badge.js +3 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +2 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts +244 -0
- package/dist/components/breadcrumb/Breadcrumb.js +3 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.js +2 -0
- package/dist/components/button/Button.d.ts +73 -0
- package/dist/components/button/Button.js +3 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +2 -0
- package/dist/components/button-group/ButtonGroup.d.ts +113 -0
- package/dist/components/button-group/ButtonGroup.js +3 -0
- package/dist/components/button-group/index.d.ts +2 -0
- package/dist/components/button-group/index.js +2 -0
- package/dist/components/calendar/Calendar.d.ts +201 -0
- package/dist/components/calendar/Calendar.js +3 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.js +2 -0
- package/dist/components/checkbox/Checkbox.d.ts +130 -0
- package/dist/components/checkbox/Checkbox.js +3 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.js +2 -0
- package/dist/components/collapsible/Collapsible.d.ts +91 -0
- package/dist/components/collapsible/Collapsible.js +3 -0
- package/dist/components/collapsible/index.d.ts +2 -0
- package/dist/components/collapsible/index.js +2 -0
- package/dist/components/color-picker/ColorPicker.d.ts +553 -0
- package/dist/components/color-picker/ColorPicker.js +4 -0
- package/dist/components/color-picker/color.d.ts +102 -0
- package/dist/components/color-picker/color.js +249 -0
- package/dist/components/color-picker/index.d.ts +2 -0
- package/dist/components/color-picker/index.js +3 -0
- package/dist/components/combobox/Combobox.d.ts +553 -0
- package/dist/components/combobox/Combobox.js +3 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +2 -0
- package/dist/components/context-menu/ContextMenu.d.ts +103 -0
- package/dist/components/context-menu/ContextMenu.js +3 -0
- package/dist/components/context-menu/index.d.ts +3 -0
- package/dist/components/context-menu/index.js +2 -0
- package/dist/components/date-picker/DatePicker.d.ts +268 -0
- package/dist/components/date-picker/DatePicker.js +3 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.js +2 -0
- package/dist/components/dialog/Dialog.d.ts +567 -0
- package/dist/components/dialog/Dialog.js +3 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dialog/index.js +2 -0
- package/dist/components/drawer/Drawer.d.ts +351 -0
- package/dist/components/drawer/Drawer.js +3 -0
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +2 -0
- package/dist/components/field/Field.d.ts +170 -0
- package/dist/components/field/Field.js +3 -0
- package/dist/components/field/index.d.ts +2 -0
- package/dist/components/field/index.js +2 -0
- package/dist/components/fieldset/Fieldset.d.ts +60 -0
- package/dist/components/fieldset/Fieldset.js +3 -0
- package/dist/components/fieldset/index.d.ts +2 -0
- package/dist/components/fieldset/index.js +2 -0
- package/dist/components/form/Form.d.ts +76 -0
- package/dist/components/form/Form.js +3 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.js +2 -0
- package/dist/components/input/Input.d.ts +67 -0
- package/dist/components/input/Input.js +3 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/index.js +2 -0
- package/dist/components/input-group/InputGroup.d.ts +214 -0
- package/dist/components/input-group/InputGroup.js +3 -0
- package/dist/components/input-group/index.d.ts +2 -0
- package/dist/components/input-group/index.js +2 -0
- package/dist/components/menu/Menu.d.ts +587 -0
- package/dist/components/menu/Menu.js +3 -0
- package/dist/components/menu/index.d.ts +2 -0
- package/dist/components/menu/index.js +2 -0
- package/dist/components/menubar/Menubar.d.ts +104 -0
- package/dist/components/menubar/Menubar.js +3 -0
- package/dist/components/menubar/index.d.ts +2 -0
- package/dist/components/menubar/index.js +2 -0
- package/dist/components/nav-list/NavList.d.ts +290 -0
- package/dist/components/nav-list/NavList.js +3 -0
- package/dist/components/nav-list/index.d.ts +2 -0
- package/dist/components/nav-list/index.js +2 -0
- package/dist/components/navigation-menu/NavigationMenu.d.ts +483 -0
- package/dist/components/navigation-menu/NavigationMenu.js +3 -0
- package/dist/components/navigation-menu/index.d.ts +2 -0
- package/dist/components/navigation-menu/index.js +2 -0
- package/dist/components/number-field/NumberField.d.ts +303 -0
- package/dist/components/number-field/NumberField.js +3 -0
- package/dist/components/number-field/index.d.ts +2 -0
- package/dist/components/number-field/index.js +2 -0
- package/dist/components/otp-field/OTPField.d.ts +206 -0
- package/dist/components/otp-field/OTPField.js +3 -0
- package/dist/components/otp-field/index.d.ts +2 -0
- package/dist/components/otp-field/index.js +2 -0
- package/dist/components/popover/Popover.d.ts +394 -0
- package/dist/components/popover/Popover.js +3 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/index.js +2 -0
- package/dist/components/preview-card/PreviewCard.d.ts +307 -0
- package/dist/components/preview-card/PreviewCard.js +3 -0
- package/dist/components/preview-card/index.d.ts +2 -0
- package/dist/components/preview-card/index.js +2 -0
- package/dist/components/progress/Progress.d.ts +156 -0
- package/dist/components/progress/Progress.js +3 -0
- package/dist/components/progress/ProgressCircle.d.ts +166 -0
- package/dist/components/progress/ProgressCircle.js +3 -0
- package/dist/components/progress/index.d.ts +4 -0
- package/dist/components/progress/index.js +3 -0
- package/dist/components/radio/Radio.d.ts +144 -0
- package/dist/components/radio/Radio.js +3 -0
- package/dist/components/radio/index.d.ts +2 -0
- package/dist/components/radio/index.js +2 -0
- package/dist/components/resizable/Resizable.d.ts +211 -0
- package/dist/components/resizable/Resizable.js +3 -0
- package/dist/components/resizable/index.d.ts +2 -0
- package/dist/components/resizable/index.js +2 -0
- package/dist/components/scroll-area/ScrollArea.d.ts +113 -0
- package/dist/components/scroll-area/ScrollArea.js +3 -0
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/index.js +2 -0
- package/dist/components/select/Select.d.ts +345 -0
- package/dist/components/select/Select.js +3 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +2 -0
- package/dist/components/separator/Separator.d.ts +75 -0
- package/dist/components/separator/Separator.js +3 -0
- package/dist/components/separator/index.d.ts +2 -0
- package/dist/components/separator/index.js +2 -0
- package/dist/components/skeleton/Skeleton.d.ts +169 -0
- package/dist/components/skeleton/Skeleton.js +3 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +2 -0
- package/dist/components/slider/Slider.d.ts +208 -0
- package/dist/components/slider/Slider.js +3 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +2 -0
- package/dist/components/spinner/Spinner.d.ts +92 -0
- package/dist/components/spinner/Spinner.js +3 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/spinner/index.js +2 -0
- package/dist/components/switch/Switch.d.ts +80 -0
- package/dist/components/switch/Switch.js +3 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +2 -0
- package/dist/components/tabs/Tabs.d.ts +125 -0
- package/dist/components/tabs/Tabs.js +3 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/index.js +2 -0
- package/dist/components/textarea/Textarea.d.ts +119 -0
- package/dist/components/textarea/Textarea.js +3 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/index.js +2 -0
- package/dist/components/toast/Toast.d.ts +517 -0
- package/dist/components/toast/Toast.js +3 -0
- package/dist/components/toast/index.d.ts +2 -0
- package/dist/components/toast/index.js +2 -0
- package/dist/components/toggle/Toggle.d.ts +171 -0
- package/dist/components/toggle/Toggle.js +3 -0
- package/dist/components/toggle/index.d.ts +2 -0
- package/dist/components/toggle/index.js +2 -0
- package/dist/components/toolbar/Toolbar.d.ts +318 -0
- package/dist/components/toolbar/Toolbar.js +3 -0
- package/dist/components/toolbar/index.d.ts +2 -0
- package/dist/components/toolbar/index.js +2 -0
- package/dist/components/tooltip/Tooltip.d.ts +361 -0
- package/dist/components/tooltip/Tooltip.js +3 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +2 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +86 -0
- package/dist/styles/Accordion.css +1 -0
- package/dist/styles/Alert.css +1 -0
- package/dist/styles/AspectRatio.css +1 -0
- package/dist/styles/Avatar.css +1 -0
- package/dist/styles/Badge.css +1 -0
- package/dist/styles/Breadcrumb.css +1 -0
- package/dist/styles/Button.css +1 -0
- package/dist/styles/ButtonGroup.css +1 -0
- package/dist/styles/Calendar.css +1 -0
- package/dist/styles/Checkbox.css +1 -0
- package/dist/styles/Collapsible.css +1 -0
- package/dist/styles/ColorPicker.css +1 -0
- package/dist/styles/Combobox.css +1 -0
- package/dist/styles/ContextMenu.css +1 -0
- package/dist/styles/DatePicker.css +1 -0
- package/dist/styles/Dialog.css +1 -0
- package/dist/styles/Drawer.css +1 -0
- package/dist/styles/Field.css +1 -0
- package/dist/styles/Fieldset.css +1 -0
- package/dist/styles/Form.css +1 -0
- package/dist/styles/Input.css +1 -0
- package/dist/styles/InputGroup.css +1 -0
- package/dist/styles/Menu.css +1 -0
- package/dist/styles/Menubar.css +1 -0
- package/dist/styles/NavList.css +1 -0
- package/dist/styles/NavigationMenu.css +1 -0
- package/dist/styles/NumberField.css +1 -0
- package/dist/styles/OTPField.css +1 -0
- package/dist/styles/Popover.css +1 -0
- package/dist/styles/PreviewCard.css +1 -0
- package/dist/styles/Progress.css +1 -0
- package/dist/styles/ProgressCircle.css +1 -0
- package/dist/styles/Radio.css +1 -0
- package/dist/styles/Resizable.css +1 -0
- package/dist/styles/ScrollArea.css +1 -0
- package/dist/styles/Select.css +1 -0
- package/dist/styles/Separator.css +1 -0
- package/dist/styles/Skeleton.css +1 -0
- package/dist/styles/Slider.css +1 -0
- package/dist/styles/Spinner.css +1 -0
- package/dist/styles/Switch.css +1 -0
- package/dist/styles/Tabs.css +1 -0
- package/dist/styles/Textarea.css +1 -0
- package/dist/styles/Toast.css +1 -0
- package/dist/styles/Toggle.css +1 -0
- package/dist/styles/Toolbar.css +1 -0
- package/dist/styles/Tooltip.css +1 -0
- package/dist/styles/a11y.css +119 -0
- package/dist/styles/layers.css +39 -0
- package/dist/styles/motion.css +194 -0
- package/dist/styles/patterns.css +236 -0
- package/dist/styles/properties.css +62 -0
- package/dist/styles/reset.css +11 -0
- package/dist/styles/tailwind.css +281 -0
- package/dist/styles/theme.css +57 -0
- package/dist/styles/tokens.color.css +223 -0
- package/dist/styles/tokens.css +460 -0
- package/dist/tailwind-merge.d.ts +52 -0
- package/dist/tailwind-merge.js +52 -0
- package/docs-data/props.json +8047 -0
- package/docs-data/theming.json +9600 -0
- package/docs-data/tokens.json +4070 -0
- package/package.json +78 -0
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
import { Popover, PopoverPopupProps } from '../popover';
|
|
2
|
+
import { DEFAULT_SWATCHES, ColorPickerFormat, Hsva, Rgba } from './color';
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export type { ColorPickerFormat, Hsva, Rgba };
|
|
5
|
+
export { DEFAULT_SWATCHES };
|
|
6
|
+
/** What moved the colour. Handed to `onValueChange` and `onValueCommitted` so
|
|
7
|
+
* a consumer can tell a drag from a paste without watching the DOM. */
|
|
8
|
+
export type ColorPickerChangeReason = "area" | "hue" | "alpha" | "swatch" | "input" | "eye-dropper" | "format-change" | "none";
|
|
9
|
+
export interface ColorPickerChangeDetails {
|
|
10
|
+
/** The colour in the picker's internal model — hue survives here at zero
|
|
11
|
+
* saturation, where the string cannot carry it. */
|
|
12
|
+
hsva: Hsva;
|
|
13
|
+
/** The same colour as eight-bit sRGB, so a consumer never has to re-parse
|
|
14
|
+
* the string it was just handed. */
|
|
15
|
+
rgba: Rgba;
|
|
16
|
+
/** The notation `value` is written in. */
|
|
17
|
+
format: ColorPickerFormat;
|
|
18
|
+
/** What moved it. */
|
|
19
|
+
reason: ColorPickerChangeReason;
|
|
20
|
+
}
|
|
21
|
+
type PopoverRootProps = React.ComponentProps<typeof Popover.Root>;
|
|
22
|
+
export interface ColorPickerRootProps {
|
|
23
|
+
/**
|
|
24
|
+
* The selected colour, as a CSS colour string. Pass it with
|
|
25
|
+
* `onValueChange` to control the picker.
|
|
26
|
+
*
|
|
27
|
+
* Accepts `#hex` (3, 4, 6 or 8 digits), `rgb()`, `hsl()`, `oklch()`,
|
|
28
|
+
* `oklab()` and `transparent`, in both the legacy comma form and the modern
|
|
29
|
+
* space form. A string that cannot be read is ignored rather than throwing,
|
|
30
|
+
* so a half-typed value in your own state never blanks the picker. Named
|
|
31
|
+
* colours (`rebeccapurple`) are not accepted — see the docs page.
|
|
32
|
+
*/
|
|
33
|
+
value?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The colour the picker starts on when it is uncontrolled.
|
|
36
|
+
* @default "#000000"
|
|
37
|
+
*/
|
|
38
|
+
defaultValue?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Called on every change, including each frame of a drag. `value` is
|
|
41
|
+
* written in the current `format`; `details` carries the same colour as
|
|
42
|
+
* HSVA and RGBA, plus what moved it.
|
|
43
|
+
*/
|
|
44
|
+
onValueChange?: (value: string, details: ColorPickerChangeDetails) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Called when an interaction ENDS — pointer up, a keyboard step, a swatch
|
|
47
|
+
* press, a committed text entry. This is the one to persist from: a drag
|
|
48
|
+
* across the area fires `onValueChange` once per pointer move and this once.
|
|
49
|
+
*/
|
|
50
|
+
onValueCommitted?: (value: string, details: ColorPickerChangeDetails) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Which notation `value` is written in. Pass it with `onFormatChange` to
|
|
53
|
+
* control the format.
|
|
54
|
+
*/
|
|
55
|
+
format?: ColorPickerFormat;
|
|
56
|
+
/**
|
|
57
|
+
* The notation the picker starts in.
|
|
58
|
+
* @default "hex"
|
|
59
|
+
*/
|
|
60
|
+
defaultFormat?: ColorPickerFormat;
|
|
61
|
+
/**
|
|
62
|
+
* Called when the format changes. Switching format also re-emits the
|
|
63
|
+
* current colour through `onValueChange` with reason `"format-change"`, so
|
|
64
|
+
* a controlled `value` never disagrees with the notation on screen.
|
|
65
|
+
*/
|
|
66
|
+
onFormatChange?: (format: ColorPickerFormat) => void;
|
|
67
|
+
/**
|
|
68
|
+
* The notations `ColorPicker.Format` offers, in order. Narrow it to the one
|
|
69
|
+
* your app stores — a design tool that writes OKLCH has no use for a HEX
|
|
70
|
+
* option that silently rounds.
|
|
71
|
+
* @default ["hex", "rgb", "hsl", "oklch"]
|
|
72
|
+
*/
|
|
73
|
+
formats?: readonly ColorPickerFormat[];
|
|
74
|
+
/**
|
|
75
|
+
* Whether every part ignores interaction.
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
disabled?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Whether the popover is open when it first mounts. Only relevant when the
|
|
81
|
+
* picker is used with `ColorPicker.Trigger` and `ColorPicker.Popup`.
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
defaultOpen?: PopoverRootProps["defaultOpen"];
|
|
85
|
+
/**
|
|
86
|
+
* Whether the popover is currently open. Pass it with `onOpenChange` to
|
|
87
|
+
* control the popover.
|
|
88
|
+
*/
|
|
89
|
+
open?: PopoverRootProps["open"];
|
|
90
|
+
/**
|
|
91
|
+
* Called when the popover wants to open or close.
|
|
92
|
+
*/
|
|
93
|
+
onOpenChange?: PopoverRootProps["onOpenChange"];
|
|
94
|
+
/**
|
|
95
|
+
* Whether the popover takes the page over while it is open. See
|
|
96
|
+
* `Popover.Root`'s own `modal` for the three settings.
|
|
97
|
+
* @default false
|
|
98
|
+
*/
|
|
99
|
+
modal?: PopoverRootProps["modal"];
|
|
100
|
+
/**
|
|
101
|
+
* The picker's parts.
|
|
102
|
+
*/
|
|
103
|
+
children?: React.ReactNode;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Owns the colour and the format, and renders no DOM element of its own — so
|
|
107
|
+
* it takes neither `className` nor `ref`.
|
|
108
|
+
*
|
|
109
|
+
* It also renders a `Popover.Root`, which is what lets `ColorPicker.Trigger`
|
|
110
|
+
* and `ColorPicker.Popup` exist without the consumer wiring a popover by hand.
|
|
111
|
+
* A picker built out of `ColorPicker.Panel` alone simply never uses it: the
|
|
112
|
+
* popover root renders nothing until a trigger and a popup are present.
|
|
113
|
+
*
|
|
114
|
+
* ```tsx
|
|
115
|
+
* <ColorPicker.Root defaultValue="#7c3aed">
|
|
116
|
+
* <ColorPicker.Trigger>Brand colour</ColorPicker.Trigger>
|
|
117
|
+
* <ColorPicker.Popup>
|
|
118
|
+
* <ColorPicker.Area />
|
|
119
|
+
* <ColorPicker.HueSlider />
|
|
120
|
+
* <ColorPicker.Row>
|
|
121
|
+
* <ColorPicker.Format />
|
|
122
|
+
* <ColorPicker.Input />
|
|
123
|
+
* </ColorPicker.Row>
|
|
124
|
+
* </ColorPicker.Popup>
|
|
125
|
+
* </ColorPicker.Root>
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export declare function ColorPickerRoot({ value, defaultValue, onValueChange, onValueCommitted, format: formatProp, defaultFormat, onFormatChange, formats, disabled, defaultOpen, open, onOpenChange, modal, children, }: ColorPickerRootProps): React.JSX.Element;
|
|
129
|
+
export interface ColorPickerTriggerProps extends Omit<React.ComponentPropsWithoutRef<"button">, "className" | "color"> {
|
|
130
|
+
/**
|
|
131
|
+
* Hide the built-in swatch, for a trigger that shows the colour some other
|
|
132
|
+
* way — a filled button, an icon that inherits it.
|
|
133
|
+
* @default false
|
|
134
|
+
*/
|
|
135
|
+
hideSwatch?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* The trigger's visible label. The current colour is announced after it, so
|
|
138
|
+
* a trigger with no children is still named.
|
|
139
|
+
*/
|
|
140
|
+
children?: React.ReactNode;
|
|
141
|
+
/**
|
|
142
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
143
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
144
|
+
*/
|
|
145
|
+
className?: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The button that opens the picker. Renders a `<button>` showing the current
|
|
149
|
+
* colour as a swatch, followed by whatever children you give it.
|
|
150
|
+
*
|
|
151
|
+
* The colour is also announced, in a visually hidden span: colour is the one
|
|
152
|
+
* thing a swatch cannot convey to a screen reader, and a trigger reading only
|
|
153
|
+
* "Brand colour" leaves out the entire answer.
|
|
154
|
+
*/
|
|
155
|
+
export declare const ColorPickerTrigger: React.ForwardRefExoticComponent<ColorPickerTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
156
|
+
export interface ColorPickerPopupProps extends Omit<PopoverPopupProps, "className" | "children"> {
|
|
157
|
+
/**
|
|
158
|
+
* Render the wedge pointing back at the trigger.
|
|
159
|
+
*
|
|
160
|
+
* A boolean here where `Popover` wants a child element, because this
|
|
161
|
+
* component's children are the picker's own parts and an `Arrow` mixed in
|
|
162
|
+
* among them would be layout, not chrome. `ColorPicker.Arrow` is still
|
|
163
|
+
* exported for the rare popup that composes its own header.
|
|
164
|
+
* @default true
|
|
165
|
+
*/
|
|
166
|
+
arrow?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* The picker's parts.
|
|
169
|
+
*/
|
|
170
|
+
children?: React.ReactNode;
|
|
171
|
+
/**
|
|
172
|
+
* Additional class name(s) for the inner panel — the element that owns the
|
|
173
|
+
* padding and the column layout.
|
|
174
|
+
*/
|
|
175
|
+
panelClassName?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Additional class name(s) for the popup surface. Applied after the
|
|
178
|
+
* internal styles so consumer utilities (e.g. Tailwind) win without needing
|
|
179
|
+
* `!important`.
|
|
180
|
+
*/
|
|
181
|
+
className?: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The picker on a popover surface, anchored to `ColorPicker.Trigger`.
|
|
185
|
+
*
|
|
186
|
+
* Wraps `Popover.Popup` and takes all of its props — `side`, `align`,
|
|
187
|
+
* `sideOffset`, `initialFocus` and the rest — so placement is tuned the same
|
|
188
|
+
* way it is on a popover.
|
|
189
|
+
*/
|
|
190
|
+
export declare const ColorPickerPopup: React.ForwardRefExoticComponent<Omit<ColorPickerPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
191
|
+
/** The wedge pointing back at the trigger. `ColorPicker.Popup` renders one by
|
|
192
|
+
* default; this is here for a popup that turns `arrow` off and places its own. */
|
|
193
|
+
export declare const ColorPickerArrow: React.ForwardRefExoticComponent<Omit<import('../popover').PopoverArrowProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
194
|
+
export interface ColorPickerPanelProps extends Omit<React.ComponentPropsWithoutRef<"div">, "className"> {
|
|
195
|
+
/**
|
|
196
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
197
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
198
|
+
*/
|
|
199
|
+
className?: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The picker laid out in the page rather than in a popover. Renders a `<div>`
|
|
203
|
+
* as a column, with the same padding, surface and width as
|
|
204
|
+
* `ColorPicker.Popup`'s inner panel — the two share one rule, so a picker
|
|
205
|
+
* moved from one to the other does not change shape.
|
|
206
|
+
*/
|
|
207
|
+
export declare const ColorPickerPanel: React.ForwardRefExoticComponent<ColorPickerPanelProps & React.RefAttributes<HTMLDivElement>>;
|
|
208
|
+
export interface ColorPickerRowProps extends Omit<React.ComponentPropsWithoutRef<"div">, "className"> {
|
|
209
|
+
/**
|
|
210
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
211
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
212
|
+
*/
|
|
213
|
+
className?: string;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The compact control row: eyedropper, preview, format and text field sitting
|
|
217
|
+
* on one line.
|
|
218
|
+
*
|
|
219
|
+
* A plain `<div>` rather than a Base UI part, the way `Popover.Footer` is. It
|
|
220
|
+
* exists because that row is the piece of chrome every second picker grows,
|
|
221
|
+
* and left to each consumer it is re-invented with a different gap each time —
|
|
222
|
+
* one that stops the text field from shrinking below its content and pushing
|
|
223
|
+
* the panel wider than the popup it sits in.
|
|
224
|
+
*/
|
|
225
|
+
export declare const ColorPickerRow: React.ForwardRefExoticComponent<ColorPickerRowProps & React.RefAttributes<HTMLDivElement>>;
|
|
226
|
+
export interface ColorPickerAreaProps extends Omit<React.ComponentPropsWithoutRef<"div">, "className" | "onChange"> {
|
|
227
|
+
/**
|
|
228
|
+
* Accessible name for the horizontal axis.
|
|
229
|
+
* @default "Saturation"
|
|
230
|
+
*/
|
|
231
|
+
saturationLabel?: string;
|
|
232
|
+
/**
|
|
233
|
+
* Accessible name for the vertical axis.
|
|
234
|
+
* @default "Brightness"
|
|
235
|
+
*/
|
|
236
|
+
brightnessLabel?: string;
|
|
237
|
+
/**
|
|
238
|
+
* How far one arrow key moves each axis, as a fraction of the axis.
|
|
239
|
+
* `Shift` multiplies it by ten, as it does on the sliders.
|
|
240
|
+
* @default 0.01
|
|
241
|
+
*/
|
|
242
|
+
step?: number;
|
|
243
|
+
/**
|
|
244
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
245
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
246
|
+
*/
|
|
247
|
+
className?: string;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The saturation/brightness canvas — the part that makes this a colour picker
|
|
251
|
+
* rather than a swatch list. Renders a `<div>` with a draggable thumb and two
|
|
252
|
+
* nested `<input type="range">`.
|
|
253
|
+
*
|
|
254
|
+
* The two inputs are the whole accessibility story. A 2D field has no ARIA
|
|
255
|
+
* role of its own, so it is expressed as what it actually is: two ranges that
|
|
256
|
+
* happen to share a thumb. Each is a real slider to assistive technology and
|
|
257
|
+
* to the keyboard — arrow keys, Home, End and Page Up/Down all work without
|
|
258
|
+
* this component implementing any of them — and an arrow key across the axes
|
|
259
|
+
* moves focus to the other input, so the value that changes is the value that
|
|
260
|
+
* gets announced.
|
|
261
|
+
*
|
|
262
|
+
* The canvas does NOT mirror under RTL, and that is deliberate: it is a
|
|
263
|
+
* picture of a colour space, not a line of text, and the hue that sits on the
|
|
264
|
+
* left of every other colour tool in the world should not move because the
|
|
265
|
+
* surrounding paragraph runs the other way. The hue and alpha rails DO mirror,
|
|
266
|
+
* because they are sliders and a slider's start follows the writing direction.
|
|
267
|
+
*/
|
|
268
|
+
export declare const ColorPickerArea: React.ForwardRefExoticComponent<ColorPickerAreaProps & React.RefAttributes<HTMLDivElement>>;
|
|
269
|
+
export interface ColorPickerHueSliderProps extends Omit<React.ComponentPropsWithoutRef<"div">, "className"> {
|
|
270
|
+
/**
|
|
271
|
+
* Accessible name for the rail.
|
|
272
|
+
* @default "Hue"
|
|
273
|
+
*/
|
|
274
|
+
label?: string;
|
|
275
|
+
/**
|
|
276
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
277
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
278
|
+
*/
|
|
279
|
+
className?: string;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* The hue rail — 0° to 360°, one degree per arrow key and ten per Page Up.
|
|
283
|
+
*
|
|
284
|
+
* Hue is the axis the canvas cannot show, since the canvas is a slice through
|
|
285
|
+
* one hue. Rendering an `Area` without this leaves the user stuck in whichever
|
|
286
|
+
* hue the value arrived in.
|
|
287
|
+
*/
|
|
288
|
+
export declare function ColorPickerHueSlider({ label, className, style, ...props }: ColorPickerHueSliderProps): React.JSX.Element;
|
|
289
|
+
export interface ColorPickerAlphaSliderProps extends Omit<React.ComponentPropsWithoutRef<"div">, "className"> {
|
|
290
|
+
/**
|
|
291
|
+
* Accessible name for the rail.
|
|
292
|
+
* @default "Opacity"
|
|
293
|
+
*/
|
|
294
|
+
label?: string;
|
|
295
|
+
/**
|
|
296
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
297
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
298
|
+
*/
|
|
299
|
+
className?: string;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* The opacity rail — 0% to 100% over a checkerboard.
|
|
303
|
+
*
|
|
304
|
+
* Rendering it is what turns alpha on: the picker omits alpha from every
|
|
305
|
+
* format while the colour is fully opaque, so a picker without this rail emits
|
|
306
|
+
* `#7c3aed` rather than `#7c3aedff` and needs no prop to say so. A
|
|
307
|
+
* `defaultValue` that already carries alpha keeps it either way.
|
|
308
|
+
*/
|
|
309
|
+
export declare function ColorPickerAlphaSlider({ label, className, style, ...props }: ColorPickerAlphaSliderProps): React.JSX.Element;
|
|
310
|
+
export interface ColorPickerSwatchesProps extends Omit<React.ComponentPropsWithoutRef<"div">, "className" | "color"> {
|
|
311
|
+
/**
|
|
312
|
+
* The palette, as CSS colour strings. Anything `value` accepts works here,
|
|
313
|
+
* including translucent colours.
|
|
314
|
+
* @default DEFAULT_SWATCHES
|
|
315
|
+
*/
|
|
316
|
+
colors?: readonly string[];
|
|
317
|
+
/**
|
|
318
|
+
* How many swatches per row. Also the arrow-key stride, so Up and Down move
|
|
319
|
+
* between rows rather than by one.
|
|
320
|
+
* @default 8
|
|
321
|
+
*/
|
|
322
|
+
columns?: number;
|
|
323
|
+
/**
|
|
324
|
+
* Accessible name for the group.
|
|
325
|
+
* @default "Colour swatches"
|
|
326
|
+
*/
|
|
327
|
+
label?: string;
|
|
328
|
+
/**
|
|
329
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
330
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
331
|
+
*/
|
|
332
|
+
className?: string;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* A grid of preset colours. Renders a `<div>` with `role="radiogroup"`.
|
|
336
|
+
*
|
|
337
|
+
* Radio semantics, not a row of buttons, because that is what the control
|
|
338
|
+
* actually is: a set of mutually exclusive options where at most one is
|
|
339
|
+
* current. It buys the whole keyboard convention with it — one tab stop for
|
|
340
|
+
* the group, arrow keys between swatches, and selection following focus — so a
|
|
341
|
+
* twenty-four colour palette costs a keyboard user one Tab instead of
|
|
342
|
+
* twenty-four.
|
|
343
|
+
*
|
|
344
|
+
* The colours come from `colors`; children are not read. That is what lets the
|
|
345
|
+
* group know its own order, which is what arrow keys and the single tab stop
|
|
346
|
+
* are computed from. For a palette you want to build element by element, use
|
|
347
|
+
* `ColorPicker.Swatch` on its own — outside a group each swatch is an
|
|
348
|
+
* independent toggle.
|
|
349
|
+
*/
|
|
350
|
+
export declare const ColorPickerSwatches: React.ForwardRefExoticComponent<ColorPickerSwatchesProps & React.RefAttributes<HTMLDivElement>>;
|
|
351
|
+
export interface ColorPickerSwatchProps extends Omit<React.ComponentPropsWithoutRef<"button">, "className" | "value" | "color"> {
|
|
352
|
+
/**
|
|
353
|
+
* The colour this swatch sets, as a CSS colour string.
|
|
354
|
+
*/
|
|
355
|
+
value: string;
|
|
356
|
+
/**
|
|
357
|
+
* Accessible name. Defaults to the colour string, which is the only thing
|
|
358
|
+
* that is reliably true about it — a name of your own ("Brand primary") is
|
|
359
|
+
* better wherever you have one.
|
|
360
|
+
*/
|
|
361
|
+
label?: string;
|
|
362
|
+
/**
|
|
363
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
364
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
365
|
+
*/
|
|
366
|
+
className?: string;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* One preset colour. Renders a `<button>`.
|
|
370
|
+
*
|
|
371
|
+
* Inside `ColorPicker.Swatches` it is a radio in that group. On its own it is
|
|
372
|
+
* a toggle button carrying `aria-pressed` — a lone `role="radio"` would
|
|
373
|
+
* promise a group that does not exist.
|
|
374
|
+
*
|
|
375
|
+
* Selection is decided by comparing eight-bit colour, not strings, so a swatch
|
|
376
|
+
* written `#f00` is still shown as current when the value reads
|
|
377
|
+
* `rgb(255 0 0)`.
|
|
378
|
+
*/
|
|
379
|
+
export declare const ColorPickerSwatch: React.ForwardRefExoticComponent<ColorPickerSwatchProps & React.RefAttributes<HTMLButtonElement>>;
|
|
380
|
+
export interface ColorPickerPreviewProps extends Omit<React.ComponentPropsWithoutRef<"div">, "className" | "color"> {
|
|
381
|
+
/**
|
|
382
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
383
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
384
|
+
*/
|
|
385
|
+
className?: string;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* A chip filled with the current colour, over a checkerboard so a translucent
|
|
389
|
+
* value is legible. Renders a `<div>`.
|
|
390
|
+
*
|
|
391
|
+
* Decorative: `aria-hidden`, because the colour it shows is already announced
|
|
392
|
+
* by the trigger and readable in `ColorPicker.Input`, and a third announcement
|
|
393
|
+
* of the same value on every drag frame is noise.
|
|
394
|
+
*/
|
|
395
|
+
export declare const ColorPickerPreview: React.ForwardRefExoticComponent<ColorPickerPreviewProps & React.RefAttributes<HTMLDivElement>>;
|
|
396
|
+
export interface ColorPickerValueProps extends Omit<React.ComponentPropsWithoutRef<"span">, "className" | "children"> {
|
|
397
|
+
/**
|
|
398
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
399
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
400
|
+
*/
|
|
401
|
+
className?: string;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* The current colour as text, in the current format. Renders a `<span>` in the
|
|
405
|
+
* mono face with tabular figures, so the readout does not change width as the
|
|
406
|
+
* digits change under a drag.
|
|
407
|
+
*/
|
|
408
|
+
export declare const ColorPickerValue: React.ForwardRefExoticComponent<ColorPickerValueProps & React.RefAttributes<HTMLSpanElement>>;
|
|
409
|
+
export interface ColorPickerFormatProps {
|
|
410
|
+
/**
|
|
411
|
+
* Accessible name for the control.
|
|
412
|
+
* @default "Colour format"
|
|
413
|
+
*/
|
|
414
|
+
label?: string;
|
|
415
|
+
/**
|
|
416
|
+
* Additional class name(s) for the trigger. Applied after the internal
|
|
417
|
+
* styles so consumer utilities (e.g. Tailwind) win without needing
|
|
418
|
+
* `!important`.
|
|
419
|
+
*/
|
|
420
|
+
className?: string;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Picks the notation the value is written in, from the `formats` allowed on
|
|
424
|
+
* `ColorPicker.Root`. Composes this library's own `Select`.
|
|
425
|
+
*
|
|
426
|
+
* Changing it rewrites the value rather than the colour: the same colour comes
|
|
427
|
+
* back out as `#7c3aed`, `rgb(124 58 237)`, `hsl(262.1 83.3% 57.8%)` or
|
|
428
|
+
* `oklch(0.5413 0.2466 293.01)` — which is also why HEX rounds and the other
|
|
429
|
+
* three do not.
|
|
430
|
+
*/
|
|
431
|
+
export declare function ColorPickerFormatSelect({ label, className, }: ColorPickerFormatProps): React.JSX.Element;
|
|
432
|
+
export interface ColorPickerInputProps extends Omit<React.ComponentPropsWithoutRef<"input">, "className" | "value" | "defaultValue" | "type" | "onChange"> {
|
|
433
|
+
/**
|
|
434
|
+
* Accessible name for the field.
|
|
435
|
+
* @default "Colour value"
|
|
436
|
+
*/
|
|
437
|
+
label?: string;
|
|
438
|
+
/**
|
|
439
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
440
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
441
|
+
*/
|
|
442
|
+
className?: string;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* A text field holding the colour in the current format. Renders an `<input>`.
|
|
446
|
+
*
|
|
447
|
+
* It is the picker's precision instrument and its paste target — and, for
|
|
448
|
+
* anyone who cannot use a canvas at all, the route to an exact colour that the
|
|
449
|
+
* canvas is not.
|
|
450
|
+
*
|
|
451
|
+
* While it has focus the field keeps the text the user is typing, not the
|
|
452
|
+
* formatted value: rewriting `#7c3` to `#77cc33` mid-keystroke would move the
|
|
453
|
+
* caret and make the field impossible to type into. Every keystroke that
|
|
454
|
+
* parses is applied immediately, so the panel previews as you type; one that
|
|
455
|
+
* does not is left alone and marked `data-invalid`. Blur restores the
|
|
456
|
+
* canonical text, so an abandoned edit cannot leave the field disagreeing with
|
|
457
|
+
* the colour.
|
|
458
|
+
*/
|
|
459
|
+
export declare const ColorPickerInput: React.ForwardRefExoticComponent<ColorPickerInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
460
|
+
export interface ColorPickerEyeDropperProps extends Omit<React.ComponentPropsWithoutRef<"button">, "className"> {
|
|
461
|
+
/**
|
|
462
|
+
* Accessible name for the button.
|
|
463
|
+
* @default "Pick a colour from the screen"
|
|
464
|
+
*/
|
|
465
|
+
label?: string;
|
|
466
|
+
/**
|
|
467
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
468
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
469
|
+
*/
|
|
470
|
+
className?: string;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Samples a colour from anywhere on the screen, through the browser's
|
|
474
|
+
* EyeDropper API. Renders a `<button>` — or nothing at all where the API is
|
|
475
|
+
* missing, which today is Firefox and every browser on iOS.
|
|
476
|
+
*
|
|
477
|
+
* Rendering nothing is the point: this is a shortcut to a colour the rest of
|
|
478
|
+
* the picker can already reach, so its absence costs a user nothing, while a
|
|
479
|
+
* button that opens no eyedropper costs them a click and their confidence in
|
|
480
|
+
* the rest of the panel. The detection runs in an effect rather than during
|
|
481
|
+
* render because the server cannot know the answer, and guessing there is what
|
|
482
|
+
* produces a hydration mismatch.
|
|
483
|
+
*/
|
|
484
|
+
export declare const ColorPickerEyeDropper: React.ForwardRefExoticComponent<ColorPickerEyeDropperProps & React.RefAttributes<HTMLButtonElement>>;
|
|
485
|
+
export interface ColorPickerHiddenInputProps extends Omit<React.ComponentPropsWithoutRef<"input">, "type" | "value" | "onChange"> {
|
|
486
|
+
/**
|
|
487
|
+
* The field name the colour is submitted under.
|
|
488
|
+
*/
|
|
489
|
+
name: string;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Submits the colour with a form. Renders `<input type="hidden">`.
|
|
493
|
+
*
|
|
494
|
+
* Place it next to `ColorPicker.Trigger`, NOT inside `ColorPicker.Popup`. The
|
|
495
|
+
* popup is portalled to `<body>` and unmounted while it is closed, so a hidden
|
|
496
|
+
* input in there is outside the form's element tree even when it exists, and
|
|
497
|
+
* missing entirely by the time anything is submitted.
|
|
498
|
+
*/
|
|
499
|
+
export declare const ColorPickerHiddenInput: React.ForwardRefExoticComponent<ColorPickerHiddenInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
500
|
+
/**
|
|
501
|
+
* A colour picker: a saturation/brightness canvas, hue and opacity rails, a
|
|
502
|
+
* preset palette, an eyedropper and a text field that reads and writes four
|
|
503
|
+
* CSS notations.
|
|
504
|
+
*
|
|
505
|
+
* Base UI has no colour-picker primitive, so this one is built here — on
|
|
506
|
+
* `Popover` for the anchored surface and on Base UI's `Slider` for the two
|
|
507
|
+
* rails, which is where the keyboard, the pointer capture and the RTL flip
|
|
508
|
+
* come from.
|
|
509
|
+
*
|
|
510
|
+
* ```tsx
|
|
511
|
+
* <ColorPicker.Root defaultValue="#7c3aed">
|
|
512
|
+
* <ColorPicker.Trigger>Brand colour</ColorPicker.Trigger>
|
|
513
|
+
* <ColorPicker.Popup>
|
|
514
|
+
* <ColorPicker.Area />
|
|
515
|
+
* <ColorPicker.HueSlider />
|
|
516
|
+
* <ColorPicker.AlphaSlider />
|
|
517
|
+
* <ColorPicker.Swatches />
|
|
518
|
+
* <ColorPicker.Row>
|
|
519
|
+
* <ColorPicker.EyeDropper />
|
|
520
|
+
* <ColorPicker.Format />
|
|
521
|
+
* <ColorPicker.Input />
|
|
522
|
+
* </ColorPicker.Row>
|
|
523
|
+
* </ColorPicker.Popup>
|
|
524
|
+
* </ColorPicker.Root>
|
|
525
|
+
* ```
|
|
526
|
+
*
|
|
527
|
+
* Every part is opt-in. A picker that is nothing but a palette is
|
|
528
|
+
* `Root` + `Swatches`; one with no transparency simply leaves out
|
|
529
|
+
* `AlphaSlider`, and the value it emits has no alpha channel in it.
|
|
530
|
+
*
|
|
531
|
+
* Styling is driven by `data-*` attributes and `--forte-color-picker-*` custom
|
|
532
|
+
* properties, so it can be re-skinned from plain CSS or targeted with Tailwind
|
|
533
|
+
* arbitrary variants (`data-[selected]:...`) without wrapping.
|
|
534
|
+
*/
|
|
535
|
+
export declare const ColorPicker: {
|
|
536
|
+
Root: typeof ColorPickerRoot;
|
|
537
|
+
Trigger: React.ForwardRefExoticComponent<ColorPickerTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
538
|
+
Popup: React.ForwardRefExoticComponent<Omit<ColorPickerPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
539
|
+
Arrow: React.ForwardRefExoticComponent<Omit<import('../popover').PopoverArrowProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
540
|
+
Panel: React.ForwardRefExoticComponent<ColorPickerPanelProps & React.RefAttributes<HTMLDivElement>>;
|
|
541
|
+
Row: React.ForwardRefExoticComponent<ColorPickerRowProps & React.RefAttributes<HTMLDivElement>>;
|
|
542
|
+
Area: React.ForwardRefExoticComponent<ColorPickerAreaProps & React.RefAttributes<HTMLDivElement>>;
|
|
543
|
+
HueSlider: typeof ColorPickerHueSlider;
|
|
544
|
+
AlphaSlider: typeof ColorPickerAlphaSlider;
|
|
545
|
+
Swatches: React.ForwardRefExoticComponent<ColorPickerSwatchesProps & React.RefAttributes<HTMLDivElement>>;
|
|
546
|
+
Swatch: React.ForwardRefExoticComponent<ColorPickerSwatchProps & React.RefAttributes<HTMLButtonElement>>;
|
|
547
|
+
Preview: React.ForwardRefExoticComponent<ColorPickerPreviewProps & React.RefAttributes<HTMLDivElement>>;
|
|
548
|
+
Value: React.ForwardRefExoticComponent<ColorPickerValueProps & React.RefAttributes<HTMLSpanElement>>;
|
|
549
|
+
Format: typeof ColorPickerFormatSelect;
|
|
550
|
+
Input: React.ForwardRefExoticComponent<ColorPickerInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
551
|
+
EyeDropper: React.ForwardRefExoticComponent<ColorPickerEyeDropperProps & React.RefAttributes<HTMLButtonElement>>;
|
|
552
|
+
HiddenInput: React.ForwardRefExoticComponent<ColorPickerHiddenInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
553
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g, v as _ } from "../../ColorPicker-B-eCI31W.js";
|
|
3
|
+
import { DEFAULT_SWATCHES as v } from "./color.js";
|
|
4
|
+
export { h as ColorPicker, u as ColorPickerAlphaSlider, p as ColorPickerArea, s as ColorPickerArrow, t as ColorPickerEyeDropper, d as ColorPickerFormatSelect, m as ColorPickerHiddenInput, n as ColorPickerHueSlider, c as ColorPickerInput, g as ColorPickerPanel, r as ColorPickerPopup, i as ColorPickerPreview, f as ColorPickerRoot, l as ColorPickerRow, o as ColorPickerSwatch, a as ColorPickerSwatches, e as ColorPickerTrigger, _ as ColorPickerValue, v as DEFAULT_SWATCHES };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/** The notations `ColorPicker` can read back and write out. */
|
|
2
|
+
export type ColorPickerFormat = "hex" | "rgb" | "hsl" | "oklch";
|
|
3
|
+
/** The picker's internal model. `h` is degrees; `s`, `v` and `a` are 0-1. */
|
|
4
|
+
export interface Hsva {
|
|
5
|
+
h: number;
|
|
6
|
+
s: number;
|
|
7
|
+
v: number;
|
|
8
|
+
a: number;
|
|
9
|
+
}
|
|
10
|
+
/** Eight-bit sRGB with an alpha channel. Channels are floats until output. */
|
|
11
|
+
export interface Rgba {
|
|
12
|
+
r: number;
|
|
13
|
+
g: number;
|
|
14
|
+
b: number;
|
|
15
|
+
a: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function hsvaToRgba({ h, s, v, a }: Hsva): Rgba;
|
|
18
|
+
export declare function rgbaToHsva({ r, g, b, a }: Rgba): Hsva;
|
|
19
|
+
export declare function hsvaToHsl({ h, s, v }: Hsva): {
|
|
20
|
+
h: number;
|
|
21
|
+
s: number;
|
|
22
|
+
l: number;
|
|
23
|
+
};
|
|
24
|
+
export declare function hslToHsv(h: number, s: number, l: number, a: number): Hsva;
|
|
25
|
+
export declare function rgbaToOklch({ r, g, b, a }: Rgba): {
|
|
26
|
+
l: number;
|
|
27
|
+
c: number;
|
|
28
|
+
h: number;
|
|
29
|
+
a: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* OKLCH to sRGB, gamut-mapped rather than clipped.
|
|
33
|
+
*
|
|
34
|
+
* `oklch(0.7 0.4 30)` names a colour no screen in this gamut can show. Clipping
|
|
35
|
+
* each channel at 0 and 1 — the obvious one-liner — changes the hue as well as
|
|
36
|
+
* the chroma, so an author's out-of-gamut orange arrives as a different colour
|
|
37
|
+
* family. Reducing chroma toward the achromatic axis at constant L and H keeps
|
|
38
|
+
* the hue the author asked for and gives up only the saturation the display
|
|
39
|
+
* could not have shown anyway. Sixteen bisection steps put the answer within
|
|
40
|
+
* ~6e-6 of the gamut boundary, well under an eight-bit step.
|
|
41
|
+
*/
|
|
42
|
+
export declare function oklchToRgba(l: number, c: number, h: number, a: number): Rgba;
|
|
43
|
+
/**
|
|
44
|
+
* Whether black or white reads better ON this colour — for the tick drawn
|
|
45
|
+
* inside a selected swatch and the ring around the area's thumb, both of which
|
|
46
|
+
* sit on colour the user chose and nothing else can be known about.
|
|
47
|
+
*
|
|
48
|
+
* Alpha is ignored on purpose: what a translucent swatch is composited over is
|
|
49
|
+
* whatever the checkerboard and the panel happen to be, which is not something
|
|
50
|
+
* this function can see, and the answer only changes near the middle of the
|
|
51
|
+
* ramp where either choice is legible.
|
|
52
|
+
*/
|
|
53
|
+
export declare function onColor({ r, g, b }: Rgba): "black" | "white";
|
|
54
|
+
/**
|
|
55
|
+
* Reads a CSS colour string into the picker's model.
|
|
56
|
+
*
|
|
57
|
+
* Accepts `#hex` (3, 4, 6 or 8 digits), `rgb()`/`rgba()`, `hsl()`/`hsla()`,
|
|
58
|
+
* `oklch()`, `oklab()` and the keyword `transparent`, in both the legacy
|
|
59
|
+
* comma-separated and the modern space-separated forms. Returns `null` for
|
|
60
|
+
* anything else — including named colours, which would need the full 148-entry
|
|
61
|
+
* CSS table to be shipped in every bundle that touches the picker, for input
|
|
62
|
+
* the picker itself never produces.
|
|
63
|
+
*
|
|
64
|
+
* `null` is a normal outcome, not an error: it is what the text field's
|
|
65
|
+
* `data-invalid` state is driven by while a value is half-typed.
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseColor(input: string): Hsva | null;
|
|
68
|
+
/**
|
|
69
|
+
* The picker's model as a CSS colour string.
|
|
70
|
+
*
|
|
71
|
+
* Alpha is omitted when the colour is fully opaque, in every format. That is
|
|
72
|
+
* the one rule worth stating out loud: it means a picker whose alpha rail was
|
|
73
|
+
* never touched — or never rendered — emits `#7c3aed` and not `#7c3aedff`, so
|
|
74
|
+
* an author who does not want alpha simply never gets any, without a prop
|
|
75
|
+
* saying so. `rgb()` also stays `rgb()` rather than becoming `rgba()`, which
|
|
76
|
+
* CSS Color 4 made an alias of it.
|
|
77
|
+
*
|
|
78
|
+
* Precision is set by what each notation can hold, not by taste: `hex` is
|
|
79
|
+
* eight-bit and exact, while `hsl` and `oklch` are rounded to the point where
|
|
80
|
+
* re-parsing lands on the same eight-bit colour. It is not what makes the
|
|
81
|
+
* picker's own round trip stable, though — see the note on `emittedRef` in
|
|
82
|
+
* ColorPicker.tsx.
|
|
83
|
+
*/
|
|
84
|
+
export declare function formatColor(hsva: Hsva, format: ColorPickerFormat): string;
|
|
85
|
+
/** `rgb()` with alpha — what the CSS custom properties carry, since a gradient
|
|
86
|
+
* stop and a preview swatch both need one string that is always valid. */
|
|
87
|
+
export declare function toCssColor(hsva: Hsva): string;
|
|
88
|
+
/** Two colours are the same swatch when they are the same eight-bit colour.
|
|
89
|
+
* Comparing the model instead would call `#000` and `hsl(200 0% 0%)` different,
|
|
90
|
+
* and neither the eye nor the output string can tell them apart. */
|
|
91
|
+
export declare function sameColor(a: Rgba, b: Rgba): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* The palette `ColorPicker.Swatches` falls back to: eight neutrals, eight warm
|
|
94
|
+
* hues and eight cool ones, in three rows of eight.
|
|
95
|
+
*
|
|
96
|
+
* Deliberately NOT built from the forte-ui ramp. Those tokens are `var()`
|
|
97
|
+
* references that resolve differently per theme scope and per light/dark, and a
|
|
98
|
+
* picker has to hand back a concrete colour the consumer can store — a swatch
|
|
99
|
+
* that means one thing in dark mode and another in light is not a colour, it is
|
|
100
|
+
* a variable. An app with a brand palette passes its own `colors`.
|
|
101
|
+
*/
|
|
102
|
+
export declare const DEFAULT_SWATCHES: readonly string[];
|