@cueplusplus/ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts/_token.js +39 -0
- package/dist/charts/container.d.ts +58 -0
- package/dist/charts/container.js +77 -0
- package/dist/charts/index.d.ts +5 -0
- package/dist/charts/index.js +5 -0
- package/dist/charts/ramps.d.ts +140 -0
- package/dist/charts/ramps.js +615 -0
- package/dist/charts/theme.d.ts +112 -0
- package/dist/charts/theme.js +165 -0
- package/dist/charts/tones.d.ts +111 -0
- package/dist/charts/tones.js +127 -0
- package/dist/chat/_glyphs.js +55 -0
- package/dist/chat/agent-color.d.ts +84 -0
- package/dist/chat/agent-color.js +101 -0
- package/dist/chat/agent-pile.d.ts +55 -0
- package/dist/chat/agent-pile.js +121 -0
- package/dist/chat/ask-box.d.ts +88 -0
- package/dist/chat/ask-box.js +341 -0
- package/dist/chat/composer.d.ts +66 -0
- package/dist/chat/composer.js +144 -0
- package/dist/chat/delegation-card.d.ts +60 -0
- package/dist/chat/delegation-card.js +129 -0
- package/dist/chat/index.d.ts +8 -0
- package/dist/chat/index.js +8 -0
- package/dist/chat/message-list.d.ts +39 -0
- package/dist/chat/message-list.js +105 -0
- package/dist/chat/message.d.ts +47 -0
- package/dist/chat/message.js +108 -0
- package/dist/chrome/_glyphs.js +101 -0
- package/dist/chrome/_tabs-scroll.d.ts +62 -0
- package/dist/chrome/_tabs-scroll.js +68 -0
- package/dist/chrome/_tree.d.ts +75 -0
- package/dist/chrome/_tree.js +49 -0
- package/dist/chrome/empty-state.d.ts +37 -0
- package/dist/chrome/empty-state.js +57 -0
- package/dist/chrome/eyebrow.d.ts +29 -0
- package/dist/chrome/eyebrow.js +36 -0
- package/dist/chrome/index.d.ts +17 -0
- package/dist/chrome/index.js +17 -0
- package/dist/chrome/navigation-menu.d.ts +80 -0
- package/dist/chrome/navigation-menu.js +121 -0
- package/dist/chrome/page-shell.d.ts +38 -0
- package/dist/chrome/page-shell.js +66 -0
- package/dist/chrome/panel.d.ts +55 -0
- package/dist/chrome/panel.js +67 -0
- package/dist/chrome/row.d.ts +82 -0
- package/dist/chrome/row.js +106 -0
- package/dist/chrome/scroll-area.d.ts +39 -0
- package/dist/chrome/scroll-area.js +70 -0
- package/dist/chrome/section-header.d.ts +42 -0
- package/dist/chrome/section-header.js +79 -0
- package/dist/chrome/segmented-control.d.ts +58 -0
- package/dist/chrome/segmented-control.js +76 -0
- package/dist/chrome/status-bar.d.ts +46 -0
- package/dist/chrome/status-bar.js +56 -0
- package/dist/chrome/tabs.d.ts +80 -0
- package/dist/chrome/tabs.js +176 -0
- package/dist/chrome/title-bar.d.ts +37 -0
- package/dist/chrome/title-bar.js +45 -0
- package/dist/chrome/toolbar.d.ts +46 -0
- package/dist/chrome/toolbar.js +62 -0
- package/dist/chrome/tree.d.ts +98 -0
- package/dist/chrome/tree.js +248 -0
- package/dist/color/_checker.js +14 -0
- package/dist/color/_convert.d.ts +52 -0
- package/dist/color/_convert.js +66 -0
- package/dist/color/_glyphs.js +28 -0
- package/dist/color/_thumb.js +15 -0
- package/dist/color/_value.js +28 -0
- package/dist/color/color-area.d.ts +27 -0
- package/dist/color/color-area.js +40 -0
- package/dist/color/color-field.d.ts +32 -0
- package/dist/color/color-field.js +43 -0
- package/dist/color/color-picker.d.ts +71 -0
- package/dist/color/color-picker.js +178 -0
- package/dist/color/color-slider.d.ts +31 -0
- package/dist/color/color-slider.js +51 -0
- package/dist/color/color-swatch.d.ts +32 -0
- package/dist/color/color-swatch.js +44 -0
- package/dist/color/index.d.ts +7 -0
- package/dist/color/index.js +7 -0
- package/dist/configurator/_export.d.ts +78 -0
- package/dist/configurator/_export.js +261 -0
- package/dist/configurator/_glyphs.js +92 -0
- package/dist/configurator/_overrides.d.ts +247 -0
- package/dist/configurator/_overrides.js +514 -0
- package/dist/configurator/configurator.d.ts +71 -0
- package/dist/configurator/configurator.js +279 -0
- package/dist/configurator/export-dialog.d.ts +30 -0
- package/dist/configurator/export-dialog.js +121 -0
- package/dist/configurator/index.d.ts +8 -0
- package/dist/configurator/index.js +8 -0
- package/dist/configurator/panel-sections.d.ts +86 -0
- package/dist/configurator/panel-sections.js +316 -0
- package/dist/configurator/token-editor.d.ts +74 -0
- package/dist/configurator/token-editor.js +149 -0
- package/dist/configurator/use-zoom.d.ts +87 -0
- package/dist/configurator/use-zoom.js +113 -0
- package/dist/date/_glyphs.js +34 -0
- package/dist/date/_segments.js +55 -0
- package/dist/date/_trigger.js +31 -0
- package/dist/date/calendar.d.ts +25 -0
- package/dist/date/calendar.js +125 -0
- package/dist/date/date-field.d.ts +34 -0
- package/dist/date/date-field.js +41 -0
- package/dist/date/date-picker.d.ts +69 -0
- package/dist/date/date-picker.js +89 -0
- package/dist/date/date-range-picker.d.ts +65 -0
- package/dist/date/date-range-picker.js +92 -0
- package/dist/date/index.d.ts +6 -0
- package/dist/date/index.js +6 -0
- package/dist/date/time-field.d.ts +29 -0
- package/dist/date/time-field.js +36 -0
- package/dist/dmx/_ramp.d.ts +77 -0
- package/dist/dmx/_ramp.js +169 -0
- package/dist/dmx/_readout.js +53 -0
- package/dist/dmx/_universe.d.ts +105 -0
- package/dist/dmx/_universe.js +112 -0
- package/dist/dmx/channel-matrix.d.ts +81 -0
- package/dist/dmx/channel-matrix.js +285 -0
- package/dist/dmx/dmx-bar.d.ts +50 -0
- package/dist/dmx/dmx-bar.js +107 -0
- package/dist/dmx/dmx-strip.d.ts +41 -0
- package/dist/dmx/dmx-strip.js +196 -0
- package/dist/dmx/index.d.ts +7 -0
- package/dist/dmx/index.js +7 -0
- package/dist/dmx/universe-grid.d.ts +61 -0
- package/dist/dmx/universe-grid.js +182 -0
- package/dist/flow/_frame.d.ts +52 -0
- package/dist/flow/_frame.js +38 -0
- package/dist/flow/controls.d.ts +41 -0
- package/dist/flow/controls.js +53 -0
- package/dist/flow/flow.css +121 -0
- package/dist/flow/handles.d.ts +40 -0
- package/dist/flow/handles.js +61 -0
- package/dist/flow/index.d.ts +7 -0
- package/dist/flow/index.js +7 -0
- package/dist/flow/node-card.d.ts +71 -0
- package/dist/flow/node-card.js +102 -0
- package/dist/flow/signal-edge.d.ts +60 -0
- package/dist/flow/signal-edge.js +108 -0
- package/dist/flow/use-flow-theme.d.ts +69 -0
- package/dist/flow/use-flow-theme.js +109 -0
- package/dist/forms/_chassis.d.ts +64 -0
- package/dist/forms/_chassis.js +59 -0
- package/dist/forms/_glyphs.js +143 -0
- package/dist/forms/_listbox.js +55 -0
- package/dist/forms/autocomplete.d.ts +61 -0
- package/dist/forms/autocomplete.js +88 -0
- package/dist/forms/button-group.d.ts +47 -0
- package/dist/forms/button-group.js +52 -0
- package/dist/forms/checkbox.d.ts +51 -0
- package/dist/forms/checkbox.js +98 -0
- package/dist/forms/combobox.d.ts +73 -0
- package/dist/forms/combobox.js +108 -0
- package/dist/forms/env-var-input.d.ts +74 -0
- package/dist/forms/env-var-input.js +116 -0
- package/dist/forms/field.d.ts +89 -0
- package/dist/forms/field.js +102 -0
- package/dist/forms/file-upload.d.ts +113 -0
- package/dist/forms/file-upload.js +232 -0
- package/dist/forms/index.d.ts +26 -0
- package/dist/forms/index.js +26 -0
- package/dist/forms/input-group.d.ts +31 -0
- package/dist/forms/input-group.js +54 -0
- package/dist/forms/input.d.ts +33 -0
- package/dist/forms/input.js +36 -0
- package/dist/forms/multi-select.d.ts +62 -0
- package/dist/forms/multi-select.js +107 -0
- package/dist/forms/number-field.d.ts +38 -0
- package/dist/forms/number-field.js +64 -0
- package/dist/forms/otp-field.d.ts +54 -0
- package/dist/forms/otp-field.js +59 -0
- package/dist/forms/password-input.d.ts +46 -0
- package/dist/forms/password-input.js +62 -0
- package/dist/forms/radio-group.d.ts +50 -0
- package/dist/forms/radio-group.js +64 -0
- package/dist/forms/rating.d.ts +69 -0
- package/dist/forms/rating.js +103 -0
- package/dist/forms/scrub-input.d.ts +81 -0
- package/dist/forms/scrub-input.js +249 -0
- package/dist/forms/search-input.d.ts +54 -0
- package/dist/forms/search-input.js +112 -0
- package/dist/forms/select.d.ts +75 -0
- package/dist/forms/select.js +91 -0
- package/dist/forms/slider.d.ts +44 -0
- package/dist/forms/slider.js +65 -0
- package/dist/forms/switch.d.ts +36 -0
- package/dist/forms/switch.js +71 -0
- package/dist/forms/tags-input.d.ts +69 -0
- package/dist/forms/tags-input.js +148 -0
- package/dist/forms/textarea.d.ts +27 -0
- package/dist/forms/textarea.js +37 -0
- package/dist/forms/toggle-group.d.ts +41 -0
- package/dist/forms/toggle-group.js +56 -0
- package/dist/forms/toggle.d.ts +41 -0
- package/dist/forms/toggle.js +100 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +104 -0
- package/dist/instruments/_ansi.js +116 -0
- package/dist/instruments/_glyphs.js +90 -0
- package/dist/instruments/_motion.js +56 -0
- package/dist/instruments/_rem.js +21 -0
- package/dist/instruments/app-window-frame.d.ts +48 -0
- package/dist/instruments/app-window-frame.js +76 -0
- package/dist/instruments/copy-button.d.ts +41 -0
- package/dist/instruments/copy-button.js +112 -0
- package/dist/instruments/data-table.d.ts +168 -0
- package/dist/instruments/data-table.js +212 -0
- package/dist/instruments/group-bar.d.ts +63 -0
- package/dist/instruments/group-bar.js +122 -0
- package/dist/instruments/index.d.ts +13 -0
- package/dist/instruments/index.js +13 -0
- package/dist/instruments/log-viewer.d.ts +74 -0
- package/dist/instruments/log-viewer.js +215 -0
- package/dist/instruments/meter.d.ts +77 -0
- package/dist/instruments/meter.js +96 -0
- package/dist/instruments/progress.d.ts +45 -0
- package/dist/instruments/progress.js +61 -0
- package/dist/instruments/seam-grid.d.ts +66 -0
- package/dist/instruments/seam-grid.js +78 -0
- package/dist/instruments/sparkline.d.ts +39 -0
- package/dist/instruments/sparkline.js +85 -0
- package/dist/instruments/stat.d.ts +35 -0
- package/dist/instruments/stat.js +59 -0
- package/dist/instruments/table.d.ts +51 -0
- package/dist/instruments/table.js +92 -0
- package/dist/instruments/terminal-frame.d.ts +89 -0
- package/dist/instruments/terminal-frame.js +256 -0
- package/dist/instruments/two-step-button.d.ts +47 -0
- package/dist/instruments/two-step-button.js +147 -0
- package/dist/instruments/usage-chart.d.ts +55 -0
- package/dist/instruments/usage-chart.js +235 -0
- package/dist/layout/_collapse.js +46 -0
- package/dist/layout/_glyphs.js +45 -0
- package/dist/layout/accordion.d.ts +52 -0
- package/dist/layout/accordion.js +81 -0
- package/dist/layout/breadcrumb.d.ts +35 -0
- package/dist/layout/breadcrumb.js +67 -0
- package/dist/layout/card.d.ts +51 -0
- package/dist/layout/card.js +76 -0
- package/dist/layout/carousel.d.ts +96 -0
- package/dist/layout/carousel.js +211 -0
- package/dist/layout/collapsible.d.ts +74 -0
- package/dist/layout/collapsible.js +126 -0
- package/dist/layout/container.d.ts +27 -0
- package/dist/layout/container.js +40 -0
- package/dist/layout/description-list.d.ts +24 -0
- package/dist/layout/description-list.js +37 -0
- package/dist/layout/grid.d.ts +40 -0
- package/dist/layout/grid.js +48 -0
- package/dist/layout/index.d.ts +15 -0
- package/dist/layout/index.js +15 -0
- package/dist/layout/item.d.ts +65 -0
- package/dist/layout/item.js +100 -0
- package/dist/layout/link.d.ts +48 -0
- package/dist/layout/link.js +63 -0
- package/dist/layout/pagination.d.ts +54 -0
- package/dist/layout/pagination.js +121 -0
- package/dist/layout/resizable.d.ts +38 -0
- package/dist/layout/resizable.js +68 -0
- package/dist/layout/sidebar.d.ts +67 -0
- package/dist/layout/sidebar.js +129 -0
- package/dist/layout/stack.d.ts +46 -0
- package/dist/layout/stack.js +62 -0
- package/dist/layout/stepper.d.ts +49 -0
- package/dist/layout/stepper.js +81 -0
- package/dist/layout/timeline.d.ts +43 -0
- package/dist/layout/timeline.js +63 -0
- package/dist/lib/aria-class.js +24 -0
- package/dist/lib/cn.js +18 -0
- package/dist/lib/compose.js +38 -0
- package/dist/lib/cva.d.ts +18 -0
- package/dist/lib/cva.js +65 -0
- package/dist/midi/_notes.d.ts +101 -0
- package/dist/midi/_notes.js +183 -0
- package/dist/midi/_ruler.d.ts +100 -0
- package/dist/midi/_ruler.js +105 -0
- package/dist/midi/_time.d.ts +107 -0
- package/dist/midi/_time.js +130 -0
- package/dist/midi/index.d.ts +9 -0
- package/dist/midi/index.js +9 -0
- package/dist/midi/musical-time-input.d.ts +48 -0
- package/dist/midi/musical-time-input.js +154 -0
- package/dist/midi/piano-keyboard.d.ts +50 -0
- package/dist/midi/piano-keyboard.js +193 -0
- package/dist/midi/spectrum-visualizer.d.ts +65 -0
- package/dist/midi/spectrum-visualizer.js +213 -0
- package/dist/midi/threshold-rail.d.ts +72 -0
- package/dist/midi/threshold-rail.js +214 -0
- package/dist/midi/timeline-ruler.d.ts +83 -0
- package/dist/midi/timeline-ruler.js +152 -0
- package/dist/overlays/_debounce.js +34 -0
- package/dist/overlays/_glyphs.js +59 -0
- package/dist/overlays/_surface.d.ts +70 -0
- package/dist/overlays/_surface.js +70 -0
- package/dist/overlays/_wheel.js +42 -0
- package/dist/overlays/alert-dialog.d.ts +67 -0
- package/dist/overlays/alert-dialog.js +117 -0
- package/dist/overlays/command-palette.d.ts +93 -0
- package/dist/overlays/command-palette.js +193 -0
- package/dist/overlays/context-menu.d.ts +64 -0
- package/dist/overlays/context-menu.js +78 -0
- package/dist/overlays/dialog.d.ts +72 -0
- package/dist/overlays/dialog.js +124 -0
- package/dist/overlays/drawer.d.ts +75 -0
- package/dist/overlays/drawer.js +151 -0
- package/dist/overlays/dropdown-menu.d.ts +79 -0
- package/dist/overlays/dropdown-menu.js +156 -0
- package/dist/overlays/hover-card.d.ts +58 -0
- package/dist/overlays/hover-card.js +91 -0
- package/dist/overlays/index.d.ts +15 -0
- package/dist/overlays/index.js +15 -0
- package/dist/overlays/info-tip.d.ts +41 -0
- package/dist/overlays/info-tip.js +45 -0
- package/dist/overlays/menubar.d.ts +72 -0
- package/dist/overlays/menubar.js +100 -0
- package/dist/overlays/popover.d.ts +66 -0
- package/dist/overlays/popover.js +114 -0
- package/dist/overlays/sheet.d.ts +78 -0
- package/dist/overlays/sheet.js +131 -0
- package/dist/overlays/toast.d.ts +106 -0
- package/dist/overlays/toast.js +146 -0
- package/dist/overlays/tooltip.d.ts +57 -0
- package/dist/overlays/tooltip.js +95 -0
- package/dist/primitives/avatar.d.ts +51 -0
- package/dist/primitives/avatar.js +93 -0
- package/dist/primitives/button.d.ts +46 -0
- package/dist/primitives/button.js +94 -0
- package/dist/primitives/chip.d.ts +47 -0
- package/dist/primitives/chip.js +152 -0
- package/dist/primitives/icon-button.d.ts +41 -0
- package/dist/primitives/icon-button.js +59 -0
- package/dist/primitives/index.d.ts +10 -0
- package/dist/primitives/index.js +10 -0
- package/dist/primitives/kbd.d.ts +17 -0
- package/dist/primitives/kbd.js +24 -0
- package/dist/primitives/separator.d.ts +25 -0
- package/dist/primitives/separator.js +30 -0
- package/dist/primitives/skeleton.d.ts +20 -0
- package/dist/primitives/skeleton.js +27 -0
- package/dist/primitives/spinner.d.ts +26 -0
- package/dist/primitives/spinner.js +31 -0
- package/dist/primitives/status-dot.d.ts +44 -0
- package/dist/primitives/status-dot.js +50 -0
- package/dist/styles.css +19 -0
- package/dist/system/density.d.ts +33 -0
- package/dist/system/density.js +49 -0
- package/dist/system/index.d.ts +8 -0
- package/dist/system/index.js +7 -0
- package/dist/system/portal.d.ts +51 -0
- package/dist/system/portal.js +122 -0
- package/dist/system/prepaint.d.ts +38 -0
- package/dist/system/prepaint.js +37 -0
- package/dist/system/theme-provider.d.ts +72 -0
- package/dist/system/theme-provider.js +252 -0
- package/dist/system/use-density.d.ts +33 -0
- package/dist/system/use-density.js +84 -0
- package/dist/system/use-isomorphic-layout-effect.js +15 -0
- package/dist/system/use-theme.d.ts +19 -0
- package/dist/system/use-theme.js +25 -0
- package/dist/theming/_presets.d.ts +11 -0
- package/dist/theming/_presets.js +487 -0
- package/dist/theming/contrast.d.ts +110 -0
- package/dist/theming/contrast.js +167 -0
- package/dist/theming/create-theme.d.ts +165 -0
- package/dist/theming/create-theme.js +442 -0
- package/dist/theming/index.d.ts +5 -0
- package/dist/theming/index.js +5 -0
- package/dist/theming/serialize.d.ts +145 -0
- package/dist/theming/serialize.js +165 -0
- package/package.json +216 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/color/_thumb.ts
|
|
2
|
+
/**
|
|
3
|
+
* The draggable puck shared by the colour area and every colour rail.
|
|
4
|
+
*
|
|
5
|
+
* The one place in this system where a ring is not a token colour: the thumb
|
|
6
|
+
* sits on top of arbitrary user colour, so it needs a light rim *and* a dark
|
|
7
|
+
* halo to stay visible against both ends of the spectrum. `--cue-fg` /
|
|
8
|
+
* `--cue-bg` supply the pair, which keeps it theme-driven without pretending a
|
|
9
|
+
* single token could do the job.
|
|
10
|
+
*
|
|
11
|
+
* @internal Not part of the public API.
|
|
12
|
+
*/
|
|
13
|
+
const colorThumbClasses = "size-[0.875rem] rounded-full border-2 border-fg shadow-[0_0_0_1px_var(--cue-bg)] outline-none data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:outline-offset-2 data-[focus-visible]:outline-accent data-[dragging]:scale-110 data-[disabled]:opacity-40";
|
|
14
|
+
//#endregion
|
|
15
|
+
export { colorThumbClasses };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { toHexString } from "./_convert.js";
|
|
2
|
+
import { parseColor } from "react-aria-components";
|
|
3
|
+
//#region src/color/_value.ts
|
|
4
|
+
/**
|
|
5
|
+
* Turn whatever the caller passed into something React Aria can hold.
|
|
6
|
+
*
|
|
7
|
+
* React Aria parses `#rgb`, `rgb()`, `hsl()` and `hsb()` and *keeps the space
|
|
8
|
+
* it was given* — which matters, because a slider for `channel="hue"` only
|
|
9
|
+
* exists on an HSL or HSB colour. So the library gets first refusal: only when
|
|
10
|
+
* it cannot parse the string (an `oklch()` token, a named colour) does this
|
|
11
|
+
* fall back to converting through culori, which necessarily lands in sRGB.
|
|
12
|
+
*
|
|
13
|
+
* Converting unconditionally would be simpler and wrong: it would quietly turn
|
|
14
|
+
* every `hsl()` into a hex value and break the hue rail.
|
|
15
|
+
*
|
|
16
|
+
* @internal Not part of the public API.
|
|
17
|
+
*/
|
|
18
|
+
function toAriaColor(value) {
|
|
19
|
+
if (typeof value !== "string") return value;
|
|
20
|
+
try {
|
|
21
|
+
return parseColor(value);
|
|
22
|
+
} catch {
|
|
23
|
+
const hex = toHexString(value);
|
|
24
|
+
return parseColor(hex ?? value);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { toAriaColor };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ColorAreaProps } from "react-aria-components";
|
|
3
|
+
//#region src/color/color-area.d.ts
|
|
4
|
+
interface ColorAreaProps$1 extends Omit<ColorAreaProps, "children"> {
|
|
5
|
+
/** Extra classes for the thumb. */
|
|
6
|
+
thumbClassName?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The two-axis colour field — saturation against brightness, by default.
|
|
10
|
+
*
|
|
11
|
+
* Wraps React Aria's `ColorArea`, so the pointer maths, the two hidden range
|
|
12
|
+
* inputs that make it keyboard- and screen-reader-operable, and the gradient
|
|
13
|
+
* background are the library's. This layer adds the rim, the radius and the
|
|
14
|
+
* shared thumb.
|
|
15
|
+
*
|
|
16
|
+
* String values may be written in any notation this suite reads, `oklch()`
|
|
17
|
+
* included — React Aria only parses sRGB, so they are converted on the way in.
|
|
18
|
+
*
|
|
19
|
+
* `react-aria-components` is an **optional peer**: import this from
|
|
20
|
+
* `@cueplusplus/ui/color`.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <ColorArea aria-label="Saturation and brightness" value={color} onChange={setColor} />
|
|
24
|
+
*/
|
|
25
|
+
declare function ColorArea$1({ className, thumbClassName, value, defaultValue, ...areaProps }: ColorAreaProps$1): React.JSX.Element;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { ColorArea$1 as ColorArea, ColorAreaProps$1 as ColorAreaProps };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ariaClassName } from "../lib/aria-class.js";
|
|
3
|
+
import { colorThumbClasses } from "./_thumb.js";
|
|
4
|
+
import { toAriaColor } from "./_value.js";
|
|
5
|
+
import "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { ColorArea, ColorThumb } from "react-aria-components";
|
|
8
|
+
//#region src/color/color-area.tsx
|
|
9
|
+
/**
|
|
10
|
+
* The two-axis colour field — saturation against brightness, by default.
|
|
11
|
+
*
|
|
12
|
+
* Wraps React Aria's `ColorArea`, so the pointer maths, the two hidden range
|
|
13
|
+
* inputs that make it keyboard- and screen-reader-operable, and the gradient
|
|
14
|
+
* background are the library's. This layer adds the rim, the radius and the
|
|
15
|
+
* shared thumb.
|
|
16
|
+
*
|
|
17
|
+
* String values may be written in any notation this suite reads, `oklch()`
|
|
18
|
+
* included — React Aria only parses sRGB, so they are converted on the way in.
|
|
19
|
+
*
|
|
20
|
+
* `react-aria-components` is an **optional peer**: import this from
|
|
21
|
+
* `@cueplusplus/ui/color`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* <ColorArea aria-label="Saturation and brightness" value={color} onChange={setColor} />
|
|
25
|
+
*/
|
|
26
|
+
function ColorArea$1({ className, thumbClassName, value, defaultValue, ...areaProps }) {
|
|
27
|
+
return /* @__PURE__ */ jsx(ColorArea, {
|
|
28
|
+
"data-slot": "color-area",
|
|
29
|
+
className: ariaClassName("relative h-[9rem] w-full touch-none rounded-(--radius-control) border border-border outline-none data-[disabled]:opacity-40", className),
|
|
30
|
+
value: toAriaColor(value),
|
|
31
|
+
defaultValue: toAriaColor(defaultValue),
|
|
32
|
+
...areaProps,
|
|
33
|
+
children: /* @__PURE__ */ jsx(ColorThumb, {
|
|
34
|
+
"data-slot": "color-thumb",
|
|
35
|
+
className: ariaClassName(colorThumbClasses, thumbClassName)
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { ColorArea$1 as ColorArea };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FormControlSize } from "../forms/_chassis.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { ColorFieldProps, InputProps } from "react-aria-components";
|
|
4
|
+
//#region src/color/color-field.d.ts
|
|
5
|
+
interface ColorFieldProps$1 extends Omit<ColorFieldProps, "children"> {
|
|
6
|
+
/** Rung of the control ladder. Defaults to `"md"`. */
|
|
7
|
+
size?: FormControlSize;
|
|
8
|
+
/** Extra classes for the input itself. */
|
|
9
|
+
inputClassName?: InputProps["className"];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A typed colour value — the whole colour as hex, or one channel as a number.
|
|
13
|
+
*
|
|
14
|
+
* Wraps React Aria's `ColorField`, so parsing, arrow-key stepping and the
|
|
15
|
+
* commit-on-blur behaviour are the library's; the input rides the same recessed
|
|
16
|
+
* chassis as every other text control.
|
|
17
|
+
*
|
|
18
|
+
* React Aria only parses sRGB notations, so it edits **hex**. For a field that
|
|
19
|
+
* also accepts `oklch()` — the notation this system's tokens are authored in —
|
|
20
|
+
* use `ColorPicker`, which owns the conversion.
|
|
21
|
+
*
|
|
22
|
+
* `react-aria-components` is an **optional peer**: import this from
|
|
23
|
+
* `@cueplusplus/ui/color`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* <ColorField aria-label="Accent" value={color} onChange={setColor} />
|
|
27
|
+
* @example
|
|
28
|
+
* <ColorField aria-label="Red" channel="red" colorSpace="rgb" size="sm" />
|
|
29
|
+
*/
|
|
30
|
+
declare function ColorField$1({ size, className, inputClassName, value, defaultValue, ...fieldProps }: ColorFieldProps$1): React.JSX.Element;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { ColorField$1 as ColorField, ColorFieldProps$1 as ColorFieldProps };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { controlVariants } from "../forms/_chassis.js";
|
|
4
|
+
import { ariaClassName } from "../lib/aria-class.js";
|
|
5
|
+
import { toAriaColor } from "./_value.js";
|
|
6
|
+
import "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { ColorField, Input } from "react-aria-components";
|
|
9
|
+
//#region src/color/color-field.tsx
|
|
10
|
+
/**
|
|
11
|
+
* A typed colour value — the whole colour as hex, or one channel as a number.
|
|
12
|
+
*
|
|
13
|
+
* Wraps React Aria's `ColorField`, so parsing, arrow-key stepping and the
|
|
14
|
+
* commit-on-blur behaviour are the library's; the input rides the same recessed
|
|
15
|
+
* chassis as every other text control.
|
|
16
|
+
*
|
|
17
|
+
* React Aria only parses sRGB notations, so it edits **hex**. For a field that
|
|
18
|
+
* also accepts `oklch()` — the notation this system's tokens are authored in —
|
|
19
|
+
* use `ColorPicker`, which owns the conversion.
|
|
20
|
+
*
|
|
21
|
+
* `react-aria-components` is an **optional peer**: import this from
|
|
22
|
+
* `@cueplusplus/ui/color`.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* <ColorField aria-label="Accent" value={color} onChange={setColor} />
|
|
26
|
+
* @example
|
|
27
|
+
* <ColorField aria-label="Red" channel="red" colorSpace="rgb" size="sm" />
|
|
28
|
+
*/
|
|
29
|
+
function ColorField$1({ size, className, inputClassName, value, defaultValue, ...fieldProps }) {
|
|
30
|
+
return /* @__PURE__ */ jsx(ColorField, {
|
|
31
|
+
"data-slot": "color-field",
|
|
32
|
+
className: ariaClassName("inline-flex flex-col gap-(--cue-space-1)", className),
|
|
33
|
+
value: toAriaColor(value),
|
|
34
|
+
defaultValue: toAriaColor(defaultValue),
|
|
35
|
+
...fieldProps,
|
|
36
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
37
|
+
"data-slot": "color-field-input",
|
|
38
|
+
className: ariaClassName(cn(controlVariants({ size }), "uppercase"), inputClassName)
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { ColorField$1 as ColorField };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ColorFormat } from "./_convert.js";
|
|
2
|
+
import { FormControlSize } from "../forms/_chassis.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
//#region src/color/color-picker.d.ts
|
|
5
|
+
interface ColorPickerProps {
|
|
6
|
+
/** The colour, in any notation this suite reads. Use with `onValueChange`. */
|
|
7
|
+
value?: string;
|
|
8
|
+
/** Initial colour for an uncontrolled picker. Defaults to `"#000000"`. */
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
/** Called with the new colour, written in the picker's output notation. */
|
|
11
|
+
onValueChange?: (value: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Notation to write back. Defaults to the notation the current value arrived
|
|
14
|
+
* in — hand it an `oklch()` token and you get `oklch()` back, so editing a
|
|
15
|
+
* theme file never silently rewrites it into hex.
|
|
16
|
+
*/
|
|
17
|
+
format?: ColorFormat;
|
|
18
|
+
/** Show the alpha rail and keep alpha in the output. Defaults to `false`. */
|
|
19
|
+
alpha?: boolean;
|
|
20
|
+
/** Accessible name for the trigger. Defaults to `"Color"`. */
|
|
21
|
+
label?: string;
|
|
22
|
+
/** Rung of the control ladder. Defaults to `"md"`. */
|
|
23
|
+
size?: FormControlSize;
|
|
24
|
+
/** Prevent opening and grey the trigger out. */
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/** Print the value beside the swatch on the trigger. Defaults to `true`. */
|
|
27
|
+
showValue?: boolean;
|
|
28
|
+
/** Name for the hidden input, when the picker is part of a form. */
|
|
29
|
+
name?: string;
|
|
30
|
+
/** Id forwarded to the trigger. */
|
|
31
|
+
id?: string;
|
|
32
|
+
/** Extra classes for the trigger. */
|
|
33
|
+
className?: string;
|
|
34
|
+
/** Extra classes for the popup surface. */
|
|
35
|
+
popupClassName?: string;
|
|
36
|
+
/** Open state, for a controlled popover. */
|
|
37
|
+
open?: boolean;
|
|
38
|
+
/** Initial open state. */
|
|
39
|
+
defaultOpen?: boolean;
|
|
40
|
+
/** Called when the popover opens or closes. */
|
|
41
|
+
onOpenChange?: (open: boolean) => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A colour, edited in a popover: two-axis area, hue rail, optional alpha rail,
|
|
45
|
+
* a text field that speaks hex *and* oklch, and an eyedropper where the browser
|
|
46
|
+
* has one.
|
|
47
|
+
*
|
|
48
|
+
* Composed from the React Aria colour parts rather than wrapping a single
|
|
49
|
+
* primitive, because no primitive owns the combination. Two decisions are this
|
|
50
|
+
* component's own:
|
|
51
|
+
*
|
|
52
|
+
* - **Notation in, notation out.** React Aria only parses sRGB; this system's
|
|
53
|
+
* tokens are authored in `oklch()`. The picker converts on both edges
|
|
54
|
+
* (culori), and writes back in the notation it was given unless `format` says
|
|
55
|
+
* otherwise. This is what makes it usable as the theme configurator's editor.
|
|
56
|
+
* - **Hue survives black.** The working colour is held as HSB and only re-read
|
|
57
|
+
* from the incoming string when that string changes for some *other* reason,
|
|
58
|
+
* so dragging the area down to black and back does not reset the hue — the
|
|
59
|
+
* defect every naive "derive state from the value" picker has.
|
|
60
|
+
*
|
|
61
|
+
* `react-aria-components` is an **optional peer**: import this from
|
|
62
|
+
* `@cueplusplus/ui/color`.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* <ColorPicker label="Accent" value={accent} onValueChange={setAccent} />
|
|
66
|
+
* @example
|
|
67
|
+
* <ColorPicker label="Scrim" value="oklch(0.2 0 0 / 0.55)" alpha format="oklch" />
|
|
68
|
+
*/
|
|
69
|
+
declare function ColorPicker({ value, defaultValue, onValueChange, format, alpha, label, size, disabled, showValue, name, id, className, popupClassName, open, defaultOpen, onOpenChange }: ColorPickerProps): React.JSX.Element;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { ColorPicker, ColorPickerProps };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { controlVariants } from "../forms/_chassis.js";
|
|
4
|
+
import { IconButton } from "../primitives/icon-button.js";
|
|
5
|
+
import { Popover } from "../overlays/popover.js";
|
|
6
|
+
import { detectColorFormat, formatColorString, toHexString } from "./_convert.js";
|
|
7
|
+
import { ColorArea as ColorArea$1 } from "./color-area.js";
|
|
8
|
+
import { EyedropperGlyph } from "./_glyphs.js";
|
|
9
|
+
import { ColorSlider as ColorSlider$1 } from "./color-slider.js";
|
|
10
|
+
import { ColorSwatch as ColorSwatch$1 } from "./color-swatch.js";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { parseColor } from "react-aria-components";
|
|
14
|
+
//#region src/color/color-picker.tsx
|
|
15
|
+
/** Fallback when a caller opens the picker with nothing selected. */
|
|
16
|
+
const FALLBACK_COLOR = "#000000";
|
|
17
|
+
/** Parse anything the suite reads into the HSB colour the parts work in. */
|
|
18
|
+
function toHsb(input) {
|
|
19
|
+
return parseColor(toHexString(input) ?? FALLBACK_COLOR).toFormat("hsb");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A colour, edited in a popover: two-axis area, hue rail, optional alpha rail,
|
|
23
|
+
* a text field that speaks hex *and* oklch, and an eyedropper where the browser
|
|
24
|
+
* has one.
|
|
25
|
+
*
|
|
26
|
+
* Composed from the React Aria colour parts rather than wrapping a single
|
|
27
|
+
* primitive, because no primitive owns the combination. Two decisions are this
|
|
28
|
+
* component's own:
|
|
29
|
+
*
|
|
30
|
+
* - **Notation in, notation out.** React Aria only parses sRGB; this system's
|
|
31
|
+
* tokens are authored in `oklch()`. The picker converts on both edges
|
|
32
|
+
* (culori), and writes back in the notation it was given unless `format` says
|
|
33
|
+
* otherwise. This is what makes it usable as the theme configurator's editor.
|
|
34
|
+
* - **Hue survives black.** The working colour is held as HSB and only re-read
|
|
35
|
+
* from the incoming string when that string changes for some *other* reason,
|
|
36
|
+
* so dragging the area down to black and back does not reset the hue — the
|
|
37
|
+
* defect every naive "derive state from the value" picker has.
|
|
38
|
+
*
|
|
39
|
+
* `react-aria-components` is an **optional peer**: import this from
|
|
40
|
+
* `@cueplusplus/ui/color`.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* <ColorPicker label="Accent" value={accent} onValueChange={setAccent} />
|
|
44
|
+
* @example
|
|
45
|
+
* <ColorPicker label="Scrim" value="oklch(0.2 0 0 / 0.55)" alpha format="oklch" />
|
|
46
|
+
*/
|
|
47
|
+
function ColorPicker({ value, defaultValue, onValueChange, format, alpha = false, label = "Color", size, disabled, showValue = true, name, id, className, popupClassName, open, defaultOpen, onOpenChange }) {
|
|
48
|
+
const [uncontrolled, setUncontrolled] = React.useState(defaultValue ?? FALLBACK_COLOR);
|
|
49
|
+
const current = value ?? uncontrolled;
|
|
50
|
+
const outputFormat = format ?? detectColorFormat(current);
|
|
51
|
+
const [color, setColor] = React.useState(() => toHsb(current));
|
|
52
|
+
const emitted = React.useRef(null);
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
if (current === emitted.current) return;
|
|
55
|
+
setColor(toHsb(current));
|
|
56
|
+
}, [current]);
|
|
57
|
+
const [draft, setDraft] = React.useState(current);
|
|
58
|
+
const [draftInvalid, setDraftInvalid] = React.useState(false);
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
setDraft(current);
|
|
61
|
+
setDraftInvalid(false);
|
|
62
|
+
}, [current]);
|
|
63
|
+
const [hasEyeDropper, setHasEyeDropper] = React.useState(false);
|
|
64
|
+
React.useEffect(() => {
|
|
65
|
+
setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
|
|
66
|
+
}, []);
|
|
67
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen ?? false);
|
|
68
|
+
const isOpen = open ?? uncontrolledOpen;
|
|
69
|
+
const setOpen = (next) => {
|
|
70
|
+
if (open === void 0) setUncontrolledOpen(next);
|
|
71
|
+
onOpenChange?.(next);
|
|
72
|
+
};
|
|
73
|
+
const applyColor = (next) => {
|
|
74
|
+
setColor(next);
|
|
75
|
+
const hex = next.toString(alpha ? "hexa" : "hex");
|
|
76
|
+
const out = formatColorString(hex, outputFormat) ?? hex;
|
|
77
|
+
emitted.current = out;
|
|
78
|
+
if (value === void 0) setUncontrolled(out);
|
|
79
|
+
onValueChange?.(out);
|
|
80
|
+
};
|
|
81
|
+
const applyString = (next) => {
|
|
82
|
+
const hex = toHexString(next);
|
|
83
|
+
if (hex === null) {
|
|
84
|
+
setDraftInvalid(true);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
setDraftInvalid(false);
|
|
88
|
+
applyColor(parseColor(hex).toFormat("hsb"));
|
|
89
|
+
};
|
|
90
|
+
const pickFromScreen = () => {
|
|
91
|
+
const EyeDropper = globalThis.EyeDropper;
|
|
92
|
+
if (EyeDropper === void 0) return;
|
|
93
|
+
new EyeDropper().open().then((result) => applyString(result.sRGBHex)).catch(() => {});
|
|
94
|
+
};
|
|
95
|
+
return /* @__PURE__ */ jsxs(Popover.Root, {
|
|
96
|
+
open: isOpen,
|
|
97
|
+
onOpenChange: setOpen,
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ jsxs(Popover.Trigger, {
|
|
100
|
+
render: /* @__PURE__ */ jsx("button", {
|
|
101
|
+
type: "button",
|
|
102
|
+
id,
|
|
103
|
+
disabled,
|
|
104
|
+
"aria-label": label,
|
|
105
|
+
"data-slot": "color-picker-trigger",
|
|
106
|
+
className: cn(controlVariants({ size }), "flex w-auto cursor-pointer items-center gap-(--cue-space-2) text-left", className)
|
|
107
|
+
}),
|
|
108
|
+
children: [/* @__PURE__ */ jsx(ColorSwatch$1, {
|
|
109
|
+
color,
|
|
110
|
+
size: "sm"
|
|
111
|
+
}), showValue ? /* @__PURE__ */ jsx("span", {
|
|
112
|
+
className: "truncate tabular-nums",
|
|
113
|
+
children: current
|
|
114
|
+
}) : null]
|
|
115
|
+
}),
|
|
116
|
+
/* @__PURE__ */ jsxs(Popover.Content, {
|
|
117
|
+
className: cn("w-[14rem] gap-(--cue-space-3) p-(--cue-space-3)", popupClassName),
|
|
118
|
+
align: "start",
|
|
119
|
+
"data-slot": "color-picker-popup",
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ jsx(ColorArea$1, {
|
|
122
|
+
"aria-label": "Saturation and brightness",
|
|
123
|
+
xChannel: "saturation",
|
|
124
|
+
yChannel: "brightness",
|
|
125
|
+
value: color,
|
|
126
|
+
onChange: applyColor
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ jsxs("div", {
|
|
129
|
+
className: "flex items-center gap-(--cue-space-2)",
|
|
130
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
131
|
+
className: "flex min-w-0 flex-1 flex-col gap-(--cue-space-2)",
|
|
132
|
+
children: [/* @__PURE__ */ jsx(ColorSlider$1, {
|
|
133
|
+
"aria-label": "Hue",
|
|
134
|
+
channel: "hue",
|
|
135
|
+
value: color,
|
|
136
|
+
onChange: applyColor
|
|
137
|
+
}), alpha ? /* @__PURE__ */ jsx(ColorSlider$1, {
|
|
138
|
+
"aria-label": "Alpha",
|
|
139
|
+
channel: "alpha",
|
|
140
|
+
value: color,
|
|
141
|
+
onChange: applyColor
|
|
142
|
+
}) : null]
|
|
143
|
+
}), hasEyeDropper ? /* @__PURE__ */ jsx(IconButton, {
|
|
144
|
+
"aria-label": "Pick a color from the screen",
|
|
145
|
+
icon: EyedropperGlyph,
|
|
146
|
+
size: "sm",
|
|
147
|
+
onClick: pickFromScreen
|
|
148
|
+
}) : null]
|
|
149
|
+
}),
|
|
150
|
+
/* @__PURE__ */ jsx("input", {
|
|
151
|
+
type: "text",
|
|
152
|
+
"aria-label": "Color value",
|
|
153
|
+
"aria-invalid": draftInvalid ? "true" : void 0,
|
|
154
|
+
spellCheck: false,
|
|
155
|
+
autoComplete: "off",
|
|
156
|
+
"data-slot": "color-picker-value",
|
|
157
|
+
className: cn(controlVariants({ size: "sm" }), "font-mono"),
|
|
158
|
+
value: draft,
|
|
159
|
+
onChange: (event) => setDraft(event.target.value),
|
|
160
|
+
onBlur: () => applyString(draft),
|
|
161
|
+
onKeyDown: (event) => {
|
|
162
|
+
if (event.key !== "Enter") return;
|
|
163
|
+
event.preventDefault();
|
|
164
|
+
applyString(draft);
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
]
|
|
168
|
+
}),
|
|
169
|
+
name === void 0 ? null : /* @__PURE__ */ jsx("input", {
|
|
170
|
+
type: "hidden",
|
|
171
|
+
name,
|
|
172
|
+
value: current
|
|
173
|
+
})
|
|
174
|
+
]
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
export { ColorPicker };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ColorSliderProps } from "react-aria-components";
|
|
3
|
+
//#region src/color/color-slider.d.ts
|
|
4
|
+
interface ColorSliderProps$1 extends Omit<ColorSliderProps, "children"> {
|
|
5
|
+
/** Extra classes for the frame around the track. */
|
|
6
|
+
frameClassName?: string;
|
|
7
|
+
/** Extra classes for the gradient track. */
|
|
8
|
+
trackClassName?: string;
|
|
9
|
+
/** Extra classes for the thumb. */
|
|
10
|
+
thumbClassName?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* One channel of a colour, as a rail: hue, alpha, lightness, a single RGB
|
|
14
|
+
* channel.
|
|
15
|
+
*
|
|
16
|
+
* Wraps React Aria's `ColorSlider`, which paints the channel's gradient and
|
|
17
|
+
* owns the keyboard and pointer behaviour. The alpha channel gets the
|
|
18
|
+
* transparency checkerboard — without it, "half transparent" and "half grey"
|
|
19
|
+
* are the same picture. It goes on the frame rather than the track because
|
|
20
|
+
* React Aria writes the gradient into the track's inline `background`, which
|
|
21
|
+
* would paint straight over a checkerboard set by a class.
|
|
22
|
+
*
|
|
23
|
+
* `react-aria-components` is an **optional peer**: import this from
|
|
24
|
+
* `@cueplusplus/ui/color`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* <ColorSlider aria-label="Hue" channel="hue" value={color} onChange={setColor} />
|
|
28
|
+
*/
|
|
29
|
+
declare function ColorSlider$1({ className, frameClassName, trackClassName, thumbClassName, channel, value, defaultValue, ...sliderProps }: ColorSliderProps$1): React.JSX.Element;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { ColorSlider$1 as ColorSlider, ColorSliderProps$1 as ColorSliderProps };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { ariaClassName } from "../lib/aria-class.js";
|
|
4
|
+
import { colorThumbClasses } from "./_thumb.js";
|
|
5
|
+
import { toAriaColor } from "./_value.js";
|
|
6
|
+
import "./_checker.js";
|
|
7
|
+
import "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { ColorSlider, ColorThumb, SliderTrack } from "react-aria-components";
|
|
10
|
+
//#region src/color/color-slider.tsx
|
|
11
|
+
/**
|
|
12
|
+
* One channel of a colour, as a rail: hue, alpha, lightness, a single RGB
|
|
13
|
+
* channel.
|
|
14
|
+
*
|
|
15
|
+
* Wraps React Aria's `ColorSlider`, which paints the channel's gradient and
|
|
16
|
+
* owns the keyboard and pointer behaviour. The alpha channel gets the
|
|
17
|
+
* transparency checkerboard — without it, "half transparent" and "half grey"
|
|
18
|
+
* are the same picture. It goes on the frame rather than the track because
|
|
19
|
+
* React Aria writes the gradient into the track's inline `background`, which
|
|
20
|
+
* would paint straight over a checkerboard set by a class.
|
|
21
|
+
*
|
|
22
|
+
* `react-aria-components` is an **optional peer**: import this from
|
|
23
|
+
* `@cueplusplus/ui/color`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* <ColorSlider aria-label="Hue" channel="hue" value={color} onChange={setColor} />
|
|
27
|
+
*/
|
|
28
|
+
function ColorSlider$1({ className, frameClassName, trackClassName, thumbClassName, channel, value, defaultValue, ...sliderProps }) {
|
|
29
|
+
return /* @__PURE__ */ jsx(ColorSlider, {
|
|
30
|
+
"data-slot": "color-slider",
|
|
31
|
+
channel,
|
|
32
|
+
className: ariaClassName("w-full touch-none data-[disabled]:opacity-40", className),
|
|
33
|
+
value: toAriaColor(value),
|
|
34
|
+
defaultValue: toAriaColor(defaultValue),
|
|
35
|
+
...sliderProps,
|
|
36
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
37
|
+
"data-slot": "color-slider-frame",
|
|
38
|
+
className: cn("relative rounded-full border border-border", channel === "alpha" && "bg-[repeating-conic-gradient(var(--cue-surface-3)_0%_25%,var(--cue-surface-1)_0%_50%)] bg-[length:0.5rem_0.5rem]", frameClassName),
|
|
39
|
+
children: /* @__PURE__ */ jsx(SliderTrack, {
|
|
40
|
+
"data-slot": "color-slider-track",
|
|
41
|
+
className: ariaClassName("relative h-icon-sm w-full rounded-full", trackClassName),
|
|
42
|
+
children: /* @__PURE__ */ jsx(ColorThumb, {
|
|
43
|
+
"data-slot": "color-thumb",
|
|
44
|
+
className: ariaClassName(cn(colorThumbClasses, "top-1/2"), thumbClassName)
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { ColorSlider$1 as ColorSlider };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ColorSwatchProps } from "react-aria-components";
|
|
3
|
+
//#region src/color/color-swatch.d.ts
|
|
4
|
+
/** Rung of the icon ladder a swatch sits on. */
|
|
5
|
+
type ColorSwatchSize = "sm" | "md" | "lg";
|
|
6
|
+
interface ColorSwatchProps$1 extends Omit<ColorSwatchProps, "className"> {
|
|
7
|
+
/** Rung of the icon ladder. Defaults to `"md"`. */
|
|
8
|
+
size?: ColorSwatchSize;
|
|
9
|
+
/** Extra classes for the frame. */
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A colour, shown as a chip.
|
|
14
|
+
*
|
|
15
|
+
* Two elements rather than one: the frame carries the rim, the radius and the
|
|
16
|
+
* transparency checkerboard, and React Aria's `ColorSwatch` paints the colour
|
|
17
|
+
* on top of it. One element cannot do both — the library writes the colour into
|
|
18
|
+
* the inline `background-color`, which paints *behind* a background image, so a
|
|
19
|
+
* checkerboard set on the same element would cover the colour instead of
|
|
20
|
+
* backing it.
|
|
21
|
+
*
|
|
22
|
+
* Takes any notation this suite reads, `oklch()` included.
|
|
23
|
+
*
|
|
24
|
+
* `react-aria-components` is an **optional peer**: import this from
|
|
25
|
+
* `@cueplusplus/ui/color`.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* <ColorSwatch color="oklch(0.7 0.15 30)" />
|
|
29
|
+
*/
|
|
30
|
+
declare function ColorSwatch$1({ size, className, color, ...swatchProps }: ColorSwatchProps$1): React.JSX.Element;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { ColorSwatch$1 as ColorSwatch, ColorSwatchProps$1 as ColorSwatchProps, ColorSwatchSize };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { toAriaColor } from "./_value.js";
|
|
4
|
+
import { checkerClasses } from "./_checker.js";
|
|
5
|
+
import "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { ColorSwatch } from "react-aria-components";
|
|
8
|
+
//#region src/color/color-swatch.tsx
|
|
9
|
+
const SWATCH_SIZES = {
|
|
10
|
+
sm: "size-icon-sm",
|
|
11
|
+
md: "size-icon-md",
|
|
12
|
+
lg: "size-control-sm"
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A colour, shown as a chip.
|
|
16
|
+
*
|
|
17
|
+
* Two elements rather than one: the frame carries the rim, the radius and the
|
|
18
|
+
* transparency checkerboard, and React Aria's `ColorSwatch` paints the colour
|
|
19
|
+
* on top of it. One element cannot do both — the library writes the colour into
|
|
20
|
+
* the inline `background-color`, which paints *behind* a background image, so a
|
|
21
|
+
* checkerboard set on the same element would cover the colour instead of
|
|
22
|
+
* backing it.
|
|
23
|
+
*
|
|
24
|
+
* Takes any notation this suite reads, `oklch()` included.
|
|
25
|
+
*
|
|
26
|
+
* `react-aria-components` is an **optional peer**: import this from
|
|
27
|
+
* `@cueplusplus/ui/color`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* <ColorSwatch color="oklch(0.7 0.15 30)" />
|
|
31
|
+
*/
|
|
32
|
+
function ColorSwatch$1({ size = "md", className, color, ...swatchProps }) {
|
|
33
|
+
return /* @__PURE__ */ jsx("span", {
|
|
34
|
+
"data-slot": "color-swatch",
|
|
35
|
+
className: cn("relative inline-block shrink-0 overflow-hidden rounded-(--radius-control) border border-border", SWATCH_SIZES[size], checkerClasses, className),
|
|
36
|
+
children: /* @__PURE__ */ jsx(ColorSwatch, {
|
|
37
|
+
color: toAriaColor(color),
|
|
38
|
+
className: "block size-full",
|
|
39
|
+
...swatchProps
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { ColorSwatch$1 as ColorSwatch };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ColorFormat, detectColorFormat, formatColorString, toHexString } from "./_convert.js";
|
|
2
|
+
import { ColorArea, ColorAreaProps } from "./color-area.js";
|
|
3
|
+
import { ColorField, ColorFieldProps } from "./color-field.js";
|
|
4
|
+
import { ColorPicker, ColorPickerProps } from "./color-picker.js";
|
|
5
|
+
import { ColorSlider, ColorSliderProps } from "./color-slider.js";
|
|
6
|
+
import { ColorSwatch, ColorSwatchProps, ColorSwatchSize } from "./color-swatch.js";
|
|
7
|
+
export { ColorArea, type ColorAreaProps, ColorField, type ColorFieldProps, type ColorFormat, ColorPicker, type ColorPickerProps, ColorSlider, type ColorSliderProps, ColorSwatch, type ColorSwatchProps, type ColorSwatchSize, detectColorFormat, formatColorString, toHexString };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { detectColorFormat, formatColorString, toHexString } from "./_convert.js";
|
|
2
|
+
import { ColorArea } from "./color-area.js";
|
|
3
|
+
import { ColorField } from "./color-field.js";
|
|
4
|
+
import { ColorSlider } from "./color-slider.js";
|
|
5
|
+
import { ColorSwatch } from "./color-swatch.js";
|
|
6
|
+
import { ColorPicker } from "./color-picker.js";
|
|
7
|
+
export { ColorArea, ColorField, ColorPicker, ColorSlider, ColorSwatch, detectColorFormat, formatColorString, toHexString };
|