@sdxc/ui 0.0.0-pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +812 -0
- package/dist/animations/index.d.ts +12 -0
- package/dist/animations/index.js +12 -0
- package/dist/animations/keyframes.d.ts +162 -0
- package/dist/animations/keyframes.js +297 -0
- package/dist/animations/scroll.d.ts +154 -0
- package/dist/animations/scroll.js +228 -0
- package/dist/animations/tokens.d.ts +47 -0
- package/dist/animations/tokens.js +47 -0
- package/dist/animations/transitions.d.ts +143 -0
- package/dist/animations/transitions.js +147 -0
- package/dist/behaviors/announcer.d.ts +90 -0
- package/dist/behaviors/announcer.js +93 -0
- package/dist/behaviors/calendar-model.d.ts +218 -0
- package/dist/behaviors/calendar-model.js +376 -0
- package/dist/behaviors/drag-session.d.ts +119 -0
- package/dist/behaviors/drag-session.js +110 -0
- package/dist/behaviors/filter-model.d.ts +117 -0
- package/dist/behaviors/filter-model.js +185 -0
- package/dist/behaviors/index.d.ts +16 -0
- package/dist/behaviors/index.js +16 -0
- package/dist/behaviors/resize-session.d.ts +115 -0
- package/dist/behaviors/resize-session.js +157 -0
- package/dist/behaviors/scroll-follow-model.d.ts +180 -0
- package/dist/behaviors/scroll-follow-model.js +197 -0
- package/dist/behaviors/selection-model.d.ts +129 -0
- package/dist/behaviors/selection-model.js +259 -0
- package/dist/behaviors/toaster.d.ts +144 -0
- package/dist/behaviors/toaster.js +228 -0
- package/dist/components/accordion.d.ts +93 -0
- package/dist/components/accordion.js +165 -0
- package/dist/components/alert-dialog.d.ts +110 -0
- package/dist/components/alert-dialog.js +169 -0
- package/dist/components/alert.d.ts +109 -0
- package/dist/components/alert.js +160 -0
- package/dist/components/aspect-ratio.d.ts +44 -0
- package/dist/components/aspect-ratio.js +35 -0
- package/dist/components/attachment.d.ts +146 -0
- package/dist/components/attachment.js +320 -0
- package/dist/components/avatar.d.ts +118 -0
- package/dist/components/avatar.js +89 -0
- package/dist/components/badge.d.ts +66 -0
- package/dist/components/badge.js +129 -0
- package/dist/components/breadcrumbs.d.ts +67 -0
- package/dist/components/breadcrumbs.js +121 -0
- package/dist/components/bubble.d.ts +91 -0
- package/dist/components/bubble.js +216 -0
- package/dist/components/button.d.ts +78 -0
- package/dist/components/button.js +207 -0
- package/dist/components/calendar.d.ts +166 -0
- package/dist/components/calendar.js +320 -0
- package/dist/components/card.d.ts +82 -0
- package/dist/components/card.js +126 -0
- package/dist/components/carousel.d.ts +96 -0
- package/dist/components/carousel.js +214 -0
- package/dist/components/chart.d.ts +485 -0
- package/dist/components/chart.js +563 -0
- package/dist/components/checkbox-group.d.ts +58 -0
- package/dist/components/checkbox-group.js +53 -0
- package/dist/components/checkbox.d.ts +61 -0
- package/dist/components/checkbox.js +81 -0
- package/dist/components/color-area.d.ts +83 -0
- package/dist/components/color-area.js +251 -0
- package/dist/components/color-field.d.ts +128 -0
- package/dist/components/color-field.js +73 -0
- package/dist/components/color-picker.d.ts +132 -0
- package/dist/components/color-picker.js +183 -0
- package/dist/components/color-slider.d.ts +103 -0
- package/dist/components/color-slider.js +198 -0
- package/dist/components/color-swatch-picker.d.ts +106 -0
- package/dist/components/color-swatch-picker.js +75 -0
- package/dist/components/color-swatch.d.ts +57 -0
- package/dist/components/color-swatch.js +82 -0
- package/dist/components/color-wheel.d.ts +58 -0
- package/dist/components/color-wheel.js +160 -0
- package/dist/components/combobox.d.ts +73 -0
- package/dist/components/combobox.js +108 -0
- package/dist/components/command.d.ts +80 -0
- package/dist/components/command.js +151 -0
- package/dist/components/confirm.d.ts +124 -0
- package/dist/components/confirm.js +56 -0
- package/dist/components/context-menu.d.ts +108 -0
- package/dist/components/context-menu.js +200 -0
- package/dist/components/date-field.d.ts +110 -0
- package/dist/components/date-field.js +49 -0
- package/dist/components/date-picker.d.ts +136 -0
- package/dist/components/date-picker.js +155 -0
- package/dist/components/date-range-picker.d.ts +152 -0
- package/dist/components/date-range-picker.js +106 -0
- package/dist/components/description.d.ts +36 -0
- package/dist/components/description.js +21 -0
- package/dist/components/dialog.d.ts +97 -0
- package/dist/components/dialog.js +203 -0
- package/dist/components/disclosure.d.ts +85 -0
- package/dist/components/disclosure.js +180 -0
- package/dist/components/drawer.d.ts +82 -0
- package/dist/components/drawer.js +162 -0
- package/dist/components/drop-indicator.d.ts +43 -0
- package/dist/components/drop-indicator.js +47 -0
- package/dist/components/drop-zone.d.ts +73 -0
- package/dist/components/drop-zone.js +54 -0
- package/dist/components/empty.d.ts +89 -0
- package/dist/components/empty.js +129 -0
- package/dist/components/field-error.d.ts +41 -0
- package/dist/components/field-error.js +36 -0
- package/dist/components/file-trigger.d.ts +84 -0
- package/dist/components/file-trigger.js +169 -0
- package/dist/components/form.d.ts +118 -0
- package/dist/components/form.js +113 -0
- package/dist/components/grid-list.d.ts +112 -0
- package/dist/components/grid-list.js +220 -0
- package/dist/components/group.d.ts +45 -0
- package/dist/components/group.js +44 -0
- package/dist/components/header.d.ts +33 -0
- package/dist/components/header.js +29 -0
- package/dist/components/heading-scope.d.ts +83 -0
- package/dist/components/heading-scope.js +82 -0
- package/dist/components/heading.d.ts +50 -0
- package/dist/components/heading.js +31 -0
- package/dist/components/hover-card.d.ts +77 -0
- package/dist/components/hover-card.js +151 -0
- package/dist/components/image-placeholder.d.ts +105 -0
- package/dist/components/image-placeholder.js +212 -0
- package/dist/components/index.d.ts +109 -0
- package/dist/components/index.js +109 -0
- package/dist/components/input.d.ts +53 -0
- package/dist/components/input.js +76 -0
- package/dist/components/item.d.ts +97 -0
- package/dist/components/item.js +185 -0
- package/dist/components/keyboard.d.ts +33 -0
- package/dist/components/keyboard.js +20 -0
- package/dist/components/label.d.ts +38 -0
- package/dist/components/label.js +24 -0
- package/dist/components/link-button.d.ts +59 -0
- package/dist/components/link-button.js +174 -0
- package/dist/components/link.d.ts +43 -0
- package/dist/components/link.js +85 -0
- package/dist/components/listbox.d.ts +119 -0
- package/dist/components/listbox.js +114 -0
- package/dist/components/logo.d.ts +117 -0
- package/dist/components/logo.js +89 -0
- package/dist/components/marker.d.ts +82 -0
- package/dist/components/marker.js +163 -0
- package/dist/components/menu.d.ts +90 -0
- package/dist/components/menu.js +146 -0
- package/dist/components/menubar.d.ts +54 -0
- package/dist/components/menubar.js +118 -0
- package/dist/components/message-scroller.d.ts +109 -0
- package/dist/components/message-scroller.js +180 -0
- package/dist/components/message.d.ts +104 -0
- package/dist/components/message.js +200 -0
- package/dist/components/meter.d.ts +60 -0
- package/dist/components/meter.js +110 -0
- package/dist/components/modal.d.ts +71 -0
- package/dist/components/modal.js +120 -0
- package/dist/components/nav-link.d.ts +53 -0
- package/dist/components/nav-link.js +83 -0
- package/dist/components/navigation-menu.d.ts +150 -0
- package/dist/components/navigation-menu.js +381 -0
- package/dist/components/number-field.d.ts +76 -0
- package/dist/components/number-field.js +190 -0
- package/dist/components/otp-field.d.ts +68 -0
- package/dist/components/otp-field.js +46 -0
- package/dist/components/overlay-arrow.d.ts +51 -0
- package/dist/components/overlay-arrow.js +77 -0
- package/dist/components/pagination.d.ts +67 -0
- package/dist/components/pagination.js +164 -0
- package/dist/components/popover.d.ts +69 -0
- package/dist/components/popover.js +68 -0
- package/dist/components/progress-bar.d.ts +53 -0
- package/dist/components/progress-bar.js +90 -0
- package/dist/components/radio-group.d.ts +102 -0
- package/dist/components/radio-group.js +114 -0
- package/dist/components/range-calendar.d.ts +169 -0
- package/dist/components/range-calendar.js +216 -0
- package/dist/components/resizable.d.ts +98 -0
- package/dist/components/resizable.js +151 -0
- package/dist/components/scroll-area.d.ts +54 -0
- package/dist/components/scroll-area.js +89 -0
- package/dist/components/search-field.d.ts +55 -0
- package/dist/components/search-field.js +49 -0
- package/dist/components/section.d.ts +37 -0
- package/dist/components/section.js +22 -0
- package/dist/components/select.d.ts +96 -0
- package/dist/components/select.js +285 -0
- package/dist/components/selection-indicator.d.ts +47 -0
- package/dist/components/selection-indicator.js +50 -0
- package/dist/components/sentinel-row.d.ts +22 -0
- package/dist/components/sentinel-row.js +29 -0
- package/dist/components/separator.d.ts +35 -0
- package/dist/components/separator.js +48 -0
- package/dist/components/shared-element.d.ts +45 -0
- package/dist/components/shared-element.js +48 -0
- package/dist/components/sheet.d.ts +78 -0
- package/dist/components/sheet.js +167 -0
- package/dist/components/sidebar.d.ts +288 -0
- package/dist/components/sidebar.js +1068 -0
- package/dist/components/skeleton.d.ts +36 -0
- package/dist/components/skeleton.js +38 -0
- package/dist/components/slider.d.ts +102 -0
- package/dist/components/slider.js +179 -0
- package/dist/components/spinner.d.ts +55 -0
- package/dist/components/spinner.js +51 -0
- package/dist/components/switch.d.ts +47 -0
- package/dist/components/switch.js +82 -0
- package/dist/components/table.d.ts +139 -0
- package/dist/components/table.js +216 -0
- package/dist/components/tabs.d.ts +124 -0
- package/dist/components/tabs.js +246 -0
- package/dist/components/tag-group.d.ts +83 -0
- package/dist/components/tag-group.js +157 -0
- package/dist/components/text-field.d.ts +119 -0
- package/dist/components/text-field.js +51 -0
- package/dist/components/text.d.ts +34 -0
- package/dist/components/text.js +19 -0
- package/dist/components/textarea.d.ts +52 -0
- package/dist/components/textarea.js +82 -0
- package/dist/components/time-field.d.ts +110 -0
- package/dist/components/time-field.js +48 -0
- package/dist/components/toast.d.ts +149 -0
- package/dist/components/toast.js +365 -0
- package/dist/components/toggle-button.d.ts +115 -0
- package/dist/components/toggle-button.js +237 -0
- package/dist/components/toolbar.d.ts +47 -0
- package/dist/components/toolbar.js +54 -0
- package/dist/components/tooltip.d.ts +52 -0
- package/dist/components/tooltip.js +92 -0
- package/dist/components/tree.d.ts +123 -0
- package/dist/components/tree.js +239 -0
- package/dist/components/typeset.d.ts +53 -0
- package/dist/components/typeset.js +271 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/mixins/aria-checked.d.ts +42 -0
- package/dist/mixins/aria-checked.js +127 -0
- package/dist/mixins/attachment-trigger.d.ts +64 -0
- package/dist/mixins/attachment-trigger.js +190 -0
- package/dist/mixins/calendar-keys.d.ts +27 -0
- package/dist/mixins/calendar-keys.js +113 -0
- package/dist/mixins/carousel-controls.d.ts +30 -0
- package/dist/mixins/carousel-controls.js +222 -0
- package/dist/mixins/chart-tooltip.d.ts +118 -0
- package/dist/mixins/chart-tooltip.js +323 -0
- package/dist/mixins/clear-field.d.ts +60 -0
- package/dist/mixins/clear-field.js +100 -0
- package/dist/mixins/color-area-drag.d.ts +58 -0
- package/dist/mixins/color-area-drag.js +162 -0
- package/dist/mixins/color-channel-sync.d.ts +73 -0
- package/dist/mixins/color-channel-sync.js +169 -0
- package/dist/mixins/color-preview.d.ts +28 -0
- package/dist/mixins/color-preview.js +77 -0
- package/dist/mixins/color-wheel-drag.d.ts +58 -0
- package/dist/mixins/color-wheel-drag.js +139 -0
- package/dist/mixins/combobox-filter.d.ts +59 -0
- package/dist/mixins/combobox-filter.js +81 -0
- package/dist/mixins/command-filter.d.ts +55 -0
- package/dist/mixins/command-filter.js +121 -0
- package/dist/mixins/command-keys.d.ts +31 -0
- package/dist/mixins/command-keys.js +116 -0
- package/dist/mixins/context-menu.d.ts +24 -0
- package/dist/mixins/context-menu.js +64 -0
- package/dist/mixins/copy-to-clipboard.d.ts +64 -0
- package/dist/mixins/copy-to-clipboard.js +109 -0
- package/dist/mixins/dismiss.d.ts +77 -0
- package/dist/mixins/dismiss.js +151 -0
- package/dist/mixins/drag-reorder.d.ts +88 -0
- package/dist/mixins/drag-reorder.js +214 -0
- package/dist/mixins/drop-zone.d.ts +52 -0
- package/dist/mixins/drop-zone.js +132 -0
- package/dist/mixins/dual-range.d.ts +60 -0
- package/dist/mixins/dual-range.js +100 -0
- package/dist/mixins/grid-list-keys.d.ts +34 -0
- package/dist/mixins/grid-list-keys.js +260 -0
- package/dist/mixins/heading-level-fallback.d.ts +81 -0
- package/dist/mixins/heading-level-fallback.js +112 -0
- package/dist/mixins/hotkey.d.ts +26 -0
- package/dist/mixins/hotkey.js +132 -0
- package/dist/mixins/image-fallback.d.ts +57 -0
- package/dist/mixins/image-fallback.js +86 -0
- package/dist/mixins/index.d.ts +48 -0
- package/dist/mixins/index.js +48 -0
- package/dist/mixins/listbox-keys.d.ts +52 -0
- package/dist/mixins/listbox-keys.js +63 -0
- package/dist/mixins/long-press.d.ts +76 -0
- package/dist/mixins/long-press.js +130 -0
- package/dist/mixins/menu-keys.d.ts +40 -0
- package/dist/mixins/menu-keys.js +117 -0
- package/dist/mixins/menubar-keys.d.ts +59 -0
- package/dist/mixins/menubar-keys.js +230 -0
- package/dist/mixins/message-follow.d.ts +56 -0
- package/dist/mixins/message-follow.js +368 -0
- package/dist/mixins/otp-slots.d.ts +53 -0
- package/dist/mixins/otp-slots.js +175 -0
- package/dist/mixins/persist.d.ts +36 -0
- package/dist/mixins/persist.js +78 -0
- package/dist/mixins/press-toggle.d.ts +43 -0
- package/dist/mixins/press-toggle.js +61 -0
- package/dist/mixins/range-preview.d.ts +26 -0
- package/dist/mixins/range-preview.js +120 -0
- package/dist/mixins/resize-handle.d.ts +101 -0
- package/dist/mixins/resize-handle.js +288 -0
- package/dist/mixins/stepper.d.ts +81 -0
- package/dist/mixins/stepper.js +194 -0
- package/dist/mixins/tab-keys.d.ts +30 -0
- package/dist/mixins/tab-keys.js +63 -0
- package/dist/mixins/theme-toggle.d.ts +82 -0
- package/dist/mixins/theme-toggle.js +158 -0
- package/dist/mixins/track-host-node.d.ts +34 -0
- package/dist/mixins/track-host-node.js +42 -0
- package/dist/mixins/treeKeys.d.ts +57 -0
- package/dist/mixins/treeKeys.js +266 -0
- package/dist/mixins/validate.d.ts +65 -0
- package/dist/mixins/validate.js +139 -0
- package/dist/mixins/view-transition.d.ts +56 -0
- package/dist/mixins/view-transition.js +111 -0
- package/dist/styles/chart-palette.d.ts +34 -0
- package/dist/styles/chart-palette.js +27 -0
- package/dist/styles/field-stack-layout.d.ts +27 -0
- package/dist/styles/field-stack-layout.js +16 -0
- package/dist/styles/floating-surface.d.ts +32 -0
- package/dist/styles/floating-surface.js +30 -0
- package/dist/styles/graphic-host.d.ts +25 -0
- package/dist/styles/graphic-host.js +18 -0
- package/dist/styles/index.d.ts +20 -0
- package/dist/styles/index.js +20 -0
- package/dist/styles/interactive-transition.d.ts +32 -0
- package/dist/styles/interactive-transition.js +32 -0
- package/dist/styles/legend-toggle.d.ts +29 -0
- package/dist/styles/legend-toggle.js +24 -0
- package/dist/styles/output-caption-text.d.ts +22 -0
- package/dist/styles/output-caption-text.js +15 -0
- package/dist/styles/panel-chrome.d.ts +34 -0
- package/dist/styles/panel-chrome.js +26 -0
- package/dist/styles/range-thumb-appearance.d.ts +36 -0
- package/dist/styles/range-thumb-appearance.js +76 -0
- package/dist/styles/rtl-aware-gradient-direction.d.ts +28 -0
- package/dist/styles/rtl-aware-gradient-direction.js +28 -0
- package/dist/styles/semantic-color-panel.d.ts +35 -0
- package/dist/styles/semantic-color-panel.js +41 -0
- package/dist/utils/chart-marker-indices.d.ts +22 -0
- package/dist/utils/chart-marker-indices.js +45 -0
- package/dist/utils/chart-path.d.ts +86 -0
- package/dist/utils/chart-path.js +122 -0
- package/dist/utils/chart-scale.d.ts +182 -0
- package/dist/utils/chart-scale.js +221 -0
- package/dist/utils/color-math.d.ts +252 -0
- package/dist/utils/color-math.js +480 -0
- package/dist/utils/command-event.d.ts +24 -0
- package/dist/utils/command-event.js +26 -0
- package/dist/utils/css-styles.d.ts +21 -0
- package/dist/utils/css-styles.js +11 -0
- package/dist/utils/decorative-icon.d.ts +15 -0
- package/dist/utils/decorative-icon.js +15 -0
- package/dist/utils/disabled-selector.d.ts +22 -0
- package/dist/utils/disabled-selector.js +22 -0
- package/dist/utils/dispatch-change.d.ts +17 -0
- package/dist/utils/dispatch-change.js +19 -0
- package/dist/utils/field-parts.d.ts +26 -0
- package/dist/utils/field-parts.js +12 -0
- package/dist/utils/full-turn-radians.d.ts +16 -0
- package/dist/utils/full-turn-radians.js +16 -0
- package/dist/utils/geometry.d.ts +14 -0
- package/dist/utils/geometry.js +9 -0
- package/dist/utils/has-accessible-text.d.ts +19 -0
- package/dist/utils/has-accessible-text.js +30 -0
- package/dist/utils/hue-spectrum.d.ts +19 -0
- package/dist/utils/hue-spectrum.js +19 -0
- package/dist/utils/index.d.ts +35 -0
- package/dist/utils/index.js +35 -0
- package/dist/utils/is-new-primary-press.d.ts +29 -0
- package/dist/utils/is-new-primary-press.js +31 -0
- package/dist/utils/keyboard-nav.d.ts +64 -0
- package/dist/utils/keyboard-nav.js +79 -0
- package/dist/utils/merge-style.d.ts +33 -0
- package/dist/utils/merge-style.js +30 -0
- package/dist/utils/paired-range-inputs.d.ts +26 -0
- package/dist/utils/paired-range-inputs.js +29 -0
- package/dist/utils/placement.d.ts +18 -0
- package/dist/utils/placement.js +12 -0
- package/dist/utils/prefers-reduced-motion.d.ts +17 -0
- package/dist/utils/prefers-reduced-motion.js +19 -0
- package/dist/utils/resolve-field-wiring.d.ts +83 -0
- package/dist/utils/resolve-field-wiring.js +53 -0
- package/dist/utils/resolve-fill-percent.d.ts +28 -0
- package/dist/utils/resolve-fill-percent.js +34 -0
- package/dist/utils/round-precision.d.ts +22 -0
- package/dist/utils/round-precision.js +25 -0
- package/dist/utils/semantic-color-panel.d.ts +35 -0
- package/dist/utils/semantic-color-panel.js +28 -0
- package/dist/utils/semantic-color.d.ts +17 -0
- package/dist/utils/semantic-color.js +11 -0
- package/dist/utils/warn-if-no-accessible-name.d.ts +52 -0
- package/dist/utils/warn-if-no-accessible-name.js +55 -0
- package/dist/utils/write-cookie.d.ts +35 -0
- package/dist/utils/write-cookie.js +37 -0
- package/package.json +32 -0
- package/src/reset.css +223 -0
- package/src/theme.css +146 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, border, outlineStyle } from "@sdxc/u/color";
|
|
3
|
+
import { rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor, pseudoContent } from "@sdxc/u/general";
|
|
5
|
+
import { absolute, appearance, inset, relative, vstack } from "@sdxc/u/layout";
|
|
6
|
+
import { bs, is, m, minIs } from "@sdxc/u/size";
|
|
7
|
+
import { z } from "@sdxc/u/stacking";
|
|
8
|
+
import { when } from "@sdxc/u/state";
|
|
9
|
+
import { outputCaptionText } from "../styles/output-caption-text.js";
|
|
10
|
+
import { rangeThumbAppearance } from "../styles/range-thumb-appearance.js";
|
|
11
|
+
import { rtlAwareGradientDirection } from "../styles/rtl-aware-gradient-direction.js";
|
|
12
|
+
import { HUE_GRADIENT_STOPS } from "../utils/hue-spectrum.js";
|
|
13
|
+
import { mergeStyle } from "../utils/merge-style.js";
|
|
14
|
+
/**
|
|
15
|
+
* Custom property carrying a {@link ColorSlider.Track}'s gradient direction,
|
|
16
|
+
* mirrored under `:dir(rtl)` so one gradient string paints correctly in both
|
|
17
|
+
* writing directions.
|
|
18
|
+
*/
|
|
19
|
+
const TRACK_DIRECTION_PROPERTY = "--ui-color-slider-track-direction";
|
|
20
|
+
/**
|
|
21
|
+
* Custom property carrying the color's current hue, in degrees, that a
|
|
22
|
+
* `"saturation"`, `"lightness"`, or `"alpha"` {@link ColorSlider.Track} reads
|
|
23
|
+
* its gradient formula from.
|
|
24
|
+
*/
|
|
25
|
+
const TRACK_HUE_PROPERTY = "--ui-color-slider-hue";
|
|
26
|
+
/** Hue {@link ColorSlider.Track} falls back to when its `hue` prop is omitted. */
|
|
27
|
+
const DEFAULT_HUE = 0;
|
|
28
|
+
/** Lower bound every {@link ColorSlider.Channel} shares, applied when `min` is omitted. */
|
|
29
|
+
const DEFAULT_MIN = 0;
|
|
30
|
+
/** Upper bound {@link ColorSlider.Props} falls back to, keyed by {@link ColorSlider.Channel}, when `max` is omitted. */
|
|
31
|
+
const DEFAULT_MAX_BY_CHANNEL = {
|
|
32
|
+
hue: 360,
|
|
33
|
+
saturation: 100,
|
|
34
|
+
lightness: 100,
|
|
35
|
+
alpha: 1,
|
|
36
|
+
};
|
|
37
|
+
/** Native `step` {@link ColorSlider.Thumb} falls back to, keyed by {@link ColorSlider.Channel}, when `step` is omitted. */
|
|
38
|
+
const DEFAULT_STEP_BY_CHANNEL = {
|
|
39
|
+
hue: 1,
|
|
40
|
+
saturation: 1,
|
|
41
|
+
lightness: 1,
|
|
42
|
+
alpha: 0.01,
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Builds one {@link ColorSlider.Track} gradient string from its color stops,
|
|
46
|
+
* reading {@link TRACK_DIRECTION_PROPERTY} for its direction so the same
|
|
47
|
+
* stops mirror correctly under `:dir(rtl)` from one shared gradient string.
|
|
48
|
+
*/
|
|
49
|
+
function trackGradient(stops) {
|
|
50
|
+
return `linear-gradient(to var(${TRACK_DIRECTION_PROPERTY}, right), ${stops})`;
|
|
51
|
+
}
|
|
52
|
+
/** The full, fixed rainbow a `"hue"` {@link ColorSlider.Track} always paints. */
|
|
53
|
+
const HUE_GRADIENT = trackGradient(HUE_GRADIENT_STOPS);
|
|
54
|
+
/** A `"saturation"` {@link ColorSlider.Track}'s gradient: fully desaturated through fully saturated, at {@link TRACK_HUE_PROPERTY}'s hue. */
|
|
55
|
+
const SATURATION_GRADIENT = trackGradient(`hsl(var(${TRACK_HUE_PROPERTY}, 0) 0% 50%), hsl(var(${TRACK_HUE_PROPERTY}, 0) 100% 50%)`);
|
|
56
|
+
/** A `"lightness"` {@link ColorSlider.Track}'s gradient: black through {@link TRACK_HUE_PROPERTY}'s hue through white. */
|
|
57
|
+
const LIGHTNESS_GRADIENT = trackGradient(`black, hsl(var(${TRACK_HUE_PROPERTY}, 0) 100% 50%), white`);
|
|
58
|
+
/** An `"alpha"` {@link ColorSlider.Track}'s gradient: fully transparent through {@link TRACK_HUE_PROPERTY}'s hue at full opacity, over the track's own checkerboard backdrop. */
|
|
59
|
+
const ALPHA_GRADIENT = trackGradient(`transparent, hsl(var(${TRACK_HUE_PROPERTY}, 0) 100% 50%)`);
|
|
60
|
+
/**
|
|
61
|
+
* Renders the root host: a `<div>` stacking its children with a small gap,
|
|
62
|
+
* resolving the channel, range, and value into component context and
|
|
63
|
+
* mirroring the channel onto its own `data-channel` attribute.
|
|
64
|
+
*
|
|
65
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link ColorSlider.Context}.
|
|
66
|
+
* @returns The render function producing the root's markup.
|
|
67
|
+
* @example
|
|
68
|
+
* <ColorSlider channel="hue" defaultValue={210}>
|
|
69
|
+
* <ColorSlider.Output htmlFor="accent-hue-thumb">210°</ColorSlider.Output>
|
|
70
|
+
* <ColorSlider.Track>
|
|
71
|
+
* <ColorSlider.Thumb id="accent-hue-thumb" aria-label={t("colorPicker.hue")} />
|
|
72
|
+
* </ColorSlider.Track>
|
|
73
|
+
* </ColorSlider>
|
|
74
|
+
* @example
|
|
75
|
+
* <ColorSlider channel="alpha" min={0} max={1} defaultValue={1}>
|
|
76
|
+
* <ColorSlider.Track hue={210}>
|
|
77
|
+
* <ColorSlider.Thumb aria-label={t("colorPicker.alpha")} />
|
|
78
|
+
* </ColorSlider.Track>
|
|
79
|
+
* </ColorSlider>
|
|
80
|
+
*/
|
|
81
|
+
export function ColorSlider(handle) {
|
|
82
|
+
return () => {
|
|
83
|
+
let { channel, min, max, value, defaultValue, mix, ...rest } = handle.props;
|
|
84
|
+
let resolvedMin = min ?? DEFAULT_MIN;
|
|
85
|
+
let resolvedMax = max ?? DEFAULT_MAX_BY_CHANNEL[channel];
|
|
86
|
+
let resolvedValue = value ?? defaultValue ?? resolvedMin;
|
|
87
|
+
handle.context.set({ channel, min: resolvedMin, max: resolvedMax, value: resolvedValue });
|
|
88
|
+
return (_jsx("div", { "data-channel": channel, ...rest, mix: [vstack({ gap: 2 }), is("full"), minIs("10rem"), mix] }));
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Renders the visual track: a `position: relative` `<div>` painting its
|
|
93
|
+
* whole length with the gradient the nearest ancestor {@link ColorSlider}'s
|
|
94
|
+
* `data-channel` attribute selects, over a checkerboard backdrop.
|
|
95
|
+
*
|
|
96
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
97
|
+
* @returns The render function producing the track's markup.
|
|
98
|
+
* @example
|
|
99
|
+
* <ColorSlider.Track>
|
|
100
|
+
* <ColorSlider.Thumb aria-label={t("colorPicker.hue")} />
|
|
101
|
+
* </ColorSlider.Track>
|
|
102
|
+
* @example
|
|
103
|
+
* <ColorSlider.Track hue={210}>
|
|
104
|
+
* <ColorSlider.Thumb aria-label={t("colorPicker.lightness")} />
|
|
105
|
+
* </ColorSlider.Track>
|
|
106
|
+
*/
|
|
107
|
+
ColorSlider.Track = function ColorSliderTrack(handle) {
|
|
108
|
+
return () => {
|
|
109
|
+
let { hue, mix, style, ...rest } = handle.props;
|
|
110
|
+
let resolvedHue = hue ?? DEFAULT_HUE;
|
|
111
|
+
let resolvedStyle = mergeStyle(style, { [TRACK_HUE_PROPERTY]: `${resolvedHue}` });
|
|
112
|
+
return (_jsx("div", { ...rest, style: resolvedStyle, mix: [
|
|
113
|
+
rtlAwareGradientDirection(TRACK_DIRECTION_PROPERTY),
|
|
114
|
+
relative(),
|
|
115
|
+
is("full"),
|
|
116
|
+
bs("var(--ui-color-slider-thumb-size, 1.25rem)"),
|
|
117
|
+
rounded("full"),
|
|
118
|
+
when("&::before", [
|
|
119
|
+
absolute(),
|
|
120
|
+
inset("0"),
|
|
121
|
+
rounded("inherit"),
|
|
122
|
+
bg({
|
|
123
|
+
image: "repeating-conic-gradient(var(--ui-neutral-border) 0% 25%, var(--ui-neutral-bg-tint) 0% 50%)",
|
|
124
|
+
size: "var(--ui-color-slider-checker-size, 0.625rem) var(--ui-color-slider-checker-size, 0.625rem)",
|
|
125
|
+
}),
|
|
126
|
+
pseudoContent('""'),
|
|
127
|
+
]),
|
|
128
|
+
when("&::after", [absolute(), inset("0"), rounded("inherit"), pseudoContent('""')]),
|
|
129
|
+
when('[data-channel="hue"] &::after', bg({ image: HUE_GRADIENT })),
|
|
130
|
+
when('[data-channel="saturation"] &::after', bg({ image: SATURATION_GRADIENT })),
|
|
131
|
+
when('[data-channel="lightness"] &::after', bg({ image: LIGHTNESS_GRADIENT })),
|
|
132
|
+
when('[data-channel="alpha"] &::after', bg({ image: ALPHA_GRADIENT })),
|
|
133
|
+
mix,
|
|
134
|
+
] }));
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Renders the interactive thumb: a native `<input type="range">` reset to
|
|
139
|
+
* cover its enclosing {@link ColorSlider.Track}'s entire box, so drag,
|
|
140
|
+
* arrow-key, and click-to-jump behavior spans the track's whole length.
|
|
141
|
+
*
|
|
142
|
+
* @param handle Runtime handle carrying the host `<input>`'s props.
|
|
143
|
+
* @returns The render function producing the thumb's markup.
|
|
144
|
+
* @example
|
|
145
|
+
* <ColorSlider.Thumb aria-label={t("colorPicker.hue")} />
|
|
146
|
+
* @example
|
|
147
|
+
* <ColorSlider.Thumb aria-label={t("colorPicker.alpha")} disabled />
|
|
148
|
+
*/
|
|
149
|
+
ColorSlider.Thumb = function ColorSliderThumb(handle) {
|
|
150
|
+
return () => {
|
|
151
|
+
let { id, min, max, step, value, defaultValue, mix, ...rest } = handle.props;
|
|
152
|
+
let context = handle.context.get(ColorSlider);
|
|
153
|
+
let resolvedStep = step ?? DEFAULT_STEP_BY_CHANNEL[context.channel];
|
|
154
|
+
let resolvedValue = value ?? defaultValue ?? context.value;
|
|
155
|
+
return (_jsx("input", { ...rest, type: "range", id: id ?? handle.id, min: min ?? context.min, max: max ?? context.max, step: resolvedStep, defaultValue: resolvedValue, mix: [
|
|
156
|
+
rangeThumbAppearance("--ui-color-slider-thumb-size", "--ui-color-slider-thumb-border-width"),
|
|
157
|
+
absolute(),
|
|
158
|
+
z(10),
|
|
159
|
+
appearance(),
|
|
160
|
+
cursor("pointer"),
|
|
161
|
+
when("&:disabled", cursor("not-allowed")),
|
|
162
|
+
inset("0"),
|
|
163
|
+
m("0"),
|
|
164
|
+
bg("transparent"),
|
|
165
|
+
outlineStyle("none"),
|
|
166
|
+
when("&::-webkit-slider-runnable-track", [
|
|
167
|
+
bs("full"),
|
|
168
|
+
bg("transparent"),
|
|
169
|
+
appearance("none", { moz: false }),
|
|
170
|
+
]),
|
|
171
|
+
when("&::-moz-range-track", [
|
|
172
|
+
bs("full"),
|
|
173
|
+
bg("transparent"),
|
|
174
|
+
border({ style: "none" }),
|
|
175
|
+
appearance("none", { webkit: false, moz: false }),
|
|
176
|
+
]),
|
|
177
|
+
mix,
|
|
178
|
+
] }));
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Renders a live readout: a native `<output>` reporting the formatted value
|
|
183
|
+
* passed as `children`. Pass the paired {@link ColorSlider.Thumb}'s own `id`
|
|
184
|
+
* explicitly as `htmlFor` to associate the two.
|
|
185
|
+
*
|
|
186
|
+
* @param handle Runtime handle carrying the host `<output>`'s props.
|
|
187
|
+
* @returns The render function producing the readout's markup.
|
|
188
|
+
* @example
|
|
189
|
+
* <ColorSlider.Output htmlFor="accent-hue-thumb">
|
|
190
|
+
* {new Intl.NumberFormat(locale, { style: "unit", unit: "degree" }).format(210)}
|
|
191
|
+
* </ColorSlider.Output>
|
|
192
|
+
*/
|
|
193
|
+
ColorSlider.Output = function ColorSliderOutput(handle) {
|
|
194
|
+
return () => {
|
|
195
|
+
let { mix, ...rest } = handle.props;
|
|
196
|
+
return _jsx("output", { ...rest, mix: [outputCaptionText(), mix] });
|
|
197
|
+
};
|
|
198
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A set of mutually exclusive color options built from native `<input
|
|
3
|
+
* type="radio">` controls sharing one grouping name, rendered as a
|
|
4
|
+
* `role="radiogroup"` host wrapping {@link ColorSwatchPicker.Swatch}
|
|
5
|
+
* instances styled from each input's own `:checked` state.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
11
|
+
import { ColorSwatch } from "./color-swatch.js";
|
|
12
|
+
/**
|
|
13
|
+
* Prop types for {@link ColorSwatchPicker} and its
|
|
14
|
+
* {@link ColorSwatchPicker.Swatch} compound part.
|
|
15
|
+
*/
|
|
16
|
+
export declare namespace ColorSwatchPicker {
|
|
17
|
+
/**
|
|
18
|
+
* Value {@link ColorSwatchPicker} stores in component context so every
|
|
19
|
+
* {@link ColorSwatchPicker.Swatch} nested inside shares the same native
|
|
20
|
+
* grouping name without a consumer repeating it on each option.
|
|
21
|
+
*/
|
|
22
|
+
interface Context {
|
|
23
|
+
/** Shared `name` every {@link ColorSwatchPicker.Swatch} reads unless it sets its own. */
|
|
24
|
+
name: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Props accepted by {@link ColorSwatchPicker}.
|
|
28
|
+
*/
|
|
29
|
+
interface Props extends TagProps<"div"> {
|
|
30
|
+
/**
|
|
31
|
+
* Native grouping name shared by every {@link ColorSwatchPicker.Swatch}
|
|
32
|
+
* nested inside. Defaults to the group's own
|
|
33
|
+
* {@link Handle.id | stable instance id} when omitted.
|
|
34
|
+
*/
|
|
35
|
+
name?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Props accepted by {@link ColorSwatchPicker.Swatch}.
|
|
39
|
+
*/
|
|
40
|
+
interface SwatchProps extends Omit<TagProps<"label">, "children" | "aria-label"> {
|
|
41
|
+
/**
|
|
42
|
+
* The color this option submits and previews, already resolved to a
|
|
43
|
+
* literal CSS color value — the same value {@link ColorSwatch} paints
|
|
44
|
+
* its indicator with and submits with the enclosing form.
|
|
45
|
+
*/
|
|
46
|
+
value: string;
|
|
47
|
+
/**
|
|
48
|
+
* Accessible name announced for this option in place of visible text —
|
|
49
|
+
* a color's name, for instance. Required, since the indicator identifies
|
|
50
|
+
* the option to assistive technology through this text alone.
|
|
51
|
+
*/
|
|
52
|
+
"aria-label": string;
|
|
53
|
+
/**
|
|
54
|
+
* Native grouping name for this option's underlying input. Defaults to
|
|
55
|
+
* the name provided by the nearest ancestor {@link ColorSwatchPicker} —
|
|
56
|
+
* set this only to opt a single option out of its group's shared name.
|
|
57
|
+
*/
|
|
58
|
+
name?: string;
|
|
59
|
+
/** The indicator's shape variant, forwarded to {@link ColorSwatch}. */
|
|
60
|
+
shape?: ColorSwatch.Shape;
|
|
61
|
+
/** The indicator's size variant, forwarded to {@link ColorSwatch}. */
|
|
62
|
+
size?: ColorSwatch.Size;
|
|
63
|
+
/** Whether this option starts selected, for a form that never tracks selection itself. */
|
|
64
|
+
defaultChecked?: boolean;
|
|
65
|
+
/** Whether this option is selected, for a form that tracks selection itself. */
|
|
66
|
+
checked?: boolean;
|
|
67
|
+
/** Whether this option is inert and excluded from the group's tab order. */
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
/** Marks the enclosing native radio group as requiring one option selected. */
|
|
70
|
+
required?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Per-part styling for the option's hidden `input` and its
|
|
73
|
+
* {@link ColorSwatch} indicator, layered after each part's own built-in
|
|
74
|
+
* styling. The `mix` prop styles the option's outer `<label>` host.
|
|
75
|
+
*/
|
|
76
|
+
parts?: {
|
|
77
|
+
/** Additional mixin(s) applied to the hidden native `<input type="radio">`. */
|
|
78
|
+
input?: TagProps<"input">["mix"];
|
|
79
|
+
/** Additional mixin(s) applied to the {@link ColorSwatch} indicator. */
|
|
80
|
+
indicator?: TagProps<"span">["mix"];
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Renders the group host: a `role="radiogroup"` `<div>` laying its
|
|
86
|
+
* {@link ColorSwatchPicker.Swatch} options out in a wrapping row, sharing its
|
|
87
|
+
* `name` through context so each option defaults to the group's own identifier.
|
|
88
|
+
*
|
|
89
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link ColorSwatchPicker.Context}.
|
|
90
|
+
* @returns The render function producing the group's markup.
|
|
91
|
+
* @example
|
|
92
|
+
* <ColorSwatchPicker aria-label={t("form.accentColor.label")} name="accentColor">
|
|
93
|
+
* <ColorSwatchPicker.Swatch value="#ef4444" aria-label={t("color.red")} />
|
|
94
|
+
* <ColorSwatchPicker.Swatch value="#3b82f6" aria-label={t("color.blue")} defaultChecked />
|
|
95
|
+
* <ColorSwatchPicker.Swatch value="#22c55e" aria-label={t("color.green")} />
|
|
96
|
+
* </ColorSwatchPicker>
|
|
97
|
+
* @example
|
|
98
|
+
* <ColorSwatchPicker aria-label={t("form.brandColor.label")}>
|
|
99
|
+
* <ColorSwatchPicker.Swatch value="#f97316" aria-label={t("color.orange")} shape="circle" size="lg" />
|
|
100
|
+
* <ColorSwatchPicker.Swatch value="#a855f7" aria-label={t("color.purple")} shape="circle" size="lg" />
|
|
101
|
+
* </ColorSwatchPicker>
|
|
102
|
+
*/
|
|
103
|
+
export declare function ColorSwatchPicker(handle: Handle<ColorSwatchPicker.Props, ColorSwatchPicker.Context>): () => import("remix/ui").RemixElement;
|
|
104
|
+
export declare namespace ColorSwatchPicker {
|
|
105
|
+
var Swatch: (handle: Handle<ColorSwatchPicker.SwatchProps>) => () => import("remix/ui").RemixElement;
|
|
106
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
3
|
+
import { border, outline } from "@sdxc/u/color";
|
|
4
|
+
import { opacity, ringShadow, transition } from "@sdxc/u/effects";
|
|
5
|
+
import { cursor } from "@sdxc/u/general";
|
|
6
|
+
import { flexWrap, hstack, inlineFlex } from "@sdxc/u/layout";
|
|
7
|
+
import { precededBy, when } from "@sdxc/u/state";
|
|
8
|
+
import { attrs } from "remix/ui";
|
|
9
|
+
import { ColorSwatch } from "./color-swatch.js";
|
|
10
|
+
/**
|
|
11
|
+
* `role="radiogroup"` applied through {@link attrs} unless a consumer
|
|
12
|
+
* supplies its own `role`, announcing the host as a radio group landmark to
|
|
13
|
+
* assistive technology.
|
|
14
|
+
*/
|
|
15
|
+
const DEFAULT_ROLE = "radiogroup";
|
|
16
|
+
/**
|
|
17
|
+
* Renders the group host: a `role="radiogroup"` `<div>` laying its
|
|
18
|
+
* {@link ColorSwatchPicker.Swatch} options out in a wrapping row, sharing its
|
|
19
|
+
* `name` through context so each option defaults to the group's own identifier.
|
|
20
|
+
*
|
|
21
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link ColorSwatchPicker.Context}.
|
|
22
|
+
* @returns The render function producing the group's markup.
|
|
23
|
+
* @example
|
|
24
|
+
* <ColorSwatchPicker aria-label={t("form.accentColor.label")} name="accentColor">
|
|
25
|
+
* <ColorSwatchPicker.Swatch value="#ef4444" aria-label={t("color.red")} />
|
|
26
|
+
* <ColorSwatchPicker.Swatch value="#3b82f6" aria-label={t("color.blue")} defaultChecked />
|
|
27
|
+
* <ColorSwatchPicker.Swatch value="#22c55e" aria-label={t("color.green")} />
|
|
28
|
+
* </ColorSwatchPicker>
|
|
29
|
+
* @example
|
|
30
|
+
* <ColorSwatchPicker aria-label={t("form.brandColor.label")}>
|
|
31
|
+
* <ColorSwatchPicker.Swatch value="#f97316" aria-label={t("color.orange")} shape="circle" size="lg" />
|
|
32
|
+
* <ColorSwatchPicker.Swatch value="#a855f7" aria-label={t("color.purple")} shape="circle" size="lg" />
|
|
33
|
+
* </ColorSwatchPicker>
|
|
34
|
+
*/
|
|
35
|
+
export function ColorSwatchPicker(handle) {
|
|
36
|
+
return () => {
|
|
37
|
+
let { name, mix, ...rest } = handle.props;
|
|
38
|
+
let resolvedName = name ?? handle.id;
|
|
39
|
+
handle.context.set({ name: resolvedName });
|
|
40
|
+
return (_jsx("div", { ...rest, mix: [attrs({ role: DEFAULT_ROLE }), hstack({ gap: 2 }), flexWrap(), mix] }));
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Renders a single option: a hidden `<input type="radio">` paired with a
|
|
45
|
+
* {@link ColorSwatch} indicator, styled through `precededBy()` since a bare
|
|
46
|
+
* element-first selector here would serialize as a declaration, not a match.
|
|
47
|
+
*
|
|
48
|
+
* @param handle Runtime handle carrying the host `<label>`'s props.
|
|
49
|
+
* @returns The render function producing the option's markup.
|
|
50
|
+
* @example
|
|
51
|
+
* <ColorSwatchPicker.Swatch value="#ef4444" aria-label={t("color.red")} />
|
|
52
|
+
* @example
|
|
53
|
+
* <ColorSwatchPicker.Swatch value="#3b82f6" aria-label={t("color.blue")} defaultChecked shape="circle" />
|
|
54
|
+
* @example
|
|
55
|
+
* <ColorSwatchPicker.Swatch value="#22c55e" aria-label={t("color.green")} disabled />
|
|
56
|
+
*/
|
|
57
|
+
ColorSwatchPicker.Swatch = function ColorSwatchPickerSwatch(handle) {
|
|
58
|
+
return () => {
|
|
59
|
+
let { value, "aria-label": ariaLabel, name, shape, size, checked, defaultChecked, disabled, required, parts, mix, ...rest } = handle.props;
|
|
60
|
+
let context = handle.context.get(ColorSwatchPicker);
|
|
61
|
+
let resolvedName = name ?? context.name;
|
|
62
|
+
return (_jsxs("label", { ...rest, mix: [
|
|
63
|
+
inlineFlex(),
|
|
64
|
+
cursor("default"),
|
|
65
|
+
when("&:has(input:disabled)", [cursor("not-allowed"), opacity(50)]),
|
|
66
|
+
mix,
|
|
67
|
+
], children: [_jsx("input", { type: "radio", id: handle.id, value: value, name: resolvedName, checked: checked, defaultChecked: defaultChecked, disabled: disabled, required: required, "aria-label": ariaLabel, mix: [visuallyHidden(), parts?.input] }), _jsx(ColorSwatch, { value: value, shape: shape, size: size, mix: [
|
|
68
|
+
transition("border-color, box-shadow"),
|
|
69
|
+
precededBy("input:checked", border("brand.solid")),
|
|
70
|
+
precededBy("input:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
71
|
+
precededBy("input:checked", ringShadow("brand")),
|
|
72
|
+
parts?.indicator,
|
|
73
|
+
] })] }));
|
|
74
|
+
};
|
|
75
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A static preview box rendering one color value as a filled, shaped
|
|
3
|
+
* swatch, backed by a fixed checkerboard so a translucent value always
|
|
4
|
+
* reads correctly against whatever sits behind it on the page rather than
|
|
5
|
+
* blending invisibly away. The value paints through two stacked layers: a
|
|
6
|
+
* checkerboard base and a color fill on top, clipped together to a circular,
|
|
7
|
+
* square, or softly rounded shape at one of three fixed sizes. Every other
|
|
8
|
+
* color preview in this component family composes this box for its own
|
|
9
|
+
* preview instead of redrawing the checkerboard-plus-fill technique itself.
|
|
10
|
+
*
|
|
11
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
12
|
+
* @copyright Sergio Xalambrí 2026
|
|
13
|
+
*/
|
|
14
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
15
|
+
/**
|
|
16
|
+
* Prop types for {@link ColorSwatch}.
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace ColorSwatch {
|
|
19
|
+
/**
|
|
20
|
+
* Shape variant controlling the swatch's corner rounding: `"circle"`
|
|
21
|
+
* renders a fully rounded disc, `"square"` renders sharp corners, and
|
|
22
|
+
* `"rounded"` renders a softly rounded square.
|
|
23
|
+
*/
|
|
24
|
+
type Shape = "circle" | "square" | "rounded";
|
|
25
|
+
/**
|
|
26
|
+
* Size variant controlling the swatch's rendered dimensions.
|
|
27
|
+
*/
|
|
28
|
+
type Size = "sm" | "md" | "lg";
|
|
29
|
+
/**
|
|
30
|
+
* Props accepted by {@link ColorSwatch}.
|
|
31
|
+
*/
|
|
32
|
+
interface Props extends TagProps<"span"> {
|
|
33
|
+
/**
|
|
34
|
+
* The color to preview, already resolved to a literal CSS value — a hex
|
|
35
|
+
* string, `rgb()`/`hsl()`/`oklch()` function, or named color. Required,
|
|
36
|
+
* since a swatch with nothing to preview has no reason to render.
|
|
37
|
+
*/
|
|
38
|
+
value: string;
|
|
39
|
+
/** Shape variant. Defaults to {@link DEFAULT_SHAPE}. */
|
|
40
|
+
shape?: Shape;
|
|
41
|
+
/** Size variant. Defaults to {@link DEFAULT_SIZE}. */
|
|
42
|
+
size?: Size;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Renders a fixed-size `<span>` that paints `value` through a local
|
|
47
|
+
* `--ui-color-swatch-value` custom property, layered over a `::before`
|
|
48
|
+
* checkerboard so any transparency in `value` reads correctly.
|
|
49
|
+
*
|
|
50
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
51
|
+
* @returns The render function producing the swatch's markup.
|
|
52
|
+
* @example
|
|
53
|
+
* <ColorSwatch value="#3b82f6" />
|
|
54
|
+
* @example
|
|
55
|
+
* <ColorSwatch value="rgb(16 185 129 / 0.4)" shape="circle" size="lg" />
|
|
56
|
+
*/
|
|
57
|
+
export declare function ColorSwatch(handle: Handle<ColorSwatch.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, border } from "@sdxc/u/color";
|
|
3
|
+
import { rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { raw, userSelect } from "@sdxc/u/general";
|
|
5
|
+
import { absolute, inlineFlex, inset, items, justify, relative, shrink } from "@sdxc/u/layout";
|
|
6
|
+
import { overflow } from "@sdxc/u/overflow";
|
|
7
|
+
import { bs, is } from "@sdxc/u/size";
|
|
8
|
+
import { after, before, data } from "@sdxc/u/state";
|
|
9
|
+
import { verticalAlign } from "@sdxc/u/typography";
|
|
10
|
+
import { attrs } from "remix/ui";
|
|
11
|
+
import { mergeStyle } from "../utils/merge-style.js";
|
|
12
|
+
/** Shape variant {@link ColorSwatch} falls back to when `shape` is omitted. */
|
|
13
|
+
const DEFAULT_SHAPE = "rounded";
|
|
14
|
+
/** Size variant {@link ColorSwatch} falls back to when `size` is omitted. */
|
|
15
|
+
const DEFAULT_SIZE = "md";
|
|
16
|
+
/**
|
|
17
|
+
* Applied through {@link attrs} so the host is hidden from assistive
|
|
18
|
+
* technology by default, since composed uses supply their own accessible
|
|
19
|
+
* name; pass `aria-hidden={false}` and `aria-label` to render standalone.
|
|
20
|
+
*/
|
|
21
|
+
const DEFAULT_ARIA_HIDDEN = "true";
|
|
22
|
+
/**
|
|
23
|
+
* Renders a fixed-size `<span>` that paints `value` through a local
|
|
24
|
+
* `--ui-color-swatch-value` custom property, layered over a `::before`
|
|
25
|
+
* checkerboard so any transparency in `value` reads correctly.
|
|
26
|
+
*
|
|
27
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
28
|
+
* @returns The render function producing the swatch's markup.
|
|
29
|
+
* @example
|
|
30
|
+
* <ColorSwatch value="#3b82f6" />
|
|
31
|
+
* @example
|
|
32
|
+
* <ColorSwatch value="rgb(16 185 129 / 0.4)" shape="circle" size="lg" />
|
|
33
|
+
*/
|
|
34
|
+
export function ColorSwatch(handle) {
|
|
35
|
+
return () => {
|
|
36
|
+
let { value, shape, size, mix, style, ...rest } = handle.props;
|
|
37
|
+
let resolvedShape = shape ?? DEFAULT_SHAPE;
|
|
38
|
+
let resolvedSize = size ?? DEFAULT_SIZE;
|
|
39
|
+
let resolvedStyle = mergeStyle(style, { "--ui-color-swatch-value": value });
|
|
40
|
+
return (_jsx("span", { ...rest, "data-slot": "swatch", "data-shape": resolvedShape, "data-size": resolvedSize, style: resolvedStyle, mix: [
|
|
41
|
+
attrs({ "aria-hidden": DEFAULT_ARIA_HIDDEN }),
|
|
42
|
+
relative(),
|
|
43
|
+
inlineFlex(),
|
|
44
|
+
items("center"),
|
|
45
|
+
justify("center"),
|
|
46
|
+
overflow("hidden"),
|
|
47
|
+
border({ width: 1, color: "neutral" }),
|
|
48
|
+
is("var(--ui-color-swatch-size-md, 1.75rem)"),
|
|
49
|
+
bs("var(--ui-color-swatch-size-md, 1.75rem)"),
|
|
50
|
+
rounded("md"),
|
|
51
|
+
data("size", "sm", [
|
|
52
|
+
is("var(--ui-color-swatch-size-sm, 1.25rem)"),
|
|
53
|
+
bs("var(--ui-color-swatch-size-sm, 1.25rem)"),
|
|
54
|
+
]),
|
|
55
|
+
data("size", "lg", [
|
|
56
|
+
is("var(--ui-color-swatch-size-lg, 2.5rem)"),
|
|
57
|
+
bs("var(--ui-color-swatch-size-lg, 2.5rem)"),
|
|
58
|
+
]),
|
|
59
|
+
data("shape", "circle", rounded("full")),
|
|
60
|
+
shrink(),
|
|
61
|
+
verticalAlign("middle"),
|
|
62
|
+
userSelect(),
|
|
63
|
+
data("shape", "square", rounded("none")),
|
|
64
|
+
before([
|
|
65
|
+
absolute(),
|
|
66
|
+
inset(0),
|
|
67
|
+
bg({
|
|
68
|
+
image: "repeating-conic-gradient(var(--ui-neutral-border) 0% 25%, var(--ui-neutral-bg-tint) 0% 50%)",
|
|
69
|
+
size: "var(--ui-color-swatch-checker-size, 0.625rem) var(--ui-color-swatch-checker-size, 0.625rem)",
|
|
70
|
+
}),
|
|
71
|
+
raw({ content: '""' }),
|
|
72
|
+
]),
|
|
73
|
+
after([
|
|
74
|
+
absolute(),
|
|
75
|
+
inset(0),
|
|
76
|
+
bg("var(--ui-color-swatch-value, transparent)"),
|
|
77
|
+
raw({ content: '""' }),
|
|
78
|
+
]),
|
|
79
|
+
mix,
|
|
80
|
+
] }));
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A circular hue picker. Hue's natural domain is an angle swept around a
|
|
3
|
+
* circle, so the pointer math is polar: a center point and an angle in, a
|
|
4
|
+
* hue out. A single native `<input type="range">` carries every value this
|
|
5
|
+
* control reports; `colorWheelDrag()` reshapes the root into a ring when a
|
|
6
|
+
* consumer attaches it through the root's `mix` prop.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
12
|
+
/**
|
|
13
|
+
* Prop types for {@link ColorWheel}.
|
|
14
|
+
*/
|
|
15
|
+
export declare namespace ColorWheel {
|
|
16
|
+
/**
|
|
17
|
+
* Per-part styling for the underlying native hue control this convenience
|
|
18
|
+
* wrapper composes alongside its own host `<div>`.
|
|
19
|
+
*/
|
|
20
|
+
interface PartsProps {
|
|
21
|
+
/** Styling for the native `<input type="range">` reporting the current hue. */
|
|
22
|
+
input?: TagProps<"input">["mix"];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Props accepted by {@link ColorWheel}. `mix` styles the root element that
|
|
26
|
+
* the plain-bar or ring rendering paints itself on; style the nested hue
|
|
27
|
+
* input individually through `parts` instead.
|
|
28
|
+
*/
|
|
29
|
+
interface Props extends Omit<TagProps<"div">, "children"> {
|
|
30
|
+
/** Current hue, in degrees `0`–`360`, for a wheel a consumer tracks itself. */
|
|
31
|
+
value?: number;
|
|
32
|
+
/** Starting hue, in degrees `0`–`360`, for a wheel left to the platform's own uncontrolled state. */
|
|
33
|
+
defaultValue?: number;
|
|
34
|
+
/** Degrees a single keypress moves the value by. Defaults to {@link DEFAULT_STEP}. */
|
|
35
|
+
step?: number;
|
|
36
|
+
/** Native `name` submitted with an enclosing form. */
|
|
37
|
+
name?: string;
|
|
38
|
+
/** Native `id` of the form the underlying hue input associates with, when it sits outside that form's own markup. */
|
|
39
|
+
form?: string;
|
|
40
|
+
/** Marks the underlying hue input inert and excluded from the tab order. */
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
/** Per-part styling for this wrapper's internally composed hue input. */
|
|
43
|
+
parts?: PartsProps;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Renders a root `<div>` around a single `<input type="range">` across
|
|
48
|
+
* hue's `0`–`360` domain, carrying every accessibility and form semantic
|
|
49
|
+
* this wheel exposes; `colorWheelDrag()` enables the ring rendering.
|
|
50
|
+
*
|
|
51
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
52
|
+
* @returns The render function producing the wheel's markup.
|
|
53
|
+
* @example
|
|
54
|
+
* <ColorWheel aria-label={t("colorPicker.hue")} defaultValue={210} />
|
|
55
|
+
* @example
|
|
56
|
+
* <ColorWheel aria-label={t("theme.accentHue")} value={hue} name="hue" disabled={isLocked} />
|
|
57
|
+
*/
|
|
58
|
+
export declare function ColorWheel(handle: Handle<ColorWheel.Props>): () => import("remix/ui").RemixElement;
|