@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,285 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { ChevronDownIcon } from "@sdxc/icons";
|
|
3
|
+
import { bg, border, borderEdge, fg, outline, outlineStyle, outlineWidth } from "@sdxc/u/color";
|
|
4
|
+
import { opacity, rounded, transition, transitionDuration } from "@sdxc/u/effects";
|
|
5
|
+
import { cursor, raw } from "@sdxc/u/general";
|
|
6
|
+
import { appearance, basis, flex, gap, grow, inlineFlex, items, justify, shrink, } from "@sdxc/u/layout";
|
|
7
|
+
import { media } from "@sdxc/u/responsive";
|
|
8
|
+
import { bs, is, m, p, pb, pi } from "@sdxc/u/size";
|
|
9
|
+
import { data, hover, when } from "@sdxc/u/state";
|
|
10
|
+
import { text, textAlign, truncate } from "@sdxc/u/typography";
|
|
11
|
+
import { attrs } from "remix/ui";
|
|
12
|
+
/** Semantic color role {@link Select} falls back to when `color` is omitted. */
|
|
13
|
+
const DEFAULT_COLOR = "neutral";
|
|
14
|
+
/**
|
|
15
|
+
* `type` {@link Select.Trigger} falls back to when a consumer doesn't supply
|
|
16
|
+
* one, keeping a click on the trigger from submitting a surrounding `<form>`
|
|
17
|
+
* the way a bare `<button>`'s default type otherwise would.
|
|
18
|
+
*/
|
|
19
|
+
const DEFAULT_TRIGGER_TYPE = "button";
|
|
20
|
+
/**
|
|
21
|
+
* `aria-hidden` applied through {@link attrs} to {@link Select.Trigger}'s
|
|
22
|
+
* default chevron glyph unless a consumer overrides it, keeping the
|
|
23
|
+
* decorative icon out of the accessibility tree.
|
|
24
|
+
*/
|
|
25
|
+
const DEFAULT_ICON_ARIA_HIDDEN = "true";
|
|
26
|
+
/**
|
|
27
|
+
* Renders a native `<select>` styled as a bordered, rounded field that
|
|
28
|
+
* progressively upgrades to customizable-select rendering via
|
|
29
|
+
* `appearance: base-select`, falling back to the platform's own dropdown.
|
|
30
|
+
*
|
|
31
|
+
* @param handle Runtime handle carrying the host `<select>`'s props.
|
|
32
|
+
* @returns The render function producing the field's markup.
|
|
33
|
+
* @example
|
|
34
|
+
* <Select aria-label={t("form.country.label")} required>
|
|
35
|
+
* <Select.Option value="">{t("form.country.placeholder")}</Select.Option>
|
|
36
|
+
* <Select.Option value="us">{t("countries.us")}</Select.Option>
|
|
37
|
+
* <Select.Option value="ca">{t("countries.ca")}</Select.Option>
|
|
38
|
+
* </Select>
|
|
39
|
+
* @example
|
|
40
|
+
* <Select aria-label={t("form.plan.label")} color="brand">
|
|
41
|
+
* <Select.Trigger />
|
|
42
|
+
* <Select.Group label={t("form.plan.groups.personal")}>
|
|
43
|
+
* <Select.Option value="free">{t("plans.free")}</Select.Option>
|
|
44
|
+
* <Select.Option value="pro">{t("plans.pro")}</Select.Option>
|
|
45
|
+
* </Select.Group>
|
|
46
|
+
* </Select>
|
|
47
|
+
*/
|
|
48
|
+
export function Select(handle) {
|
|
49
|
+
return () => {
|
|
50
|
+
let { color, multiple, size, mix, ...rest } = handle.props;
|
|
51
|
+
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
52
|
+
if (import.meta.env.DEV && (multiple || (typeof size === "number" && size > 1))) {
|
|
53
|
+
console.warn("Select: `appearance: base-select` styling has no effect on a `multiple` select or one with a `size` greater than 1 — the browser keeps its plain list-box rendering there instead of the customized trigger, value, and option styling.");
|
|
54
|
+
}
|
|
55
|
+
let fieldMix = [
|
|
56
|
+
flex(),
|
|
57
|
+
items("center"),
|
|
58
|
+
justify("between"),
|
|
59
|
+
cursor("default"),
|
|
60
|
+
text("sm"),
|
|
61
|
+
when("&:focus", outline("none")),
|
|
62
|
+
when("&:focus-visible", [
|
|
63
|
+
border("neutral.strong"),
|
|
64
|
+
outline({ color: "neutral.ring", offset: 0 }),
|
|
65
|
+
data("color", "brand", [
|
|
66
|
+
border("brand.strong"),
|
|
67
|
+
outline({ color: "brand.ring", offset: 0 }),
|
|
68
|
+
]),
|
|
69
|
+
data("color", "neutral", [
|
|
70
|
+
border("neutral.strong"),
|
|
71
|
+
outline({ color: "neutral.ring", offset: 0 }),
|
|
72
|
+
]),
|
|
73
|
+
data("color", "success", [
|
|
74
|
+
border("success.strong"),
|
|
75
|
+
outline({ color: "success.ring", offset: 0 }),
|
|
76
|
+
]),
|
|
77
|
+
data("color", "warning", [
|
|
78
|
+
border("warning.strong"),
|
|
79
|
+
outline({ color: "warning.ring", offset: 0 }),
|
|
80
|
+
]),
|
|
81
|
+
data("color", "danger", [
|
|
82
|
+
border("danger.strong"),
|
|
83
|
+
outline({ color: "danger.ring", offset: 0 }),
|
|
84
|
+
]),
|
|
85
|
+
]),
|
|
86
|
+
when('&[aria-invalid="true"], &:user-invalid', [
|
|
87
|
+
outlineWidth("2px"),
|
|
88
|
+
outlineStyle("solid"),
|
|
89
|
+
raw({ outlineOffset: "0px" }),
|
|
90
|
+
]),
|
|
91
|
+
when("&:disabled", [cursor("not-allowed"), opacity(50)]),
|
|
92
|
+
raw({
|
|
93
|
+
"&::picker(select)": {
|
|
94
|
+
margin: "0",
|
|
95
|
+
inset: "auto",
|
|
96
|
+
boxShadow: "0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",
|
|
97
|
+
maxBlockSize: "15rem",
|
|
98
|
+
overflow: "auto",
|
|
99
|
+
padding: "0.25rem",
|
|
100
|
+
outline: "none",
|
|
101
|
+
opacity: "0",
|
|
102
|
+
transitionProperty: "opacity, display, overlay",
|
|
103
|
+
transitionDuration: "150ms",
|
|
104
|
+
transitionBehavior: "allow-discrete",
|
|
105
|
+
"@starting-style": {
|
|
106
|
+
opacity: "0",
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
"&:open": {
|
|
110
|
+
"&::picker(select)": {
|
|
111
|
+
opacity: "1",
|
|
112
|
+
},
|
|
113
|
+
'& [data-slot="icon"]': {
|
|
114
|
+
transform: "rotate(180deg)",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
"&:has(option:checked:disabled)": {
|
|
118
|
+
"& selectedcontent": {
|
|
119
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
"@media (prefers-reduced-motion: reduce)": {
|
|
123
|
+
"&::picker(select)": {
|
|
124
|
+
transitionDuration: "0s",
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
gap("0.5rem"),
|
|
129
|
+
is("full"),
|
|
130
|
+
bs("2.5rem"),
|
|
131
|
+
rounded("md"),
|
|
132
|
+
border({ color: "neutral", width: 1 }),
|
|
133
|
+
bg("neutral.tint"),
|
|
134
|
+
fg("neutral.emphasis"),
|
|
135
|
+
pi("0.75rem"),
|
|
136
|
+
pb("0.5rem"),
|
|
137
|
+
appearance("base-select"),
|
|
138
|
+
transition("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter"),
|
|
139
|
+
hover(border("neutral.strong")),
|
|
140
|
+
when("&:focus", border("neutral.strong")),
|
|
141
|
+
when('&[aria-invalid="true"], &:user-invalid', [
|
|
142
|
+
border("danger.strong"),
|
|
143
|
+
outline({ color: "danger.ring", offset: 0 }),
|
|
144
|
+
]),
|
|
145
|
+
when("&:disabled", bg("neutral.bg-tint-hover")),
|
|
146
|
+
raw({
|
|
147
|
+
"&::picker(select)": {
|
|
148
|
+
borderRadius: "var(--ui-radius-lg, 0.5rem)",
|
|
149
|
+
borderWidth: "1px",
|
|
150
|
+
borderStyle: "solid",
|
|
151
|
+
borderColor: "var(--ui-neutral-border)",
|
|
152
|
+
backgroundColor: "var(--ui-neutral-bg-tint)",
|
|
153
|
+
},
|
|
154
|
+
"&::picker-icon": {
|
|
155
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
156
|
+
},
|
|
157
|
+
}),
|
|
158
|
+
mix,
|
|
159
|
+
];
|
|
160
|
+
return (_jsx("select", { multiple: multiple, size: size, "data-color": resolvedColor, ...rest, mix: fieldMix }));
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Renders {@link Select}'s customizable trigger: a native `<button>` placed
|
|
165
|
+
* as {@link Select}'s first child, showing {@link Select.Value} and a
|
|
166
|
+
* rotating chevron by default, filling the field's box edge to edge.
|
|
167
|
+
*
|
|
168
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
169
|
+
* @returns The render function producing the trigger's markup.
|
|
170
|
+
* @example
|
|
171
|
+
* <Select.Trigger />
|
|
172
|
+
* @example
|
|
173
|
+
* <Select.Trigger>
|
|
174
|
+
* <Select.Value>{t("form.plan.placeholder")}</Select.Value>
|
|
175
|
+
* </Select.Trigger>
|
|
176
|
+
*/
|
|
177
|
+
Select.Trigger = function SelectTrigger(handle) {
|
|
178
|
+
return () => {
|
|
179
|
+
let { type, children, mix, ...rest } = handle.props;
|
|
180
|
+
return (_jsx("button", { type: type ?? DEFAULT_TRIGGER_TYPE, ...rest, mix: [
|
|
181
|
+
flex(),
|
|
182
|
+
items("center"),
|
|
183
|
+
justify("between"),
|
|
184
|
+
gap("0.5rem"),
|
|
185
|
+
is("full"),
|
|
186
|
+
bs("full"),
|
|
187
|
+
m(0),
|
|
188
|
+
p(0),
|
|
189
|
+
border({ width: 0, style: "none" }),
|
|
190
|
+
bg("transparent"),
|
|
191
|
+
fg("inherit"),
|
|
192
|
+
raw({ font: "inherit" }),
|
|
193
|
+
textAlign("start"),
|
|
194
|
+
cursor("inherit"),
|
|
195
|
+
mix,
|
|
196
|
+
], children: children ?? (_jsxs(_Fragment, { children: [_jsx(Select.Value, {}), _jsx("span", { "data-slot": "icon", mix: [
|
|
197
|
+
attrs({ "aria-hidden": DEFAULT_ICON_ARIA_HIDDEN }),
|
|
198
|
+
inlineFlex(),
|
|
199
|
+
shrink(),
|
|
200
|
+
transition("transform"),
|
|
201
|
+
when("& svg", [is("1rem"), bs("1rem")]),
|
|
202
|
+
media("(prefers-reduced-motion: reduce)", transitionDuration("0s")),
|
|
203
|
+
fg("neutral.muted"),
|
|
204
|
+
], children: _jsx(ChevronDownIcon, {}) })] })) }));
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Renders a native `<selectedcontent>` element inside {@link Select.Trigger},
|
|
209
|
+
* mirroring the currently selected {@link Select.Option}'s content via the
|
|
210
|
+
* platform; `children` render as a fallback where it's treated as unknown.
|
|
211
|
+
*
|
|
212
|
+
* @param handle Runtime handle carrying the host element's props.
|
|
213
|
+
* @returns The render function producing the value slot's markup.
|
|
214
|
+
* @example
|
|
215
|
+
* <Select.Value />
|
|
216
|
+
* @example
|
|
217
|
+
* <Select.Value>{t("form.plan.placeholder")}</Select.Value>
|
|
218
|
+
*/
|
|
219
|
+
Select.Value = function SelectValue(handle) {
|
|
220
|
+
return () => {
|
|
221
|
+
let { mix, ...rest } = handle.props;
|
|
222
|
+
return (_jsx("selectedcontent", { ...rest, mix: [grow(), shrink(1), basis("0%"), truncate(), textAlign("start"), mix] }));
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Renders a native `<option>` styled for the rounded, padded row a
|
|
227
|
+
* supporting browser shows inside {@link Select}'s `::picker(select)`
|
|
228
|
+
* dropdown, reading its own hover, focus, checked, and disabled states.
|
|
229
|
+
*
|
|
230
|
+
* @param handle Runtime handle carrying the host `<option>`'s props.
|
|
231
|
+
* @returns The render function producing the option's markup.
|
|
232
|
+
* @example
|
|
233
|
+
* <Select.Option value="us">{t("countries.us")}</Select.Option>
|
|
234
|
+
* @example
|
|
235
|
+
* <Select.Option value="" disabled>{t("form.country.placeholder")}</Select.Option>
|
|
236
|
+
*/
|
|
237
|
+
Select.Option = function SelectOption(handle) {
|
|
238
|
+
return () => {
|
|
239
|
+
let { mix, ...rest } = handle.props;
|
|
240
|
+
return (_jsx("option", { ...rest, mix: [
|
|
241
|
+
cursor("default"),
|
|
242
|
+
pi("0.75rem"),
|
|
243
|
+
pb("0.5rem"),
|
|
244
|
+
text("sm"),
|
|
245
|
+
outline("none"),
|
|
246
|
+
when("&:disabled", opacity(50)),
|
|
247
|
+
when("&::checkmark", fg("currentColor")),
|
|
248
|
+
rounded("md"),
|
|
249
|
+
fg("neutral.emphasis"),
|
|
250
|
+
transition("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke"),
|
|
251
|
+
when("&:hover", bg("neutral.bg-tint-hover")),
|
|
252
|
+
when("&:active", bg("neutral.bg-tint-pressed")),
|
|
253
|
+
when("&:focus", bg("brand.tint")),
|
|
254
|
+
when("&:checked", [bg("brand.solid"), fg("brand.onSolid")]),
|
|
255
|
+
mix,
|
|
256
|
+
] }));
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* Renders a native `<optgroup>` styled as a padded run of
|
|
261
|
+
* {@link Select.Option}s, set off from the group before it by a
|
|
262
|
+
* block-start divider on every group after the first.
|
|
263
|
+
*
|
|
264
|
+
* @param handle Runtime handle carrying the host `<optgroup>`'s props.
|
|
265
|
+
* @returns The render function producing the group's markup.
|
|
266
|
+
* @example
|
|
267
|
+
* <Select.Group label={t("form.plan.groups.personal")}>
|
|
268
|
+
* <Select.Option value="free">{t("plans.free")}</Select.Option>
|
|
269
|
+
* <Select.Option value="pro">{t("plans.pro")}</Select.Option>
|
|
270
|
+
* </Select.Group>
|
|
271
|
+
*/
|
|
272
|
+
Select.Group = function SelectGroup(handle) {
|
|
273
|
+
return () => {
|
|
274
|
+
let { mix, ...rest } = handle.props;
|
|
275
|
+
if (import.meta.env.DEV && !rest.label) {
|
|
276
|
+
console.warn("Select.Group: an `optgroup` with no `label` renders with no visible heading for its options — pass a `label` describing the group.");
|
|
277
|
+
}
|
|
278
|
+
return (_jsx("optgroup", { ...rest, mix: [
|
|
279
|
+
when("&:not(:first-child)", borderEdge("block-start", { width: 1 })),
|
|
280
|
+
pb("0.25rem"),
|
|
281
|
+
when("&:not(:first-child)", border("neutral")),
|
|
282
|
+
mix,
|
|
283
|
+
] }));
|
|
284
|
+
};
|
|
285
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small marker that stays invisible, while still reserving its own layout
|
|
3
|
+
* slot, until the element carrying it is the current selection. Anchors a
|
|
4
|
+
* menu or listbox option's checkmark, a tab strip's active-tab underline, or
|
|
5
|
+
* any similar per-item selection cue to a fixed spot so neighboring content
|
|
6
|
+
* never reflows between the selected and unselected states.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
12
|
+
/**
|
|
13
|
+
* Prop types for {@link SelectionIndicator}.
|
|
14
|
+
*/
|
|
15
|
+
export declare namespace SelectionIndicator {
|
|
16
|
+
/**
|
|
17
|
+
* Every native `<div>` attribute, plus the `mix` passthrough. Selection
|
|
18
|
+
* state reads directly from `aria-selected`/`aria-current` already set on
|
|
19
|
+
* the host, so there is no separate boolean prop to duplicate it.
|
|
20
|
+
*/
|
|
21
|
+
interface Props extends TagProps<"div"> {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Renders a marker that stays present in the layout at all times but only
|
|
26
|
+
* becomes visible once its host carries `aria-selected="true"` or a truthy
|
|
27
|
+
* `aria-current`, so sibling content never reflows on selection change.
|
|
28
|
+
*
|
|
29
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
30
|
+
* @returns The render function producing the indicator's markup.
|
|
31
|
+
* @example
|
|
32
|
+
* <Menu.Item aria-selected={isChecked}>
|
|
33
|
+
* <SelectionIndicator aria-selected={isChecked}>
|
|
34
|
+
* <CheckIcon />
|
|
35
|
+
* </SelectionIndicator>
|
|
36
|
+
* <Text slot="label">{t("menu.autosave")}</Text>
|
|
37
|
+
* </Menu.Item>
|
|
38
|
+
* @example
|
|
39
|
+
* <Tabs.Trigger id="billing" aria-selected={activeTab === "billing"}>
|
|
40
|
+
* {t("settings.tabs.billing")}
|
|
41
|
+
* <SelectionIndicator
|
|
42
|
+
* aria-selected={activeTab === "billing"}
|
|
43
|
+
* mix={css({ position: "absolute", insetBlockEnd: "0", insetInline: "0", blockSize: "2px" })}
|
|
44
|
+
* />
|
|
45
|
+
* </Tabs.Trigger>
|
|
46
|
+
*/
|
|
47
|
+
export declare function SelectionIndicator(handle: Handle<SelectionIndicator.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { fg } from "@sdxc/u/color";
|
|
3
|
+
import { visibility } from "@sdxc/u/effects";
|
|
4
|
+
import { bs, is } from "@sdxc/u/size";
|
|
5
|
+
import { when } from "@sdxc/u/state";
|
|
6
|
+
import { attrs } from "remix/ui";
|
|
7
|
+
/**
|
|
8
|
+
* `aria-hidden="true"` applied through {@link attrs} unless a consumer
|
|
9
|
+
* overrides it. The indicator restates a selection state already exposed
|
|
10
|
+
* via `aria-selected`/`aria-current`, so assistive technology gains nothing.
|
|
11
|
+
*/
|
|
12
|
+
const DEFAULT_ARIA_HIDDEN = "true";
|
|
13
|
+
/**
|
|
14
|
+
* Renders a marker that stays present in the layout at all times but only
|
|
15
|
+
* becomes visible once its host carries `aria-selected="true"` or a truthy
|
|
16
|
+
* `aria-current`, so sibling content never reflows on selection change.
|
|
17
|
+
*
|
|
18
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
19
|
+
* @returns The render function producing the indicator's markup.
|
|
20
|
+
* @example
|
|
21
|
+
* <Menu.Item aria-selected={isChecked}>
|
|
22
|
+
* <SelectionIndicator aria-selected={isChecked}>
|
|
23
|
+
* <CheckIcon />
|
|
24
|
+
* </SelectionIndicator>
|
|
25
|
+
* <Text slot="label">{t("menu.autosave")}</Text>
|
|
26
|
+
* </Menu.Item>
|
|
27
|
+
* @example
|
|
28
|
+
* <Tabs.Trigger id="billing" aria-selected={activeTab === "billing"}>
|
|
29
|
+
* {t("settings.tabs.billing")}
|
|
30
|
+
* <SelectionIndicator
|
|
31
|
+
* aria-selected={activeTab === "billing"}
|
|
32
|
+
* mix={css({ position: "absolute", insetBlockEnd: "0", insetInline: "0", blockSize: "2px" })}
|
|
33
|
+
* />
|
|
34
|
+
* </Tabs.Trigger>
|
|
35
|
+
*/
|
|
36
|
+
export function SelectionIndicator(handle) {
|
|
37
|
+
return () => {
|
|
38
|
+
let { mix, ...rest } = handle.props;
|
|
39
|
+
return (_jsx("div", { ...rest, mix: [
|
|
40
|
+
attrs({ "aria-hidden": DEFAULT_ARIA_HIDDEN }),
|
|
41
|
+
is("var(--ui-selection-indicator-size, 1rem)"),
|
|
42
|
+
bs("var(--ui-selection-indicator-size, 1rem)"),
|
|
43
|
+
fg("currentColor"),
|
|
44
|
+
visibility("hidden"),
|
|
45
|
+
when('&[aria-selected="true"]', visibility()),
|
|
46
|
+
when('&[aria-current]:not([aria-current="false"])', visibility()),
|
|
47
|
+
mix,
|
|
48
|
+
] }));
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A decorative sentinel row shared by every list-shaped compound component
|
|
3
|
+
* that renders a trailing loading placeholder: a `<div>` styled as centered,
|
|
4
|
+
* muted small text, sized to match its enclosing list's own row rhythm.
|
|
5
|
+
* Every trailing-row part across these compound components assigns this
|
|
6
|
+
* same implementation, keeping the markup, styling, and behavior identical.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
12
|
+
/**
|
|
13
|
+
* Renders a decorative sentinel row: a `<div>` styled as centered, muted
|
|
14
|
+
* small text, ready to hold whatever loading indicator or "load more"
|
|
15
|
+
* trigger a paired enhancement supplies as `children`.
|
|
16
|
+
*
|
|
17
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
18
|
+
* @returns The render function producing the sentinel row's markup.
|
|
19
|
+
* @example
|
|
20
|
+
* <ListBox.LoadMoreItem>{t("list.loadingMore")}</ListBox.LoadMoreItem>
|
|
21
|
+
*/
|
|
22
|
+
export declare function SentinelRow(handle: Handle<TagProps<"div">>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { fg } from "@sdxc/u/color";
|
|
3
|
+
import { flex, items, justify } from "@sdxc/u/layout";
|
|
4
|
+
import { pb } from "@sdxc/u/size";
|
|
5
|
+
import { text } from "@sdxc/u/typography";
|
|
6
|
+
/**
|
|
7
|
+
* Renders a decorative sentinel row: a `<div>` styled as centered, muted
|
|
8
|
+
* small text, ready to hold whatever loading indicator or "load more"
|
|
9
|
+
* trigger a paired enhancement supplies as `children`.
|
|
10
|
+
*
|
|
11
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
12
|
+
* @returns The render function producing the sentinel row's markup.
|
|
13
|
+
* @example
|
|
14
|
+
* <ListBox.LoadMoreItem>{t("list.loadingMore")}</ListBox.LoadMoreItem>
|
|
15
|
+
*/
|
|
16
|
+
export function SentinelRow(handle) {
|
|
17
|
+
return () => {
|
|
18
|
+
let { mix, ...rest } = handle.props;
|
|
19
|
+
return (_jsx("div", { ...rest, mix: [
|
|
20
|
+
flex(),
|
|
21
|
+
items("center"),
|
|
22
|
+
justify("center"),
|
|
23
|
+
text("sm"),
|
|
24
|
+
pb("0.5rem"),
|
|
25
|
+
fg("neutral.muted"),
|
|
26
|
+
mix,
|
|
27
|
+
] }));
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A thin visual divider marking a boundary between two groups of content —
|
|
3
|
+
* a menu's sections, a toolbar's clusters, a page's regions. It renders as
|
|
4
|
+
* a single hairline element whose axis and length come from the semantic
|
|
5
|
+
* border color and the orientation it carries.
|
|
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
|
+
* Props accepted by {@link Separator}.
|
|
13
|
+
*/
|
|
14
|
+
export declare namespace Separator {
|
|
15
|
+
/**
|
|
16
|
+
* Every native `<div>` attribute, unchanged, plus the `mix` passthrough.
|
|
17
|
+
* Setting `aria-orientation="vertical"` switches both the accessibility
|
|
18
|
+
* contract and the rendered axis to a vertical divider.
|
|
19
|
+
*/
|
|
20
|
+
interface Props extends TagProps<"div"> {
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Renders a static hairline divider between two groups of content, carrying
|
|
25
|
+
* the `separator` role and defaulting to a full-width horizontal line;
|
|
26
|
+
* setting `aria-orientation="vertical"` flips it to a full-height vertical line.
|
|
27
|
+
*
|
|
28
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
29
|
+
* @returns The render function producing the divider's markup.
|
|
30
|
+
* @example
|
|
31
|
+
* <Separator />
|
|
32
|
+
* @example
|
|
33
|
+
* <Separator aria-orientation="vertical" />
|
|
34
|
+
*/
|
|
35
|
+
export declare function Separator(handle: Handle<Separator.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg } from "@sdxc/u/color";
|
|
3
|
+
import { bs, is, minBs } from "@sdxc/u/size";
|
|
4
|
+
import { when } from "@sdxc/u/state";
|
|
5
|
+
import { attrs } from "remix/ui";
|
|
6
|
+
/**
|
|
7
|
+
* ARIA role applied through {@link attrs} so the host `<div>` is announced
|
|
8
|
+
* as a divider between content groups without requiring the consumer to
|
|
9
|
+
* repeat it on every instance.
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_ROLE = "separator";
|
|
12
|
+
/**
|
|
13
|
+
* Default `aria-orientation` value applied through {@link attrs}. Keeping
|
|
14
|
+
* the accessibility attribute and the CSS variant selector on the same
|
|
15
|
+
* value lets a consumer flip the axis by setting `aria-orientation="vertical"`.
|
|
16
|
+
*/
|
|
17
|
+
const DEFAULT_ORIENTATION = "horizontal";
|
|
18
|
+
/**
|
|
19
|
+
* Renders a static hairline divider between two groups of content, carrying
|
|
20
|
+
* the `separator` role and defaulting to a full-width horizontal line;
|
|
21
|
+
* setting `aria-orientation="vertical"` flips it to a full-height vertical line.
|
|
22
|
+
*
|
|
23
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
24
|
+
* @returns The render function producing the divider's markup.
|
|
25
|
+
* @example
|
|
26
|
+
* <Separator />
|
|
27
|
+
* @example
|
|
28
|
+
* <Separator aria-orientation="vertical" />
|
|
29
|
+
*/
|
|
30
|
+
export function Separator(handle) {
|
|
31
|
+
return () => {
|
|
32
|
+
let { mix, ...rest } = handle.props;
|
|
33
|
+
return (_jsx("div", { ...rest, mix: [
|
|
34
|
+
attrs({ role: DEFAULT_ROLE, "aria-orientation": DEFAULT_ORIENTATION }),
|
|
35
|
+
when('&[aria-orientation="horizontal"]', [
|
|
36
|
+
bs("var(--ui-separator-thickness, 1px)"),
|
|
37
|
+
is("100%"),
|
|
38
|
+
]),
|
|
39
|
+
when('&[aria-orientation="vertical"]', [
|
|
40
|
+
bs("100%"),
|
|
41
|
+
minBs("var(--ui-separator-min-size, 1rem)"),
|
|
42
|
+
is("var(--ui-separator-thickness, 1px)"),
|
|
43
|
+
]),
|
|
44
|
+
bg("neutral.border"),
|
|
45
|
+
mix,
|
|
46
|
+
] }));
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plain host that carries a stable view-transition identity across
|
|
3
|
+
* separate page loads, so a same-origin, cross-document navigation morphs it
|
|
4
|
+
* from its old position, size, and appearance into its new one instead of
|
|
5
|
+
* replacing it outright. Its identity comes straight from its own `id`,
|
|
6
|
+
* matched against the same `id` on the corresponding element in the document
|
|
7
|
+
* being navigated to or from — no script, snapshotting, or scope wrapper
|
|
8
|
+
* required for this baseline.
|
|
9
|
+
*
|
|
10
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
11
|
+
* @copyright Sergio Xalambrí 2026
|
|
12
|
+
*/
|
|
13
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
14
|
+
/**
|
|
15
|
+
* Prop types for {@link SharedElement}.
|
|
16
|
+
*/
|
|
17
|
+
export declare namespace SharedElement {
|
|
18
|
+
/**
|
|
19
|
+
* Props accepted by {@link SharedElement}: every native `<div>` attribute
|
|
20
|
+
* plus the `mix` passthrough. `id` doubles as the view transition identity,
|
|
21
|
+
* matched against the same `id` in the document navigated to or from.
|
|
22
|
+
*/
|
|
23
|
+
interface Props extends TagProps<"div"> {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Renders a plain `<div>` host whose `view-transition-name` comes from its
|
|
28
|
+
* own `id`, so a same-origin, cross-document navigation matching that `id`
|
|
29
|
+
* on the other side morphs the element instead of replacing it outright.
|
|
30
|
+
*
|
|
31
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
32
|
+
* @returns The render function producing the host's markup.
|
|
33
|
+
* @example
|
|
34
|
+
* // On the listing page
|
|
35
|
+
* <SharedElement id={`cover-${book.slug}`}>
|
|
36
|
+
* <img src={book.coverUrl} alt={book.title} />
|
|
37
|
+
* </SharedElement>
|
|
38
|
+
* @example
|
|
39
|
+
* // On the book's own page — the matching `id` lets the browser morph
|
|
40
|
+
* // between the two instead of swapping the image outright.
|
|
41
|
+
* <SharedElement id={`cover-${book.slug}`}>
|
|
42
|
+
* <img src={book.coverUrl} alt={book.title} />
|
|
43
|
+
* </SharedElement>
|
|
44
|
+
*/
|
|
45
|
+
export declare function SharedElement(handle: Handle<SharedElement.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { block } from "@sdxc/u/layout";
|
|
3
|
+
import { mergeStyle } from "../utils/merge-style.js";
|
|
4
|
+
/**
|
|
5
|
+
* Written as plain CSS text inside a `<style>` element: `@view-transition`
|
|
6
|
+
* accepts only descriptors, and `::view-transition-group(*)` selects from
|
|
7
|
+
* the browser's own transition tree, both needing selectors written directly in CSS.
|
|
8
|
+
*/
|
|
9
|
+
const CROSS_DOCUMENT_TRANSITION_STYLESHEET = `
|
|
10
|
+
@view-transition {
|
|
11
|
+
navigation: auto;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@media (prefers-reduced-motion: reduce) {
|
|
15
|
+
::view-transition-group(*) {
|
|
16
|
+
animation: none;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
/**
|
|
21
|
+
* Renders a plain `<div>` host whose `view-transition-name` comes from its
|
|
22
|
+
* own `id`, so a same-origin, cross-document navigation matching that `id`
|
|
23
|
+
* on the other side morphs the element instead of replacing it outright.
|
|
24
|
+
*
|
|
25
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
26
|
+
* @returns The render function producing the host's markup.
|
|
27
|
+
* @example
|
|
28
|
+
* // On the listing page
|
|
29
|
+
* <SharedElement id={`cover-${book.slug}`}>
|
|
30
|
+
* <img src={book.coverUrl} alt={book.title} />
|
|
31
|
+
* </SharedElement>
|
|
32
|
+
* @example
|
|
33
|
+
* // On the book's own page — the matching `id` lets the browser morph
|
|
34
|
+
* // between the two instead of swapping the image outright.
|
|
35
|
+
* <SharedElement id={`cover-${book.slug}`}>
|
|
36
|
+
* <img src={book.coverUrl} alt={book.title} />
|
|
37
|
+
* </SharedElement>
|
|
38
|
+
*/
|
|
39
|
+
export function SharedElement(handle) {
|
|
40
|
+
return () => {
|
|
41
|
+
let { id, mix, style, ...rest } = handle.props;
|
|
42
|
+
if (import.meta.env.DEV && !id) {
|
|
43
|
+
console.warn('SharedElement rendered without an "id" — the browser has nothing to match it against on the other side of a cross-document view transition.');
|
|
44
|
+
}
|
|
45
|
+
let resolvedStyle = mergeStyle(style, { "view-transition-name": id });
|
|
46
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", { children: CROSS_DOCUMENT_TRANSITION_STYLESHEET }), _jsx("div", { ...rest, id: id, style: resolvedStyle, mix: [block(), mix] })] }));
|
|
47
|
+
};
|
|
48
|
+
}
|