@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,320 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, border, fg, outline } from "@sdxc/u/color";
|
|
3
|
+
import { rounded, transition } from "@sdxc/u/effects";
|
|
4
|
+
import { raw } from "@sdxc/u/general";
|
|
5
|
+
import { basis, block, container, flex, flexCol, gap, grow, hstack, items, justify, relative, shrink, vstack, } from "@sdxc/u/layout";
|
|
6
|
+
import { overflow, overflowX } from "@sdxc/u/overflow";
|
|
7
|
+
import { media } from "@sdxc/u/responsive";
|
|
8
|
+
import { aspect, bs, fit, is, minIs, p } from "@sdxc/u/size";
|
|
9
|
+
import { when } from "@sdxc/u/state";
|
|
10
|
+
import { text, textAlign, truncate, weight } from "@sdxc/u/typography";
|
|
11
|
+
import { attrs } from "remix/ui";
|
|
12
|
+
import { shimmer } from "../animations/keyframes.js";
|
|
13
|
+
import { scrollFade } from "../animations/scroll.js";
|
|
14
|
+
import { Button } from "./button.js";
|
|
15
|
+
const DEFAULT_STATE = "idle";
|
|
16
|
+
/**
|
|
17
|
+
* Named container {@link Attachment} declares on its own host, so
|
|
18
|
+
* {@link Attachment.Media}, {@link Attachment.Content}, and the inner layout
|
|
19
|
+
* wrapper resolve their width queries against the card itself.
|
|
20
|
+
*/
|
|
21
|
+
const CONTAINER_NAME = "ui-attachment";
|
|
22
|
+
/**
|
|
23
|
+
* `@container` query every width-adapting part below the root shares: at or
|
|
24
|
+
* under this width the card reflows into a taller tile, the shape
|
|
25
|
+
* {@link Attachment.Group}'s narrow, fixed-width cards need.
|
|
26
|
+
*/
|
|
27
|
+
const NARROW_CONTAINER_QUERY = `@container ${CONTAINER_NAME} (max-width: 12rem)`;
|
|
28
|
+
/**
|
|
29
|
+
* Selector fragment gating {@link Attachment.Title}'s shimmer: it matches the
|
|
30
|
+
* title's own `data-state` attribute while that reads `"uploading"` or
|
|
31
|
+
* `"processing"`, so a title given no state stays plain.
|
|
32
|
+
*/
|
|
33
|
+
const TITLE_SHIMMER_WHEN = ':is([data-state="uploading"], [data-state="processing"])';
|
|
34
|
+
const DEFAULT_ACTION_VARIANT = "ghost";
|
|
35
|
+
const DEFAULT_ACTION_SIZE = "sm";
|
|
36
|
+
const DEFAULT_ACTION_COLOR = "neutral";
|
|
37
|
+
/**
|
|
38
|
+
* Tab-stop order {@link attrs} applies to {@link Attachment.Group} when a
|
|
39
|
+
* consumer supplies no `tabIndex`, so the row itself stays keyboard-reachable
|
|
40
|
+
* and scrollable whatever its cards contain.
|
|
41
|
+
*/
|
|
42
|
+
const DEFAULT_GROUP_TAB_INDEX = 0;
|
|
43
|
+
const GROUP_SCROLL_FADE_SIZE = "2rem";
|
|
44
|
+
/**
|
|
45
|
+
* The card's outer host, recolored to the danger tint at `state="error"` and
|
|
46
|
+
* declaring the `ui-attachment` named container so nested parts reflow at the
|
|
47
|
+
* card's width. A busy state sets `aria-busy` to the token ARIA recognizes.
|
|
48
|
+
*
|
|
49
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
50
|
+
* @returns The render function producing the card's markup.
|
|
51
|
+
* @example
|
|
52
|
+
* <Attachment state="uploading">
|
|
53
|
+
* <Attachment.Media><FileIcon aria-hidden /></Attachment.Media>
|
|
54
|
+
* <Attachment.Content>
|
|
55
|
+
* <Attachment.Title state="uploading">quarterly-report.pdf</Attachment.Title>
|
|
56
|
+
* <Attachment.Description>{t("attachment.uploading")}</Attachment.Description>
|
|
57
|
+
* </Attachment.Content>
|
|
58
|
+
* </Attachment>
|
|
59
|
+
* @example
|
|
60
|
+
* <Attachment state="error">
|
|
61
|
+
* <Attachment.Media><FileIcon aria-hidden /></Attachment.Media>
|
|
62
|
+
* <Attachment.Content>
|
|
63
|
+
* <Attachment.Title>quarterly-report.pdf</Attachment.Title>
|
|
64
|
+
* <Attachment.Description>{t("attachment.uploadFailed")}</Attachment.Description>
|
|
65
|
+
* </Attachment.Content>
|
|
66
|
+
* <Attachment.Actions>
|
|
67
|
+
* <Attachment.Action aria-label={t("attachment.retry")}><RotateCwIcon /></Attachment.Action>
|
|
68
|
+
* </Attachment.Actions>
|
|
69
|
+
* </Attachment>
|
|
70
|
+
*/
|
|
71
|
+
export function Attachment(handle) {
|
|
72
|
+
return () => {
|
|
73
|
+
let { state, children, mix, ...rest } = handle.props;
|
|
74
|
+
let resolvedState = state ?? DEFAULT_STATE;
|
|
75
|
+
let isBusy = resolvedState === "uploading" || resolvedState === "processing";
|
|
76
|
+
return (_jsx("div", { ...rest, "data-slot": "attachment", "data-state": resolvedState, "aria-busy": isBusy ? "true" : undefined, mix: [
|
|
77
|
+
relative(),
|
|
78
|
+
rounded("lg"),
|
|
79
|
+
border({ width: 1 }),
|
|
80
|
+
border("neutral"),
|
|
81
|
+
bg("neutral.tint"),
|
|
82
|
+
fg("neutral.emphasis"),
|
|
83
|
+
p(3),
|
|
84
|
+
transition("border-color, background-color"),
|
|
85
|
+
container(CONTAINER_NAME),
|
|
86
|
+
when('&[data-state="error"]', [
|
|
87
|
+
border("danger"),
|
|
88
|
+
bg("danger.tint"),
|
|
89
|
+
fg("danger.emphasis"),
|
|
90
|
+
]),
|
|
91
|
+
mix,
|
|
92
|
+
], children: _jsx("div", { "data-slot": "body", mix: [
|
|
93
|
+
hstack({ gap: 3, align: "center" }),
|
|
94
|
+
when(NARROW_CONTAINER_QUERY, [flexCol(), items("stretch")]),
|
|
95
|
+
], children: children }) }));
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The card's media well: a fixed-size, rounded box clipping the preview a
|
|
100
|
+
* consumer nests inside. Inside a narrow container it grows to the card's own
|
|
101
|
+
* inline size at a wider aspect ratio, reading as a thumbnail tile.
|
|
102
|
+
*
|
|
103
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
104
|
+
* @returns The render function producing the media well's markup.
|
|
105
|
+
* @example
|
|
106
|
+
* <Attachment.Media><img src={file.thumbnailUrl} alt="" /></Attachment.Media>
|
|
107
|
+
* @example
|
|
108
|
+
* <Attachment.Media><FileTextIcon aria-hidden /></Attachment.Media>
|
|
109
|
+
*/
|
|
110
|
+
Attachment.Media = function AttachmentMedia(handle) {
|
|
111
|
+
return () => {
|
|
112
|
+
let { children, mix, ...rest } = handle.props;
|
|
113
|
+
return (_jsx("div", { ...rest, "data-slot": "media", mix: [
|
|
114
|
+
flex(),
|
|
115
|
+
shrink(0),
|
|
116
|
+
items("center"),
|
|
117
|
+
justify("center"),
|
|
118
|
+
overflow(),
|
|
119
|
+
is(10),
|
|
120
|
+
bs(10),
|
|
121
|
+
rounded("md"),
|
|
122
|
+
bg("neutral.bg-tint-hover"),
|
|
123
|
+
fg("neutral"),
|
|
124
|
+
when("& > svg", [is(5), bs(5)]),
|
|
125
|
+
when("& > img", [is("full"), bs("full"), fit("cover")]),
|
|
126
|
+
when(NARROW_CONTAINER_QUERY, [is("full"), bs("auto"), aspect(4, 3), rounded("lg")]),
|
|
127
|
+
mix,
|
|
128
|
+
], children: children }));
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* The card's text column, growing into whatever inline space
|
|
133
|
+
* {@link Attachment.Media} and {@link Attachment.Actions} leave it. Its minimum
|
|
134
|
+
* inline size collapses to `0`, which is what lets its children truncate.
|
|
135
|
+
*
|
|
136
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
137
|
+
* @returns The render function producing the text column's markup.
|
|
138
|
+
* @example
|
|
139
|
+
* <Attachment.Content>
|
|
140
|
+
* <Attachment.Title>quarterly-report.pdf</Attachment.Title>
|
|
141
|
+
* <Attachment.Description>2.4 MB</Attachment.Description>
|
|
142
|
+
* </Attachment.Content>
|
|
143
|
+
*/
|
|
144
|
+
Attachment.Content = function AttachmentContent(handle) {
|
|
145
|
+
return () => {
|
|
146
|
+
let { children, mix, ...rest } = handle.props;
|
|
147
|
+
return (_jsx("div", { ...rest, "data-slot": "content", mix: [
|
|
148
|
+
vstack({ gap: 0.5 }),
|
|
149
|
+
minIs(0),
|
|
150
|
+
grow(),
|
|
151
|
+
shrink(1),
|
|
152
|
+
basis("0%"),
|
|
153
|
+
when(NARROW_CONTAINER_QUERY, textAlign("center")),
|
|
154
|
+
mix,
|
|
155
|
+
], children: children }));
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* The file or image name in a native `<p>`, truncated to a single line with an
|
|
160
|
+
* ellipsis. Given the same `state` as the ancestor {@link Attachment}, it
|
|
161
|
+
* shimmers while that reads `"uploading"` or `"processing"`, then settles.
|
|
162
|
+
*
|
|
163
|
+
* @param handle Runtime handle carrying the host `<p>`'s props.
|
|
164
|
+
* @returns The render function producing the title's markup.
|
|
165
|
+
* @example
|
|
166
|
+
* <Attachment.Title>quarterly-report.pdf</Attachment.Title>
|
|
167
|
+
* @example
|
|
168
|
+
* <Attachment.Title state={attachment.state}>{attachment.name}</Attachment.Title>
|
|
169
|
+
*/
|
|
170
|
+
Attachment.Title = function AttachmentTitle(handle) {
|
|
171
|
+
return () => {
|
|
172
|
+
let { state, children, mix, ...rest } = handle.props;
|
|
173
|
+
return (_jsx("p", { ...rest, "data-slot": "title", "data-state": state, mix: [
|
|
174
|
+
weight("semibold"),
|
|
175
|
+
truncate(),
|
|
176
|
+
text("sm"),
|
|
177
|
+
shimmer({ when: TITLE_SHIMMER_WHEN }),
|
|
178
|
+
mix,
|
|
179
|
+
], children: children }));
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* The card's supporting detail line: a muted, single-line `<p>` carrying a file
|
|
184
|
+
* size, a page count, or the explanation of what went wrong once the ancestor
|
|
185
|
+
* {@link Attachment}'s `state` reads `"error"`.
|
|
186
|
+
*
|
|
187
|
+
* @param handle Runtime handle carrying the host `<p>`'s props.
|
|
188
|
+
* @returns The render function producing the description's markup.
|
|
189
|
+
* @example
|
|
190
|
+
* <Attachment.Description>2.4 MB</Attachment.Description>
|
|
191
|
+
* @example
|
|
192
|
+
* <Attachment.Description>{t("attachment.uploadFailed")}</Attachment.Description>
|
|
193
|
+
*/
|
|
194
|
+
Attachment.Description = function AttachmentDescription(handle) {
|
|
195
|
+
return () => {
|
|
196
|
+
let { children, mix, ...rest } = handle.props;
|
|
197
|
+
return (_jsx("p", { ...rest, "data-slot": "description", mix: [truncate(), fg("neutral.muted"), text("xs"), mix], children: children }));
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* The card's action row, shrink-proof so a narrow card's width is absorbed by
|
|
202
|
+
* {@link Attachment.Content}'s own truncation while the actions keep their
|
|
203
|
+
* size.
|
|
204
|
+
*
|
|
205
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
206
|
+
* @returns The render function producing the action row's markup.
|
|
207
|
+
* @example
|
|
208
|
+
* <Attachment.Actions>
|
|
209
|
+
* <Attachment.Action aria-label={t("attachment.download")}><DownloadIcon /></Attachment.Action>
|
|
210
|
+
* <Attachment.Action aria-label={t("attachment.remove")}><XIcon /></Attachment.Action>
|
|
211
|
+
* </Attachment.Actions>
|
|
212
|
+
*/
|
|
213
|
+
Attachment.Actions = function AttachmentActions(handle) {
|
|
214
|
+
return () => {
|
|
215
|
+
let { children, mix, ...rest } = handle.props;
|
|
216
|
+
return (_jsx("div", { ...rest, "data-slot": "actions", mix: [flex(), shrink(0), items("center"), gap(1), mix], children: children }));
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* A single card action as a {@link Button}, defaulting to a compact, `"ghost"`,
|
|
221
|
+
* neutral control so a row of actions reads as secondary to the card's title.
|
|
222
|
+
* Every {@link Button} prop stays available, `type` included.
|
|
223
|
+
*
|
|
224
|
+
* @param handle Runtime handle carrying the host button's props.
|
|
225
|
+
* @returns The render function producing the action's markup.
|
|
226
|
+
* @example
|
|
227
|
+
* <Attachment.Action aria-label={t("attachment.download")}>
|
|
228
|
+
* <DownloadIcon />
|
|
229
|
+
* </Attachment.Action>
|
|
230
|
+
* @example
|
|
231
|
+
* <Attachment.Action type="submit" name="intent" value="retry" aria-label={t("attachment.retry")}>
|
|
232
|
+
* <RotateCwIcon />
|
|
233
|
+
* </Attachment.Action>
|
|
234
|
+
*/
|
|
235
|
+
Attachment.Action = function AttachmentAction(handle) {
|
|
236
|
+
return () => {
|
|
237
|
+
let { color, variant, size, mix, ...rest } = handle.props;
|
|
238
|
+
return (_jsx(Button, { color: color ?? DEFAULT_ACTION_COLOR, variant: variant ?? DEFAULT_ACTION_VARIANT, size: size ?? DEFAULT_ACTION_SIZE, ...rest, "data-slot": "action", mix: [shrink(0), mix] }));
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* A wrapper `<div>` whose `href` or `commandfor` stays an inert attribute until
|
|
243
|
+
* a consumer mixes in `attachmentTrigger()`. Either one also derives a `role`
|
|
244
|
+
* and `tabIndex`, so whole-card activation is announced and keyboard-reachable.
|
|
245
|
+
*
|
|
246
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
247
|
+
* @returns The render function producing the wrapper's markup.
|
|
248
|
+
* @example
|
|
249
|
+
* <Attachment.Trigger href="/files/quarterly-report.pdf" mix={attachmentTrigger()}>
|
|
250
|
+
* <Attachment state="done">
|
|
251
|
+
* <Attachment.Media><FileTextIcon aria-hidden /></Attachment.Media>
|
|
252
|
+
* <Attachment.Content>
|
|
253
|
+
* <Attachment.Title>quarterly-report.pdf</Attachment.Title>
|
|
254
|
+
* </Attachment.Content>
|
|
255
|
+
* <Attachment.Actions>
|
|
256
|
+
* <Attachment.Action aria-label={t("attachment.download")}><DownloadIcon /></Attachment.Action>
|
|
257
|
+
* </Attachment.Actions>
|
|
258
|
+
* </Attachment>
|
|
259
|
+
* </Attachment.Trigger>
|
|
260
|
+
* @example
|
|
261
|
+
* <Attachment.Trigger commandfor="quarterly-report-preview" mix={attachmentTrigger()}>
|
|
262
|
+
* <Attachment state="done">…</Attachment>
|
|
263
|
+
* </Attachment.Trigger>
|
|
264
|
+
* <Dialog id="quarterly-report-preview">…</Dialog>
|
|
265
|
+
*/
|
|
266
|
+
Attachment.Trigger = function AttachmentTrigger(handle) {
|
|
267
|
+
return () => {
|
|
268
|
+
let { href, commandfor, command, target, role, tabIndex, children, mix, ...rest } = handle.props;
|
|
269
|
+
let isConfigured = href !== undefined || commandfor !== undefined;
|
|
270
|
+
let resolvedRole = role ?? (href !== undefined ? "link" : isConfigured ? "button" : undefined);
|
|
271
|
+
let resolvedTabIndex = tabIndex ?? (isConfigured ? 0 : undefined);
|
|
272
|
+
if (import.meta.env.DEV && !isConfigured) {
|
|
273
|
+
console.warn('Attachment.Trigger: rendered with neither "href" nor "commandfor" — nothing will happen once `attachmentTrigger()` handles an activation.');
|
|
274
|
+
}
|
|
275
|
+
return (_jsx("div", { ...rest, role: resolvedRole, tabIndex: resolvedTabIndex, "data-slot": "trigger", mix: [
|
|
276
|
+
attrs({ href, commandfor, command, target }),
|
|
277
|
+
relative(),
|
|
278
|
+
block(),
|
|
279
|
+
rounded("inherit"),
|
|
280
|
+
when("&[role]:hover", bg("neutral.bg-tint-hover")),
|
|
281
|
+
when("&[role]:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
282
|
+
mix,
|
|
283
|
+
], children: children }));
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* A horizontally scroll-snapping row of cards, faded at both inline edges to
|
|
288
|
+
* hint at cards beyond the current view. The row itself carries the tab stop,
|
|
289
|
+
* since the row is what scrolls.
|
|
290
|
+
*
|
|
291
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
292
|
+
* @returns The render function producing the row's markup.
|
|
293
|
+
* @example
|
|
294
|
+
* <Attachment.Group aria-label={t("thread.attachments")}>
|
|
295
|
+
* {attachments.map((attachment) => (
|
|
296
|
+
* <Attachment key={attachment.id} state={attachment.state}>…</Attachment>
|
|
297
|
+
* ))}
|
|
298
|
+
* </Attachment.Group>
|
|
299
|
+
*/
|
|
300
|
+
Attachment.Group = function AttachmentGroup(handle) {
|
|
301
|
+
return () => {
|
|
302
|
+
let { children, mix, ...rest } = handle.props;
|
|
303
|
+
return (_jsx("div", { ...rest, "data-slot": "group", mix: [
|
|
304
|
+
attrs({ tabIndex: DEFAULT_GROUP_TAB_INDEX }),
|
|
305
|
+
flex(),
|
|
306
|
+
gap(3),
|
|
307
|
+
overflowX("auto"),
|
|
308
|
+
raw({
|
|
309
|
+
overscrollBehaviorInline: "contain",
|
|
310
|
+
scrollSnapType: "inline mandatory",
|
|
311
|
+
scrollPaddingInline: "0.75rem",
|
|
312
|
+
scrollBehavior: "auto",
|
|
313
|
+
}),
|
|
314
|
+
when("& > *", [shrink(0), raw({ scrollSnapAlign: "start" })]),
|
|
315
|
+
media("(prefers-reduced-motion: no-preference)", raw({ scrollBehavior: "smooth" })),
|
|
316
|
+
scrollFade({ axis: "inline", size: GROUP_SCROLL_FADE_SIZE }),
|
|
317
|
+
mix,
|
|
318
|
+
], children: children }));
|
|
319
|
+
};
|
|
320
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A person's or entity's picture rendered as a fixed-size, fully circular
|
|
3
|
+
* host stacking an image layer, an initials fallback, and an optional corner
|
|
4
|
+
* status badge, plus a way to overlap several instances into one group with
|
|
5
|
+
* a trailing overflow count. The circular shape stays fixed, since a profile
|
|
6
|
+
* picture always renders fully rounded.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { Handle } from "remix/ui";
|
|
12
|
+
import { ImagePlaceholder } from "./image-placeholder.js";
|
|
13
|
+
/**
|
|
14
|
+
* Prop types for {@link Avatar} and its compound parts. Each part aliases
|
|
15
|
+
* {@link ImagePlaceholder}'s matching part, since {@link Avatar} renders
|
|
16
|
+
* straight through to it with the shape fixed to a full circle.
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace Avatar {
|
|
19
|
+
/**
|
|
20
|
+
* Size variant controlling the host's rendered dimensions and, through
|
|
21
|
+
* ordinary inheritance, the fallback initials' font size. Re-exports
|
|
22
|
+
* {@link ImagePlaceholder.Size}.
|
|
23
|
+
*/
|
|
24
|
+
type Size = ImagePlaceholder.Size;
|
|
25
|
+
/**
|
|
26
|
+
* Props accepted by {@link Avatar}: every prop {@link ImagePlaceholder.Props}
|
|
27
|
+
* accepts except `shape`, which stays fixed to a full circle.
|
|
28
|
+
*/
|
|
29
|
+
interface Props extends Omit<ImagePlaceholder.Props, "shape"> {
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Props accepted by {@link Avatar.Image}, unchanged from
|
|
33
|
+
* {@link ImagePlaceholder.ImageProps}.
|
|
34
|
+
*/
|
|
35
|
+
interface ImageProps extends ImagePlaceholder.ImageProps {
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Props accepted by {@link Avatar.Fallback}, unchanged from
|
|
39
|
+
* {@link ImagePlaceholder.FallbackProps}.
|
|
40
|
+
*/
|
|
41
|
+
interface FallbackProps extends ImagePlaceholder.FallbackProps {
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Props accepted by {@link Avatar.Badge}, unchanged from
|
|
45
|
+
* {@link ImagePlaceholder.BadgeProps}.
|
|
46
|
+
*/
|
|
47
|
+
interface BadgeProps extends ImagePlaceholder.BadgeProps {
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Props accepted by {@link Avatar.Group}, unchanged from
|
|
51
|
+
* {@link ImagePlaceholder.GroupProps}.
|
|
52
|
+
*/
|
|
53
|
+
interface GroupProps extends ImagePlaceholder.GroupProps {
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Props accepted by {@link Avatar.Group.Count}: every prop
|
|
57
|
+
* {@link ImagePlaceholder.GroupCountProps} accepts except `shape`, which
|
|
58
|
+
* stays fixed to the same full circle the avatars it trails render with.
|
|
59
|
+
*/
|
|
60
|
+
interface GroupCountProps extends Omit<ImagePlaceholder.GroupCountProps, "shape"> {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Renders a fixed-size, fully circular picture host sized through the
|
|
65
|
+
* `data-size` attribute contract (`"sm"`, `"md"`, or `"lg"`), stacking
|
|
66
|
+
* whichever image, fallback, and badge parts a consumer composes as children.
|
|
67
|
+
*
|
|
68
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
69
|
+
* @returns The render function producing the picture host's markup.
|
|
70
|
+
* @example
|
|
71
|
+
* <Avatar>
|
|
72
|
+
* <Avatar.Image src={user.avatarUrl} alt={user.name} />
|
|
73
|
+
* <Avatar.Fallback>{initials}</Avatar.Fallback>
|
|
74
|
+
* </Avatar>
|
|
75
|
+
* @example
|
|
76
|
+
* <Avatar size="lg">
|
|
77
|
+
* <Avatar.Image src={user.avatarUrl} alt={user.name} />
|
|
78
|
+
* <Avatar.Fallback>{initials}</Avatar.Fallback>
|
|
79
|
+
* <Avatar.Badge aria-label={t("status.online")} />
|
|
80
|
+
* </Avatar>
|
|
81
|
+
*/
|
|
82
|
+
export declare function Avatar(handle: Handle<Avatar.Props>): () => import("remix/ui").RemixElement;
|
|
83
|
+
export declare namespace Avatar {
|
|
84
|
+
var Image: (handle: Handle<ImagePlaceholder.ImageProps>) => () => import("remix/ui").RemixElement;
|
|
85
|
+
var Fallback: (handle: Handle<ImagePlaceholder.FallbackProps>) => () => import("remix/ui").RemixElement;
|
|
86
|
+
var Badge: (handle: Handle<ImagePlaceholder.BadgeProps>) => () => import("remix/ui").RemixElement;
|
|
87
|
+
var Group: typeof AvatarGroup;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Renders {@link Avatar.GroupProps.children} as a row of overlapping
|
|
91
|
+
* avatars, pulling every child but the first back over its predecessor and
|
|
92
|
+
* ringing it, so the overlap reads as stacked cutouts.
|
|
93
|
+
*
|
|
94
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
95
|
+
* @returns The render function producing the group's markup.
|
|
96
|
+
* @example
|
|
97
|
+
* <Avatar.Group>
|
|
98
|
+
* <Avatar>…</Avatar>
|
|
99
|
+
* <Avatar>…</Avatar>
|
|
100
|
+
* <Avatar.Group.Count>+3</Avatar.Group.Count>
|
|
101
|
+
* </Avatar.Group>
|
|
102
|
+
*/
|
|
103
|
+
declare function AvatarGroup(handle: Handle<Avatar.GroupProps>): () => import("remix/ui").RemixElement;
|
|
104
|
+
declare namespace AvatarGroup {
|
|
105
|
+
var Count: typeof AvatarGroupCount;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Renders the "+N" overflow indicator that trails {@link Avatar.Group}: a
|
|
109
|
+
* fixed medium-size box matching {@link Avatar}'s default dimensions, ringed
|
|
110
|
+
* the same way a grouped avatar is and fixed to the same full circle.
|
|
111
|
+
*
|
|
112
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
113
|
+
* @returns The render function producing the overflow indicator's markup.
|
|
114
|
+
* @example
|
|
115
|
+
* <Avatar.Group.Count>+3</Avatar.Group.Count>
|
|
116
|
+
*/
|
|
117
|
+
declare function AvatarGroupCount(handle: Handle<Avatar.GroupCountProps>): () => import("remix/ui").RemixElement;
|
|
118
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { ImagePlaceholder } from "./image-placeholder.js";
|
|
3
|
+
/**
|
|
4
|
+
* Renders a fixed-size, fully circular picture host sized through the
|
|
5
|
+
* `data-size` attribute contract (`"sm"`, `"md"`, or `"lg"`), stacking
|
|
6
|
+
* whichever image, fallback, and badge parts a consumer composes as children.
|
|
7
|
+
*
|
|
8
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
9
|
+
* @returns The render function producing the picture host's markup.
|
|
10
|
+
* @example
|
|
11
|
+
* <Avatar>
|
|
12
|
+
* <Avatar.Image src={user.avatarUrl} alt={user.name} />
|
|
13
|
+
* <Avatar.Fallback>{initials}</Avatar.Fallback>
|
|
14
|
+
* </Avatar>
|
|
15
|
+
* @example
|
|
16
|
+
* <Avatar size="lg">
|
|
17
|
+
* <Avatar.Image src={user.avatarUrl} alt={user.name} />
|
|
18
|
+
* <Avatar.Fallback>{initials}</Avatar.Fallback>
|
|
19
|
+
* <Avatar.Badge aria-label={t("status.online")} />
|
|
20
|
+
* </Avatar>
|
|
21
|
+
*/
|
|
22
|
+
export function Avatar(handle) {
|
|
23
|
+
return () => _jsx(ImagePlaceholder, { ...handle.props, shape: "circle" });
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Renders the avatar's image layer: an absolutely positioned `<img>` filling
|
|
27
|
+
* the host edge to edge, cropped with `object-fit: cover` and clipped to
|
|
28
|
+
* {@link Avatar}'s circular shape. Stacking order decides which layer shows.
|
|
29
|
+
*
|
|
30
|
+
* @param handle Runtime handle carrying the host `<img>`'s props.
|
|
31
|
+
* @returns The render function producing the image layer's markup.
|
|
32
|
+
* @example
|
|
33
|
+
* <Avatar.Image src={user.avatarUrl} alt={user.name} />
|
|
34
|
+
*/
|
|
35
|
+
Avatar.Image = ImagePlaceholder.Image;
|
|
36
|
+
/**
|
|
37
|
+
* Renders the avatar's fallback layer: an absolutely positioned `<span>`
|
|
38
|
+
* centering its content (typically initials) in uppercase, medium-weight
|
|
39
|
+
* text whose size inherits from the host, staying in proportion at any size.
|
|
40
|
+
*
|
|
41
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
42
|
+
* @returns The render function producing the fallback layer's markup.
|
|
43
|
+
* @example
|
|
44
|
+
* <Avatar.Fallback>{initials}</Avatar.Fallback>
|
|
45
|
+
*/
|
|
46
|
+
Avatar.Fallback = ImagePlaceholder.Fallback;
|
|
47
|
+
/**
|
|
48
|
+
* Renders a small status dot pinned to the host's block-end/inline-end
|
|
49
|
+
* corner: always fully rounded and ringed with a border matching the
|
|
50
|
+
* surrounding background, so it reads as cut out from what sits beneath it.
|
|
51
|
+
*
|
|
52
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
53
|
+
* @returns The render function producing the badge's markup.
|
|
54
|
+
* @example
|
|
55
|
+
* <Avatar.Badge aria-label={t("status.online")} />
|
|
56
|
+
*/
|
|
57
|
+
Avatar.Badge = ImagePlaceholder.Badge;
|
|
58
|
+
/**
|
|
59
|
+
* Renders {@link Avatar.GroupProps.children} as a row of overlapping
|
|
60
|
+
* avatars, pulling every child but the first back over its predecessor and
|
|
61
|
+
* ringing it, so the overlap reads as stacked cutouts.
|
|
62
|
+
*
|
|
63
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
64
|
+
* @returns The render function producing the group's markup.
|
|
65
|
+
* @example
|
|
66
|
+
* <Avatar.Group>
|
|
67
|
+
* <Avatar>…</Avatar>
|
|
68
|
+
* <Avatar>…</Avatar>
|
|
69
|
+
* <Avatar.Group.Count>+3</Avatar.Group.Count>
|
|
70
|
+
* </Avatar.Group>
|
|
71
|
+
*/
|
|
72
|
+
function AvatarGroup(handle) {
|
|
73
|
+
return () => _jsx(ImagePlaceholder.Group, { ...handle.props });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Renders the "+N" overflow indicator that trails {@link Avatar.Group}: a
|
|
77
|
+
* fixed medium-size box matching {@link Avatar}'s default dimensions, ringed
|
|
78
|
+
* the same way a grouped avatar is and fixed to the same full circle.
|
|
79
|
+
*
|
|
80
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
81
|
+
* @returns The render function producing the overflow indicator's markup.
|
|
82
|
+
* @example
|
|
83
|
+
* <Avatar.Group.Count>+3</Avatar.Group.Count>
|
|
84
|
+
*/
|
|
85
|
+
function AvatarGroupCount(handle) {
|
|
86
|
+
return () => _jsx(ImagePlaceholder.GroupCount, { ...handle.props, shape: "circle" });
|
|
87
|
+
}
|
|
88
|
+
AvatarGroup.Count = AvatarGroupCount;
|
|
89
|
+
Avatar.Group = AvatarGroup;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A compact pill communicating a short status, label, or count inline with
|
|
3
|
+
* surrounding content. Its host renders solid, tinted, or outlined depending
|
|
4
|
+
* on a variant attribute, colored through a semantic color role, and
|
|
5
|
+
* composes with `Icon` and `Text` parts for glyph-plus-label badges.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
11
|
+
import type { SemanticColor } from "../utils/semantic-color.js";
|
|
12
|
+
/**
|
|
13
|
+
* Prop types for {@link Badge} and its compound parts.
|
|
14
|
+
*/
|
|
15
|
+
export declare namespace Badge {
|
|
16
|
+
/**
|
|
17
|
+
* Semantic color role, each mapped to its matching `--ui-*` variables.
|
|
18
|
+
*/
|
|
19
|
+
type Color = SemanticColor;
|
|
20
|
+
/**
|
|
21
|
+
* Visual weight the badge renders with: a solid fill, a tinted fill, or
|
|
22
|
+
* a transparent chip with just an outline.
|
|
23
|
+
*/
|
|
24
|
+
type Variant = "default" | "secondary" | "outline";
|
|
25
|
+
/**
|
|
26
|
+
* Props accepted by {@link Badge}.
|
|
27
|
+
*/
|
|
28
|
+
interface Props extends TagProps<"span"> {
|
|
29
|
+
/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */
|
|
30
|
+
color?: Color;
|
|
31
|
+
/** Visual weight. Defaults to {@link DEFAULT_VARIANT}. */
|
|
32
|
+
variant?: Variant;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Props accepted by {@link Badge.Icon}.
|
|
36
|
+
*/
|
|
37
|
+
interface IconProps extends TagProps<"span"> {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Props accepted by {@link Badge.Text}.
|
|
41
|
+
*/
|
|
42
|
+
interface TextProps extends TagProps<"span"> {
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Renders a single-line pill host, colored and shaped through the
|
|
47
|
+
* `data-color` and `data-variant` attribute contract: `"default"` fills the
|
|
48
|
+
* pill solid, `"secondary"` tints the fill, `"outline"` keeps just a border.
|
|
49
|
+
*
|
|
50
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
51
|
+
* @returns The render function producing the badge's markup.
|
|
52
|
+
* @example
|
|
53
|
+
* <Badge>{t("badge.new")}</Badge>
|
|
54
|
+
* @example
|
|
55
|
+
* <Badge color="success" variant="secondary">
|
|
56
|
+
* <Badge.Icon><CheckIcon /></Badge.Icon>
|
|
57
|
+
* <Badge.Text>{t("badge.active")}</Badge.Text>
|
|
58
|
+
* </Badge>
|
|
59
|
+
* @example
|
|
60
|
+
* <Badge color="danger" variant="outline">{t("badge.failed")}</Badge>
|
|
61
|
+
*/
|
|
62
|
+
export declare function Badge(handle: Handle<Badge.Props>): () => import("remix/ui").RemixElement;
|
|
63
|
+
export declare namespace Badge {
|
|
64
|
+
var Icon: (handle: Handle<Badge.IconProps>) => () => import("remix/ui").RemixElement;
|
|
65
|
+
var Text: (handle: Handle<Badge.TextProps>) => () => import("remix/ui").RemixElement;
|
|
66
|
+
}
|