@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,220 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { GripVerticalIcon } from "@sdxc/icons";
|
|
3
|
+
import { bg, borderEdge, fg, outline } from "@sdxc/u/color";
|
|
4
|
+
import { opacity, rounded } from "@sdxc/u/effects";
|
|
5
|
+
import { cursor } from "@sdxc/u/general";
|
|
6
|
+
import { container, flex, flexCol, gap, grid, gridTemplate, items, virtualize, } from "@sdxc/u/layout";
|
|
7
|
+
import { at } from "@sdxc/u/responsive";
|
|
8
|
+
import { mbs, pb, pbs, pi } from "@sdxc/u/size";
|
|
9
|
+
import { active, data, hover, not, when } from "@sdxc/u/state";
|
|
10
|
+
import { text, textTransform, tracking, weight } from "@sdxc/u/typography";
|
|
11
|
+
import { attrs } from "remix/ui";
|
|
12
|
+
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
13
|
+
import { panelChrome } from "../styles/panel-chrome.js";
|
|
14
|
+
import { warnIfNoAccessibleLabel } from "../utils/warn-if-no-accessible-name.js";
|
|
15
|
+
import { SentinelRow } from "./sentinel-row.js";
|
|
16
|
+
/**
|
|
17
|
+
* Named container {@link GridList} declares on its own host, so its inner
|
|
18
|
+
* row-list wrapper can react to the list's own width — switching a `"grid"`
|
|
19
|
+
* layout's column count, in particular.
|
|
20
|
+
*/
|
|
21
|
+
const CONTAINER_NAME = "ui-grid-list";
|
|
22
|
+
/** Arrangement {@link GridList} falls back to when `layout` is omitted. */
|
|
23
|
+
const DEFAULT_LAYOUT = "stack";
|
|
24
|
+
/** `role="grid"` applied to {@link GridList} through {@link attrs} unless a consumer supplies its own `role`. */
|
|
25
|
+
const DEFAULT_ROLE = "grid";
|
|
26
|
+
/** `role="row"` applied to {@link GridList.Item} through {@link attrs} unless a consumer supplies its own `role`. */
|
|
27
|
+
const DEFAULT_ITEM_ROLE = "row";
|
|
28
|
+
/**
|
|
29
|
+
* Tab stop {@link GridList.Item} falls back to when no explicit `tabIndex` is
|
|
30
|
+
* set, so every row stays individually reachable in ordinary Tab order
|
|
31
|
+
* before a keyboard-navigation behavior collapses the list to one stop.
|
|
32
|
+
*/
|
|
33
|
+
const DEFAULT_ITEM_TAB_INDEX = 0;
|
|
34
|
+
/** `role="rowgroup"` applied to {@link GridList.Section} through {@link attrs} unless a consumer supplies its own `role`. */
|
|
35
|
+
const DEFAULT_SECTION_ROLE = "rowgroup";
|
|
36
|
+
/** `role="gridcell"` applied to {@link GridList.DragHandle} through {@link attrs} unless a consumer supplies its own `role`. */
|
|
37
|
+
const DEFAULT_DRAG_HANDLE_ROLE = "gridcell";
|
|
38
|
+
/**
|
|
39
|
+
* Marker {@link GridList.DragHandle} always carries as `data-drag-handle`
|
|
40
|
+
* via {@link attrs} unless overridden, so a reorder behavior can tell where
|
|
41
|
+
* within the row a drag gesture should originate.
|
|
42
|
+
*/
|
|
43
|
+
const DEFAULT_DRAG_HANDLE_MARKER = true;
|
|
44
|
+
/**
|
|
45
|
+
* Renders the list's root host as a bordered `<div>` with `role="grid"`,
|
|
46
|
+
* keeping its row-list layer in an inner wrapper since a `@container` query
|
|
47
|
+
* can't resolve against the host that declares it; reach `parts.list` to adjust it.
|
|
48
|
+
*
|
|
49
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
50
|
+
* @returns The render function producing the list's markup.
|
|
51
|
+
* @example
|
|
52
|
+
* <GridList aria-label={t("playlist.title")}>
|
|
53
|
+
* <GridList.Item id="track-1">{t("playlist.track", { title: "Intro" })}</GridList.Item>
|
|
54
|
+
* <GridList.Item id="track-2">{t("playlist.track", { title: "Chorus" })}</GridList.Item>
|
|
55
|
+
* </GridList>
|
|
56
|
+
* @example
|
|
57
|
+
* <GridList aria-label={t("gallery.title")} layout="grid">
|
|
58
|
+
* <GridList.Item id="photo-1">{t("gallery.photo", { name: "Sunset" })}</GridList.Item>
|
|
59
|
+
* <GridList.Item id="photo-2">{t("gallery.photo", { name: "Harbor" })}</GridList.Item>
|
|
60
|
+
* </GridList>
|
|
61
|
+
*/
|
|
62
|
+
export function GridList(handle) {
|
|
63
|
+
return () => {
|
|
64
|
+
let { layout, children, parts, mix, ...rest } = handle.props;
|
|
65
|
+
let resolvedLayout = layout ?? DEFAULT_LAYOUT;
|
|
66
|
+
warnIfNoAccessibleLabel(handle.props, 'GridList: needs an "aria-label" or "aria-labelledby" describing its contents for assistive technology.');
|
|
67
|
+
return (_jsx("div", { ...rest, mix: [
|
|
68
|
+
attrs({ role: DEFAULT_ROLE }),
|
|
69
|
+
panelChrome(),
|
|
70
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
71
|
+
pb(2),
|
|
72
|
+
pi(2),
|
|
73
|
+
outline("none"),
|
|
74
|
+
container(CONTAINER_NAME),
|
|
75
|
+
mix,
|
|
76
|
+
], children: _jsx("div", { "data-slot": "list", "data-layout": resolvedLayout, mix: [
|
|
77
|
+
flex(),
|
|
78
|
+
flexCol(),
|
|
79
|
+
gap(1),
|
|
80
|
+
virtualize("auto var(--ui-grid-list-intrinsic-size, 32rem)"),
|
|
81
|
+
data("layout", "grid", [
|
|
82
|
+
grid(),
|
|
83
|
+
gap("0.5rem"),
|
|
84
|
+
gridTemplate({ columns: "repeat(2, minmax(0, 1fr))" }),
|
|
85
|
+
at("40rem", CONTAINER_NAME, gridTemplate({ columns: "repeat(3, minmax(0, 1fr))" })),
|
|
86
|
+
at("48rem", CONTAINER_NAME, gridTemplate({ columns: "repeat(4, minmax(0, 1fr))" })),
|
|
87
|
+
]),
|
|
88
|
+
parts?.list,
|
|
89
|
+
], children: children }) }));
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Renders a single row: a `<div>` carrying `role="row"`, its `id` mirrored
|
|
94
|
+
* onto a `data-rmx-key` attribute so a paired selection, keyboard-navigation, or
|
|
95
|
+
* reorder behavior can correlate the row with its own state.
|
|
96
|
+
*
|
|
97
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
98
|
+
* @returns The render function producing the row's markup.
|
|
99
|
+
* @example
|
|
100
|
+
* <GridList.Item id="track-1">{t("playlist.track", { title: "Intro" })}</GridList.Item>
|
|
101
|
+
* @example
|
|
102
|
+
* <GridList.Item id="track-2" aria-selected="true">
|
|
103
|
+
* {t("playlist.track", { title: "Chorus" })}
|
|
104
|
+
* </GridList.Item>
|
|
105
|
+
*/
|
|
106
|
+
GridList.Item = function GridListItem(handle) {
|
|
107
|
+
return () => {
|
|
108
|
+
let { id, mix, ...rest } = handle.props;
|
|
109
|
+
return (_jsx("div", { ...rest, id: id, "data-rmx-key": id, mix: [
|
|
110
|
+
interactiveTransition(),
|
|
111
|
+
attrs({ role: DEFAULT_ITEM_ROLE, tabIndex: DEFAULT_ITEM_TAB_INDEX }),
|
|
112
|
+
flex(),
|
|
113
|
+
items("center"),
|
|
114
|
+
gap(2),
|
|
115
|
+
rounded("md"),
|
|
116
|
+
pb(2),
|
|
117
|
+
pi(2),
|
|
118
|
+
fg("neutral.emphasis"),
|
|
119
|
+
hover(bg("neutral.bg-tint-hover")),
|
|
120
|
+
active(bg("neutral.bg-tint-pressed")),
|
|
121
|
+
when("&:focus", bg("neutral.bg-tint-hover")),
|
|
122
|
+
when('&[aria-selected="true"]', bg("brand.tint")),
|
|
123
|
+
when('&[aria-disabled="true"]', opacity(50)),
|
|
124
|
+
cursor("default"),
|
|
125
|
+
outline("none"),
|
|
126
|
+
mix,
|
|
127
|
+
] }));
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Renders a titled group of rows: a `<div>` carrying `role="rowgroup"`,
|
|
132
|
+
* stacking an optional {@link GridList.Header} above its {@link GridList.Item}
|
|
133
|
+
* rows, with a block-start rule before every section but the first.
|
|
134
|
+
*
|
|
135
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
136
|
+
* @returns The render function producing the section's markup.
|
|
137
|
+
* @example
|
|
138
|
+
* <GridList.Section aria-labelledby="recents-heading">
|
|
139
|
+
* <GridList.Header id="recents-heading">{t("playlist.recents")}</GridList.Header>
|
|
140
|
+
* <GridList.Item id="track-1">{t("playlist.track", { title: "Intro" })}</GridList.Item>
|
|
141
|
+
* </GridList.Section>
|
|
142
|
+
*/
|
|
143
|
+
GridList.Section = function GridListSection(handle) {
|
|
144
|
+
return () => {
|
|
145
|
+
let { mix, ...rest } = handle.props;
|
|
146
|
+
return (_jsx("div", { ...rest, mix: [
|
|
147
|
+
attrs({ role: DEFAULT_SECTION_ROLE }),
|
|
148
|
+
flex(),
|
|
149
|
+
flexCol(),
|
|
150
|
+
gap(1),
|
|
151
|
+
not(":first-child", [
|
|
152
|
+
mbs(2),
|
|
153
|
+
pbs(2),
|
|
154
|
+
borderEdge("block-start", { color: "neutral", width: 1 }),
|
|
155
|
+
]),
|
|
156
|
+
mix,
|
|
157
|
+
] }));
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Renders a section's label: a `<header>` styled as small, muted, uppercase
|
|
162
|
+
* text for the {@link GridList.Item} rows nested beneath it in a
|
|
163
|
+
* {@link GridList.Section}; point the section's `aria-labelledby` at its `id`.
|
|
164
|
+
*
|
|
165
|
+
* @param handle Runtime handle carrying the host `<header>`'s props.
|
|
166
|
+
* @returns The render function producing the label's markup.
|
|
167
|
+
* @example
|
|
168
|
+
* <GridList.Header id="recents-heading">{t("playlist.recents")}</GridList.Header>
|
|
169
|
+
*/
|
|
170
|
+
GridList.Header = function GridListHeader(handle) {
|
|
171
|
+
return () => {
|
|
172
|
+
let { mix, ...rest } = handle.props;
|
|
173
|
+
return (_jsx("header", { ...rest, mix: [
|
|
174
|
+
pb(1),
|
|
175
|
+
pi(2),
|
|
176
|
+
weight("semibold"),
|
|
177
|
+
tracking("wider"),
|
|
178
|
+
fg("neutral.muted"),
|
|
179
|
+
text("xs"),
|
|
180
|
+
textTransform("uppercase"),
|
|
181
|
+
mix,
|
|
182
|
+
] }));
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Renders a decorative sentinel row: a `<div>` styled as centered, muted
|
|
187
|
+
* small text sized to match {@link GridList.Item}'s vertical rhythm, ready to
|
|
188
|
+
* hold whatever loading indicator a paired enhancement supplies as `children`.
|
|
189
|
+
*
|
|
190
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
191
|
+
* @returns The render function producing the sentinel row's markup.
|
|
192
|
+
* @example
|
|
193
|
+
* <GridList.LoadMoreItem>{t("playlist.loadingMore")}</GridList.LoadMoreItem>
|
|
194
|
+
*/
|
|
195
|
+
GridList.LoadMoreItem = SentinelRow;
|
|
196
|
+
/**
|
|
197
|
+
* Renders the drag-grab element of a row: a native `<button type="button">`
|
|
198
|
+
* written before the consumer's own attributes, so a `command`/`commandfor`
|
|
199
|
+
* pair still runs inside a `<form>` — a `type` seen only after them is ignored.
|
|
200
|
+
*
|
|
201
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
202
|
+
* @returns The render function producing the handle's markup.
|
|
203
|
+
* @example
|
|
204
|
+
* <GridList.Item id="track-1">
|
|
205
|
+
* {t("playlist.track", { title: "Intro" })}
|
|
206
|
+
* <GridList.DragHandle aria-label={t("playlist.reorder")} />
|
|
207
|
+
* </GridList.Item>
|
|
208
|
+
*/
|
|
209
|
+
GridList.DragHandle = function GridListDragHandle(handle) {
|
|
210
|
+
return () => {
|
|
211
|
+
let { mix, ...rest } = handle.props;
|
|
212
|
+
return (_jsx("button", { type: "button", ...rest, mix: [
|
|
213
|
+
attrs({ role: DEFAULT_DRAG_HANDLE_ROLE, "data-drag-handle": DEFAULT_DRAG_HANDLE_MARKER }),
|
|
214
|
+
fg("neutral.muted"),
|
|
215
|
+
cursor("grab"),
|
|
216
|
+
active(cursor("grabbing")),
|
|
217
|
+
mix,
|
|
218
|
+
], children: _jsx(GripVerticalIcon, { size: 16 }) }));
|
|
219
|
+
};
|
|
220
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A visual and semantic wrapper binding a cluster of related controls into
|
|
3
|
+
* one unit — a text input paired with its clear button, a row of segmented
|
|
4
|
+
* buttons, a search field with a trailing submit action. The host lays its
|
|
5
|
+
* children out in a single row and gains a keyboard focus ring around the
|
|
6
|
+
* whole cluster whenever a control inside it becomes focus-visible, detected
|
|
7
|
+
* structurally rather than through any tracked state.
|
|
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 Group}.
|
|
15
|
+
*/
|
|
16
|
+
export declare namespace Group {
|
|
17
|
+
/**
|
|
18
|
+
* Native `<div>` attributes plus `mix`. `role` defaults to
|
|
19
|
+
* {@link DEFAULT_ROLE} (or `"region"`/`"presentation"`); `aria-invalid`
|
|
20
|
+
* gives the focus ring the danger tone, `aria-disabled` marks it disabled.
|
|
21
|
+
*/
|
|
22
|
+
interface Props extends TagProps<"div"> {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Lays children out in a centered flex row with no border, background, or
|
|
27
|
+
* gap, so controls can compose their own edges into one shape, and shows a
|
|
28
|
+
* keyboard focus ring (primary, or danger under `aria-invalid="true"`).
|
|
29
|
+
*
|
|
30
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
31
|
+
* @returns The render function producing the group's markup.
|
|
32
|
+
* @example
|
|
33
|
+
* <Group>
|
|
34
|
+
* <Button>{t("stepper.decrement")}</Button>
|
|
35
|
+
* <Button>{t("stepper.increment")}</Button>
|
|
36
|
+
* </Group>
|
|
37
|
+
* @example
|
|
38
|
+
* <Group aria-invalid="true">
|
|
39
|
+
* <input aria-label={t("form.email")} />
|
|
40
|
+
* <Button aria-label={t("form.clear")}>
|
|
41
|
+
* <XIcon />
|
|
42
|
+
* </Button>
|
|
43
|
+
* </Group>
|
|
44
|
+
*/
|
|
45
|
+
export declare function Group(handle: Handle<Group.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { outline, outlineColor } from "@sdxc/u/color";
|
|
3
|
+
import { flex, items } from "@sdxc/u/layout";
|
|
4
|
+
import { when } from "@sdxc/u/state";
|
|
5
|
+
import { attrs } from "remix/ui";
|
|
6
|
+
/**
|
|
7
|
+
* Default ARIA role applied through {@link attrs} unless a consumer
|
|
8
|
+
* overrides `role`; pass `"region"` for landmark-worthy content or
|
|
9
|
+
* `"presentation"` for purely visual grouping.
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_ROLE = "group";
|
|
12
|
+
/**
|
|
13
|
+
* Lays children out in a centered flex row with no border, background, or
|
|
14
|
+
* gap, so controls can compose their own edges into one shape, and shows a
|
|
15
|
+
* keyboard focus ring (primary, or danger under `aria-invalid="true"`).
|
|
16
|
+
*
|
|
17
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
18
|
+
* @returns The render function producing the group's markup.
|
|
19
|
+
* @example
|
|
20
|
+
* <Group>
|
|
21
|
+
* <Button>{t("stepper.decrement")}</Button>
|
|
22
|
+
* <Button>{t("stepper.increment")}</Button>
|
|
23
|
+
* </Group>
|
|
24
|
+
* @example
|
|
25
|
+
* <Group aria-invalid="true">
|
|
26
|
+
* <input aria-label={t("form.email")} />
|
|
27
|
+
* <Button aria-label={t("form.clear")}>
|
|
28
|
+
* <XIcon />
|
|
29
|
+
* </Button>
|
|
30
|
+
* </Group>
|
|
31
|
+
*/
|
|
32
|
+
export function Group(handle) {
|
|
33
|
+
return () => {
|
|
34
|
+
let { mix, ...rest } = handle.props;
|
|
35
|
+
return (_jsx("div", { ...rest, mix: [
|
|
36
|
+
attrs({ role: DEFAULT_ROLE }),
|
|
37
|
+
when("&:has(:focus-visible)", outline({ color: "brand.ring", offset: 2 })),
|
|
38
|
+
flex(),
|
|
39
|
+
items("center"),
|
|
40
|
+
when('&[aria-invalid="true"]', outlineColor("danger")),
|
|
41
|
+
mix,
|
|
42
|
+
] }));
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small, muted section label rendered inside a native `<header>` element —
|
|
3
|
+
* the heading that introduces a group of related items inside a listbox,
|
|
4
|
+
* menu, or combobox section. It carries no interactive behavior of its own,
|
|
5
|
+
* only the compact uppercase typography that sets it apart from the items
|
|
6
|
+
* beneath it.
|
|
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
|
+
* Props accepted by {@link Header}.
|
|
14
|
+
*/
|
|
15
|
+
export declare namespace Header {
|
|
16
|
+
/**
|
|
17
|
+
* Native `<header>` attributes plus `mix`. Renders whatever `children`
|
|
18
|
+
* the consumer supplies — a section's name, most often plain text.
|
|
19
|
+
*/
|
|
20
|
+
interface Props extends TagProps<"header"> {
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Renders its children inside a `<header>` element styled as a small,
|
|
25
|
+
* muted, uppercase section label — the heading introducing a group of
|
|
26
|
+
* related items inside a listbox, menu, or combobox section.
|
|
27
|
+
*
|
|
28
|
+
* @param handle Runtime handle carrying the host `<header>`'s props.
|
|
29
|
+
* @returns The render function producing the section label's markup.
|
|
30
|
+
* @example
|
|
31
|
+
* <Header>Fruits</Header>
|
|
32
|
+
*/
|
|
33
|
+
export declare function Header(handle: Handle<Header.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { fg } from "@sdxc/u/color";
|
|
3
|
+
import { pb, pi } from "@sdxc/u/size";
|
|
4
|
+
import { text, textTransform, tracking, weight } from "@sdxc/u/typography";
|
|
5
|
+
/**
|
|
6
|
+
* Renders its children inside a `<header>` element styled as a small,
|
|
7
|
+
* muted, uppercase section label — the heading introducing a group of
|
|
8
|
+
* related items inside a listbox, menu, or combobox section.
|
|
9
|
+
*
|
|
10
|
+
* @param handle Runtime handle carrying the host `<header>`'s props.
|
|
11
|
+
* @returns The render function producing the section label's markup.
|
|
12
|
+
* @example
|
|
13
|
+
* <Header>Fruits</Header>
|
|
14
|
+
*/
|
|
15
|
+
export function Header(handle) {
|
|
16
|
+
return () => {
|
|
17
|
+
let { mix, ...rest } = handle.props;
|
|
18
|
+
return (_jsx("header", { ...rest, mix: [
|
|
19
|
+
pi(3),
|
|
20
|
+
pb(1.5),
|
|
21
|
+
weight("semibold"),
|
|
22
|
+
tracking("wider"),
|
|
23
|
+
fg("neutral.muted"),
|
|
24
|
+
text("xs"),
|
|
25
|
+
textTransform("uppercase"),
|
|
26
|
+
mix,
|
|
27
|
+
] }));
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Establishes an ambient heading level read by nested headings and scopes,
|
|
3
|
+
* keeping a document outline sequential without passing a level by hand.
|
|
4
|
+
* Nesting moves one level deeper unless an explicit `level` fixes it, and
|
|
5
|
+
* renders a `display: contents` host so composing it adds no layout box
|
|
6
|
+
* while still exposing the depth via `data-heading-level`.
|
|
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
|
+
* Semantic depth, from `1` (`<h1>`) through `6` (`<h6>`), shared by every
|
|
14
|
+
* heading-related component's level resolution.
|
|
15
|
+
*/
|
|
16
|
+
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
17
|
+
/**
|
|
18
|
+
* Native tag rendered for each supported {@link HeadingLevel}, as a single
|
|
19
|
+
* level-to-element lookup table.
|
|
20
|
+
*/
|
|
21
|
+
export declare const TAG_BY_LEVEL: Record<HeadingLevel, "h1" | "h2" | "h3" | "h4" | "h5" | "h6">;
|
|
22
|
+
/**
|
|
23
|
+
* Prop and context types for {@link HeadingScope}.
|
|
24
|
+
*/
|
|
25
|
+
export declare namespace HeadingScope {
|
|
26
|
+
/** Value {@link HeadingScope} provides to descendants through context. */
|
|
27
|
+
interface Context {
|
|
28
|
+
/** Semantic depth this scope establishes for the headings and nested scopes rendered inside it. */
|
|
29
|
+
level: HeadingLevel;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Native `<div>` attributes, plus `mix` and an optional `level` that
|
|
33
|
+
* fixes this scope's depth outright, overriding the ambient
|
|
34
|
+
* one-level-deeper default.
|
|
35
|
+
*/
|
|
36
|
+
interface Props extends TagProps<"div"> {
|
|
37
|
+
/**
|
|
38
|
+
* Explicit semantic depth for this scope. Defaults to one level past
|
|
39
|
+
* the nearest ancestor scope's depth, or `1` where no scope wraps
|
|
40
|
+
* this one at all.
|
|
41
|
+
*/
|
|
42
|
+
level?: HeadingLevel;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Reads the semantic depth from the nearest ancestor {@link HeadingScope},
|
|
47
|
+
* always resolving safely to `undefined` when no ancestor scope exists,
|
|
48
|
+
* regardless of how that absence surfaces.
|
|
49
|
+
*
|
|
50
|
+
* @param handle Runtime handle of the component performing the lookup.
|
|
51
|
+
* @returns The nearest ancestor scope's depth, or `undefined` where nothing wraps the caller.
|
|
52
|
+
* @example
|
|
53
|
+
* let ambient = readAmbientLevel(handle); // 2, nested inside a HeadingScope holding level 2
|
|
54
|
+
*/
|
|
55
|
+
export declare function readAmbientLevel(handle: Handle<unknown, any>): HeadingLevel | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Resolves the semantic depth a heading renders at: an explicit level wins,
|
|
58
|
+
* then the nearest ancestor {@link HeadingScope}'s depth, then `1`, clamped
|
|
59
|
+
* to `6` with a dev-mode warning to flatten or restart the nesting.
|
|
60
|
+
*
|
|
61
|
+
* @param handle Runtime handle of the component resolving its depth.
|
|
62
|
+
* @param explicitLevel A `level` passed directly to the component, if any.
|
|
63
|
+
* @returns The resolved, clamped {@link HeadingLevel}.
|
|
64
|
+
* @example
|
|
65
|
+
* let level = resolveHeadingLevel(handle, handle.props.level); // an explicit level always wins
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveHeadingLevel(handle: Handle<unknown, any>, explicitLevel?: HeadingLevel): HeadingLevel;
|
|
68
|
+
/**
|
|
69
|
+
* Establishes an ambient heading level for descendants: an explicit `level`
|
|
70
|
+
* fixes it, otherwise one level past the nearest ancestor {@link HeadingScope},
|
|
71
|
+
* read before this scope publishes its own depth, or `1` with no ancestor.
|
|
72
|
+
*
|
|
73
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link HeadingScope.Context} to descendants.
|
|
74
|
+
* @returns The render function producing the scope's markup.
|
|
75
|
+
* @example
|
|
76
|
+
* <HeadingScope>
|
|
77
|
+
* <Heading>Document title</Heading>
|
|
78
|
+
* <HeadingScope>
|
|
79
|
+
* <Heading>Section title</Heading>
|
|
80
|
+
* </HeadingScope>
|
|
81
|
+
* </HeadingScope>
|
|
82
|
+
*/
|
|
83
|
+
export declare function HeadingScope(handle: Handle<HeadingScope.Props, HeadingScope.Context>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { contents } from "@sdxc/u/layout";
|
|
3
|
+
/**
|
|
4
|
+
* Native tag rendered for each supported {@link HeadingLevel}, as a single
|
|
5
|
+
* level-to-element lookup table.
|
|
6
|
+
*/
|
|
7
|
+
export const TAG_BY_LEVEL = {
|
|
8
|
+
1: "h1",
|
|
9
|
+
2: "h2",
|
|
10
|
+
3: "h3",
|
|
11
|
+
4: "h4",
|
|
12
|
+
5: "h5",
|
|
13
|
+
6: "h6",
|
|
14
|
+
};
|
|
15
|
+
const DEFAULT_LEVEL = 1;
|
|
16
|
+
/** Deepest semantic depth the native heading elements support; a resolution past this clamps down to it. */
|
|
17
|
+
const MAX_LEVEL = 6;
|
|
18
|
+
/**
|
|
19
|
+
* Reads the semantic depth from the nearest ancestor {@link HeadingScope},
|
|
20
|
+
* always resolving safely to `undefined` when no ancestor scope exists,
|
|
21
|
+
* regardless of how that absence surfaces.
|
|
22
|
+
*
|
|
23
|
+
* @param handle Runtime handle of the component performing the lookup.
|
|
24
|
+
* @returns The nearest ancestor scope's depth, or `undefined` where nothing wraps the caller.
|
|
25
|
+
* @example
|
|
26
|
+
* let ambient = readAmbientLevel(handle); // 2, nested inside a HeadingScope holding level 2
|
|
27
|
+
*/
|
|
28
|
+
export function readAmbientLevel(handle) {
|
|
29
|
+
try {
|
|
30
|
+
let ambient = handle.context.get(HeadingScope);
|
|
31
|
+
return ambient?.level;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolves the semantic depth a heading renders at: an explicit level wins,
|
|
39
|
+
* then the nearest ancestor {@link HeadingScope}'s depth, then `1`, clamped
|
|
40
|
+
* to `6` with a dev-mode warning to flatten or restart the nesting.
|
|
41
|
+
*
|
|
42
|
+
* @param handle Runtime handle of the component resolving its depth.
|
|
43
|
+
* @param explicitLevel A `level` passed directly to the component, if any.
|
|
44
|
+
* @returns The resolved, clamped {@link HeadingLevel}.
|
|
45
|
+
* @example
|
|
46
|
+
* let level = resolveHeadingLevel(handle, handle.props.level); // an explicit level always wins
|
|
47
|
+
*/
|
|
48
|
+
export function resolveHeadingLevel(handle, explicitLevel) {
|
|
49
|
+
let resolved = explicitLevel ?? readAmbientLevel(handle) ?? DEFAULT_LEVEL;
|
|
50
|
+
if (resolved > MAX_LEVEL) {
|
|
51
|
+
if (import.meta.env.DEV) {
|
|
52
|
+
console.warn(`Heading nesting resolved to level ${resolved}, past the native "h1"–"h6" range. Flatten the nesting, or start a new top-level HeadingScope instead of nesting further.`);
|
|
53
|
+
}
|
|
54
|
+
return MAX_LEVEL;
|
|
55
|
+
}
|
|
56
|
+
return resolved;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Establishes an ambient heading level for descendants: an explicit `level`
|
|
60
|
+
* fixes it, otherwise one level past the nearest ancestor {@link HeadingScope},
|
|
61
|
+
* read before this scope publishes its own depth, or `1` with no ancestor.
|
|
62
|
+
*
|
|
63
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link HeadingScope.Context} to descendants.
|
|
64
|
+
* @returns The render function producing the scope's markup.
|
|
65
|
+
* @example
|
|
66
|
+
* <HeadingScope>
|
|
67
|
+
* <Heading>Document title</Heading>
|
|
68
|
+
* <HeadingScope>
|
|
69
|
+
* <Heading>Section title</Heading>
|
|
70
|
+
* </HeadingScope>
|
|
71
|
+
* </HeadingScope>
|
|
72
|
+
*/
|
|
73
|
+
export function HeadingScope(handle) {
|
|
74
|
+
return () => {
|
|
75
|
+
let { level, mix, ...rest } = handle.props;
|
|
76
|
+
let ambient = readAmbientLevel(handle);
|
|
77
|
+
let requested = level ?? (ambient === undefined ? undefined : (ambient + 1));
|
|
78
|
+
let resolved = resolveHeadingLevel(handle, requested);
|
|
79
|
+
handle.context.set({ level: resolved });
|
|
80
|
+
return _jsx("div", { ...rest, "data-heading-level": resolved, mix: [contents(), mix] });
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A section title rendered inside the native heading element matching its
|
|
3
|
+
* semantic depth — `<h1>` through `<h6>` — styled at one fixed emphasis size
|
|
4
|
+
* regardless of which level it renders. An explicit `level` prop fixes the
|
|
5
|
+
* depth outright; otherwise, the nearest ancestor `HeadingScope` supplies
|
|
6
|
+
* it, and a heading with no scope wrapping it at all renders as `<h1>`.
|
|
7
|
+
* Choosing a level changes only the document outline the element contributes to
|
|
8
|
+
* assistive technology; its rendered size stays fixed, so nesting sections
|
|
9
|
+
* correctly never requires a visual trade-off.
|
|
10
|
+
*
|
|
11
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
12
|
+
* @copyright Sergio Xalambrí 2026
|
|
13
|
+
*/
|
|
14
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
15
|
+
import type { HeadingLevel } from "./heading-scope.js";
|
|
16
|
+
/**
|
|
17
|
+
* Prop types for {@link Heading}.
|
|
18
|
+
*/
|
|
19
|
+
export declare namespace Heading {
|
|
20
|
+
/**
|
|
21
|
+
* Semantic depth, from `1` (`<h1>`) through `6` (`<h6>`), mapped to the
|
|
22
|
+
* matching native heading element.
|
|
23
|
+
*/
|
|
24
|
+
type Level = HeadingLevel;
|
|
25
|
+
/**
|
|
26
|
+
* Every native heading-element attribute, unchanged, plus the `mix`
|
|
27
|
+
* passthrough and a `level` prop choosing which native element the
|
|
28
|
+
* heading renders as.
|
|
29
|
+
*/
|
|
30
|
+
interface Props extends TagProps<"h1"> {
|
|
31
|
+
/**
|
|
32
|
+
* Semantic depth. Defaults to the nearest ancestor `HeadingScope`'s
|
|
33
|
+
* depth, or `1` where no scope wraps this heading at all.
|
|
34
|
+
*/
|
|
35
|
+
level?: Level;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Renders its children inside the native heading element matching `level`,
|
|
40
|
+
* styled at one fixed emphasis size — semibold, tight-tracked, and colored for
|
|
41
|
+
* emphasis, with line height collapsed for compact wrapping.
|
|
42
|
+
*
|
|
43
|
+
* @param handle Runtime handle carrying the host heading element's props.
|
|
44
|
+
* @returns The render function producing the heading's markup.
|
|
45
|
+
* @example
|
|
46
|
+
* <Heading level={1}>Page title</Heading>
|
|
47
|
+
* @example
|
|
48
|
+
* <Heading>Section title</Heading>
|
|
49
|
+
*/
|
|
50
|
+
export declare function Heading(handle: Handle<Heading.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { fg } from "@sdxc/u/color";
|
|
3
|
+
import { fontSize, leading, tracking, weight } from "@sdxc/u/typography";
|
|
4
|
+
import { resolveHeadingLevel, TAG_BY_LEVEL } from "./heading-scope.js";
|
|
5
|
+
/**
|
|
6
|
+
* Renders its children inside the native heading element matching `level`,
|
|
7
|
+
* styled at one fixed emphasis size — semibold, tight-tracked, and colored for
|
|
8
|
+
* emphasis, with line height collapsed for compact wrapping.
|
|
9
|
+
*
|
|
10
|
+
* @param handle Runtime handle carrying the host heading element's props.
|
|
11
|
+
* @returns The render function producing the heading's markup.
|
|
12
|
+
* @example
|
|
13
|
+
* <Heading level={1}>Page title</Heading>
|
|
14
|
+
* @example
|
|
15
|
+
* <Heading>Section title</Heading>
|
|
16
|
+
*/
|
|
17
|
+
export function Heading(handle) {
|
|
18
|
+
return () => {
|
|
19
|
+
let { level, mix, ...rest } = handle.props;
|
|
20
|
+
let resolved = resolveHeadingLevel(handle, level);
|
|
21
|
+
let Tag = TAG_BY_LEVEL[resolved];
|
|
22
|
+
return (_jsx(Tag, { ...rest, "data-heading-level": resolved, mix: [
|
|
23
|
+
weight("semibold"),
|
|
24
|
+
tracking("tight"),
|
|
25
|
+
fg("neutral.emphasis"),
|
|
26
|
+
fontSize("lg"),
|
|
27
|
+
leading("none"),
|
|
28
|
+
mix,
|
|
29
|
+
] }));
|
|
30
|
+
};
|
|
31
|
+
}
|