@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,129 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, border, fg } from "@sdxc/u/color";
|
|
3
|
+
import { rounded, transition } from "@sdxc/u/effects";
|
|
4
|
+
import { userSelect } from "@sdxc/u/general";
|
|
5
|
+
import { gap, inlineFlex, items, shrink } from "@sdxc/u/layout";
|
|
6
|
+
import { bs, is, pb, pi } from "@sdxc/u/size";
|
|
7
|
+
import { data, when } from "@sdxc/u/state";
|
|
8
|
+
import { fontSize, leading, nowrap, weight } from "@sdxc/u/typography";
|
|
9
|
+
import { attrs } from "remix/ui";
|
|
10
|
+
import { DEFAULT_ICON_ARIA_HIDDEN } from "../utils/decorative-icon.js";
|
|
11
|
+
/** Semantic color role {@link Badge} falls back to when `color` is omitted. */
|
|
12
|
+
const DEFAULT_COLOR = "neutral";
|
|
13
|
+
/** Visual weight {@link Badge} falls back to when `variant` is omitted. */
|
|
14
|
+
const DEFAULT_VARIANT = "default";
|
|
15
|
+
/**
|
|
16
|
+
* Renders a single-line pill host, colored and shaped through the
|
|
17
|
+
* `data-color` and `data-variant` attribute contract: `"default"` fills the
|
|
18
|
+
* pill solid, `"secondary"` tints the fill, `"outline"` keeps just a border.
|
|
19
|
+
*
|
|
20
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
21
|
+
* @returns The render function producing the badge's markup.
|
|
22
|
+
* @example
|
|
23
|
+
* <Badge>{t("badge.new")}</Badge>
|
|
24
|
+
* @example
|
|
25
|
+
* <Badge color="success" variant="secondary">
|
|
26
|
+
* <Badge.Icon><CheckIcon /></Badge.Icon>
|
|
27
|
+
* <Badge.Text>{t("badge.active")}</Badge.Text>
|
|
28
|
+
* </Badge>
|
|
29
|
+
* @example
|
|
30
|
+
* <Badge color="danger" variant="outline">{t("badge.failed")}</Badge>
|
|
31
|
+
*/
|
|
32
|
+
export function Badge(handle) {
|
|
33
|
+
return () => {
|
|
34
|
+
let { color, variant, mix, ...rest } = handle.props;
|
|
35
|
+
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
36
|
+
let resolvedVariant = variant ?? DEFAULT_VARIANT;
|
|
37
|
+
return (_jsx("span", { "data-color": resolvedColor, "data-variant": resolvedVariant, ...rest, mix: [
|
|
38
|
+
inlineFlex(),
|
|
39
|
+
items("center"),
|
|
40
|
+
gap(1),
|
|
41
|
+
rounded("full"),
|
|
42
|
+
border({ width: 1 }),
|
|
43
|
+
pi(2.5),
|
|
44
|
+
pb(0.5),
|
|
45
|
+
leading(1),
|
|
46
|
+
weight("semibold"),
|
|
47
|
+
nowrap(),
|
|
48
|
+
transition("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke"),
|
|
49
|
+
fontSize("xs"),
|
|
50
|
+
userSelect(),
|
|
51
|
+
data("variant", "default", [
|
|
52
|
+
data("color", "brand", [bg("brand.solid"), fg("brand.onSolid"), border("brand.solid")]),
|
|
53
|
+
data("color", "neutral", [
|
|
54
|
+
bg("neutral.solid"),
|
|
55
|
+
fg("neutral.onSolid"),
|
|
56
|
+
border("neutral.solid"),
|
|
57
|
+
]),
|
|
58
|
+
data("color", "success", [
|
|
59
|
+
bg("success.solid"),
|
|
60
|
+
fg("success.onSolid"),
|
|
61
|
+
border("success.solid"),
|
|
62
|
+
]),
|
|
63
|
+
data("color", "warning", [
|
|
64
|
+
bg("warning.solid"),
|
|
65
|
+
fg("warning.onSolid"),
|
|
66
|
+
border("warning.solid"),
|
|
67
|
+
]),
|
|
68
|
+
data("color", "danger", [
|
|
69
|
+
bg("danger.solid"),
|
|
70
|
+
fg("danger.onSolid"),
|
|
71
|
+
border("danger.solid"),
|
|
72
|
+
]),
|
|
73
|
+
]),
|
|
74
|
+
data("variant", "secondary", [
|
|
75
|
+
data("color", "brand", [bg("brand.tint"), fg("brand"), border("brand")]),
|
|
76
|
+
data("color", "neutral", [bg("neutral.tint"), fg("neutral"), border("neutral")]),
|
|
77
|
+
data("color", "success", [bg("success.tint"), fg("success"), border("success")]),
|
|
78
|
+
data("color", "warning", [bg("warning.tint"), fg("warning"), border("warning")]),
|
|
79
|
+
data("color", "danger", [bg("danger.tint"), fg("danger"), border("danger")]),
|
|
80
|
+
]),
|
|
81
|
+
data("variant", "outline", [
|
|
82
|
+
bg("transparent"),
|
|
83
|
+
data("color", "brand", [border("brand.strong"), fg("brand")]),
|
|
84
|
+
data("color", "neutral", [border("neutral"), fg("neutral")]),
|
|
85
|
+
data("color", "success", [border("success.strong"), fg("success")]),
|
|
86
|
+
data("color", "warning", [border("warning.strong"), fg("warning")]),
|
|
87
|
+
data("color", "danger", [border("danger.strong"), fg("danger")]),
|
|
88
|
+
]),
|
|
89
|
+
mix,
|
|
90
|
+
] }));
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Renders the badge's leading or trailing glyph slot: an inert, shrink-proof
|
|
95
|
+
* `<span>` sized to hold a single small icon and hidden from assistive
|
|
96
|
+
* technology, since {@link Badge.Text} carries the badge's meaning.
|
|
97
|
+
*
|
|
98
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
99
|
+
* @returns The render function producing the icon slot's markup.
|
|
100
|
+
* @example
|
|
101
|
+
* <Badge.Icon><CheckIcon /></Badge.Icon>
|
|
102
|
+
*/
|
|
103
|
+
Badge.Icon = function BadgeIcon(handle) {
|
|
104
|
+
return () => {
|
|
105
|
+
let { mix, ...rest } = handle.props;
|
|
106
|
+
return (_jsx("span", { ...rest, mix: [
|
|
107
|
+
attrs({ "aria-hidden": DEFAULT_ICON_ARIA_HIDDEN }),
|
|
108
|
+
inlineFlex(),
|
|
109
|
+
shrink(0),
|
|
110
|
+
when("& > svg", [is(3), bs(3), shrink(0), fg("currentColor")]),
|
|
111
|
+
mix,
|
|
112
|
+
] }));
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Renders the badge's label slot: a `<span>` with its line height collapsed
|
|
117
|
+
* to one, keeping short label text vertically centered inside the pill.
|
|
118
|
+
*
|
|
119
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
120
|
+
* @returns The render function producing the label slot's markup.
|
|
121
|
+
* @example
|
|
122
|
+
* <Badge.Text>{t("badge.active")}</Badge.Text>
|
|
123
|
+
*/
|
|
124
|
+
Badge.Text = function BadgeText(handle) {
|
|
125
|
+
return () => {
|
|
126
|
+
let { mix, ...rest } = handle.props;
|
|
127
|
+
return _jsx("span", { ...rest, mix: [leading(1), mix] });
|
|
128
|
+
};
|
|
129
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A trail of links marking the page's position within a hierarchy of parent
|
|
3
|
+
* sections, composing a `<nav>` root, an `<ol>` list, and `<li>` items around
|
|
4
|
+
* {@link Breadcrumbs.Link}, a restyled {@link Link}. Every item but the last
|
|
5
|
+
* draws its separator through a CSS `::after` pseudo-element, keeping it
|
|
6
|
+
* purely presentational, and the trail's current segment reads straight from
|
|
7
|
+
* the native `aria-current` attribute a consumer sets while rendering the
|
|
8
|
+
* page it currently occupies.
|
|
9
|
+
*
|
|
10
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
11
|
+
* @copyright Sergio Xalambrí 2026
|
|
12
|
+
*/
|
|
13
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
14
|
+
import { Link } from "./link.js";
|
|
15
|
+
/**
|
|
16
|
+
* Prop types for {@link Breadcrumbs} and its compound parts.
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace Breadcrumbs {
|
|
19
|
+
/**
|
|
20
|
+
* Every native `<nav>` attribute, unchanged, plus the `mix` passthrough.
|
|
21
|
+
*/
|
|
22
|
+
interface Props extends TagProps<"nav"> {
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Every native `<ol>` attribute, unchanged, plus the `mix` passthrough.
|
|
26
|
+
*/
|
|
27
|
+
interface ListProps extends TagProps<"ol"> {
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Every native `<li>` attribute, unchanged, plus the `mix` passthrough.
|
|
31
|
+
*/
|
|
32
|
+
interface ItemProps extends TagProps<"li"> {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Every prop {@link Link.Props} accepts, unchanged. A type alias rather than
|
|
36
|
+
* an interface, since {@link Link.Props} resolves through a conditional type
|
|
37
|
+
* that an `interface extends` clause can't statically extend.
|
|
38
|
+
*/
|
|
39
|
+
type LinkProps = Link.Props;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Renders the trail's `<nav>` root, laying {@link Breadcrumbs.List} as a row.
|
|
43
|
+
* A root missing `aria-label` or `aria-labelledby` logs a dev-mode
|
|
44
|
+
* `console.warn`, since assistive technology needs one to identify this landmark.
|
|
45
|
+
*
|
|
46
|
+
* @param handle Runtime handle carrying the host `<nav>`'s props.
|
|
47
|
+
* @returns The render function producing the trail's markup.
|
|
48
|
+
* @example
|
|
49
|
+
* <Breadcrumbs aria-label={t("breadcrumbs.label")}>
|
|
50
|
+
* <Breadcrumbs.List>
|
|
51
|
+
* <Breadcrumbs.Item>
|
|
52
|
+
* <Breadcrumbs.Link href="/">{t("nav.home")}</Breadcrumbs.Link>
|
|
53
|
+
* </Breadcrumbs.Item>
|
|
54
|
+
* <Breadcrumbs.Item>
|
|
55
|
+
* <Breadcrumbs.Link href="/projects" aria-current="page">
|
|
56
|
+
* {t("nav.projects")}
|
|
57
|
+
* </Breadcrumbs.Link>
|
|
58
|
+
* </Breadcrumbs.Item>
|
|
59
|
+
* </Breadcrumbs.List>
|
|
60
|
+
* </Breadcrumbs>
|
|
61
|
+
*/
|
|
62
|
+
export declare function Breadcrumbs(handle: Handle<Breadcrumbs.Props>): () => import("remix/ui").RemixElement;
|
|
63
|
+
export declare namespace Breadcrumbs {
|
|
64
|
+
var List: (handle: Handle<Breadcrumbs.ListProps>) => () => import("remix/ui").RemixElement;
|
|
65
|
+
var Item: (handle: Handle<Breadcrumbs.ItemProps>) => () => import("remix/ui").RemixElement;
|
|
66
|
+
var Link: (handle: Handle<Breadcrumbs.LinkProps>) => () => import("remix/ui").RemixElement;
|
|
67
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { fg } from "@sdxc/u/color";
|
|
3
|
+
import { listStyle, raw } from "@sdxc/u/general";
|
|
4
|
+
import { flex, gap, items } from "@sdxc/u/layout";
|
|
5
|
+
import { m, mi, p } from "@sdxc/u/size";
|
|
6
|
+
import { data, hover, when } from "@sdxc/u/state";
|
|
7
|
+
import { fontSize, textDecoration, weight } from "@sdxc/u/typography";
|
|
8
|
+
import { warnIfNoAccessibleLabel } from "../utils/warn-if-no-accessible-name.js";
|
|
9
|
+
import { Link } from "./link.js";
|
|
10
|
+
/** Semantic color role {@link Breadcrumbs.Link} falls back to when `color` is omitted. */
|
|
11
|
+
const DEFAULT_COLOR = "neutral";
|
|
12
|
+
/**
|
|
13
|
+
* Renders the trail's `<nav>` root, laying {@link Breadcrumbs.List} as a row.
|
|
14
|
+
* A root missing `aria-label` or `aria-labelledby` logs a dev-mode
|
|
15
|
+
* `console.warn`, since assistive technology needs one to identify this landmark.
|
|
16
|
+
*
|
|
17
|
+
* @param handle Runtime handle carrying the host `<nav>`'s props.
|
|
18
|
+
* @returns The render function producing the trail's markup.
|
|
19
|
+
* @example
|
|
20
|
+
* <Breadcrumbs aria-label={t("breadcrumbs.label")}>
|
|
21
|
+
* <Breadcrumbs.List>
|
|
22
|
+
* <Breadcrumbs.Item>
|
|
23
|
+
* <Breadcrumbs.Link href="/">{t("nav.home")}</Breadcrumbs.Link>
|
|
24
|
+
* </Breadcrumbs.Item>
|
|
25
|
+
* <Breadcrumbs.Item>
|
|
26
|
+
* <Breadcrumbs.Link href="/projects" aria-current="page">
|
|
27
|
+
* {t("nav.projects")}
|
|
28
|
+
* </Breadcrumbs.Link>
|
|
29
|
+
* </Breadcrumbs.Item>
|
|
30
|
+
* </Breadcrumbs.List>
|
|
31
|
+
* </Breadcrumbs>
|
|
32
|
+
*/
|
|
33
|
+
export function Breadcrumbs(handle) {
|
|
34
|
+
return () => {
|
|
35
|
+
let { mix, ...rest } = handle.props;
|
|
36
|
+
warnIfNoAccessibleLabel(handle.props, 'Breadcrumbs: needs an "aria-label" or "aria-labelledby" identifying this navigation landmark for assistive technology.');
|
|
37
|
+
return _jsx("nav", { ...rest, "data-slot": "breadcrumbs", mix: [flex(), items("center"), mix] });
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Renders the trail's `<ol>` list, resetting native list markers and spacing
|
|
42
|
+
* and laying {@link Breadcrumbs.Item} children out as a wrapped row with a
|
|
43
|
+
* small gap between them.
|
|
44
|
+
*
|
|
45
|
+
* @param handle Runtime handle carrying the host `<ol>`'s props.
|
|
46
|
+
* @returns The render function producing the list's markup.
|
|
47
|
+
* @example
|
|
48
|
+
* <Breadcrumbs.List>
|
|
49
|
+
* <Breadcrumbs.Item>
|
|
50
|
+
* <Breadcrumbs.Link href="/">{t("nav.home")}</Breadcrumbs.Link>
|
|
51
|
+
* </Breadcrumbs.Item>
|
|
52
|
+
* </Breadcrumbs.List>
|
|
53
|
+
*/
|
|
54
|
+
Breadcrumbs.List = function BreadcrumbsList(handle) {
|
|
55
|
+
return () => {
|
|
56
|
+
let { mix, ...rest } = handle.props;
|
|
57
|
+
return (_jsx("ol", { ...rest, "data-slot": "list", mix: [flex(), items("center"), gap(1), m(0), p(0), listStyle(), mix] }));
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Renders a single `<li>` wrapping one {@link Breadcrumbs.Link}. Every item
|
|
62
|
+
* but the last draws a `›` separator glyph via a CSS `::after`
|
|
63
|
+
* pseudo-element, keeping the divider purely presentational.
|
|
64
|
+
*
|
|
65
|
+
* @param handle Runtime handle carrying the host `<li>`'s props.
|
|
66
|
+
* @returns The render function producing the item's markup.
|
|
67
|
+
* @example
|
|
68
|
+
* <Breadcrumbs.Item>
|
|
69
|
+
* <Breadcrumbs.Link href="/projects">{t("nav.projects")}</Breadcrumbs.Link>
|
|
70
|
+
* </Breadcrumbs.Item>
|
|
71
|
+
*/
|
|
72
|
+
Breadcrumbs.Item = function BreadcrumbsItem(handle) {
|
|
73
|
+
return () => {
|
|
74
|
+
let { mix, ...rest } = handle.props;
|
|
75
|
+
return (_jsx("li", { ...rest, "data-slot": "item", mix: [
|
|
76
|
+
flex(),
|
|
77
|
+
items("center"),
|
|
78
|
+
gap(1),
|
|
79
|
+
when("&:not(:last-child)::after", [
|
|
80
|
+
mi(1),
|
|
81
|
+
fg("neutral.muted"),
|
|
82
|
+
fontSize("sm"),
|
|
83
|
+
raw({ content: '"›"' }),
|
|
84
|
+
]),
|
|
85
|
+
mix,
|
|
86
|
+
] }));
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Renders one trail segment as a restyled {@link Link}: sized to `0.875rem`
|
|
91
|
+
* with its underline dropped, defaulting to a quiet neutral color role that
|
|
92
|
+
* brightens on hover and bolds when `aria-current="page"` is set.
|
|
93
|
+
*
|
|
94
|
+
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
95
|
+
* @returns The render function producing the segment's markup.
|
|
96
|
+
* @example
|
|
97
|
+
* <Breadcrumbs.Link href="/settings">{t("nav.settings")}</Breadcrumbs.Link>
|
|
98
|
+
* @example
|
|
99
|
+
* <Breadcrumbs.Link href="/settings/profile" aria-current="page">
|
|
100
|
+
* {t("nav.profile")}
|
|
101
|
+
* </Breadcrumbs.Link>
|
|
102
|
+
* @example
|
|
103
|
+
* <Breadcrumbs.Link aria-disabled="true">{t("nav.archived")}</Breadcrumbs.Link>
|
|
104
|
+
*/
|
|
105
|
+
Breadcrumbs.Link = function BreadcrumbsLink(handle) {
|
|
106
|
+
return () => {
|
|
107
|
+
let { color, mix, ...rest } = handle.props;
|
|
108
|
+
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
109
|
+
return (_jsx(Link, { color: resolvedColor, ...rest, "data-slot": "link", mix: [
|
|
110
|
+
fontSize("sm"),
|
|
111
|
+
textDecoration("none"),
|
|
112
|
+
hover(textDecoration("none")),
|
|
113
|
+
data("color", "neutral", [fg("neutral.muted"), hover(fg("neutral"))]),
|
|
114
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
115
|
+
weight("medium"),
|
|
116
|
+
fg("neutral.emphasis"),
|
|
117
|
+
]),
|
|
118
|
+
mix,
|
|
119
|
+
] }));
|
|
120
|
+
};
|
|
121
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The framed message surface inside a conversational row's content slot,
|
|
3
|
+
* sized to its own content up to a share of the row's width. Variants cover
|
|
4
|
+
* tones from a solid fill to fully unframed, and `align` hugs either row
|
|
5
|
+
* edge. `Bubble.Content`, `Bubble.Reactions`, and `Bubble.Group` compose the
|
|
6
|
+
* turn's text, its reaction toggles, and multi-bubble runs.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/ui";
|
|
12
|
+
/**
|
|
13
|
+
* Prop types for {@link Bubble} and its compound parts.
|
|
14
|
+
*/
|
|
15
|
+
export declare namespace Bubble {
|
|
16
|
+
/**
|
|
17
|
+
* Visual weight the frame renders with: solid `"default"`/`"secondary"` fills,
|
|
18
|
+
* soft `"muted"`/`"tinted"` tints, a bordered `"outline"`, an unframed
|
|
19
|
+
* `"ghost"`, and a solid danger fill for `"destructive"`.
|
|
20
|
+
*/
|
|
21
|
+
type Variant = "default" | "secondary" | "muted" | "tinted" | "outline" | "ghost" | "destructive";
|
|
22
|
+
/**
|
|
23
|
+
* Edge of the row the frame hugs: `"start"` stays flush with the row's
|
|
24
|
+
* leading edge (flipping under `dir="rtl"`), `"end"` stays flush with the
|
|
25
|
+
* trailing edge, typically paired with the reader's own turns vs everyone else's.
|
|
26
|
+
*/
|
|
27
|
+
type Align = "start" | "end";
|
|
28
|
+
/**
|
|
29
|
+
* Props accepted by {@link Bubble}.
|
|
30
|
+
*/
|
|
31
|
+
interface Props extends TagProps<"div"> {
|
|
32
|
+
/** Visual weight. Defaults to {@link DEFAULT_VARIANT}. */
|
|
33
|
+
variant?: Variant;
|
|
34
|
+
/** Edge of the row the frame hugs. Defaults to {@link DEFAULT_ALIGN}. */
|
|
35
|
+
align?: Align;
|
|
36
|
+
/** The frame's compound parts: {@link Bubble.Content}, an optional {@link Bubble.Reactions}, or any other content. */
|
|
37
|
+
children: RemixNode;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Props accepted by {@link Bubble.Content}.
|
|
41
|
+
*/
|
|
42
|
+
interface ContentProps extends TagProps<"div"> {
|
|
43
|
+
/** The turn's text — plain, or wrapped in a typography layer for rendered markdown. */
|
|
44
|
+
children: RemixNode;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Props accepted by {@link Bubble.Reactions}. `aria-label` is required so
|
|
48
|
+
* assistive technology has an accessible name to announce for this row.
|
|
49
|
+
*/
|
|
50
|
+
interface ReactionsProps extends Omit<TagProps<"div">, "aria-label"> {
|
|
51
|
+
/** Accessible label describing the row as a set of reactions. */
|
|
52
|
+
"aria-label": string;
|
|
53
|
+
/** One or more already-pressed toggle controls, each scoped to a single reaction. */
|
|
54
|
+
children: RemixNode;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Props accepted by {@link Bubble.Group}.
|
|
58
|
+
*/
|
|
59
|
+
interface GroupProps extends TagProps<"div"> {
|
|
60
|
+
/** Two or more {@link Bubble} frames from the same turn, stacked into one run. */
|
|
61
|
+
children: RemixNode;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Renders the frame, pushed to the edge `align` names via auto margins so it
|
|
66
|
+
* aligns correctly regardless of its row's layout. Its nearest corner falls
|
|
67
|
+
* back to a literal `0.125rem`, since `roundedCorner()` has no `"xs"` step.
|
|
68
|
+
*
|
|
69
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
70
|
+
* @returns The render function producing the frame's markup.
|
|
71
|
+
* @example
|
|
72
|
+
* <Bubble align="end">
|
|
73
|
+
* <Bubble.Content>{turn.text}</Bubble.Content>
|
|
74
|
+
* </Bubble>
|
|
75
|
+
* @example
|
|
76
|
+
* <Bubble variant="muted" align="start">
|
|
77
|
+
* <Bubble.Content>{turn.text}</Bubble.Content>
|
|
78
|
+
* </Bubble>
|
|
79
|
+
* @example
|
|
80
|
+
* <Bubble variant="ghost" align="start">
|
|
81
|
+
* <Bubble.Content>
|
|
82
|
+
* <Typeset preset="chat">{renderedMarkdownHtml}</Typeset>
|
|
83
|
+
* </Bubble.Content>
|
|
84
|
+
* </Bubble>
|
|
85
|
+
*/
|
|
86
|
+
export declare function Bubble(handle: Handle<Bubble.Props>): () => import("remix/ui").RemixElement;
|
|
87
|
+
export declare namespace Bubble {
|
|
88
|
+
var Content: (handle: Handle<Bubble.ContentProps>) => () => import("remix/ui").RemixElement;
|
|
89
|
+
var Reactions: (handle: Handle<Bubble.ReactionsProps>) => () => import("remix/ui").RemixElement;
|
|
90
|
+
var Group: (handle: Handle<Bubble.GroupProps>) => () => import("remix/ui").RemixElement;
|
|
91
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, border, fg } from "@sdxc/u/color";
|
|
3
|
+
import { rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { raw, vars } from "@sdxc/u/general";
|
|
5
|
+
import { block, container, flex, flexWrap, gap, items, vstack } from "@sdxc/u/layout";
|
|
6
|
+
import { maxIs, mbs, mie, mis, pb, pi, width } from "@sdxc/u/size";
|
|
7
|
+
import { data, when } from "@sdxc/u/state";
|
|
8
|
+
import { wordBreak } from "@sdxc/u/typography";
|
|
9
|
+
import { attrs } from "remix/ui";
|
|
10
|
+
/**
|
|
11
|
+
* Named container {@link Bubble} declares on its own host, so
|
|
12
|
+
* {@link Bubble.Reactions} can measure the frame's own width and fall back to
|
|
13
|
+
* a plain, non-overlapping row once that space runs out.
|
|
14
|
+
*/
|
|
15
|
+
const CONTAINER_NAME = "ui-bubble";
|
|
16
|
+
/** Visual weight {@link Bubble} falls back to when `variant` is omitted. */
|
|
17
|
+
const DEFAULT_VARIANT = "default";
|
|
18
|
+
/** Edge of the row {@link Bubble} falls back to when `align` is omitted. */
|
|
19
|
+
const DEFAULT_ALIGN = "start";
|
|
20
|
+
/**
|
|
21
|
+
* ARIA role applied to {@link Bubble.Reactions} through {@link attrs},
|
|
22
|
+
* announcing the row as one related set of pressed toggles.
|
|
23
|
+
*/
|
|
24
|
+
const DEFAULT_REACTIONS_ROLE = "group";
|
|
25
|
+
/**
|
|
26
|
+
* Renders the frame, pushed to the edge `align` names via auto margins so it
|
|
27
|
+
* aligns correctly regardless of its row's layout. Its nearest corner falls
|
|
28
|
+
* back to a literal `0.125rem`, since `roundedCorner()` has no `"xs"` step.
|
|
29
|
+
*
|
|
30
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
31
|
+
* @returns The render function producing the frame's markup.
|
|
32
|
+
* @example
|
|
33
|
+
* <Bubble align="end">
|
|
34
|
+
* <Bubble.Content>{turn.text}</Bubble.Content>
|
|
35
|
+
* </Bubble>
|
|
36
|
+
* @example
|
|
37
|
+
* <Bubble variant="muted" align="start">
|
|
38
|
+
* <Bubble.Content>{turn.text}</Bubble.Content>
|
|
39
|
+
* </Bubble>
|
|
40
|
+
* @example
|
|
41
|
+
* <Bubble variant="ghost" align="start">
|
|
42
|
+
* <Bubble.Content>
|
|
43
|
+
* <Typeset preset="chat">{renderedMarkdownHtml}</Typeset>
|
|
44
|
+
* </Bubble.Content>
|
|
45
|
+
* </Bubble>
|
|
46
|
+
*/
|
|
47
|
+
export function Bubble(handle) {
|
|
48
|
+
return () => {
|
|
49
|
+
let { variant, align, children, mix, ...rest } = handle.props;
|
|
50
|
+
let resolvedVariant = variant ?? DEFAULT_VARIANT;
|
|
51
|
+
let resolvedAlign = align ?? DEFAULT_ALIGN;
|
|
52
|
+
return (_jsx("div", { ...rest, "data-slot": "bubble", "data-variant": resolvedVariant, "data-align": resolvedAlign, mix: [
|
|
53
|
+
container(CONTAINER_NAME),
|
|
54
|
+
block(),
|
|
55
|
+
maxIs("80%"),
|
|
56
|
+
rounded("xl"),
|
|
57
|
+
border({ width: 1 }),
|
|
58
|
+
border("transparent"),
|
|
59
|
+
width("fit-content"),
|
|
60
|
+
data("align", "start", [
|
|
61
|
+
mie("auto"),
|
|
62
|
+
raw({ borderEndStartRadius: "var(--ui-radius-xs, 0.125rem)" }),
|
|
63
|
+
vars({ "ui-bubble-reactions-justify": "flex-start" }),
|
|
64
|
+
]),
|
|
65
|
+
data("align", "end", [
|
|
66
|
+
mis("auto"),
|
|
67
|
+
raw({ borderEndEndRadius: "var(--ui-radius-xs, 0.125rem)" }),
|
|
68
|
+
vars({ "ui-bubble-reactions-justify": "flex-end" }),
|
|
69
|
+
]),
|
|
70
|
+
data("variant", "default", [bg("brand.solid"), fg("brand.onSolid")]),
|
|
71
|
+
data("variant", "secondary", [bg("neutral.solid"), fg("neutral.onSolid")]),
|
|
72
|
+
data("variant", "muted", [bg("neutral.tint"), fg("neutral.emphasis"), border("neutral")]),
|
|
73
|
+
data("variant", "tinted", [bg("brand.tint"), fg("brand.emphasis"), border("brand")]),
|
|
74
|
+
data("variant", "outline", [
|
|
75
|
+
fg("neutral.emphasis"),
|
|
76
|
+
border("neutral.strong"),
|
|
77
|
+
bg("transparent"),
|
|
78
|
+
]),
|
|
79
|
+
data("variant", "ghost", [
|
|
80
|
+
fg("neutral.emphasis"),
|
|
81
|
+
maxIs("none"),
|
|
82
|
+
mis(0),
|
|
83
|
+
mie(0),
|
|
84
|
+
bg("transparent"),
|
|
85
|
+
border("transparent"),
|
|
86
|
+
width("full"),
|
|
87
|
+
]),
|
|
88
|
+
data("variant", "destructive", [bg("danger.solid"), fg("danger.onSolid")]),
|
|
89
|
+
mix,
|
|
90
|
+
], children: children }));
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Renders {@link Bubble.ContentProps.children} as the frame's padded text
|
|
95
|
+
* slot, breaking long unbroken runs at the inline box edge and taking its
|
|
96
|
+
* text color from the ancestor {@link Bubble}'s `variant` via CSS inheritance.
|
|
97
|
+
*
|
|
98
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
99
|
+
* @returns The render function producing the text slot's markup.
|
|
100
|
+
* @example
|
|
101
|
+
* <Bubble.Content>{turn.text}</Bubble.Content>
|
|
102
|
+
* @example
|
|
103
|
+
* <Bubble.Content>
|
|
104
|
+
* <p>{turn.summary}</p>
|
|
105
|
+
* <Disclosure>
|
|
106
|
+
* <Disclosure.Trigger>{t("message.showMore")}</Disclosure.Trigger>
|
|
107
|
+
* <Disclosure.Panel>{turn.rest}</Disclosure.Panel>
|
|
108
|
+
* </Disclosure>
|
|
109
|
+
* </Bubble.Content>
|
|
110
|
+
* @example
|
|
111
|
+
* <Bubble.Content>
|
|
112
|
+
* {turn.text}
|
|
113
|
+
* <button popovertarget={`${turn.id}-meta`} aria-label={t("message.details")}>
|
|
114
|
+
* <InfoIcon aria-hidden />
|
|
115
|
+
* </button>
|
|
116
|
+
* <Popover id={`${turn.id}-meta`} popover="hint" placement="top-end">
|
|
117
|
+
* {t("message.model", { model: turn.model })}
|
|
118
|
+
* </Popover>
|
|
119
|
+
* </Bubble.Content>
|
|
120
|
+
*/
|
|
121
|
+
Bubble.Content = function BubbleContent(handle) {
|
|
122
|
+
return () => {
|
|
123
|
+
let { children, mix, ...rest } = handle.props;
|
|
124
|
+
return (_jsx("div", { ...rest, "data-slot": "content", mix: [
|
|
125
|
+
pb(2.5),
|
|
126
|
+
pi(3.5),
|
|
127
|
+
raw({
|
|
128
|
+
fontSize: "0.9375rem",
|
|
129
|
+
lineHeight: "1.5",
|
|
130
|
+
overflowWrap: "break-word",
|
|
131
|
+
}),
|
|
132
|
+
wordBreak("break-word"),
|
|
133
|
+
mix,
|
|
134
|
+
], children: children }));
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Renders {@link Bubble.ReactionsProps.children} as a `role="group"` row: a
|
|
139
|
+
* negative block-start margin pins it into the frame's lower padding, aligned
|
|
140
|
+
* via the `--ui-bubble-reactions-justify` property the frame sets from `align`.
|
|
141
|
+
*
|
|
142
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
143
|
+
* @returns The render function producing the reaction row's markup.
|
|
144
|
+
* @example
|
|
145
|
+
* <Bubble.Reactions aria-label={t("message.reactions")}>
|
|
146
|
+
* <ToggleButton
|
|
147
|
+
* aria-pressed={reactions.thumbsUp}
|
|
148
|
+
* aria-label={t("message.reactThumbsUp")}
|
|
149
|
+
* size="sm"
|
|
150
|
+
* name="reaction"
|
|
151
|
+
* value="thumbs-up"
|
|
152
|
+
* >
|
|
153
|
+
* 👍
|
|
154
|
+
* </ToggleButton>
|
|
155
|
+
* <ToggleButton
|
|
156
|
+
* aria-pressed={reactions.heart}
|
|
157
|
+
* aria-label={t("message.reactHeart")}
|
|
158
|
+
* size="sm"
|
|
159
|
+
* name="reaction"
|
|
160
|
+
* value="heart"
|
|
161
|
+
* >
|
|
162
|
+
* ❤️
|
|
163
|
+
* </ToggleButton>
|
|
164
|
+
* </Bubble.Reactions>
|
|
165
|
+
*/
|
|
166
|
+
Bubble.Reactions = function BubbleReactions(handle) {
|
|
167
|
+
return () => {
|
|
168
|
+
let { children, mix, ...rest } = handle.props;
|
|
169
|
+
return (_jsx("div", { ...rest, "data-slot": "reactions", mix: [
|
|
170
|
+
attrs({ role: DEFAULT_REACTIONS_ROLE }),
|
|
171
|
+
flex(),
|
|
172
|
+
flexWrap("wrap"),
|
|
173
|
+
items("center"),
|
|
174
|
+
gap(1),
|
|
175
|
+
pi(0.5),
|
|
176
|
+
mbs(-2),
|
|
177
|
+
raw({ justifyContent: "var(--ui-bubble-reactions-justify, flex-start)" }),
|
|
178
|
+
when(`@container ${CONTAINER_NAME} (max-width: 16rem)`, mbs("0.375rem")),
|
|
179
|
+
mix,
|
|
180
|
+
], children: children }));
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Renders {@link Bubble.GroupProps.children} as a tightly spaced column of
|
|
185
|
+
* consecutive {@link Bubble} frames, softening only the corners touching a
|
|
186
|
+
* neighbor to a smaller radius, so the run reads as one continuous shape.
|
|
187
|
+
*
|
|
188
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
189
|
+
* @returns The render function producing the run's markup.
|
|
190
|
+
* @example
|
|
191
|
+
* <Bubble.Group>
|
|
192
|
+
* <Bubble align="end"><Bubble.Content>{turnOne.text}</Bubble.Content></Bubble>
|
|
193
|
+
* <Bubble align="end"><Bubble.Content>{turnTwo.text}</Bubble.Content></Bubble>
|
|
194
|
+
* </Bubble.Group>
|
|
195
|
+
*/
|
|
196
|
+
Bubble.Group = function BubbleGroup(handle) {
|
|
197
|
+
return () => {
|
|
198
|
+
let { children, mix, ...rest } = handle.props;
|
|
199
|
+
return (_jsx("div", { ...rest, "data-slot": "group", mix: [
|
|
200
|
+
vstack({ gap: 0.5 }),
|
|
201
|
+
when('& > [data-slot="bubble"]:not(:first-child)', [
|
|
202
|
+
raw({
|
|
203
|
+
borderStartStartRadius: "var(--ui-radius-xs, 0.125rem)",
|
|
204
|
+
borderStartEndRadius: "var(--ui-radius-xs, 0.125rem)",
|
|
205
|
+
}),
|
|
206
|
+
]),
|
|
207
|
+
when('& > [data-slot="bubble"]:not(:last-child)', [
|
|
208
|
+
raw({
|
|
209
|
+
borderEndStartRadius: "var(--ui-radius-xs, 0.125rem)",
|
|
210
|
+
borderEndEndRadius: "var(--ui-radius-xs, 0.125rem)",
|
|
211
|
+
}),
|
|
212
|
+
]),
|
|
213
|
+
mix,
|
|
214
|
+
], children: children }));
|
|
215
|
+
};
|
|
216
|
+
};
|