@astra-kit/ui 0.0.0-stage → 1.0.0
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/CHANGELOG.md +21 -0
- package/LICENSE.md +21 -0
- package/README.md +330 -2
- package/THIRD_PARTY_NOTICES.md +31 -0
- package/assets/fonts/geist-LICENSE.txt +93 -0
- package/assets/fonts/geist-latin-variable.woff2 +0 -0
- package/assets/fonts/ibm-plex-mono-latin-400.woff2 +0 -0
- package/assets/fonts/ibm-plex-mono-latin-500.woff2 +0 -0
- package/assets/fonts/ibmplexmono-LICENSE.txt +93 -0
- package/assets/fonts/inter-LICENSE.txt +93 -0
- package/assets/fonts/inter-latin-variable.woff2 +0 -0
- package/dist/adapters/unpic-image.d.ts +3 -0
- package/dist/adapters/unpic-image.js +98 -0
- package/dist/components/account-menu.d.ts +67 -0
- package/dist/components/account-menu.js +440 -0
- package/dist/components/action-button.d.ts +25 -0
- package/dist/components/action-button.js +264 -0
- package/dist/components/alert.d.ts +31 -0
- package/dist/components/alert.js +503 -0
- package/dist/components/animated-collapse.d.ts +19 -0
- package/dist/components/animated-collapse.js +170 -0
- package/dist/components/animated-count.d.ts +13 -0
- package/dist/components/animated-count.js +105 -0
- package/dist/components/animated-list-item.d.ts +25 -0
- package/dist/components/animated-list-item.js +134 -0
- package/dist/components/animated-theme-toggler.d.ts +12 -0
- package/dist/components/animated-theme-toggler.js +200 -0
- package/dist/components/avatar.d.ts +65 -0
- package/dist/components/avatar.js +463 -0
- package/dist/components/badge.d.ts +21 -0
- package/dist/components/badge.js +297 -0
- package/dist/components/button-interaction.d.ts +23 -0
- package/dist/components/button-interaction.js +22 -0
- package/dist/components/button-label.d.ts +8 -0
- package/dist/components/button-label.js +203 -0
- package/dist/components/button.d.ts +23 -0
- package/dist/components/button.js +145 -0
- package/dist/components/calendar.d.ts +47 -0
- package/dist/components/calendar.js +155 -0
- package/dist/components/card.d.ts +38 -0
- package/dist/components/card.js +904 -0
- package/dist/components/carousel.d.ts +71 -0
- package/dist/components/carousel.js +585 -0
- package/dist/components/checkbox.d.ts +15 -0
- package/dist/components/checkbox.js +324 -0
- package/dist/components/control-button.d.ts +16 -0
- package/dist/components/control-button.js +215 -0
- package/dist/components/data-table.d.ts +118 -0
- package/dist/components/data-table.js +895 -0
- package/dist/components/dialog-surface.d.ts +49 -0
- package/dist/components/dialog-surface.js +220 -0
- package/dist/components/dialog.d.ts +92 -0
- package/dist/components/dialog.js +320 -0
- package/dist/components/dropdown-menu.d.ts +58 -0
- package/dist/components/dropdown-menu.js +135 -0
- package/dist/components/field.d.ts +53 -0
- package/dist/components/field.js +710 -0
- package/dist/components/file-upload.d.ts +88 -0
- package/dist/components/file-upload.js +776 -0
- package/dist/components/filter-presets-bar.d.ts +73 -0
- package/dist/components/filter-presets-bar.js +510 -0
- package/dist/components/filter-query-bar.d.ts +21 -0
- package/dist/components/filter-query-bar.js +881 -0
- package/dist/components/filter-query-grammar.d.ts +188 -0
- package/dist/components/filter-query-grammar.js +875 -0
- package/dist/components/form.d.ts +29 -0
- package/dist/components/form.js +330 -0
- package/dist/components/highlighter.d.ts +15 -0
- package/dist/components/highlighter.js +152 -0
- package/dist/components/hover-card.d.ts +50 -0
- package/dist/components/hover-card.js +80 -0
- package/dist/components/input-group.d.ts +16 -0
- package/dist/components/input-group.js +277 -0
- package/dist/components/input.d.ts +17 -0
- package/dist/components/input.js +120 -0
- package/dist/components/label.d.ts +4 -0
- package/dist/components/label.js +43 -0
- package/dist/components/link.d.ts +9 -0
- package/dist/components/link.js +43 -0
- package/dist/components/morph-text.d.ts +14 -0
- package/dist/components/morph-text.js +210 -0
- package/dist/components/pagination.d.ts +59 -0
- package/dist/components/pagination.js +190 -0
- package/dist/components/popover.d.ts +17 -0
- package/dist/components/popover.js +40 -0
- package/dist/components/presence-swap.d.ts +22 -0
- package/dist/components/presence-swap.js +209 -0
- package/dist/components/primitives/alert-dialog.d.ts +68 -0
- package/dist/components/primitives/alert-dialog.js +629 -0
- package/dist/components/primitives/avatar.d.ts +46 -0
- package/dist/components/primitives/avatar.js +265 -0
- package/dist/components/primitives/calendar.d.ts +37 -0
- package/dist/components/primitives/calendar.js +1250 -0
- package/dist/components/primitives/carousel.d.ts +106 -0
- package/dist/components/primitives/carousel.js +928 -0
- package/dist/components/primitives/dialog.d.ts +62 -0
- package/dist/components/primitives/dialog.js +490 -0
- package/dist/components/primitives/dropdown-menu-items.d.ts +59 -0
- package/dist/components/primitives/dropdown-menu-items.js +265 -0
- package/dist/components/primitives/dropdown-menu.d.ts +64 -0
- package/dist/components/primitives/dropdown-menu.js +560 -0
- package/dist/components/primitives/hover-card.d.ts +50 -0
- package/dist/components/primitives/hover-card.js +507 -0
- package/dist/components/primitives/pagination.d.ts +65 -0
- package/dist/components/primitives/pagination.js +373 -0
- package/dist/components/primitives/popover.d.ts +22 -0
- package/dist/components/primitives/popover.js +213 -0
- package/dist/components/primitives/select.d.ts +37 -0
- package/dist/components/primitives/select.js +428 -0
- package/dist/components/primitives/tooltip.d.ts +30 -0
- package/dist/components/primitives/tooltip.js +277 -0
- package/dist/components/progress-ring.d.ts +20 -0
- package/dist/components/progress-ring.js +53 -0
- package/dist/components/radio-group.d.ts +34 -0
- package/dist/components/radio-group.js +392 -0
- package/dist/components/reaction-button.d.ts +30 -0
- package/dist/components/reaction-button.js +189 -0
- package/dist/components/rich-link-editor.d.ts +25 -0
- package/dist/components/rich-link-editor.js +320 -0
- package/dist/components/rich-markdown-content.d.ts +10 -0
- package/dist/components/rich-markdown-content.js +56 -0
- package/dist/components/rich-text-content.d.ts +19 -0
- package/dist/components/rich-text-content.js +26 -0
- package/dist/components/select.d.ts +55 -0
- package/dist/components/select.js +188 -0
- package/dist/components/separator.d.ts +3 -0
- package/dist/components/separator.js +48 -0
- package/dist/components/sheet.d.ts +19 -0
- package/dist/components/sheet.js +420 -0
- package/dist/components/sidebar-panel-context.d.ts +17 -0
- package/dist/components/sidebar-panel-context.js +14 -0
- package/dist/components/sidebar.d.ts +195 -0
- package/dist/components/sidebar.js +2041 -0
- package/dist/components/skeleton.d.ts +23 -0
- package/dist/components/skeleton.js +334 -0
- package/dist/components/split-button.d.ts +36 -0
- package/dist/components/split-button.js +306 -0
- package/dist/components/svgs/whatsappIcon.d.ts +3 -0
- package/dist/components/svgs/whatsappIcon.js +14 -0
- package/dist/components/switch.d.ts +13 -0
- package/dist/components/switch.js +444 -0
- package/dist/components/table.d.ts +10 -0
- package/dist/components/table.js +298 -0
- package/dist/components/tabs.d.ts +36 -0
- package/dist/components/tabs.js +636 -0
- package/dist/components/textarea.d.ts +16 -0
- package/dist/components/textarea.js +111 -0
- package/dist/components/themed-toaster.d.ts +7 -0
- package/dist/components/themed-toaster.js +86 -0
- package/dist/components/toaster.d.ts +12 -0
- package/dist/components/toaster.js +62 -0
- package/dist/components/tooltip.d.ts +43 -0
- package/dist/components/tooltip.js +65 -0
- package/dist/components/typing-animation.d.ts +34 -0
- package/dist/components/typing-animation.js +389 -0
- package/dist/constants/action-button.d.ts +20 -0
- package/dist/constants/action-button.js +17 -0
- package/dist/constants/alert.d.ts +16 -0
- package/dist/constants/alert.js +13 -0
- package/dist/constants/avatar.d.ts +38 -0
- package/dist/constants/avatar.js +32 -0
- package/dist/constants/badge.d.ts +6 -0
- package/dist/constants/badge.js +6 -0
- package/dist/constants/button.d.ts +16 -0
- package/dist/constants/button.js +16 -0
- package/dist/constants/calendar.d.ts +36 -0
- package/dist/constants/calendar.js +34 -0
- package/dist/constants/card.d.ts +23 -0
- package/dist/constants/card.js +20 -0
- package/dist/constants/carousel.d.ts +55 -0
- package/dist/constants/carousel.js +74 -0
- package/dist/constants/checkbox.d.ts +17 -0
- package/dist/constants/checkbox.js +17 -0
- package/dist/constants/dialog.d.ts +11 -0
- package/dist/constants/dialog.js +10 -0
- package/dist/constants/dropdown-menu.d.ts +17 -0
- package/dist/constants/dropdown-menu.js +48 -0
- package/dist/constants/field.d.ts +24 -0
- package/dist/constants/field.js +24 -0
- package/dist/constants/hover-card.d.ts +37 -0
- package/dist/constants/hover-card.js +85 -0
- package/dist/constants/morph-text.d.ts +13 -0
- package/dist/constants/morph-text.js +13 -0
- package/dist/constants/motion.d.ts +12 -0
- package/dist/constants/motion.js +12 -0
- package/dist/constants/pagination.d.ts +20 -0
- package/dist/constants/pagination.js +20 -0
- package/dist/constants/popover.d.ts +7 -0
- package/dist/constants/popover.js +33 -0
- package/dist/constants/radio-group.d.ts +10 -0
- package/dist/constants/radio-group.js +10 -0
- package/dist/constants/select.d.ts +7 -0
- package/dist/constants/select.js +34 -0
- package/dist/constants/sidebar.d.ts +9 -0
- package/dist/constants/sidebar.js +17 -0
- package/dist/constants/skeleton.d.ts +17 -0
- package/dist/constants/skeleton.js +17 -0
- package/dist/constants/split-button.d.ts +7 -0
- package/dist/constants/split-button.js +5 -0
- package/dist/constants/switch.d.ts +33 -0
- package/dist/constants/switch.js +41 -0
- package/dist/constants/tabs.d.ts +17 -0
- package/dist/constants/tabs.js +17 -0
- package/dist/constants/toast.d.ts +3 -0
- package/dist/constants/toast.js +3 -0
- package/dist/constants/tooltip.d.ts +13 -0
- package/dist/constants/tooltip.js +52 -0
- package/dist/hooks/use-horizontal-swipe.d.ts +23 -0
- package/dist/hooks/use-horizontal-swipe.js +80 -0
- package/dist/hooks/use-is-hydrated.d.ts +6 -0
- package/dist/hooks/use-is-hydrated.js +20 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js +19 -0
- package/dist/hooks/use-prefers-reduced-motion.d.ts +2 -0
- package/dist/hooks/use-prefers-reduced-motion.js +27 -0
- package/dist/hooks/use-rich-link-editor.d.ts +55 -0
- package/dist/hooks/use-rich-link-editor.js +515 -0
- package/dist/hooks/use-sidebar-persistence.d.ts +6 -0
- package/dist/hooks/use-sidebar-persistence.js +52 -0
- package/dist/hooks/use-today.d.ts +7 -0
- package/dist/hooks/use-today.js +50 -0
- package/dist/hooks/use-viewer-time-zone.d.ts +6 -0
- package/dist/hooks/use-viewer-time-zone.js +20 -0
- package/dist/hooks.d.ts +11 -0
- package/dist/hooks.js +11 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +69 -0
- package/dist/lib/browser-clipboard.d.ts +13 -0
- package/dist/lib/browser-clipboard.js +48 -0
- package/dist/lib/column-filter-value.d.ts +12 -0
- package/dist/lib/column-filter-value.js +52 -0
- package/dist/lib/file-acceptance.d.ts +43 -0
- package/dist/lib/file-acceptance.js +107 -0
- package/dist/lib/format-file-size.d.ts +16 -0
- package/dist/lib/format-file-size.js +34 -0
- package/dist/lib/fuzzy-search.d.ts +17 -0
- package/dist/lib/fuzzy-search.js +183 -0
- package/dist/lib/horizontal-swipe.d.ts +23 -0
- package/dist/lib/horizontal-swipe.js +29 -0
- package/dist/lib/image-dimensions.d.ts +2 -0
- package/dist/lib/image-dimensions.js +7 -0
- package/dist/lib/name-initials.d.ts +7 -0
- package/dist/lib/name-initials.js +11 -0
- package/dist/lib/rich-text/link-markdown-constants.d.ts +147 -0
- package/dist/lib/rich-text/link-markdown-constants.js +458 -0
- package/dist/lib/rich-text/link-markdown-types.d.ts +53 -0
- package/dist/lib/rich-text/link-markdown-types.js +1 -0
- package/dist/lib/rich-text/link-markdown.d.ts +193 -0
- package/dist/lib/rich-text/link-markdown.js +592 -0
- package/dist/lib/rich-text/rich-markdown.d.ts +41 -0
- package/dist/lib/rich-text/rich-markdown.js +105 -0
- package/dist/lib/rich-text/rich-text-editor-dom.d.ts +26 -0
- package/dist/lib/rich-text/rich-text-editor-dom.js +79 -0
- package/dist/lib/toast-layer.d.ts +24 -0
- package/dist/lib/toast-layer.js +76 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +2 -0
- package/dist/lib/year-month-filter.d.ts +16 -0
- package/dist/lib/year-month-filter.js +46 -0
- package/dist/motion/arc-floating-slot.d.ts +40 -0
- package/dist/motion/arc-floating-slot.js +177 -0
- package/dist/motion/arc-press.d.ts +6 -0
- package/dist/motion/arc-press.js +59 -0
- package/dist/motion/arc-swap.d.ts +22 -0
- package/dist/motion/arc-swap.js +49 -0
- package/dist/motion/arc-tokens.d.ts +53 -0
- package/dist/motion/arc-tokens.js +73 -0
- package/dist/motion/glide-indicator.d.ts +69 -0
- package/dist/motion/glide-indicator.js +309 -0
- package/dist/motion/glide-slot.d.ts +9 -0
- package/dist/motion/glide-slot.js +71 -0
- package/dist/motion/motion-slot.d.ts +12 -0
- package/dist/motion/motion-slot.js +376 -0
- package/dist/motion/overlay-warmth.d.ts +24 -0
- package/dist/motion/overlay-warmth.js +70 -0
- package/dist/motion/presence.d.ts +40 -0
- package/dist/motion/presence.js +101 -0
- package/dist/motion/surface-keyframes.d.ts +24 -0
- package/dist/motion/surface-keyframes.js +141 -0
- package/dist/motion/tokens.d.ts +81 -0
- package/dist/motion/tokens.js +67 -0
- package/dist/motion/use-attached-element.d.ts +7 -0
- package/dist/motion/use-attached-element.js +22 -0
- package/dist/motion/use-morph-width.d.ts +13 -0
- package/dist/motion/use-morph-width.js +59 -0
- package/dist/next.d.ts +14 -0
- package/dist/next.js +79 -0
- package/dist/providers/astra-ui-provider.d.ts +27 -0
- package/dist/providers/astra-ui-provider.js +100 -0
- package/dist/providers/native-provider.d.ts +4 -0
- package/dist/providers/native-provider.js +45 -0
- package/dist/sonner.d.ts +7 -0
- package/dist/sonner.js +8 -0
- package/dist/styles.css +2 -0
- package/dist/tanstack.d.ts +11 -0
- package/dist/tanstack.js +50 -0
- package/dist/theme.d.ts +3 -0
- package/dist/theme.js +1 -0
- package/dist/types/data-table.d.ts +27 -0
- package/dist/types/data-table.js +1 -0
- package/fonts.css +5 -0
- package/package.json +450 -4
- package/styles.css +4 -0
- package/theme.css +248 -0
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Arc's Avatar and Avatar group (https://uiarc.dev, MIT License, see THIRD_PARTY_NOTICES.md). The avatar is a round
|
|
5
|
+
* portrait named once for assistive technology, with the first two initials standing in until the photo loads or when
|
|
6
|
+
* it fails, and a presence dot that pops in and out. The group overlaps several avatars, collapses the rest into a +N
|
|
7
|
+
* chip whose count rolls the way it moved, opens and closes the slot of members who join or leave, and on fine
|
|
8
|
+
* pointers fans apart while the pointed-at person lifts and shows their name.
|
|
9
|
+
*/
|
|
10
|
+
import { useState } from "react";
|
|
11
|
+
import { AnimatePresence, motion, useIsPresent } from "motion/react";
|
|
12
|
+
import { AVATAR_GROUP_COUNT_OFFSET_EM, AVATAR_GROUP_DEFAULT_LABEL, AVATAR_GROUP_DEFAULT_MAX, AVATAR_GROUP_OVERFLOW_SUFFIX, AVATAR_GROUP_SLOT_HIDDEN_SCALE, AVATAR_LABEL_SEPARATOR, AVATAR_SIZE_PX, AVATAR_STATUS_LABEL } from "../constants/avatar.js";
|
|
13
|
+
import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion.js";
|
|
14
|
+
import { getNameInitials } from "../lib/name-initials.js";
|
|
15
|
+
import { cn } from "../lib/utils.js";
|
|
16
|
+
import { ARC_BLUR, ARC_DURATION, ARC_EASE, ARC_SPRING_MORPH } from "../motion/arc-tokens.js";
|
|
17
|
+
import { AvatarBadge, AvatarFallback, AvatarImage, AvatarRoot } from "./primitives/avatar.js";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
/**
|
|
20
|
+
* Builds the avatar's accessible name: the person plus, when shown, their presence.
|
|
21
|
+
* @param name - Text that names the person.
|
|
22
|
+
* @param presence - Presence text, if any.
|
|
23
|
+
* @returns The accessible name.
|
|
24
|
+
*/
|
|
25
|
+
function buildAvatarLabel(name, presence) {
|
|
26
|
+
return presence ? `${name}${AVATAR_LABEL_SEPARATOR}${presence}` : name;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A round portrait for one person, with initials as fallback and an optional presence dot.
|
|
30
|
+
* @param props - Name, photo, size, presence, optional fallback and badge, plus native span attributes for the root.
|
|
31
|
+
* @returns The avatar, announced as one image.
|
|
32
|
+
*/
|
|
33
|
+
function Avatar(t0) {
|
|
34
|
+
const $ = _c(31);
|
|
35
|
+
let alt;
|
|
36
|
+
let badge;
|
|
37
|
+
let fallback;
|
|
38
|
+
let name;
|
|
39
|
+
let props;
|
|
40
|
+
let src;
|
|
41
|
+
let status;
|
|
42
|
+
let statusLabel;
|
|
43
|
+
let t1;
|
|
44
|
+
if ($[0] !== t0) {
|
|
45
|
+
({name, src, size: t1, status, statusLabel, fallback, badge, alt, ...props} = t0);
|
|
46
|
+
$[0] = t0;
|
|
47
|
+
$[1] = alt;
|
|
48
|
+
$[2] = badge;
|
|
49
|
+
$[3] = fallback;
|
|
50
|
+
$[4] = name;
|
|
51
|
+
$[5] = props;
|
|
52
|
+
$[6] = src;
|
|
53
|
+
$[7] = status;
|
|
54
|
+
$[8] = statusLabel;
|
|
55
|
+
$[9] = t1;
|
|
56
|
+
} else {
|
|
57
|
+
alt = $[1];
|
|
58
|
+
badge = $[2];
|
|
59
|
+
fallback = $[3];
|
|
60
|
+
name = $[4];
|
|
61
|
+
props = $[5];
|
|
62
|
+
src = $[6];
|
|
63
|
+
status = $[7];
|
|
64
|
+
statusLabel = $[8];
|
|
65
|
+
t1 = $[9];
|
|
66
|
+
}
|
|
67
|
+
const size = t1 === undefined ? "md" : t1;
|
|
68
|
+
const presence = status ? statusLabel ?? AVATAR_STATUS_LABEL[status] : undefined;
|
|
69
|
+
const t2 = alt ?? name;
|
|
70
|
+
let t3;
|
|
71
|
+
if ($[10] !== presence || $[11] !== t2) {
|
|
72
|
+
t3 = buildAvatarLabel(t2, presence);
|
|
73
|
+
$[10] = presence;
|
|
74
|
+
$[11] = t2;
|
|
75
|
+
$[12] = t3;
|
|
76
|
+
} else {
|
|
77
|
+
t3 = $[12];
|
|
78
|
+
}
|
|
79
|
+
let t4;
|
|
80
|
+
if ($[13] !== size || $[14] !== src) {
|
|
81
|
+
t4 = src ? /* @__PURE__ */ _jsx(AvatarImage, {
|
|
82
|
+
src,
|
|
83
|
+
alt: "",
|
|
84
|
+
width: AVATAR_SIZE_PX[size],
|
|
85
|
+
height: AVATAR_SIZE_PX[size],
|
|
86
|
+
sizes: `${AVATAR_SIZE_PX[size]}px`
|
|
87
|
+
}) : null;
|
|
88
|
+
$[13] = size;
|
|
89
|
+
$[14] = src;
|
|
90
|
+
$[15] = t4;
|
|
91
|
+
} else {
|
|
92
|
+
t4 = $[15];
|
|
93
|
+
}
|
|
94
|
+
let t5;
|
|
95
|
+
if ($[16] !== fallback || $[17] !== name) {
|
|
96
|
+
t5 = fallback ?? getNameInitials(name);
|
|
97
|
+
$[16] = fallback;
|
|
98
|
+
$[17] = name;
|
|
99
|
+
$[18] = t5;
|
|
100
|
+
} else {
|
|
101
|
+
t5 = $[18];
|
|
102
|
+
}
|
|
103
|
+
let t6;
|
|
104
|
+
if ($[19] !== t5) {
|
|
105
|
+
t6 = /* @__PURE__ */ _jsx(AvatarFallback, {
|
|
106
|
+
"aria-hidden": "true",
|
|
107
|
+
children: t5
|
|
108
|
+
});
|
|
109
|
+
$[19] = t5;
|
|
110
|
+
$[20] = t6;
|
|
111
|
+
} else {
|
|
112
|
+
t6 = $[20];
|
|
113
|
+
}
|
|
114
|
+
let t7;
|
|
115
|
+
if ($[21] !== badge) {
|
|
116
|
+
t7 = badge ? /* @__PURE__ */ _jsx(AvatarBadge, { children: badge }) : null;
|
|
117
|
+
$[21] = badge;
|
|
118
|
+
$[22] = t7;
|
|
119
|
+
} else {
|
|
120
|
+
t7 = $[22];
|
|
121
|
+
}
|
|
122
|
+
let t8;
|
|
123
|
+
if ($[23] !== props || $[24] !== size || $[25] !== status || $[26] !== t3 || $[27] !== t4 || $[28] !== t6 || $[29] !== t7) {
|
|
124
|
+
t8 = /* @__PURE__ */ _jsxs(AvatarRoot, {
|
|
125
|
+
role: "img",
|
|
126
|
+
"aria-label": t3,
|
|
127
|
+
size,
|
|
128
|
+
status,
|
|
129
|
+
...props,
|
|
130
|
+
children: [
|
|
131
|
+
t4,
|
|
132
|
+
t6,
|
|
133
|
+
t7
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
$[23] = props;
|
|
137
|
+
$[24] = size;
|
|
138
|
+
$[25] = status;
|
|
139
|
+
$[26] = t3;
|
|
140
|
+
$[27] = t4;
|
|
141
|
+
$[28] = t6;
|
|
142
|
+
$[29] = t7;
|
|
143
|
+
$[30] = t8;
|
|
144
|
+
} else {
|
|
145
|
+
t8 = $[30];
|
|
146
|
+
}
|
|
147
|
+
return t8;
|
|
148
|
+
}
|
|
149
|
+
/** The overflow count rolls the way it moved: more people rise in from below, fewer drop in from above. */
|
|
150
|
+
const countRoll = {
|
|
151
|
+
hidden: (direction) => ({
|
|
152
|
+
opacity: 0,
|
|
153
|
+
y: `${AVATAR_GROUP_COUNT_OFFSET_EM * direction}em`,
|
|
154
|
+
filter: `blur(${ARC_BLUR.subtle}px)`
|
|
155
|
+
}),
|
|
156
|
+
shown: {
|
|
157
|
+
opacity: 1,
|
|
158
|
+
y: 0,
|
|
159
|
+
filter: "blur(0px)",
|
|
160
|
+
transition: {
|
|
161
|
+
duration: ARC_DURATION.standard,
|
|
162
|
+
ease: [...ARC_EASE.enter]
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
gone: (direction) => ({
|
|
166
|
+
opacity: 0,
|
|
167
|
+
y: `${-AVATAR_GROUP_COUNT_OFFSET_EM * direction}em`,
|
|
168
|
+
filter: `blur(${ARC_BLUR.subtle}px)`,
|
|
169
|
+
transition: {
|
|
170
|
+
duration: ARC_DURATION.fast,
|
|
171
|
+
ease: [...ARC_EASE.standard]
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
};
|
|
175
|
+
/** Same keys as `countRoll`, so the settled style is identical whichever branch renders on the server. */
|
|
176
|
+
const countFade = {
|
|
177
|
+
hidden: {
|
|
178
|
+
opacity: 0,
|
|
179
|
+
y: 0,
|
|
180
|
+
filter: "blur(0px)"
|
|
181
|
+
},
|
|
182
|
+
shown: {
|
|
183
|
+
opacity: 1,
|
|
184
|
+
y: 0,
|
|
185
|
+
filter: "blur(0px)",
|
|
186
|
+
transition: { duration: ARC_DURATION.instant }
|
|
187
|
+
},
|
|
188
|
+
gone: {
|
|
189
|
+
opacity: 0,
|
|
190
|
+
y: 0,
|
|
191
|
+
filter: "blur(0px)",
|
|
192
|
+
transition: { duration: ARC_DURATION.instant }
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
/** A person joining or leaving opens or closes their slot, so the rest of the stack slides instead of jumping. */
|
|
196
|
+
const slotPresence = {
|
|
197
|
+
initial: {
|
|
198
|
+
width: 0,
|
|
199
|
+
opacity: 0,
|
|
200
|
+
scale: AVATAR_GROUP_SLOT_HIDDEN_SCALE
|
|
201
|
+
},
|
|
202
|
+
animate: {
|
|
203
|
+
width: "auto",
|
|
204
|
+
opacity: 1,
|
|
205
|
+
scale: 1
|
|
206
|
+
},
|
|
207
|
+
exit: {
|
|
208
|
+
width: 0,
|
|
209
|
+
opacity: 0,
|
|
210
|
+
scale: AVATAR_GROUP_SLOT_HIDDEN_SCALE
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Each slot is the avatar's visible width, so a slot that opens or closes moves the rest of the stack smoothly. On fine
|
|
215
|
+
* pointers it carries the hover moves as custom properties: the whole stack fans out from its center, the pointed-at
|
|
216
|
+
* slot rises above its neighbours and they ease aside.
|
|
217
|
+
*/
|
|
218
|
+
const slotClassName = "group/avatar-group-slot peer/avatar-group-slot relative inline-flex flex-none items-center [--aside:0px] [--fan:0px] [--rise:0px] pointer-fine:group-hover/avatar-group:[--fan:calc((var(--index)-(var(--count)-1)/2)*4px)] hover-fine:z-1 hover-fine:[--rise:-2px] pointer-fine:peer-hover/avatar-group-slot:[--aside:3px] pointer-fine:has-[~[data-slot=avatar-group-slot]:hover]:[--aside:-3px]";
|
|
219
|
+
/** One wrapper per person carries every hover move as a single translate, so the stack never changes size. */
|
|
220
|
+
const liftClassName = "relative -ml-1.5 inline-flex rounded-(--radius-pill) [transform:translate(calc(var(--fan)+var(--aside)),var(--rise))] transition-transform duration-(--duration-standard) ease-(--ease-standard) motion-reduce:transform-none! motion-reduce:transition-none";
|
|
221
|
+
/** The surface ring that separates overlapping avatars, which sharpens on the pointed-at one. */
|
|
222
|
+
const ringClassName = "border-2 border-surface shadow-[0_0_0_1px_var(--border)] transition-shadow duration-(--duration-fast) ease-(--ease-standard) pointer-fine:group-hover/avatar-group-slot:shadow-[0_0_0_1px_var(--border-strong)]";
|
|
223
|
+
/**
|
|
224
|
+
* One slot of the stack. A slot that is closing turns inert and hidden from assistive technology, so a person who left
|
|
225
|
+
* is no longer announced while the exit spring plays.
|
|
226
|
+
* @param props - Motion span props for the slot.
|
|
227
|
+
* @returns The slot.
|
|
228
|
+
*/
|
|
229
|
+
function AvatarGroupSlot(props) {
|
|
230
|
+
const $ = _c(4);
|
|
231
|
+
const isPresent = useIsPresent();
|
|
232
|
+
const t0 = isPresent ? props["aria-hidden"] : true;
|
|
233
|
+
const t1 = !isPresent || undefined;
|
|
234
|
+
let t2;
|
|
235
|
+
if ($[0] !== props || $[1] !== t0 || $[2] !== t1) {
|
|
236
|
+
t2 = /* @__PURE__ */ _jsx(motion.span, {
|
|
237
|
+
"data-slot": "avatar-group-slot",
|
|
238
|
+
...props,
|
|
239
|
+
"aria-hidden": t0,
|
|
240
|
+
inert: t1
|
|
241
|
+
});
|
|
242
|
+
$[0] = props;
|
|
243
|
+
$[1] = t0;
|
|
244
|
+
$[2] = t1;
|
|
245
|
+
$[3] = t2;
|
|
246
|
+
} else {
|
|
247
|
+
t2 = $[3];
|
|
248
|
+
}
|
|
249
|
+
return t2;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Builds the overflow chip's accessible name, as in "2 integrantes más".
|
|
253
|
+
* @param overflow - How many members are hidden.
|
|
254
|
+
* @param label - Accessible name of the group.
|
|
255
|
+
* @returns The chip's accessible name.
|
|
256
|
+
*/
|
|
257
|
+
function buildOverflowLabel(overflow, label) {
|
|
258
|
+
return `${overflow} ${label.toLowerCase()} ${AVATAR_GROUP_OVERFLOW_SUFFIX}`;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* An overlapping stack of avatars with a +N overflow chip.
|
|
262
|
+
* @param props - Members, optional total, how many to show, size, accessible label, classes and native root attributes.
|
|
263
|
+
* @returns The group.
|
|
264
|
+
*/
|
|
265
|
+
function AvatarGroup(t0) {
|
|
266
|
+
const $ = _c(40);
|
|
267
|
+
let className;
|
|
268
|
+
let members;
|
|
269
|
+
let props;
|
|
270
|
+
let style;
|
|
271
|
+
let t1;
|
|
272
|
+
let t2;
|
|
273
|
+
let t3;
|
|
274
|
+
let total;
|
|
275
|
+
if ($[0] !== t0) {
|
|
276
|
+
({members, total, max: t1, size: t2, label: t3, className, style, ...props} = t0);
|
|
277
|
+
$[0] = t0;
|
|
278
|
+
$[1] = className;
|
|
279
|
+
$[2] = members;
|
|
280
|
+
$[3] = props;
|
|
281
|
+
$[4] = style;
|
|
282
|
+
$[5] = t1;
|
|
283
|
+
$[6] = t2;
|
|
284
|
+
$[7] = t3;
|
|
285
|
+
$[8] = total;
|
|
286
|
+
} else {
|
|
287
|
+
className = $[1];
|
|
288
|
+
members = $[2];
|
|
289
|
+
props = $[3];
|
|
290
|
+
style = $[4];
|
|
291
|
+
t1 = $[5];
|
|
292
|
+
t2 = $[6];
|
|
293
|
+
t3 = $[7];
|
|
294
|
+
total = $[8];
|
|
295
|
+
}
|
|
296
|
+
const max = t1 === undefined ? AVATAR_GROUP_DEFAULT_MAX : t1;
|
|
297
|
+
const size = t2 === undefined ? "md" : t2;
|
|
298
|
+
const label = t3 === undefined ? AVATAR_GROUP_DEFAULT_LABEL : t3;
|
|
299
|
+
const reduceMotion = usePrefersReducedMotion();
|
|
300
|
+
const visibleMembers = members.slice(0, Math.max(0, max));
|
|
301
|
+
const memberCount = Math.max(members.length, total ?? 0);
|
|
302
|
+
const overflow = Math.max(0, memberCount - visibleMembers.length);
|
|
303
|
+
let t4;
|
|
304
|
+
if ($[9] !== reduceMotion) {
|
|
305
|
+
t4 = reduceMotion ? { duration: 0 } : ARC_SPRING_MORPH;
|
|
306
|
+
$[9] = reduceMotion;
|
|
307
|
+
$[10] = t4;
|
|
308
|
+
} else {
|
|
309
|
+
t4 = $[10];
|
|
310
|
+
}
|
|
311
|
+
const slotTransition = t4;
|
|
312
|
+
let t5;
|
|
313
|
+
if ($[11] !== overflow) {
|
|
314
|
+
t5 = {
|
|
315
|
+
overflow,
|
|
316
|
+
direction: 1
|
|
317
|
+
};
|
|
318
|
+
$[11] = overflow;
|
|
319
|
+
$[12] = t5;
|
|
320
|
+
} else {
|
|
321
|
+
t5 = $[12];
|
|
322
|
+
}
|
|
323
|
+
const [shownCount, setShownCount] = useState(t5);
|
|
324
|
+
if (shownCount.overflow !== overflow) {
|
|
325
|
+
setShownCount({
|
|
326
|
+
overflow,
|
|
327
|
+
direction: overflow < shownCount.overflow ? -1 : 1
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
const t6 = visibleMembers.length + (overflow > 0 ? 1 : 0);
|
|
331
|
+
let t7;
|
|
332
|
+
if ($[13] !== style || $[14] !== t6) {
|
|
333
|
+
t7 = {
|
|
334
|
+
...style,
|
|
335
|
+
"--count": t6
|
|
336
|
+
};
|
|
337
|
+
$[13] = style;
|
|
338
|
+
$[14] = t6;
|
|
339
|
+
$[15] = t7;
|
|
340
|
+
} else {
|
|
341
|
+
t7 = $[15];
|
|
342
|
+
}
|
|
343
|
+
const groupStyle = t7;
|
|
344
|
+
const t8 = "group";
|
|
345
|
+
const t9 = "avatar-group";
|
|
346
|
+
let t10;
|
|
347
|
+
if ($[16] !== className) {
|
|
348
|
+
t10 = cn("group/avatar-group inline-flex items-center pl-1.5", className);
|
|
349
|
+
$[16] = className;
|
|
350
|
+
$[17] = t10;
|
|
351
|
+
} else {
|
|
352
|
+
t10 = $[17];
|
|
353
|
+
}
|
|
354
|
+
const T0 = AnimatePresence;
|
|
355
|
+
const t11 = false;
|
|
356
|
+
let t12;
|
|
357
|
+
if ($[18] !== size || $[19] !== slotTransition) {
|
|
358
|
+
t12 = (member, index) => /* @__PURE__ */ _jsx(AvatarGroupSlot, {
|
|
359
|
+
className: slotClassName,
|
|
360
|
+
style: { "--index": index },
|
|
361
|
+
...slotPresence,
|
|
362
|
+
transition: slotTransition,
|
|
363
|
+
children: /* @__PURE__ */ _jsxs("span", {
|
|
364
|
+
className: liftClassName,
|
|
365
|
+
children: [/* @__PURE__ */ _jsx(Avatar, {
|
|
366
|
+
className: ringClassName,
|
|
367
|
+
name: member.name,
|
|
368
|
+
src: member.src,
|
|
369
|
+
status: member.status,
|
|
370
|
+
size
|
|
371
|
+
}), /* @__PURE__ */ _jsx("span", {
|
|
372
|
+
"aria-hidden": "true",
|
|
373
|
+
className: "pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2 z-2 -translate-x-1/2 translate-y-[3px] rounded-(--radius-pill) bg-foreground px-2 py-1 text-xs leading-(--leading-body) font-medium whitespace-nowrap text-background opacity-0 transition-[opacity,translate] duration-(--duration-fast) ease-(--ease-standard) pointer-fine:group-hover/avatar-group-slot:translate-y-0 pointer-fine:group-hover/avatar-group-slot:opacity-100 pointer-fine:group-hover/avatar-group-slot:delay-60 motion-reduce:translate-y-0 motion-reduce:transition-none",
|
|
374
|
+
children: member.name
|
|
375
|
+
})]
|
|
376
|
+
})
|
|
377
|
+
}, member.key ?? member.name);
|
|
378
|
+
$[18] = size;
|
|
379
|
+
$[19] = slotTransition;
|
|
380
|
+
$[20] = t12;
|
|
381
|
+
} else {
|
|
382
|
+
t12 = $[20];
|
|
383
|
+
}
|
|
384
|
+
const t13 = visibleMembers.map(t12);
|
|
385
|
+
let t14;
|
|
386
|
+
if ($[21] !== label || $[22] !== overflow || $[23] !== reduceMotion || $[24] !== shownCount.direction || $[25] !== size || $[26] !== slotTransition || $[27] !== visibleMembers) {
|
|
387
|
+
t14 = overflow > 0 ? /* @__PURE__ */ _jsx(AvatarGroupSlot, {
|
|
388
|
+
className: slotClassName,
|
|
389
|
+
style: { "--index": visibleMembers.length },
|
|
390
|
+
...slotPresence,
|
|
391
|
+
transition: slotTransition,
|
|
392
|
+
children: /* @__PURE__ */ _jsx("span", {
|
|
393
|
+
role: "img",
|
|
394
|
+
"aria-label": buildOverflowLabel(overflow, label),
|
|
395
|
+
"data-slot": "avatar-group-count",
|
|
396
|
+
"data-size": size,
|
|
397
|
+
className: cn(liftClassName, ringClassName, "relative grid size-8 place-items-center overflow-hidden bg-surface-muted text-xs font-medium text-text-secondary tabular-nums data-[size=lg]:size-10 data-[size=lg]:text-sm data-[size=sm]:size-6 data-[size=sm]:text-[10px]"),
|
|
398
|
+
children: /* @__PURE__ */ _jsx(AnimatePresence, {
|
|
399
|
+
mode: "popLayout",
|
|
400
|
+
initial: false,
|
|
401
|
+
custom: shownCount.direction,
|
|
402
|
+
children: /* @__PURE__ */ _jsxs(motion.span, {
|
|
403
|
+
"aria-hidden": "true",
|
|
404
|
+
className: "inline-block",
|
|
405
|
+
custom: shownCount.direction,
|
|
406
|
+
variants: reduceMotion ? countFade : countRoll,
|
|
407
|
+
initial: "hidden",
|
|
408
|
+
animate: "shown",
|
|
409
|
+
exit: "gone",
|
|
410
|
+
children: ["+", overflow]
|
|
411
|
+
}, overflow)
|
|
412
|
+
})
|
|
413
|
+
})
|
|
414
|
+
}, "overflow") : null;
|
|
415
|
+
$[21] = label;
|
|
416
|
+
$[22] = overflow;
|
|
417
|
+
$[23] = reduceMotion;
|
|
418
|
+
$[24] = shownCount.direction;
|
|
419
|
+
$[25] = size;
|
|
420
|
+
$[26] = slotTransition;
|
|
421
|
+
$[27] = visibleMembers;
|
|
422
|
+
$[28] = t14;
|
|
423
|
+
} else {
|
|
424
|
+
t14 = $[28];
|
|
425
|
+
}
|
|
426
|
+
let t15;
|
|
427
|
+
if ($[29] !== T0 || $[30] !== t13 || $[31] !== t14) {
|
|
428
|
+
t15 = /* @__PURE__ */ _jsxs(T0, {
|
|
429
|
+
initial: t11,
|
|
430
|
+
children: [t13, t14]
|
|
431
|
+
});
|
|
432
|
+
$[29] = T0;
|
|
433
|
+
$[30] = t13;
|
|
434
|
+
$[31] = t14;
|
|
435
|
+
$[32] = t15;
|
|
436
|
+
} else {
|
|
437
|
+
t15 = $[32];
|
|
438
|
+
}
|
|
439
|
+
let t16;
|
|
440
|
+
if ($[33] !== groupStyle || $[34] !== label || $[35] !== props || $[36] !== size || $[37] !== t10 || $[38] !== t15) {
|
|
441
|
+
t16 = /* @__PURE__ */ _jsx("div", {
|
|
442
|
+
...props,
|
|
443
|
+
role: t8,
|
|
444
|
+
"aria-label": label,
|
|
445
|
+
"data-slot": t9,
|
|
446
|
+
"data-size": size,
|
|
447
|
+
className: t10,
|
|
448
|
+
style: groupStyle,
|
|
449
|
+
children: t15
|
|
450
|
+
});
|
|
451
|
+
$[33] = groupStyle;
|
|
452
|
+
$[34] = label;
|
|
453
|
+
$[35] = props;
|
|
454
|
+
$[36] = size;
|
|
455
|
+
$[37] = t10;
|
|
456
|
+
$[38] = t15;
|
|
457
|
+
$[39] = t16;
|
|
458
|
+
} else {
|
|
459
|
+
t16 = $[39];
|
|
460
|
+
}
|
|
461
|
+
return t16;
|
|
462
|
+
}
|
|
463
|
+
export { Avatar, AvatarGroup };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
/** Arc's semantic tones. */
|
|
3
|
+
export type BadgeTone = "neutral" | "success" | "info" | "warning" | "danger";
|
|
4
|
+
/** Arc's badge heights: 26px (`md`) and 22px (`sm`). */
|
|
5
|
+
export type BadgeSize = "sm" | "md";
|
|
6
|
+
export type BadgeProps = ComponentProps<"span"> & {
|
|
7
|
+
/** Arc's semantic tone: `neutral` (default), `success`, `info`, `warning` or `danger`. */
|
|
8
|
+
tone?: BadgeTone;
|
|
9
|
+
/** Arc's height: `md` (26px, default) or `sm` (22px). */
|
|
10
|
+
size?: BadgeSize;
|
|
11
|
+
/** A leading icon tinted with the tone, hidden from assistive technology. A different icon component crossfades in. */
|
|
12
|
+
icon?: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A small label for status, category or metadata. String or number children swap in place with Arc's motion and the
|
|
16
|
+
* pill springs to the new width; other children render as they are.
|
|
17
|
+
* @param props - Tone, size, optional icon and native span attributes.
|
|
18
|
+
* @returns The badge.
|
|
19
|
+
*/
|
|
20
|
+
declare function Badge({ className, tone, size, icon, children, ...props }: BadgeProps): import("react").JSX.Element;
|
|
21
|
+
export { Badge };
|