@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,237 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, border, fg, outline } from "@sdxc/u/color";
|
|
3
|
+
import { rounded, opacity } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor, userSelect } from "@sdxc/u/general";
|
|
5
|
+
import { flex, flexCol, inlineFlex, items, justify, gap } from "@sdxc/u/layout";
|
|
6
|
+
import { pi, pb } from "@sdxc/u/size";
|
|
7
|
+
import { when, hover, active, data } from "@sdxc/u/state";
|
|
8
|
+
import { text, weight } from "@sdxc/u/typography";
|
|
9
|
+
import { attrs } from "remix/ui";
|
|
10
|
+
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
11
|
+
import { warnIfNoAccessibleName } from "../utils/warn-if-no-accessible-name.js";
|
|
12
|
+
/** Semantic color role {@link ToggleButton} falls back to when `color` is omitted. */
|
|
13
|
+
const DEFAULT_COLOR = "neutral";
|
|
14
|
+
/** Visual weight {@link ToggleButton} falls back to when `variant` is omitted. */
|
|
15
|
+
const DEFAULT_VARIANT = "outline";
|
|
16
|
+
/** Size variant {@link ToggleButton} falls back to when `size` is omitted. */
|
|
17
|
+
const DEFAULT_SIZE = "md";
|
|
18
|
+
/** Role {@link ToggleButtonGroup} carries by default, matching the arrow-key-navigable pattern a row of grouped toggle buttons follows. */
|
|
19
|
+
const DEFAULT_GROUP_ROLE = "toolbar";
|
|
20
|
+
/** Layout axis {@link ToggleButtonGroup} falls back to when `orientation` is omitted. */
|
|
21
|
+
const DEFAULT_GROUP_ORIENTATION = "horizontal";
|
|
22
|
+
/**
|
|
23
|
+
* Folds the pressed state a consumer passed into the token the host renders.
|
|
24
|
+
* ARIA reads text, so a boolean `true`/`false` would serialize as the bare
|
|
25
|
+
* name or vanish; `"false"` stays explicit since its absence would leave the button with no toggle semantics at all.
|
|
26
|
+
*
|
|
27
|
+
* @param pressed The state as the consumer expressed it.
|
|
28
|
+
* @returns The token to render.
|
|
29
|
+
*/
|
|
30
|
+
function resolveAriaPressed(pressed) {
|
|
31
|
+
if (pressed === "mixed")
|
|
32
|
+
return "mixed";
|
|
33
|
+
if (pressed === true || pressed === "true")
|
|
34
|
+
return "true";
|
|
35
|
+
return "false";
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Renders a native `<button aria-pressed>` host clicking which submits its
|
|
39
|
+
* enclosing form by default, flipping the state through a server round-trip
|
|
40
|
+
* with no script required; pair `pressToggle()` through `mix` in a hydrated island to skip the round-trip.
|
|
41
|
+
*
|
|
42
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
43
|
+
* @returns The render function producing the toggle button's markup.
|
|
44
|
+
* @example
|
|
45
|
+
* <ToggleButton aria-pressed={isMuted} aria-label={t("player.mute")}>
|
|
46
|
+
* <VolumeXIcon />
|
|
47
|
+
* </ToggleButton>
|
|
48
|
+
* @example
|
|
49
|
+
* <ToggleButton aria-pressed={isBold} variant="ghost" size="sm" aria-label={t("editor.bold")}>
|
|
50
|
+
* <BoldIcon />
|
|
51
|
+
* </ToggleButton>
|
|
52
|
+
* @example
|
|
53
|
+
* <ToggleButton aria-pressed={filter === "active"} color="brand" name="filter" value="active">
|
|
54
|
+
* {t("tasks.filterActive")}
|
|
55
|
+
* </ToggleButton>
|
|
56
|
+
*/
|
|
57
|
+
export function ToggleButton(handle) {
|
|
58
|
+
return () => {
|
|
59
|
+
let { color, variant, size, children, mix, "aria-pressed": pressed, ...rest } = handle.props;
|
|
60
|
+
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
61
|
+
let resolvedVariant = variant ?? DEFAULT_VARIANT;
|
|
62
|
+
let resolvedSize = size ?? DEFAULT_SIZE;
|
|
63
|
+
let resolvedPressed = resolveAriaPressed(pressed);
|
|
64
|
+
warnIfNoAccessibleName(handle.props, children, "ToggleButton: an icon-only toggle needs an `aria-label` describing what it does — assistive technology has no accessible name to announce otherwise.");
|
|
65
|
+
return (_jsx("button", { ...rest, "aria-pressed": resolvedPressed, "data-color": resolvedColor, "data-variant": resolvedVariant, "data-size": resolvedSize, mix: [
|
|
66
|
+
when("&:focus-visible", [
|
|
67
|
+
outline({ color: "brand.ring", offset: 2 }),
|
|
68
|
+
when('&[data-color="neutral"]', outline("neutral.ring")),
|
|
69
|
+
when('&[data-color="success"]', outline("success.ring")),
|
|
70
|
+
when('&[data-color="warning"]', outline("warning.ring")),
|
|
71
|
+
when('&[data-color="danger"]', outline("danger.ring")),
|
|
72
|
+
]),
|
|
73
|
+
interactiveTransition(),
|
|
74
|
+
inlineFlex(),
|
|
75
|
+
items("center"),
|
|
76
|
+
justify("center"),
|
|
77
|
+
gap("0.5rem"),
|
|
78
|
+
rounded("md"),
|
|
79
|
+
weight(500),
|
|
80
|
+
cursor("default"),
|
|
81
|
+
userSelect(),
|
|
82
|
+
pi("1rem"),
|
|
83
|
+
pb("0.5rem"),
|
|
84
|
+
when('&[data-size="sm"]', [pi("0.75rem"), pb("0.375rem")]),
|
|
85
|
+
when('&[data-size="lg"]', [pi("1.25rem"), pb("0.625rem")]),
|
|
86
|
+
text("sm"),
|
|
87
|
+
data("size", "sm", text("xs")),
|
|
88
|
+
data("size", "lg", text("base")),
|
|
89
|
+
when('&[data-variant="solid"]', [
|
|
90
|
+
when('&[data-color="brand"]', [
|
|
91
|
+
bg("brand.bg-solid"),
|
|
92
|
+
fg("brand.fg-on-solid"),
|
|
93
|
+
hover(bg("brand.bg-solid-hover")),
|
|
94
|
+
active(bg("brand.bg-solid-pressed")),
|
|
95
|
+
]),
|
|
96
|
+
when('&[data-color="neutral"]', [
|
|
97
|
+
bg("neutral.bg-solid"),
|
|
98
|
+
fg("neutral.fg-on-solid"),
|
|
99
|
+
hover(bg("neutral.bg-solid-hover")),
|
|
100
|
+
active(bg("neutral.bg-solid-pressed")),
|
|
101
|
+
]),
|
|
102
|
+
when('&[data-color="success"]', [
|
|
103
|
+
bg("success.bg-solid"),
|
|
104
|
+
fg("success.fg-on-solid"),
|
|
105
|
+
hover(bg("success.bg-solid-hover")),
|
|
106
|
+
active(bg("success.bg-solid-pressed")),
|
|
107
|
+
]),
|
|
108
|
+
when('&[data-color="warning"]', [
|
|
109
|
+
bg("warning.bg-solid"),
|
|
110
|
+
fg("warning.fg-on-solid"),
|
|
111
|
+
hover(bg("warning.bg-solid-hover")),
|
|
112
|
+
active(bg("warning.bg-solid-pressed")),
|
|
113
|
+
]),
|
|
114
|
+
when('&[data-color="danger"]', [
|
|
115
|
+
bg("danger.bg-solid"),
|
|
116
|
+
fg("danger.fg-on-solid"),
|
|
117
|
+
hover(bg("danger.bg-solid-hover")),
|
|
118
|
+
active(bg("danger.bg-solid-pressed")),
|
|
119
|
+
]),
|
|
120
|
+
]),
|
|
121
|
+
when('&[data-variant="outline"]', [
|
|
122
|
+
border({ width: 2, noStyleDefault: true }),
|
|
123
|
+
bg("transparent"),
|
|
124
|
+
]),
|
|
125
|
+
when('&[data-variant="ghost"]', bg("transparent")),
|
|
126
|
+
when('&[data-variant="outline"]', [
|
|
127
|
+
when('&[data-color="brand"]', [
|
|
128
|
+
border("brand.border-strong"),
|
|
129
|
+
fg("brand.fg"),
|
|
130
|
+
hover(bg("brand.bg-tint")),
|
|
131
|
+
active(bg("brand.bg-tint-hover")),
|
|
132
|
+
]),
|
|
133
|
+
when('&[data-color="neutral"]', [
|
|
134
|
+
border("neutral.border-strong"),
|
|
135
|
+
fg("neutral.fg"),
|
|
136
|
+
hover(bg("neutral.bg-tint")),
|
|
137
|
+
active(bg("neutral.bg-tint-hover")),
|
|
138
|
+
]),
|
|
139
|
+
when('&[data-color="success"]', [
|
|
140
|
+
border("success.border-strong"),
|
|
141
|
+
fg("success.fg"),
|
|
142
|
+
hover(bg("success.bg-tint")),
|
|
143
|
+
active(bg("success.bg-tint-hover")),
|
|
144
|
+
]),
|
|
145
|
+
when('&[data-color="danger"]', [
|
|
146
|
+
border("danger.border-strong"),
|
|
147
|
+
fg("danger.fg"),
|
|
148
|
+
hover(bg("danger.bg-tint")),
|
|
149
|
+
active(bg("danger.bg-tint-hover")),
|
|
150
|
+
]),
|
|
151
|
+
when('&[data-color="warning"]', [
|
|
152
|
+
border("warning.border-strong"),
|
|
153
|
+
fg("warning.fg"),
|
|
154
|
+
hover(bg("warning.bg-tint")),
|
|
155
|
+
active(bg("warning.bg-tint-hover")),
|
|
156
|
+
]),
|
|
157
|
+
]),
|
|
158
|
+
when('&[data-variant="ghost"]', [
|
|
159
|
+
when('&[data-color="brand"]', [
|
|
160
|
+
fg("brand.fg"),
|
|
161
|
+
hover(bg("brand.bg-tint")),
|
|
162
|
+
active(bg("brand.bg-tint-hover")),
|
|
163
|
+
]),
|
|
164
|
+
when('&[data-color="neutral"]', [
|
|
165
|
+
fg("neutral.fg"),
|
|
166
|
+
hover(bg("neutral.bg-tint-hover")),
|
|
167
|
+
active(bg("neutral.bg-tint-pressed")),
|
|
168
|
+
]),
|
|
169
|
+
when('&[data-color="success"]', [
|
|
170
|
+
fg("success.fg"),
|
|
171
|
+
hover(bg("success.bg-tint")),
|
|
172
|
+
active(bg("success.bg-tint-hover")),
|
|
173
|
+
]),
|
|
174
|
+
when('&[data-color="danger"]', [
|
|
175
|
+
fg("danger.fg"),
|
|
176
|
+
hover(bg("danger.bg-tint")),
|
|
177
|
+
active(bg("danger.bg-tint-hover")),
|
|
178
|
+
]),
|
|
179
|
+
when('&[data-color="warning"]', [
|
|
180
|
+
fg("warning.fg"),
|
|
181
|
+
hover(bg("warning.bg-tint")),
|
|
182
|
+
active(bg("warning.bg-tint-hover")),
|
|
183
|
+
]),
|
|
184
|
+
]),
|
|
185
|
+
when('&[aria-pressed="true"]', [
|
|
186
|
+
when('&[data-variant="outline"][data-color="brand"], &[data-variant="ghost"][data-color="brand"]', bg("brand.bg-tint")),
|
|
187
|
+
when('&[data-variant="outline"][data-color="neutral"], &[data-variant="ghost"][data-color="neutral"]', bg("neutral.bg-tint-pressed")),
|
|
188
|
+
when('&[data-variant="outline"][data-color="success"], &[data-variant="ghost"][data-color="success"]', bg("success.bg-tint")),
|
|
189
|
+
when('&[data-variant="outline"][data-color="danger"], &[data-variant="ghost"][data-color="danger"]', bg("danger.bg-tint")),
|
|
190
|
+
when('&[data-variant="outline"][data-color="warning"], &[data-variant="ghost"][data-color="warning"]', bg("warning.bg-tint")),
|
|
191
|
+
]),
|
|
192
|
+
when("&:disabled", opacity(50)),
|
|
193
|
+
when("&:disabled", cursor("not-allowed")),
|
|
194
|
+
mix,
|
|
195
|
+
], children: children }));
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Renders a `role="toolbar"` `<div>` laying a run of independently pressed
|
|
200
|
+
* {@link ToggleButton} children out in a row, or a column when `orientation`
|
|
201
|
+
* is `"vertical"`; each toggle button owns its own `aria-pressed` state, and this host contributes only shared layout and grouping.
|
|
202
|
+
*
|
|
203
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
204
|
+
* @returns The render function producing the group's markup.
|
|
205
|
+
* @example
|
|
206
|
+
* <ToggleButtonGroup aria-label={t("editor.textStyle")}>
|
|
207
|
+
* <ToggleButton aria-pressed={isBold} aria-label={t("editor.bold")}>
|
|
208
|
+
* <BoldIcon />
|
|
209
|
+
* </ToggleButton>
|
|
210
|
+
* <ToggleButton aria-pressed={isItalic} aria-label={t("editor.italic")}>
|
|
211
|
+
* <ItalicIcon />
|
|
212
|
+
* </ToggleButton>
|
|
213
|
+
* </ToggleButtonGroup>
|
|
214
|
+
* @example
|
|
215
|
+
* <ToggleButtonGroup aria-label={t("editor.alignment")} orientation="vertical">
|
|
216
|
+
* <ToggleButton aria-pressed={align === "start"} aria-label={t("editor.alignStart")}>
|
|
217
|
+
* <AlignStartIcon />
|
|
218
|
+
* </ToggleButton>
|
|
219
|
+
* <ToggleButton aria-pressed={align === "center"} aria-label={t("editor.alignCenter")}>
|
|
220
|
+
* <AlignCenterIcon />
|
|
221
|
+
* </ToggleButton>
|
|
222
|
+
* </ToggleButtonGroup>
|
|
223
|
+
*/
|
|
224
|
+
export function ToggleButtonGroup(handle) {
|
|
225
|
+
return () => {
|
|
226
|
+
let { orientation, mix, ...rest } = handle.props;
|
|
227
|
+
let resolvedOrientation = orientation ?? DEFAULT_GROUP_ORIENTATION;
|
|
228
|
+
return (_jsx("div", { "data-orientation": resolvedOrientation, ...rest, mix: [
|
|
229
|
+
attrs({ role: DEFAULT_GROUP_ROLE }),
|
|
230
|
+
flex(),
|
|
231
|
+
items("center"),
|
|
232
|
+
gap("0.25rem"),
|
|
233
|
+
when('&[data-orientation="vertical"]', [flexCol(), items("start")]),
|
|
234
|
+
mix,
|
|
235
|
+
] }));
|
|
236
|
+
};
|
|
237
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A bordered, tinted panel that groups a set of interactive controls —
|
|
3
|
+
* buttons, toggles, menus — along a single axis. The host renders as a
|
|
4
|
+
* `toolbar` landmark and lays its children out as a row by default,
|
|
5
|
+
* switching to a column when its orientation flips to vertical.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
11
|
+
/**
|
|
12
|
+
* Prop types for {@link Toolbar}.
|
|
13
|
+
*/
|
|
14
|
+
export declare namespace Toolbar {
|
|
15
|
+
/**
|
|
16
|
+
* Axis the toolbar's controls lay out along: a single row, or a single
|
|
17
|
+
* column.
|
|
18
|
+
*/
|
|
19
|
+
type Orientation = "horizontal" | "vertical";
|
|
20
|
+
/**
|
|
21
|
+
* Every native `<div>` attribute, unchanged, plus the `mix` passthrough.
|
|
22
|
+
* Setting `aria-orientation="vertical"` switches both the accessibility
|
|
23
|
+
* contract and rendered layout to a column; leaving it unset keeps the row.
|
|
24
|
+
*/
|
|
25
|
+
interface Props extends TagProps<"div"> {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Renders a bordered, tinted panel grouping a set of interactive controls
|
|
30
|
+
* along one axis. The host carries the `toolbar` role and lays its children
|
|
31
|
+
* out as a row by default, flipping to a column when `aria-orientation="vertical"`.
|
|
32
|
+
*
|
|
33
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
34
|
+
* @returns The render function producing the toolbar's markup.
|
|
35
|
+
* @example
|
|
36
|
+
* <Toolbar aria-label={t("editor.toolbar")}>
|
|
37
|
+
* <Button variant="ghost"><ScissorsIcon /></Button>
|
|
38
|
+
* <Button variant="ghost"><CopyIcon /></Button>
|
|
39
|
+
* <Button variant="ghost"><ClipboardIcon /></Button>
|
|
40
|
+
* </Toolbar>
|
|
41
|
+
* @example
|
|
42
|
+
* <Toolbar aria-label={t("editor.toolbar")} aria-orientation="vertical">
|
|
43
|
+
* <Button variant="ghost"><BoldIcon /></Button>
|
|
44
|
+
* <Button variant="ghost"><ItalicIcon /></Button>
|
|
45
|
+
* </Toolbar>
|
|
46
|
+
*/
|
|
47
|
+
export declare function Toolbar(handle: Handle<Toolbar.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, border } from "@sdxc/u/color";
|
|
3
|
+
import { rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { flexCol, hstack, items } from "@sdxc/u/layout";
|
|
5
|
+
import { pb, pi } from "@sdxc/u/size";
|
|
6
|
+
import { when } from "@sdxc/u/state";
|
|
7
|
+
import { attrs } from "remix/ui";
|
|
8
|
+
/**
|
|
9
|
+
* `role="toolbar"` applied through {@link attrs} unless a consumer supplies
|
|
10
|
+
* its own `role`, announcing the host as a toolbar landmark for the controls
|
|
11
|
+
* grouped inside it.
|
|
12
|
+
*/
|
|
13
|
+
const DEFAULT_ROLE = "toolbar";
|
|
14
|
+
/**
|
|
15
|
+
* Default {@link Toolbar.Props} orientation, applied through {@link attrs}
|
|
16
|
+
* unless a consumer sets `aria-orientation` directly, so one attribute flips
|
|
17
|
+
* both the accessibility contract and the CSS layout variant.
|
|
18
|
+
*/
|
|
19
|
+
const DEFAULT_ORIENTATION = "horizontal";
|
|
20
|
+
/**
|
|
21
|
+
* Renders a bordered, tinted panel grouping a set of interactive controls
|
|
22
|
+
* along one axis. The host carries the `toolbar` role and lays its children
|
|
23
|
+
* out as a row by default, flipping to a column when `aria-orientation="vertical"`.
|
|
24
|
+
*
|
|
25
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
26
|
+
* @returns The render function producing the toolbar's markup.
|
|
27
|
+
* @example
|
|
28
|
+
* <Toolbar aria-label={t("editor.toolbar")}>
|
|
29
|
+
* <Button variant="ghost"><ScissorsIcon /></Button>
|
|
30
|
+
* <Button variant="ghost"><CopyIcon /></Button>
|
|
31
|
+
* <Button variant="ghost"><ClipboardIcon /></Button>
|
|
32
|
+
* </Toolbar>
|
|
33
|
+
* @example
|
|
34
|
+
* <Toolbar aria-label={t("editor.toolbar")} aria-orientation="vertical">
|
|
35
|
+
* <Button variant="ghost"><BoldIcon /></Button>
|
|
36
|
+
* <Button variant="ghost"><ItalicIcon /></Button>
|
|
37
|
+
* </Toolbar>
|
|
38
|
+
*/
|
|
39
|
+
export function Toolbar(handle) {
|
|
40
|
+
return () => {
|
|
41
|
+
let { mix, ...rest } = handle.props;
|
|
42
|
+
return (_jsx("div", { ...rest, mix: [
|
|
43
|
+
attrs({ role: DEFAULT_ROLE, "aria-orientation": DEFAULT_ORIENTATION }),
|
|
44
|
+
hstack({ gap: 2, align: "center" }),
|
|
45
|
+
rounded("lg"),
|
|
46
|
+
border({ color: "neutral.border", width: 1 }),
|
|
47
|
+
bg("neutral.tint"),
|
|
48
|
+
pb(2),
|
|
49
|
+
pi(2),
|
|
50
|
+
when('&[aria-orientation="vertical"]', [flexCol(), items("start")]),
|
|
51
|
+
mix,
|
|
52
|
+
] }));
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small floating label identifying an otherwise unlabeled control or
|
|
3
|
+
* adding a supplementary hint, riding the same `popover`-attributed host and
|
|
4
|
+
* CSS anchor positioning contract as {@link Popover}. Its reveal is plain
|
|
5
|
+
* `:hover`/`:focus-visible` state read off the sibling immediately before it
|
|
6
|
+
* in the DOM — the trigger — so pointing at or tabbing to that trigger
|
|
7
|
+
* surfaces the hint with no script anywhere in the path.
|
|
8
|
+
*
|
|
9
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
10
|
+
* @copyright Sergio Xalambrí 2026
|
|
11
|
+
*/
|
|
12
|
+
import type { Handle } from "remix/ui";
|
|
13
|
+
import { Popover } from "./popover.js";
|
|
14
|
+
/**
|
|
15
|
+
* Prop types for {@link Tooltip}.
|
|
16
|
+
*/
|
|
17
|
+
export declare namespace Tooltip {
|
|
18
|
+
/**
|
|
19
|
+
* Every prop {@link Popover.Props} accepts except `popover` and `role`,
|
|
20
|
+
* fixed here: `popover` is always `"hint"` so the tooltip layers over an
|
|
21
|
+
* open `"auto"` popover, and `role` is always `"tooltip"` per WAI-ARIA.
|
|
22
|
+
*/
|
|
23
|
+
interface Props extends Omit<Popover.Props, "popover" | "role"> {
|
|
24
|
+
/**
|
|
25
|
+
* Whether to render a pointer-arrow child pointing back at the trigger,
|
|
26
|
+
* filled to match this host's own solid background so the two read as
|
|
27
|
+
* one continuous shape. Defaults to {@link DEFAULT_SHOW_ARROW}.
|
|
28
|
+
*/
|
|
29
|
+
showArrow?: boolean;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Renders the hint through {@link Popover}, fixing `popover` to `"hint"` and
|
|
34
|
+
* `role` to `"tooltip"`. The host stays present in the DOM, entering on
|
|
35
|
+
* `:popover-open`, `:focus-visible`, or the trigger's hover, animated via `@starting-style`.
|
|
36
|
+
*
|
|
37
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
38
|
+
* @returns The render function producing the hint's markup.
|
|
39
|
+
* @example
|
|
40
|
+
* <button popovertarget="save-tooltip" aria-describedby="save-tooltip">
|
|
41
|
+
* {t("actions.save")}
|
|
42
|
+
* </button>
|
|
43
|
+
* <Tooltip id="save-tooltip">{t("actions.saveDescription")}</Tooltip>
|
|
44
|
+
* @example
|
|
45
|
+
* <a href="/settings" popovertarget="settings-tooltip" aria-describedby="settings-tooltip">
|
|
46
|
+
* <GearIcon aria-hidden />
|
|
47
|
+
* </a>
|
|
48
|
+
* <Tooltip id="settings-tooltip" placement="right" showArrow={false}>
|
|
49
|
+
* {t("nav.settings")}
|
|
50
|
+
* </Tooltip>
|
|
51
|
+
*/
|
|
52
|
+
export declare function Tooltip(handle: Handle<Tooltip.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, fg, fill } from "@sdxc/u/color";
|
|
3
|
+
import { opacity, rounded, shadow, transition, transitionBehavior } from "@sdxc/u/effects";
|
|
4
|
+
import { block } from "@sdxc/u/layout";
|
|
5
|
+
import { media, startingStyle } from "@sdxc/u/responsive";
|
|
6
|
+
import { pb, pi } from "@sdxc/u/size";
|
|
7
|
+
import { when } from "@sdxc/u/state";
|
|
8
|
+
import { scaleProperty } from "@sdxc/u/transform";
|
|
9
|
+
import { text } from "@sdxc/u/typography";
|
|
10
|
+
import { durations, easings } from "../animations/tokens.js";
|
|
11
|
+
import { OverlayArrow } from "./overlay-arrow.js";
|
|
12
|
+
import { Popover } from "./popover.js";
|
|
13
|
+
/**
|
|
14
|
+
* Side of the trigger {@link Tooltip} renders against when `placement` is
|
|
15
|
+
* left unset — above the trigger, the most common resting spot for a hint
|
|
16
|
+
* that shouldn't cover the control it describes.
|
|
17
|
+
*/
|
|
18
|
+
const DEFAULT_PLACEMENT = "top";
|
|
19
|
+
/**
|
|
20
|
+
* Whether {@link Tooltip} renders its pointer-arrow child when a consumer
|
|
21
|
+
* leaves `showArrow` unset.
|
|
22
|
+
*/
|
|
23
|
+
const DEFAULT_SHOW_ARROW = true;
|
|
24
|
+
/**
|
|
25
|
+
* Selector matching the pointer-hovered trigger — the sibling immediately
|
|
26
|
+
* before {@link Tooltip}'s host — for use only inside `@media (hover: hover)`,
|
|
27
|
+
* wrapped in `:is()` since the style serializer treats a bare selector starting with `*` as a plain declaration.
|
|
28
|
+
*/
|
|
29
|
+
const HOVERED_TRIGGER_SELECTOR = ":is(*:hover) ~ &";
|
|
30
|
+
/**
|
|
31
|
+
* Selector matching {@link Tooltip}'s entered state: native `:popover-open` —
|
|
32
|
+
* set by a `popovertarget` (or `commandfor`/`command="toggle-popover"`)
|
|
33
|
+
* invoker, or an `interestfor` attribute — or keyboard focus on the trigger sibling immediately before it.
|
|
34
|
+
*/
|
|
35
|
+
const ENTERED_SELECTOR = "&:popover-open, *:focus-visible ~ &";
|
|
36
|
+
/**
|
|
37
|
+
* Renders the hint through {@link Popover}, fixing `popover` to `"hint"` and
|
|
38
|
+
* `role` to `"tooltip"`. The host stays present in the DOM, entering on
|
|
39
|
+
* `:popover-open`, `:focus-visible`, or the trigger's hover, animated via `@starting-style`.
|
|
40
|
+
*
|
|
41
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
42
|
+
* @returns The render function producing the hint's markup.
|
|
43
|
+
* @example
|
|
44
|
+
* <button popovertarget="save-tooltip" aria-describedby="save-tooltip">
|
|
45
|
+
* {t("actions.save")}
|
|
46
|
+
* </button>
|
|
47
|
+
* <Tooltip id="save-tooltip">{t("actions.saveDescription")}</Tooltip>
|
|
48
|
+
* @example
|
|
49
|
+
* <a href="/settings" popovertarget="settings-tooltip" aria-describedby="settings-tooltip">
|
|
50
|
+
* <GearIcon aria-hidden />
|
|
51
|
+
* </a>
|
|
52
|
+
* <Tooltip id="settings-tooltip" placement="right" showArrow={false}>
|
|
53
|
+
* {t("nav.settings")}
|
|
54
|
+
* </Tooltip>
|
|
55
|
+
*/
|
|
56
|
+
export function Tooltip(handle) {
|
|
57
|
+
return () => {
|
|
58
|
+
let { placement, showArrow, children, mix, ...rest } = handle.props;
|
|
59
|
+
let resolvedPlacement = placement ?? DEFAULT_PLACEMENT;
|
|
60
|
+
let resolvedShowArrow = showArrow ?? DEFAULT_SHOW_ARROW;
|
|
61
|
+
return (_jsxs(Popover, { ...rest, popover: "hint", role: "tooltip", placement: resolvedPlacement, mix: [
|
|
62
|
+
rounded("md"),
|
|
63
|
+
pi(2),
|
|
64
|
+
pb(1),
|
|
65
|
+
shadow("md"),
|
|
66
|
+
bg("neutral.solid"),
|
|
67
|
+
fg("neutral.onSolid"),
|
|
68
|
+
opacity(0),
|
|
69
|
+
transition("opacity, scale, display, overlay", {
|
|
70
|
+
duration: durations.fast,
|
|
71
|
+
easing: easings.standard,
|
|
72
|
+
}),
|
|
73
|
+
text("sm"),
|
|
74
|
+
scaleProperty("0.95"),
|
|
75
|
+
transitionBehavior("allow-discrete"),
|
|
76
|
+
when(ENTERED_SELECTOR, [block(), opacity(100), scaleProperty("none")]),
|
|
77
|
+
startingStyle(when(ENTERED_SELECTOR, [opacity(0), scaleProperty("0.95")])),
|
|
78
|
+
media("(hover: hover)", [
|
|
79
|
+
when(HOVERED_TRIGGER_SELECTOR, [block(), opacity(100), scaleProperty("none")]),
|
|
80
|
+
startingStyle(when(HOVERED_TRIGGER_SELECTOR, [opacity(0), scaleProperty("0.95")])),
|
|
81
|
+
]),
|
|
82
|
+
media("(prefers-reduced-motion: reduce)", [
|
|
83
|
+
transition("opacity, display, overlay", {
|
|
84
|
+
duration: durations.fast,
|
|
85
|
+
easing: easings.standard,
|
|
86
|
+
}),
|
|
87
|
+
scaleProperty("none"),
|
|
88
|
+
]),
|
|
89
|
+
mix,
|
|
90
|
+
], children: [children, resolvedShowArrow && (_jsx(OverlayArrow, { placement: resolvedPlacement, mix: fill("neutral.solid"), children: _jsx("svg", { width: 8, height: 8, viewBox: "0 0 8 8", children: _jsx("path", { d: "M0 0 L4 4 L8 0" }) }) }))] }));
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A hierarchical list of nodes built from nested `<details>` and `<summary>`
|
|
3
|
+
* elements, so a branch's expand/collapse state, keyboard toggling, and
|
|
4
|
+
* content hiding all come from the platform rather than tracked state.
|
|
5
|
+
* {@link Tree.Item} nests further {@link Tree.Item} nodes directly inside
|
|
6
|
+
* itself to describe a subtree, {@link Tree.ItemContent} renders each node's
|
|
7
|
+
* always-visible row, and {@link Tree.LoadMoreItem} holds a trailing loading
|
|
8
|
+
* placeholder exactly like a row list's own.
|
|
9
|
+
*
|
|
10
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
11
|
+
* @copyright Sergio Xalambrí 2026
|
|
12
|
+
*/
|
|
13
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/ui";
|
|
14
|
+
import { SentinelRow } from "./sentinel-row.js";
|
|
15
|
+
/**
|
|
16
|
+
* Prop and context types for {@link Tree} and its compound parts.
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace Tree {
|
|
19
|
+
/** Value each {@link Tree.Item} provides to the nodes nested inside it. */
|
|
20
|
+
interface ItemContext {
|
|
21
|
+
/** Nesting depth this item occupies, `0` for a node rendered directly inside {@link Tree}. */
|
|
22
|
+
depth: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Props accepted by {@link Tree}.
|
|
26
|
+
*/
|
|
27
|
+
interface Props extends TagProps<"div"> {
|
|
28
|
+
/** {@link Tree.Item} and {@link Tree.LoadMoreItem} nodes to render. */
|
|
29
|
+
children: RemixNode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Props accepted by {@link Tree.Item}. Every native `<details>` attribute
|
|
33
|
+
* still applies, so `open` sets a branch's initial and current expanded
|
|
34
|
+
* state declaratively, exactly as on any native `<details>` element.
|
|
35
|
+
*/
|
|
36
|
+
interface ItemProps extends TagProps<"details"> {
|
|
37
|
+
/**
|
|
38
|
+
* Stable identifier for this node, mirrored onto the rendered element's
|
|
39
|
+
* own `id` and a `data-rmx-key` attribute so a paired selection, navigation, or
|
|
40
|
+
* reorder behavior can correlate the node with its own tracked state.
|
|
41
|
+
*/
|
|
42
|
+
id: string;
|
|
43
|
+
/** The node's {@link Tree.ItemContent} row, followed by zero or more nested {@link Tree.Item} nodes describing its subtree. */
|
|
44
|
+
children: RemixNode;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Props accepted by {@link Tree.ItemContent}.
|
|
48
|
+
*/
|
|
49
|
+
interface ItemContentProps extends TagProps<"summary"> {
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Props accepted by {@link Tree.LoadMoreItem}.
|
|
53
|
+
*/
|
|
54
|
+
interface LoadMoreItemProps extends TagProps<"div"> {
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Props accepted by {@link Tree.ExpandButton}: every native `<button>`
|
|
58
|
+
* attribute except `type` (fixed to `"button"` so it never submits an
|
|
59
|
+
* enclosing form), plus a required `aria-label` for the icon-only control.
|
|
60
|
+
*/
|
|
61
|
+
interface ExpandButtonProps extends Omit<TagProps<"button">, "type"> {
|
|
62
|
+
/** Accessible name for the icon-only control, e.g. "Expand" or "Collapse". */
|
|
63
|
+
"aria-label": string;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Renders the tree's root host: a bordered `<div>` carrying `role="tree"`,
|
|
68
|
+
* stacking {@link Tree.Item} nodes in block flow, with `data-empty`
|
|
69
|
+
* centering a fallback message; an unlabeled tree logs a dev `console.warn`.
|
|
70
|
+
*
|
|
71
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
72
|
+
* @returns The render function producing the tree's markup.
|
|
73
|
+
* @example
|
|
74
|
+
* <Tree aria-label={t("files.title")}>
|
|
75
|
+
* <Tree.Item id="src">
|
|
76
|
+
* <Tree.ItemContent>
|
|
77
|
+
* <Tree.ExpandButton aria-label={t("files.expand")} />
|
|
78
|
+
* {t("files.folder", { name: "src" })}
|
|
79
|
+
* </Tree.ItemContent>
|
|
80
|
+
* <Tree.Item id="src-index">
|
|
81
|
+
* <Tree.ItemContent>{t("files.file", { name: "index.ts" })}</Tree.ItemContent>
|
|
82
|
+
* </Tree.Item>
|
|
83
|
+
* </Tree.Item>
|
|
84
|
+
* </Tree>
|
|
85
|
+
* @example
|
|
86
|
+
* <Tree aria-label={t("files.title")} data-empty>
|
|
87
|
+
* {t("files.empty")}
|
|
88
|
+
* </Tree>
|
|
89
|
+
*/
|
|
90
|
+
export declare function Tree(handle: Handle<Tree.Props>): () => import("remix/ui").RemixElement;
|
|
91
|
+
export declare namespace Tree {
|
|
92
|
+
var Item: typeof TreeItem;
|
|
93
|
+
var ItemContent: (handle: Handle<Tree.ItemContentProps>) => () => import("remix/ui").RemixElement;
|
|
94
|
+
var LoadMoreItem: typeof SentinelRow;
|
|
95
|
+
var ExpandButton: (handle: Handle<Tree.ExpandButtonProps>) => () => import("remix/ui").RemixElement;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Renders a node as a native `<details>`, so a subtree's reveal and `[open]`
|
|
99
|
+
* state come from the platform. Nest {@link Tree.ItemContent} first as the
|
|
100
|
+
* row, then nested {@link Tree.Item} children; reveal animates via `::details-content`.
|
|
101
|
+
*
|
|
102
|
+
* @param handle Runtime handle carrying the host `<details>`'s props and providing {@link Tree.ItemContext} to nodes nested inside it.
|
|
103
|
+
* @returns The render function producing the node's markup.
|
|
104
|
+
* @example
|
|
105
|
+
* <Tree.Item id="src">
|
|
106
|
+
* <Tree.ItemContent>
|
|
107
|
+
* <Tree.ExpandButton aria-label={t("files.expand")} />
|
|
108
|
+
* {t("files.folder", { name: "src" })}
|
|
109
|
+
* </Tree.ItemContent>
|
|
110
|
+
* <Tree.Item id="src-index">
|
|
111
|
+
* <Tree.ItemContent>{t("files.file", { name: "index.ts" })}</Tree.ItemContent>
|
|
112
|
+
* </Tree.Item>
|
|
113
|
+
* </Tree.Item>
|
|
114
|
+
* @example
|
|
115
|
+
* <Tree.Item id="src" open>
|
|
116
|
+
* <Tree.ItemContent>
|
|
117
|
+
* <Tree.ExpandButton aria-label={t("files.collapse")} />
|
|
118
|
+
* {t("files.folder", { name: "src" })}
|
|
119
|
+
* </Tree.ItemContent>
|
|
120
|
+
* </Tree.Item>
|
|
121
|
+
*/
|
|
122
|
+
declare function TreeItem(handle: Handle<Tree.ItemProps, Tree.ItemContext>): () => import("remix/ui").RemixElement;
|
|
123
|
+
export {};
|