@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,146 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, fg, outline } from "@sdxc/u/color";
|
|
3
|
+
import { rounded, opacity } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor } from "@sdxc/u/general";
|
|
5
|
+
import { flex, gap, items } from "@sdxc/u/layout";
|
|
6
|
+
import { is, minIs, mb, pb, pi, p } from "@sdxc/u/size";
|
|
7
|
+
import { active, disabled, focusVisible, hover, when } from "@sdxc/u/state";
|
|
8
|
+
import { text, textAlign, textDecoration, 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
|
+
import { Popover } from "./popover.js";
|
|
13
|
+
import { Separator } from "./separator.js";
|
|
14
|
+
/**
|
|
15
|
+
* Side of the invoker {@link Menu} renders against when `placement` is left
|
|
16
|
+
* unset, reading down and start-ward the way a dropdown conventionally does.
|
|
17
|
+
*/
|
|
18
|
+
const DEFAULT_PLACEMENT = "bottom-start";
|
|
19
|
+
/**
|
|
20
|
+
* `role` applied to {@link Menu}'s host through {@link attrs} unless a
|
|
21
|
+
* consumer supplies its own, identifying the surface as an ARIA menu.
|
|
22
|
+
*/
|
|
23
|
+
const DEFAULT_ROLE = "menu";
|
|
24
|
+
/**
|
|
25
|
+
* `role` applied to {@link Menu.Item} through {@link attrs} unless a
|
|
26
|
+
* consumer supplies its own — `"menuitemcheckbox"` and `"menuitemradio"` are
|
|
27
|
+
* valid overrides for a row that toggles or selects on activation.
|
|
28
|
+
*/
|
|
29
|
+
const DEFAULT_ITEM_ROLE = "menuitem";
|
|
30
|
+
/**
|
|
31
|
+
* {@link Menu.ItemProps.type} applied to the `<button>` variant when a
|
|
32
|
+
* consumer leaves it unset, keeping a click on the row from submitting a
|
|
33
|
+
* surrounding `<form>` the way a bare `<button>` otherwise would.
|
|
34
|
+
*/
|
|
35
|
+
const DEFAULT_ITEM_TYPE = "button";
|
|
36
|
+
/**
|
|
37
|
+
* Renders the menu's own host: a {@link Popover} defaulting to
|
|
38
|
+
* `"bottom-start"` placement and `"menu"` role, sized to its content. Point a
|
|
39
|
+
* row's `commandfor` at another `<Menu>`'s `id` to open it as a nested menu.
|
|
40
|
+
*
|
|
41
|
+
* @param handle Runtime handle carrying the host's {@link Popover} props.
|
|
42
|
+
* @returns The render function producing the menu's markup.
|
|
43
|
+
* @example
|
|
44
|
+
* <Button commandfor="account-menu" command="toggle-popover">{t("nav.account")}</Button>
|
|
45
|
+
* <Menu id="account-menu" aria-label={t("nav.accountMenu")}>
|
|
46
|
+
* <Menu.Item href="/settings/profile">{t("nav.profile")}</Menu.Item>
|
|
47
|
+
* <Menu.Item href="/settings/billing">{t("nav.billing")}</Menu.Item>
|
|
48
|
+
* <Menu.Separator />
|
|
49
|
+
* <Menu.Item danger>{t("actions.signOut")}</Menu.Item>
|
|
50
|
+
* </Menu>
|
|
51
|
+
* @example
|
|
52
|
+
* <Menu id="row-menu" placement="left-start" aria-label={t("table.rowActions")}>
|
|
53
|
+
* <Section aria-labelledby="row-menu-view-heading">
|
|
54
|
+
* <Header id="row-menu-view-heading">{t("menu.view")}</Header>
|
|
55
|
+
* <Menu.Item href={viewUrl}>{t("actions.view")}</Menu.Item>
|
|
56
|
+
* <Menu.Item href={editUrl}>{t("actions.edit")}</Menu.Item>
|
|
57
|
+
* </Section>
|
|
58
|
+
* <Menu.Separator />
|
|
59
|
+
* <Menu.Item danger commandfor="confirm-delete" command="show-modal">{t("actions.delete")}</Menu.Item>
|
|
60
|
+
* </Menu>
|
|
61
|
+
*/
|
|
62
|
+
export function Menu(handle) {
|
|
63
|
+
return () => {
|
|
64
|
+
let { placement, children, mix, ...rest } = handle.props;
|
|
65
|
+
let resolvedPlacement = placement ?? DEFAULT_PLACEMENT;
|
|
66
|
+
return (_jsx(Popover, { ...rest, placement: resolvedPlacement, mix: [attrs({ role: DEFAULT_ROLE }), minIs("10rem"), p(1), outline("none"), mix], children: children }));
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Renders a native `<a>` when `href` is set, else a `<button>`, defaulting
|
|
71
|
+
* `role` to `"menuitem"`; only omitting or neutralizing `href` stops the
|
|
72
|
+
* `<a>` variant's navigation, since `aria-disabled` mutes it visually only.
|
|
73
|
+
*
|
|
74
|
+
* @param handle Runtime handle carrying the host `<a>`/`<button>`'s props.
|
|
75
|
+
* @returns The render function producing the row's markup.
|
|
76
|
+
* @example
|
|
77
|
+
* <Menu.Item href="/settings/profile">{t("nav.profile")}</Menu.Item>
|
|
78
|
+
* @example
|
|
79
|
+
* <Menu.Item danger disabled>{t("actions.delete")}</Menu.Item>
|
|
80
|
+
* @example
|
|
81
|
+
* <Menu.Item aria-selected={sort === "name" ? "true" : undefined}>{t("sort.name")}</Menu.Item>
|
|
82
|
+
*/
|
|
83
|
+
Menu.Item = function MenuItem(handle) {
|
|
84
|
+
return () => {
|
|
85
|
+
let { href, target, rel, type, danger, children, mix, ...rest } = handle.props;
|
|
86
|
+
warnIfNoAccessibleName(handle.props, children, "Menu.Item: a row with no visible text needs an `aria-label` describing it — assistive technology has no accessible name to announce otherwise.");
|
|
87
|
+
let itemMix = [
|
|
88
|
+
interactiveTransition(),
|
|
89
|
+
attrs({ role: DEFAULT_ITEM_ROLE }),
|
|
90
|
+
flex(),
|
|
91
|
+
is("full"),
|
|
92
|
+
items("center"),
|
|
93
|
+
gap(2),
|
|
94
|
+
rounded("md"),
|
|
95
|
+
pi(3),
|
|
96
|
+
pb(2),
|
|
97
|
+
fg("neutral.emphasis"),
|
|
98
|
+
hover(bg("neutral.bg-tint-hover")),
|
|
99
|
+
active(bg("neutral.bg-tint-pressed")),
|
|
100
|
+
when("&:focus", bg("brand.tint")),
|
|
101
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
102
|
+
when('&[aria-selected="true"]', [bg("brand.solid"), fg("brand.onSolid"), weight(500)]),
|
|
103
|
+
disabled([opacity(50), cursor("not-allowed")]),
|
|
104
|
+
when("&[data-danger]", [
|
|
105
|
+
fg("danger"),
|
|
106
|
+
hover(bg("danger.tint")),
|
|
107
|
+
active(bg("danger.bg-tint-pressed")),
|
|
108
|
+
when("&:focus", bg("danger.tint")),
|
|
109
|
+
focusVisible(outline("danger.ring")),
|
|
110
|
+
]),
|
|
111
|
+
cursor("default"),
|
|
112
|
+
textDecoration("none"),
|
|
113
|
+
text("sm"),
|
|
114
|
+
textAlign("start"),
|
|
115
|
+
mix,
|
|
116
|
+
];
|
|
117
|
+
if (href) {
|
|
118
|
+
/**
|
|
119
|
+
* `rest`'s fields (aria-*, data-*, id, event props, …) are all valid
|
|
120
|
+
* on an `<a>` too, so retargeting its type here is safe; `role` is
|
|
121
|
+
* left out since the anchor type narrows it conditionally on `href`.
|
|
122
|
+
*/
|
|
123
|
+
let anchorRest = rest;
|
|
124
|
+
return (_jsx("a", { href: href, target: target, rel: rel, ...anchorRest, "data-danger": danger || undefined, mix: itemMix, children: children }));
|
|
125
|
+
}
|
|
126
|
+
return (_jsx("button", { type: type ?? DEFAULT_ITEM_TYPE, ...rest, "data-danger": danger || undefined, mix: itemMix, children: children }));
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Renders a hairline divider between two runs of {@link Menu.Item}s: the
|
|
131
|
+
* shared {@link Separator} component with the small block-axis margin a
|
|
132
|
+
* menu's compact rows need on either side of it.
|
|
133
|
+
*
|
|
134
|
+
* @param handle Runtime handle carrying the host's {@link Separator} props.
|
|
135
|
+
* @returns The render function producing the divider's markup.
|
|
136
|
+
* @example
|
|
137
|
+
* <Menu.Item href="/settings/profile">{t("nav.profile")}</Menu.Item>
|
|
138
|
+
* <Menu.Separator />
|
|
139
|
+
* <Menu.Item danger>{t("actions.signOut")}</Menu.Item>
|
|
140
|
+
*/
|
|
141
|
+
Menu.Separator = function MenuSeparator(handle) {
|
|
142
|
+
return () => {
|
|
143
|
+
let { mix, ...rest } = handle.props;
|
|
144
|
+
return _jsx(Separator, { ...rest, mix: [mb(1), mix] });
|
|
145
|
+
};
|
|
146
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A horizontal row of top-level triggers modeled on a native application's
|
|
3
|
+
* menu bar, where each trigger opens its own dropdown built from the
|
|
4
|
+
* existing {@link Menu} component.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
10
|
+
/**
|
|
11
|
+
* Prop types for {@link Menubar} and its compound parts.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace Menubar {
|
|
14
|
+
/**
|
|
15
|
+
* Every native `<div>` attribute, plus the `mix` passthrough.
|
|
16
|
+
*/
|
|
17
|
+
interface Props extends TagProps<"div"> {
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Every native `<button>` attribute, plus the `mix` passthrough, with
|
|
21
|
+
* `commandfor` narrowed to required so it always points at the `id` of
|
|
22
|
+
* the {@link Menu} this trigger opens.
|
|
23
|
+
*/
|
|
24
|
+
interface TriggerProps extends Omit<TagProps<"button">, "commandfor"> {
|
|
25
|
+
/** `id` of the {@link Menu} this trigger opens. */
|
|
26
|
+
commandfor: string;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Renders the row's host: a native `<div>` carrying the `menubar` role for
|
|
31
|
+
* {@link Menubar.Trigger}s. In dev mode, a root missing an `aria-label` or
|
|
32
|
+
* `aria-labelledby` logs a `console.warn`.
|
|
33
|
+
*
|
|
34
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
35
|
+
* @returns The render function producing the row's markup.
|
|
36
|
+
* @example
|
|
37
|
+
* <Menubar aria-label={t("app.menubar")}>
|
|
38
|
+
* <Menubar.Trigger commandfor="file-menu">{t("menubar.file")}</Menubar.Trigger>
|
|
39
|
+
* <Menu id="file-menu" aria-label={t("menubar.fileMenu")}>
|
|
40
|
+
* <Menu.Item>{t("actions.new")}</Menu.Item>
|
|
41
|
+
* <Menu.Item>{t("actions.open")}</Menu.Item>
|
|
42
|
+
* </Menu>
|
|
43
|
+
*
|
|
44
|
+
* <Menubar.Trigger commandfor="edit-menu">{t("menubar.edit")}</Menubar.Trigger>
|
|
45
|
+
* <Menu id="edit-menu" aria-label={t("menubar.editMenu")}>
|
|
46
|
+
* <Menu.Item>{t("actions.undo")}</Menu.Item>
|
|
47
|
+
* <Menu.Item>{t("actions.redo")}</Menu.Item>
|
|
48
|
+
* </Menu>
|
|
49
|
+
* </Menubar>
|
|
50
|
+
*/
|
|
51
|
+
export declare function Menubar(handle: Handle<Menubar.Props>): () => import("remix/ui").RemixElement;
|
|
52
|
+
export declare namespace Menubar {
|
|
53
|
+
var Trigger: (handle: Handle<Menubar.TriggerProps>) => () => import("remix/ui").RemixElement;
|
|
54
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, border, fg, outline } from "@sdxc/u/color";
|
|
3
|
+
import { opacity, rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor, userSelect } from "@sdxc/u/general";
|
|
5
|
+
import { flex, gap, inlineFlex, items } from "@sdxc/u/layout";
|
|
6
|
+
import { pb, pi } from "@sdxc/u/size";
|
|
7
|
+
import { active, disabled, hover, when } 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 { warnIfNoAccessibleLabel, warnIfNoAccessibleName, } from "../utils/warn-if-no-accessible-name.js";
|
|
12
|
+
/**
|
|
13
|
+
* `role="menubar"` applied to {@link Menubar}'s host through {@link attrs}
|
|
14
|
+
* unless a consumer supplies its own `role`, identifying the row as an ARIA
|
|
15
|
+
* menubar.
|
|
16
|
+
*/
|
|
17
|
+
const DEFAULT_ROLE = "menubar";
|
|
18
|
+
/**
|
|
19
|
+
* `role` applied to {@link Menubar.Trigger} through {@link attrs} unless a
|
|
20
|
+
* consumer supplies its own, identifying each top-level trigger as an ARIA
|
|
21
|
+
* menu-bar item that owns a submenu.
|
|
22
|
+
*/
|
|
23
|
+
const DEFAULT_TRIGGER_ROLE = "menuitem";
|
|
24
|
+
/**
|
|
25
|
+
* `type` {@link Menubar.TriggerProps} falls back to when a consumer doesn't
|
|
26
|
+
* supply one, keeping a click on the trigger from submitting a surrounding
|
|
27
|
+
* `<form>` the way a bare `<button>`'s default type otherwise would.
|
|
28
|
+
*/
|
|
29
|
+
const DEFAULT_TRIGGER_TYPE = "button";
|
|
30
|
+
/**
|
|
31
|
+
* Invoker Commands verb {@link Menubar.TriggerProps.command} falls back to
|
|
32
|
+
* when omitted: toggles the paired {@link Menu} between shown and hidden,
|
|
33
|
+
* the same default a standalone {@link Menu} trigger uses.
|
|
34
|
+
*/
|
|
35
|
+
const DEFAULT_TRIGGER_COMMAND = "toggle-popover";
|
|
36
|
+
/**
|
|
37
|
+
* Renders the row's host: a native `<div>` carrying the `menubar` role for
|
|
38
|
+
* {@link Menubar.Trigger}s. In dev mode, a root missing an `aria-label` or
|
|
39
|
+
* `aria-labelledby` logs a `console.warn`.
|
|
40
|
+
*
|
|
41
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
42
|
+
* @returns The render function producing the row's markup.
|
|
43
|
+
* @example
|
|
44
|
+
* <Menubar aria-label={t("app.menubar")}>
|
|
45
|
+
* <Menubar.Trigger commandfor="file-menu">{t("menubar.file")}</Menubar.Trigger>
|
|
46
|
+
* <Menu id="file-menu" aria-label={t("menubar.fileMenu")}>
|
|
47
|
+
* <Menu.Item>{t("actions.new")}</Menu.Item>
|
|
48
|
+
* <Menu.Item>{t("actions.open")}</Menu.Item>
|
|
49
|
+
* </Menu>
|
|
50
|
+
*
|
|
51
|
+
* <Menubar.Trigger commandfor="edit-menu">{t("menubar.edit")}</Menubar.Trigger>
|
|
52
|
+
* <Menu id="edit-menu" aria-label={t("menubar.editMenu")}>
|
|
53
|
+
* <Menu.Item>{t("actions.undo")}</Menu.Item>
|
|
54
|
+
* <Menu.Item>{t("actions.redo")}</Menu.Item>
|
|
55
|
+
* </Menu>
|
|
56
|
+
* </Menubar>
|
|
57
|
+
*/
|
|
58
|
+
export function Menubar(handle) {
|
|
59
|
+
return () => {
|
|
60
|
+
let { mix, ...rest } = handle.props;
|
|
61
|
+
warnIfNoAccessibleLabel(handle.props, 'Menubar: needs an "aria-label" or "aria-labelledby" identifying this menu bar for assistive technology.');
|
|
62
|
+
return (_jsx("div", { ...rest, mix: [
|
|
63
|
+
attrs({ role: DEFAULT_ROLE }),
|
|
64
|
+
flex(),
|
|
65
|
+
items("center"),
|
|
66
|
+
gap("0.125rem"),
|
|
67
|
+
rounded("md"),
|
|
68
|
+
border({ color: "neutral", width: 1 }),
|
|
69
|
+
bg("neutral.tint"),
|
|
70
|
+
pb(1),
|
|
71
|
+
pi(1),
|
|
72
|
+
mix,
|
|
73
|
+
] }));
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Renders a single top-level trigger: a native `<button>` pointed at the
|
|
78
|
+
* `id` of the {@link Menu} it opens through `commandfor`, with `command`
|
|
79
|
+
* defaulting to `"toggle-popover"` and `role` to `"menuitem"`.
|
|
80
|
+
*
|
|
81
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
82
|
+
* @returns The render function producing the trigger's markup.
|
|
83
|
+
* @example
|
|
84
|
+
* <Menubar.Trigger commandfor="file-menu">{t("menubar.file")}</Menubar.Trigger>
|
|
85
|
+
* @example
|
|
86
|
+
* <Menubar.Trigger commandfor="archived-menu" aria-disabled="true">
|
|
87
|
+
* {t("menubar.archived")}
|
|
88
|
+
* </Menubar.Trigger>
|
|
89
|
+
*/
|
|
90
|
+
Menubar.Trigger = function MenubarTrigger(handle) {
|
|
91
|
+
return () => {
|
|
92
|
+
let { type, command, children, mix, ...rest } = handle.props;
|
|
93
|
+
let resolvedType = type ?? DEFAULT_TRIGGER_TYPE;
|
|
94
|
+
let resolvedCommand = command ?? DEFAULT_TRIGGER_COMMAND;
|
|
95
|
+
warnIfNoAccessibleName(handle.props, children, "Menubar.Trigger: a trigger with no visible text needs an `aria-label` describing it — assistive technology has no accessible name to announce otherwise.");
|
|
96
|
+
return (_jsx("button", { type: resolvedType, command: resolvedCommand, ...rest, mix: [
|
|
97
|
+
interactiveTransition(),
|
|
98
|
+
attrs({ role: DEFAULT_TRIGGER_ROLE, "aria-haspopup": "menu" }),
|
|
99
|
+
inlineFlex(),
|
|
100
|
+
items("center"),
|
|
101
|
+
gap(2),
|
|
102
|
+
rounded("sm"),
|
|
103
|
+
pi(3),
|
|
104
|
+
pb("0.375rem"),
|
|
105
|
+
fg("neutral"),
|
|
106
|
+
hover([bg("neutral.bg-tint-hover"), fg("neutral.emphasis")]),
|
|
107
|
+
active(bg("neutral.bg-tint-pressed")),
|
|
108
|
+
when('&[aria-expanded="true"]', [bg("brand.solid"), fg("brand.onSolid")]),
|
|
109
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
110
|
+
disabled([opacity(50), cursor("not-allowed")]),
|
|
111
|
+
cursor("default"),
|
|
112
|
+
weight(500),
|
|
113
|
+
userSelect(),
|
|
114
|
+
text("sm"),
|
|
115
|
+
mix,
|
|
116
|
+
], children: children }));
|
|
117
|
+
};
|
|
118
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A scrollable frame for a conversational message log. Its viewport reuses
|
|
3
|
+
* the same scrollbar treatment every scrolling surface in this catalog
|
|
4
|
+
* shares and fades its own edges to hint at history above and replies still
|
|
5
|
+
* below; its content region announces newly appended rows through the ARIA
|
|
6
|
+
* log role; each row carries the message id and anchor data a scroll-follow
|
|
7
|
+
* behavior reads; and a static jump-to-latest control sits ready for that
|
|
8
|
+
* same behavior to reveal.
|
|
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 { Button } from "./button.js";
|
|
15
|
+
/**
|
|
16
|
+
* Prop types for {@link MessageScroller} and its compound parts.
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace MessageScroller {
|
|
19
|
+
/**
|
|
20
|
+
* Every native `<div>` attribute, unchanged, plus the `mix` passthrough.
|
|
21
|
+
* Size the frame through `mix` since {@link MessageScroller.Viewport}
|
|
22
|
+
* fills whatever block size this host resolves to.
|
|
23
|
+
*/
|
|
24
|
+
interface Props extends TagProps<"div"> {
|
|
25
|
+
/** The frame's compound parts: {@link MessageScroller.Viewport} and, optionally, {@link MessageScroller.Button}. */
|
|
26
|
+
children: RemixNode;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Every native `<div>` attribute, unchanged, plus the `mix` passthrough.
|
|
30
|
+
*/
|
|
31
|
+
interface ViewportProps extends TagProps<"div"> {
|
|
32
|
+
/** {@link MessageScroller.Content}, scrolling inside the viewport. */
|
|
33
|
+
children?: RemixNode;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Every native `<div>` attribute, unchanged, plus the `mix` passthrough.
|
|
37
|
+
*/
|
|
38
|
+
interface ContentProps extends TagProps<"div"> {
|
|
39
|
+
/**
|
|
40
|
+
* Marks the log as busy while a row inside it is still being written
|
|
41
|
+
* to — a reply still streaming in, for instance — forwarded to the host's
|
|
42
|
+
* native `aria-busy` attribute. Clear it once the row settles.
|
|
43
|
+
*/
|
|
44
|
+
"aria-busy"?: TagProps<"div">["aria-busy"];
|
|
45
|
+
/** The {@link MessageScroller.Item} rows to render in document order. */
|
|
46
|
+
children?: RemixNode;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Every native `<div>` attribute, unchanged, plus the `mix` passthrough.
|
|
50
|
+
*/
|
|
51
|
+
interface ItemProps extends TagProps<"div"> {
|
|
52
|
+
/**
|
|
53
|
+
* Stable id of the message this row renders, mirrored onto the host's
|
|
54
|
+
* `data-message-id` attribute so a scroll-follow behavior can find,
|
|
55
|
+
* measure, and scroll to this exact row directly.
|
|
56
|
+
*/
|
|
57
|
+
messageId: string;
|
|
58
|
+
/**
|
|
59
|
+
* Marks this row as a candidate anchor point — typically the first row
|
|
60
|
+
* of a new turn — mirrored onto `data-scroll-anchor` so a scroll-follow
|
|
61
|
+
* behavior can tell which rows are worth anchoring the viewport to.
|
|
62
|
+
*
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
scrollAnchor?: boolean;
|
|
66
|
+
/** The row's own content, typically a conversational row composed inside it. */
|
|
67
|
+
children?: RemixNode;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Every {@link Button.Props} field, unchanged, except `hidden`, which
|
|
71
|
+
* defaults to `true`.
|
|
72
|
+
*/
|
|
73
|
+
interface ButtonProps extends Button.Props {
|
|
74
|
+
/**
|
|
75
|
+
* Whether the control is absent from rendering and the accessibility tree.
|
|
76
|
+
* A paired scroll-follow behavior clears this attribute as the reader
|
|
77
|
+
* scrolls away from the live edge and sets it again on return or press.
|
|
78
|
+
*
|
|
79
|
+
* @default true
|
|
80
|
+
*/
|
|
81
|
+
hidden?: boolean;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Renders the frame's root host: a bordered, rounded `<div>` that
|
|
86
|
+
* declares the `ui-message-scroller` container queried by
|
|
87
|
+
* {@link MessageScroller.Button} for its own placement.
|
|
88
|
+
*
|
|
89
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
90
|
+
* @returns The render function producing the frame's markup.
|
|
91
|
+
* @example
|
|
92
|
+
* <MessageScroller mix={css({ blockSize: "32rem" })}>
|
|
93
|
+
* <MessageScroller.Viewport>
|
|
94
|
+
* <MessageScroller.Content aria-busy={isStreaming}>
|
|
95
|
+
* <MessageScroller.Item messageId={turn.id} scrollAnchor>
|
|
96
|
+
* {turn.content}
|
|
97
|
+
* </MessageScroller.Item>
|
|
98
|
+
* </MessageScroller.Content>
|
|
99
|
+
* </MessageScroller.Viewport>
|
|
100
|
+
* <MessageScroller.Button aria-label={t("chat.jumpToLatest")} />
|
|
101
|
+
* </MessageScroller>
|
|
102
|
+
*/
|
|
103
|
+
export declare function MessageScroller(handle: Handle<MessageScroller.Props>): () => import("remix/ui").RemixElement;
|
|
104
|
+
export declare namespace MessageScroller {
|
|
105
|
+
var Viewport: (handle: Handle<MessageScroller.ViewportProps>) => () => import("remix/ui").RemixElement;
|
|
106
|
+
var Content: (handle: Handle<MessageScroller.ContentProps>) => () => import("remix/ui").RemixElement;
|
|
107
|
+
var Item: (handle: Handle<MessageScroller.ItemProps>) => () => import("remix/ui").RemixElement;
|
|
108
|
+
var Button: (handle: Handle<MessageScroller.ButtonProps>) => () => import("remix/ui").RemixElement;
|
|
109
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { border } from "@sdxc/u/color";
|
|
3
|
+
import { rounded, shadow } from "@sdxc/u/effects";
|
|
4
|
+
import { raw } from "@sdxc/u/general";
|
|
5
|
+
import { absolute, container, flex, flexCol, gap, insIe, insIs, inset, justify, relative, } from "@sdxc/u/layout";
|
|
6
|
+
import { pb, pi } from "@sdxc/u/size";
|
|
7
|
+
import { z } from "@sdxc/u/stacking";
|
|
8
|
+
import { when } from "@sdxc/u/state";
|
|
9
|
+
import { translateProperty } from "@sdxc/u/transform";
|
|
10
|
+
import { attrs } from "remix/ui";
|
|
11
|
+
import { Button } from "./button.js";
|
|
12
|
+
import { ScrollArea } from "./scroll-area.js";
|
|
13
|
+
/**
|
|
14
|
+
* Named container {@link MessageScroller} declares on its own host, so
|
|
15
|
+
* {@link MessageScroller.Button} can size its own placement to the
|
|
16
|
+
* frame's own width.
|
|
17
|
+
*/
|
|
18
|
+
const CONTAINER_NAME = "ui-message-scroller";
|
|
19
|
+
/**
|
|
20
|
+
* Container width under which {@link MessageScroller.Button} switches from a
|
|
21
|
+
* centered floating pill to a bar stretched across the frame's own inline
|
|
22
|
+
* size.
|
|
23
|
+
*/
|
|
24
|
+
const BUTTON_NARROW_QUERY = `@container ${CONTAINER_NAME} (max-width: 28rem)`;
|
|
25
|
+
/**
|
|
26
|
+
* `role="log"` applied to {@link MessageScroller.Content} through
|
|
27
|
+
* {@link attrs} unless a consumer supplies its own `role`, whose implicit
|
|
28
|
+
* `aria-live="polite"` behavior announces each newly appended row.
|
|
29
|
+
*/
|
|
30
|
+
const DEFAULT_CONTENT_ROLE = "log";
|
|
31
|
+
/**
|
|
32
|
+
* `aria-relevant="additions"` applied to {@link MessageScroller.Content}
|
|
33
|
+
* through {@link attrs} unless overridden, scoping assistive-technology
|
|
34
|
+
* announcements to newly appended rows.
|
|
35
|
+
*/
|
|
36
|
+
const DEFAULT_CONTENT_ARIA_RELEVANT = "additions";
|
|
37
|
+
/** Semantic color role {@link MessageScroller.Button} falls back to when `color` is omitted. */
|
|
38
|
+
const DEFAULT_BUTTON_COLOR = "brand";
|
|
39
|
+
/** Visual weight {@link MessageScroller.Button} falls back to when `variant` is omitted. */
|
|
40
|
+
const DEFAULT_BUTTON_VARIANT = "solid";
|
|
41
|
+
/** Size variant {@link MessageScroller.Button} falls back to when `size` is omitted. */
|
|
42
|
+
const DEFAULT_BUTTON_SIZE = "sm";
|
|
43
|
+
/**
|
|
44
|
+
* `hidden` applied to {@link MessageScroller.Button} when a consumer omits
|
|
45
|
+
* it: the control starts absent from rendering and the accessibility tree
|
|
46
|
+
* until a paired scroll-follow behavior reveals it.
|
|
47
|
+
*/
|
|
48
|
+
const DEFAULT_BUTTON_HIDDEN = true;
|
|
49
|
+
/**
|
|
50
|
+
* Renders the frame's root host: a bordered, rounded `<div>` that
|
|
51
|
+
* declares the `ui-message-scroller` container queried by
|
|
52
|
+
* {@link MessageScroller.Button} for its own placement.
|
|
53
|
+
*
|
|
54
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
55
|
+
* @returns The render function producing the frame's markup.
|
|
56
|
+
* @example
|
|
57
|
+
* <MessageScroller mix={css({ blockSize: "32rem" })}>
|
|
58
|
+
* <MessageScroller.Viewport>
|
|
59
|
+
* <MessageScroller.Content aria-busy={isStreaming}>
|
|
60
|
+
* <MessageScroller.Item messageId={turn.id} scrollAnchor>
|
|
61
|
+
* {turn.content}
|
|
62
|
+
* </MessageScroller.Item>
|
|
63
|
+
* </MessageScroller.Content>
|
|
64
|
+
* </MessageScroller.Viewport>
|
|
65
|
+
* <MessageScroller.Button aria-label={t("chat.jumpToLatest")} />
|
|
66
|
+
* </MessageScroller>
|
|
67
|
+
*/
|
|
68
|
+
export function MessageScroller(handle) {
|
|
69
|
+
return () => {
|
|
70
|
+
let { children, mix, ...rest } = handle.props;
|
|
71
|
+
return (_jsx("div", { ...rest, "data-slot": "message-scroller", mix: [
|
|
72
|
+
rounded("lg"),
|
|
73
|
+
border({ color: "neutral", width: 1 }),
|
|
74
|
+
relative(),
|
|
75
|
+
container(CONTAINER_NAME),
|
|
76
|
+
mix,
|
|
77
|
+
], children: children }));
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Renders the frame's scrolling surface as {@link ScrollArea.Viewport},
|
|
82
|
+
* fixed to the block axis. Compose `scrollFade()` through `mix` to fade
|
|
83
|
+
* this viewport's edges when more content is off-screen.
|
|
84
|
+
*
|
|
85
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
86
|
+
* @returns The render function producing the viewport's markup.
|
|
87
|
+
* @example
|
|
88
|
+
* <MessageScroller.Viewport mix={scrollFade({ axis: "block" })}>
|
|
89
|
+
* <MessageScroller.Content>...</MessageScroller.Content>
|
|
90
|
+
* </MessageScroller.Viewport>
|
|
91
|
+
*/
|
|
92
|
+
MessageScroller.Viewport = function MessageScrollerViewport(handle) {
|
|
93
|
+
return () => {
|
|
94
|
+
let { mix, ...rest } = handle.props;
|
|
95
|
+
return _jsx(ScrollArea.Viewport, { ...rest, orientation: "vertical", mix: mix });
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Renders the frame's live region: a `<div>` carrying the ARIA log role,
|
|
100
|
+
* stacking its {@link MessageScroller.Item} rows in a column and
|
|
101
|
+
* announcing each added row via `aria-relevant="additions"`.
|
|
102
|
+
*
|
|
103
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
104
|
+
* @returns The render function producing the log region's markup.
|
|
105
|
+
* @example
|
|
106
|
+
* <MessageScroller.Content aria-busy={isStreaming}>
|
|
107
|
+
* <MessageScroller.Item messageId={turn.id}>{turn.content}</MessageScroller.Item>
|
|
108
|
+
* </MessageScroller.Content>
|
|
109
|
+
*/
|
|
110
|
+
MessageScroller.Content = function MessageScrollerContent(handle) {
|
|
111
|
+
return () => {
|
|
112
|
+
let { children, mix, ...rest } = handle.props;
|
|
113
|
+
return (_jsx("div", { ...rest, "data-slot": "content", mix: [
|
|
114
|
+
attrs({ role: DEFAULT_CONTENT_ROLE, "aria-relevant": DEFAULT_CONTENT_ARIA_RELEVANT }),
|
|
115
|
+
flex(),
|
|
116
|
+
flexCol(),
|
|
117
|
+
gap(4),
|
|
118
|
+
pb(4),
|
|
119
|
+
pi(4),
|
|
120
|
+
mix,
|
|
121
|
+
], children: children }));
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Renders a single message row: a `<div>` mirroring `messageId` onto
|
|
126
|
+
* `data-message-id` and, when `scrollAnchor` is set, an empty
|
|
127
|
+
* `data-scroll-anchor` attribute for a scroll-follow behavior to read.
|
|
128
|
+
*
|
|
129
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
130
|
+
* @returns The render function producing the row's markup.
|
|
131
|
+
* @example
|
|
132
|
+
* <MessageScroller.Item messageId={turn.id} scrollAnchor={turn.startsNewTurn}>
|
|
133
|
+
* {turn.content}
|
|
134
|
+
* </MessageScroller.Item>
|
|
135
|
+
*/
|
|
136
|
+
MessageScroller.Item = function MessageScrollerItem(handle) {
|
|
137
|
+
return () => {
|
|
138
|
+
let { messageId, scrollAnchor, children, mix, ...rest } = handle.props;
|
|
139
|
+
if (import.meta.env.DEV && !messageId) {
|
|
140
|
+
console.warn('MessageScroller.Item: needs a "messageId" — a scroll-follow behavior matches rows against this instead of parsing rendered children.');
|
|
141
|
+
}
|
|
142
|
+
return (_jsx("div", { ...rest, "data-slot": "item", "data-message-id": messageId, "data-scroll-anchor": scrollAnchor || undefined, mix: [
|
|
143
|
+
raw({
|
|
144
|
+
scrollMarginBlockStart: "var(--ui-message-scroller-anchor-offset, 0px)",
|
|
145
|
+
}),
|
|
146
|
+
mix,
|
|
147
|
+
], children: children }));
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Renders a static jump-to-latest control as {@link Button}, floating
|
|
152
|
+
* over the frame's block-end edge and starting `hidden` until a paired
|
|
153
|
+
* scroll-follow behavior clears the attribute.
|
|
154
|
+
*
|
|
155
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
156
|
+
* @returns The render function producing the control's markup.
|
|
157
|
+
* @example
|
|
158
|
+
* <MessageScroller.Button aria-label={t("chat.jumpToLatest")}>
|
|
159
|
+
* {t("chat.jumpToLatest")}
|
|
160
|
+
* </MessageScroller.Button>
|
|
161
|
+
*/
|
|
162
|
+
MessageScroller.Button = function MessageScrollerButton(handle) {
|
|
163
|
+
return () => {
|
|
164
|
+
let { hidden, color, variant, size, mix, ...rest } = handle.props;
|
|
165
|
+
return (_jsx(Button, { ...rest, type: "button", color: color ?? DEFAULT_BUTTON_COLOR, variant: variant ?? DEFAULT_BUTTON_VARIANT, size: size ?? DEFAULT_BUTTON_SIZE, hidden: hidden ?? DEFAULT_BUTTON_HIDDEN, "data-slot": "jump-button", mix: [
|
|
166
|
+
z(1),
|
|
167
|
+
absolute(),
|
|
168
|
+
inset("auto", "auto", "1rem", "50%"),
|
|
169
|
+
shadow("lg"),
|
|
170
|
+
translateProperty("-50% 0"),
|
|
171
|
+
when(BUTTON_NARROW_QUERY, [
|
|
172
|
+
justify("center"),
|
|
173
|
+
insIs("1rem"),
|
|
174
|
+
insIe("1rem"),
|
|
175
|
+
translateProperty("0 0"),
|
|
176
|
+
]),
|
|
177
|
+
mix,
|
|
178
|
+
] }));
|
|
179
|
+
};
|
|
180
|
+
};
|