@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,160 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, border, outline, outlineStyle } from "@sdxc/u/color";
|
|
3
|
+
import { mask, opacity, rounded, shadow, transition, transitionDuration } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor, pointerEvents, pseudoContent, raw } from "@sdxc/u/general";
|
|
5
|
+
import { absolute, appearance, block, inlineBlock, insBs, insIs, inset, relative, } from "@sdxc/u/layout";
|
|
6
|
+
import { media } from "@sdxc/u/responsive";
|
|
7
|
+
import { bs, is, m, mbs, minIs, mis } from "@sdxc/u/size";
|
|
8
|
+
import { when } from "@sdxc/u/state";
|
|
9
|
+
import { rangeThumbAppearance } from "../styles/range-thumb-appearance.js";
|
|
10
|
+
import { rtlAwareGradientDirection } from "../styles/rtl-aware-gradient-direction.js";
|
|
11
|
+
import { clampChannel, roundChannel } from "../utils/color-math.js";
|
|
12
|
+
import { HUE_GRADIENT_STOPS } from "../utils/hue-spectrum.js";
|
|
13
|
+
import { mergeStyle } from "../utils/merge-style.js";
|
|
14
|
+
import { warnIfNoAccessibleLabel } from "../utils/warn-if-no-accessible-name.js";
|
|
15
|
+
/** Lower bound of {@link ColorWheel}'s fixed hue domain, in degrees — fixed, since the full domain is what makes this control a hue wheel. */
|
|
16
|
+
const DEFAULT_MIN = 0;
|
|
17
|
+
/** Upper bound of {@link ColorWheel}'s fixed hue domain, in degrees; reaching it wraps back to the same red {@link DEFAULT_MIN} starts from, since hue is continuous around the circle. */
|
|
18
|
+
const DEFAULT_MAX = 360;
|
|
19
|
+
/** Degrees a single keypress moves {@link ColorWheel}'s value by, applied when `step` is omitted. */
|
|
20
|
+
const DEFAULT_STEP = 1;
|
|
21
|
+
/** Hue, in degrees, {@link ColorWheel} falls back to when both `value` and `defaultValue` are omitted. */
|
|
22
|
+
const DEFAULT_VALUE = 0;
|
|
23
|
+
/**
|
|
24
|
+
* Custom property naming the plain-bar track gradient's sweep direction,
|
|
25
|
+
* flipped from `"right"` to `"left"` under `:dir(rtl)` so the gradient
|
|
26
|
+
* always reads in the same direction as the surrounding text.
|
|
27
|
+
*/
|
|
28
|
+
const TRACK_DIRECTION_PROPERTY = "--ui-color-wheel-track-direction";
|
|
29
|
+
/**
|
|
30
|
+
* The plain-bar track background, sweeping {@link HUE_GRADIENT_STOPS}
|
|
31
|
+
* toward {@link TRACK_DIRECTION_PROPERTY}'s current direction — shared
|
|
32
|
+
* verbatim between the WebKit and Gecko track pseudo-elements.
|
|
33
|
+
*/
|
|
34
|
+
const HUE_TRACK_GRADIENT = `linear-gradient(to var(${TRACK_DIRECTION_PROPERTY}, right), ${HUE_GRADIENT_STOPS})`;
|
|
35
|
+
/**
|
|
36
|
+
* The ring rendering's background: {@link HUE_GRADIENT_STOPS} swept
|
|
37
|
+
* clockwise from twelve o'clock, matching the convention the ring's own
|
|
38
|
+
* drag math measures angles by, so painted position always matches value.
|
|
39
|
+
*/
|
|
40
|
+
const WHEEL_CONIC_GRADIENT = `conic-gradient(from 0deg, ${HUE_GRADIENT_STOPS})`;
|
|
41
|
+
/**
|
|
42
|
+
* An alpha mask cutting the ring's filled disc down to a
|
|
43
|
+
* `--ui-color-wheel-thumb-size` band at the outer edge, the same width the
|
|
44
|
+
* plain bar's track and thumb share, so only a ring remains visible.
|
|
45
|
+
*/
|
|
46
|
+
const RING_MASK = "radial-gradient(circle, transparent calc(50% - var(--ui-color-wheel-thumb-size, 1.25rem)), black calc(50% - var(--ui-color-wheel-thumb-size, 1.25rem) + 1px))";
|
|
47
|
+
/**
|
|
48
|
+
* Renders a root `<div>` around a single `<input type="range">` across
|
|
49
|
+
* hue's `0`–`360` domain, carrying every accessibility and form semantic
|
|
50
|
+
* this wheel exposes; `colorWheelDrag()` enables the ring rendering.
|
|
51
|
+
*
|
|
52
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
53
|
+
* @returns The render function producing the wheel's markup.
|
|
54
|
+
* @example
|
|
55
|
+
* <ColorWheel aria-label={t("colorPicker.hue")} defaultValue={210} />
|
|
56
|
+
* @example
|
|
57
|
+
* <ColorWheel aria-label={t("theme.accentHue")} value={hue} name="hue" disabled={isLocked} />
|
|
58
|
+
*/
|
|
59
|
+
export function ColorWheel(handle) {
|
|
60
|
+
return () => {
|
|
61
|
+
let { value, defaultValue, step, name, disabled, form, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, parts, style, mix, ...rest } = handle.props;
|
|
62
|
+
let resolvedValue = value ?? defaultValue ?? DEFAULT_VALUE;
|
|
63
|
+
let resolvedStep = step ?? DEFAULT_STEP;
|
|
64
|
+
let resolvedHue = roundChannel(clampChannel(resolvedValue, DEFAULT_MIN, DEFAULT_MAX));
|
|
65
|
+
let resolvedStyle = mergeStyle(style, {
|
|
66
|
+
"--ui-color-wheel-value": `hsl(${resolvedHue} 100% 50%)`,
|
|
67
|
+
"--ui-color-wheel-hue": `${resolvedHue}`,
|
|
68
|
+
});
|
|
69
|
+
warnIfNoAccessibleLabel(handle.props, "ColorWheel: a wheel with no `aria-label` or `aria-labelledby` needs one describing the hue it picks — assistive technology has no accessible name to announce otherwise.");
|
|
70
|
+
return (_jsx("div", { ...rest, "data-slot": "color-wheel", style: resolvedStyle, mix: [
|
|
71
|
+
relative(),
|
|
72
|
+
block(),
|
|
73
|
+
is("full"),
|
|
74
|
+
minIs("10rem"),
|
|
75
|
+
when('&[data-shape="circular"]', when("&:has(> input:focus-visible)", outline({ color: "brand.ring", offset: 2 }))),
|
|
76
|
+
when('&[data-shape="circular"]', [
|
|
77
|
+
inlineBlock(),
|
|
78
|
+
is("var(--ui-color-wheel-size, 12rem)"),
|
|
79
|
+
bs("var(--ui-color-wheel-size, 12rem)"),
|
|
80
|
+
minIs("0"),
|
|
81
|
+
rounded("full"),
|
|
82
|
+
bg({ image: WHEEL_CONIC_GRADIENT }),
|
|
83
|
+
mask(RING_MASK),
|
|
84
|
+
when("&::after", [
|
|
85
|
+
absolute(),
|
|
86
|
+
is("var(--ui-color-wheel-thumb-size, 1.25rem)"),
|
|
87
|
+
bs("var(--ui-color-wheel-thumb-size, 1.25rem)"),
|
|
88
|
+
mbs("calc(var(--ui-color-wheel-thumb-size, 1.25rem) / -2)"),
|
|
89
|
+
mis("calc(var(--ui-color-wheel-thumb-size, 1.25rem) / -2)"),
|
|
90
|
+
rounded("full"),
|
|
91
|
+
border({
|
|
92
|
+
width: "var(--ui-color-wheel-thumb-border-width, 2px)",
|
|
93
|
+
style: "solid",
|
|
94
|
+
color: "var(--ui-color-wheel-value, var(--ui-brand-bg-solid))",
|
|
95
|
+
}),
|
|
96
|
+
bg("neutral.tint"),
|
|
97
|
+
transition("transform"),
|
|
98
|
+
insBs("50%"),
|
|
99
|
+
insIs("50%"),
|
|
100
|
+
shadow("base"),
|
|
101
|
+
pointerEvents(),
|
|
102
|
+
pseudoContent('""'),
|
|
103
|
+
raw({
|
|
104
|
+
transform: "rotate(calc(var(--ui-color-wheel-hue, 0) * 1deg)) translateY(calc(var(--ui-color-wheel-size, 12rem) / -2 + var(--ui-color-wheel-thumb-size, 1.25rem) / 2))",
|
|
105
|
+
}),
|
|
106
|
+
]),
|
|
107
|
+
when("&:has(> input:disabled)", [
|
|
108
|
+
opacity(50),
|
|
109
|
+
when("&::after", [border("neutral"), raw({ boxShadow: "none" })]),
|
|
110
|
+
]),
|
|
111
|
+
when("& > input", [absolute(), inset("0"), is("full"), bs("full"), opacity(0)]),
|
|
112
|
+
media("(prefers-reduced-motion: reduce)", when("&::after", transitionDuration("0s"))),
|
|
113
|
+
]),
|
|
114
|
+
mix,
|
|
115
|
+
], children: _jsx("input", { type: "range", min: DEFAULT_MIN, max: DEFAULT_MAX, step: resolvedStep, defaultValue: resolvedValue, name: name, disabled: disabled, form: form, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, "data-slot": "input", mix: [
|
|
116
|
+
rtlAwareGradientDirection(TRACK_DIRECTION_PROPERTY),
|
|
117
|
+
rangeThumbAppearance("--ui-color-wheel-thumb-size", "--ui-color-wheel-thumb-border-width"),
|
|
118
|
+
block(),
|
|
119
|
+
is("full"),
|
|
120
|
+
cursor("pointer"),
|
|
121
|
+
when("&:disabled", cursor("not-allowed")),
|
|
122
|
+
bs("var(--ui-color-wheel-thumb-size, 1.25rem)"),
|
|
123
|
+
m("0"),
|
|
124
|
+
bg("transparent"),
|
|
125
|
+
appearance("none", { moz: false }),
|
|
126
|
+
outlineStyle("none"),
|
|
127
|
+
when("&::-webkit-slider-runnable-track", [
|
|
128
|
+
bs("var(--ui-color-wheel-thumb-size, 1.25rem)"),
|
|
129
|
+
rounded("full"),
|
|
130
|
+
bg({ image: HUE_TRACK_GRADIENT }),
|
|
131
|
+
appearance("none", { moz: false }),
|
|
132
|
+
]),
|
|
133
|
+
when("&::-moz-range-track", [
|
|
134
|
+
bs("var(--ui-color-wheel-thumb-size, 1.25rem)"),
|
|
135
|
+
rounded("full"),
|
|
136
|
+
bg({ image: HUE_TRACK_GRADIENT }),
|
|
137
|
+
border({ style: "none" }),
|
|
138
|
+
appearance("none", { webkit: false, moz: false }),
|
|
139
|
+
]),
|
|
140
|
+
when('[data-shape="circular"] &', [
|
|
141
|
+
cursor("pointer"),
|
|
142
|
+
appearance("none", { moz: false }),
|
|
143
|
+
when("&::-webkit-slider-runnable-track", bg({ image: "none", color: "transparent" })),
|
|
144
|
+
when("&::-moz-range-track", bg({ image: "none", color: "transparent" })),
|
|
145
|
+
when("&::-webkit-slider-thumb", [
|
|
146
|
+
border({ style: "none" }),
|
|
147
|
+
bg("transparent"),
|
|
148
|
+
raw({ boxShadow: "none" }),
|
|
149
|
+
]),
|
|
150
|
+
when("&::-moz-range-thumb", [
|
|
151
|
+
border({ style: "none" }),
|
|
152
|
+
bg("transparent"),
|
|
153
|
+
raw({ boxShadow: "none" }),
|
|
154
|
+
]),
|
|
155
|
+
when("&:focus-visible::-webkit-slider-thumb, &:focus-visible::-moz-range-thumb", outlineStyle("none")),
|
|
156
|
+
]),
|
|
157
|
+
parts?.input,
|
|
158
|
+
] }) }));
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single-line text control paired with a native list of suggested values: a
|
|
3
|
+
* {@link ComboBox.Group} row housing the {@link ComboBox.Input} control and a
|
|
4
|
+
* trailing {@link ComboBox.Button} disclosure glyph, all stacked beneath a
|
|
5
|
+
* caption or above supporting copy in a single column with a small gap. The
|
|
6
|
+
* text control builds on {@link Input} for its box, color, and interaction
|
|
7
|
+
* states, and pairs with a plain `<datalist>` of `<option>`s through its own
|
|
8
|
+
* `list` attribute — the browser renders and filters that list entirely on
|
|
9
|
+
* its own, with no styling opportunity across the suggestions themselves.
|
|
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
|
+
import { Input } from "./input.js";
|
|
16
|
+
/**
|
|
17
|
+
* Prop types for {@link ComboBox} and its compound parts.
|
|
18
|
+
*/
|
|
19
|
+
export declare namespace ComboBox {
|
|
20
|
+
/**
|
|
21
|
+
* Every native `<div>` attribute, unchanged, plus the `mix` passthrough.
|
|
22
|
+
* `children` composes this control's parts — typically a caption, the
|
|
23
|
+
* {@link ComboBox.Group} row, a `<datalist>`, and supporting copy.
|
|
24
|
+
*/
|
|
25
|
+
interface Props extends TagProps<"div"> {
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Every native `<div>` attribute, unchanged, plus the `mix` passthrough.
|
|
29
|
+
* `children` composes {@link ComboBox.Input} and {@link ComboBox.Button}
|
|
30
|
+
* into one visual row.
|
|
31
|
+
*/
|
|
32
|
+
interface GroupProps extends TagProps<"div"> {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Every prop {@link Input.Props} accepts, unchanged — a type alias, since
|
|
36
|
+
* {@link Input.Props} resolves through a conditional type only a type
|
|
37
|
+
* alias can express. Pass `list` with a `<datalist>` id to wire suggestions.
|
|
38
|
+
*/
|
|
39
|
+
type InputProps = Input.Props;
|
|
40
|
+
/**
|
|
41
|
+
* Every native `<button>` attribute except `children`, which stays fixed to
|
|
42
|
+
* this button's own disclosure glyph, plus the `mix` passthrough. `type`
|
|
43
|
+
* defaults to {@link DEFAULT_BUTTON_TYPE}.
|
|
44
|
+
*/
|
|
45
|
+
interface ButtonProps extends Omit<TagProps<"button">, "children"> {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Renders a plain host stacking this control's compound parts — a caption,
|
|
50
|
+
* the {@link ComboBox.Group} row, a `<datalist>` of suggested values, and
|
|
51
|
+
* supporting copy — in a single column with a small gap between them.
|
|
52
|
+
*
|
|
53
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
54
|
+
* @returns The render function producing the control's markup.
|
|
55
|
+
* @example
|
|
56
|
+
* <ComboBox>
|
|
57
|
+
* <Label htmlFor="fruit">{t("form.fruit.label")}</Label>
|
|
58
|
+
* <ComboBox.Group>
|
|
59
|
+
* <ComboBox.Input id="fruit" name="fruit" list="fruit-options" />
|
|
60
|
+
* <ComboBox.Button aria-label={t("form.fruit.toggle")} />
|
|
61
|
+
* </ComboBox.Group>
|
|
62
|
+
* <datalist id="fruit-options">
|
|
63
|
+
* <option value="Apple" />
|
|
64
|
+
* <option value="Banana" />
|
|
65
|
+
* </datalist>
|
|
66
|
+
* </ComboBox>
|
|
67
|
+
*/
|
|
68
|
+
export declare function ComboBox(handle: Handle<ComboBox.Props>): () => import("remix/ui").RemixElement;
|
|
69
|
+
export declare namespace ComboBox {
|
|
70
|
+
var Group: (handle: Handle<ComboBox.GroupProps>) => () => import("remix/ui").RemixElement;
|
|
71
|
+
var Input: (handle: Handle<ComboBox.InputProps>) => () => import("remix/ui").RemixElement;
|
|
72
|
+
var Button: (handle: Handle<ComboBox.ButtonProps>) => () => import("remix/ui").RemixElement;
|
|
73
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { ChevronDownIcon } from "@sdxc/icons";
|
|
3
|
+
import { bg, fg, outline } from "@sdxc/u/color";
|
|
4
|
+
import { rounded } from "@sdxc/u/effects";
|
|
5
|
+
import { center, hstack, spacer, vstack } from "@sdxc/u/layout";
|
|
6
|
+
import { bs, is, mis, pie } from "@sdxc/u/size";
|
|
7
|
+
import { when } from "@sdxc/u/state";
|
|
8
|
+
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
9
|
+
import { warnIfNoAccessibleLabel } from "../utils/warn-if-no-accessible-name.js";
|
|
10
|
+
import { Input } from "./input.js";
|
|
11
|
+
/**
|
|
12
|
+
* Native `<button>` `type` {@link ComboBox.Button} falls back to when a
|
|
13
|
+
* consumer omits one, keeping a click from submitting a surrounding
|
|
14
|
+
* `<form>` the way a bare `<button>`'s own default type otherwise would.
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_BUTTON_TYPE = "button";
|
|
17
|
+
/**
|
|
18
|
+
* Renders a plain host stacking this control's compound parts — a caption,
|
|
19
|
+
* the {@link ComboBox.Group} row, a `<datalist>` of suggested values, and
|
|
20
|
+
* supporting copy — in a single column with a small gap between them.
|
|
21
|
+
*
|
|
22
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
23
|
+
* @returns The render function producing the control's markup.
|
|
24
|
+
* @example
|
|
25
|
+
* <ComboBox>
|
|
26
|
+
* <Label htmlFor="fruit">{t("form.fruit.label")}</Label>
|
|
27
|
+
* <ComboBox.Group>
|
|
28
|
+
* <ComboBox.Input id="fruit" name="fruit" list="fruit-options" />
|
|
29
|
+
* <ComboBox.Button aria-label={t("form.fruit.toggle")} />
|
|
30
|
+
* </ComboBox.Group>
|
|
31
|
+
* <datalist id="fruit-options">
|
|
32
|
+
* <option value="Apple" />
|
|
33
|
+
* <option value="Banana" />
|
|
34
|
+
* </datalist>
|
|
35
|
+
* </ComboBox>
|
|
36
|
+
*/
|
|
37
|
+
export function ComboBox(handle) {
|
|
38
|
+
return () => {
|
|
39
|
+
let { mix, ...rest } = handle.props;
|
|
40
|
+
return _jsx("div", { ...rest, "data-slot": "combobox", mix: [vstack({ gap: 1 }), mix] });
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Renders {@link ComboBox}'s control row: a plain flex host laying
|
|
45
|
+
* {@link ComboBox.Input} and {@link ComboBox.Button} side by side, the
|
|
46
|
+
* button pulled back over the input's padding so they read as one field.
|
|
47
|
+
*
|
|
48
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
49
|
+
* @returns The render function producing the row's markup.
|
|
50
|
+
* @example
|
|
51
|
+
* <ComboBox.Group>
|
|
52
|
+
* <ComboBox.Input id="fruit" list="fruit-options" />
|
|
53
|
+
* <ComboBox.Button aria-label={t("form.fruit.toggle")} />
|
|
54
|
+
* </ComboBox.Group>
|
|
55
|
+
*/
|
|
56
|
+
ComboBox.Group = function ComboBoxGroup(handle) {
|
|
57
|
+
return () => {
|
|
58
|
+
let { mix, ...rest } = handle.props;
|
|
59
|
+
return _jsx("div", { ...rest, "data-slot": "combobox-group", mix: [hstack({ align: "center" }), mix] });
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Renders {@link ComboBox}'s text control: an {@link Input} that grows to
|
|
64
|
+
* fill its row, reserves inline-end padding for {@link ComboBox.Button}'s
|
|
65
|
+
* glyph, and carries every {@link Input} interaction state unchanged.
|
|
66
|
+
*
|
|
67
|
+
* @param handle Runtime handle carrying the host `<input>`'s props.
|
|
68
|
+
* @returns The render function producing the control's markup.
|
|
69
|
+
* @example
|
|
70
|
+
* <ComboBox.Input id="fruit" name="fruit" list="fruit-options" />
|
|
71
|
+
* @example
|
|
72
|
+
* <ComboBox.Input aria-label={t("form.country.label")} color="brand" list="country-options" />
|
|
73
|
+
*/
|
|
74
|
+
ComboBox.Input = function ComboBoxInput(handle) {
|
|
75
|
+
return () => {
|
|
76
|
+
let { mix, ...rest } = handle.props;
|
|
77
|
+
return _jsx(Input, { ...rest, mix: [spacer(), pie(9), mix] });
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Renders {@link ComboBox}'s trailing disclosure glyph: a native `<button>`
|
|
82
|
+
* pulled back over {@link ComboBox.Input}'s padding so it reads as part of
|
|
83
|
+
* the same field, its chevron marked `aria-hidden` since it carries no text.
|
|
84
|
+
*
|
|
85
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
86
|
+
* @returns The render function producing the button's markup.
|
|
87
|
+
* @example
|
|
88
|
+
* <ComboBox.Button aria-label={t("form.fruit.toggle")} />
|
|
89
|
+
*/
|
|
90
|
+
ComboBox.Button = function ComboBoxButton(handle) {
|
|
91
|
+
return () => {
|
|
92
|
+
let { type, mix, ...rest } = handle.props;
|
|
93
|
+
warnIfNoAccessibleLabel(handle.props, "ComboBox.Button: this button needs an `aria-label` describing what it does — its content is a decorative glyph with no accessible name of its own.");
|
|
94
|
+
return (_jsx("button", { type: type ?? DEFAULT_BUTTON_TYPE, ...rest, mix: [
|
|
95
|
+
interactiveTransition(),
|
|
96
|
+
center(),
|
|
97
|
+
is("1.75rem"),
|
|
98
|
+
bs("1.75rem"),
|
|
99
|
+
rounded("sm"),
|
|
100
|
+
fg("neutral"),
|
|
101
|
+
when("& svg", [is("1rem"), bs("1rem")]),
|
|
102
|
+
when("&:hover", bg("neutral.bg-tint-hover")),
|
|
103
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 0 })),
|
|
104
|
+
mis("-2rem"),
|
|
105
|
+
mix,
|
|
106
|
+
], children: _jsx(ChevronDownIcon, {}) }));
|
|
107
|
+
};
|
|
108
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A bordered panel for searching and choosing among a list of actions:
|
|
3
|
+
* {@link Command.Input} holds the query row, {@link Command.List} scrolls
|
|
4
|
+
* through {@link Command.Item} rows, and {@link Command.Empty} holds a
|
|
5
|
+
* message for when nothing matches. Its baseline rendering is a plain, fully
|
|
6
|
+
* visible list of options, styled and ready to compose; the as-you-type
|
|
7
|
+
* filtering and match highlighting a search experience needs arrive through
|
|
8
|
+
* a separate opt-in behavior a consumer attaches.
|
|
9
|
+
*
|
|
10
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
11
|
+
* @copyright Sergio Xalambrí 2026
|
|
12
|
+
*/
|
|
13
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/ui";
|
|
14
|
+
/**
|
|
15
|
+
* Prop types for {@link Command} and its compound parts.
|
|
16
|
+
*/
|
|
17
|
+
export declare namespace Command {
|
|
18
|
+
/**
|
|
19
|
+
* Props accepted by {@link Command}.
|
|
20
|
+
*/
|
|
21
|
+
interface Props extends TagProps<"div"> {
|
|
22
|
+
/** The panel's compound parts: {@link Command.Input}, {@link Command.List}, {@link Command.Empty}. */
|
|
23
|
+
children: RemixNode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Every native `<input>` attribute, unchanged, plus the `mix` passthrough,
|
|
27
|
+
* styling the control itself — a type alias, since the native input prop
|
|
28
|
+
* type resolves through a conditional type only a type alias can express.
|
|
29
|
+
*/
|
|
30
|
+
type InputProps = TagProps<"input">;
|
|
31
|
+
/**
|
|
32
|
+
* Props accepted by {@link Command.List}.
|
|
33
|
+
*/
|
|
34
|
+
interface ListProps extends TagProps<"div"> {
|
|
35
|
+
/** The {@link Command.Item} rows (and, once nothing matches, {@link Command.Empty}) to scroll through. */
|
|
36
|
+
children: RemixNode;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Props accepted by {@link Command.Item}.
|
|
40
|
+
*/
|
|
41
|
+
interface ItemProps extends TagProps<"div"> {
|
|
42
|
+
/**
|
|
43
|
+
* Plain-text value identifying this row's content. A paired filter
|
|
44
|
+
* behavior matches typed text against this value directly, so it stays
|
|
45
|
+
* required even when the visible content is already plain text.
|
|
46
|
+
*/
|
|
47
|
+
value: string;
|
|
48
|
+
/** The row's visible content: a label, and optionally a leading icon or trailing hint. */
|
|
49
|
+
children?: RemixNode;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Props accepted by {@link Command.Empty}.
|
|
53
|
+
*/
|
|
54
|
+
interface EmptyProps extends TagProps<"div"> {
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Renders the panel's root host: a bordered, rounded, elevated `<div>`
|
|
59
|
+
* stacking its compound parts in a column, clipping {@link Command.List}'s
|
|
60
|
+
* scrolled content to the panel's own rounded corners.
|
|
61
|
+
*
|
|
62
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
63
|
+
* @returns The render function producing the panel's markup.
|
|
64
|
+
* @example
|
|
65
|
+
* <Command aria-label={t("command.label")}>
|
|
66
|
+
* <Command.Input aria-label={t("command.label")} placeholder={t("command.placeholder")} />
|
|
67
|
+
* <Command.List>
|
|
68
|
+
* <Command.Item value="new-file">{t("command.newFile")}</Command.Item>
|
|
69
|
+
* <Command.Item value="new-folder">{t("command.newFolder")}</Command.Item>
|
|
70
|
+
* </Command.List>
|
|
71
|
+
* <Command.Empty>{t("command.empty")}</Command.Empty>
|
|
72
|
+
* </Command>
|
|
73
|
+
*/
|
|
74
|
+
export declare function Command(handle: Handle<Command.Props>): () => import("remix/ui").RemixElement;
|
|
75
|
+
export declare namespace Command {
|
|
76
|
+
var Input: (handle: Handle<Command.InputProps>) => () => import("remix/ui").RemixElement;
|
|
77
|
+
var List: (handle: Handle<Command.ListProps>) => () => import("remix/ui").RemixElement;
|
|
78
|
+
var Item: (handle: Handle<Command.ItemProps>) => () => import("remix/ui").RemixElement;
|
|
79
|
+
var Empty: (handle: Handle<Command.EmptyProps>) => () => import("remix/ui").RemixElement;
|
|
80
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, borderEdge, fg, outline, outlineStyle } from "@sdxc/u/color";
|
|
3
|
+
import { opacity, rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor } from "@sdxc/u/general";
|
|
5
|
+
import { hstack, vstack } from "@sdxc/u/layout";
|
|
6
|
+
import { overflow } from "@sdxc/u/overflow";
|
|
7
|
+
import { bs, is, maxBs, p, pb, pi } from "@sdxc/u/size";
|
|
8
|
+
import { when } from "@sdxc/u/state";
|
|
9
|
+
import { text, textAlign } from "@sdxc/u/typography";
|
|
10
|
+
import { attrs } from "remix/ui";
|
|
11
|
+
import { floatingSurface } from "../styles/floating-surface.js";
|
|
12
|
+
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
13
|
+
/** `role="listbox"` applied to {@link Command.List} through {@link attrs} unless a consumer supplies its own `role`. */
|
|
14
|
+
const DEFAULT_LIST_ROLE = "listbox";
|
|
15
|
+
/** `role="option"` applied to {@link Command.Item} through {@link attrs} unless a consumer supplies its own `role`. */
|
|
16
|
+
const DEFAULT_ITEM_ROLE = "option";
|
|
17
|
+
/**
|
|
18
|
+
* Renders the panel's root host: a bordered, rounded, elevated `<div>`
|
|
19
|
+
* stacking its compound parts in a column, clipping {@link Command.List}'s
|
|
20
|
+
* scrolled content to the panel's own rounded corners.
|
|
21
|
+
*
|
|
22
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
23
|
+
* @returns The render function producing the panel's markup.
|
|
24
|
+
* @example
|
|
25
|
+
* <Command aria-label={t("command.label")}>
|
|
26
|
+
* <Command.Input aria-label={t("command.label")} placeholder={t("command.placeholder")} />
|
|
27
|
+
* <Command.List>
|
|
28
|
+
* <Command.Item value="new-file">{t("command.newFile")}</Command.Item>
|
|
29
|
+
* <Command.Item value="new-folder">{t("command.newFolder")}</Command.Item>
|
|
30
|
+
* </Command.List>
|
|
31
|
+
* <Command.Empty>{t("command.empty")}</Command.Empty>
|
|
32
|
+
* </Command>
|
|
33
|
+
*/
|
|
34
|
+
export function Command(handle) {
|
|
35
|
+
return () => {
|
|
36
|
+
let { children, mix, ...rest } = handle.props;
|
|
37
|
+
return (_jsx("div", { ...rest, "data-slot": "command", mix: [floatingSurface(), vstack(), overflow("hidden"), fg("neutral.emphasis"), mix], children: children }));
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Renders the panel's query row: a `<div>` bordered along its block-end
|
|
42
|
+
* edge wrapping a native `<input>` sized to the row's full padding and
|
|
43
|
+
* height, marked `data-command-input` for a paired filter mixin to read.
|
|
44
|
+
*
|
|
45
|
+
* @param handle Runtime handle carrying the host `<input>`'s props.
|
|
46
|
+
* @returns The render function producing the query row's markup.
|
|
47
|
+
* @example
|
|
48
|
+
* <Command.Input aria-label={t("command.label")} placeholder={t("command.placeholder")} />
|
|
49
|
+
* @example
|
|
50
|
+
* <Command.Input aria-label={t("command.label")} value={query} disabled />
|
|
51
|
+
*/
|
|
52
|
+
Command.Input = function CommandInput(handle) {
|
|
53
|
+
return () => {
|
|
54
|
+
let { mix, ...rest } = handle.props;
|
|
55
|
+
return (_jsx("div", { "data-slot": "input-wrapper", mix: borderEdge("block-end", { color: "neutral", width: 1 }), children: _jsx("input", { ...rest, "data-slot": "input", "data-command-input": true, mix: [
|
|
56
|
+
is("full"),
|
|
57
|
+
bs("3.5rem"),
|
|
58
|
+
pi(3),
|
|
59
|
+
fg("neutral.emphasis"),
|
|
60
|
+
when("&::placeholder", fg("neutral.muted")),
|
|
61
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
62
|
+
when("&:disabled", [cursor("not-allowed"), opacity(50)]),
|
|
63
|
+
bg("transparent"),
|
|
64
|
+
text("sm"),
|
|
65
|
+
outlineStyle("none"),
|
|
66
|
+
mix,
|
|
67
|
+
] }) }));
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Renders the panel's scrollable option region: a `<div>` carrying the
|
|
72
|
+
* `listbox` role, capped at a fixed block size, its small inline padding
|
|
73
|
+
* leaving room for a selected {@link Command.Item}'s own rounded corners.
|
|
74
|
+
*
|
|
75
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
76
|
+
* @returns The render function producing the option region's markup.
|
|
77
|
+
* @example
|
|
78
|
+
* <Command.List>
|
|
79
|
+
* <Command.Item value="new-file">{t("command.newFile")}</Command.Item>
|
|
80
|
+
* <Command.Item value="new-folder">{t("command.newFolder")}</Command.Item>
|
|
81
|
+
* </Command.List>
|
|
82
|
+
*/
|
|
83
|
+
Command.List = function CommandList(handle) {
|
|
84
|
+
return () => {
|
|
85
|
+
let { mix, ...rest } = handle.props;
|
|
86
|
+
return (_jsx("div", { ...rest, "data-slot": "list", mix: [
|
|
87
|
+
attrs({ role: DEFAULT_LIST_ROLE }),
|
|
88
|
+
maxBs("18rem"),
|
|
89
|
+
overflow("auto"),
|
|
90
|
+
p(2, 1),
|
|
91
|
+
outlineStyle("none"),
|
|
92
|
+
mix,
|
|
93
|
+
] }));
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Renders a single row: a `<div>` carrying the `option` role, its `value`
|
|
98
|
+
* mirrored onto `data-value` for a paired filter behavior to read. Nest a
|
|
99
|
+
* `<button>` or `<a>` in `children` for native activation.
|
|
100
|
+
*
|
|
101
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
102
|
+
* @returns The render function producing the row's markup.
|
|
103
|
+
* @example
|
|
104
|
+
* <Command.Item value="new-file">{t("command.newFile")}</Command.Item>
|
|
105
|
+
* @example
|
|
106
|
+
* <Command.Item value="archived-project" aria-disabled="true">
|
|
107
|
+
* {t("command.archivedProject")}
|
|
108
|
+
* </Command.Item>
|
|
109
|
+
*/
|
|
110
|
+
Command.Item = function CommandItem(handle) {
|
|
111
|
+
return () => {
|
|
112
|
+
let { value, children, mix, ...rest } = handle.props;
|
|
113
|
+
if (import.meta.env.DEV && !value) {
|
|
114
|
+
console.warn('Command.Item: needs a "value" — a filter behavior matches typed text against this instead of parsing rendered children.');
|
|
115
|
+
}
|
|
116
|
+
return (_jsx("div", { ...rest, "data-slot": "item", "data-value": value, mix: [
|
|
117
|
+
interactiveTransition(),
|
|
118
|
+
attrs({ role: DEFAULT_ITEM_ROLE }),
|
|
119
|
+
hstack({ gap: 2, align: "center" }),
|
|
120
|
+
cursor("default"),
|
|
121
|
+
rounded("md"),
|
|
122
|
+
pi(2),
|
|
123
|
+
pb(2),
|
|
124
|
+
fg("neutral.emphasis"),
|
|
125
|
+
when("&:hover", bg("neutral.bg-tint-hover")),
|
|
126
|
+
when("&:active", bg("neutral.bg-tint-pressed")),
|
|
127
|
+
when("&:focus", bg("brand.tint")),
|
|
128
|
+
when('&[aria-selected="true"]', [bg("brand.solid"), fg("brand.onSolid")]),
|
|
129
|
+
when('&[aria-disabled="true"]', opacity(50)),
|
|
130
|
+
text("sm"),
|
|
131
|
+
outlineStyle("none"),
|
|
132
|
+
mix,
|
|
133
|
+
], children: children }));
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Renders the panel's no-match message: a centered, muted passage of small
|
|
138
|
+
* text filling {@link Command.List}'s content area, carrying a
|
|
139
|
+
* `data-command-empty` marker a paired filter behavior reads to toggle it.
|
|
140
|
+
*
|
|
141
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
142
|
+
* @returns The render function producing the message's markup.
|
|
143
|
+
* @example
|
|
144
|
+
* <Command.Empty>{t("command.empty")}</Command.Empty>
|
|
145
|
+
*/
|
|
146
|
+
Command.Empty = function CommandEmpty(handle) {
|
|
147
|
+
return () => {
|
|
148
|
+
let { mix, ...rest } = handle.props;
|
|
149
|
+
return (_jsx("div", { ...rest, "data-slot": "empty", "data-command-empty": true, mix: [pi(3), pb(6), textAlign("center"), fg("neutral.muted"), text("sm"), mix] }));
|
|
150
|
+
};
|
|
151
|
+
};
|