@teamofsilicons/silicon-ui 0.0.0-stage → 0.2.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/LICENSE +22 -0
- package/README.md +81 -2
- package/check.mjs +236 -0
- package/components/accordion/accordion.d.ts +13 -0
- package/components/accordion/accordion.js +35 -0
- package/components/accordion/accordion.module.css +15 -0
- package/components/action-button/action-button.d.ts +11 -0
- package/components/action-button/action-button.js +57 -0
- package/components/action-button/action-button.module.css +15 -0
- package/components/activity-heatmap/activity-heatmap.d.ts +37 -0
- package/components/activity-heatmap/activity-heatmap.js +303 -0
- package/components/activity-heatmap/activity-heatmap.module.css +83 -0
- package/components/alert/alert.d.ts +13 -0
- package/components/alert/alert.js +79 -0
- package/components/alert/alert.module.css +15 -0
- package/components/animated-counter/animated-counter.d.ts +13 -0
- package/components/animated-counter/animated-counter.js +73 -0
- package/components/animated-counter/animated-counter.module.css +12 -0
- package/components/announcement-bar/announcement-bar.d.ts +53 -0
- package/components/announcement-bar/announcement-bar.js +187 -0
- package/components/announcement-bar/announcement-bar.module.css +60 -0
- package/components/avatar/avatar.d.ts +8 -0
- package/components/avatar/avatar.js +18 -0
- package/components/avatar/avatar.module.css +60 -0
- package/components/avatar-group/avatar-group.d.ts +13 -0
- package/components/avatar-group/avatar-group.js +24 -0
- package/components/avatar-group/avatar-group.module.css +27 -0
- package/components/badge/badge.d.ts +10 -0
- package/components/badge/badge.js +66 -0
- package/components/badge/badge.module.css +52 -0
- package/components/bar-chart/bar-chart.d.ts +32 -0
- package/components/bar-chart/bar-chart.js +327 -0
- package/components/bar-chart/bar-chart.module.css +49 -0
- package/components/billing-toggle/billing-toggle.d.ts +35 -0
- package/components/billing-toggle/billing-toggle.js +83 -0
- package/components/billing-toggle/billing-toggle.module.css +139 -0
- package/components/bottom-sheet/bottom-sheet.d.ts +27 -0
- package/components/bottom-sheet/bottom-sheet.js +386 -0
- package/components/bottom-sheet/bottom-sheet.module.css +69 -0
- package/components/breadcrumb/breadcrumb.d.ts +13 -0
- package/components/breadcrumb/breadcrumb.js +19 -0
- package/components/breadcrumb/breadcrumb.module.css +12 -0
- package/components/brush-chart/brush-chart.d.ts +45 -0
- package/components/brush-chart/brush-chart.js +426 -0
- package/components/brush-chart/brush-chart.module.css +69 -0
- package/components/button/button.d.ts +10 -0
- package/components/button/button.js +97 -0
- package/components/button/button.module.css +39 -0
- package/components/button-group/button-group.d.ts +59 -0
- package/components/button-group/button-group.js +280 -0
- package/components/button-group/button-group.module.css +87 -0
- package/components/button-link/button-link.d.ts +24 -0
- package/components/button-link/button-link.js +11 -0
- package/components/button-link/button-link.module.css +7 -0
- package/components/calendar/calendar.d.ts +22 -0
- package/components/calendar/calendar.js +253 -0
- package/components/calendar/calendar.module.css +51 -0
- package/components/card/card.d.ts +19 -0
- package/components/card/card.js +108 -0
- package/components/card/card.module.css +51 -0
- package/components/card-stack/card-stack.d.ts +34 -0
- package/components/card-stack/card-stack.js +291 -0
- package/components/card-stack/card-stack.module.css +63 -0
- package/components/carousel/carousel.d.ts +28 -0
- package/components/carousel/carousel.js +332 -0
- package/components/carousel/carousel.module.css +42 -0
- package/components/chat-thread/chat-thread.d.ts +135 -0
- package/components/chat-thread/chat-thread.js +406 -0
- package/components/chat-thread/chat-thread.module.css +242 -0
- package/components/checkbox/checkbox.d.ts +7 -0
- package/components/checkbox/checkbox.js +23 -0
- package/components/checkbox/checkbox.module.css +15 -0
- package/components/chip-group/chip-group.d.ts +24 -0
- package/components/chip-group/chip-group.js +196 -0
- package/components/chip-group/chip-group.module.css +38 -0
- package/components/code-block/code-block.d.ts +11 -0
- package/components/code-block/code-block.js +133 -0
- package/components/code-block/code-block.module.css +43 -0
- package/components/color-picker/color-picker.d.ts +40 -0
- package/components/color-picker/color-picker.js +449 -0
- package/components/color-picker/color-picker.module.css +111 -0
- package/components/combobox/combobox.d.ts +19 -0
- package/components/combobox/combobox.js +167 -0
- package/components/combobox/combobox.module.css +28 -0
- package/components/command-palette/command-palette.d.ts +20 -0
- package/components/command-palette/command-palette.js +151 -0
- package/components/command-palette/command-palette.module.css +94 -0
- package/components/comment-thread/comment-thread.d.ts +120 -0
- package/components/comment-thread/comment-thread.js +343 -0
- package/components/comment-thread/comment-thread.module.css +195 -0
- package/components/confirm-morph/confirm-morph.d.ts +65 -0
- package/components/confirm-morph/confirm-morph.js +355 -0
- package/components/confirm-morph/confirm-morph.module.css +146 -0
- package/components/context-menu/context-menu.d.ts +18 -0
- package/components/context-menu/context-menu.js +148 -0
- package/components/context-menu/context-menu.module.css +17 -0
- package/components/copy-button/copy-button.d.ts +10 -0
- package/components/copy-button/copy-button.js +69 -0
- package/components/copy-button/copy-button.module.css +21 -0
- package/components/countdown/countdown.d.ts +31 -0
- package/components/countdown/countdown.js +177 -0
- package/components/countdown/countdown.module.css +49 -0
- package/components/date-picker/date-picker.d.ts +17 -0
- package/components/date-picker/date-picker.js +100 -0
- package/components/date-picker/date-picker.module.css +34 -0
- package/components/date-range-picker/date-range-picker.d.ts +44 -0
- package/components/date-range-picker/date-range-picker.js +534 -0
- package/components/date-range-picker/date-range-picker.module.css +214 -0
- package/components/dialog/dialog.d.ts +11 -0
- package/components/dialog/dialog.js +52 -0
- package/components/dialog/dialog.module.css +36 -0
- package/components/donut-chart/donut-chart.d.ts +46 -0
- package/components/donut-chart/donut-chart.js +382 -0
- package/components/donut-chart/donut-chart.module.css +48 -0
- package/components/drawer/drawer.d.ts +20 -0
- package/components/drawer/drawer.js +111 -0
- package/components/drawer/drawer.module.css +97 -0
- package/components/dropdown-menu/dropdown-menu.d.ts +16 -0
- package/components/dropdown-menu/dropdown-menu.js +39 -0
- package/components/dropdown-menu/dropdown-menu.module.css +38 -0
- package/components/elastic-slider/elastic-slider.d.ts +39 -0
- package/components/elastic-slider/elastic-slider.js +261 -0
- package/components/elastic-slider/elastic-slider.module.css +40 -0
- package/components/empty-state/empty-state.d.ts +12 -0
- package/components/empty-state/empty-state.js +69 -0
- package/components/empty-state/empty-state.module.css +13 -0
- package/components/expandable-card/expandable-card.d.ts +13 -0
- package/components/expandable-card/expandable-card.js +89 -0
- package/components/expandable-card/expandable-card.module.css +22 -0
- package/components/expanding-button-group/expanding-button-group.d.ts +41 -0
- package/components/expanding-button-group/expanding-button-group.js +258 -0
- package/components/expanding-button-group/expanding-button-group.module.css +44 -0
- package/components/expanding-search/expanding-search.d.ts +38 -0
- package/components/expanding-search/expanding-search.js +242 -0
- package/components/expanding-search/expanding-search.module.css +52 -0
- package/components/file-dropzone/file-dropzone.d.ts +44 -0
- package/components/file-dropzone/file-dropzone.js +379 -0
- package/components/file-dropzone/file-dropzone.module.css +115 -0
- package/components/file-upload/file-upload.d.ts +22 -0
- package/components/file-upload/file-upload.js +192 -0
- package/components/file-upload/file-upload.module.css +49 -0
- package/components/filter-toolbar/filter-toolbar.d.ts +48 -0
- package/components/filter-toolbar/filter-toolbar.js +446 -0
- package/components/filter-toolbar/filter-toolbar.module.css +70 -0
- package/components/floating-button-group/floating-button-group.d.ts +51 -0
- package/components/floating-button-group/floating-button-group.js +215 -0
- package/components/floating-button-group/floating-button-group.module.css +74 -0
- package/components/gauge/gauge.d.ts +18 -0
- package/components/gauge/gauge.js +101 -0
- package/components/gauge/gauge.module.css +22 -0
- package/components/hold-to-confirm/hold-to-confirm.d.ts +25 -0
- package/components/hold-to-confirm/hold-to-confirm.js +165 -0
- package/components/hold-to-confirm/hold-to-confirm.module.css +20 -0
- package/components/hover-card/hover-card.d.ts +38 -0
- package/components/hover-card/hover-card.js +145 -0
- package/components/hover-card/hover-card.module.css +20 -0
- package/components/image-compare/image-compare.d.ts +27 -0
- package/components/image-compare/image-compare.js +267 -0
- package/components/image-compare/image-compare.module.css +25 -0
- package/components/in-view-title/in-view-title.d.ts +17 -0
- package/components/in-view-title/in-view-title.js +70 -0
- package/components/in-view-title/in-view-title.module.css +13 -0
- package/components/inline-edit/inline-edit.d.ts +27 -0
- package/components/inline-edit/inline-edit.js +315 -0
- package/components/inline-edit/inline-edit.module.css +73 -0
- package/components/input/input.d.ts +7 -0
- package/components/input/input.js +60 -0
- package/components/input/input.module.css +22 -0
- package/components/json-viewer/json-viewer.d.ts +48 -0
- package/components/json-viewer/json-viewer.js +463 -0
- package/components/json-viewer/json-viewer.module.css +92 -0
- package/components/line-chart/line-chart.d.ts +58 -0
- package/components/line-chart/line-chart.js +383 -0
- package/components/line-chart/line-chart.module.css +60 -0
- package/components/mention-input/mention-input.d.ts +72 -0
- package/components/mention-input/mention-input.js +417 -0
- package/components/mention-input/mention-input.module.css +134 -0
- package/components/metric-card/metric-card.d.ts +8 -0
- package/components/metric-card/metric-card.js +44 -0
- package/components/metric-card/metric-card.module.css +18 -0
- package/components/money-input/money-input.d.ts +48 -0
- package/components/money-input/money-input.js +503 -0
- package/components/money-input/money-input.module.css +77 -0
- package/components/morph-select/morph-select.d.ts +50 -0
- package/components/morph-select/morph-select.js +395 -0
- package/components/morph-select/morph-select.module.css +88 -0
- package/components/multi-select/multi-select.d.ts +18 -0
- package/components/multi-select/multi-select.js +105 -0
- package/components/multi-select/multi-select.module.css +37 -0
- package/components/notification-center/notification-center.d.ts +24 -0
- package/components/notification-center/notification-center.js +146 -0
- package/components/notification-center/notification-center.module.css +79 -0
- package/components/number-field/number-field.d.ts +41 -0
- package/components/number-field/number-field.js +455 -0
- package/components/number-field/number-field.module.css +71 -0
- package/components/otp-input/otp-input.d.ts +13 -0
- package/components/otp-input/otp-input.js +129 -0
- package/components/otp-input/otp-input.module.css +28 -0
- package/components/pagination/pagination.d.ts +7 -0
- package/components/pagination/pagination.js +60 -0
- package/components/pagination/pagination.module.css +16 -0
- package/components/password-field/password-field.d.ts +14 -0
- package/components/password-field/password-field.js +51 -0
- package/components/password-field/password-field.module.css +27 -0
- package/components/password-strength/password-strength.d.ts +107 -0
- package/components/password-strength/password-strength.js +161 -0
- package/components/password-strength/password-strength.module.css +57 -0
- package/components/phone-input/phone-input.d.ts +73 -0
- package/components/phone-input/phone-input.js +612 -0
- package/components/phone-input/phone-input.module.css +98 -0
- package/components/popover/popover.d.ts +6 -0
- package/components/popover/popover.js +19 -0
- package/components/popover/popover.module.css +32 -0
- package/components/progress/progress.d.ts +8 -0
- package/components/progress/progress.js +42 -0
- package/components/progress/progress.module.css +1 -0
- package/components/radio-cards/radio-cards.d.ts +35 -0
- package/components/radio-cards/radio-cards.js +110 -0
- package/components/radio-cards/radio-cards.module.css +84 -0
- package/components/radio-group/radio-group.d.ts +13 -0
- package/components/radio-group/radio-group.js +55 -0
- package/components/radio-group/radio-group.module.css +30 -0
- package/components/resizable-panels/resizable-panels.d.ts +37 -0
- package/components/resizable-panels/resizable-panels.js +338 -0
- package/components/resizable-panels/resizable-panels.module.css +40 -0
- package/components/rich-text-editor/rich-text-editor.d.ts +55 -0
- package/components/rich-text-editor/rich-text-editor.js +1733 -0
- package/components/rich-text-editor/rich-text-editor.module.css +201 -0
- package/components/ridgeline/ridgeline.d.ts +37 -0
- package/components/ridgeline/ridgeline.js +346 -0
- package/components/ridgeline/ridgeline.module.css +58 -0
- package/components/scroll-area/scroll-area.d.ts +40 -0
- package/components/scroll-area/scroll-area.js +153 -0
- package/components/scroll-area/scroll-area.module.css +79 -0
- package/components/search-field/search-field.d.ts +7 -0
- package/components/search-field/search-field.js +20 -0
- package/components/search-field/search-field.module.css +17 -0
- package/components/segmented-control/segmented-control.d.ts +16 -0
- package/components/segmented-control/segmented-control.js +56 -0
- package/components/segmented-control/segmented-control.module.css +15 -0
- package/components/select/select.d.ts +15 -0
- package/components/select/select.js +36 -0
- package/components/select/select.module.css +35 -0
- package/components/shortcut-recorder/shortcut-recorder.d.ts +108 -0
- package/components/shortcut-recorder/shortcut-recorder.js +380 -0
- package/components/shortcut-recorder/shortcut-recorder.module.css +85 -0
- package/components/signature-pad/signature-pad.d.ts +72 -0
- package/components/signature-pad/signature-pad.js +450 -0
- package/components/signature-pad/signature-pad.module.css +84 -0
- package/components/skeleton/skeleton.d.ts +13 -0
- package/components/skeleton/skeleton.js +53 -0
- package/components/skeleton/skeleton.module.css +11 -0
- package/components/slider/slider.d.ts +45 -0
- package/components/slider/slider.js +347 -0
- package/components/slider/slider.module.css +45 -0
- package/components/slope-chart/slope-chart.d.ts +38 -0
- package/components/slope-chart/slope-chart.js +183 -0
- package/components/slope-chart/slope-chart.module.css +51 -0
- package/components/slot-text/slot-text.d.ts +26 -0
- package/components/slot-text/slot-text.js +119 -0
- package/components/slot-text/slot-text.module.css +19 -0
- package/components/sortable-data-table/sortable-data-table.d.ts +38 -0
- package/components/sortable-data-table/sortable-data-table.js +240 -0
- package/components/sortable-data-table/sortable-data-table.module.css +116 -0
- package/components/sparkline/sparkline.d.ts +19 -0
- package/components/sparkline/sparkline.js +239 -0
- package/components/sparkline/sparkline.module.css +26 -0
- package/components/split-button/split-button.d.ts +19 -0
- package/components/split-button/split-button.js +33 -0
- package/components/split-button/split-button.module.css +51 -0
- package/components/stepper/stepper.d.ts +36 -0
- package/components/stepper/stepper.js +108 -0
- package/components/stepper/stepper.module.css +74 -0
- package/components/streamgraph/streamgraph.d.ts +51 -0
- package/components/streamgraph/streamgraph.js +376 -0
- package/components/streamgraph/streamgraph.module.css +55 -0
- package/components/swipe-actions/swipe-actions.d.ts +35 -0
- package/components/swipe-actions/swipe-actions.js +330 -0
- package/components/swipe-actions/swipe-actions.module.css +64 -0
- package/components/switch/switch.d.ts +7 -0
- package/components/switch/switch.js +45 -0
- package/components/switch/switch.module.css +12 -0
- package/components/tabs/tabs.d.ts +8 -0
- package/components/tabs/tabs.js +138 -0
- package/components/tabs/tabs.module.css +27 -0
- package/components/tag-input/tag-input.d.ts +15 -0
- package/components/tag-input/tag-input.js +150 -0
- package/components/tag-input/tag-input.module.css +34 -0
- package/components/text-morph/text-morph.d.ts +13 -0
- package/components/text-morph/text-morph.js +69 -0
- package/components/text-morph/text-morph.module.css +8 -0
- package/components/text-reveal/text-reveal.d.ts +14 -0
- package/components/text-reveal/text-reveal.js +20 -0
- package/components/text-reveal/text-reveal.module.css +13 -0
- package/components/text-shimmer/text-shimmer.d.ts +18 -0
- package/components/text-shimmer/text-shimmer.js +90 -0
- package/components/text-shimmer/text-shimmer.module.css +9 -0
- package/components/textarea/textarea.d.ts +7 -0
- package/components/textarea/textarea.js +56 -0
- package/components/textarea/textarea.module.css +22 -0
- package/components/theme-switch/theme-switch.d.ts +11 -0
- package/components/theme-switch/theme-switch.js +37 -0
- package/components/theme-switch/theme-switch.module.css +31 -0
- package/components/time-picker/time-picker.d.ts +13 -0
- package/components/time-picker/time-picker.js +95 -0
- package/components/time-picker/time-picker.module.css +23 -0
- package/components/timeline/timeline.d.ts +47 -0
- package/components/timeline/timeline.js +171 -0
- package/components/timeline/timeline.module.css +51 -0
- package/components/toast/toast.d.ts +8 -0
- package/components/toast/toast.js +118 -0
- package/components/toast/toast.module.css +100 -0
- package/components/toast-stack/toast-stack.d.ts +57 -0
- package/components/toast-stack/toast-stack.js +399 -0
- package/components/toast-stack/toast-stack.module.css +61 -0
- package/components/tooltip/tooltip.d.ts +8 -0
- package/components/tooltip/tooltip.js +62 -0
- package/components/tooltip/tooltip.module.css +18 -0
- package/components/tree-view/tree-view.d.ts +17 -0
- package/components/tree-view/tree-view.js +147 -0
- package/components/tree-view/tree-view.module.css +22 -0
- package/components/treemap/treemap.d.ts +35 -0
- package/components/treemap/treemap.js +375 -0
- package/components/treemap/treemap.module.css +59 -0
- package/components/usage-meter/usage-meter.d.ts +24 -0
- package/components/usage-meter/usage-meter.js +296 -0
- package/components/usage-meter/usage-meter.module.css +61 -0
- package/components/user-menu/user-menu.d.ts +62 -0
- package/components/user-menu/user-menu.js +316 -0
- package/components/user-menu/user-menu.module.css +97 -0
- package/components/waffle-chart/waffle-chart.d.ts +39 -0
- package/components/waffle-chart/waffle-chart.js +244 -0
- package/components/waffle-chart/waffle-chart.module.css +52 -0
- package/components.json +1330 -0
- package/eslint.js +53 -0
- package/lib/escape.d.ts +19 -0
- package/lib/escape.js +50 -0
- package/lib/media.d.ts +353 -0
- package/lib/media.js +65 -0
- package/lib/menu-highlight.d.ts +28 -0
- package/lib/menu-highlight.js +43 -0
- package/lib/motion-tokens.d.ts +60 -0
- package/lib/motion-tokens.js +25 -0
- package/lib/return-focus.d.ts +9 -0
- package/lib/return-focus.js +53 -0
- package/lib/silicon-provider.d.ts +60 -0
- package/lib/silicon-provider.js +47 -0
- package/lib/use-copy-feedback.d.ts +8 -0
- package/lib/use-copy-feedback.js +36 -0
- package/lib/use-today.d.ts +2 -0
- package/lib/use-today.js +29 -0
- package/package.json +76 -4
- package/styles.css +218 -0
- package/styles.css.d.ts +1 -0
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useEffectEvent, useId, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
4
|
+
import { AnimatePresence, Reorder, animate, motion, useMotionValue, useReducedMotion, useTransform } from "motion/react";
|
|
5
|
+
import { Check, Pipette, Plus } from "lucide-react";
|
|
6
|
+
import { TextMorph } from "../text-morph/text-morph.js";
|
|
7
|
+
import { motionTokens } from "../../lib/motion-tokens.js";
|
|
8
|
+
import styles from "./color-picker.module.css";
|
|
9
|
+
const { spring, duration, ease, blur } = motionTokens;
|
|
10
|
+
const clamp = (value, min = 0, max = 1) => Math.min(max, Math.max(min, value));
|
|
11
|
+
const round = (value, digits = 0) => { const f = 10 ** digits; return Math.round(value * f) / f; };
|
|
12
|
+
const physical = (visualDuration, bounce) => {
|
|
13
|
+
const root = 2 * Math.PI / (visualDuration * 1.2);
|
|
14
|
+
return { type: "spring", stiffness: root * root, damping: 2 * (1 - bounce) * root, mass: 1, restDelta: .0005, restSpeed: .005 };
|
|
15
|
+
};
|
|
16
|
+
/** Thumbs chase the pointer on a quick spring with a little life, so a click lands with a soft settle and a drag trails by a hair. */
|
|
17
|
+
const thumbSpring = physical(.26, .22);
|
|
18
|
+
/** Under a finger or mouse drag the thumb stays glued to the pointer: a stiff spring with no bounce, so it never trails or wobbles. */
|
|
19
|
+
const dragSpring = physical(.1, 0);
|
|
20
|
+
const openSpring = physical(spring.morph.visualDuration, .1), closeSpring = physical(.3, 0);
|
|
21
|
+
const instant = { duration: 0 };
|
|
22
|
+
/* Color math. sRGB channels are 0 to 1. */
|
|
23
|
+
function hsvToRgb({ h, s, v, a }) {
|
|
24
|
+
const f = (n) => { const k = (n + h / 60) % 6; return v - v * s * Math.max(0, Math.min(k, 4 - k, 1)); };
|
|
25
|
+
return { r: f(5), g: f(3), b: f(1), a };
|
|
26
|
+
}
|
|
27
|
+
function rgbToHsv({ r, g, b, a }, hue = 0) {
|
|
28
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b), d = max - min;
|
|
29
|
+
let h = hue;
|
|
30
|
+
if (d > 1e-6) {
|
|
31
|
+
if (max === r)
|
|
32
|
+
h = 60 * (((g - b) / d) % 6);
|
|
33
|
+
else if (max === g)
|
|
34
|
+
h = 60 * ((b - r) / d + 2);
|
|
35
|
+
else
|
|
36
|
+
h = 60 * ((r - g) / d + 4);
|
|
37
|
+
if (h < 0)
|
|
38
|
+
h += 360;
|
|
39
|
+
}
|
|
40
|
+
return { h, s: max === 0 ? 0 : d / max, v: max, a };
|
|
41
|
+
}
|
|
42
|
+
function hslToRgb(h, s, l, a) {
|
|
43
|
+
const k = (n) => (n + h / 30) % 12, c = s * Math.min(l, 1 - l);
|
|
44
|
+
const f = (n) => l - c * Math.max(-1, Math.min(k(n) - 3, 9 - k(n), 1));
|
|
45
|
+
return { r: f(0), g: f(8), b: f(4), a };
|
|
46
|
+
}
|
|
47
|
+
function rgbToHsl({ r, g, b }, hue) {
|
|
48
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b), l = (max + min) / 2, d = max - min;
|
|
49
|
+
const s = d < 1e-6 ? 0 : d / (1 - Math.abs(2 * l - 1));
|
|
50
|
+
return { h: d < 1e-6 ? hue : rgbToHsv({ r, g, b, a: 1 }).h, s, l };
|
|
51
|
+
}
|
|
52
|
+
const toLinear = (c) => c <= .04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4;
|
|
53
|
+
const fromLinear = (c) => c <= .0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - .055;
|
|
54
|
+
function rgbToOklch({ r, g, b }, hue) {
|
|
55
|
+
const lr = toLinear(r), lg = toLinear(g), lb = toLinear(b);
|
|
56
|
+
const l = Math.cbrt(.4122214708 * lr + .5363325363 * lg + .0514459929 * lb);
|
|
57
|
+
const m = Math.cbrt(.2119034982 * lr + .6806995451 * lg + .1073969566 * lb);
|
|
58
|
+
const s = Math.cbrt(.0883024619 * lr + .2817188376 * lg + .6299787005 * lb);
|
|
59
|
+
const L = .2104542553 * l + .793617785 * m - .0040720468 * s;
|
|
60
|
+
const A = 1.9779984951 * l - 2.428592205 * m + .4505937099 * s;
|
|
61
|
+
const B = .0259040371 * l + .7827717662 * m - .808675766 * s;
|
|
62
|
+
const C = Math.hypot(A, B);
|
|
63
|
+
let H = Math.atan2(B, A) * 180 / Math.PI;
|
|
64
|
+
if (H < 0)
|
|
65
|
+
H += 360;
|
|
66
|
+
return { l: L, c: C, h: C < .0005 ? hue : H };
|
|
67
|
+
}
|
|
68
|
+
function oklchToRgb(L, C, H, a) {
|
|
69
|
+
const A = C * Math.cos(H * Math.PI / 180), B = C * Math.sin(H * Math.PI / 180);
|
|
70
|
+
const l = (L + .3963377774 * A + .2158037573 * B) ** 3;
|
|
71
|
+
const m = (L - .1055613458 * A - .0638541728 * B) ** 3;
|
|
72
|
+
const s = (L - .0894841775 * A - 1.291485548 * B) ** 3;
|
|
73
|
+
return {
|
|
74
|
+
r: clamp(fromLinear(4.0767416621 * l - 3.3077115913 * m + .2309699292 * s)),
|
|
75
|
+
g: clamp(fromLinear(-1.2684380046 * l + 2.6097574011 * m - .3413193965 * s)),
|
|
76
|
+
b: clamp(fromLinear(-.0041960863 * l - .7034186147 * m + 1.707614701 * s)),
|
|
77
|
+
a,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const byte = (c) => Math.round(clamp(c) * 255);
|
|
81
|
+
const hex2 = (c) => byte(c).toString(16).padStart(2, "0").toUpperCase();
|
|
82
|
+
export function toHex(hsva) {
|
|
83
|
+
const { r, g, b, a } = hsvToRgb(hsva);
|
|
84
|
+
return `#${hex2(r)}${hex2(g)}${hex2(b)}${a < .999 ? hex2(a) : ""}`;
|
|
85
|
+
}
|
|
86
|
+
function format(hsva, kind) {
|
|
87
|
+
const rgb = hsvToRgb(hsva);
|
|
88
|
+
const alpha = hsva.a < .999 ? ` / ${Math.round(hsva.a * 100)}%` : "";
|
|
89
|
+
if (kind === "hex")
|
|
90
|
+
return toHex(hsva);
|
|
91
|
+
if (kind === "rgb")
|
|
92
|
+
return `rgb(${byte(rgb.r)} ${byte(rgb.g)} ${byte(rgb.b)}${alpha})`;
|
|
93
|
+
if (kind === "hsl") {
|
|
94
|
+
const { h, s, l } = rgbToHsl(rgb, hsva.h);
|
|
95
|
+
return `hsl(${Math.round(h) % 360} ${Math.round(s * 100)}% ${Math.round(l * 100)}%${alpha})`;
|
|
96
|
+
}
|
|
97
|
+
const { l, c, h } = rgbToOklch(rgb, hsva.h);
|
|
98
|
+
return `oklch(${round(l * 100, 1)}% ${round(c, 3)} ${round(h, 1) % 360}${alpha})`;
|
|
99
|
+
}
|
|
100
|
+
const readAlpha = (text) => text === undefined ? 1 : text.endsWith("%") ? clamp(parseFloat(text) / 100) : clamp(parseFloat(text));
|
|
101
|
+
/** Reads hex, rgb(), hsl(), and oklch() in modern or comma syntax. Returns null for anything else. */
|
|
102
|
+
export function parseColor(input, hue = 0) {
|
|
103
|
+
const text = input.trim().toLowerCase();
|
|
104
|
+
let match = /^#?([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(text);
|
|
105
|
+
if (match) {
|
|
106
|
+
let digits = match[1];
|
|
107
|
+
if (digits.length <= 4)
|
|
108
|
+
digits = digits.split("").map(d => d + d).join("");
|
|
109
|
+
const n = (i) => parseInt(digits.slice(i, i + 2), 16) / 255;
|
|
110
|
+
return rgbToHsv({ r: n(0), g: n(2), b: n(4), a: digits.length === 8 ? n(6) : 1 }, hue);
|
|
111
|
+
}
|
|
112
|
+
match = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[/,]\s*([\d.]+%?))?\s*\)$/.exec(text);
|
|
113
|
+
if (match)
|
|
114
|
+
return rgbToHsv({ r: clamp(+match[1] / 255), g: clamp(+match[2] / 255), b: clamp(+match[3] / 255), a: readAlpha(match[4]) }, hue);
|
|
115
|
+
match = /^hsla?\(\s*([\d.]+)(?:deg)?[\s,]+([\d.]+)%?[\s,]+([\d.]+)%?(?:\s*[/,]\s*([\d.]+%?))?\s*\)$/.exec(text);
|
|
116
|
+
if (match) {
|
|
117
|
+
const h = +match[1] % 360;
|
|
118
|
+
const next = rgbToHsv(hslToRgb(h, clamp(+match[2] / 100), clamp(+match[3] / 100), readAlpha(match[4])), h);
|
|
119
|
+
return { ...next, h };
|
|
120
|
+
}
|
|
121
|
+
match = /^oklch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(?:deg)?(?:\s*\/\s*([\d.]+%?))?\s*\)$/.exec(text);
|
|
122
|
+
if (match) {
|
|
123
|
+
const L = match[2] ? +match[1] / 100 : +match[1];
|
|
124
|
+
return rgbToHsv(oklchToRgb(clamp(L), +match[3], +match[4], readAlpha(match[5])), hue);
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
/** WCAG contrast of a color, composited over the background, against that background. */
|
|
129
|
+
function contrast(hsva, background) {
|
|
130
|
+
const fg = hsvToRgb(hsva);
|
|
131
|
+
const mix = (c, bg) => c * fg.a + bg * (1 - fg.a);
|
|
132
|
+
const lum = (r, g, b) => .2126 * toLinear(r) + .7152 * toLinear(g) + .0722 * toLinear(b);
|
|
133
|
+
const a = lum(mix(fg.r, background.r), mix(fg.g, background.g), mix(fg.b, background.b)), b = lum(background.r, background.g, background.b);
|
|
134
|
+
return (Math.max(a, b) + .05) / (Math.min(a, b) + .05);
|
|
135
|
+
}
|
|
136
|
+
const level = (ratio) => ratio >= 7 ? "AAA" : ratio >= 4.5 ? "AA" : ratio >= 3 ? "AA large" : "Fails";
|
|
137
|
+
const formats = ["hex", "rgb", "hsl", "oklch"];
|
|
138
|
+
const formatNames = { hex: "Hex", rgb: "RGB", hsl: "HSL", oklch: "OKLCH" };
|
|
139
|
+
const subscribe = () => () => { };
|
|
140
|
+
function useHydrated() { return useSyncExternalStore(subscribe, () => true, () => false); }
|
|
141
|
+
function useEyeDropper() { return useSyncExternalStore(subscribe, () => "EyeDropper" in window, () => false); }
|
|
142
|
+
/** Springs a motion value to a new target, or jumps under reduced motion. Retargeting keeps the current velocity. */
|
|
143
|
+
function useFollow(target, reduced, dragging = false) {
|
|
144
|
+
const value = useMotionValue(target);
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (reduced) {
|
|
147
|
+
value.jump(target);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const controls = animate(value, target, dragging ? dragSpring : thumbSpring);
|
|
151
|
+
return () => controls.stop();
|
|
152
|
+
}, [dragging, reduced, target, value]);
|
|
153
|
+
return value;
|
|
154
|
+
}
|
|
155
|
+
/** Tracks a pointer drag over an element and reports its position as fractions of the element's box. */
|
|
156
|
+
function usePad(onMove, onActive) {
|
|
157
|
+
const pointer = useRef(null);
|
|
158
|
+
const read = (event) => {
|
|
159
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
160
|
+
onMove(clamp((event.clientX - box.left) / box.width), clamp((event.clientY - box.top) / box.height));
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
onPointerDown(event) {
|
|
164
|
+
if (event.button !== 0 || pointer.current !== null)
|
|
165
|
+
return;
|
|
166
|
+
pointer.current = event.pointerId;
|
|
167
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
168
|
+
onActive(true);
|
|
169
|
+
read(event);
|
|
170
|
+
},
|
|
171
|
+
onPointerMove(event) { if (event.pointerId === pointer.current)
|
|
172
|
+
read(event); },
|
|
173
|
+
onPointerUp(event) { if (event.pointerId !== pointer.current)
|
|
174
|
+
return; pointer.current = null; onActive(false); },
|
|
175
|
+
onPointerCancel(event) { if (event.pointerId !== pointer.current)
|
|
176
|
+
return; pointer.current = null; onActive(false); },
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/** Arrow keys step by a small amount, Shift by ten, Page keys by ten, Home and End to the ends. */
|
|
180
|
+
function stepFor(event, axis) {
|
|
181
|
+
const big = event.shiftKey || event.key.startsWith("Page");
|
|
182
|
+
const size = big ? 10 : 1;
|
|
183
|
+
const map = {
|
|
184
|
+
ArrowRight: [size, 0], ArrowLeft: [-size, 0], ArrowUp: axis === "both" ? [0, size] : [size, 0], ArrowDown: axis === "both" ? [0, -size] : [-size, 0],
|
|
185
|
+
PageUp: [10, 0], PageDown: [-10, 0],
|
|
186
|
+
};
|
|
187
|
+
return map[event.key] ?? null;
|
|
188
|
+
}
|
|
189
|
+
function Slider({ label, value, valueText, max, unit, onChange, className, style, reduced, fill, onActive, active }) {
|
|
190
|
+
const x = useFollow(value / max, reduced, active);
|
|
191
|
+
const left = useTransform(x, v => `${v * 100}%`);
|
|
192
|
+
const pad = usePad(fx => onChange(fx * max), onActive);
|
|
193
|
+
return _jsx("div", { className: `${styles.slider} ${className}`, style: style, ...pad, children: _jsx(motion.div, { className: styles.sliderThumb, role: "slider", tabIndex: 0, "aria-label": label, "aria-valuemin": 0, "aria-valuemax": max, "aria-valuenow": Math.round(value), "aria-valuetext": valueText, style: { left, "--thumb-fill": fill }, "data-active": active || undefined, onKeyDown: event => {
|
|
194
|
+
if (event.key === "Home" || event.key === "End") {
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
onChange(event.key === "Home" ? 0 : max);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const step = stepFor(event, "x");
|
|
200
|
+
if (!step)
|
|
201
|
+
return;
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
onChange(clamp(value + step[0] * unit, 0, max));
|
|
204
|
+
} }) });
|
|
205
|
+
}
|
|
206
|
+
function Chip({ color, className }) {
|
|
207
|
+
return _jsx("span", { className: `${styles.chip} ${className ?? ""}`, children: _jsx("span", { style: { background: color } }) });
|
|
208
|
+
}
|
|
209
|
+
let swatchCount = 0;
|
|
210
|
+
const newId = () => `swatch-${Date.now().toString(36)}-${swatchCount++}`;
|
|
211
|
+
export function ColorPicker({ value, defaultValue = "#2F6BFF", onValueChange, background = "#FFFFFF", label = "Color", swatches: swatchesProp, defaultSwatches, onSwatchesChange, maxSwatches = 7, defaultFormat = "hex", className, }) {
|
|
212
|
+
const uid = useId().replace(/[^a-zA-Z0-9-]/g, "");
|
|
213
|
+
const hydrated = useHydrated();
|
|
214
|
+
const reduced = !!useReducedMotion() && hydrated;
|
|
215
|
+
const canPick = useEyeDropper();
|
|
216
|
+
const [hsva, setHsva] = useState(() => parseColor(value ?? defaultValue) ?? { h: 220, s: .8, v: 1, a: 1 });
|
|
217
|
+
const [synced, setSynced] = useState(value);
|
|
218
|
+
if (value !== undefined && value !== synced) {
|
|
219
|
+
setSynced(value);
|
|
220
|
+
if (value.toUpperCase() !== toHex(hsva)) {
|
|
221
|
+
const next = parseColor(value, hsva.h);
|
|
222
|
+
if (next)
|
|
223
|
+
setHsva(next);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const [ownSwatches, setOwnSwatches] = useState(defaultSwatches ?? []);
|
|
227
|
+
const swatches = swatchesProp ?? ownSwatches;
|
|
228
|
+
const [open, setOpen] = useState(false);
|
|
229
|
+
const [shown, setShown] = useState(false);
|
|
230
|
+
const [kind, setKind] = useState(defaultFormat);
|
|
231
|
+
const [draft, setDraft] = useState(null);
|
|
232
|
+
const [invalid, setInvalid] = useState(false);
|
|
233
|
+
const [morph, setMorph] = useState(null);
|
|
234
|
+
const [active, setActive] = useState(null);
|
|
235
|
+
const [focusSwatch, setFocusSwatch] = useState(null);
|
|
236
|
+
const rootRef = useRef(null);
|
|
237
|
+
const triggerRef = useRef(null);
|
|
238
|
+
const panelRef = useRef(null);
|
|
239
|
+
const areaThumb = useRef(null);
|
|
240
|
+
const inputRef = useRef(null);
|
|
241
|
+
const swatchRefs = useRef(new Map());
|
|
242
|
+
const dragged = useRef(false);
|
|
243
|
+
const fieldX = useMotionValue(0);
|
|
244
|
+
/** Whether the panel is meant to be open right now, read when a closing animation finishes. */
|
|
245
|
+
const openNow = useRef(false);
|
|
246
|
+
const hex = toHex(hsva);
|
|
247
|
+
const rgb = hsvToRgb(hsva);
|
|
248
|
+
const css = `rgb(${byte(rgb.r)} ${byte(rgb.g)} ${byte(rgb.b)} / ${round(hsva.a, 3)})`;
|
|
249
|
+
const opaque = `rgb(${byte(rgb.r)} ${byte(rgb.g)} ${byte(rgb.b)})`;
|
|
250
|
+
const pure = `hsl(${hsva.h} 100% 50%)`;
|
|
251
|
+
const bg = parseColor(background);
|
|
252
|
+
const ratio = contrast(hsva, bg ? hsvToRgb(bg) : { r: 1, g: 1, b: 1, a: 1 });
|
|
253
|
+
const text = format(hsva, kind);
|
|
254
|
+
function commit(next) {
|
|
255
|
+
setHsva(next);
|
|
256
|
+
const nextHex = toHex(next);
|
|
257
|
+
if (nextHex !== hex)
|
|
258
|
+
onValueChange?.(nextHex);
|
|
259
|
+
}
|
|
260
|
+
function setSwatches(next) { if (!swatchesProp)
|
|
261
|
+
setOwnSwatches(next); onSwatchesChange?.(next); }
|
|
262
|
+
// The surface: one progress value grows the swatch's box into the panel's box; the content fades in behind the leading edge.
|
|
263
|
+
const progress = useMotionValue(0), fade = useMotionValue(0);
|
|
264
|
+
const size = { W: useMotionValue(300), H: useMotionValue(420), w: useMotionValue(160), h: useMotionValue(44) };
|
|
265
|
+
const clipPath = useTransform(() => {
|
|
266
|
+
const q = clamp(progress.get());
|
|
267
|
+
return `inset(0px ${round((size.W.get() - size.w.get()) * (1 - q), 2)}px ${round((size.H.get() - size.h.get()) * (1 - q), 2)}px 0px round ${round(22 + 4 * q, 2)}px)`;
|
|
268
|
+
});
|
|
269
|
+
const contentOpacity = useTransform(progress, [.35, .9], [0, 1]);
|
|
270
|
+
const contentY = useTransform(progress, [0, 1], [-10, 0]);
|
|
271
|
+
useLayoutEffect(() => {
|
|
272
|
+
if (!shown)
|
|
273
|
+
return;
|
|
274
|
+
const panel = panelRef.current, trigger = triggerRef.current;
|
|
275
|
+
if (!panel || !trigger)
|
|
276
|
+
return;
|
|
277
|
+
const measure = () => { size.W.set(panel.offsetWidth); size.H.set(panel.offsetHeight); size.w.set(trigger.offsetWidth); size.h.set(trigger.offsetHeight); };
|
|
278
|
+
measure();
|
|
279
|
+
const observer = new ResizeObserver(measure);
|
|
280
|
+
observer.observe(panel);
|
|
281
|
+
return () => observer.disconnect();
|
|
282
|
+
}, [shown, size.W, size.H, size.w, size.h]);
|
|
283
|
+
useEffect(() => {
|
|
284
|
+
if (!shown)
|
|
285
|
+
return;
|
|
286
|
+
if (reduced) {
|
|
287
|
+
progress.jump(open ? 1 : progress.get());
|
|
288
|
+
const controls = animate(fade, open ? 1 : 0, { duration: duration.fast, ease: [...ease.standard] });
|
|
289
|
+
controls.then(() => { if (!openNow.current) {
|
|
290
|
+
progress.jump(0);
|
|
291
|
+
setShown(false);
|
|
292
|
+
} });
|
|
293
|
+
return () => controls.stop();
|
|
294
|
+
}
|
|
295
|
+
fade.jump(1);
|
|
296
|
+
const controls = animate(progress, open ? 1 : 0, open ? openSpring : closeSpring);
|
|
297
|
+
if (!open)
|
|
298
|
+
controls.then(() => { if (!openNow.current)
|
|
299
|
+
setShown(false); });
|
|
300
|
+
return () => controls.stop();
|
|
301
|
+
}, [fade, open, progress, reduced, shown]);
|
|
302
|
+
useEffect(() => {
|
|
303
|
+
if (open)
|
|
304
|
+
requestAnimationFrame(() => areaThumb.current?.focus({ preventScroll: true }));
|
|
305
|
+
}, [open]);
|
|
306
|
+
function show() { openNow.current = true; setShown(true); setOpen(true); }
|
|
307
|
+
function hide(returnFocus = true) {
|
|
308
|
+
openNow.current = false;
|
|
309
|
+
setOpen(false);
|
|
310
|
+
setDraft(null);
|
|
311
|
+
setInvalid(false);
|
|
312
|
+
if (returnFocus)
|
|
313
|
+
triggerRef.current?.focus({ preventScroll: true });
|
|
314
|
+
}
|
|
315
|
+
const dismiss = useEffectEvent((event) => {
|
|
316
|
+
if (event instanceof KeyboardEvent) {
|
|
317
|
+
if (event.key !== "Escape")
|
|
318
|
+
return;
|
|
319
|
+
hide(!!rootRef.current?.contains(document.activeElement));
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (!rootRef.current?.contains(event.target))
|
|
323
|
+
hide(false);
|
|
324
|
+
});
|
|
325
|
+
useEffect(() => {
|
|
326
|
+
if (!open)
|
|
327
|
+
return;
|
|
328
|
+
const listener = (event) => dismiss(event);
|
|
329
|
+
document.addEventListener("pointerdown", listener, true);
|
|
330
|
+
document.addEventListener("keydown", listener);
|
|
331
|
+
return () => { document.removeEventListener("pointerdown", listener, true); document.removeEventListener("keydown", listener); };
|
|
332
|
+
}, [open]);
|
|
333
|
+
// The saturation and brightness area.
|
|
334
|
+
const areaX = useFollow(hsva.s, reduced, active === "area"), areaY = useFollow(1 - hsva.v, reduced, active === "area");
|
|
335
|
+
const areaLeft = useTransform(areaX, v => `${v * 100}%`), areaTop = useTransform(areaY, v => `${v * 100}%`);
|
|
336
|
+
const areaPad = usePad((x, y) => commit({ ...hsva, s: x, v: 1 - y }), on => setActive(on ? "area" : null));
|
|
337
|
+
// Format morph: the new text mounts showing the old string, then morphs to the new one, and the live field returns once it settles.
|
|
338
|
+
useEffect(() => {
|
|
339
|
+
if (!morph || morph.phase === 1)
|
|
340
|
+
return;
|
|
341
|
+
const frame = requestAnimationFrame(() => setMorph(current => current && current.id === morph.id ? { ...current, phase: 1 } : current));
|
|
342
|
+
return () => cancelAnimationFrame(frame);
|
|
343
|
+
}, [morph]);
|
|
344
|
+
useEffect(() => {
|
|
345
|
+
if (!morph || morph.phase === 0)
|
|
346
|
+
return;
|
|
347
|
+
const timer = window.setTimeout(() => setMorph(current => current?.id === morph.id ? null : current), 620);
|
|
348
|
+
return () => window.clearTimeout(timer);
|
|
349
|
+
}, [morph]);
|
|
350
|
+
function cycleFormat() {
|
|
351
|
+
const next = formats[(formats.indexOf(kind) + 1) % formats.length];
|
|
352
|
+
setKind(next);
|
|
353
|
+
setDraft(null);
|
|
354
|
+
setInvalid(false);
|
|
355
|
+
if (!reduced)
|
|
356
|
+
setMorph({ id: Date.now(), from: text, to: format(hsva, next), phase: 0 });
|
|
357
|
+
}
|
|
358
|
+
function submitDraft() {
|
|
359
|
+
if (draft === null)
|
|
360
|
+
return true;
|
|
361
|
+
const next = parseColor(draft, hsva.h);
|
|
362
|
+
if (!next) {
|
|
363
|
+
setInvalid(true);
|
|
364
|
+
if (!reduced)
|
|
365
|
+
animate(fieldX, [0, -5, 4, -2, 0], { duration: .32, ease: [...ease.standard] });
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
commit(next);
|
|
369
|
+
setDraft(null);
|
|
370
|
+
setInvalid(false);
|
|
371
|
+
return true;
|
|
372
|
+
}
|
|
373
|
+
function pickFromScreen() {
|
|
374
|
+
if (!canPick)
|
|
375
|
+
return;
|
|
376
|
+
const Ctor = window.EyeDropper;
|
|
377
|
+
new Ctor().open().then(result => { const next = parseColor(result.sRGBHex, hsva.h); if (next)
|
|
378
|
+
commit({ ...next, a: hsva.a }); }).catch(() => { });
|
|
379
|
+
}
|
|
380
|
+
function saveSwatch() {
|
|
381
|
+
const entry = { id: newId(), color: hex };
|
|
382
|
+
setSwatches([entry, ...swatches].slice(0, maxSwatches));
|
|
383
|
+
setFocusSwatch(entry.id);
|
|
384
|
+
}
|
|
385
|
+
function onSwatchKey(event, index) {
|
|
386
|
+
const item = swatches[index];
|
|
387
|
+
const move = event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : 0;
|
|
388
|
+
if (event.key === "Delete" || event.key === "Backspace") {
|
|
389
|
+
event.preventDefault();
|
|
390
|
+
const next = swatches.filter(entry => entry.id !== item.id);
|
|
391
|
+
setSwatches(next);
|
|
392
|
+
const neighbor = next[Math.min(index, next.length - 1)];
|
|
393
|
+
setFocusSwatch(neighbor?.id ?? null);
|
|
394
|
+
requestAnimationFrame(() => neighbor ? swatchRefs.current.get(neighbor.id)?.focus({ preventScroll: true }) : inputRef.current?.focus({ preventScroll: true }));
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (!move && event.key !== "Home" && event.key !== "End")
|
|
398
|
+
return;
|
|
399
|
+
event.preventDefault();
|
|
400
|
+
if (move && event.altKey) {
|
|
401
|
+
const to = index + move;
|
|
402
|
+
if (to < 0 || to >= swatches.length)
|
|
403
|
+
return;
|
|
404
|
+
const next = [...swatches];
|
|
405
|
+
next.splice(index, 1);
|
|
406
|
+
next.splice(to, 0, item);
|
|
407
|
+
setSwatches(next);
|
|
408
|
+
requestAnimationFrame(() => swatchRefs.current.get(item.id)?.focus({ preventScroll: true }));
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
const target = event.key === "Home" ? 0 : event.key === "End" ? swatches.length - 1 : (index + move + swatches.length) % swatches.length;
|
|
412
|
+
setFocusSwatch(swatches[target].id);
|
|
413
|
+
swatchRefs.current.get(swatches[target].id)?.focus({ preventScroll: true });
|
|
414
|
+
}
|
|
415
|
+
const ratioValue = useFollow(ratio, reduced);
|
|
416
|
+
const ratioText = useTransform(ratioValue, v => v.toFixed(2));
|
|
417
|
+
const grade = level(ratio);
|
|
418
|
+
const hidden = reduced ? { opacity: 0 } : { opacity: 0, y: "0.3em", filter: `blur(${blur.subtle}px)` };
|
|
419
|
+
const swatchTab = swatches.some(entry => entry.id === focusSwatch) ? focusSwatch : swatches[0]?.id;
|
|
420
|
+
const style = { "--picker-color": css, "--picker-opaque": opaque, "--picker-hue": pure, "--picker-bg": background };
|
|
421
|
+
return _jsxs("div", { ref: rootRef, className: [styles.root, className].filter(Boolean).join(" "), style: style, children: [_jsxs("button", { ref: triggerRef, type: "button", className: styles.trigger, "aria-haspopup": "dialog", "aria-expanded": open, "aria-controls": open ? `${uid}-panel` : undefined, onClick: () => open ? hide() : show(), children: [_jsx(Chip, { color: css }), _jsxs("span", { className: styles.triggerText, children: [_jsx("span", { className: styles.name, children: label }), _jsx("span", { className: styles.hex, children: hex })] })] }), shown && _jsx("div", { className: styles.float, "data-open": open || undefined, children: _jsxs(motion.div, { ref: panelRef, id: `${uid}-panel`, role: "dialog", "aria-label": `${label} color`, className: styles.panel, inert: !open, style: { clipPath, opacity: fade }, children: [_jsxs("div", { className: styles.head, children: [_jsx(Chip, { color: css }), _jsxs("span", { className: styles.triggerText, children: [_jsx("span", { className: styles.name, children: label }), _jsx("span", { className: styles.hex, children: hex })] }), _jsxs(motion.span, { className: styles.headActions, style: { opacity: contentOpacity }, children: [canPick && _jsx("button", { type: "button", className: styles.iconButton, "aria-label": "Pick a color from the screen", onClick: pickFromScreen, children: _jsx(Pipette, { size: 18, strokeWidth: 1.75, "aria-hidden": "true" }) }), _jsx("button", { type: "button", className: styles.iconButton, "aria-label": "Done", onClick: () => hide(), children: _jsx(Check, { size: 18, strokeWidth: 1.75, "aria-hidden": "true" }) })] })] }), _jsxs(motion.div, { className: styles.body, style: { opacity: contentOpacity, y: contentY }, children: [_jsx("div", { className: styles.area, "data-active": active === "area" || undefined, ...areaPad, children: _jsx(motion.div, { ref: areaThumb, className: styles.areaThumb, role: "slider", tabIndex: 0, "aria-roledescription": "2D slider", "aria-label": "Saturation and brightness", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": Math.round(hsva.s * 100), "aria-valuetext": `Saturation ${Math.round(hsva.s * 100)}%, brightness ${Math.round(hsva.v * 100)}%`, style: { left: areaLeft, top: areaTop }, onKeyDown: event => {
|
|
422
|
+
const step = stepFor(event, "both");
|
|
423
|
+
if (!step)
|
|
424
|
+
return;
|
|
425
|
+
event.preventDefault();
|
|
426
|
+
commit({ ...hsva, s: clamp(hsva.s + step[0] / 100), v: clamp(hsva.v + step[1] / 100) });
|
|
427
|
+
} }) }), _jsx(Slider, { label: "Hue", value: hsva.h, valueText: `${Math.round(hsva.h)} degrees`, max: 360, unit: 1, className: styles.hue, reduced: reduced, fill: pure, onChange: h => commit({ ...hsva, h: clamp(h, 0, 359.9) }), active: active === "hue", onActive: on => setActive(on ? "hue" : null) }), _jsx(Slider, { label: "Opacity", value: hsva.a * 100, valueText: `${Math.round(hsva.a * 100)}%`, max: 100, unit: 1, className: styles.alpha, reduced: reduced, fill: css, onChange: a => commit({ ...hsva, a: clamp(a / 100) }), active: active === "alpha", onActive: on => setActive(on ? "alpha" : null) }), _jsxs(motion.div, { className: styles.field, "data-invalid": invalid || undefined, style: { x: fieldX }, children: [_jsx("button", { type: "button", className: styles.format, onClick: cycleFormat, "aria-label": `Format: ${formatNames[kind]}. Switch format`, children: _jsx(TextMorph, { children: formatNames[kind] }) }), _jsxs("span", { className: styles.inputWrap, children: [_jsx("input", { ref: inputRef, className: styles.input, value: draft ?? text, spellCheck: false, autoComplete: "off", "aria-label": `${label} in ${formatNames[kind]}`, "aria-invalid": invalid || undefined, "aria-describedby": invalid ? `${uid}-error` : undefined, "data-morphing": morph ? "" : undefined, onChange: event => { setDraft(event.target.value); setInvalid(false); }, onKeyDown: event => {
|
|
428
|
+
if (event.key === "Enter") {
|
|
429
|
+
event.preventDefault();
|
|
430
|
+
if (submitDraft())
|
|
431
|
+
event.currentTarget.select();
|
|
432
|
+
}
|
|
433
|
+
if (event.key === "Escape" && draft !== null) {
|
|
434
|
+
event.stopPropagation();
|
|
435
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
436
|
+
setDraft(null);
|
|
437
|
+
setInvalid(false);
|
|
438
|
+
}
|
|
439
|
+
}, onBlur: () => { if (!submitDraft()) {
|
|
440
|
+
setDraft(null);
|
|
441
|
+
setInvalid(false);
|
|
442
|
+
} } }), morph && _jsx("span", { className: styles.morph, "aria-hidden": "true", children: _jsx(TextMorph, { children: morph.phase === 0 ? morph.from : morph.to }) })] })] }), _jsx("p", { id: `${uid}-error`, className: styles.error, "aria-live": "polite", children: invalid ? "Enter a hex, RGB, HSL, or OKLCH color" : "" }), _jsxs("div", { className: styles.contrast, children: [_jsx("span", { className: styles.sample, "aria-hidden": "true", children: "Aa" }), _jsxs("span", { className: styles.ratio, children: [_jsx(motion.span, { children: ratioText }), ":1"] }), _jsx("span", { className: styles.against, children: "against background" }), _jsx("span", { className: styles.grade, "data-grade": grade === "Fails" ? "fail" : grade === "AA large" ? "large" : "pass", children: _jsx(AnimatePresence, { mode: "popLayout", initial: false, children: _jsx(motion.span, { initial: hidden, animate: { opacity: 1, y: "0em", filter: "blur(0px)" }, exit: { ...hidden, transition: { duration: duration.instant } }, transition: reduced ? { duration: duration.instant } : { duration: duration.standard, ease: [...ease.enter] }, children: grade }, grade) }) }), _jsx("span", { className: styles.srOnly, children: `Contrast ${ratio.toFixed(2)} to 1, ${grade === "Fails" ? "fails" : `passes ${grade}`}` })] }), _jsxs("div", { className: styles.swatches, children: [_jsx("button", { type: "button", className: styles.add, onClick: saveSwatch, "aria-label": `Save ${hex}`, children: _jsx(Plus, { size: 16, strokeWidth: 1.75, "aria-hidden": "true" }) }), _jsx(Reorder.Group, { as: "div", axis: "x", values: swatches, onReorder: setSwatches, className: styles.swatchList, role: "listbox", "aria-label": "Saved colors", "aria-orientation": "horizontal", children: _jsx(AnimatePresence, { initial: false, children: swatches.map((entry, index) => _jsx(Reorder.Item, { value: entry, as: "div", className: styles.swatchSlot, dragElastic: .12, initial: reduced ? { opacity: 0 } : { opacity: 0, scale: .4 }, animate: { opacity: 1, scale: 1 }, exit: reduced ? { opacity: 0 } : { opacity: 0, scale: .4, transition: { duration: duration.fast } }, transition: reduced ? instant : { ...spring.snappy, layout: spring.smooth }, whileDrag: reduced ? undefined : { scale: 1.15, zIndex: 2 }, onDragStart: () => { dragged.current = true; }, onDragEnd: () => requestAnimationFrame(() => { dragged.current = false; }), children: _jsx("button", { ref: node => { if (node)
|
|
443
|
+
swatchRefs.current.set(entry.id, node);
|
|
444
|
+
else
|
|
445
|
+
swatchRefs.current.delete(entry.id); }, type: "button", role: "option", "aria-selected": entry.color.toUpperCase() === hex, className: styles.swatch, "data-current": entry.color.toUpperCase() === hex || undefined, "aria-label": `${entry.color}. Alt and arrow keys to move, Delete to remove`, tabIndex: entry.id === swatchTab ? 0 : -1, onFocus: () => setFocusSwatch(entry.id), onKeyDown: event => onSwatchKey(event, index), onClick: () => { if (dragged.current)
|
|
446
|
+
return; const next = parseColor(entry.color, hsva.h); if (next)
|
|
447
|
+
commit(next); }, children: _jsx(Chip, { color: entry.color, className: styles.swatchChip }) }) }, entry.id)) }) })] })] })] }) })] });
|
|
448
|
+
}
|
|
449
|
+
export default ColorPicker;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* The swatch is the panel's top left corner: the panel opens over it and grows out of its box. Leave room below and to the right. */
|
|
2
|
+
.root {
|
|
3
|
+
--picker-fill: var(--surface);
|
|
4
|
+
--picker-width: min(19rem, calc(100vw - 32px));
|
|
5
|
+
--checker: repeating-conic-gradient(oklch(88% 0 0) 0 25%, oklch(100% 0 0) 0 50%) 0 0 / 10px 10px;
|
|
6
|
+
position: relative;
|
|
7
|
+
display: inline-block;
|
|
8
|
+
font-family: var(--font-body);
|
|
9
|
+
letter-spacing: var(--tracking-body);
|
|
10
|
+
color: var(--foreground);
|
|
11
|
+
}
|
|
12
|
+
:global(:root[data-theme="dark"]) .root { --picker-fill: var(--surface-raised); --checker: repeating-conic-gradient(oklch(42% 0 0) 0 25%, oklch(30% 0 0) 0 50%) 0 0 / 10px 10px; }
|
|
13
|
+
|
|
14
|
+
.trigger, .head { display: flex; height: 44px; align-items: center; gap: 10px; padding: 6px 16px 6px 6px; }
|
|
15
|
+
.trigger {
|
|
16
|
+
border: 1px solid var(--border); border-radius: var(--radius-container); corner-shape: var(--corner-shape); background: var(--picker-fill); box-shadow: var(--shadow-resting); color: inherit; font: inherit; cursor: pointer;
|
|
17
|
+
-webkit-tap-highlight-color: transparent; transition: border-color var(--duration-fast) var(--ease-standard);
|
|
18
|
+
}
|
|
19
|
+
.triggerText { display: grid; min-width: 0; text-align: start; line-height: 1.15; }
|
|
20
|
+
.name { color: var(--text-secondary); font-size: var(--text-xs); }
|
|
21
|
+
.hex { font-size: var(--text-sm); font-variant-numeric: tabular-nums; font-weight: 500; }
|
|
22
|
+
|
|
23
|
+
/* A chip over a checkerboard, so opacity reads as opacity. */
|
|
24
|
+
.chip { position: relative; display: block; width: 32px; height: 32px; flex: none; overflow: hidden; border-radius: 50%; corner-shape: round; background: var(--checker); }
|
|
25
|
+
.chip > span { position: absolute; inset: 0; border-radius: inherit; corner-shape: inherit; box-shadow: inset 0 0 0 1px oklch(0% 0 0 / .1); }
|
|
26
|
+
|
|
27
|
+
/* The floating layer. Its drop shadow follows the clipped shape, so the shadow grows with the panel. */
|
|
28
|
+
.float { position: absolute; z-index: 20; top: -1px; left: -1px; filter: drop-shadow(0 18px 36px oklch(0% 0 0 / .12)) drop-shadow(0 2px 6px oklch(0% 0 0 / .06)); pointer-events: none; }
|
|
29
|
+
:global(:root[data-theme="dark"]) .float { filter: drop-shadow(0 20px 44px oklch(0% 0 0 / .5)); }
|
|
30
|
+
.float[data-open] { pointer-events: auto; }
|
|
31
|
+
.panel { width: var(--picker-width); padding-bottom: 14px; border: 1px solid var(--border); border-radius: var(--radius-container); corner-shape: var(--corner-shape); background: var(--picker-fill); will-change: clip-path; }
|
|
32
|
+
.head { gap: 10px; padding-right: 6px; }
|
|
33
|
+
.head .triggerText { flex: 1; }
|
|
34
|
+
.headActions { display: flex; gap: 2px; }
|
|
35
|
+
.iconButton {
|
|
36
|
+
display: grid; width: 32px; height: 32px; place-items: center; padding: 0; border: 0; border-radius: var(--radius-control); corner-shape: var(--corner-shape); background: transparent; color: var(--text-secondary); cursor: pointer;
|
|
37
|
+
transition: background-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard);
|
|
38
|
+
}
|
|
39
|
+
.iconButton:active { transform: scale(.94); }
|
|
40
|
+
/* One column locked to the panel: a wider grade label ("AA large") must never widen the area and sliders mid drag. */
|
|
41
|
+
.body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 8px 14px 0; }
|
|
42
|
+
|
|
43
|
+
/* Saturation runs left to right, brightness bottom to top, over the pure hue. */
|
|
44
|
+
.area {
|
|
45
|
+
position: relative; height: 164px; border-radius: var(--radius-control); corner-shape: var(--corner-shape); cursor: crosshair; touch-action: none;
|
|
46
|
+
background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), var(--picker-hue);
|
|
47
|
+
box-shadow: inset 0 0 0 1px oklch(0% 0 0 / .08);
|
|
48
|
+
}
|
|
49
|
+
.areaThumb, .sliderThumb {
|
|
50
|
+
position: absolute; width: 22px; height: 22px; border-radius: 50%; corner-shape: round; translate: -50% -50%; cursor: grab;
|
|
51
|
+
box-shadow: 0 0 0 3px #fff, 0 2px 8px oklch(0% 0 0 / .3), inset 0 0 0 1px oklch(0% 0 0 / .12);
|
|
52
|
+
transition: scale var(--duration-spring) var(--ease-spring);
|
|
53
|
+
}
|
|
54
|
+
.areaThumb { background: var(--picker-opaque); }
|
|
55
|
+
.area[data-active] .areaThumb, .sliderThumb[data-active] { scale: 1.2; cursor: grabbing; }
|
|
56
|
+
|
|
57
|
+
.slider { position: relative; height: 14px; margin: 0 11px; border-radius: var(--radius-full); corner-shape: round; cursor: pointer; touch-action: none; }
|
|
58
|
+
.slider::before { content: ""; position: absolute; inset: 0 -11px; border-radius: inherit; corner-shape: inherit; background: var(--track); box-shadow: inset 0 0 0 1px oklch(0% 0 0 / .08); }
|
|
59
|
+
.sliderThumb { top: 50%; background: var(--checker); }
|
|
60
|
+
.sliderThumb::after { content: ""; position: absolute; inset: 0; border-radius: inherit; corner-shape: inherit; background: var(--thumb-fill); }
|
|
61
|
+
/* The gradient stops sit at the thumb's travel ends, so the color under the thumb is the value it reports. */
|
|
62
|
+
.hue { --track: linear-gradient(to right, #f00 11px, #ff0 calc(11px + (100% - 22px) * .1666), #0f0 calc(11px + (100% - 22px) * .3333), #0ff 50%, #00f calc(11px + (100% - 22px) * .6666), #f0f calc(11px + (100% - 22px) * .8333), #f00 calc(100% - 11px)); }
|
|
63
|
+
.alpha { --track: linear-gradient(to right, transparent 11px, var(--picker-opaque) calc(100% - 11px)), var(--checker); }
|
|
64
|
+
|
|
65
|
+
.field { display: flex; height: 40px; align-items: stretch; overflow: hidden; margin-top: 2px; border: 1px solid var(--border); border-radius: var(--radius-control); corner-shape: var(--corner-shape); background: var(--surface-muted); transition: border-color var(--duration-fast) var(--ease-standard); }
|
|
66
|
+
.field[data-invalid] { border-color: var(--danger); }
|
|
67
|
+
.format {
|
|
68
|
+
display: flex; min-width: 56px; align-items: center; justify-content: center; padding: 0 10px; border: 0; border-right: 1px solid var(--border); background: transparent;
|
|
69
|
+
color: var(--foreground); font: inherit; font-size: var(--text-xs); font-weight: 500; cursor: pointer; transition: background-color var(--duration-fast) var(--ease-standard);
|
|
70
|
+
}
|
|
71
|
+
.inputWrap { position: relative; display: flex; min-width: 0; flex: 1; }
|
|
72
|
+
.input, .morph { padding: 0 10px; font: inherit; font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
|
|
73
|
+
.input { width: 100%; min-width: 0; border: 0; background: transparent; color: var(--foreground); caret-color: var(--foreground); }
|
|
74
|
+
.input[data-morphing] { color: transparent; }
|
|
75
|
+
.morph { position: absolute; inset: 0; display: flex; align-items: center; overflow: hidden; color: var(--foreground); pointer-events: none; white-space: nowrap; }
|
|
76
|
+
.error { min-height: 0; margin: -10px 2px -4px; color: var(--danger); font-size: var(--text-xs); }
|
|
77
|
+
.error:empty { display: none; }
|
|
78
|
+
|
|
79
|
+
.contrast { display: flex; align-items: center; gap: 10px; font-size: var(--text-sm); }
|
|
80
|
+
.sample { display: grid; width: 36px; height: 28px; flex: none; place-items: center; border: 1px solid var(--border); border-radius: var(--radius-detail); corner-shape: var(--corner-shape); background: var(--picker-bg); color: var(--picker-color); font-weight: 500; }
|
|
81
|
+
.ratio { font-variant-numeric: tabular-nums; font-weight: 500; min-width: 4.4ch; }
|
|
82
|
+
.against { flex: 1; min-width: 0; overflow: hidden; color: var(--text-secondary); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
|
|
83
|
+
.grade { position: relative; display: inline-grid; height: 22px; align-items: center; padding: 0 8px; border-radius: var(--radius-full); corner-shape: round; font-size: var(--text-xs); font-weight: 500; white-space: nowrap; transition: background-color var(--duration-standard) var(--ease-standard), color var(--duration-standard) var(--ease-standard); }
|
|
84
|
+
.grade[data-grade="pass"] { background: color-mix(in oklab, var(--success) 14%, transparent); color: var(--success); }
|
|
85
|
+
.grade[data-grade="large"] { background: color-mix(in oklab, var(--warning) 16%, transparent); color: var(--warning); }
|
|
86
|
+
.grade[data-grade="fail"] { background: color-mix(in oklab, var(--danger) 12%, transparent); color: var(--danger); }
|
|
87
|
+
|
|
88
|
+
.swatches { display: flex; align-items: center; gap: 6px; min-height: 32px; }
|
|
89
|
+
.add {
|
|
90
|
+
display: grid; width: 30px; height: 30px; flex: none; place-items: center; padding: 0; border: 1px dashed var(--border-strong); border-radius: 50%; corner-shape: round; background: transparent; color: var(--text-secondary); cursor: pointer;
|
|
91
|
+
transition: color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard);
|
|
92
|
+
}
|
|
93
|
+
.add:active { transform: scale(.92); }
|
|
94
|
+
.swatchList { display: flex; min-width: 0; flex: 1; gap: 6px; }
|
|
95
|
+
.swatchSlot { position: relative; flex: none; touch-action: pan-y; }
|
|
96
|
+
.swatch { display: grid; width: 30px; height: 30px; place-items: center; padding: 0; border: 0; border-radius: 50%; corner-shape: round; background: transparent; cursor: pointer; }
|
|
97
|
+
.swatchChip { width: 26px; height: 26px; transition: scale var(--duration-spring) var(--ease-spring); }
|
|
98
|
+
.swatch[data-current] { box-shadow: inset 0 0 0 2px var(--foreground); }
|
|
99
|
+
.swatch[data-current] .swatchChip { scale: .78; }
|
|
100
|
+
|
|
101
|
+
.srOnly { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
102
|
+
|
|
103
|
+
@media (hover: hover) and (pointer: fine) {
|
|
104
|
+
.trigger:hover { border-color: var(--border-strong); }
|
|
105
|
+
.iconButton:hover, .format:hover { background: var(--surface-muted); color: var(--foreground); }
|
|
106
|
+
.format:hover { background: color-mix(in oklab, var(--foreground) 5%, transparent); }
|
|
107
|
+
.add:hover { border-color: var(--foreground); color: var(--foreground); }
|
|
108
|
+
}
|
|
109
|
+
@media (max-width: 360px) { .against { display: none; } }
|
|
110
|
+
@media (prefers-contrast: more) { .trigger, .panel, .field { border-color: var(--border-strong); } }
|
|
111
|
+
@media (prefers-reduced-motion: reduce) { .areaThumb, .sliderThumb, .swatchChip, .iconButton, .add { transition: none; } }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { InputHTMLAttributes } from "react";
|
|
2
|
+
export interface ComboboxOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
keywords?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface ComboboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "placeholder"> {
|
|
9
|
+
label: string;
|
|
10
|
+
options: ComboboxOption[];
|
|
11
|
+
value?: string;
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
onValueChange?: (value: string) => void;
|
|
14
|
+
description?: string;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
emptyMessage?: string;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const Combobox: import("react").ForwardRefExoticComponent<ComboboxProps & import("react").RefAttributes<HTMLInputElement>>;
|