@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,164 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, fg, outline } from "@sdxc/u/color";
|
|
3
|
+
import { opacity, rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor, listStyle, pointerEvents } from "@sdxc/u/general";
|
|
5
|
+
import { flex, gap, inlineFlex, items, justify } from "@sdxc/u/layout";
|
|
6
|
+
import { bs, m, minIs, p, pi } from "@sdxc/u/size";
|
|
7
|
+
import { active, hover, when } from "@sdxc/u/state";
|
|
8
|
+
import { text, textDecoration, weight } from "@sdxc/u/typography";
|
|
9
|
+
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
10
|
+
import { warnIfNoAccessibleLabel, warnIfNoAccessibleName, } from "../utils/warn-if-no-accessible-name.js";
|
|
11
|
+
/**
|
|
12
|
+
* `type` given to a {@link Pagination.Button} carrying an Invoker Command, for
|
|
13
|
+
* which the platform accepts no other value.
|
|
14
|
+
*/
|
|
15
|
+
const INVOKER_TYPE = "button";
|
|
16
|
+
/**
|
|
17
|
+
* Renders the pagination's `<nav>` root, laying its single {@link
|
|
18
|
+
* Pagination.List} child out as a centered row. In dev mode, a root missing
|
|
19
|
+
* `aria-label`/`aria-labelledby` logs a `console.warn` for assistive tech.
|
|
20
|
+
*
|
|
21
|
+
* @param handle Runtime handle carrying the host `<nav>`'s props.
|
|
22
|
+
* @returns The render function producing the navigation landmark's markup.
|
|
23
|
+
* @example
|
|
24
|
+
* <Pagination aria-label={t("pagination.label")}>
|
|
25
|
+
* <Pagination.List>
|
|
26
|
+
* <Pagination.Item>
|
|
27
|
+
* <Pagination.Link href="?page=1" aria-current="page">1</Pagination.Link>
|
|
28
|
+
* </Pagination.Item>
|
|
29
|
+
* </Pagination.List>
|
|
30
|
+
* </Pagination>
|
|
31
|
+
*/
|
|
32
|
+
export function Pagination(handle) {
|
|
33
|
+
return () => {
|
|
34
|
+
let { mix, ...rest } = handle.props;
|
|
35
|
+
warnIfNoAccessibleLabel(handle.props, 'Pagination: needs an "aria-label" or "aria-labelledby" identifying which set of results it paginates for assistive technology.');
|
|
36
|
+
return _jsx("nav", { ...rest, "data-slot": "pagination", mix: [flex(), items("center"), mix] });
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Renders the pagination's `<ul>` list, resetting native list markers and
|
|
41
|
+
* spacing and laying {@link Pagination.Item} children out as a centered row
|
|
42
|
+
* with a small gap between them.
|
|
43
|
+
*
|
|
44
|
+
* @param handle Runtime handle carrying the host `<ul>`'s props.
|
|
45
|
+
* @returns The render function producing the list's markup.
|
|
46
|
+
* @example
|
|
47
|
+
* <Pagination.List>
|
|
48
|
+
* <Pagination.Item>
|
|
49
|
+
* <Pagination.Link href="?page=1" aria-current="page">1</Pagination.Link>
|
|
50
|
+
* </Pagination.Item>
|
|
51
|
+
* <Pagination.Item>
|
|
52
|
+
* <Pagination.Link href="?page=2">2</Pagination.Link>
|
|
53
|
+
* </Pagination.Item>
|
|
54
|
+
* </Pagination.List>
|
|
55
|
+
*/
|
|
56
|
+
Pagination.List = function PaginationList(handle) {
|
|
57
|
+
return () => {
|
|
58
|
+
let { mix, ...rest } = handle.props;
|
|
59
|
+
return (_jsx("ul", { ...rest, "data-slot": "list", mix: [flex(), items("center"), gap("0.25rem"), m("0"), p("0"), listStyle(), mix] }));
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Renders a single `<li>` wrapping one {@link Pagination.Link} or
|
|
64
|
+
* {@link Pagination.Button}, centering its content — this element carries no
|
|
65
|
+
* visual styling of its own beyond the layout needed to hold its child.
|
|
66
|
+
*
|
|
67
|
+
* @param handle Runtime handle carrying the host `<li>`'s props.
|
|
68
|
+
* @returns The render function producing the item's markup.
|
|
69
|
+
* @example
|
|
70
|
+
* <Pagination.Item>
|
|
71
|
+
* <Pagination.Link href="?page=3">3</Pagination.Link>
|
|
72
|
+
* </Pagination.Item>
|
|
73
|
+
*/
|
|
74
|
+
Pagination.Item = function PaginationItem(handle) {
|
|
75
|
+
return () => {
|
|
76
|
+
let { mix, ...rest } = handle.props;
|
|
77
|
+
return _jsx("li", { ...rest, "data-slot": "item", mix: [flex(), items("center"), mix] });
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Renders a page-number destination as a native `<a>`. Setting
|
|
82
|
+
* `aria-current="page"` fills it with the active-page treatment, and
|
|
83
|
+
* `aria-disabled="true"` mutes it and blocks pointer interaction.
|
|
84
|
+
*
|
|
85
|
+
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
86
|
+
* @returns The render function producing the link's markup.
|
|
87
|
+
* @example
|
|
88
|
+
* <Pagination.Link href="?page=4">4</Pagination.Link>
|
|
89
|
+
* @example
|
|
90
|
+
* <Pagination.Link href="?page=5" aria-current="page">5</Pagination.Link>
|
|
91
|
+
* @example
|
|
92
|
+
* <Pagination.Link aria-disabled="true">…</Pagination.Link>
|
|
93
|
+
*/
|
|
94
|
+
Pagination.Link = function PaginationLink(handle) {
|
|
95
|
+
return () => {
|
|
96
|
+
let { mix, ...rest } = handle.props;
|
|
97
|
+
return (_jsx("a", { ...rest, "data-slot": "link", mix: [
|
|
98
|
+
interactiveTransition(),
|
|
99
|
+
inlineFlex(),
|
|
100
|
+
items("center"),
|
|
101
|
+
justify("center"),
|
|
102
|
+
bs("var(--ui-pagination-control-size, 2.25rem)"),
|
|
103
|
+
minIs("var(--ui-pagination-control-size, 2.25rem)"),
|
|
104
|
+
rounded("md"),
|
|
105
|
+
pi("0.75rem"),
|
|
106
|
+
weight(500),
|
|
107
|
+
fg("neutral"),
|
|
108
|
+
hover([bg("neutral.bg-tint-hover"), fg("neutral.emphasis")]),
|
|
109
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
110
|
+
bg("brand.solid"),
|
|
111
|
+
fg("brand.onSolid"),
|
|
112
|
+
]),
|
|
113
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
114
|
+
when('&[aria-disabled="true"]', opacity(50)),
|
|
115
|
+
text("sm"),
|
|
116
|
+
textDecoration("none"),
|
|
117
|
+
when('&[aria-disabled="true"]', [cursor("not-allowed"), pointerEvents()]),
|
|
118
|
+
mix,
|
|
119
|
+
] }));
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Renders a previous/next control as a native `<button>`. A control with
|
|
124
|
+
* `command`/`commandfor` renders `type="button"` first, since the platform's
|
|
125
|
+
* ambiguity check can't see a `type` written after those attributes.
|
|
126
|
+
*
|
|
127
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
128
|
+
* @returns The render function producing the control's markup.
|
|
129
|
+
* @example
|
|
130
|
+
* <Pagination.Button aria-label={t("pagination.previous")} disabled={!hasPreviousPage}>
|
|
131
|
+
* <ChevronLeftIcon aria-hidden />
|
|
132
|
+
* </Pagination.Button>
|
|
133
|
+
* @example
|
|
134
|
+
* <Pagination.Button aria-label={t("pagination.next")} disabled={!hasNextPage}>
|
|
135
|
+
* <ChevronRightIcon aria-hidden />
|
|
136
|
+
* </Pagination.Button>
|
|
137
|
+
*/
|
|
138
|
+
Pagination.Button = function PaginationButton(handle) {
|
|
139
|
+
return () => {
|
|
140
|
+
let { type, children, mix, ...rest } = handle.props;
|
|
141
|
+
let isInvoker = rest.command !== undefined || rest.commandfor !== undefined;
|
|
142
|
+
let resolvedType = type ?? (isInvoker ? INVOKER_TYPE : undefined);
|
|
143
|
+
warnIfNoAccessibleName(handle.props, children, 'Pagination.Button: an icon-only control needs an "aria-label" describing what it does — assistive technology has no accessible text to announce otherwise.');
|
|
144
|
+
return (_jsx("button", { type: resolvedType, ...rest, "data-slot": "button", mix: [
|
|
145
|
+
interactiveTransition(),
|
|
146
|
+
inlineFlex(),
|
|
147
|
+
items("center"),
|
|
148
|
+
justify("center"),
|
|
149
|
+
bs("var(--ui-pagination-control-size, 2.25rem)"),
|
|
150
|
+
minIs("var(--ui-pagination-control-size, 2.25rem)"),
|
|
151
|
+
rounded("md"),
|
|
152
|
+
pi("0.75rem"),
|
|
153
|
+
weight(500),
|
|
154
|
+
fg("neutral"),
|
|
155
|
+
hover([bg("neutral.bg-tint-hover"), fg("neutral.emphasis")]),
|
|
156
|
+
active(bg("neutral.bg-tint-pressed")),
|
|
157
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
158
|
+
when("&:disabled", opacity(50)),
|
|
159
|
+
text("sm"),
|
|
160
|
+
when("&:disabled", cursor("not-allowed")),
|
|
161
|
+
mix,
|
|
162
|
+
], children: children }));
|
|
163
|
+
};
|
|
164
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A floating surface anchored to whatever element opened it, built entirely
|
|
3
|
+
* on the native Popover API: the host carries the `popover` attribute and
|
|
4
|
+
* opens through `popovertarget` or a Command Invoker (`commandfor`/
|
|
5
|
+
* `command="toggle-popover"`) elsewhere on the page, with no positioning
|
|
6
|
+
* logic running in script. Placement rides CSS anchor positioning, using
|
|
7
|
+
* the invoker relationship as an implicit anchor and the `data-placement`
|
|
8
|
+
* attribute to pick which `position-area` it resolves against.
|
|
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 type { AnchorPlacement } from "../utils/placement.js";
|
|
15
|
+
/**
|
|
16
|
+
* Prop types for {@link Popover}.
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace Popover {
|
|
19
|
+
/**
|
|
20
|
+
* Side of the anchor the host renders against, and, for the four corner
|
|
21
|
+
* variants, which anchor edge it aligns to along the perpendicular axis.
|
|
22
|
+
* Each name is a physical viewport side, fixed under any `dir` value.
|
|
23
|
+
*/
|
|
24
|
+
type Placement = AnchorPlacement;
|
|
25
|
+
/**
|
|
26
|
+
* Every native `<div>` attribute, plus the `mix` passthrough, with `id`
|
|
27
|
+
* narrowed to required, since `popovertarget`, `commandfor`, and the host's
|
|
28
|
+
* own implicit CSS anchor reference all target it by that id.
|
|
29
|
+
*/
|
|
30
|
+
interface Props extends Omit<TagProps<"div">, "id" | "popover"> {
|
|
31
|
+
/** Stable id an invoker elsewhere on the page targets to open this host. */
|
|
32
|
+
id: string;
|
|
33
|
+
/**
|
|
34
|
+
* `popover` attribute mode: `"auto"` dismisses on outside click or Escape
|
|
35
|
+
* and closes sibling `"auto"` popovers when shown; `"hint"` layers over an
|
|
36
|
+
* open one without closing it; `"manual"` closes only when hidden explicitly.
|
|
37
|
+
*
|
|
38
|
+
* @default {@link DEFAULT_MODE}
|
|
39
|
+
*/
|
|
40
|
+
popover?: "auto" | "hint" | "manual";
|
|
41
|
+
/** Side of the anchor to render against. Defaults to {@link DEFAULT_PLACEMENT}. */
|
|
42
|
+
placement?: Placement;
|
|
43
|
+
/** The popover's content. */
|
|
44
|
+
children: RemixNode;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Renders the floating surface itself: a `popover`-attributed `<div>`
|
|
49
|
+
* positioned via CSS anchor positioning. The invoker that opens it becomes
|
|
50
|
+
* the implicit anchor its `position-area` resolves against.
|
|
51
|
+
*
|
|
52
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
53
|
+
* @returns The render function producing the surface's markup.
|
|
54
|
+
* @example
|
|
55
|
+
* <button commandfor="account-menu" command="toggle-popover">{t("nav.account")}</button>
|
|
56
|
+
* <Popover id="account-menu" placement="bottom-start">
|
|
57
|
+
* <p>{t("nav.accountMenu.body")}</p>
|
|
58
|
+
* </Popover>
|
|
59
|
+
* @example
|
|
60
|
+
* <Popover id="filters" placement="top" mix={[fade({ duration: durations.normal })]}>
|
|
61
|
+
* <OverlayArrow placement="top">
|
|
62
|
+
* <svg width={12} height={12} viewBox="0 0 12 12">
|
|
63
|
+
* <path d="M0 0 L6 6 L12 0" />
|
|
64
|
+
* </svg>
|
|
65
|
+
* </OverlayArrow>
|
|
66
|
+
* {content}
|
|
67
|
+
* </Popover>
|
|
68
|
+
*/
|
|
69
|
+
export declare function Popover(handle: Handle<Popover.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { inset, positionArea, positionTryFallbacks } from "@sdxc/u/layout";
|
|
3
|
+
import { m, marginLeft, marginRight, mbe, mbs } from "@sdxc/u/size";
|
|
4
|
+
import { data, when } from "@sdxc/u/state";
|
|
5
|
+
import { floatingSurface } from "../styles/floating-surface.js";
|
|
6
|
+
/**
|
|
7
|
+
* Side of the anchor {@link Popover} renders against when `placement` is
|
|
8
|
+
* left unset.
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_PLACEMENT = "bottom";
|
|
11
|
+
/**
|
|
12
|
+
* `popover` attribute mode applied when a consumer leaves it unset, giving
|
|
13
|
+
* the host light-dismiss behavior: it closes on outside click or Escape, and
|
|
14
|
+
* showing it closes any other `"auto"` popover already open.
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_MODE = "auto";
|
|
17
|
+
/**
|
|
18
|
+
* Renders the floating surface itself: a `popover`-attributed `<div>`
|
|
19
|
+
* positioned via CSS anchor positioning. The invoker that opens it becomes
|
|
20
|
+
* the implicit anchor its `position-area` resolves against.
|
|
21
|
+
*
|
|
22
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
23
|
+
* @returns The render function producing the surface's markup.
|
|
24
|
+
* @example
|
|
25
|
+
* <button commandfor="account-menu" command="toggle-popover">{t("nav.account")}</button>
|
|
26
|
+
* <Popover id="account-menu" placement="bottom-start">
|
|
27
|
+
* <p>{t("nav.accountMenu.body")}</p>
|
|
28
|
+
* </Popover>
|
|
29
|
+
* @example
|
|
30
|
+
* <Popover id="filters" placement="top" mix={[fade({ duration: durations.normal })]}>
|
|
31
|
+
* <OverlayArrow placement="top">
|
|
32
|
+
* <svg width={12} height={12} viewBox="0 0 12 12">
|
|
33
|
+
* <path d="M0 0 L6 6 L12 0" />
|
|
34
|
+
* </svg>
|
|
35
|
+
* </OverlayArrow>
|
|
36
|
+
* {content}
|
|
37
|
+
* </Popover>
|
|
38
|
+
*/
|
|
39
|
+
export function Popover(handle) {
|
|
40
|
+
return () => {
|
|
41
|
+
let { id, popover, placement, children, mix, ...rest } = handle.props;
|
|
42
|
+
let resolvedMode = popover ?? DEFAULT_MODE;
|
|
43
|
+
let resolvedPlacement = placement ?? DEFAULT_PLACEMENT;
|
|
44
|
+
return (_jsx("div", { id: id, popover: resolvedMode, "data-placement": resolvedPlacement, ...rest, mix: [
|
|
45
|
+
floatingSurface(),
|
|
46
|
+
m("0"),
|
|
47
|
+
inset("auto"),
|
|
48
|
+
when('&[data-placement^="top"]', mbe("var(--ui-popover-offset, 0.5rem)")),
|
|
49
|
+
when('&[data-placement^="bottom"]', mbs("var(--ui-popover-offset, 0.5rem)")),
|
|
50
|
+
when('&[data-placement^="left"]', marginRight("var(--ui-popover-offset, 0.5rem)")),
|
|
51
|
+
when('&[data-placement^="right"]', marginLeft("var(--ui-popover-offset, 0.5rem)")),
|
|
52
|
+
positionTryFallbacks("flip-block", "flip-inline", "flip-block flip-inline"),
|
|
53
|
+
data("placement", "top", positionArea("top")),
|
|
54
|
+
data("placement", "top-start", positionArea("top left")),
|
|
55
|
+
data("placement", "top-end", positionArea("top right")),
|
|
56
|
+
data("placement", "bottom", positionArea("bottom")),
|
|
57
|
+
data("placement", "bottom-start", positionArea("bottom left")),
|
|
58
|
+
data("placement", "bottom-end", positionArea("bottom right")),
|
|
59
|
+
data("placement", "left", positionArea("left")),
|
|
60
|
+
data("placement", "left-start", positionArea("left top")),
|
|
61
|
+
data("placement", "left-end", positionArea("left bottom")),
|
|
62
|
+
data("placement", "right", positionArea("right")),
|
|
63
|
+
data("placement", "right-start", positionArea("right top")),
|
|
64
|
+
data("placement", "right-end", positionArea("right bottom")),
|
|
65
|
+
mix,
|
|
66
|
+
], children: children }));
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A styled native `<progress>` control paired with an optional value label,
|
|
3
|
+
* stacked in a single column so a caption can sit alongside the bar it
|
|
4
|
+
* describes. The indicator's track and fill read entirely from the control's
|
|
5
|
+
* own `value`/`max` attributes and its native `:indeterminate` state, so a
|
|
6
|
+
* value-less indicator already renders as busy with zero library JavaScript.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
12
|
+
/**
|
|
13
|
+
* Prop types for {@link ProgressBar} and its compound parts.
|
|
14
|
+
*/
|
|
15
|
+
export declare namespace ProgressBar {
|
|
16
|
+
/**
|
|
17
|
+
* Every native `<div>` attribute, unchanged, plus the `mix` passthrough.
|
|
18
|
+
* The root only supplies the column layout stacking {@link
|
|
19
|
+
* ProgressBar.Indicator} and {@link ProgressBar.ValueLabel}.
|
|
20
|
+
*/
|
|
21
|
+
interface Props extends TagProps<"div"> {
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Every native `<progress>` attribute, unchanged, plus the `mix`
|
|
25
|
+
* passthrough. Leaving `value` unset renders the indeterminate state;
|
|
26
|
+
* `max` defaults to {@link DEFAULT_MAX}.
|
|
27
|
+
*/
|
|
28
|
+
interface IndicatorProps extends TagProps<"progress"> {
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Every native `<span>` attribute, unchanged, plus the `mix` passthrough.
|
|
32
|
+
*/
|
|
33
|
+
interface ValueLabelProps extends TagProps<"span"> {
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Renders the root column: a `<div>` stacking {@link ProgressBar.Indicator}
|
|
38
|
+
* and an optional {@link ProgressBar.ValueLabel}, carrying no ARIA of its
|
|
39
|
+
* own since the `<progress>` inside already exposes progressbar semantics.
|
|
40
|
+
*
|
|
41
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
42
|
+
* @returns The render function producing the root column's markup.
|
|
43
|
+
* @example
|
|
44
|
+
* <ProgressBar>
|
|
45
|
+
* <ProgressBar.Indicator value={70} max={100} aria-label={t("upload.progress")} />
|
|
46
|
+
* <ProgressBar.ValueLabel>{t("upload.percent", { value: 70 })}</ProgressBar.ValueLabel>
|
|
47
|
+
* </ProgressBar>
|
|
48
|
+
*/
|
|
49
|
+
export declare function ProgressBar(handle: Handle<ProgressBar.Props>): () => import("remix/ui").RemixElement;
|
|
50
|
+
export declare namespace ProgressBar {
|
|
51
|
+
var Indicator: (handle: Handle<ProgressBar.IndicatorProps>) => () => import("remix/ui").RemixElement;
|
|
52
|
+
var ValueLabel: (handle: Handle<ProgressBar.ValueLabelProps>) => () => import("remix/ui").RemixElement;
|
|
53
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, border, fg } from "@sdxc/u/color";
|
|
3
|
+
import { rounded, transition, transitionDuration } from "@sdxc/u/effects";
|
|
4
|
+
import { appearance, block, flex, flexCol, gap } from "@sdxc/u/layout";
|
|
5
|
+
import { overflow } from "@sdxc/u/overflow";
|
|
6
|
+
import { media } from "@sdxc/u/responsive";
|
|
7
|
+
import { bs, is, m, p } from "@sdxc/u/size";
|
|
8
|
+
import { when } from "@sdxc/u/state";
|
|
9
|
+
import { text } from "@sdxc/u/typography";
|
|
10
|
+
import { warnIfNoAccessibleLabel } from "../utils/warn-if-no-accessible-name.js";
|
|
11
|
+
/** Native `max` value {@link ProgressBar.Indicator} falls back to when `max` is omitted, so a bare `value` reads as a percentage without passing `max={100}` every time. */
|
|
12
|
+
const DEFAULT_MAX = 100;
|
|
13
|
+
/**
|
|
14
|
+
* Renders the root column: a `<div>` stacking {@link ProgressBar.Indicator}
|
|
15
|
+
* and an optional {@link ProgressBar.ValueLabel}, carrying no ARIA of its
|
|
16
|
+
* own since the `<progress>` inside already exposes progressbar semantics.
|
|
17
|
+
*
|
|
18
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
19
|
+
* @returns The render function producing the root column's markup.
|
|
20
|
+
* @example
|
|
21
|
+
* <ProgressBar>
|
|
22
|
+
* <ProgressBar.Indicator value={70} max={100} aria-label={t("upload.progress")} />
|
|
23
|
+
* <ProgressBar.ValueLabel>{t("upload.percent", { value: 70 })}</ProgressBar.ValueLabel>
|
|
24
|
+
* </ProgressBar>
|
|
25
|
+
*/
|
|
26
|
+
export function ProgressBar(handle) {
|
|
27
|
+
return () => {
|
|
28
|
+
let { mix, ...rest } = handle.props;
|
|
29
|
+
return _jsx("div", { ...rest, mix: [flex(), flexCol(), gap("0.25rem"), mix] });
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Renders the busy/progress indicator: a native `<progress>` restyled as a
|
|
34
|
+
* pill track. Firefox paints from the host itself, so track and fill colors
|
|
35
|
+
* mirror onto the `::-webkit-*`/`::-moz-*` pseudo-elements each engine paints.
|
|
36
|
+
*
|
|
37
|
+
* @param handle Runtime handle carrying the host `<progress>`'s props.
|
|
38
|
+
* @returns The render function producing the indicator's markup.
|
|
39
|
+
* @example
|
|
40
|
+
* <ProgressBar.Indicator value={70} max={100} aria-label={t("upload.progress")} />
|
|
41
|
+
* @example
|
|
42
|
+
* <ProgressBar.Indicator aria-label={t("upload.progress")} mix={[shimmer()]} />
|
|
43
|
+
*/
|
|
44
|
+
ProgressBar.Indicator = function ProgressBarIndicator(handle) {
|
|
45
|
+
return () => {
|
|
46
|
+
let { mix, max, ...rest } = handle.props;
|
|
47
|
+
let resolvedMax = max ?? DEFAULT_MAX;
|
|
48
|
+
warnIfNoAccessibleLabel(handle.props, "ProgressBar.Indicator: a progress indicator with no `aria-label` or `aria-labelledby` needs one describing what it tracks — assistive technology has no accessible name to announce otherwise.");
|
|
49
|
+
return (_jsx("progress", { max: resolvedMax, ...rest, mix: [
|
|
50
|
+
appearance(),
|
|
51
|
+
block(),
|
|
52
|
+
is("full"),
|
|
53
|
+
bs("var(--ui-progress-bar-block-size, 0.5rem)"),
|
|
54
|
+
m("0"),
|
|
55
|
+
p("0"),
|
|
56
|
+
overflow("hidden"),
|
|
57
|
+
rounded("full"),
|
|
58
|
+
bg("neutral.border"),
|
|
59
|
+
when("&::-webkit-progress-bar", [bg("neutral.border"), rounded("full")]),
|
|
60
|
+
when("&::-webkit-progress-value", [
|
|
61
|
+
bg("brand.solid"),
|
|
62
|
+
rounded("full"),
|
|
63
|
+
transition("all"),
|
|
64
|
+
]),
|
|
65
|
+
when("&::-moz-progress-bar", [bg("brand.solid"), rounded("full"), transition("all")]),
|
|
66
|
+
border("none"),
|
|
67
|
+
media("(prefers-reduced-motion: reduce)", [
|
|
68
|
+
when("&::-webkit-progress-value", transitionDuration("0s")),
|
|
69
|
+
when("&::-moz-progress-bar", transitionDuration("0s")),
|
|
70
|
+
]),
|
|
71
|
+
mix,
|
|
72
|
+
] }));
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Renders the indicator's caption: a `<span>` sized as a small run of body
|
|
77
|
+
* copy in the neutral muted foreground color, for a percentage or status
|
|
78
|
+
* string placed alongside {@link ProgressBar.Indicator}.
|
|
79
|
+
*
|
|
80
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
81
|
+
* @returns The render function producing the value label's markup.
|
|
82
|
+
* @example
|
|
83
|
+
* <ProgressBar.ValueLabel>{t("upload.percent", { value: 70 })}</ProgressBar.ValueLabel>
|
|
84
|
+
*/
|
|
85
|
+
ProgressBar.ValueLabel = function ProgressBarValueLabel(handle) {
|
|
86
|
+
return () => {
|
|
87
|
+
let { mix, ...rest } = handle.props;
|
|
88
|
+
return _jsx("span", { ...rest, mix: [fg("neutral"), text("sm"), mix] });
|
|
89
|
+
};
|
|
90
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A set of mutually exclusive options built from native `<input
|
|
3
|
+
* type="radio">` controls sharing one grouping name, rendered as a
|
|
4
|
+
* `role="radiogroup"` host wrapping a run of {@link RadioGroup.Radio}
|
|
5
|
+
* instances. Each option pairs a visually hidden native input — carrying
|
|
6
|
+
* every focus, keyboard, and form-submission semantic the platform already
|
|
7
|
+
* provides — with a styled visual indicator that reads the input's own
|
|
8
|
+
* `:checked` and `:focus-visible` states through sibling selectors.
|
|
9
|
+
*
|
|
10
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
11
|
+
* @copyright Sergio Xalambrí 2026
|
|
12
|
+
*/
|
|
13
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/ui";
|
|
14
|
+
/**
|
|
15
|
+
* Prop types for {@link RadioGroup} and its {@link RadioGroup.Radio}
|
|
16
|
+
* compound part.
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace RadioGroup {
|
|
19
|
+
/**
|
|
20
|
+
* Axis a group's options lay out along: a single column, or a single row.
|
|
21
|
+
*/
|
|
22
|
+
type Orientation = "horizontal" | "vertical";
|
|
23
|
+
/**
|
|
24
|
+
* Value {@link RadioGroup} stores in component context so every
|
|
25
|
+
* {@link RadioGroup.Radio} nested inside shares the same native grouping
|
|
26
|
+
* name without a consumer repeating it on each option.
|
|
27
|
+
*/
|
|
28
|
+
interface Context {
|
|
29
|
+
/** Shared `name` every {@link RadioGroup.Radio} reads unless it sets its own. */
|
|
30
|
+
name: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Props accepted by {@link RadioGroup}.
|
|
34
|
+
*/
|
|
35
|
+
interface Props extends TagProps<"div"> {
|
|
36
|
+
/**
|
|
37
|
+
* Native grouping name shared by every {@link RadioGroup.Radio} nested
|
|
38
|
+
* inside. Defaults to the group's own {@link Handle.id | stable
|
|
39
|
+
* instance id} so options group correctly without a consumer setting one.
|
|
40
|
+
*/
|
|
41
|
+
name?: string;
|
|
42
|
+
/** Layout axis. Defaults to {@link DEFAULT_ORIENTATION}. */
|
|
43
|
+
orientation?: Orientation;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Props accepted by {@link RadioGroup.Radio}.
|
|
47
|
+
*/
|
|
48
|
+
interface RadioProps extends Omit<TagProps<"label">, "children"> {
|
|
49
|
+
/** Value submitted with the enclosing form when this option is selected. */
|
|
50
|
+
value: string;
|
|
51
|
+
/**
|
|
52
|
+
* Native grouping name for this option's underlying input. Defaults to
|
|
53
|
+
* the name provided by the nearest ancestor {@link RadioGroup} — set
|
|
54
|
+
* this only to opt a single option out of its group's shared name.
|
|
55
|
+
*/
|
|
56
|
+
name?: string;
|
|
57
|
+
/** Whether this option starts selected, for a form that leaves selection tracking to the browser. */
|
|
58
|
+
defaultChecked?: boolean;
|
|
59
|
+
/** Whether this option is selected, for a form that tracks selection itself. */
|
|
60
|
+
checked?: boolean;
|
|
61
|
+
/** Whether this option is inert and excluded from the group's tab order. */
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
/** Marks the enclosing native radio group as requiring one option selected. */
|
|
64
|
+
required?: boolean;
|
|
65
|
+
/** The option's visible label text, associated with the input by native nesting. */
|
|
66
|
+
children?: RemixNode;
|
|
67
|
+
/**
|
|
68
|
+
* Per-part styling for the option's hidden `input` and visible
|
|
69
|
+
* `indicator` elements, layered after each part's own built-in styling.
|
|
70
|
+
* Use the `mix` prop instead to style the option's outer `<label>` host.
|
|
71
|
+
*/
|
|
72
|
+
parts?: {
|
|
73
|
+
/** Additional mixin(s) applied to the hidden native `<input type="radio">`. */
|
|
74
|
+
input?: TagProps<"input">["mix"];
|
|
75
|
+
/** Additional mixin(s) applied to the visible indicator `<span>`. */
|
|
76
|
+
indicator?: TagProps<"span">["mix"];
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Renders the group host: a `role="radiogroup"` `<div>` laying its
|
|
82
|
+
* {@link RadioGroup.Radio} options in a column, or a row when
|
|
83
|
+
* `orientation` is `"horizontal"`, giving every option a shared, stable `name`.
|
|
84
|
+
*
|
|
85
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link RadioGroup.Context}.
|
|
86
|
+
* @returns The render function producing the group's markup.
|
|
87
|
+
* @example
|
|
88
|
+
* <RadioGroup aria-label={t("shipping.method")}>
|
|
89
|
+
* <RadioGroup.Radio value="standard">{t("shipping.standard")}</RadioGroup.Radio>
|
|
90
|
+
* <RadioGroup.Radio value="express">{t("shipping.express")}</RadioGroup.Radio>
|
|
91
|
+
* </RadioGroup>
|
|
92
|
+
* @example
|
|
93
|
+
* <RadioGroup aria-label={t("size.label")} orientation="horizontal">
|
|
94
|
+
* <RadioGroup.Radio value="sm">{t("size.small")}</RadioGroup.Radio>
|
|
95
|
+
* <RadioGroup.Radio value="md">{t("size.medium")}</RadioGroup.Radio>
|
|
96
|
+
* <RadioGroup.Radio value="lg">{t("size.large")}</RadioGroup.Radio>
|
|
97
|
+
* </RadioGroup>
|
|
98
|
+
*/
|
|
99
|
+
export declare function RadioGroup(handle: Handle<RadioGroup.Props, RadioGroup.Context>): () => import("remix/ui").RemixElement;
|
|
100
|
+
export declare namespace RadioGroup {
|
|
101
|
+
var Radio: (handle: Handle<RadioGroup.RadioProps>) => () => import("remix/ui").RemixElement;
|
|
102
|
+
}
|
|
@@ -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, border, fg, outline } from "@sdxc/u/color";
|
|
4
|
+
import { opacity, rounded, transition } from "@sdxc/u/effects";
|
|
5
|
+
import { cursor, pseudoContent } from "@sdxc/u/general";
|
|
6
|
+
import { flex, flexCol, flexRow, gap, items, justify, relative, shrink } from "@sdxc/u/layout";
|
|
7
|
+
import { bs, is } from "@sdxc/u/size";
|
|
8
|
+
import { after, precededBy, when } from "@sdxc/u/state";
|
|
9
|
+
import { scale } from "@sdxc/u/transform";
|
|
10
|
+
import { text } from "@sdxc/u/typography";
|
|
11
|
+
import { attrs } from "remix/ui";
|
|
12
|
+
/**
|
|
13
|
+
* `role="radiogroup"` applied through {@link attrs} unless a consumer
|
|
14
|
+
* supplies its own `role`, announcing the host as a radio group landmark to
|
|
15
|
+
* assistive technology.
|
|
16
|
+
*/
|
|
17
|
+
const DEFAULT_ROLE = "radiogroup";
|
|
18
|
+
/**
|
|
19
|
+
* Default {@link RadioGroup.Props} orientation, applied when `orientation`
|
|
20
|
+
* is omitted, laying options out in a single column.
|
|
21
|
+
*/
|
|
22
|
+
const DEFAULT_ORIENTATION = "vertical";
|
|
23
|
+
/**
|
|
24
|
+
* Renders the group host: a `role="radiogroup"` `<div>` laying its
|
|
25
|
+
* {@link RadioGroup.Radio} options in a column, or a row when
|
|
26
|
+
* `orientation` is `"horizontal"`, giving every option a shared, stable `name`.
|
|
27
|
+
*
|
|
28
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link RadioGroup.Context}.
|
|
29
|
+
* @returns The render function producing the group's markup.
|
|
30
|
+
* @example
|
|
31
|
+
* <RadioGroup aria-label={t("shipping.method")}>
|
|
32
|
+
* <RadioGroup.Radio value="standard">{t("shipping.standard")}</RadioGroup.Radio>
|
|
33
|
+
* <RadioGroup.Radio value="express">{t("shipping.express")}</RadioGroup.Radio>
|
|
34
|
+
* </RadioGroup>
|
|
35
|
+
* @example
|
|
36
|
+
* <RadioGroup aria-label={t("size.label")} orientation="horizontal">
|
|
37
|
+
* <RadioGroup.Radio value="sm">{t("size.small")}</RadioGroup.Radio>
|
|
38
|
+
* <RadioGroup.Radio value="md">{t("size.medium")}</RadioGroup.Radio>
|
|
39
|
+
* <RadioGroup.Radio value="lg">{t("size.large")}</RadioGroup.Radio>
|
|
40
|
+
* </RadioGroup>
|
|
41
|
+
*/
|
|
42
|
+
export function RadioGroup(handle) {
|
|
43
|
+
return () => {
|
|
44
|
+
let { name, orientation, mix, ...rest } = handle.props;
|
|
45
|
+
let resolvedName = name ?? handle.id;
|
|
46
|
+
let resolvedOrientation = orientation ?? DEFAULT_ORIENTATION;
|
|
47
|
+
handle.context.set({ name: resolvedName });
|
|
48
|
+
return (_jsx("div", { "data-orientation": resolvedOrientation, "aria-orientation": resolvedOrientation, ...rest, mix: [
|
|
49
|
+
attrs({ role: DEFAULT_ROLE }),
|
|
50
|
+
flex(),
|
|
51
|
+
flexCol(),
|
|
52
|
+
when('&[data-orientation="horizontal"]', flexRow()),
|
|
53
|
+
gap("0.5rem"),
|
|
54
|
+
when('&[data-orientation="horizontal"]', gap("1rem")),
|
|
55
|
+
mix,
|
|
56
|
+
] }));
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Renders a single option: a `<label>` pairing a hidden native `<input
|
|
61
|
+
* type="radio">` with a styled indicator driven by its checked, focus, and
|
|
62
|
+
* disabled state; add `ariaChecked()` via `parts.input` for `aria-checked`.
|
|
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
|
+
* <RadioGroup.Radio value="dog">{t("pet.dog")}</RadioGroup.Radio>
|
|
68
|
+
* @example
|
|
69
|
+
* <RadioGroup.Radio value="cat" defaultChecked>{t("pet.cat")}</RadioGroup.Radio>
|
|
70
|
+
* @example
|
|
71
|
+
* <RadioGroup.Radio value="hamster" disabled>{t("pet.hamster")}</RadioGroup.Radio>
|
|
72
|
+
*/
|
|
73
|
+
RadioGroup.Radio = function RadioGroupRadio(handle) {
|
|
74
|
+
return () => {
|
|
75
|
+
let { value, name, checked, defaultChecked, disabled, required, children, parts, mix, ...rest } = handle.props;
|
|
76
|
+
let context = handle.context.get(RadioGroup);
|
|
77
|
+
let resolvedName = name ?? context.name;
|
|
78
|
+
return (_jsxs("label", { ...rest, mix: [
|
|
79
|
+
flex(),
|
|
80
|
+
cursor("default"),
|
|
81
|
+
items("center"),
|
|
82
|
+
text("sm"),
|
|
83
|
+
when("&:has(input:disabled)", [cursor("not-allowed"), opacity(50)]),
|
|
84
|
+
gap("0.5rem"),
|
|
85
|
+
fg("neutral.emphasis"),
|
|
86
|
+
mix,
|
|
87
|
+
], children: [_jsx("input", { type: "radio", id: handle.id, value: value, name: resolvedName, checked: checked, defaultChecked: defaultChecked, disabled: disabled, required: required, mix: [visuallyHidden(), parts?.input] }), _jsx("span", { "data-slot": "indicator", mix: [
|
|
88
|
+
relative(),
|
|
89
|
+
flex(),
|
|
90
|
+
shrink(),
|
|
91
|
+
items("center"),
|
|
92
|
+
justify("center"),
|
|
93
|
+
is("var(--ui-radio-size, 1.25rem)"),
|
|
94
|
+
bs("var(--ui-radio-size, 1.25rem)"),
|
|
95
|
+
after([
|
|
96
|
+
is("var(--ui-radio-mark-size, 0.625rem)"),
|
|
97
|
+
bs("var(--ui-radio-mark-size, 0.625rem)"),
|
|
98
|
+
rounded("full"),
|
|
99
|
+
bg("brand.onSolid"),
|
|
100
|
+
transition("transform"),
|
|
101
|
+
pseudoContent('""'),
|
|
102
|
+
scale(0),
|
|
103
|
+
]),
|
|
104
|
+
rounded("full"),
|
|
105
|
+
border({ color: "neutral.strong", width: 2 }),
|
|
106
|
+
bg("neutral.tint"),
|
|
107
|
+
transition("background-color, border-color"),
|
|
108
|
+
precededBy("input:checked", after(scale(1))),
|
|
109
|
+
precededBy("input:checked", [border("brand.solid"), bg("brand.solid")]),
|
|
110
|
+
precededBy("input:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
111
|
+
parts?.indicator,
|
|
112
|
+
] }), children] }));
|
|
113
|
+
};
|
|
114
|
+
};
|