@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,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A styled native checkbox: an `<input type="checkbox">` paired with a
|
|
3
|
+
* decorative glyph box that renders its check or dash mark purely from the
|
|
4
|
+
* input's own state, wrapped in a `<label>` so clicking or tapping anywhere
|
|
5
|
+
* in the row — box, glyph, or label text alike — toggles the control.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/ui";
|
|
11
|
+
/**
|
|
12
|
+
* Prop types for {@link Checkbox}.
|
|
13
|
+
*/
|
|
14
|
+
export declare namespace Checkbox {
|
|
15
|
+
/**
|
|
16
|
+
* Semantic color role, each mapped to its matching `--ui-*` variables.
|
|
17
|
+
*/
|
|
18
|
+
type Color = "brand" | "neutral" | "success" | "warning" | "danger";
|
|
19
|
+
/**
|
|
20
|
+
* Per-part styling for the elements this convenience wrapper composes
|
|
21
|
+
* internally alongside its own host `<input>`.
|
|
22
|
+
*/
|
|
23
|
+
interface PartsProps {
|
|
24
|
+
/** Styling for the decorative box rendering the checkmark or dash glyph. */
|
|
25
|
+
box?: TagProps<"span">["mix"];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Props accepted by {@link Checkbox}. Extends every native `<input>`
|
|
29
|
+
* attribute except `type`, fixed to `"checkbox"`; `mix` styles that same
|
|
30
|
+
* `<input>` host, and `role` is narrowed to what a checkbox input allows.
|
|
31
|
+
*/
|
|
32
|
+
interface Props extends Omit<TagProps<"input">, "type" | "role"> {
|
|
33
|
+
/** ARIA role override, restricted to what a checkbox input may carry. */
|
|
34
|
+
role?: "checkbox" | "button" | "menuitemcheckbox" | "option" | "switch";
|
|
35
|
+
/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */
|
|
36
|
+
color?: Color;
|
|
37
|
+
/**
|
|
38
|
+
* Label content rendered after the box, inside the same native
|
|
39
|
+
* `<label>` wrapping the row — clicking any of it toggles the checkbox
|
|
40
|
+
* natively, with no separate `htmlFor`/`id` pair required.
|
|
41
|
+
*/
|
|
42
|
+
children?: RemixNode;
|
|
43
|
+
/** Per-part styling for this wrapper's internally composed elements. */
|
|
44
|
+
parts?: PartsProps;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The box precedes the input in source order so its `:has(~ input:…)` rules
|
|
49
|
+
* can read state directly off it, keeping the whole control CSS-driven;
|
|
50
|
+
* `shrink(0)` also keeps the box square regardless of label length.
|
|
51
|
+
*
|
|
52
|
+
* @param handle Runtime handle carrying the host `<input>`'s props.
|
|
53
|
+
* @returns The render function producing the checkbox's markup.
|
|
54
|
+
* @example
|
|
55
|
+
* <Checkbox name="terms" required>{t("signup.acceptTerms")}</Checkbox>
|
|
56
|
+
* @example
|
|
57
|
+
* <Checkbox color="danger" checked={row.flagged} aria-label={t("table.flagRow")} />
|
|
58
|
+
* @example
|
|
59
|
+
* <Checkbox disabled defaultChecked>{t("settings.legacyOptIn")}</Checkbox>
|
|
60
|
+
*/
|
|
61
|
+
export declare function Checkbox(handle: Handle<Checkbox.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { CheckIcon, MinusIcon } from "@sdxc/icons";
|
|
3
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
4
|
+
import { bg, border, fg, outline } from "@sdxc/u/color";
|
|
5
|
+
import { opacity, rounded } from "@sdxc/u/effects";
|
|
6
|
+
import { cursor } from "@sdxc/u/general";
|
|
7
|
+
import { block, center, hidden, hstack, relative, shrink } from "@sdxc/u/layout";
|
|
8
|
+
import { bs, is } from "@sdxc/u/size";
|
|
9
|
+
import { when } from "@sdxc/u/state";
|
|
10
|
+
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
11
|
+
import { warnIfNoAccessibleName } from "../utils/warn-if-no-accessible-name.js";
|
|
12
|
+
/** Semantic color role {@link Checkbox} falls back to when `color` is omitted. */
|
|
13
|
+
const DEFAULT_COLOR = "neutral";
|
|
14
|
+
/**
|
|
15
|
+
* The box precedes the input in source order so its `:has(~ input:…)` rules
|
|
16
|
+
* can read state directly off it, keeping the whole control CSS-driven;
|
|
17
|
+
* `shrink(0)` also keeps the box square regardless of label length.
|
|
18
|
+
*
|
|
19
|
+
* @param handle Runtime handle carrying the host `<input>`'s props.
|
|
20
|
+
* @returns The render function producing the checkbox's markup.
|
|
21
|
+
* @example
|
|
22
|
+
* <Checkbox name="terms" required>{t("signup.acceptTerms")}</Checkbox>
|
|
23
|
+
* @example
|
|
24
|
+
* <Checkbox color="danger" checked={row.flagged} aria-label={t("table.flagRow")} />
|
|
25
|
+
* @example
|
|
26
|
+
* <Checkbox disabled defaultChecked>{t("settings.legacyOptIn")}</Checkbox>
|
|
27
|
+
*/
|
|
28
|
+
export function Checkbox(handle) {
|
|
29
|
+
return () => {
|
|
30
|
+
let { color, children, parts, mix, ...rest } = handle.props;
|
|
31
|
+
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
32
|
+
warnIfNoAccessibleName(handle.props, children, "Checkbox: a checkbox with no visible label text needs an `aria-label` describing what it toggles — assistive technology has no accessible name to announce otherwise.");
|
|
33
|
+
return (_jsxs("label", { mix: [relative(), hstack({ gap: 2, align: "center" })], children: [_jsxs("span", { "aria-hidden": "true", "data-slot": "box", "data-color": resolvedColor, mix: [
|
|
34
|
+
center(),
|
|
35
|
+
is("1.25rem"),
|
|
36
|
+
bs("1.25rem"),
|
|
37
|
+
shrink(0),
|
|
38
|
+
rounded("sm"),
|
|
39
|
+
border({ width: 2, color: "neutral.strong" }),
|
|
40
|
+
bg("neutral.tint"),
|
|
41
|
+
interactiveTransition(),
|
|
42
|
+
when("& > svg", [hidden(), is("0.75rem"), bs("0.75rem")]),
|
|
43
|
+
when("&:has(~ input:checked) > svg:first-child", block()),
|
|
44
|
+
when("&:has(~ input:indeterminate) > svg:last-child", block()),
|
|
45
|
+
when('&[data-color="brand"]', when("&:has(~ input:checked), &:has(~ input:indeterminate)", [
|
|
46
|
+
border("brand.solid"),
|
|
47
|
+
bg("brand.solid"),
|
|
48
|
+
fg("brand.onSolid"),
|
|
49
|
+
])),
|
|
50
|
+
when('&[data-color="neutral"]', when("&:has(~ input:checked), &:has(~ input:indeterminate)", [
|
|
51
|
+
border("neutral.solid"),
|
|
52
|
+
bg("neutral.solid"),
|
|
53
|
+
fg("neutral.onSolid"),
|
|
54
|
+
])),
|
|
55
|
+
when('&[data-color="success"]', when("&:has(~ input:checked), &:has(~ input:indeterminate)", [
|
|
56
|
+
border("success.solid"),
|
|
57
|
+
bg("success.solid"),
|
|
58
|
+
fg("success.onSolid"),
|
|
59
|
+
])),
|
|
60
|
+
when('&[data-color="warning"]', when("&:has(~ input:checked), &:has(~ input:indeterminate)", [
|
|
61
|
+
border("warning.solid"),
|
|
62
|
+
bg("warning.solid"),
|
|
63
|
+
fg("warning.onSolid"),
|
|
64
|
+
])),
|
|
65
|
+
when('&[data-color="danger"]', when("&:has(~ input:checked), &:has(~ input:indeterminate)", [
|
|
66
|
+
border("danger.solid"),
|
|
67
|
+
bg("danger.solid"),
|
|
68
|
+
fg("danger.onSolid"),
|
|
69
|
+
])),
|
|
70
|
+
when("&:has(~ input:focus-visible)", [
|
|
71
|
+
outline({ color: "brand.ring", offset: 2 }),
|
|
72
|
+
when('&[data-color="neutral"]', outline("neutral.ring")),
|
|
73
|
+
when('&[data-color="success"]', outline("success.ring")),
|
|
74
|
+
when('&[data-color="warning"]', outline("warning.ring")),
|
|
75
|
+
when('&[data-color="danger"]', outline("danger.ring")),
|
|
76
|
+
]),
|
|
77
|
+
when("&:has(~ input:disabled)", [cursor("not-allowed"), opacity(50)]),
|
|
78
|
+
parts?.box,
|
|
79
|
+
], children: [_jsx(CheckIcon, {}), _jsx(MinusIcon, {})] }), _jsx("input", { type: "checkbox", ...rest, mix: [visuallyHidden(), mix] }), children] }));
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A two-dimensional saturation/brightness picking square for a given hue,
|
|
3
|
+
* built from two overlaid native `<input type="range">` elements — one
|
|
4
|
+
* horizontal for saturation, one rotated vertical for brightness — whose
|
|
5
|
+
* native thumbs, each reshaped into a thin line, cross at the picked point.
|
|
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
|
+
/**
|
|
12
|
+
* Prop types for {@link ColorArea} and its compound parts.
|
|
13
|
+
*/
|
|
14
|
+
export declare namespace ColorArea {
|
|
15
|
+
/**
|
|
16
|
+
* Value {@link ColorArea} stores in component context so its
|
|
17
|
+
* {@link ColorArea.SaturationThumb} and {@link ColorArea.ValueThumb} share
|
|
18
|
+
* the same resolved hue, position, and stable ids without repeating them.
|
|
19
|
+
*/
|
|
20
|
+
interface Context {
|
|
21
|
+
/** Resolved hue, in degrees, the square's background paints for. */
|
|
22
|
+
hue: number;
|
|
23
|
+
/** Resolved saturation (x-axis position), `0`–`100`. */
|
|
24
|
+
saturation: number;
|
|
25
|
+
/** Resolved brightness (y-axis position), `0`–`100`. */
|
|
26
|
+
value: number;
|
|
27
|
+
/** Id shared by {@link ColorArea.SaturationThumb} as its own `id`. */
|
|
28
|
+
saturationThumbId: string;
|
|
29
|
+
/** Id shared by {@link ColorArea.ValueThumb} as its own `id`. */
|
|
30
|
+
valueThumbId: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Props accepted by {@link ColorArea}.
|
|
34
|
+
*/
|
|
35
|
+
interface Props extends TagProps<"div"> {
|
|
36
|
+
/**
|
|
37
|
+
* Hue, in degrees `0`–`360`, the square's background renders every reachable
|
|
38
|
+
* saturation/brightness combination for. Defaults to {@link DEFAULT_HUE}.
|
|
39
|
+
* Typically driven by a hue control alongside this one, re-rendering on change.
|
|
40
|
+
*/
|
|
41
|
+
hue?: number;
|
|
42
|
+
/** Current saturation (x-axis position), `0`–`100`, for a square whose position the consumer tracks itself. */
|
|
43
|
+
saturation?: number;
|
|
44
|
+
/** Starting saturation (x-axis position), `0`–`100`, for a square that never tracks its own position. */
|
|
45
|
+
defaultSaturation?: number;
|
|
46
|
+
/** Current brightness (y-axis position), `0`–`100`, for a square whose position the consumer tracks itself. */
|
|
47
|
+
value?: number;
|
|
48
|
+
/** Starting brightness (y-axis position), `0`–`100`, for a square that never tracks its own position. */
|
|
49
|
+
defaultValue?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Every native `<input>` attribute except `type` (fixed to `"range"`) and
|
|
53
|
+
* `role` (the platform's implicit `"slider"`), plus `mix`. Use
|
|
54
|
+
* `value`/`defaultValue`, `min`/`max`/`step`, and `aria-label` as usual.
|
|
55
|
+
*/
|
|
56
|
+
interface SaturationThumbProps extends Omit<TagProps<"input">, "type" | "role"> {
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Every native `<input>` attribute except `type` (fixed to `"range"`) and
|
|
60
|
+
* `role` (the platform's implicit `"slider"`), plus `mix`. Use
|
|
61
|
+
* `value`/`defaultValue`, `min`/`max`/`step`, and `aria-label` as usual.
|
|
62
|
+
*/
|
|
63
|
+
interface ValueThumbProps extends Omit<TagProps<"input">, "type" | "role"> {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Renders the root `<div>`'s picking-square background: literal `black`/`white`
|
|
68
|
+
* gradient stops are the fixed brightness/saturation math primaries, and the
|
|
69
|
+
* hue's `hsl()` composes through `bg()`, since it passes `(`-values unchanged.
|
|
70
|
+
*
|
|
71
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link ColorArea.Context}.
|
|
72
|
+
* @returns The render function producing the root's markup.
|
|
73
|
+
* @example
|
|
74
|
+
* <ColorArea aria-label={t("colorPicker.area")} hue={210} defaultSaturation={80} defaultValue={70}>
|
|
75
|
+
* <ColorArea.SaturationThumb aria-label={t("colorPicker.saturation")} />
|
|
76
|
+
* <ColorArea.ValueThumb aria-label={t("colorPicker.brightness")} />
|
|
77
|
+
* </ColorArea>
|
|
78
|
+
*/
|
|
79
|
+
export declare function ColorArea(handle: Handle<ColorArea.Props, ColorArea.Context>): () => import("remix/ui").RemixElement;
|
|
80
|
+
export declare namespace ColorArea {
|
|
81
|
+
var SaturationThumb: (handle: Handle<ColorArea.SaturationThumbProps>) => () => import("remix/ui").RemixElement;
|
|
82
|
+
var ValueThumb: (handle: Handle<ColorArea.ValueThumbProps>) => () => import("remix/ui").RemixElement;
|
|
83
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, border, linearGradient, outline, outlineStyle } from "@sdxc/u/color";
|
|
3
|
+
import { opacity, ringShadow, rounded, transition, transitionDuration } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor, pointerEvents, raw } from "@sdxc/u/general";
|
|
5
|
+
import { absolute, appearance, inlineBlock, inset, relative } from "@sdxc/u/layout";
|
|
6
|
+
import { overflow } from "@sdxc/u/overflow";
|
|
7
|
+
import { media } from "@sdxc/u/responsive";
|
|
8
|
+
import { bs, is, m } from "@sdxc/u/size";
|
|
9
|
+
import { z } from "@sdxc/u/stacking";
|
|
10
|
+
import { when } from "@sdxc/u/state";
|
|
11
|
+
import { scaleProperty } from "@sdxc/u/transform";
|
|
12
|
+
import { attrs } from "remix/ui";
|
|
13
|
+
import { mergeStyle } from "../utils/merge-style.js";
|
|
14
|
+
import { warnIfNoAccessibleLabel } from "../utils/warn-if-no-accessible-name.js";
|
|
15
|
+
/** Hue, in degrees, {@link ColorArea} falls back to when `hue` is omitted. */
|
|
16
|
+
const DEFAULT_HUE = 0;
|
|
17
|
+
/** Lower bound shared by both axis inputs' native `min`. */
|
|
18
|
+
const DEFAULT_MIN = 0;
|
|
19
|
+
/** Upper bound shared by both axis inputs' native `max`. */
|
|
20
|
+
const DEFAULT_MAX = 100;
|
|
21
|
+
/** Step shared by both axis inputs' native `step`, applied when a thumb's own `step` is omitted. */
|
|
22
|
+
const DEFAULT_STEP = 1;
|
|
23
|
+
/**
|
|
24
|
+
* Saturation (x-axis) {@link ColorArea} falls back to when neither
|
|
25
|
+
* `saturation` nor `defaultSaturation` is set — full saturation, so the
|
|
26
|
+
* default picked point starts at the pure-hue edge of the square.
|
|
27
|
+
*/
|
|
28
|
+
const DEFAULT_SATURATION = 100;
|
|
29
|
+
/**
|
|
30
|
+
* Brightness (y-axis) {@link ColorArea} falls back to when neither `value`
|
|
31
|
+
* nor `defaultValue` is set — full brightness, pairing with
|
|
32
|
+
* {@link DEFAULT_SATURATION} for a default picked point at the pure-hue corner.
|
|
33
|
+
*/
|
|
34
|
+
const DEFAULT_VALUE = 100;
|
|
35
|
+
/**
|
|
36
|
+
* `role="group"` applied through {@link attrs} unless a consumer supplies
|
|
37
|
+
* its own `role`, announcing the root as one grouped control to assistive
|
|
38
|
+
* technology despite its two axes riding two separate native inputs.
|
|
39
|
+
*/
|
|
40
|
+
const DEFAULT_ROLE = "group";
|
|
41
|
+
/**
|
|
42
|
+
* Renders the root `<div>`'s picking-square background: literal `black`/`white`
|
|
43
|
+
* gradient stops are the fixed brightness/saturation math primaries, and the
|
|
44
|
+
* hue's `hsl()` composes through `bg()`, since it passes `(`-values unchanged.
|
|
45
|
+
*
|
|
46
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link ColorArea.Context}.
|
|
47
|
+
* @returns The render function producing the root's markup.
|
|
48
|
+
* @example
|
|
49
|
+
* <ColorArea aria-label={t("colorPicker.area")} hue={210} defaultSaturation={80} defaultValue={70}>
|
|
50
|
+
* <ColorArea.SaturationThumb aria-label={t("colorPicker.saturation")} />
|
|
51
|
+
* <ColorArea.ValueThumb aria-label={t("colorPicker.brightness")} />
|
|
52
|
+
* </ColorArea>
|
|
53
|
+
*/
|
|
54
|
+
export function ColorArea(handle) {
|
|
55
|
+
return () => {
|
|
56
|
+
let { hue, saturation, defaultSaturation, value, defaultValue, mix, style, ...rest } = handle.props;
|
|
57
|
+
let resolvedHue = hue ?? DEFAULT_HUE;
|
|
58
|
+
let resolvedSaturation = saturation ?? defaultSaturation ?? DEFAULT_SATURATION;
|
|
59
|
+
let resolvedValue = value ?? defaultValue ?? DEFAULT_VALUE;
|
|
60
|
+
let resolvedStyle = mergeStyle(style, { "--ui-color-area-hue": resolvedHue });
|
|
61
|
+
warnIfNoAccessibleLabel(handle.props, "ColorArea: this group needs an `aria-label` describing what it picks — assistive technology has no accessible name for the group its two axis inputs are announced under otherwise.");
|
|
62
|
+
handle.context.set({
|
|
63
|
+
hue: resolvedHue,
|
|
64
|
+
saturation: resolvedSaturation,
|
|
65
|
+
value: resolvedValue,
|
|
66
|
+
saturationThumbId: `${handle.id}-saturation`,
|
|
67
|
+
valueThumbId: `${handle.id}-value`,
|
|
68
|
+
});
|
|
69
|
+
return (_jsx("div", { "data-slot": "area", ...rest, style: resolvedStyle, mix: [
|
|
70
|
+
attrs({ role: DEFAULT_ROLE }),
|
|
71
|
+
relative(),
|
|
72
|
+
inlineBlock(),
|
|
73
|
+
is("var(--ui-color-area-size, 16rem)"),
|
|
74
|
+
bs("var(--ui-color-area-size, 16rem)"),
|
|
75
|
+
rounded("md"),
|
|
76
|
+
border({ width: 1, color: "neutral" }),
|
|
77
|
+
overflow(),
|
|
78
|
+
bg({
|
|
79
|
+
image: `${linearGradient("to top", "black", "transparent")}, ${linearGradient("to right", "white", "transparent")}`,
|
|
80
|
+
}),
|
|
81
|
+
bg("hsl(var(--ui-color-area-hue, 0) 100% 50%)"),
|
|
82
|
+
mix,
|
|
83
|
+
] }));
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* `direction` stays fixed left-to-right regardless of the page's own `dir`,
|
|
88
|
+
* matching the root gradient's physical axes; only this thumb's own line
|
|
89
|
+
* accepts pointer input, so elsewhere a click reaches the axis line beneath it.
|
|
90
|
+
*
|
|
91
|
+
* @param handle Runtime handle carrying the host `<input>`'s props.
|
|
92
|
+
* @returns The render function producing the thumb's markup.
|
|
93
|
+
* @example
|
|
94
|
+
* <ColorArea.SaturationThumb aria-label={t("colorPicker.saturation")} />
|
|
95
|
+
*/
|
|
96
|
+
ColorArea.SaturationThumb = function ColorAreaSaturationThumb(handle) {
|
|
97
|
+
return () => {
|
|
98
|
+
let { id, min, max, step, value, defaultValue, mix, ...rest } = handle.props;
|
|
99
|
+
let context = handle.context.get(ColorArea);
|
|
100
|
+
let resolvedStep = step ?? DEFAULT_STEP;
|
|
101
|
+
let resolvedValue = value ?? defaultValue ?? context.saturation;
|
|
102
|
+
warnIfNoAccessibleLabel(handle.props, "ColorArea.SaturationThumb: this thumb needs an `aria-label` describing the saturation axis — assistive technology has no accessible name for it otherwise.");
|
|
103
|
+
return (_jsx("input", { ...rest, type: "range", id: id ?? context.saturationThumbId, min: min ?? DEFAULT_MIN, max: max ?? DEFAULT_MAX, step: resolvedStep, defaultValue: resolvedValue, mix: [
|
|
104
|
+
absolute(),
|
|
105
|
+
z(10),
|
|
106
|
+
is("full"),
|
|
107
|
+
bs("full"),
|
|
108
|
+
when("&::-webkit-slider-thumb", [
|
|
109
|
+
rounded("full"),
|
|
110
|
+
border({ width: 2, color: "neutral.tint" }),
|
|
111
|
+
bg("neutral.tint"),
|
|
112
|
+
cursor("pointer"),
|
|
113
|
+
transition("scale"),
|
|
114
|
+
]),
|
|
115
|
+
when("&::-moz-range-thumb", [
|
|
116
|
+
rounded("full"),
|
|
117
|
+
border({ width: 2, color: "neutral.tint" }),
|
|
118
|
+
bg("neutral.tint"),
|
|
119
|
+
cursor("pointer"),
|
|
120
|
+
transition("scale"),
|
|
121
|
+
]),
|
|
122
|
+
when("&:focus-visible::-webkit-slider-thumb", outline({ color: "brand.ring", offset: 2 })),
|
|
123
|
+
when("&:focus-visible::-moz-range-thumb", outline({ color: "brand.ring", offset: 2 })),
|
|
124
|
+
when("&:disabled::-webkit-slider-thumb", [cursor("not-allowed"), opacity(50)]),
|
|
125
|
+
when("&:disabled::-moz-range-thumb", [cursor("not-allowed"), opacity(50)]),
|
|
126
|
+
inset("0"),
|
|
127
|
+
m("0"),
|
|
128
|
+
bg("transparent"),
|
|
129
|
+
appearance("none", { moz: false }),
|
|
130
|
+
raw({ direction: "ltr" }),
|
|
131
|
+
pointerEvents(),
|
|
132
|
+
outlineStyle("none"),
|
|
133
|
+
when("&::-webkit-slider-runnable-track", [
|
|
134
|
+
is("full"),
|
|
135
|
+
bs("full"),
|
|
136
|
+
bg("transparent"),
|
|
137
|
+
appearance("none", { moz: false }),
|
|
138
|
+
]),
|
|
139
|
+
when("&::-moz-range-track", [
|
|
140
|
+
is("full"),
|
|
141
|
+
bs("full"),
|
|
142
|
+
bg("transparent"),
|
|
143
|
+
appearance("none", { webkit: false, moz: false }),
|
|
144
|
+
border({ style: "none" }),
|
|
145
|
+
]),
|
|
146
|
+
when("&::-webkit-slider-thumb", [
|
|
147
|
+
is("var(--ui-color-area-thumb-thickness, 0.1875rem)"),
|
|
148
|
+
bs("var(--ui-color-area-size, 16rem)"),
|
|
149
|
+
appearance("none", { moz: false }),
|
|
150
|
+
pointerEvents("auto"),
|
|
151
|
+
ringShadow("rgb(0 0 0 / 0.4)", 1),
|
|
152
|
+
]),
|
|
153
|
+
when("&::-moz-range-thumb", [
|
|
154
|
+
is("var(--ui-color-area-thumb-thickness, 0.1875rem)"),
|
|
155
|
+
bs("var(--ui-color-area-size, 16rem)"),
|
|
156
|
+
pointerEvents("auto"),
|
|
157
|
+
ringShadow("rgb(0 0 0 / 0.4)", 1),
|
|
158
|
+
]),
|
|
159
|
+
when("&:active::-webkit-slider-thumb", scaleProperty(1.2)),
|
|
160
|
+
when("&:active::-moz-range-thumb", scaleProperty(1.2)),
|
|
161
|
+
media("(prefers-reduced-motion: reduce)", [
|
|
162
|
+
when("&::-webkit-slider-thumb", transitionDuration("0s")),
|
|
163
|
+
when("&::-moz-range-thumb", transitionDuration("0s")),
|
|
164
|
+
]),
|
|
165
|
+
mix,
|
|
166
|
+
] }));
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* `writing-mode`/`direction` stay fixed regardless of the page's own `dir`,
|
|
171
|
+
* so this line travels block-end (black) to block-start, the low-at-the-
|
|
172
|
+
* bottom convention; pointer layering matches {@link ColorArea.SaturationThumb}.
|
|
173
|
+
*
|
|
174
|
+
* @param handle Runtime handle carrying the host `<input>`'s props.
|
|
175
|
+
* @returns The render function producing the thumb's markup.
|
|
176
|
+
* @example
|
|
177
|
+
* <ColorArea.ValueThumb aria-label={t("colorPicker.brightness")} />
|
|
178
|
+
*/
|
|
179
|
+
ColorArea.ValueThumb = function ColorAreaValueThumb(handle) {
|
|
180
|
+
return () => {
|
|
181
|
+
let { id, min, max, step, value, defaultValue, mix, ...rest } = handle.props;
|
|
182
|
+
let context = handle.context.get(ColorArea);
|
|
183
|
+
let resolvedStep = step ?? DEFAULT_STEP;
|
|
184
|
+
let resolvedValue = value ?? defaultValue ?? context.value;
|
|
185
|
+
warnIfNoAccessibleLabel(handle.props, "ColorArea.ValueThumb: this thumb needs an `aria-label` describing the brightness axis — assistive technology has no accessible name for it otherwise.");
|
|
186
|
+
return (_jsx("input", { ...rest, type: "range", id: id ?? context.valueThumbId, min: min ?? DEFAULT_MIN, max: max ?? DEFAULT_MAX, step: resolvedStep, defaultValue: resolvedValue, "aria-orientation": "vertical", mix: [
|
|
187
|
+
absolute(),
|
|
188
|
+
z(10),
|
|
189
|
+
is("full"),
|
|
190
|
+
bs("full"),
|
|
191
|
+
when("&::-webkit-slider-thumb", [
|
|
192
|
+
rounded("full"),
|
|
193
|
+
border({ width: 2, color: "neutral.tint" }),
|
|
194
|
+
bg("neutral.tint"),
|
|
195
|
+
cursor("pointer"),
|
|
196
|
+
transition("scale"),
|
|
197
|
+
]),
|
|
198
|
+
when("&::-moz-range-thumb", [
|
|
199
|
+
rounded("full"),
|
|
200
|
+
border({ width: 2, color: "neutral.tint" }),
|
|
201
|
+
bg("neutral.tint"),
|
|
202
|
+
cursor("pointer"),
|
|
203
|
+
transition("scale"),
|
|
204
|
+
]),
|
|
205
|
+
when("&:focus-visible::-webkit-slider-thumb", outline({ color: "brand.ring", offset: 2 })),
|
|
206
|
+
when("&:focus-visible::-moz-range-thumb", outline({ color: "brand.ring", offset: 2 })),
|
|
207
|
+
when("&:disabled::-webkit-slider-thumb", [cursor("not-allowed"), opacity(50)]),
|
|
208
|
+
when("&:disabled::-moz-range-thumb", [cursor("not-allowed"), opacity(50)]),
|
|
209
|
+
inset("0"),
|
|
210
|
+
m("0"),
|
|
211
|
+
bg("transparent"),
|
|
212
|
+
appearance("none", { moz: false }),
|
|
213
|
+
raw({ writingMode: "vertical-lr", direction: "rtl" }),
|
|
214
|
+
pointerEvents(),
|
|
215
|
+
outlineStyle("none"),
|
|
216
|
+
when("&::-webkit-slider-runnable-track", [
|
|
217
|
+
is("full"),
|
|
218
|
+
bs("full"),
|
|
219
|
+
bg("transparent"),
|
|
220
|
+
appearance("none", { moz: false }),
|
|
221
|
+
]),
|
|
222
|
+
when("&::-moz-range-track", [
|
|
223
|
+
is("full"),
|
|
224
|
+
bs("full"),
|
|
225
|
+
bg("transparent"),
|
|
226
|
+
appearance("none", { webkit: false, moz: false }),
|
|
227
|
+
border({ style: "none" }),
|
|
228
|
+
]),
|
|
229
|
+
when("&::-webkit-slider-thumb", [
|
|
230
|
+
is("var(--ui-color-area-thumb-thickness, 0.1875rem)"),
|
|
231
|
+
bs("var(--ui-color-area-size, 16rem)"),
|
|
232
|
+
appearance("none", { moz: false }),
|
|
233
|
+
pointerEvents("auto"),
|
|
234
|
+
ringShadow("rgb(0 0 0 / 0.4)", 1),
|
|
235
|
+
]),
|
|
236
|
+
when("&::-moz-range-thumb", [
|
|
237
|
+
is("var(--ui-color-area-thumb-thickness, 0.1875rem)"),
|
|
238
|
+
bs("var(--ui-color-area-size, 16rem)"),
|
|
239
|
+
pointerEvents("auto"),
|
|
240
|
+
ringShadow("rgb(0 0 0 / 0.4)", 1),
|
|
241
|
+
]),
|
|
242
|
+
when("&:active::-webkit-slider-thumb", scaleProperty(1.2)),
|
|
243
|
+
when("&:active::-moz-range-thumb", scaleProperty(1.2)),
|
|
244
|
+
media("(prefers-reduced-motion: reduce)", [
|
|
245
|
+
when("&::-webkit-slider-thumb", transitionDuration("0s")),
|
|
246
|
+
when("&::-moz-range-thumb", transitionDuration("0s")),
|
|
247
|
+
]),
|
|
248
|
+
mix,
|
|
249
|
+
] }));
|
|
250
|
+
};
|
|
251
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A labeled, described, and validated color field in one call: every id and
|
|
3
|
+
* `aria-describedby` relationship comes from this instance's own stable
|
|
4
|
+
* identifier, so the composed parts stay associated on their own. The preview
|
|
5
|
+
* paints the resolved value at render time, so it matches the control on
|
|
6
|
+
* first paint and on every server round-trip.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/ui";
|
|
12
|
+
import type { FieldPartsProps } from "../utils/field-parts.js";
|
|
13
|
+
/**
|
|
14
|
+
* Prop types for {@link ColorField}.
|
|
15
|
+
*/
|
|
16
|
+
export declare namespace ColorField {
|
|
17
|
+
/**
|
|
18
|
+
* Semantic color role for the control's keyboard focus ring, each mapped
|
|
19
|
+
* to its matching `--ui-*` variables.
|
|
20
|
+
*/
|
|
21
|
+
type Color = "brand" | "neutral" | "success" | "warning" | "danger";
|
|
22
|
+
/**
|
|
23
|
+
* Notation the control's typed value is constrained to through its native
|
|
24
|
+
* `pattern`: `"hex"` for `#rgb`/`#rrggbb` and their alpha forms, `"rgb"`
|
|
25
|
+
* for `rgb()`/`rgba()`, and `"hsl"` for `hsl()`/`hsla()`.
|
|
26
|
+
*/
|
|
27
|
+
type Format = "hex" | "rgb" | "hsl";
|
|
28
|
+
/**
|
|
29
|
+
* Per-part styling for the elements this convenience wrapper composes in
|
|
30
|
+
* one call, layered after each part's own built-in styling.
|
|
31
|
+
*/
|
|
32
|
+
interface PartsProps extends FieldPartsProps {
|
|
33
|
+
/** Styling for the row grouping the control and its preview. */
|
|
34
|
+
control?: TagProps<"div">["mix"];
|
|
35
|
+
/** Styling for the live preview, rendered through {@link ColorSwatch}. */
|
|
36
|
+
swatch?: TagProps<"span">["mix"];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Props accepted by {@link ColorField}. `mix` styles the root element
|
|
40
|
+
* grouping the field's parts; style the composed label, control, preview,
|
|
41
|
+
* description, and error individually through `parts` instead.
|
|
42
|
+
*/
|
|
43
|
+
interface Props extends Omit<TagProps<"div">, "children"> {
|
|
44
|
+
/** Semantic color role for the control's focus ring. Defaults to `"neutral"` when omitted. */
|
|
45
|
+
color?: Color;
|
|
46
|
+
/**
|
|
47
|
+
* The field's caption, rendered through {@link Label} and associated
|
|
48
|
+
* with the control through a native `for`/`id` relationship computed
|
|
49
|
+
* from this instance's own identifier.
|
|
50
|
+
*/
|
|
51
|
+
label: RemixNode;
|
|
52
|
+
/**
|
|
53
|
+
* Supporting copy rendered through {@link Description} beneath the
|
|
54
|
+
* control and referenced by the control's `aria-describedby`.
|
|
55
|
+
*/
|
|
56
|
+
description?: RemixNode;
|
|
57
|
+
/**
|
|
58
|
+
* Validation message rendered through {@link FieldError} beneath the
|
|
59
|
+
* control, referenced by its `aria-describedby`; its presence alone
|
|
60
|
+
* marks `aria-invalid`. Inside a {@link Form} carrying `issues`, this prop wins.
|
|
61
|
+
*/
|
|
62
|
+
errorMessage?: RemixNode;
|
|
63
|
+
/**
|
|
64
|
+
* Native `autofocus`. Defaults to `true` for the first invalid field of
|
|
65
|
+
* an enclosing {@link Form}'s `issues`, so a server round-trip lands
|
|
66
|
+
* keyboard focus on the first problem while staying script-free.
|
|
67
|
+
*/
|
|
68
|
+
autoFocus?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Notation the control's `pattern` constrains typed entry to. Defaults
|
|
71
|
+
* to {@link DEFAULT_FORMAT}.
|
|
72
|
+
*/
|
|
73
|
+
format?: Format;
|
|
74
|
+
/** Native `name` submitted with an enclosing form. */
|
|
75
|
+
name?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Current value, as a literal color string in `format`'s notation, for a
|
|
78
|
+
* control a consumer tracks itself. This same string paints the
|
|
79
|
+
* preview directly.
|
|
80
|
+
*/
|
|
81
|
+
value?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Initial value, as a literal color string in `format`'s notation, for a
|
|
84
|
+
* control left to the platform's own uncontrolled state. This same
|
|
85
|
+
* string paints the preview directly whenever `value` is unset.
|
|
86
|
+
*/
|
|
87
|
+
defaultValue?: string;
|
|
88
|
+
/** Placeholder copy shown while the control is empty. */
|
|
89
|
+
placeholder?: string;
|
|
90
|
+
/** Marks the control required for its enclosing form. */
|
|
91
|
+
required?: boolean;
|
|
92
|
+
/** Marks the control inert and excluded from the tab order. */
|
|
93
|
+
disabled?: boolean;
|
|
94
|
+
/** Marks the control's value fixed, while keeping it focusable and included in form submission. */
|
|
95
|
+
readOnly?: boolean;
|
|
96
|
+
/** Native autofill hint. */
|
|
97
|
+
autoComplete?: string;
|
|
98
|
+
/** Per-part styling for this wrapper's internally composed elements. */
|
|
99
|
+
parts?: PartsProps;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Composes {@link Label}, an {@link Input} constrained by `format`'s native
|
|
104
|
+
* `pattern`, a live {@link ColorSwatch} preview of the resolved value, and
|
|
105
|
+
* any {@link Description} or {@link FieldError}, wired to this instance's own id.
|
|
106
|
+
*
|
|
107
|
+
* @param handle Runtime handle carrying the root element's props and this instance's stable identifier.
|
|
108
|
+
* @returns The render function producing the field's markup.
|
|
109
|
+
* @example
|
|
110
|
+
* <ColorField label={t("form.accentColor.label")} name="accentColor" defaultValue="#3b82f6" />
|
|
111
|
+
* @example
|
|
112
|
+
* <ColorField
|
|
113
|
+
* label={t("form.brandColor.label")}
|
|
114
|
+
* name="brandColor"
|
|
115
|
+
* format="rgb"
|
|
116
|
+
* defaultValue="rgb(16, 185, 129)"
|
|
117
|
+
* description={t("form.brandColor.hint")}
|
|
118
|
+
* />
|
|
119
|
+
* @example
|
|
120
|
+
* <ColorField
|
|
121
|
+
* label={t("form.themeColor.label")}
|
|
122
|
+
* name="themeColor"
|
|
123
|
+
* format="hsl"
|
|
124
|
+
* value="hsl(210, 90%, 55%)"
|
|
125
|
+
* errorMessage={t("form.themeColor.invalid")}
|
|
126
|
+
* />
|
|
127
|
+
*/
|
|
128
|
+
export declare function ColorField(handle: Handle<ColorField.Props>): () => import("remix/ui").RemixElement;
|