@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,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A decorative loading placeholder rendered as a single static block,
|
|
3
|
+
* sized to stand in for the content it precedes and showing a still,
|
|
4
|
+
* inert silhouette while data loads.
|
|
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
|
+
/**
|
|
11
|
+
* Props accepted by {@link Skeleton}.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace Skeleton {
|
|
14
|
+
/**
|
|
15
|
+
* Every native `<div>` attribute, unchanged, plus the `mix` passthrough.
|
|
16
|
+
* A placeholder's box shape comes from the space it renders into, tuned
|
|
17
|
+
* through `style`, a wrapping layout, or a `css()` mixin via `mix`.
|
|
18
|
+
*/
|
|
19
|
+
interface Props extends TagProps<"div"> {
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A static loading placeholder: a rounded block filled with the neutral
|
|
24
|
+
* border color, sized to its container and one text line tall by default.
|
|
25
|
+
* Compose `pulse()` or `shimmer()` through `mix` for a motion cue.
|
|
26
|
+
*
|
|
27
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
28
|
+
* @returns The render function producing the placeholder's markup.
|
|
29
|
+
* @example
|
|
30
|
+
* <Skeleton mix={[pulse()]} />
|
|
31
|
+
* @example
|
|
32
|
+
* <Skeleton style={{ blockSize: "2.5rem", inlineSize: "2.5rem", borderRadius: "9999px" }} />
|
|
33
|
+
* @example
|
|
34
|
+
* <Skeleton aria-hidden={false} aria-label={t("status.loadingProfile")} />
|
|
35
|
+
*/
|
|
36
|
+
export declare function Skeleton(handle: Handle<Skeleton.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg } from "@sdxc/u/color";
|
|
3
|
+
import { rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { bs, is } from "@sdxc/u/size";
|
|
5
|
+
import { attrs } from "remix/ui";
|
|
6
|
+
/**
|
|
7
|
+
* Default `aria-hidden` value applied through {@link attrs}, keeping a
|
|
8
|
+
* placeholder out of the accessibility tree unless a consumer sets
|
|
9
|
+
* `aria-hidden={false}` to expose a loading label to assistive tech.
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_ARIA_HIDDEN = "true";
|
|
12
|
+
/**
|
|
13
|
+
* A static loading placeholder: a rounded block filled with the neutral
|
|
14
|
+
* border color, sized to its container and one text line tall by default.
|
|
15
|
+
* Compose `pulse()` or `shimmer()` through `mix` for a motion cue.
|
|
16
|
+
*
|
|
17
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
18
|
+
* @returns The render function producing the placeholder's markup.
|
|
19
|
+
* @example
|
|
20
|
+
* <Skeleton mix={[pulse()]} />
|
|
21
|
+
* @example
|
|
22
|
+
* <Skeleton style={{ blockSize: "2.5rem", inlineSize: "2.5rem", borderRadius: "9999px" }} />
|
|
23
|
+
* @example
|
|
24
|
+
* <Skeleton aria-hidden={false} aria-label={t("status.loadingProfile")} />
|
|
25
|
+
*/
|
|
26
|
+
export function Skeleton(handle) {
|
|
27
|
+
return () => {
|
|
28
|
+
let { mix, ...rest } = handle.props;
|
|
29
|
+
return (_jsx("div", { ...rest, mix: [
|
|
30
|
+
attrs({ "aria-hidden": DEFAULT_ARIA_HIDDEN }),
|
|
31
|
+
bs("var(--ui-skeleton-block-size, 1rem)"),
|
|
32
|
+
is("full"),
|
|
33
|
+
rounded("md"),
|
|
34
|
+
bg("neutral.border"),
|
|
35
|
+
mix,
|
|
36
|
+
] }));
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single-value range control built on a native `<input type="range">`,
|
|
3
|
+
* paired with a track that draws its own background rail and a live fill
|
|
4
|
+
* bar, plus an `<output>` for reporting the current value. The root shares
|
|
5
|
+
* the resolved range and value with every part through component context,
|
|
6
|
+
* so a track's fill bar and a thumb's native attributes always agree
|
|
7
|
+
* without a consumer repeating the same numbers twice.
|
|
8
|
+
*
|
|
9
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
10
|
+
* @copyright Sergio Xalambrí 2026
|
|
11
|
+
*/
|
|
12
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
13
|
+
/**
|
|
14
|
+
* Prop types for {@link Slider} and its compound parts.
|
|
15
|
+
*/
|
|
16
|
+
export declare namespace Slider {
|
|
17
|
+
/**
|
|
18
|
+
* Axis the track's fill bar and thumb travel along: a full-width row, or
|
|
19
|
+
* a full-height column.
|
|
20
|
+
*/
|
|
21
|
+
type Orientation = "horizontal" | "vertical";
|
|
22
|
+
/**
|
|
23
|
+
* Value {@link Slider} shares through component context so every nested
|
|
24
|
+
* {@link Slider.Track}, {@link Slider.Thumb}, and {@link Slider.Output}
|
|
25
|
+
* reads the same resolved range, value, orientation, and thumb id.
|
|
26
|
+
*/
|
|
27
|
+
interface Context {
|
|
28
|
+
/** Resolved lower bound of the range, shared with {@link Slider.Thumb}. */
|
|
29
|
+
min: number;
|
|
30
|
+
/** Resolved upper bound of the range, shared with {@link Slider.Thumb}. */
|
|
31
|
+
max: number;
|
|
32
|
+
/** Resolved current value, used to compute {@link Slider.Track}'s fill bar and default {@link Slider.Thumb}'s own value. */
|
|
33
|
+
value: number;
|
|
34
|
+
/** Layout axis, read by {@link Slider.Thumb} to set its accessible orientation. */
|
|
35
|
+
orientation: Orientation;
|
|
36
|
+
/**
|
|
37
|
+
* Id shared by {@link Slider.Thumb} (as its own `id`) and
|
|
38
|
+
* {@link Slider.Output} (as its `htmlFor`) so the two associate
|
|
39
|
+
* natively without either needing an explicit id from the consumer.
|
|
40
|
+
*/
|
|
41
|
+
thumbId: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Props accepted by {@link Slider}.
|
|
45
|
+
*/
|
|
46
|
+
interface Props extends TagProps<"div"> {
|
|
47
|
+
/** Layout axis. Defaults to {@link DEFAULT_ORIENTATION}. */
|
|
48
|
+
orientation?: Orientation;
|
|
49
|
+
/** Lower bound of the range. Defaults to {@link DEFAULT_MIN}. */
|
|
50
|
+
min?: number;
|
|
51
|
+
/** Upper bound of the range. Defaults to {@link DEFAULT_MAX}. */
|
|
52
|
+
max?: number;
|
|
53
|
+
/** Current value, for a slider whose value the consumer tracks itself. */
|
|
54
|
+
value?: number;
|
|
55
|
+
/** Starting value, for a slider that never tracks its own value. */
|
|
56
|
+
defaultValue?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Props accepted by {@link Slider.Track}.
|
|
60
|
+
*/
|
|
61
|
+
interface TrackProps extends TagProps<"div"> {
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Every native `<input>` attribute except `type` and `role`, fixed to
|
|
65
|
+
* `"range"` and the platform's implicit `"slider"` role. `min`/`max`/`step`
|
|
66
|
+
* override the range inherited from the nearest ancestor {@link Slider}.
|
|
67
|
+
*/
|
|
68
|
+
interface ThumbProps extends Omit<TagProps<"input">, "type" | "role"> {
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Props accepted by {@link Slider.Output}.
|
|
72
|
+
*/
|
|
73
|
+
interface OutputProps extends TagProps<"output"> {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Renders the root host: a `<div>` stacking its children, growing to fill
|
|
78
|
+
* the inline axis by default or a fixed block axis when vertical. Resolves
|
|
79
|
+
* the range, value, orientation, and thumb id into context for nested parts.
|
|
80
|
+
*
|
|
81
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link Slider.Context}.
|
|
82
|
+
* @returns The render function producing the root's markup.
|
|
83
|
+
* @example
|
|
84
|
+
* <Slider aria-label={t("settings.volume")} min={0} max={100} defaultValue={40}>
|
|
85
|
+
* <Slider.Output />
|
|
86
|
+
* <Slider.Track>
|
|
87
|
+
* <Slider.Thumb />
|
|
88
|
+
* </Slider.Track>
|
|
89
|
+
* </Slider>
|
|
90
|
+
* @example
|
|
91
|
+
* <Slider orientation="vertical" min={0} max={10} defaultValue={6}>
|
|
92
|
+
* <Slider.Track>
|
|
93
|
+
* <Slider.Thumb aria-label={t("equalizer.band", { hz: 250 })} />
|
|
94
|
+
* </Slider.Track>
|
|
95
|
+
* </Slider>
|
|
96
|
+
*/
|
|
97
|
+
export declare function Slider(handle: Handle<Slider.Props, Slider.Context>): () => import("remix/ui").RemixElement;
|
|
98
|
+
export declare namespace Slider {
|
|
99
|
+
var Track: (handle: Handle<Slider.TrackProps>) => () => import("remix/ui").RemixElement;
|
|
100
|
+
var Thumb: (handle: Handle<Slider.ThumbProps>) => () => import("remix/ui").RemixElement;
|
|
101
|
+
var Output: (handle: Handle<Slider.OutputProps>) => () => import("remix/ui").RemixElement;
|
|
102
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { absolute, after, appearance, basis, before, bg, border, bs, cursor, grow, insBe, insBs, insIe, insIs, inset, is, items, m, minBs, minIs, outlineStyle, overflow, pseudoContent, raw, relative, rounded, shrink, translateX, translateY, vstack, when, z, } from "@sdxc/u";
|
|
3
|
+
import { outputCaptionText } from "../styles/output-caption-text.js";
|
|
4
|
+
import { rangeThumbAppearance } from "../styles/range-thumb-appearance.js";
|
|
5
|
+
import { mergeStyle } from "../utils/merge-style.js";
|
|
6
|
+
import { resolveFillPercent } from "../utils/resolve-fill-percent.js";
|
|
7
|
+
/** Default {@link Slider.Props} orientation, applied when `orientation` is omitted. */
|
|
8
|
+
const DEFAULT_ORIENTATION = "horizontal";
|
|
9
|
+
/** Default {@link Slider.Props} lower bound, applied when `min` is omitted. */
|
|
10
|
+
const DEFAULT_MIN = 0;
|
|
11
|
+
/** Default {@link Slider.Props} upper bound, applied when `max` is omitted. */
|
|
12
|
+
const DEFAULT_MAX = 100;
|
|
13
|
+
/** Default {@link Slider.ThumbProps} step, applied when `step` is omitted. */
|
|
14
|
+
const DEFAULT_STEP = 1;
|
|
15
|
+
/**
|
|
16
|
+
* Renders the root host: a `<div>` stacking its children, growing to fill
|
|
17
|
+
* the inline axis by default or a fixed block axis when vertical. Resolves
|
|
18
|
+
* the range, value, orientation, and thumb id into context for nested parts.
|
|
19
|
+
*
|
|
20
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link Slider.Context}.
|
|
21
|
+
* @returns The render function producing the root's markup.
|
|
22
|
+
* @example
|
|
23
|
+
* <Slider aria-label={t("settings.volume")} min={0} max={100} defaultValue={40}>
|
|
24
|
+
* <Slider.Output />
|
|
25
|
+
* <Slider.Track>
|
|
26
|
+
* <Slider.Thumb />
|
|
27
|
+
* </Slider.Track>
|
|
28
|
+
* </Slider>
|
|
29
|
+
* @example
|
|
30
|
+
* <Slider orientation="vertical" min={0} max={10} defaultValue={6}>
|
|
31
|
+
* <Slider.Track>
|
|
32
|
+
* <Slider.Thumb aria-label={t("equalizer.band", { hz: 250 })} />
|
|
33
|
+
* </Slider.Track>
|
|
34
|
+
* </Slider>
|
|
35
|
+
*/
|
|
36
|
+
export function Slider(handle) {
|
|
37
|
+
return () => {
|
|
38
|
+
let { orientation, min, max, value, defaultValue, mix, ...rest } = handle.props;
|
|
39
|
+
let resolvedOrientation = orientation ?? DEFAULT_ORIENTATION;
|
|
40
|
+
let resolvedMin = min ?? DEFAULT_MIN;
|
|
41
|
+
let resolvedMax = max ?? DEFAULT_MAX;
|
|
42
|
+
let resolvedValue = value ?? defaultValue ?? resolvedMin;
|
|
43
|
+
handle.context.set({
|
|
44
|
+
min: resolvedMin,
|
|
45
|
+
max: resolvedMax,
|
|
46
|
+
value: resolvedValue,
|
|
47
|
+
orientation: resolvedOrientation,
|
|
48
|
+
thumbId: handle.id,
|
|
49
|
+
});
|
|
50
|
+
return (_jsx("div", { "data-orientation": resolvedOrientation, ...rest, mix: [
|
|
51
|
+
vstack({ gap: "0.5rem" }),
|
|
52
|
+
when('&[data-orientation="horizontal"]', [is("100%"), minIs("10rem")]),
|
|
53
|
+
when('&[data-orientation="vertical"]', [bs("10rem"), items("center")]),
|
|
54
|
+
mix,
|
|
55
|
+
] }));
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Renders the visual track: a `position: relative` `<div>` that draws a rail
|
|
60
|
+
* and fill bar as pseudo-elements sized from context's resolved value, and
|
|
61
|
+
* overlays a nested {@link Slider.Thumb} so native drag spans its full length.
|
|
62
|
+
*
|
|
63
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
64
|
+
* @returns The render function producing the track's markup.
|
|
65
|
+
* @example
|
|
66
|
+
* <Slider.Track>
|
|
67
|
+
* <Slider.Thumb />
|
|
68
|
+
* </Slider.Track>
|
|
69
|
+
*/
|
|
70
|
+
Slider.Track = function SliderTrack(handle) {
|
|
71
|
+
return () => {
|
|
72
|
+
let { mix, style, ...rest } = handle.props;
|
|
73
|
+
let context = handle.context.get(Slider);
|
|
74
|
+
let fillPercent = resolveFillPercent(context.min, context.max, context.value);
|
|
75
|
+
let resolvedStyle = mergeStyle(style, { "--ui-slider-fill": `${fillPercent}%` });
|
|
76
|
+
return (_jsx("div", { ...rest, style: resolvedStyle, mix: [
|
|
77
|
+
relative(),
|
|
78
|
+
when('[data-orientation="horizontal"] &', [
|
|
79
|
+
is("100%"),
|
|
80
|
+
bs("var(--ui-slider-thumb-size, 1.25rem)"),
|
|
81
|
+
]),
|
|
82
|
+
when('[data-orientation="vertical"] &', [
|
|
83
|
+
is("var(--ui-slider-thumb-size, 1.25rem)"),
|
|
84
|
+
minBs("0"),
|
|
85
|
+
overflow("hidden"),
|
|
86
|
+
]),
|
|
87
|
+
before([absolute(), rounded("full"), bg("neutral.border"), pseudoContent('""')]),
|
|
88
|
+
after([absolute(), rounded("full"), bg("brand.solid"), pseudoContent('""')]),
|
|
89
|
+
when('[data-orientation="vertical"] &', [grow(), shrink(1), basis("0%")]),
|
|
90
|
+
when('[data-orientation="horizontal"] &::before', [
|
|
91
|
+
bs("var(--ui-slider-track-thickness, 0.5rem)"),
|
|
92
|
+
insIs("0"),
|
|
93
|
+
insIe("0"),
|
|
94
|
+
insBs("50%"),
|
|
95
|
+
translateY("-50%"),
|
|
96
|
+
]),
|
|
97
|
+
when('[data-orientation="horizontal"] &::after', [
|
|
98
|
+
bs("var(--ui-slider-track-thickness, 0.5rem)"),
|
|
99
|
+
is("var(--ui-slider-fill, 0%)"),
|
|
100
|
+
insIs("0"),
|
|
101
|
+
insBs("50%"),
|
|
102
|
+
translateY("-50%"),
|
|
103
|
+
]),
|
|
104
|
+
when('[data-orientation="vertical"] &::before', [
|
|
105
|
+
is("var(--ui-slider-track-thickness, 0.5rem)"),
|
|
106
|
+
bs("100%"),
|
|
107
|
+
insBs("0"),
|
|
108
|
+
insIs("50%"),
|
|
109
|
+
translateX("-50%"),
|
|
110
|
+
]),
|
|
111
|
+
when('[data-orientation="vertical"] &::after', [
|
|
112
|
+
is("var(--ui-slider-track-thickness, 0.5rem)"),
|
|
113
|
+
bs("var(--ui-slider-fill, 0%)"),
|
|
114
|
+
insBe("0"),
|
|
115
|
+
insIs("50%"),
|
|
116
|
+
translateX("-50%"),
|
|
117
|
+
]),
|
|
118
|
+
mix,
|
|
119
|
+
] }));
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Renders the interactive thumb: a native `<input type="range">` reset to
|
|
124
|
+
* cover {@link Slider.Track}'s full box so native drag and keyboard control
|
|
125
|
+
* span its whole length, rotating with `writing-mode` when vertical.
|
|
126
|
+
*
|
|
127
|
+
* @param handle Runtime handle carrying the host `<input>`'s props.
|
|
128
|
+
* @returns The render function producing the thumb's markup.
|
|
129
|
+
* @example
|
|
130
|
+
* <Slider.Thumb aria-label={t("settings.volume")} />
|
|
131
|
+
* @example
|
|
132
|
+
* <Slider.Thumb aria-label={t("settings.brightness")} disabled />
|
|
133
|
+
*/
|
|
134
|
+
Slider.Thumb = function SliderThumb(handle) {
|
|
135
|
+
return () => {
|
|
136
|
+
let { id, min, max, step, value, defaultValue, mix, ...rest } = handle.props;
|
|
137
|
+
let context = handle.context.get(Slider);
|
|
138
|
+
let resolvedStep = step ?? DEFAULT_STEP;
|
|
139
|
+
let resolvedValue = value ?? defaultValue ?? context.value;
|
|
140
|
+
return (_jsx("input", { ...rest, type: "range", id: id ?? context.thumbId, min: min ?? context.min, max: max ?? context.max, step: resolvedStep, defaultValue: resolvedValue, "aria-orientation": context.orientation === "vertical" ? "vertical" : undefined, mix: [
|
|
141
|
+
rangeThumbAppearance("--ui-slider-thumb-size", "--ui-slider-thumb-border-width"),
|
|
142
|
+
absolute(),
|
|
143
|
+
inset("0"),
|
|
144
|
+
z(10),
|
|
145
|
+
m("0"),
|
|
146
|
+
appearance(),
|
|
147
|
+
bg("transparent"),
|
|
148
|
+
cursor("pointer"),
|
|
149
|
+
when("&:disabled", cursor("not-allowed")),
|
|
150
|
+
outlineStyle("none"),
|
|
151
|
+
when("&::-webkit-slider-runnable-track", [appearance(), bs("100%"), bg("transparent")]),
|
|
152
|
+
when("&::-moz-range-track", [
|
|
153
|
+
appearance(),
|
|
154
|
+
bs("100%"),
|
|
155
|
+
bg("transparent"),
|
|
156
|
+
border({ style: "none" }),
|
|
157
|
+
]),
|
|
158
|
+
when('[data-orientation="vertical"] &', raw({ writingMode: "vertical-lr", direction: "rtl" })),
|
|
159
|
+
mix,
|
|
160
|
+
] }));
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Renders a live readout: a native `<output>` associated by default with
|
|
165
|
+
* the nearest ancestor {@link Slider}'s thumb via `htmlFor`, so assistive
|
|
166
|
+
* technology knows which control it reports on. Pass the value as `children`.
|
|
167
|
+
*
|
|
168
|
+
* @param handle Runtime handle carrying the host `<output>`'s props.
|
|
169
|
+
* @returns The render function producing the readout's markup.
|
|
170
|
+
* @example
|
|
171
|
+
* <Slider.Output>{new Intl.NumberFormat(locale, { style: "percent" }).format(0.4)}</Slider.Output>
|
|
172
|
+
*/
|
|
173
|
+
Slider.Output = function SliderOutput(handle) {
|
|
174
|
+
return () => {
|
|
175
|
+
let { htmlFor, mix, ...rest } = handle.props;
|
|
176
|
+
let context = handle.context.get(Slider);
|
|
177
|
+
return (_jsx("output", { ...rest, htmlFor: htmlFor ?? context.thumbId, mix: [outputCaptionText(), mix] }));
|
|
178
|
+
};
|
|
179
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A busy indicator rendered as a rotating icon inside a `role="progressbar"`
|
|
3
|
+
* host, colored by a semantic color role and sized by a size variant. Its own
|
|
4
|
+
* styling holds still — compose the `spin()` factory from the animation
|
|
5
|
+
* layer through `mix` for the rotating loop, so a page can render the
|
|
6
|
+
* indicator's shape before any motion-driving CSS lands.
|
|
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 Spinner}.
|
|
15
|
+
*/
|
|
16
|
+
export declare namespace Spinner {
|
|
17
|
+
/**
|
|
18
|
+
* Semantic color role, each mapped to its matching `--ui-*-fg` variable.
|
|
19
|
+
*/
|
|
20
|
+
type Color = SemanticColor;
|
|
21
|
+
/**
|
|
22
|
+
* Size variant controlling the rotating icon's rendered dimensions.
|
|
23
|
+
*/
|
|
24
|
+
type Size = "sm" | "md" | "lg";
|
|
25
|
+
/**
|
|
26
|
+
* Props accepted by {@link Spinner}.
|
|
27
|
+
*/
|
|
28
|
+
interface Props extends Omit<TagProps<"div">, "aria-label"> {
|
|
29
|
+
/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */
|
|
30
|
+
color?: Color;
|
|
31
|
+
/** Size variant. Defaults to {@link DEFAULT_SIZE}. */
|
|
32
|
+
size?: Size;
|
|
33
|
+
/**
|
|
34
|
+
* Accessible label announced by assistive technology for as long as
|
|
35
|
+
* the spinner is on screen. Required — the component ships no
|
|
36
|
+
* built-in copy, so a consumer's own localized string drives it.
|
|
37
|
+
*/
|
|
38
|
+
"aria-label": string;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Renders a busy indicator: a `role="progressbar"` host with no
|
|
43
|
+
* `aria-valuenow`, so assistive technology reads it as indeterminate. Pair
|
|
44
|
+
* it with the `spin()` mixin from the animation layer for the rotating loop.
|
|
45
|
+
*
|
|
46
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
47
|
+
* @returns The render function producing the indicator's markup.
|
|
48
|
+
* @example
|
|
49
|
+
* <Spinner aria-label={t("status.loading")} />
|
|
50
|
+
* @example
|
|
51
|
+
* <Spinner color="danger" size="lg" aria-label={t("status.retrying")} />
|
|
52
|
+
* @example
|
|
53
|
+
* <Spinner mix={[spin()]} aria-label={t("status.loading")} />
|
|
54
|
+
*/
|
|
55
|
+
export declare function Spinner(handle: Handle<Spinner.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { LoaderCircleIcon } from "@sdxc/icons";
|
|
3
|
+
import { bs, fg, inlineFlex, is, items, justify, when } from "@sdxc/u";
|
|
4
|
+
/** Semantic color role {@link Spinner} falls back to when `color` is omitted. */
|
|
5
|
+
const DEFAULT_COLOR = "neutral";
|
|
6
|
+
/** Size variant {@link Spinner} falls back to when `size` is omitted. */
|
|
7
|
+
const DEFAULT_SIZE = "md";
|
|
8
|
+
/**
|
|
9
|
+
* Renders a busy indicator: a `role="progressbar"` host with no
|
|
10
|
+
* `aria-valuenow`, so assistive technology reads it as indeterminate. Pair
|
|
11
|
+
* it with the `spin()` mixin from the animation layer for the rotating loop.
|
|
12
|
+
*
|
|
13
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
14
|
+
* @returns The render function producing the indicator's markup.
|
|
15
|
+
* @example
|
|
16
|
+
* <Spinner aria-label={t("status.loading")} />
|
|
17
|
+
* @example
|
|
18
|
+
* <Spinner color="danger" size="lg" aria-label={t("status.retrying")} />
|
|
19
|
+
* @example
|
|
20
|
+
* <Spinner mix={[spin()]} aria-label={t("status.loading")} />
|
|
21
|
+
*/
|
|
22
|
+
export function Spinner(handle) {
|
|
23
|
+
return () => {
|
|
24
|
+
let { mix, color, size, "aria-label": ariaLabel, ...rest } = handle.props;
|
|
25
|
+
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
26
|
+
let resolvedSize = size ?? DEFAULT_SIZE;
|
|
27
|
+
return (_jsx("div", { role: "progressbar", "aria-label": ariaLabel, "data-color": resolvedColor, "data-size": resolvedSize, ...rest, mix: [
|
|
28
|
+
inlineFlex(),
|
|
29
|
+
items("center"),
|
|
30
|
+
justify("center"),
|
|
31
|
+
when('&[data-color="brand"]', fg("brand")),
|
|
32
|
+
when('&[data-color="neutral"]', fg("neutral")),
|
|
33
|
+
when('&[data-color="success"]', fg("success")),
|
|
34
|
+
when('&[data-color="warning"]', fg("warning")),
|
|
35
|
+
when('&[data-color="danger"]', fg("danger")),
|
|
36
|
+
when("& svg", [
|
|
37
|
+
is("var(--ui-spinner-icon-size-md, 1.25rem)"),
|
|
38
|
+
bs("var(--ui-spinner-icon-size-md, 1.25rem)"),
|
|
39
|
+
]),
|
|
40
|
+
when('&[data-size="sm"] svg', [
|
|
41
|
+
is("var(--ui-spinner-icon-size-sm, 1rem)"),
|
|
42
|
+
bs("var(--ui-spinner-icon-size-sm, 1rem)"),
|
|
43
|
+
]),
|
|
44
|
+
when('&[data-size="lg"] svg', [
|
|
45
|
+
is("var(--ui-spinner-icon-size-lg, 1.75rem)"),
|
|
46
|
+
bs("var(--ui-spinner-icon-size-lg, 1.75rem)"),
|
|
47
|
+
]),
|
|
48
|
+
mix,
|
|
49
|
+
], children: _jsx(LoaderCircleIcon, {}) }));
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A native checkbox styled and wired as an on/off switch: a pill-shaped
|
|
3
|
+
* track whose thumb slides from the inline-start edge to the inline-end
|
|
4
|
+
* edge when checked, tinting with the semantic primary color along the way.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/ui";
|
|
10
|
+
/**
|
|
11
|
+
* Prop types for {@link Switch}.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace Switch {
|
|
14
|
+
/**
|
|
15
|
+
* Every native `<input>` attribute except `type`, `role`, and
|
|
16
|
+
* `aria-checked` — the host fixes the first two and withholds the third
|
|
17
|
+
* so the control's own live checkedness stays the switch's only state.
|
|
18
|
+
*/
|
|
19
|
+
interface Props extends Omit<TagProps<"input">, "type" | "role" | "aria-checked"> {
|
|
20
|
+
/**
|
|
21
|
+
* Visible label text rendered after the track, inside the same native
|
|
22
|
+
* `<label>` wrapping both, so clicking either half toggles the switch
|
|
23
|
+
* with no separate `htmlFor`/`id` pairing required.
|
|
24
|
+
*/
|
|
25
|
+
children?: RemixNode;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Renders a single `<input type="checkbox" role="switch">`. It carries no
|
|
30
|
+
* `aria-checked` because an authored value would go stale the instant the
|
|
31
|
+
* switch is flipped; the live control's own checkedness is what persists.
|
|
32
|
+
*
|
|
33
|
+
* @param handle Runtime handle carrying the host `<input>`'s props.
|
|
34
|
+
* @returns The render function producing the switch's markup.
|
|
35
|
+
* @example
|
|
36
|
+
* <Switch name="notifications" defaultChecked>{t("settings.notifications.label")}</Switch>
|
|
37
|
+
* @example
|
|
38
|
+
* <Label>
|
|
39
|
+
* {t("settings.notifications.label")}
|
|
40
|
+
* <Switch name="notifications" defaultChecked />
|
|
41
|
+
* </Label>
|
|
42
|
+
* @example
|
|
43
|
+
* <Switch aria-label={t("settings.darkMode")} checked={isDark} disabled={isLocked} />
|
|
44
|
+
* @example
|
|
45
|
+
* <Switch aria-label={t("settings.notifications")} mix={[ariaChecked()]} />
|
|
46
|
+
*/
|
|
47
|
+
export declare function Switch(handle: Handle<Switch.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { absolute, appearance, before, bg, bs, cursor, focusVisible, hstack, inlineBlock, insBs, insIs, is, m, media, opacity, outline, pseudoContent, raw, relative, rounded, scaleProperty, shadow, shrink, transition, transitionDuration, when, } from "@sdxc/u";
|
|
3
|
+
import { attrs } from "remix/ui";
|
|
4
|
+
import { durations, easings } from "../animations/tokens.js";
|
|
5
|
+
/**
|
|
6
|
+
* Applied through {@link attrs} so the host always carries the platform's
|
|
7
|
+
* boolean `switch` attribute, letting recognizing browsers render native
|
|
8
|
+
* switch semantics while others fall back to the host's own CSS and `role="switch"`.
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_SWITCH_ATTRIBUTE = true;
|
|
11
|
+
/**
|
|
12
|
+
* Renders a single `<input type="checkbox" role="switch">`. It carries no
|
|
13
|
+
* `aria-checked` because an authored value would go stale the instant the
|
|
14
|
+
* switch is flipped; the live control's own checkedness is what persists.
|
|
15
|
+
*
|
|
16
|
+
* @param handle Runtime handle carrying the host `<input>`'s props.
|
|
17
|
+
* @returns The render function producing the switch's markup.
|
|
18
|
+
* @example
|
|
19
|
+
* <Switch name="notifications" defaultChecked>{t("settings.notifications.label")}</Switch>
|
|
20
|
+
* @example
|
|
21
|
+
* <Label>
|
|
22
|
+
* {t("settings.notifications.label")}
|
|
23
|
+
* <Switch name="notifications" defaultChecked />
|
|
24
|
+
* </Label>
|
|
25
|
+
* @example
|
|
26
|
+
* <Switch aria-label={t("settings.darkMode")} checked={isDark} disabled={isLocked} />
|
|
27
|
+
* @example
|
|
28
|
+
* <Switch aria-label={t("settings.notifications")} mix={[ariaChecked()]} />
|
|
29
|
+
*/
|
|
30
|
+
export function Switch(handle) {
|
|
31
|
+
return () => {
|
|
32
|
+
let { mix, children, ...rest } = handle.props;
|
|
33
|
+
let track = (_jsx("input", { ...rest, type: "checkbox",
|
|
34
|
+
// oxlint-disable-next-line jsx-a11y/role-has-required-aria-props -- The host is a native checkbox, so its own checkedness supplies the switch's checked state; see the note above for why authoring one would be worse than omitting it.
|
|
35
|
+
role: "switch", mix: [
|
|
36
|
+
attrs({ switch: DEFAULT_SWITCH_ATTRIBUTE }),
|
|
37
|
+
appearance(),
|
|
38
|
+
relative(),
|
|
39
|
+
inlineBlock(),
|
|
40
|
+
m("0"),
|
|
41
|
+
is("var(--ui-switch-track-inline-size, 2.75rem)"),
|
|
42
|
+
bs("var(--ui-switch-track-block-size, 1.5rem)"),
|
|
43
|
+
rounded("full"),
|
|
44
|
+
bg("neutral.border"),
|
|
45
|
+
before([
|
|
46
|
+
absolute(),
|
|
47
|
+
is("var(--ui-switch-thumb-size, 1.25rem)"),
|
|
48
|
+
bs("var(--ui-switch-thumb-size, 1.25rem)"),
|
|
49
|
+
rounded("full"),
|
|
50
|
+
bg("brand.onSolid"),
|
|
51
|
+
transition("inset-inline-start, scale", { duration: 150 }),
|
|
52
|
+
]),
|
|
53
|
+
when("&:checked", bg("brand.solid")),
|
|
54
|
+
when("&:active", bg("neutral.strong")),
|
|
55
|
+
when("&:checked:active", bg("brand.bg-solid-hover")),
|
|
56
|
+
focusVisible(outline({ color: "brand.ring", offset: 2 })),
|
|
57
|
+
when("&:disabled", opacity(50)),
|
|
58
|
+
cursor("pointer"),
|
|
59
|
+
shrink(0),
|
|
60
|
+
transition("background-color", { duration: durations.fast, easing: easings.standard }),
|
|
61
|
+
when("&:disabled", cursor("not-allowed")),
|
|
62
|
+
raw({ verticalAlign: "middle" }),
|
|
63
|
+
before([
|
|
64
|
+
pseudoContent('""'),
|
|
65
|
+
insBs("var(--ui-switch-thumb-inset, 0.125rem)"),
|
|
66
|
+
insIs("var(--ui-switch-thumb-inset, 0.125rem)"),
|
|
67
|
+
shadow("base"),
|
|
68
|
+
]),
|
|
69
|
+
when("&:checked", before(insIs("calc(var(--ui-switch-track-inline-size, 2.75rem) - var(--ui-switch-thumb-size, 1.25rem) - var(--ui-switch-thumb-inset, 0.125rem))"))),
|
|
70
|
+
when("&:active", before(scaleProperty("0.95"))),
|
|
71
|
+
media("(prefers-reduced-motion: reduce)", before(transitionDuration("0s"))),
|
|
72
|
+
mix,
|
|
73
|
+
] }));
|
|
74
|
+
if (children === undefined)
|
|
75
|
+
return track;
|
|
76
|
+
return (_jsxs("label", { mix: [
|
|
77
|
+
hstack({ gap: 2, align: "center" }),
|
|
78
|
+
cursor("pointer"),
|
|
79
|
+
when("&:has(input:disabled)", cursor("not-allowed")),
|
|
80
|
+
], children: [track, children] }));
|
|
81
|
+
};
|
|
82
|
+
}
|