@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,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A navigation action styled to read as a button rather than inline text —
|
|
3
|
+
* "View project", "Download", a dialog's "Cancel" that also navigates away.
|
|
4
|
+
* Its host renders as a native `<a>`, sharing {@link Button}'s semantic
|
|
5
|
+
* color role, visual weight variant, and size so a link and a button placed
|
|
6
|
+
* side by side render pixel-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
|
+
import type { SemanticColor } from "../utils/semantic-color.js";
|
|
13
|
+
/**
|
|
14
|
+
* Prop types for {@link LinkButton}.
|
|
15
|
+
*/
|
|
16
|
+
export declare namespace LinkButton {
|
|
17
|
+
/**
|
|
18
|
+
* Semantic color role, each mapped to its matching `--ui-*` variables.
|
|
19
|
+
*/
|
|
20
|
+
type Color = SemanticColor;
|
|
21
|
+
/**
|
|
22
|
+
* Visual weight the link renders with: a solid fill with an on-solid
|
|
23
|
+
* foreground, a transparent fill with a strong colored border, or a fully
|
|
24
|
+
* transparent fill with just a colored label.
|
|
25
|
+
*/
|
|
26
|
+
type Variant = "solid" | "outline" | "ghost";
|
|
27
|
+
/**
|
|
28
|
+
* Size variant controlling the link's padding and font size.
|
|
29
|
+
*/
|
|
30
|
+
type Size = "sm" | "md" | "lg";
|
|
31
|
+
/**
|
|
32
|
+
* Props accepted by {@link LinkButton}. A type alias rather than an
|
|
33
|
+
* interface, since the native anchor props resolve to an intersection
|
|
34
|
+
* type that TypeScript can't use in an `extends` clause.
|
|
35
|
+
*/
|
|
36
|
+
type Props = TagProps<"a"> & {
|
|
37
|
+
/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */
|
|
38
|
+
color?: Color;
|
|
39
|
+
/** Visual weight. Defaults to {@link DEFAULT_VARIANT}. */
|
|
40
|
+
variant?: Variant;
|
|
41
|
+
/** Size variant. Defaults to {@link DEFAULT_SIZE}. */
|
|
42
|
+
size?: Size;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Renders a native `<a>` host, colored and shaped through the same color,
|
|
47
|
+
* variant, and size data attributes as {@link Button}. `aria-disabled="true"`
|
|
48
|
+
* keeps it focusable while dimmed, so drop `href` too for full inertness.
|
|
49
|
+
*
|
|
50
|
+
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
51
|
+
* @returns The render function producing the link's markup.
|
|
52
|
+
* @example
|
|
53
|
+
* <LinkButton href="/projects/new">{t("actions.createProject")}</LinkButton>
|
|
54
|
+
* @example
|
|
55
|
+
* <LinkButton href="/projects" color="neutral" variant="outline" size="sm">{t("actions.cancel")}</LinkButton>
|
|
56
|
+
* @example
|
|
57
|
+
* <LinkButton href="/export/report.csv" download aria-disabled={!hasReport || undefined}>{t("actions.download")}</LinkButton>
|
|
58
|
+
*/
|
|
59
|
+
export declare function LinkButton(handle: Handle<LinkButton.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, border, fg, outline } from "@sdxc/u/color";
|
|
3
|
+
import { opacity, rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor, pointerEvents, userSelect } from "@sdxc/u/general";
|
|
5
|
+
import { gap, inlineFlex, items, justify, shrink } from "@sdxc/u/layout";
|
|
6
|
+
import { pb, pi } from "@sdxc/u/size";
|
|
7
|
+
import { active, data, hover, when } from "@sdxc/u/state";
|
|
8
|
+
import { text, weight } from "@sdxc/u/typography";
|
|
9
|
+
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
10
|
+
/** Semantic color role {@link LinkButton} falls back to when `color` is omitted. */
|
|
11
|
+
const DEFAULT_COLOR = "neutral";
|
|
12
|
+
/** Visual weight {@link LinkButton} falls back to when `variant` is omitted. */
|
|
13
|
+
const DEFAULT_VARIANT = "solid";
|
|
14
|
+
/** Size variant {@link LinkButton} falls back to when `size` is omitted. */
|
|
15
|
+
const DEFAULT_SIZE = "md";
|
|
16
|
+
/**
|
|
17
|
+
* Renders a native `<a>` host, colored and shaped through the same color,
|
|
18
|
+
* variant, and size data attributes as {@link Button}. `aria-disabled="true"`
|
|
19
|
+
* keeps it focusable while dimmed, so drop `href` too for full inertness.
|
|
20
|
+
*
|
|
21
|
+
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
22
|
+
* @returns The render function producing the link's markup.
|
|
23
|
+
* @example
|
|
24
|
+
* <LinkButton href="/projects/new">{t("actions.createProject")}</LinkButton>
|
|
25
|
+
* @example
|
|
26
|
+
* <LinkButton href="/projects" color="neutral" variant="outline" size="sm">{t("actions.cancel")}</LinkButton>
|
|
27
|
+
* @example
|
|
28
|
+
* <LinkButton href="/export/report.csv" download aria-disabled={!hasReport || undefined}>{t("actions.download")}</LinkButton>
|
|
29
|
+
*/
|
|
30
|
+
export function LinkButton(handle) {
|
|
31
|
+
return () => {
|
|
32
|
+
let { color, variant, size, mix, ...rest } = handle.props;
|
|
33
|
+
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
34
|
+
let resolvedVariant = variant ?? DEFAULT_VARIANT;
|
|
35
|
+
let resolvedSize = size ?? DEFAULT_SIZE;
|
|
36
|
+
return (_jsx("a", { ...rest, "data-color": resolvedColor, "data-variant": resolvedVariant, "data-size": resolvedSize, mix: [
|
|
37
|
+
when("&:focus-visible", [
|
|
38
|
+
outline({ color: "brand.ring", offset: 2 }),
|
|
39
|
+
data("color", "neutral", outline("neutral.ring")),
|
|
40
|
+
data("color", "success", outline("success.ring")),
|
|
41
|
+
data("color", "warning", outline("warning.ring")),
|
|
42
|
+
data("color", "danger", outline("danger.ring")),
|
|
43
|
+
]),
|
|
44
|
+
interactiveTransition(),
|
|
45
|
+
inlineFlex(),
|
|
46
|
+
items("center"),
|
|
47
|
+
justify("center"),
|
|
48
|
+
gap(2),
|
|
49
|
+
/**
|
|
50
|
+
* An icon inside a link button never shrinks — the same rule `Button` states, for the
|
|
51
|
+
* same reason: squeeze the row and the default `flex-shrink: 1` compresses the glyph
|
|
52
|
+
* rather than the words, and a squashed icon reads as a rendering fault.
|
|
53
|
+
*/
|
|
54
|
+
when("& > svg", shrink()),
|
|
55
|
+
rounded("md"),
|
|
56
|
+
weight("medium"),
|
|
57
|
+
pi(4),
|
|
58
|
+
pb(2),
|
|
59
|
+
/**
|
|
60
|
+
* Every variant carries the same border width, colored to match its
|
|
61
|
+
* own fill (transparent for ghost), so solid, outline, and ghost
|
|
62
|
+
* render at the same footprint.
|
|
63
|
+
*/
|
|
64
|
+
border({ width: 2 }),
|
|
65
|
+
data("size", "sm", [pi(3), pb(1.5)]),
|
|
66
|
+
data("size", "lg", [pi(5), pb(2.5), text("base")]),
|
|
67
|
+
data("variant", "solid", [
|
|
68
|
+
data("color", "brand", [
|
|
69
|
+
bg("brand.solid"),
|
|
70
|
+
border("brand.solid"),
|
|
71
|
+
fg("brand.onSolid"),
|
|
72
|
+
hover([bg("brand.bg-solid-hover"), border("brand.bg-solid-hover")]),
|
|
73
|
+
active([bg("brand.bg-solid-pressed"), border("brand.bg-solid-pressed")]),
|
|
74
|
+
]),
|
|
75
|
+
data("color", "neutral", [
|
|
76
|
+
bg("neutral.solid"),
|
|
77
|
+
border("neutral.solid"),
|
|
78
|
+
fg("neutral.onSolid"),
|
|
79
|
+
hover([bg("neutral.bg-solid-hover"), border("neutral.bg-solid-hover")]),
|
|
80
|
+
active([bg("neutral.bg-solid-pressed"), border("neutral.bg-solid-pressed")]),
|
|
81
|
+
]),
|
|
82
|
+
data("color", "success", [
|
|
83
|
+
bg("success.solid"),
|
|
84
|
+
border("success.solid"),
|
|
85
|
+
fg("success.onSolid"),
|
|
86
|
+
hover([bg("success.bg-solid-hover"), border("success.bg-solid-hover")]),
|
|
87
|
+
active([bg("success.bg-solid-pressed"), border("success.bg-solid-pressed")]),
|
|
88
|
+
]),
|
|
89
|
+
data("color", "warning", [
|
|
90
|
+
bg("warning.solid"),
|
|
91
|
+
border("warning.solid"),
|
|
92
|
+
fg("warning.onSolid"),
|
|
93
|
+
hover([bg("warning.bg-solid-hover"), border("warning.bg-solid-hover")]),
|
|
94
|
+
active([bg("warning.bg-solid-pressed"), border("warning.bg-solid-pressed")]),
|
|
95
|
+
]),
|
|
96
|
+
data("color", "danger", [
|
|
97
|
+
bg("danger.solid"),
|
|
98
|
+
border("danger.solid"),
|
|
99
|
+
fg("danger.onSolid"),
|
|
100
|
+
hover([bg("danger.bg-solid-hover"), border("danger.bg-solid-hover")]),
|
|
101
|
+
active([bg("danger.bg-solid-pressed"), border("danger.bg-solid-pressed")]),
|
|
102
|
+
]),
|
|
103
|
+
]),
|
|
104
|
+
data("variant", "outline", [
|
|
105
|
+
data("color", "brand", [
|
|
106
|
+
border("brand.strong"),
|
|
107
|
+
fg("brand"),
|
|
108
|
+
hover(bg("brand.tint")),
|
|
109
|
+
active(bg("brand.bg-tint-hover")),
|
|
110
|
+
]),
|
|
111
|
+
data("color", "neutral", [
|
|
112
|
+
border("neutral.strong"),
|
|
113
|
+
fg("neutral"),
|
|
114
|
+
hover(bg("neutral.tint")),
|
|
115
|
+
active(bg("neutral.bg-tint-hover")),
|
|
116
|
+
]),
|
|
117
|
+
data("color", "success", [
|
|
118
|
+
border("success.strong"),
|
|
119
|
+
fg("success"),
|
|
120
|
+
hover(bg("success.tint")),
|
|
121
|
+
active(bg("success.bg-tint-hover")),
|
|
122
|
+
]),
|
|
123
|
+
data("color", "warning", [
|
|
124
|
+
border("warning.strong"),
|
|
125
|
+
fg("warning"),
|
|
126
|
+
hover(bg("warning.tint")),
|
|
127
|
+
active(bg("warning.bg-tint-hover")),
|
|
128
|
+
]),
|
|
129
|
+
data("color", "danger", [
|
|
130
|
+
border("danger.strong"),
|
|
131
|
+
fg("danger"),
|
|
132
|
+
hover(bg("danger.tint")),
|
|
133
|
+
active(bg("danger.bg-tint-hover")),
|
|
134
|
+
]),
|
|
135
|
+
]),
|
|
136
|
+
data("variant", "outline", bg("transparent")),
|
|
137
|
+
data("variant", "ghost", [
|
|
138
|
+
data("color", "brand", [
|
|
139
|
+
fg("brand"),
|
|
140
|
+
hover(bg("brand.tint")),
|
|
141
|
+
active(bg("brand.bg-tint-hover")),
|
|
142
|
+
]),
|
|
143
|
+
data("color", "neutral", [
|
|
144
|
+
fg("neutral"),
|
|
145
|
+
hover(bg("neutral.bg-tint-hover")),
|
|
146
|
+
active(bg("neutral.bg-tint-pressed")),
|
|
147
|
+
]),
|
|
148
|
+
data("color", "success", [
|
|
149
|
+
fg("success"),
|
|
150
|
+
hover(bg("success.tint")),
|
|
151
|
+
active(bg("success.bg-tint-hover")),
|
|
152
|
+
]),
|
|
153
|
+
data("color", "warning", [
|
|
154
|
+
fg("warning"),
|
|
155
|
+
hover(bg("warning.tint")),
|
|
156
|
+
active(bg("warning.bg-tint-hover")),
|
|
157
|
+
]),
|
|
158
|
+
data("color", "danger", [
|
|
159
|
+
fg("danger"),
|
|
160
|
+
hover(bg("danger.tint")),
|
|
161
|
+
active(bg("danger.bg-tint-hover")),
|
|
162
|
+
]),
|
|
163
|
+
]),
|
|
164
|
+
data("variant", "ghost", [bg("transparent"), border("transparent")]),
|
|
165
|
+
when('&[aria-disabled="true"]', opacity(50)),
|
|
166
|
+
when('&[aria-disabled="true"]', [cursor("not-allowed"), pointerEvents()]),
|
|
167
|
+
cursor("default"),
|
|
168
|
+
userSelect(),
|
|
169
|
+
text("sm"),
|
|
170
|
+
data("size", "sm", text("xs")),
|
|
171
|
+
mix,
|
|
172
|
+
] }));
|
|
173
|
+
};
|
|
174
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A native anchor for inline navigation, always underlined so its
|
|
3
|
+
* affordance never rests on color alone, and colored through a semantic
|
|
4
|
+
* color role that also drives its focus ring and disabled state.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
10
|
+
import type { SemanticColor } from "../utils/semantic-color.js";
|
|
11
|
+
/**
|
|
12
|
+
* Prop types for {@link Link}.
|
|
13
|
+
*/
|
|
14
|
+
export declare namespace Link {
|
|
15
|
+
/**
|
|
16
|
+
* Semantic color role, each mapped to its matching `--ui-*` variables.
|
|
17
|
+
*/
|
|
18
|
+
type Color = SemanticColor;
|
|
19
|
+
/**
|
|
20
|
+
* Props accepted by {@link Link}. A type alias rather than an interface,
|
|
21
|
+
* since the native anchor props resolve through a conditional type that an
|
|
22
|
+
* `interface extends` clause can't statically extend.
|
|
23
|
+
*/
|
|
24
|
+
type Props = TagProps<"a"> & {
|
|
25
|
+
/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */
|
|
26
|
+
color?: Color;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Renders a native `<a>` host, colored through the `data-color` attribute
|
|
31
|
+
* contract and underlined unconditionally. `aria-disabled="true"` mutes the
|
|
32
|
+
* link, but only removing or neutralizing `href` actually stops navigation.
|
|
33
|
+
*
|
|
34
|
+
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
35
|
+
* @returns The render function producing the link's markup.
|
|
36
|
+
* @example
|
|
37
|
+
* <Link href="/about">{t("nav.about")}</Link>
|
|
38
|
+
* @example
|
|
39
|
+
* <Link href="/delete" color="danger">{t("actions.delete")}</Link>
|
|
40
|
+
* @example
|
|
41
|
+
* <Link href="/settings" aria-disabled="true">{t("nav.settings")}</Link>
|
|
42
|
+
*/
|
|
43
|
+
export declare function Link(handle: Handle<Link.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { colorMix, fg, outline } from "@sdxc/u/color";
|
|
3
|
+
import { opacity, rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor, raw, var as varUtility } from "@sdxc/u/general";
|
|
5
|
+
import { data, when } from "@sdxc/u/state";
|
|
6
|
+
import { textDecoration } from "@sdxc/u/typography";
|
|
7
|
+
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
8
|
+
/** Semantic color role {@link Link} falls back to when `color` is omitted. */
|
|
9
|
+
const DEFAULT_COLOR = "brand";
|
|
10
|
+
/**
|
|
11
|
+
* Renders a native `<a>` host, colored through the `data-color` attribute
|
|
12
|
+
* contract and underlined unconditionally. `aria-disabled="true"` mutes the
|
|
13
|
+
* link, but only removing or neutralizing `href` actually stops navigation.
|
|
14
|
+
*
|
|
15
|
+
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
16
|
+
* @returns The render function producing the link's markup.
|
|
17
|
+
* @example
|
|
18
|
+
* <Link href="/about">{t("nav.about")}</Link>
|
|
19
|
+
* @example
|
|
20
|
+
* <Link href="/delete" color="danger">{t("actions.delete")}</Link>
|
|
21
|
+
* @example
|
|
22
|
+
* <Link href="/settings" aria-disabled="true">{t("nav.settings")}</Link>
|
|
23
|
+
*/
|
|
24
|
+
export function Link(handle) {
|
|
25
|
+
return () => {
|
|
26
|
+
let { color, mix, ...rest } = handle.props;
|
|
27
|
+
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
28
|
+
return (_jsx("a", { "data-color": resolvedColor, ...rest, mix: [
|
|
29
|
+
when("&:focus-visible", [
|
|
30
|
+
outline({ color: "brand.ring", offset: 2 }),
|
|
31
|
+
data("color", "neutral", outline("neutral.ring")),
|
|
32
|
+
data("color", "success", outline("success.ring")),
|
|
33
|
+
data("color", "warning", outline("warning.ring")),
|
|
34
|
+
data("color", "danger", outline("danger.ring")),
|
|
35
|
+
]),
|
|
36
|
+
interactiveTransition(),
|
|
37
|
+
rounded("sm"),
|
|
38
|
+
data("color", "brand", fg("brand")),
|
|
39
|
+
data("color", "neutral", fg("neutral")),
|
|
40
|
+
data("color", "success", fg("success")),
|
|
41
|
+
data("color", "danger", fg("danger")),
|
|
42
|
+
data("color", "warning", fg("warning")),
|
|
43
|
+
when('&[aria-disabled="true"]', opacity(50)),
|
|
44
|
+
textDecoration("underline"),
|
|
45
|
+
cursor("pointer"),
|
|
46
|
+
data("color", "brand", [
|
|
47
|
+
/**
|
|
48
|
+
* `color-mix()`'s color argument needs the raw CSS variable
|
|
49
|
+
* (`var(--ui-brand-fg)`), so the property stays `raw()` while
|
|
50
|
+
* the literal string becomes a builder call.
|
|
51
|
+
*/
|
|
52
|
+
raw({
|
|
53
|
+
textDecorationColor: colorMix("srgb", { color: varUtility("ui-brand-fg"), weight: 60 }, "transparent"),
|
|
54
|
+
}),
|
|
55
|
+
when("&:hover", raw({ textDecorationColor: varUtility("ui-brand-fg") })),
|
|
56
|
+
]),
|
|
57
|
+
data("color", "neutral", [
|
|
58
|
+
raw({
|
|
59
|
+
textDecorationColor: colorMix("srgb", { color: varUtility("ui-neutral-fg"), weight: 50 }, "transparent"),
|
|
60
|
+
}),
|
|
61
|
+
when("&:hover", raw({ textDecorationColor: varUtility("ui-neutral-fg") })),
|
|
62
|
+
]),
|
|
63
|
+
data("color", "success", [
|
|
64
|
+
raw({
|
|
65
|
+
textDecorationColor: colorMix("srgb", { color: varUtility("ui-success-fg"), weight: 60 }, "transparent"),
|
|
66
|
+
}),
|
|
67
|
+
when("&:hover", raw({ textDecorationColor: varUtility("ui-success-fg") })),
|
|
68
|
+
]),
|
|
69
|
+
data("color", "danger", [
|
|
70
|
+
raw({
|
|
71
|
+
textDecorationColor: colorMix("srgb", { color: varUtility("ui-danger-fg"), weight: 60 }, "transparent"),
|
|
72
|
+
}),
|
|
73
|
+
when("&:hover", raw({ textDecorationColor: varUtility("ui-danger-fg") })),
|
|
74
|
+
]),
|
|
75
|
+
data("color", "warning", [
|
|
76
|
+
raw({
|
|
77
|
+
textDecorationColor: colorMix("srgb", { color: varUtility("ui-warning-fg"), weight: 60 }, "transparent"),
|
|
78
|
+
}),
|
|
79
|
+
when("&:hover", raw({ textDecorationColor: varUtility("ui-warning-fg") })),
|
|
80
|
+
]),
|
|
81
|
+
when('&[aria-disabled="true"]', [cursor("not-allowed"), textDecoration("none")]),
|
|
82
|
+
mix,
|
|
83
|
+
] }));
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A run of selectable option rows sharing one native grouping name — each
|
|
3
|
+
* {@link ListBox.Item} pairs a visually hidden `<input type="radio">` or
|
|
4
|
+
* `<input type="checkbox">` with its own visible content, so every focus,
|
|
5
|
+
* keyboard, and form-submission semantic keeps coming from the platform
|
|
6
|
+
* itself. The host renders as a scrollable column reading each option's
|
|
7
|
+
* `:checked` and `:focus` state through a `:has()` selector to color the
|
|
8
|
+
* whole row, with no selection state tracked anywhere in this module.
|
|
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
|
+
import { SentinelRow } from "./sentinel-row.js";
|
|
15
|
+
/**
|
|
16
|
+
* Prop types for {@link ListBox} and its {@link ListBox.Item} compound part.
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace ListBox {
|
|
19
|
+
/**
|
|
20
|
+
* Value {@link ListBox} stores in component context so every
|
|
21
|
+
* {@link ListBox.Item} nested inside shares the same grouping name and
|
|
22
|
+
* selection cardinality without repeating them on each option.
|
|
23
|
+
*/
|
|
24
|
+
interface Context {
|
|
25
|
+
/** Shared `name` every {@link ListBox.Item} reads unless it sets its own. */
|
|
26
|
+
name: string;
|
|
27
|
+
/**
|
|
28
|
+
* Whether an option's underlying input renders as a checkbox (`true`,
|
|
29
|
+
* letting several options be selected at once) or a radio (`false`,
|
|
30
|
+
* limiting the group to a single selected option).
|
|
31
|
+
*/
|
|
32
|
+
multiple: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Props accepted by {@link ListBox}.
|
|
36
|
+
*/
|
|
37
|
+
interface Props extends TagProps<"div"> {
|
|
38
|
+
/**
|
|
39
|
+
* Native grouping name shared by every {@link ListBox.Item} nested inside,
|
|
40
|
+
* provided through component context. Defaults to the group's own
|
|
41
|
+
* {@link Handle.id | stable instance id}, so options always group correctly.
|
|
42
|
+
*/
|
|
43
|
+
name?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Renders every option as a checkbox, allowing more than one selected
|
|
46
|
+
* at once, instead of the default mutually exclusive radio behavior.
|
|
47
|
+
* Defaults to {@link DEFAULT_MULTIPLE}.
|
|
48
|
+
*/
|
|
49
|
+
multiple?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Props accepted by {@link ListBox.Item}.
|
|
53
|
+
*/
|
|
54
|
+
interface ItemProps extends Omit<TagProps<"label">, "children"> {
|
|
55
|
+
/** Value submitted with the enclosing form when this option is selected. */
|
|
56
|
+
value: string;
|
|
57
|
+
/**
|
|
58
|
+
* Native grouping name for this option's underlying input. Defaults to
|
|
59
|
+
* the name provided by the nearest ancestor {@link ListBox} — set this
|
|
60
|
+
* only to opt a single option out of its group's shared name.
|
|
61
|
+
*/
|
|
62
|
+
name?: string;
|
|
63
|
+
/** Whether this option starts selected, for a form that never tracks selection itself. */
|
|
64
|
+
defaultChecked?: boolean;
|
|
65
|
+
/** Whether this option is selected, for a form that tracks selection itself. */
|
|
66
|
+
checked?: boolean;
|
|
67
|
+
/** Whether this option is inert and excluded from the group's tab order. */
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Sets the underlying input's native `required` attribute. On a radio
|
|
71
|
+
* input this requires at least one option in the group be selected; on
|
|
72
|
+
* a checkbox input it requires this specific option be checked.
|
|
73
|
+
*/
|
|
74
|
+
required?: boolean;
|
|
75
|
+
/** The option's visible content, associated with the input by native nesting. */
|
|
76
|
+
children?: RemixNode;
|
|
77
|
+
/**
|
|
78
|
+
* Per-part styling for the option's hidden `input` element, layered
|
|
79
|
+
* after its own built-in styling. Use the `mix` prop instead to style
|
|
80
|
+
* the option's outer `<label>` host.
|
|
81
|
+
*/
|
|
82
|
+
parts?: {
|
|
83
|
+
/** Additional mixin(s) applied to the hidden native `<input>`. */
|
|
84
|
+
input?: TagProps<"input">["mix"];
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Props accepted by {@link ListBox.LoadMoreItem}.
|
|
89
|
+
*/
|
|
90
|
+
interface LoadMoreItemProps extends TagProps<"div"> {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Renders the group host: a `<div>` laying its {@link ListBox.Item} options
|
|
95
|
+
* out as a scrollable column capped at a fixed block size, with `role`
|
|
96
|
+
* defaulting to `"radiogroup"` for single selection or `"group"` for `multiple`.
|
|
97
|
+
*
|
|
98
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link ListBox.Context}.
|
|
99
|
+
* @returns The render function producing the group's markup.
|
|
100
|
+
* @example
|
|
101
|
+
* <ListBox aria-label={t("settings.theme")}>
|
|
102
|
+
* <ListBox.Item value="light" defaultChecked>{t("settings.themeLight")}</ListBox.Item>
|
|
103
|
+
* <ListBox.Item value="dark">{t("settings.themeDark")}</ListBox.Item>
|
|
104
|
+
* <ListBox.Item value="system">{t("settings.themeSystem")}</ListBox.Item>
|
|
105
|
+
* </ListBox>
|
|
106
|
+
* @example
|
|
107
|
+
* <ListBox aria-label={t("settings.notifications")} multiple>
|
|
108
|
+
* <Section aria-labelledby="notifications-heading">
|
|
109
|
+
* <Header id="notifications-heading">{t("settings.channels")}</Header>
|
|
110
|
+
* <ListBox.Item value="email" defaultChecked>{t("settings.email")}</ListBox.Item>
|
|
111
|
+
* <ListBox.Item value="sms">{t("settings.sms")}</ListBox.Item>
|
|
112
|
+
* </Section>
|
|
113
|
+
* </ListBox>
|
|
114
|
+
*/
|
|
115
|
+
export declare function ListBox(handle: Handle<ListBox.Props, ListBox.Context>): () => import("remix/ui").RemixElement;
|
|
116
|
+
export declare namespace ListBox {
|
|
117
|
+
var Item: (handle: Handle<ListBox.ItemProps>) => () => import("remix/ui").RemixElement;
|
|
118
|
+
var LoadMoreItem: typeof SentinelRow;
|
|
119
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
3
|
+
import { bg, fg, outline } from "@sdxc/u/color";
|
|
4
|
+
import { opacity, rounded } from "@sdxc/u/effects";
|
|
5
|
+
import { cursor } from "@sdxc/u/general";
|
|
6
|
+
import { flex, gap, items } from "@sdxc/u/layout";
|
|
7
|
+
import { overflow } from "@sdxc/u/overflow";
|
|
8
|
+
import { maxBs, p, pb, pi } from "@sdxc/u/size";
|
|
9
|
+
import { active, hover, when } from "@sdxc/u/state";
|
|
10
|
+
import { text } from "@sdxc/u/typography";
|
|
11
|
+
import { attrs } from "remix/ui";
|
|
12
|
+
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
13
|
+
import { warnIfNoAccessibleName } from "../utils/warn-if-no-accessible-name.js";
|
|
14
|
+
import { SentinelRow } from "./sentinel-row.js";
|
|
15
|
+
/**
|
|
16
|
+
* Default {@link ListBox.Props} selection cardinality, applied when
|
|
17
|
+
* `multiple` is omitted, rendering every {@link ListBox.Item} as a native
|
|
18
|
+
* `<input type="radio">` limiting the group to one selected option.
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_MULTIPLE = false;
|
|
21
|
+
/**
|
|
22
|
+
* Renders the group host: a `<div>` laying its {@link ListBox.Item} options
|
|
23
|
+
* out as a scrollable column capped at a fixed block size, with `role`
|
|
24
|
+
* defaulting to `"radiogroup"` for single selection or `"group"` for `multiple`.
|
|
25
|
+
*
|
|
26
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link ListBox.Context}.
|
|
27
|
+
* @returns The render function producing the group's markup.
|
|
28
|
+
* @example
|
|
29
|
+
* <ListBox aria-label={t("settings.theme")}>
|
|
30
|
+
* <ListBox.Item value="light" defaultChecked>{t("settings.themeLight")}</ListBox.Item>
|
|
31
|
+
* <ListBox.Item value="dark">{t("settings.themeDark")}</ListBox.Item>
|
|
32
|
+
* <ListBox.Item value="system">{t("settings.themeSystem")}</ListBox.Item>
|
|
33
|
+
* </ListBox>
|
|
34
|
+
* @example
|
|
35
|
+
* <ListBox aria-label={t("settings.notifications")} multiple>
|
|
36
|
+
* <Section aria-labelledby="notifications-heading">
|
|
37
|
+
* <Header id="notifications-heading">{t("settings.channels")}</Header>
|
|
38
|
+
* <ListBox.Item value="email" defaultChecked>{t("settings.email")}</ListBox.Item>
|
|
39
|
+
* <ListBox.Item value="sms">{t("settings.sms")}</ListBox.Item>
|
|
40
|
+
* </Section>
|
|
41
|
+
* </ListBox>
|
|
42
|
+
*/
|
|
43
|
+
export function ListBox(handle) {
|
|
44
|
+
return () => {
|
|
45
|
+
let { name, multiple, mix, ...rest } = handle.props;
|
|
46
|
+
let resolvedName = name ?? handle.id;
|
|
47
|
+
let resolvedMultiple = multiple ?? DEFAULT_MULTIPLE;
|
|
48
|
+
handle.context.set({ name: resolvedName, multiple: resolvedMultiple });
|
|
49
|
+
return (_jsx("div", { ...rest, mix: [
|
|
50
|
+
attrs({ role: resolvedMultiple ? "group" : "radiogroup" }),
|
|
51
|
+
maxBs(60),
|
|
52
|
+
overflow("auto"),
|
|
53
|
+
p(1),
|
|
54
|
+
outline("none"),
|
|
55
|
+
mix,
|
|
56
|
+
] }));
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Renders a single option: a native `<label>` pairing a visually hidden
|
|
61
|
+
* radio or checkbox input with the option's content. In dev mode, an
|
|
62
|
+
* option with no accessible name logs a `console.warn`.
|
|
63
|
+
*
|
|
64
|
+
* @param handle Runtime handle carrying the host `<label>`'s props.
|
|
65
|
+
* @returns The render function producing the option's markup.
|
|
66
|
+
* @example
|
|
67
|
+
* <ListBox.Item value="dog">{t("pet.dog")}</ListBox.Item>
|
|
68
|
+
* @example
|
|
69
|
+
* <ListBox.Item value="cat" defaultChecked>{t("pet.cat")}</ListBox.Item>
|
|
70
|
+
* @example
|
|
71
|
+
* <ListBox.Item value="hamster" disabled>{t("pet.hamster")}</ListBox.Item>
|
|
72
|
+
*/
|
|
73
|
+
ListBox.Item = function ListBoxItem(handle) {
|
|
74
|
+
return () => {
|
|
75
|
+
let { value, name, checked, defaultChecked, disabled, required, children, parts, mix, ...rest } = handle.props;
|
|
76
|
+
let context = handle.context.get(ListBox);
|
|
77
|
+
let resolvedName = name ?? context.name;
|
|
78
|
+
let type = context.multiple ? "checkbox" : "radio";
|
|
79
|
+
warnIfNoAccessibleName(handle.props, children, "ListBox.Item: an option with no visible text needs an `aria-label` describing it — assistive technology has no accessible name to announce otherwise.");
|
|
80
|
+
return (_jsxs("label", { ...rest, mix: [
|
|
81
|
+
interactiveTransition(),
|
|
82
|
+
flex(),
|
|
83
|
+
items("center"),
|
|
84
|
+
gap(2),
|
|
85
|
+
rounded("md"),
|
|
86
|
+
pi(3),
|
|
87
|
+
pb(2),
|
|
88
|
+
fg("neutral.emphasis"),
|
|
89
|
+
hover(bg("neutral.bg-tint-hover")),
|
|
90
|
+
active(bg("neutral.bg-tint-pressed")),
|
|
91
|
+
when("&:has(input:focus)", bg("brand.tint")),
|
|
92
|
+
when('&:has(input:checked), &[aria-selected="true"]', [
|
|
93
|
+
bg("brand.solid"),
|
|
94
|
+
fg("brand.onSolid"),
|
|
95
|
+
]),
|
|
96
|
+
when('&:has(input:disabled), &[aria-disabled="true"]', opacity(50)),
|
|
97
|
+
cursor("default"),
|
|
98
|
+
text("sm"),
|
|
99
|
+
outline("none"),
|
|
100
|
+
mix,
|
|
101
|
+
], children: [_jsx("input", { type: type, value: value, name: resolvedName, checked: checked, defaultChecked: defaultChecked, disabled: disabled, required: required, mix: [visuallyHidden(), parts?.input] }), children] }));
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Renders a decorative sentinel row: a `<div>` styled as a centered, muted
|
|
106
|
+
* line of small text sized to match {@link ListBox.Item}'s vertical rhythm,
|
|
107
|
+
* ready to hold a loading indicator or "load more" trigger as `children`.
|
|
108
|
+
*
|
|
109
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
110
|
+
* @returns The render function producing the sentinel row's markup.
|
|
111
|
+
* @example
|
|
112
|
+
* <ListBox.LoadMoreItem>{t("list.loadingMore")}</ListBox.LoadMoreItem>
|
|
113
|
+
*/
|
|
114
|
+
ListBox.LoadMoreItem = SentinelRow;
|