@mortenbrudvik/waveui 0.12.0 → 0.14.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/README.md +362 -60
- package/dist/components/data-display/Avatar.cjs +1 -1
- package/dist/components/data-display/Avatar.cjs.map +1 -1
- package/dist/components/data-display/Avatar.colors.cjs +2 -0
- package/dist/components/data-display/Avatar.colors.cjs.map +1 -0
- package/dist/components/data-display/Avatar.colors.mjs +45 -0
- package/dist/components/data-display/Avatar.colors.mjs.map +1 -0
- package/dist/components/data-display/Avatar.context.cjs +1 -1
- package/dist/components/data-display/Avatar.context.cjs.map +1 -1
- package/dist/components/data-display/Avatar.context.mjs +4 -2
- package/dist/components/data-display/Avatar.context.mjs.map +1 -1
- package/dist/components/data-display/Avatar.mjs +103 -96
- package/dist/components/data-display/Avatar.mjs.map +1 -1
- package/dist/components/data-display/Avatar.sizes.cjs +2 -0
- package/dist/components/data-display/Avatar.sizes.cjs.map +1 -0
- package/dist/components/data-display/Avatar.sizes.mjs +41 -0
- package/dist/components/data-display/Avatar.sizes.mjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.cjs +1 -1
- package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.context.cjs +2 -0
- package/dist/components/data-display/AvatarGroup.context.cjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.context.mjs +9 -0
- package/dist/components/data-display/AvatarGroup.context.mjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.mjs +65 -122
- package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.partition.cjs +2 -0
- package/dist/components/data-display/AvatarGroup.partition.cjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.partition.mjs +14 -0
- package/dist/components/data-display/AvatarGroup.partition.mjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.parts.cjs +2 -0
- package/dist/components/data-display/AvatarGroup.parts.cjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.parts.mjs +178 -0
- package/dist/components/data-display/AvatarGroup.parts.mjs.map +1 -0
- package/dist/components/data-display/InteractionTag.cjs +1 -1
- package/dist/components/data-display/InteractionTag.cjs.map +1 -1
- package/dist/components/data-display/InteractionTag.mjs +36 -33
- package/dist/components/data-display/InteractionTag.mjs.map +1 -1
- package/dist/components/data-display/List.cjs +1 -1
- package/dist/components/data-display/List.cjs.map +1 -1
- package/dist/components/data-display/List.mjs +245 -195
- package/dist/components/data-display/List.mjs.map +1 -1
- package/dist/components/data-display/List.registry.cjs.map +1 -1
- package/dist/components/data-display/List.registry.mjs.map +1 -1
- package/dist/components/data-display/Persona.cjs +1 -1
- package/dist/components/data-display/Persona.cjs.map +1 -1
- package/dist/components/data-display/Persona.mjs +96 -37
- package/dist/components/data-display/Persona.mjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.cjs +1 -1
- package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.mjs +42 -28
- package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
- package/dist/components/data-display/Tag.cjs +1 -1
- package/dist/components/data-display/Tag.cjs.map +1 -1
- package/dist/components/data-display/Tag.mjs +111 -108
- package/dist/components/data-display/Tag.mjs.map +1 -1
- package/dist/components/layout/Card.cjs +1 -1
- package/dist/components/layout/Card.cjs.map +1 -1
- package/dist/components/layout/Card.context.cjs +2 -0
- package/dist/components/layout/Card.context.cjs.map +1 -0
- package/dist/components/layout/Card.context.mjs +14 -0
- package/dist/components/layout/Card.context.mjs.map +1 -0
- package/dist/components/layout/Card.mjs +138 -92
- package/dist/components/layout/Card.mjs.map +1 -1
- package/dist/components/layout/Card.preview.cjs +2 -0
- package/dist/components/layout/Card.preview.cjs.map +1 -0
- package/dist/components/layout/Card.preview.mjs +22 -0
- package/dist/components/layout/Card.preview.mjs.map +1 -0
- package/dist/components/layout/Carousel.button.cjs +2 -0
- package/dist/components/layout/Carousel.button.cjs.map +1 -0
- package/dist/components/layout/Carousel.button.mjs +34 -0
- package/dist/components/layout/Carousel.button.mjs.map +1 -0
- package/dist/components/layout/Carousel.cjs +1 -1
- package/dist/components/layout/Carousel.cjs.map +1 -1
- package/dist/components/layout/Carousel.context.cjs +2 -0
- package/dist/components/layout/Carousel.context.cjs.map +1 -0
- package/dist/components/layout/Carousel.context.mjs +24 -0
- package/dist/components/layout/Carousel.context.mjs.map +1 -0
- package/dist/components/layout/Carousel.drag.cjs +2 -0
- package/dist/components/layout/Carousel.drag.cjs.map +1 -0
- package/dist/components/layout/Carousel.drag.mjs +79 -0
- package/dist/components/layout/Carousel.drag.mjs.map +1 -0
- package/dist/components/layout/Carousel.groups.cjs +2 -0
- package/dist/components/layout/Carousel.groups.cjs.map +1 -0
- package/dist/components/layout/Carousel.groups.mjs +23 -0
- package/dist/components/layout/Carousel.groups.mjs.map +1 -0
- package/dist/components/layout/Carousel.mjs +288 -150
- package/dist/components/layout/Carousel.mjs.map +1 -1
- package/dist/components/layout/Carousel.styles.cjs +2 -0
- package/dist/components/layout/Carousel.styles.cjs.map +1 -0
- package/dist/components/layout/Carousel.styles.mjs +30 -0
- package/dist/components/layout/Carousel.styles.mjs.map +1 -0
- package/dist/components/layout/Overflow.cjs +1 -1
- package/dist/components/layout/Overflow.cjs.map +1 -1
- package/dist/components/layout/Overflow.mjs +240 -192
- package/dist/components/layout/Overflow.mjs.map +1 -1
- package/dist/components/layout/Overflow.store.cjs +2 -0
- package/dist/components/layout/Overflow.store.cjs.map +1 -0
- package/dist/components/layout/Overflow.store.mjs +209 -0
- package/dist/components/layout/Overflow.store.mjs.map +1 -0
- package/dist/components/layout/TabList.cjs +1 -1
- package/dist/components/layout/TabList.cjs.map +1 -1
- package/dist/components/layout/TabList.mjs +163 -124
- package/dist/components/layout/TabList.mjs.map +1 -1
- package/dist/components/navigation/Breadcrumb.cjs +1 -1
- package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
- package/dist/components/navigation/Breadcrumb.mjs +239 -84
- package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
- package/dist/components/overlays/Dialog.slots.cjs +1 -1
- package/dist/components/overlays/Dialog.slots.cjs.map +1 -1
- package/dist/components/overlays/Dialog.slots.mjs +19 -15
- package/dist/components/overlays/Dialog.slots.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.context.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.context.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.context.mjs +51 -0
- package/dist/components/overlays/TeachingPopover.context.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.mjs +15 -185
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.parts.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.parts.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.parts.mjs +398 -0
- package/dist/components/overlays/TeachingPopover.parts.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.root.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.root.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.root.mjs +150 -0
- package/dist/components/overlays/TeachingPopover.root.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.stack.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.stack.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.stack.mjs +86 -0
- package/dist/components/overlays/TeachingPopover.stack.mjs.map +1 -0
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.mjs +540 -311
- package/dist/components/table/DataGrid.mjs.map +1 -1
- package/dist/components/table/Table.cjs +1 -1
- package/dist/components/table/Table.cjs.map +1 -1
- package/dist/components/table/Table.mjs +183 -60
- package/dist/components/table/Table.mjs.map +1 -1
- package/dist/components/table/Table.shared.cjs +2 -0
- package/dist/components/table/Table.shared.cjs.map +1 -0
- package/dist/components/table/Table.shared.mjs +65 -0
- package/dist/components/table/Table.shared.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2299 -213
- package/dist/index.d.ts +2299 -213
- package/dist/index.mjs +135 -127
- package/dist/lib/breadcrumb.cjs +2 -0
- package/dist/lib/breadcrumb.cjs.map +1 -0
- package/dist/lib/breadcrumb.mjs +26 -0
- package/dist/lib/breadcrumb.mjs.map +1 -0
- package/dist/lib/classNames.cjs +1 -1
- package/dist/lib/classNames.cjs.map +1 -1
- package/dist/lib/classNames.mjs +143 -95
- package/dist/lib/classNames.mjs.map +1 -1
- package/dist/lib/events.cjs +1 -1
- package/dist/lib/events.cjs.map +1 -1
- package/dist/lib/events.mjs +35 -8
- package/dist/lib/events.mjs.map +1 -1
- package/dist/lib/icons.cjs +1 -1
- package/dist/lib/icons.cjs.map +1 -1
- package/dist/lib/icons.mjs +34 -20
- package/dist/lib/icons.mjs.map +1 -1
- package/dist/lib/initials.cjs +2 -0
- package/dist/lib/initials.cjs.map +1 -0
- package/dist/lib/initials.mjs +21 -0
- package/dist/lib/initials.mjs.map +1 -0
- package/dist/lib/table.cjs +2 -0
- package/dist/lib/table.cjs.map +1 -0
- package/dist/lib/table.mjs +16 -0
- package/dist/lib/table.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/styles/tokens.css +102 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/slot.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../hooks/useMergedRefs.cjs"),
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/slot.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../lib/initials.cjs"),ee=require("../../hooks/useMergedRefs.cjs"),te=require("../../lib/aria.cjs"),ne=require("../../hooks/useDirection.cjs"),re=require("../../lib/icons.cjs"),o=require("./Avatar.context.cjs"),ie=require("./AvatarGroup.context.cjs"),s=require("./Avatar.colors.cjs"),c=require("./Avatar.sizes.cjs");let l=require("react");l=e.__toESM(l,1);let u=require("react/jsx-runtime");c.avatarBoxClasses[24],c.avatarBoxClasses[32],c.avatarBoxClasses[40],c.avatarBoxClasses[48],c.avatarBoxClasses[56];var d=`w-full h-full object-cover`,ae={ring:`ring-2 ring-primary ring-offset-2 ring-offset-background`,"ring-shadow":`ring-2 ring-primary ring-offset-2 ring-offset-background shadow-8`,shadow:`shadow-8`,glow:`shadow-[0_0_0.5rem_0.125rem_var(--wave-primary)]`};function f(e){return e?.trim().replace(/\s+/g,` `)||void 0}function oe(e){if(l.isValidElement(e))return e.props;if(typeof e==`object`&&e&&!(Symbol.iterator in e))return e}function se(e,t,n){if(e===void 0)return[void 0,void 0,n||void 0,void 0];if(typeof e==`string`)return[void 0,void 0,e,void 0];let r=l.isValidElement(e)?e:void 0;return[r?.type,r?.key,t?.src,t?.srcSet]}function p(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function m(e,t){if(Object.is(e,t))return!0;if(!p(e)||!p(t))return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.prototype.hasOwnProperty.call(t,n)&&Object.is(e[n],t[n]))}function ce(e,t){return e.every((e,n)=>m(e,t[n]))}var h=({src:e,name:p,size:m,shape:h,color:le=`brand`,idForColor:ue,active:g=`unset`,activeAppearance:_=`ring`,initials:v,icon:y,image:b,badge:x,decorative:S=!1,className:C,ref:w,role:T,"aria-label":de,"aria-labelledby":E,"aria-describedby":fe,"aria-description":pe,"aria-details":me,...he})=>{let D=l.useContext(o.AvatarSizeContext),O=b==null||typeof b==`boolean`||b===``?void 0:b,k=oe(O),A=se(O,k,e),[ge,j]=l.useState(!1),[_e,ve]=l.useState(A);ce(_e,A)||(ve(A),j(!1));let M=l.useRef(null);l.useLayoutEffect(()=>{let e=M.current?.querySelector(`img`);if(!e||!e.complete||e.naturalWidth!==0)return;let t=!0,n=e.getAttribute(`src`),r=e.getAttribute(`srcset`),i=()=>{t&&e.isConnected&&e.getAttribute(`src`)===n&&e.getAttribute(`srcset`)===r&&j(!0)};return typeof e.decode==`function`?e.decode().then(void 0,i):queueMicrotask(i),()=>{t=!1}},[]);let ye=ee.useMergedRefs(w,M),N=de!==void 0||E!==void 0,P=T!==void 0&&T!==`presentation`&&T!==`none`,F=f(p),I=S||N||P?``:F??``,L=()=>j(!0),R=k?.alt,z=R!=null,B=z?R:I,V={"aria-describedby":fe,"aria-description":pe,"aria-details":me},H=!S&&!N&&!P&&typeof B==`string`&&B.trim()!==``,U=H?V:{},W=null;if(!ge){if(typeof O==`string`)W=(0,u.jsx)(`img`,{src:O,alt:I,...U,className:t.cn(i.avatarClassNames.image,d),onError:L});else if(O!==void 0){let e={onError:r.composeEventHandlers(k?.onError,L)};if(z||(e.alt=I),H){let t=k?.[`aria-describedby`];e[`aria-describedby`]=te.joinIds(fe,typeof t==`string`?t:void 0)}let a=l.isValidElement(O)?l.cloneElement(O,e):k?{...O,...e}:O;W=n.renderSlot(a,`img`,t.cn(i.avatarClassNames.image,d),{alt:I,...U})}else e&&(W=(0,u.jsx)(`img`,{src:e,alt:I,...U,className:t.cn(i.avatarClassNames.image,d),onError:L}))}let G=W!==null&&H?{}:V,K=W===null&&y&&n.slotRendersContent(y)?n.renderSlot(y,`span`,t.cn(i.avatarClassNames.icon,`inline-flex`),{"aria-hidden":!0}):null,be=ne.useDirection(),q=l.useContext(ie.AvatarGroupContext),xe=t.cn(i.avatarClassNames.initials,q?.layout===`pie`&&`invisible`),J=s.resolveAvatarColor(le,ue,p),Se=W===null&&K===null,Ce=Se&&p?a.getInitials(p,{dir:be}):``,we=Se?v&&n.slotRendersContent(v)?n.renderSlot(v,`span`,xe,{"aria-hidden":!0}):Ce?(0,u.jsx)(`span`,{"aria-hidden":`true`,className:xe,children:Ce}):null:null,Y,X;W===null?K===null?we?(Y=we,X=s.avatarColorClasses[J]):(Y=(0,u.jsx)(re.PersonIcon,{size:`60%`,className:i.avatarClassNames.icon}),X=`bg-muted text-muted-foreground`):(Y=K,X=`bg-muted text-muted-foreground`):Y=W;let Te=W!==null&&P&&typeof B==`string`?f(B):void 0,Ee=typeof R==`string`?f(R):void 0,De=de??(W===null?F??Ee:P?Te??F:void 0),Z;Z=S?{"aria-hidden":!0,...G}:De!==void 0||E!==void 0?{role:T??`img`,"aria-label":De,"aria-labelledby":E,...G}:W!==null||T!==void 0?{role:T,...G}:{"aria-hidden":!0,...G};let Oe=x&&n.slotRendersContent(x)?n.renderSlot(x,`span`,t.cn(i.avatarClassNames.badge,`absolute bottom-0 end-0 inline-flex`)):null,ke=Oe!==null,Q=m??q?.size??(D?D.size:`medium`),Ae=h??D?.shape??`circular`,je=c.avatarPixelSize(Q),Me={"data-size":String(Q),"data-shape":Ae,"data-color":J,"data-active":g,"data-active-appearance":_},$=t.cn(i.avatarClassNames.visual,`inline-flex items-center justify-center overflow-hidden shrink-0 font-bold`,c.avatarShapeClasses(Ae,je),c.avatarSizeClassesFor(Q),X,g===`active`&&ae[_],g===`inactive`&&`opacity-60 transition-opacity motion-reduce:transition-none`);return ke?(0,u.jsxs)(`span`,{ref:w,...Me,...he,className:t.cn(i.avatarClassNames.root,`relative inline-flex shrink-0`,C),children:[(0,u.jsx)(`span`,{ref:M,...Z,className:$,children:Y}),(0,u.jsx)(o.AvatarBadgeSizeContext.Provider,{value:c.avatarBadgeSize(je),children:Oe})]}):(0,u.jsx)(`span`,{ref:ye,...Z,...Me,...he,className:t.cn(i.avatarClassNames.root,$,C),children:Y})};h.displayName=`Avatar`,exports.Avatar=h;
|
|
2
2
|
//# sourceMappingURL=Avatar.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.cjs","names":["React","AvatarSizeContext","useMergedRefs","cn","avatarClassNames","composeEventHandlers","joinIds","renderSlot","slotRendersContent","PersonIcon","require_runtime","require_cn","require_slot","require_composeEventHandlers","require_classNames","require_useMergedRefs","require_aria","require_icons","require_Avatar_context","react","react_jsx_runtime","avatarSizeClasses","AVATAR_BOX_CLASSES","IMAGE_CLASS","getInitials","parts","name","normaliseName","readSlotProps","slot","getImageKey","imageSlot","src","element","slotProps","isPlainObject","value","proto","sameKeyPart","a","b","keys","k","sameImageKey","part","i","Avatar","sizeProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaDescription","ariaDetails","rest","box","image","imageKey","failed","setFailed","prevImageKey","setPrevImageKey","visualRef","img","active","checkedSrc","checkedSrcSet","markFailed","rootVisualRef","ref","hasConsumerName","roleCarriesName","role","normalisedName","imageAlt","decorative","handleError","ownAlt","hasOwnAlt","renderedAlt","description","imageIsNamed","imageDescription","imageNode","overrides","ownIds","visualDescription","iconNode","icon","initials","content","colorClass","imageName","slotAltName","label","a11yProps","badgeNode","badge","hasBadge","sizeClasses","visualClassName","className"],"sources":["../../../src/components/data-display/Avatar.tsx"],"sourcesContent":["import * as React from 'react';\nimport { joinIds } from '../../lib/aria';\nimport { cn } from '../../lib/cn';\nimport { avatarClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { PersonIcon } from '../../lib/icons';\nimport type { Size, Slot } from '../../lib/types';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport { AvatarSizeContext, type AvatarSizeContextValue } from './Avatar.context';\n\n/** Properties for the Avatar component. */\nexport interface AvatarProps extends React.HTMLAttributes<HTMLSpanElement> {\n /**\n * URL of the avatar image. When it fails to load (also before hydration, for server-rendered\n * markup), the avatar falls back to its icon or initials; a new `src` is tried again.\n */\n src?: string;\n /**\n * Full name of the person. It names the avatar for assistive technology (the image `alt`; in\n * initials and icon mode, or with a consumer `role`, the avatar's `aria-label`, with\n * `role=\"img\"` unless `role` is given) and generates the initials shown when there is no image.\n */\n name?: string;\n /**\n * Size of the avatar. Without it, an Avatar in the `media` of a tag (Tag, InteractionTag) takes\n * the tag's media box instead: 24, 20 or 16px by the tag's size.\n * @default 'medium'\n */\n size?: Size;\n /**\n * Icon shown instead of the initials when there is no image. Rendered in an `aria-hidden`\n * `<span>` (a slot object can override its attributes). A falsy value (`null`, `false`, `''`,\n * `0`, `NaN`, e.g. `icon={count && <Icon />}`) counts as no icon, as in 0.4, and so does an\n * array, `Set` or generator whose items render nothing. Without `icon` and without a usable\n * `name`, a generic person glyph is shown.\n */\n icon?: Slot<'span'>;\n /**\n * Custom image. Accepts a URL string (treated like `src`), an element (rendered as the image\n * itself, e.g. `<img>` or a framework image component) or an object of `<img>` attributes\n * (`{ src, alt, … }`). Takes precedence over `src`; its `alt` defaults to `name` (an `alt` that\n * is `undefined` counts as not given). When its alt names the avatar, the avatar's\n * `aria-describedby` ids are joined with the slot's own, while the slot's own `aria-description`\n * and `aria-details` win over the avatar's. When the image fails to load, an avatar without a\n * `name` keeps the name of the slot's own `alt`. After a load failure, a new image is tried\n * again: another `src` or `srcSet` of any type (an equal inline object is the same image), or\n * for an element slot another component type or `key`.\n */\n image?: Slot<'img'>;\n /**\n * Badge shown at the bottom end corner, e.g. `<PresenceBadge status=\"busy\" />`. With a badge\n * the avatar is wrapped in an outer `<span>` that receives `ref`, `className` and the other\n * props; `role`, `aria-label`, `aria-labelledby`, `aria-describedby`, `aria-description` and\n * `aria-details` stay on the avatar visual, so the badge keeps its own accessible name. A falsy\n * value (`null`, `false`, `''`, `0`, `NaN`, e.g. `badge={count && <CounterBadge count={count} />}`)\n * counts as no badge, as in 0.4, and so does an array, `Set` or generator whose items render\n * nothing: the avatar then renders without the wrapper.\n */\n badge?: Slot<'span'>;\n /**\n * Hides the avatar visual from assistive technology (`aria-hidden`, empty image `alt`, no\n * `role=\"img\"`). Use it when the name is already shown next to the avatar (Persona). A badge\n * stays exposed.\n * @default false\n */\n decorative?: boolean;\n /** Ref to the root `<span>`: the avatar itself, or the badge wrapper when `badge` is set. */\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n/**\n * Width, height and text size classes of the avatar per `size`. Module-only (not in the barrel):\n * AvatarGroup sizes its overflow button with the same classes, so the two always match.\n */\nexport const avatarSizeClasses: Readonly<Record<Size, string>> = {\n 'extra-small': 'w-6 h-6 text-[10px]', // 24px\n small: 'w-8 h-8 text-xs', // 32px\n medium: 'w-10 h-10 text-sm', // 40px\n large: 'w-12 h-12 text-base', // 48px\n 'extra-large': 'w-14 h-14 text-lg', // 56px\n};\n\n/**\n * Width, height and text size classes of each box of {@link AvatarSizeContext}, for an Avatar\n * that sets no `size`: 24px is the `extra-small` size, 20px and 16px are internal boxes.\n */\nconst AVATAR_BOX_CLASSES: Readonly<Record<AvatarSizeContextValue['size'], string>> = {\n 24: avatarSizeClasses['extra-small'],\n 20: 'w-5 h-5 text-[10px]',\n 16: 'w-4 h-4 text-[10px]',\n};\n\nconst IMAGE_CLASS = 'w-full h-full object-cover';\n\n/** First letter of the first and last word, upper-cased; `''` for a blank name. */\nfunction getInitials(name: string): string {\n const parts = name.trim().split(/\\s+/).filter(Boolean);\n if (parts.length === 0) return '';\n const first = Array.from(parts[0]!)[0] ?? '';\n const last = parts.length > 1 ? (Array.from(parts[parts.length - 1]!)[0] ?? '') : '';\n return (first + last).toUpperCase();\n}\n\n/** A name with its whitespace collapsed, or `undefined` when it is blank. */\nfunction normaliseName(name: string | undefined): string | undefined {\n return name?.trim().replace(/\\s+/g, ' ') || undefined;\n}\n\ntype ImageErrorHandler = React.ReactEventHandler<HTMLImageElement>;\n\n/** Description props that go to the element carrying the avatar's name (data-display#19). */\ntype DescriptionProps = Pick<\n React.HTMLAttributes<HTMLElement>,\n 'aria-describedby' | 'aria-description' | 'aria-details'\n>;\n\n/** Props the avatar sets on an element or object image slot, over the slot's own. */\ninterface SlotOverrides {\n onError: ImageErrorHandler;\n alt?: string;\n 'aria-describedby'?: string;\n}\n\n/** The props of an element or object image slot that the avatar reads. */\ninterface ImageSlotProps {\n src?: unknown;\n srcSet?: unknown;\n alt?: unknown;\n onError?: unknown;\n 'aria-describedby'?: unknown;\n}\n\n/** The props of an element or object image slot (to read its `src`, `alt` and handlers). */\nfunction readSlotProps(slot: unknown): ImageSlotProps | undefined {\n if (React.isValidElement(slot)) return slot.props as ImageSlotProps;\n if (typeof slot === 'object' && slot !== null && !(Symbol.iterator in slot)) {\n return slot as ImageSlotProps;\n }\n return undefined;\n}\n\n/**\n * What identifies the image, so a load failure is kept for it and a new image is tried again\n * (data-display#4): the `src` and `srcSet`, of any type (a framework image component may take a\n * static-import object), and for an element slot also its type and `key`.\n */\ntype ImageKey = readonly [type: unknown, key: unknown, src: unknown, srcSet: unknown];\n\nfunction getImageKey(\n imageSlot: unknown,\n slotProps: ImageSlotProps | undefined,\n src: string | undefined,\n): ImageKey {\n if (imageSlot === undefined) return [undefined, undefined, src || undefined, undefined];\n if (typeof imageSlot === 'string') return [undefined, undefined, imageSlot, undefined];\n const element = React.isValidElement(imageSlot) ? imageSlot : undefined;\n return [element?.type, element?.key, slotProps?.src, slotProps?.srcSet];\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) return false;\n const proto: unknown = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\n/** Same value, or plain objects with the same entries (an inline `src={{ … }}` on each render). */\nfunction sameKeyPart(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (!isPlainObject(a) || !isPlainObject(b)) return false;\n const keys = Object.keys(a);\n return (\n keys.length === Object.keys(b).length &&\n keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && Object.is(a[k], b[k]))\n );\n}\n\nfunction sameImageKey(a: ImageKey, b: ImageKey): boolean {\n return a.every((part, i) => sameKeyPart(part, b[i]));\n}\n\n/**\n * A circular picture of a person: their image, an icon, or the initials of their `name`.\n *\n * - **Image**: `image` (URL string, element or `{ src, alt }` object) or `src`. If the image fails\n * to load, the avatar falls back to `icon`, the initials or a person glyph, with their\n * background; a new image is tried again. A server-rendered image that failed before hydration\n * is detected after mount (settled without a natural size, confirmed by `decode()`).\n * - **Accessible name**: an image uses `name` (whitespace collapsed) as its `alt`, or `''` when the\n * name is blank. Without an image (none given, or it failed to load) the avatar is `role=\"img\"`\n * with `aria-label={name}` (without a name: the image slot's own `alt`) and the initials/icon\n * are hidden; without either (and without `aria-label`/`aria-labelledby`) it is decorative\n * (`aria-hidden`). A consumer `aria-label`, `aria-labelledby` or `role` (other than\n * `presentation`/`none`) puts the name on the avatar visual, and an image inside it gets\n * `alt=\"\"`. `decorative` hides it in every mode. `aria-describedby`, `aria-description` and\n * `aria-details` go to the element that carries the name: the `<img>` when a non-blank `alt`\n * names it, otherwise the avatar visual (never an `alt=\"\"` image).\n * - **Badge**: `badge` renders at the bottom end corner (logical, RTL-safe) as a sibling of the\n * avatar visual, so a `PresenceBadge` keeps its own name. With a badge, `ref`, `className` and\n * the rest props go to the outer wrapper.\n *\n * @example\n * <Avatar name=\"Jane Doe\" src=\"/jane.jpg\" badge={<PresenceBadge status=\"available\" />} />\n */\nexport const Avatar = ({\n src,\n name,\n size: sizeProp,\n icon,\n image,\n badge,\n decorative = false,\n className,\n ref,\n role,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-description': ariaDescription,\n 'aria-details': ariaDetails,\n ...rest\n}: AvatarProps) => {\n // The media box of a surrounding Tag or InteractionTag, for an Avatar without its own `size`.\n const box = React.useContext(AvatarSizeContext);\n const imageSlot =\n image === null || image === undefined || typeof image === 'boolean' || image === ''\n ? undefined\n : image;\n const slotProps = readSlotProps(imageSlot);\n const imageKey = getImageKey(imageSlot, slotProps, src);\n\n // Load failure of the current image; a new image is tried again (C-HOOKS: adjust state during\n // render on prop change).\n const [failed, setFailed] = React.useState(false);\n const [prevImageKey, setPrevImageKey] = React.useState(imageKey);\n if (!sameImageKey(prevImageKey, imageKey)) {\n setPrevImageKey(imageKey);\n setFailed(false);\n }\n\n // An image that failed before hydration (a fast 404 of server-rendered markup) never reaches\n // `onError`: React attaches the listener while hydrating and does not replay the event. After\n // mount, a settled image without a natural size is broken, unless it is an SVG without one, so\n // `decode()` (which rejects for a broken image) confirms it where the browser supports it. Later\n // images, rendered by the client, report their errors through `onError`.\n const visualRef = React.useRef<HTMLSpanElement>(null);\n React.useLayoutEffect(() => {\n const img = visualRef.current?.querySelector('img');\n if (!img || !img.complete || img.naturalWidth !== 0) return;\n let active = true;\n const checkedSrc = img.getAttribute('src');\n const checkedSrcSet = img.getAttribute('srcset');\n const markFailed = () => {\n // Deferred (C-HOOKS); skipped if the image was replaced or got another source meanwhile.\n if (\n active &&\n img.isConnected &&\n img.getAttribute('src') === checkedSrc &&\n img.getAttribute('srcset') === checkedSrcSet\n ) {\n setFailed(true);\n }\n };\n if (typeof img.decode === 'function') img.decode().then(undefined, markFailed);\n else queueMicrotask(markFailed);\n return () => {\n active = false;\n };\n }, []);\n const rootVisualRef = useMergedRefs(ref, visualRef);\n\n const hasConsumerName = ariaLabel !== undefined || ariaLabelledBy !== undefined;\n // A consumer role goes to the visual span together with the name (data-display#19), so the\n // image inside it is presentational (`alt=\"\"`), as with a consumer `aria-label`: the children\n // of `role=\"img\"` are not exposed. A presentational role (`presentation`, `none`) cannot carry\n // a name, so the image keeps it.\n const roleCarriesName = role !== undefined && role !== 'presentation' && role !== 'none';\n const normalisedName = normaliseName(name);\n const imageAlt = decorative || hasConsumerName || roleCarriesName ? '' : (normalisedName ?? '');\n const handleError: ImageErrorHandler = () => setFailed(true);\n\n // The alt text the image renders with: an element or object slot's own `alt` wins over ours. An\n // `alt` that is `undefined` (an optional `alt: user.photoAlt`, a wrapper forwarding `alt={alt}`)\n // or `null` is not given, so ours applies (the slot's own value would otherwise override it).\n const ownAlt = slotProps?.alt;\n const hasOwnAlt = ownAlt !== undefined && ownAlt !== null;\n const renderedAlt: unknown = hasOwnAlt ? ownAlt : imageAlt;\n\n // The description goes to the element that carries the name: the image itself when a non-blank\n // `alt` names it (the visual span then has no role, or a presentational one), otherwise the\n // visual span. An image with an empty `alt` is presentational, and a description on it would\n // conflict with that role.\n const description: DescriptionProps = {\n 'aria-describedby': ariaDescribedBy,\n 'aria-description': ariaDescription,\n 'aria-details': ariaDetails,\n };\n const imageIsNamed =\n !decorative &&\n !hasConsumerName &&\n !roleCarriesName &&\n typeof renderedAlt === 'string' &&\n renderedAlt.trim() !== '';\n const imageDescription: DescriptionProps = imageIsNamed ? description : {};\n\n let imageNode: React.ReactNode = null;\n if (!failed) {\n if (typeof imageSlot === 'string') {\n imageNode = (\n <img\n src={imageSlot}\n alt={imageAlt}\n {...imageDescription}\n className={cn(avatarClassNames.image, IMAGE_CLASS)}\n onError={handleError}\n />\n );\n } else if (imageSlot !== undefined) {\n // The slot's own props win over renderSlot's defaults, so the composed `onError`, the\n // default `alt` (when the slot gives none) and the joined `aria-describedby` (the avatar's\n // ids, then the slot's) are set on the slot itself. A slot's own `aria-description` and\n // `aria-details` win over the avatar's.\n const overrides: SlotOverrides = {\n onError: composeEventHandlers(\n slotProps?.onError as ImageErrorHandler | undefined,\n handleError,\n ),\n };\n if (!hasOwnAlt) overrides.alt = imageAlt;\n if (imageIsNamed) {\n const ownIds = slotProps?.['aria-describedby'];\n overrides['aria-describedby'] = joinIds(\n ariaDescribedBy,\n typeof ownIds === 'string' ? ownIds : undefined,\n );\n }\n const slot = React.isValidElement(imageSlot)\n ? React.cloneElement(imageSlot as React.ReactElement<SlotOverrides>, overrides)\n : slotProps\n ? { ...(imageSlot as object), ...overrides }\n : imageSlot;\n imageNode = renderSlot(slot as Slot<'img'>, 'img', cn(avatarClassNames.image, IMAGE_CLASS), {\n alt: imageAlt,\n ...imageDescription,\n });\n } else if (src) {\n imageNode = (\n <img\n src={src}\n alt={imageAlt}\n {...imageDescription}\n className={cn(avatarClassNames.image, IMAGE_CLASS)}\n onError={handleError}\n />\n );\n }\n }\n const visualDescription = imageNode !== null && imageIsNamed ? {} : description;\n\n // A falsy icon (`icon={count && <Icon />}` with count 0) is no icon, as in 0.4, and so is a\n // collection whose items render nothing (`icon={items.map(…)}` mapping to nothing). The check\n // does not consume a generator: renderSlot still renders its items.\n const iconNode =\n imageNode === null && icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(avatarClassNames.icon, 'inline-flex'), { 'aria-hidden': true })\n : null;\n const initials = imageNode === null && iconNode === null && name ? getInitials(name) : '';\n\n let content: React.ReactNode;\n let colorClass: string | undefined;\n if (imageNode !== null) {\n content = imageNode;\n } else if (iconNode !== null) {\n content = iconNode;\n colorClass = 'bg-muted text-muted-foreground';\n } else if (initials) {\n content = (\n <span aria-hidden=\"true\" className={avatarClassNames.initials}>\n {initials}\n </span>\n );\n colorClass = 'bg-primary text-primary-foreground';\n } else {\n content = <PersonIcon size=\"60%\" className={avatarClassNames.icon} />;\n colorClass = 'bg-muted text-muted-foreground';\n }\n\n // Accessible name of the avatar visual (data-display#19, #27). With a consumer role and an\n // image it is the name the image would carry: an element or object slot's own alt, else `name`.\n // Without an image (none given, or it failed to load) it is `name`, else the slot's own alt: an\n // avatar named only by its image alt keeps that name when the image fails.\n const imageName =\n imageNode !== null && roleCarriesName && typeof renderedAlt === 'string'\n ? normaliseName(renderedAlt)\n : undefined;\n const slotAltName = typeof ownAlt === 'string' ? normaliseName(ownAlt) : undefined;\n const label =\n ariaLabel ??\n (imageNode === null\n ? (normalisedName ?? slotAltName)\n : roleCarriesName\n ? (imageName ?? normalisedName)\n : undefined);\n let a11yProps: React.HTMLAttributes<HTMLSpanElement>;\n if (decorative) {\n a11yProps = { 'aria-hidden': true, ...visualDescription };\n } else if (label !== undefined || ariaLabelledBy !== undefined) {\n a11yProps = {\n role: role ?? 'img',\n 'aria-label': label,\n 'aria-labelledby': ariaLabelledBy,\n ...visualDescription,\n };\n } else if (imageNode !== null || role !== undefined) {\n a11yProps = { role, ...visualDescription };\n } else {\n a11yProps = { 'aria-hidden': true, ...visualDescription };\n }\n\n // A falsy or empty badge (`badge={count && <CounterBadge … />}` with count 0) is no badge, as in\n // 0.4 and like `icon`: no stray \"0\" in the corner, and no wrapper taking the root props.\n const badgeNode =\n badge && slotRendersContent(badge)\n ? renderSlot(badge, 'span', cn(avatarClassNames.badge, 'absolute bottom-0 end-0 inline-flex'))\n : null;\n const hasBadge = badgeNode !== null;\n\n // An own `size` wins; without one, the box of a surrounding tag's media, else medium. With a\n // badge the visual is sized, not the wrapper.\n const sizeClasses =\n sizeProp !== undefined\n ? avatarSizeClasses[sizeProp]\n : box\n ? AVATAR_BOX_CLASSES[box.size]\n : avatarSizeClasses.medium;\n const visualClassName = cn(\n avatarClassNames.visual,\n 'inline-flex items-center justify-center rounded-full overflow-hidden shrink-0 font-bold',\n sizeClasses,\n colorClass,\n );\n\n if (!hasBadge) {\n return (\n <span\n ref={rootVisualRef}\n {...a11yProps}\n {...rest}\n className={cn(avatarClassNames.root, visualClassName, className)}\n >\n {content}\n </span>\n );\n }\n\n return (\n <span\n ref={ref}\n {...rest}\n className={cn(avatarClassNames.root, 'relative inline-flex shrink-0', className)}\n >\n <span ref={visualRef} {...a11yProps} className={visualClassName}>\n {content}\n </span>\n {badgeNode}\n </span>\n );\n};\n\nAvatar.displayName = 'Avatar';\n"],"mappings":"obA2EA,IAAaqB,EAAoD,CAC/D,cAAe,sBACf,MAAO,kBACP,OAAQ,oBACR,MAAO,sBACP,cAAe,mBACjB,EAMMC,GAA+E,CACnF,GAAID,EAAkB,eACtB,GAAI,sBACJ,GAAI,qBACN,EAEME,EAAc,6BAGpB,SAASC,GAAY,EAAsB,CACzC,IAAMC,EAAQC,EAAK,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,EAIrD,OAHID,EAAM,SAAW,EAAU,KACjB,MAAM,KAAKA,EAAM,EAAG,CAAC,CAAC,IAAM,KAC7BA,EAAM,OAAS,EAAK,M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ACd,kBAAmB5C,EACnB,GAAGoC,CACL,EACSH,IAAc,MAAQX,IAAS,IAAA,GAC5B,CAAE,OAAM,GAAGc,CAAkB,EAE7B,CAAE,cAAe,GAAM,GAAGA,CAAkB,EAK1D,IAAMU,EACJC,GAASxF,EAAAA,mBAAmBwF,CAAK,EAC7BzF,EAAAA,WAAWyF,EAAO,OAAQ7F,EAAAA,GAAGC,EAAAA,iBAAiB,MAAO,qCAAqC,CAAC,EAC3F,KACA6F,GAAWF,IAAc,KAIzBG,GACJnD,IAAa,IAAA,GAETO,EACEhC,GAAmBgC,EAAI,MACvBjC,EAAkB,OAHpBA,EAAkB0B,GAIlBoD,EAAkBhG,EAAAA,GACtBC,EAAAA,iBAAiB,OACjB,0FACA8F,GACAR,CACF,EAeA,OAbKO,IAcH,EAAA7E,EAAA,KAAA,CAAC,OAAD,CACO,MACL,GAAIiC,EACJ,UAAWlD,EAAAA,GAAGC,EAAAA,iBAAiB,KAAM,gCAAiCgG,CAAS,EAHjF,SAAA,EAKE,EAAAhF,EAAA,IAAA,CAAC,OAAD,CAAM,IAAKyC,EAAW,GAAIiC,EAAW,UAAWK,EAC7C,SAAAV,CACG,CAAA,EACLM,CACG,KArBJ,EAAA3E,EAAA,IAAA,CAAC,OAAD,CACE,IAAK+C,EACL,GAAI2B,EACJ,GAAIzC,EACJ,UAAWlD,EAAAA,GAAGC,EAAAA,iBAAiB,KAAM+F,EAAiBC,CAAS,EAE9D,SAAAX,CACG,CAAA,CAgBZ,EAEA,EAAO,YAAc"}
|
|
1
|
+
{"version":3,"file":"Avatar.cjs","names":["avatarBoxClasses","React","AvatarSizeContext","useMergedRefs","cn","avatarClassNames","composeEventHandlers","joinIds","renderSlot","slotRendersContent","useDirection","AvatarGroupContext","resolveAvatarColor","getInitials","avatarColorClasses","PersonIcon","avatarPixelSize","avatarShapeClasses","avatarSizeClassesFor","AvatarBadgeSizeContext","avatarBadgeSize","require_runtime","require_cn","require_slot","require_composeEventHandlers","require_classNames","require_initials","require_useMergedRefs","require_aria","require_useDirection","require_icons","require_Avatar_context","require_AvatarGroup_context","require_Avatar_colors","require_Avatar_sizes","react","react_jsx_runtime","IMAGE_CLASS","activeClasses","normaliseName","name","readSlotProps","slot","getImageKey","imageSlot","src","element","slotProps","isPlainObject","value","proto","sameKeyPart","a","b","keys","k","sameImageKey","part","i","Avatar","sizeProp","shapeProp","colorProp","initialsSlot","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaDescription","ariaDetails","rest","box","image","imageKey","failed","setFailed","prevImageKey","setPrevImageKey","visualRef","img","active","checkedSrc","checkedSrcSet","markFailed","rootVisualRef","ref","hasConsumerName","roleCarriesName","role","normalisedName","imageAlt","decorative","handleError","ownAlt","hasOwnAlt","renderedAlt","description","imageIsNamed","imageDescription","imageNode","overrides","ownIds","visualDescription","iconNode","icon","dir","group","initialsClass","resolvedColor","idForColor","showsInitials","computedInitials","initialsNode","content","colorClass","imageName","slotAltName","label","a11yProps","badgeNode","badge","hasBadge","resolvedSize","resolvedShape","pixels","stateProps","activeAppearance","visualClassName","className"],"sources":["../../../src/components/data-display/Avatar.tsx"],"sourcesContent":["import * as React from 'react';\nimport { joinIds } from '../../lib/aria';\nimport { cn } from '../../lib/cn';\nimport { avatarClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useDirection } from '../../hooks/useDirection';\nimport { getInitials } from '../../lib/initials';\nimport { PersonIcon } from '../../lib/icons';\nimport type { Size, Slot } from '../../lib/types';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport { AvatarBadgeSizeContext, AvatarSizeContext } from './Avatar.context';\nimport { AvatarGroupContext } from './AvatarGroup.context';\nimport { avatarColorClasses, resolveAvatarColor, type AvatarColor } from './Avatar.colors';\nimport {\n avatarBadgeSize,\n avatarBoxClasses,\n avatarPixelSize,\n avatarShapeClasses,\n avatarSizeClassesFor,\n type AvatarSize,\n} from './Avatar.sizes';\n\nexport type { AvatarNumericSize, AvatarSize } from './Avatar.sizes';\nexport type { AvatarColor, AvatarNamedColor } from './Avatar.colors';\n\n/** Properties for the Avatar component. */\nexport interface AvatarProps extends React.HTMLAttributes<HTMLSpanElement> {\n /**\n * URL of the avatar image. When it fails to load (also before hydration, for server-rendered\n * markup), the avatar falls back to its icon or initials; a new `src` is tried again.\n */\n src?: string;\n /**\n * Full name of the person. It names the avatar for assistive technology (the image `alt`; in\n * initials and icon mode, or with a consumer `role`, the avatar's `aria-label`, with\n * `role=\"img\"` unless `role` is given) and generates the initials shown when there is no image.\n */\n name?: string;\n /**\n * Size of the avatar: a named size (`extra-small` 24px to `extra-large` 56px) or a pixel size from\n * 16 to 128. Without it, an Avatar in the `media` of a tag (Tag, InteractionTag) takes the tag's\n * media box instead: 24, 20 or 16px by the tag's size.\n * @default 'medium'\n */\n size?: AvatarSize;\n /**\n * Shape of the avatar. Without it, an Avatar in the `media` of a rounded tag is square.\n * @default 'circular'\n */\n shape?: 'circular' | 'square';\n /**\n * Color of the avatar when it shows initials: `brand` (the primary color), `neutral` (muted),\n * `colorful` (one of the named colors, chosen from `idForColor`, else from `name`; `brand`\n * without either) or a named color of the persona palette. An image, or an icon, keeps its own\n * look.\n * @default 'brand'\n */\n color?: AvatarColor;\n /**\n * Whether the person is active: `active` draws the `activeAppearance` around the avatar, `inactive`\n * dims it, `unset` shows neither.\n * @default 'unset'\n */\n active?: 'active' | 'inactive' | 'unset';\n /**\n * How an `active` avatar is marked: a `ring`, a `shadow`, both (`ring-shadow`) or a `glow` in the\n * primary color.\n * @default 'ring'\n */\n activeAppearance?: 'ring' | 'ring-shadow' | 'shadow' | 'glow';\n /**\n * A stable id (a user id, say) that picks the color of `color=\"colorful\"`, so the same person has\n * the same color wherever they are shown, whatever their name looks like.\n */\n idForColor?: string;\n /**\n * The initials shown when there is no image and no icon, instead of the ones computed from\n * `name` (see `getInitials`): a string, an element or an object of `<span>` attributes. A value\n * that renders nothing (`''`, `[]`) keeps the computed initials. Rendered in an `aria-hidden`\n * `<span>`.\n */\n initials?: Slot<'span'>;\n /**\n * Icon shown instead of the initials when there is no image. Rendered in an `aria-hidden`\n * `<span>` (a slot object can override its attributes). A falsy value (`null`, `false`, `''`,\n * `0`, `NaN`, e.g. `icon={count && <Icon />}`) counts as no icon, as in 0.4, and so does an\n * array, `Set` or generator whose items render nothing. Without `icon` and without a usable\n * `name`, a generic person glyph is shown.\n */\n icon?: Slot<'span'>;\n /**\n * Custom image. Accepts a URL string (treated like `src`), an element (rendered as the image\n * itself, e.g. `<img>` or a framework image component) or an object of `<img>` attributes\n * (`{ src, alt, … }`). Takes precedence over `src`; its `alt` defaults to `name` (an `alt` that\n * is `undefined` counts as not given). When its alt names the avatar, the avatar's\n * `aria-describedby` ids are joined with the slot's own, while the slot's own `aria-description`\n * and `aria-details` win over the avatar's. When the image fails to load, an avatar without a\n * `name` keeps the name of the slot's own `alt`. After a load failure, a new image is tried\n * again: another `src` or `srcSet` of any type (an equal inline object is the same image), or\n * for an element slot another component type or `key`.\n */\n image?: Slot<'img'>;\n /**\n * Badge shown at the bottom end corner, e.g. `<PresenceBadge status=\"busy\" />`. With a badge\n * the avatar is wrapped in an outer `<span>` that receives `ref`, `className` and the other\n * props; `role`, `aria-label`, `aria-labelledby`, `aria-describedby`, `aria-description` and\n * `aria-details` stay on the avatar visual, so the badge keeps its own accessible name. A falsy\n * value (`null`, `false`, `''`, `0`, `NaN`, e.g. `badge={count && <CounterBadge count={count} />}`)\n * counts as no badge, as in 0.4, and so does an array, `Set` or generator whose items render\n * nothing: the avatar then renders without the wrapper.\n */\n badge?: Slot<'span'>;\n /**\n * Hides the avatar visual from assistive technology (`aria-hidden`, empty image `alt`, no\n * `role=\"img\"`). Use it when the name is already shown next to the avatar (Persona). A badge\n * stays exposed.\n * @default false\n */\n decorative?: boolean;\n /** Ref to the root `<span>`: the avatar itself, or the badge wrapper when `badge` is set. */\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n/**\n * Width, height and text size classes of the avatar per `size`. Module-only (not in the barrel):\n * AvatarGroup sizes its overflow button with the same classes, so the two always match.\n */\nexport const avatarSizeClasses: Readonly<Record<Size, string>> = {\n 'extra-small': avatarBoxClasses[24],\n small: avatarBoxClasses[32],\n medium: avatarBoxClasses[40],\n large: avatarBoxClasses[48],\n 'extra-large': avatarBoxClasses[56],\n};\n\nconst IMAGE_CLASS = 'w-full h-full object-cover';\n\n/** How an `active` avatar is marked. Literal strings only. */\nconst activeClasses: Readonly<Record<'ring' | 'ring-shadow' | 'shadow' | 'glow', string>> = {\n ring: 'ring-2 ring-primary ring-offset-2 ring-offset-background',\n 'ring-shadow': 'ring-2 ring-primary ring-offset-2 ring-offset-background shadow-8',\n shadow: 'shadow-8',\n glow: 'shadow-[0_0_0.5rem_0.125rem_var(--wave-primary)]',\n};\n\n/** A name with its whitespace collapsed, or `undefined` when it is blank. */\nfunction normaliseName(name: string | undefined): string | undefined {\n return name?.trim().replace(/\\s+/g, ' ') || undefined;\n}\n\ntype ImageErrorHandler = React.ReactEventHandler<HTMLImageElement>;\n\n/** Description props that go to the element carrying the avatar's name (data-display#19). */\ntype DescriptionProps = Pick<\n React.HTMLAttributes<HTMLElement>,\n 'aria-describedby' | 'aria-description' | 'aria-details'\n>;\n\n/** Props the avatar sets on an element or object image slot, over the slot's own. */\ninterface SlotOverrides {\n onError: ImageErrorHandler;\n alt?: string;\n 'aria-describedby'?: string;\n}\n\n/** The props of an element or object image slot that the avatar reads. */\ninterface ImageSlotProps {\n src?: unknown;\n srcSet?: unknown;\n alt?: unknown;\n onError?: unknown;\n 'aria-describedby'?: unknown;\n}\n\n/** The props of an element or object image slot (to read its `src`, `alt` and handlers). */\nfunction readSlotProps(slot: unknown): ImageSlotProps | undefined {\n if (React.isValidElement(slot)) return slot.props as ImageSlotProps;\n if (typeof slot === 'object' && slot !== null && !(Symbol.iterator in slot)) {\n return slot as ImageSlotProps;\n }\n return undefined;\n}\n\n/**\n * What identifies the image, so a load failure is kept for it and a new image is tried again\n * (data-display#4): the `src` and `srcSet`, of any type (a framework image component may take a\n * static-import object), and for an element slot also its type and `key`.\n */\ntype ImageKey = readonly [type: unknown, key: unknown, src: unknown, srcSet: unknown];\n\nfunction getImageKey(\n imageSlot: unknown,\n slotProps: ImageSlotProps | undefined,\n src: string | undefined,\n): ImageKey {\n if (imageSlot === undefined) return [undefined, undefined, src || undefined, undefined];\n if (typeof imageSlot === 'string') return [undefined, undefined, imageSlot, undefined];\n const element = React.isValidElement(imageSlot) ? imageSlot : undefined;\n return [element?.type, element?.key, slotProps?.src, slotProps?.srcSet];\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) return false;\n const proto: unknown = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\n/** Same value, or plain objects with the same entries (an inline `src={{ … }}` on each render). */\nfunction sameKeyPart(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (!isPlainObject(a) || !isPlainObject(b)) return false;\n const keys = Object.keys(a);\n return (\n keys.length === Object.keys(b).length &&\n keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && Object.is(a[k], b[k]))\n );\n}\n\nfunction sameImageKey(a: ImageKey, b: ImageKey): boolean {\n return a.every((part, i) => sameKeyPart(part, b[i]));\n}\n\n/**\n * A circular picture of a person: their image, an icon, or the initials of their `name`.\n *\n * - **Image**: `image` (URL string, element or `{ src, alt }` object) or `src`. If the image fails\n * to load, the avatar falls back to `icon`, the initials or a person glyph, with their\n * background; a new image is tried again. A server-rendered image that failed before hydration\n * is detected after mount (settled without a natural size, confirmed by `decode()`).\n * - **Accessible name**: an image uses `name` (whitespace collapsed) as its `alt`, or `''` when the\n * name is blank. Without an image (none given, or it failed to load) the avatar is `role=\"img\"`\n * with `aria-label={name}` (without a name: the image slot's own `alt`) and the initials/icon\n * are hidden; without either (and without `aria-label`/`aria-labelledby`) it is decorative\n * (`aria-hidden`). A consumer `aria-label`, `aria-labelledby` or `role` (other than\n * `presentation`/`none`) puts the name on the avatar visual, and an image inside it gets\n * `alt=\"\"`. `decorative` hides it in every mode. `aria-describedby`, `aria-description` and\n * `aria-details` go to the element that carries the name: the `<img>` when a non-blank `alt`\n * names it, otherwise the avatar visual (never an `alt=\"\"` image).\n * - **Badge**: `badge` renders at the bottom end corner (logical, RTL-safe) as a sibling of the\n * avatar visual, so a `PresenceBadge` keeps its own name. With a badge, `ref`, `className` and\n * the rest props go to the outer wrapper.\n *\n * @example\n * <Avatar name=\"Jane Doe\" src=\"/jane.jpg\" badge={<PresenceBadge status=\"available\" />} />\n */\nexport const Avatar = ({\n src,\n name,\n size: sizeProp,\n shape: shapeProp,\n color: colorProp = 'brand',\n idForColor,\n active = 'unset',\n activeAppearance = 'ring',\n initials: initialsSlot,\n icon,\n image,\n badge,\n decorative = false,\n className,\n ref,\n role,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-description': ariaDescription,\n 'aria-details': ariaDetails,\n ...rest\n}: AvatarProps) => {\n // The media box of a surrounding Tag or InteractionTag, for an Avatar without its own `size`.\n const box = React.useContext(AvatarSizeContext);\n const imageSlot =\n image === null || image === undefined || typeof image === 'boolean' || image === ''\n ? undefined\n : image;\n const slotProps = readSlotProps(imageSlot);\n const imageKey = getImageKey(imageSlot, slotProps, src);\n\n // Load failure of the current image; a new image is tried again (C-HOOKS: adjust state during\n // render on prop change).\n const [failed, setFailed] = React.useState(false);\n const [prevImageKey, setPrevImageKey] = React.useState(imageKey);\n if (!sameImageKey(prevImageKey, imageKey)) {\n setPrevImageKey(imageKey);\n setFailed(false);\n }\n\n // An image that failed before hydration (a fast 404 of server-rendered markup) never reaches\n // `onError`: React attaches the listener while hydrating and does not replay the event. After\n // mount, a settled image without a natural size is broken, unless it is an SVG without one, so\n // `decode()` (which rejects for a broken image) confirms it where the browser supports it. Later\n // images, rendered by the client, report their errors through `onError`.\n const visualRef = React.useRef<HTMLSpanElement>(null);\n React.useLayoutEffect(() => {\n const img = visualRef.current?.querySelector('img');\n if (!img || !img.complete || img.naturalWidth !== 0) return;\n let active = true;\n const checkedSrc = img.getAttribute('src');\n const checkedSrcSet = img.getAttribute('srcset');\n const markFailed = () => {\n // Deferred (C-HOOKS); skipped if the image was replaced or got another source meanwhile.\n if (\n active &&\n img.isConnected &&\n img.getAttribute('src') === checkedSrc &&\n img.getAttribute('srcset') === checkedSrcSet\n ) {\n setFailed(true);\n }\n };\n if (typeof img.decode === 'function') img.decode().then(undefined, markFailed);\n else queueMicrotask(markFailed);\n return () => {\n active = false;\n };\n }, []);\n const rootVisualRef = useMergedRefs(ref, visualRef);\n\n const hasConsumerName = ariaLabel !== undefined || ariaLabelledBy !== undefined;\n // A consumer role goes to the visual span together with the name (data-display#19), so the\n // image inside it is presentational (`alt=\"\"`), as with a consumer `aria-label`: the children\n // of `role=\"img\"` are not exposed. A presentational role (`presentation`, `none`) cannot carry\n // a name, so the image keeps it.\n const roleCarriesName = role !== undefined && role !== 'presentation' && role !== 'none';\n const normalisedName = normaliseName(name);\n const imageAlt = decorative || hasConsumerName || roleCarriesName ? '' : (normalisedName ?? '');\n const handleError: ImageErrorHandler = () => setFailed(true);\n\n // The alt text the image renders with: an element or object slot's own `alt` wins over ours. An\n // `alt` that is `undefined` (an optional `alt: user.photoAlt`, a wrapper forwarding `alt={alt}`)\n // or `null` is not given, so ours applies (the slot's own value would otherwise override it).\n const ownAlt = slotProps?.alt;\n const hasOwnAlt = ownAlt !== undefined && ownAlt !== null;\n const renderedAlt: unknown = hasOwnAlt ? ownAlt : imageAlt;\n\n // The description goes to the element that carries the name: the image itself when a non-blank\n // `alt` names it (the visual span then has no role, or a presentational one), otherwise the\n // visual span. An image with an empty `alt` is presentational, and a description on it would\n // conflict with that role.\n const description: DescriptionProps = {\n 'aria-describedby': ariaDescribedBy,\n 'aria-description': ariaDescription,\n 'aria-details': ariaDetails,\n };\n const imageIsNamed =\n !decorative &&\n !hasConsumerName &&\n !roleCarriesName &&\n typeof renderedAlt === 'string' &&\n renderedAlt.trim() !== '';\n const imageDescription: DescriptionProps = imageIsNamed ? description : {};\n\n let imageNode: React.ReactNode = null;\n if (!failed) {\n if (typeof imageSlot === 'string') {\n imageNode = (\n <img\n src={imageSlot}\n alt={imageAlt}\n {...imageDescription}\n className={cn(avatarClassNames.image, IMAGE_CLASS)}\n onError={handleError}\n />\n );\n } else if (imageSlot !== undefined) {\n // The slot's own props win over renderSlot's defaults, so the composed `onError`, the\n // default `alt` (when the slot gives none) and the joined `aria-describedby` (the avatar's\n // ids, then the slot's) are set on the slot itself. A slot's own `aria-description` and\n // `aria-details` win over the avatar's.\n const overrides: SlotOverrides = {\n onError: composeEventHandlers(\n slotProps?.onError as ImageErrorHandler | undefined,\n handleError,\n ),\n };\n if (!hasOwnAlt) overrides.alt = imageAlt;\n if (imageIsNamed) {\n const ownIds = slotProps?.['aria-describedby'];\n overrides['aria-describedby'] = joinIds(\n ariaDescribedBy,\n typeof ownIds === 'string' ? ownIds : undefined,\n );\n }\n const slot = React.isValidElement(imageSlot)\n ? React.cloneElement(imageSlot as React.ReactElement<SlotOverrides>, overrides)\n : slotProps\n ? { ...(imageSlot as object), ...overrides }\n : imageSlot;\n imageNode = renderSlot(slot as Slot<'img'>, 'img', cn(avatarClassNames.image, IMAGE_CLASS), {\n alt: imageAlt,\n ...imageDescription,\n });\n } else if (src) {\n imageNode = (\n <img\n src={src}\n alt={imageAlt}\n {...imageDescription}\n className={cn(avatarClassNames.image, IMAGE_CLASS)}\n onError={handleError}\n />\n );\n }\n }\n const visualDescription = imageNode !== null && imageIsNamed ? {} : description;\n\n // A falsy icon (`icon={count && <Icon />}` with count 0) is no icon, as in 0.4, and so is a\n // collection whose items render nothing (`icon={items.map(…)}` mapping to nothing). The check\n // does not consume a generator: renderSlot still renders its items.\n const iconNode =\n imageNode === null && icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(avatarClassNames.icon, 'inline-flex'), { 'aria-hidden': true })\n : null;\n const dir = useDirection();\n const group = React.useContext(AvatarGroupContext);\n // The wedges of a pie overlap at its centre: their initials would print over each other.\n const initialsClass = cn(avatarClassNames.initials, group?.layout === 'pie' && 'invisible');\n const resolvedColor = resolveAvatarColor(colorProp, idForColor, name);\n const showsInitials = imageNode === null && iconNode === null;\n const computedInitials = showsInitials && name ? getInitials(name, { dir }) : '';\n const initialsNode = !showsInitials ? null : initialsSlot && slotRendersContent(initialsSlot) ? (\n renderSlot(initialsSlot, 'span', initialsClass, { 'aria-hidden': true })\n ) : computedInitials ? (\n <span aria-hidden=\"true\" className={initialsClass}>\n {computedInitials}\n </span>\n ) : null;\n\n let content: React.ReactNode;\n let colorClass: string | undefined;\n if (imageNode !== null) {\n content = imageNode;\n } else if (iconNode !== null) {\n content = iconNode;\n colorClass = 'bg-muted text-muted-foreground';\n } else if (initialsNode) {\n content = initialsNode;\n colorClass = avatarColorClasses[resolvedColor];\n } else {\n content = <PersonIcon size=\"60%\" className={avatarClassNames.icon} />;\n colorClass = 'bg-muted text-muted-foreground';\n }\n\n // Accessible name of the avatar visual (data-display#19, #27). With a consumer role and an\n // image it is the name the image would carry: an element or object slot's own alt, else `name`.\n // Without an image (none given, or it failed to load) it is `name`, else the slot's own alt: an\n // avatar named only by its image alt keeps that name when the image fails.\n const imageName =\n imageNode !== null && roleCarriesName && typeof renderedAlt === 'string'\n ? normaliseName(renderedAlt)\n : undefined;\n const slotAltName = typeof ownAlt === 'string' ? normaliseName(ownAlt) : undefined;\n const label =\n ariaLabel ??\n (imageNode === null\n ? (normalisedName ?? slotAltName)\n : roleCarriesName\n ? (imageName ?? normalisedName)\n : undefined);\n let a11yProps: React.HTMLAttributes<HTMLSpanElement>;\n if (decorative) {\n a11yProps = { 'aria-hidden': true, ...visualDescription };\n } else if (label !== undefined || ariaLabelledBy !== undefined) {\n a11yProps = {\n role: role ?? 'img',\n 'aria-label': label,\n 'aria-labelledby': ariaLabelledBy,\n ...visualDescription,\n };\n } else if (imageNode !== null || role !== undefined) {\n a11yProps = { role, ...visualDescription };\n } else {\n a11yProps = { 'aria-hidden': true, ...visualDescription };\n }\n\n // A falsy or empty badge (`badge={count && <CounterBadge … />}` with count 0) is no badge, as in\n // 0.4 and like `icon`: no stray \"0\" in the corner, and no wrapper taking the root props.\n const badgeNode =\n badge && slotRendersContent(badge)\n ? renderSlot(badge, 'span', cn(avatarClassNames.badge, 'absolute bottom-0 end-0 inline-flex'))\n : null;\n const hasBadge = badgeNode !== null;\n\n // An own `size` wins; without one, the box of a surrounding tag's media, else medium. With a\n // badge the visual is sized, not the wrapper.\n const resolvedSize: AvatarSize =\n sizeProp ?? group?.size ?? (box ? (box.size as AvatarSize) : 'medium');\n const resolvedShape = shapeProp ?? box?.shape ?? 'circular';\n const pixels = avatarPixelSize(resolvedSize);\n const stateProps = {\n 'data-size': String(resolvedSize),\n 'data-shape': resolvedShape,\n 'data-color': resolvedColor,\n 'data-active': active,\n 'data-active-appearance': activeAppearance,\n };\n const visualClassName = cn(\n avatarClassNames.visual,\n 'inline-flex items-center justify-center overflow-hidden shrink-0 font-bold',\n avatarShapeClasses(resolvedShape, pixels),\n avatarSizeClassesFor(resolvedSize),\n colorClass,\n active === 'active' && activeClasses[activeAppearance],\n active === 'inactive' && 'opacity-60 transition-opacity motion-reduce:transition-none',\n );\n\n if (!hasBadge) {\n return (\n <span\n ref={rootVisualRef}\n {...a11yProps}\n {...stateProps}\n {...rest}\n className={cn(avatarClassNames.root, visualClassName, className)}\n >\n {content}\n </span>\n );\n }\n\n return (\n <span\n ref={ref}\n {...stateProps}\n {...rest}\n className={cn(avatarClassNames.root, 'relative inline-flex shrink-0', className)}\n >\n <span ref={visualRef} {...a11yProps} className={visualClassName}>\n {content}\n </span>\n <AvatarBadgeSizeContext.Provider value={avatarBadgeSize(pixels)}>\n {badgeNode}\n </AvatarBadgeSizeContext.Provider>\n </span>\n );\n};\n\nAvatar.displayName = 'Avatar';\n"],"mappings":"6mBAiIiBA,EAA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AmByG,GAAeC,EAAM,EACxCzG,EAAAA,qBAAqBuG,CAAY,EACjCR,EACAlC,IAAW,UAAYzC,GAAcuF,GACrC9C,IAAW,YAAc,6DAC3B,EAgBA,OAdKyC,IAeH,EAAApF,EAAA,KAAA,CAAC,OAAD,CACO,MACL,GAAIwF,GACJ,GAAIvD,GACJ,UAAWjE,EAAAA,GAAGC,EAAAA,iBAAiB,KAAM,gCAAiC0H,CAAS,EAJjF,SAAA,EAME,EAAA3F,EAAA,IAAA,CAAC,OAAD,CAAM,IAAKyC,EAAW,GAAIwC,EAAW,UAAWS,EAC7C,SAAAd,CACG,CAAA,GACN,EAAA5E,EAAA,IAAA,CAACjB,EAAAA,uBAAuB,SAAxB,CAAiC,MAAOC,EAAAA,gBAAgBuG,EAAM,EAC3D,SAAAL,EAC8B,CAAA,CAC7B,KAzBJ,EAAAlF,EAAA,IAAA,CAAC,OAAD,CACE,IAAK+C,GACL,GAAIkC,EACJ,GAAIO,GACJ,GAAIvD,GACJ,UAAWjE,EAAAA,GAAGC,EAAAA,iBAAiB,KAAMyH,EAAiBC,CAAS,EAE9D,SAAAf,CACG,CAAA,CAmBZ,EAEA,EAAO,YAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";var e=[`red`,`pumpkin`,`gold`,`forest`,`teal`,`blue`,`navy`,`lavender`,`purple`,`magenta`,`brown`,`steel`],t={neutral:`bg-muted text-muted-foreground`,brand:`bg-primary text-primary-foreground`,red:`bg-palette-red text-palette-red-foreground`,pumpkin:`bg-palette-pumpkin text-palette-pumpkin-foreground`,gold:`bg-palette-gold text-palette-gold-foreground`,forest:`bg-palette-forest text-palette-forest-foreground`,teal:`bg-palette-teal text-palette-teal-foreground`,blue:`bg-palette-blue text-palette-blue-foreground`,navy:`bg-palette-navy text-palette-navy-foreground`,lavender:`bg-palette-lavender text-palette-lavender-foreground`,purple:`bg-palette-purple text-palette-purple-foreground`,magenta:`bg-palette-magenta text-palette-magenta-foreground`,brown:`bg-palette-brown text-palette-brown-foreground`,steel:`bg-palette-steel text-palette-steel-foreground`};function n(t){let n=2166136261;for(let e=0;e<t.length;e+=1)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return e[(n>>>0)%e.length]}function r(e,t,r){if(e!==`colorful`)return e;let i=t?.trim()||r?.trim();return i?n(i):`brand`}exports.AVATAR_NAMED_COLORS=e,exports.avatarColorClasses=t,exports.hashToNamedColor=n,exports.resolveAvatarColor=r;
|
|
2
|
+
//# sourceMappingURL=Avatar.colors.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Avatar.colors.cjs","names":["AVATAR_NAMED_COLORS","avatarColorClasses","hashToNamedColor","hash","index","key","resolveAvatarColor","color","idForColor","name"],"sources":["../../../src/components/data-display/Avatar.colors.ts"],"sourcesContent":["/** The named colors of an Avatar: the persona palette (`--wave-palette-<name>` tokens). */\nexport type AvatarNamedColor =\n | 'red'\n | 'pumpkin'\n | 'gold'\n | 'forest'\n | 'teal'\n | 'blue'\n | 'navy'\n | 'lavender'\n | 'purple'\n | 'magenta'\n | 'brown'\n | 'steel';\n\n/** The color of an Avatar that shows initials: a look, `colorful` (hashed), or a named color. */\nexport type AvatarColor = 'neutral' | 'brand' | 'colorful' | AvatarNamedColor;\n\n/** The named colors in a fixed order: `colorful` indexes into it, so the order never changes. */\nexport const AVATAR_NAMED_COLORS: readonly AvatarNamedColor[] = [\n 'red',\n 'pumpkin',\n 'gold',\n 'forest',\n 'teal',\n 'blue',\n 'navy',\n 'lavender',\n 'purple',\n 'magenta',\n 'brown',\n 'steel',\n];\n\n/** Fill and text classes of each resolved color. Literal strings only (Tailwind scans them). */\nexport const avatarColorClasses: Readonly<Record<Exclude<AvatarColor, 'colorful'>, string>> = {\n neutral: 'bg-muted text-muted-foreground',\n brand: 'bg-primary text-primary-foreground',\n red: 'bg-palette-red text-palette-red-foreground',\n pumpkin: 'bg-palette-pumpkin text-palette-pumpkin-foreground',\n gold: 'bg-palette-gold text-palette-gold-foreground',\n forest: 'bg-palette-forest text-palette-forest-foreground',\n teal: 'bg-palette-teal text-palette-teal-foreground',\n blue: 'bg-palette-blue text-palette-blue-foreground',\n navy: 'bg-palette-navy text-palette-navy-foreground',\n lavender: 'bg-palette-lavender text-palette-lavender-foreground',\n purple: 'bg-palette-purple text-palette-purple-foreground',\n magenta: 'bg-palette-magenta text-palette-magenta-foreground',\n brown: 'bg-palette-brown text-palette-brown-foreground',\n steel: 'bg-palette-steel text-palette-steel-foreground',\n};\n\n/**\n * The named color a string stands for: a 32-bit FNV-1a hash of its UTF-16 code units, modulo the\n * number of named colors. Stable across runs, the server and the client, and releases.\n */\nexport function hashToNamedColor(key: string): AvatarNamedColor {\n let hash = 0x811c9dc5;\n for (let index = 0; index < key.length; index += 1) {\n hash ^= key.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193);\n }\n return AVATAR_NAMED_COLORS[(hash >>> 0) % AVATAR_NAMED_COLORS.length]!;\n}\n\n/**\n * Resolves the `color` prop: `colorful` becomes the named color of `idForColor`, else of `name`,\n * else `brand`.\n */\nexport function resolveAvatarColor(\n color: AvatarColor,\n idForColor: string | undefined,\n name: string | undefined,\n): Exclude<AvatarColor, 'colorful'> {\n if (color !== 'colorful') return color;\n const key = idForColor?.trim() || name?.trim();\n return key ? hashToNamedColor(key) : 'brand';\n}\n"],"mappings":"aAmBA,IAAaA,EAAmD,CAC9D,MACA,UACA,OACA,SACA,OACA,OACA,OACA,WACA,SACA,UACA,QACA,OACF,EAGaC,EAAiF,CAC5F,QAAS,iCACT,MAAO,qCACP,IAAK,6CACL,QAAS,qDACT,KAAM,+CACN,OAAQ,mDACR,KAAM,+CACN,KAAM,+CACN,KAAM,+CACN,SAAU,uDACV,OAAQ,mDACR,QAAS,qDACT,MAAO,iDACP,MAAO,gDACT,EAMA,SAAgBC,EAAiB,EAA+B,CAC9D,IAAIC,EAAO,WACX,IAAK,IAAIC,EAAQ,EAAGA,EAAQC,EAAI,OAAQ,GAAS,EAC/C,GAAQA,EAAI,WAAWD,CAAK,EAC5B,EAAO,KAAK,KAAKD,EAAM,QAAU,EAEnC,OAAOH,GAAqBG,IAAS,GAAKH,EAAoB,OAChE,CAMA,SAAgBM,EACd,EACA,EACA,EACkC,CAClC,GAAIC,IAAU,WAAY,OAAOA,EACjC,IAAMF,EAAMG,GAAY,KAAK,GAAKC,GAAM,KAAK,EAC7C,OAAOJ,EAAMH,EAAiBG,CAAG,EAAI,OACvC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region src/components/data-display/Avatar.colors.ts
|
|
3
|
+
var e = [
|
|
4
|
+
"red",
|
|
5
|
+
"pumpkin",
|
|
6
|
+
"gold",
|
|
7
|
+
"forest",
|
|
8
|
+
"teal",
|
|
9
|
+
"blue",
|
|
10
|
+
"navy",
|
|
11
|
+
"lavender",
|
|
12
|
+
"purple",
|
|
13
|
+
"magenta",
|
|
14
|
+
"brown",
|
|
15
|
+
"steel"
|
|
16
|
+
], t = {
|
|
17
|
+
neutral: "bg-muted text-muted-foreground",
|
|
18
|
+
brand: "bg-primary text-primary-foreground",
|
|
19
|
+
red: "bg-palette-red text-palette-red-foreground",
|
|
20
|
+
pumpkin: "bg-palette-pumpkin text-palette-pumpkin-foreground",
|
|
21
|
+
gold: "bg-palette-gold text-palette-gold-foreground",
|
|
22
|
+
forest: "bg-palette-forest text-palette-forest-foreground",
|
|
23
|
+
teal: "bg-palette-teal text-palette-teal-foreground",
|
|
24
|
+
blue: "bg-palette-blue text-palette-blue-foreground",
|
|
25
|
+
navy: "bg-palette-navy text-palette-navy-foreground",
|
|
26
|
+
lavender: "bg-palette-lavender text-palette-lavender-foreground",
|
|
27
|
+
purple: "bg-palette-purple text-palette-purple-foreground",
|
|
28
|
+
magenta: "bg-palette-magenta text-palette-magenta-foreground",
|
|
29
|
+
brown: "bg-palette-brown text-palette-brown-foreground",
|
|
30
|
+
steel: "bg-palette-steel text-palette-steel-foreground"
|
|
31
|
+
};
|
|
32
|
+
function n(t) {
|
|
33
|
+
let n = 2166136261;
|
|
34
|
+
for (let e = 0; e < t.length; e += 1) n ^= t.charCodeAt(e), n = Math.imul(n, 16777619);
|
|
35
|
+
return e[(n >>> 0) % e.length];
|
|
36
|
+
}
|
|
37
|
+
function r(e, t, r) {
|
|
38
|
+
if (e !== "colorful") return e;
|
|
39
|
+
let i = t?.trim() || r?.trim();
|
|
40
|
+
return i ? n(i) : "brand";
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { e as AVATAR_NAMED_COLORS, t as avatarColorClasses, n as hashToNamedColor, r as resolveAvatarColor };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=Avatar.colors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Avatar.colors.mjs","names":["AVATAR_NAMED_COLORS","avatarColorClasses","hashToNamedColor","hash","index","key","resolveAvatarColor","color","idForColor","name"],"sources":["../../../src/components/data-display/Avatar.colors.ts"],"sourcesContent":["/** The named colors of an Avatar: the persona palette (`--wave-palette-<name>` tokens). */\nexport type AvatarNamedColor =\n | 'red'\n | 'pumpkin'\n | 'gold'\n | 'forest'\n | 'teal'\n | 'blue'\n | 'navy'\n | 'lavender'\n | 'purple'\n | 'magenta'\n | 'brown'\n | 'steel';\n\n/** The color of an Avatar that shows initials: a look, `colorful` (hashed), or a named color. */\nexport type AvatarColor = 'neutral' | 'brand' | 'colorful' | AvatarNamedColor;\n\n/** The named colors in a fixed order: `colorful` indexes into it, so the order never changes. */\nexport const AVATAR_NAMED_COLORS: readonly AvatarNamedColor[] = [\n 'red',\n 'pumpkin',\n 'gold',\n 'forest',\n 'teal',\n 'blue',\n 'navy',\n 'lavender',\n 'purple',\n 'magenta',\n 'brown',\n 'steel',\n];\n\n/** Fill and text classes of each resolved color. Literal strings only (Tailwind scans them). */\nexport const avatarColorClasses: Readonly<Record<Exclude<AvatarColor, 'colorful'>, string>> = {\n neutral: 'bg-muted text-muted-foreground',\n brand: 'bg-primary text-primary-foreground',\n red: 'bg-palette-red text-palette-red-foreground',\n pumpkin: 'bg-palette-pumpkin text-palette-pumpkin-foreground',\n gold: 'bg-palette-gold text-palette-gold-foreground',\n forest: 'bg-palette-forest text-palette-forest-foreground',\n teal: 'bg-palette-teal text-palette-teal-foreground',\n blue: 'bg-palette-blue text-palette-blue-foreground',\n navy: 'bg-palette-navy text-palette-navy-foreground',\n lavender: 'bg-palette-lavender text-palette-lavender-foreground',\n purple: 'bg-palette-purple text-palette-purple-foreground',\n magenta: 'bg-palette-magenta text-palette-magenta-foreground',\n brown: 'bg-palette-brown text-palette-brown-foreground',\n steel: 'bg-palette-steel text-palette-steel-foreground',\n};\n\n/**\n * The named color a string stands for: a 32-bit FNV-1a hash of its UTF-16 code units, modulo the\n * number of named colors. Stable across runs, the server and the client, and releases.\n */\nexport function hashToNamedColor(key: string): AvatarNamedColor {\n let hash = 0x811c9dc5;\n for (let index = 0; index < key.length; index += 1) {\n hash ^= key.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193);\n }\n return AVATAR_NAMED_COLORS[(hash >>> 0) % AVATAR_NAMED_COLORS.length]!;\n}\n\n/**\n * Resolves the `color` prop: `colorful` becomes the named color of `idForColor`, else of `name`,\n * else `brand`.\n */\nexport function resolveAvatarColor(\n color: AvatarColor,\n idForColor: string | undefined,\n name: string | undefined,\n): Exclude<AvatarColor, 'colorful'> {\n if (color !== 'colorful') return color;\n const key = idForColor?.trim() || name?.trim();\n return key ? hashToNamedColor(key) : 'brand';\n}\n"],"mappings":";;AAmBA,IAAaA,IAAmD;CAC9D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAGaC,IAAiF;CAC5F,SAAS;CACT,OAAO;CACP,KAAK;CACL,SAAS;CACT,MAAM;CACN,QAAQ;CACR,MAAM;CACN,MAAM;CACN,MAAM;CACN,UAAU;CACV,QAAQ;CACR,SAAS;CACT,OAAO;CACP,OAAO;AACT;AAMA,SAAgBC,EAAiB,GAA+B;CAC9D,IAAIC,IAAO;CACX,KAAK,IAAIC,IAAQ,GAAGA,IAAQC,EAAI,QAAQ,KAAS,GAE/C,AADA,KAAQA,EAAI,WAAWD,CAAK,GAC5B,IAAO,KAAK,KAAKD,GAAM,QAAU;CAEnC,OAAOH,GAAqBG,MAAS,KAAKH,EAAoB;AAChE;AAMA,SAAgBM,EACd,GACA,GACA,GACkC;CAClC,IAAIC,MAAU,YAAY,OAAOA;CACjC,IAAMF,IAAMG,GAAY,KAAK,KAAKC,GAAM,KAAK;CAC7C,OAAOJ,IAAMH,EAAiBG,CAAG,IAAI;AACvC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs");let t=require("react");t=e.__toESM(t,1);var n=t.createContext(null);n.displayName=`AvatarSizeContext`,exports.AvatarSizeContext=
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs");let t=require("react");t=e.__toESM(t,1);var n=t.createContext(null);n.displayName=`AvatarBadgeSizeContext`;var r=t.createContext(null);r.displayName=`AvatarSizeContext`,exports.AvatarBadgeSizeContext=n,exports.AvatarSizeContext=r;
|
|
2
2
|
//# sourceMappingURL=Avatar.context.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.context.cjs","names":["React","require_runtime","react","AvatarSizeContext"],"sources":["../../../src/components/data-display/Avatar.context.ts"],"sourcesContent":["import * as React from 'react';\n\n/*\n * The box a container gives the Avatars inside it that set no `size`: Tag and\n * InteractionTag.Primary provide it around their `media`, so a person's Avatar there matches the\n * tag's size. Internal (never exported from a barrel); imports no component, so a Tag that reads
|
|
1
|
+
{"version":3,"file":"Avatar.context.cjs","names":["React","require_runtime","react","AvatarBadgeSizeContext","AvatarSizeContext"],"sources":["../../../src/components/data-display/Avatar.context.ts"],"sourcesContent":["import * as React from 'react';\nimport type { Size } from '../../lib/types';\n\n/*\n * The box a container gives the Avatars inside it that set no `size`: Tag and\n * InteractionTag.Primary provide it around their `media`, so a person's Avatar there matches the\n * tag's size, and Table.CellLayout a 32px box around its `media`. Internal (never exported\n * from a barrel); imports no component, so a Tag that reads it holds no Avatar code.\n */\n\n/**\n * The box a container gives the Avatars inside it that set no `size` (Tag, InteractionTag and\n * Table.CellLayout media). Internal.\n */\nexport interface AvatarSizeContextValue {\n /** The box in pixels: a tag's 24px (Avatar's `extra-small`), 20px or 16px box, or a group's size. */\n size: number;\n /** The shape the container gives its Avatars: a rounded Tag gives `square`. */\n shape?: 'circular' | 'square';\n}\n\n/**\n * The size a badge in an Avatar's `badge` slot takes when it sets none (PresenceBadge): derived from\n * the avatar's pixel size. Internal.\n */\nexport const AvatarBadgeSizeContext = React.createContext<Size | null>(null);\nAvatarBadgeSizeContext.displayName = 'AvatarBadgeSizeContext';\n\n/**\n * Internal: provided by Tag, InteractionTag.Primary and Table.CellLayout around their `media`;\n * `null` elsewhere.\n */\nexport const AvatarSizeContext = React.createContext<AvatarSizeContextValue | null>(null);\nAvatarSizeContext.displayName = 'AvatarSizeContext';\n"],"mappings":"6GAyBA,IAAaG,EAAyBH,EAAM,cAA2B,IAAI,EAC3E,EAAuB,YAAc,yBAMrC,IAAaI,EAAoBJ,EAAM,cAA6C,IAAI,EACxF,EAAkB,YAAc"}
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
import * as e from "react";
|
|
3
3
|
//#region src/components/data-display/Avatar.context.ts
|
|
4
4
|
var t = e.createContext(null);
|
|
5
|
-
t.displayName = "
|
|
5
|
+
t.displayName = "AvatarBadgeSizeContext";
|
|
6
|
+
var n = e.createContext(null);
|
|
7
|
+
n.displayName = "AvatarSizeContext";
|
|
6
8
|
//#endregion
|
|
7
|
-
export { t as AvatarSizeContext };
|
|
9
|
+
export { t as AvatarBadgeSizeContext, n as AvatarSizeContext };
|
|
8
10
|
|
|
9
11
|
//# sourceMappingURL=Avatar.context.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.context.mjs","names":["React","AvatarSizeContext"],"sources":["../../../src/components/data-display/Avatar.context.ts"],"sourcesContent":["import * as React from 'react';\n\n/*\n * The box a container gives the Avatars inside it that set no `size`: Tag and\n * InteractionTag.Primary provide it around their `media`, so a person's Avatar there matches the\n * tag's size. Internal (never exported from a barrel); imports no component, so a Tag that reads
|
|
1
|
+
{"version":3,"file":"Avatar.context.mjs","names":["React","AvatarBadgeSizeContext","AvatarSizeContext"],"sources":["../../../src/components/data-display/Avatar.context.ts"],"sourcesContent":["import * as React from 'react';\nimport type { Size } from '../../lib/types';\n\n/*\n * The box a container gives the Avatars inside it that set no `size`: Tag and\n * InteractionTag.Primary provide it around their `media`, so a person's Avatar there matches the\n * tag's size, and Table.CellLayout a 32px box around its `media`. Internal (never exported\n * from a barrel); imports no component, so a Tag that reads it holds no Avatar code.\n */\n\n/**\n * The box a container gives the Avatars inside it that set no `size` (Tag, InteractionTag and\n * Table.CellLayout media). Internal.\n */\nexport interface AvatarSizeContextValue {\n /** The box in pixels: a tag's 24px (Avatar's `extra-small`), 20px or 16px box, or a group's size. */\n size: number;\n /** The shape the container gives its Avatars: a rounded Tag gives `square`. */\n shape?: 'circular' | 'square';\n}\n\n/**\n * The size a badge in an Avatar's `badge` slot takes when it sets none (PresenceBadge): derived from\n * the avatar's pixel size. Internal.\n */\nexport const AvatarBadgeSizeContext = React.createContext<Size | null>(null);\nAvatarBadgeSizeContext.displayName = 'AvatarBadgeSizeContext';\n\n/**\n * Internal: provided by Tag, InteractionTag.Primary and Table.CellLayout around their `media`;\n * `null` elsewhere.\n */\nexport const AvatarSizeContext = React.createContext<AvatarSizeContextValue | null>(null);\nAvatarSizeContext.displayName = 'AvatarSizeContext';\n"],"mappings":";;;AAyBA,IAAaC,IAAyBD,EAAM,cAA2B,IAAI;AAC3E,EAAuB,cAAc;AAMrC,IAAaE,IAAoBF,EAAM,cAA6C,IAAI;AACxF,EAAkB,cAAc"}
|
|
@@ -3,36 +3,32 @@ import { cn as e } from "../../lib/cn.mjs";
|
|
|
3
3
|
import { renderSlot as t, slotRendersContent as n } from "../../lib/slot.mjs";
|
|
4
4
|
import { composeEventHandlers as r } from "../../lib/composeEventHandlers.mjs";
|
|
5
5
|
import { avatarClassNames as i } from "../../lib/classNames.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { getInitials as ee } from "../../lib/initials.mjs";
|
|
7
|
+
import { useMergedRefs as te } from "../../hooks/useMergedRefs.mjs";
|
|
8
|
+
import { joinIds as ne } from "../../lib/aria.mjs";
|
|
9
|
+
import { useDirection as re } from "../../hooks/useDirection.mjs";
|
|
10
|
+
import { PersonIcon as ie } from "../../lib/icons.mjs";
|
|
11
|
+
import { AvatarBadgeSizeContext as ae, AvatarSizeContext as oe } from "./Avatar.context.mjs";
|
|
12
|
+
import { AvatarGroupContext as se } from "./AvatarGroup.context.mjs";
|
|
13
|
+
import { avatarColorClasses as ce, resolveAvatarColor as le } from "./Avatar.colors.mjs";
|
|
14
|
+
import { avatarBadgeSize as ue, avatarBoxClasses as a, avatarPixelSize as de, avatarShapeClasses as fe, avatarSizeClassesFor as pe } from "./Avatar.sizes.mjs";
|
|
10
15
|
import * as o from "react";
|
|
11
|
-
import { jsx as s, jsxs as
|
|
12
|
-
|
|
13
|
-
var c = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
24: c["extra-small"],
|
|
21
|
-
20: "w-5 h-5 text-[10px]",
|
|
22
|
-
16: "w-4 h-4 text-[10px]"
|
|
23
|
-
}, l = "w-full h-full object-cover";
|
|
24
|
-
function ae(e) {
|
|
25
|
-
let t = e.trim().split(/\s+/).filter(Boolean);
|
|
26
|
-
return t.length === 0 ? "" : ((Array.from(t[0])[0] ?? "") + (t.length > 1 ? Array.from(t[t.length - 1])[0] ?? "" : "")).toUpperCase();
|
|
27
|
-
}
|
|
28
|
-
function u(e) {
|
|
16
|
+
import { jsx as s, jsxs as me } from "react/jsx-runtime";
|
|
17
|
+
a[24], a[32], a[40], a[48], a[56];
|
|
18
|
+
var c = "w-full h-full object-cover", he = {
|
|
19
|
+
ring: "ring-2 ring-primary ring-offset-2 ring-offset-background",
|
|
20
|
+
"ring-shadow": "ring-2 ring-primary ring-offset-2 ring-offset-background shadow-8",
|
|
21
|
+
shadow: "shadow-8",
|
|
22
|
+
glow: "shadow-[0_0_0.5rem_0.125rem_var(--wave-primary)]"
|
|
23
|
+
};
|
|
24
|
+
function l(e) {
|
|
29
25
|
return e?.trim().replace(/\s+/g, " ") || void 0;
|
|
30
26
|
}
|
|
31
|
-
function
|
|
27
|
+
function ge(e) {
|
|
32
28
|
if (o.isValidElement(e)) return e.props;
|
|
33
29
|
if (typeof e == "object" && e && !(Symbol.iterator in e)) return e;
|
|
34
30
|
}
|
|
35
|
-
function
|
|
31
|
+
function _e(e, t, n) {
|
|
36
32
|
if (e === void 0) return [
|
|
37
33
|
void 0,
|
|
38
34
|
void 0,
|
|
@@ -53,115 +49,126 @@ function se(e, t, n) {
|
|
|
53
49
|
t?.srcSet
|
|
54
50
|
];
|
|
55
51
|
}
|
|
56
|
-
function
|
|
52
|
+
function u(e) {
|
|
57
53
|
if (typeof e != "object" || !e) return !1;
|
|
58
54
|
let t = Object.getPrototypeOf(e);
|
|
59
55
|
return t === Object.prototype || t === null;
|
|
60
56
|
}
|
|
61
|
-
function
|
|
57
|
+
function d(e, t) {
|
|
62
58
|
if (Object.is(e, t)) return !0;
|
|
63
|
-
if (!
|
|
59
|
+
if (!u(e) || !u(t)) return !1;
|
|
64
60
|
let n = Object.keys(e);
|
|
65
61
|
return n.length === Object.keys(t).length && n.every((n) => Object.prototype.hasOwnProperty.call(t, n) && Object.is(e[n], t[n]));
|
|
66
62
|
}
|
|
67
|
-
function
|
|
68
|
-
return e.every((e, n) =>
|
|
63
|
+
function ve(e, t) {
|
|
64
|
+
return e.every((e, n) => d(e, t[n]));
|
|
69
65
|
}
|
|
70
|
-
var
|
|
71
|
-
let
|
|
72
|
-
|
|
73
|
-
let
|
|
66
|
+
var f = ({ src: a, name: u, size: d, shape: f, color: ye = "brand", idForColor: be, active: p = "unset", activeAppearance: m = "ring", initials: h, icon: g, image: _, badge: v, decorative: y = !1, className: xe, ref: Se, role: b, "aria-label": x, "aria-labelledby": S, "aria-describedby": C, "aria-description": Ce, "aria-details": we, ...w }) => {
|
|
67
|
+
let T = o.useContext(oe), E = _ == null || typeof _ == "boolean" || _ === "" ? void 0 : _, D = ge(E), O = _e(E, D, a), [Te, k] = o.useState(!1), [Ee, De] = o.useState(O);
|
|
68
|
+
ve(Ee, O) || (De(O), k(!1));
|
|
69
|
+
let A = o.useRef(null);
|
|
74
70
|
o.useLayoutEffect(() => {
|
|
75
|
-
let e =
|
|
71
|
+
let e = A.current?.querySelector("img");
|
|
76
72
|
if (!e || !e.complete || e.naturalWidth !== 0) return;
|
|
77
73
|
let t = !0, n = e.getAttribute("src"), r = e.getAttribute("srcset"), i = () => {
|
|
78
|
-
t && e.isConnected && e.getAttribute("src") === n && e.getAttribute("srcset") === r &&
|
|
74
|
+
t && e.isConnected && e.getAttribute("src") === n && e.getAttribute("srcset") === r && k(!0);
|
|
79
75
|
};
|
|
80
76
|
return typeof e.decode == "function" ? e.decode().then(void 0, i) : queueMicrotask(i), () => {
|
|
81
77
|
t = !1;
|
|
82
78
|
};
|
|
83
79
|
}, []);
|
|
84
|
-
let
|
|
85
|
-
"aria-describedby":
|
|
86
|
-
"aria-description":
|
|
87
|
-
"aria-details":
|
|
88
|
-
},
|
|
89
|
-
if (!
|
|
90
|
-
if (typeof
|
|
91
|
-
src:
|
|
92
|
-
alt:
|
|
93
|
-
...
|
|
94
|
-
className: e(i.image,
|
|
95
|
-
onError:
|
|
80
|
+
let Oe = te(Se, A), j = x !== void 0 || S !== void 0, M = b !== void 0 && b !== "presentation" && b !== "none", N = l(u), P = y || j || M ? "" : N ?? "", F = () => k(!0), I = D?.alt, L = I != null, R = L ? I : P, z = {
|
|
81
|
+
"aria-describedby": C,
|
|
82
|
+
"aria-description": Ce,
|
|
83
|
+
"aria-details": we
|
|
84
|
+
}, B = !y && !j && !M && typeof R == "string" && R.trim() !== "", V = B ? z : {}, H = null;
|
|
85
|
+
if (!Te) {
|
|
86
|
+
if (typeof E == "string") H = /* @__PURE__ */ s("img", {
|
|
87
|
+
src: E,
|
|
88
|
+
alt: P,
|
|
89
|
+
...V,
|
|
90
|
+
className: e(i.image, c),
|
|
91
|
+
onError: F
|
|
96
92
|
});
|
|
97
|
-
else if (
|
|
98
|
-
let n = { onError: r(
|
|
99
|
-
if (
|
|
100
|
-
let e =
|
|
101
|
-
n["aria-describedby"] =
|
|
93
|
+
else if (E !== void 0) {
|
|
94
|
+
let n = { onError: r(D?.onError, F) };
|
|
95
|
+
if (L || (n.alt = P), B) {
|
|
96
|
+
let e = D?.["aria-describedby"];
|
|
97
|
+
n["aria-describedby"] = ne(C, typeof e == "string" ? e : void 0);
|
|
102
98
|
}
|
|
103
|
-
let
|
|
104
|
-
...
|
|
99
|
+
let ee = o.isValidElement(E) ? o.cloneElement(E, n) : D ? {
|
|
100
|
+
...E,
|
|
105
101
|
...n
|
|
106
|
-
} :
|
|
107
|
-
|
|
108
|
-
alt:
|
|
109
|
-
...
|
|
102
|
+
} : E;
|
|
103
|
+
H = t(ee, "img", e(i.image, c), {
|
|
104
|
+
alt: P,
|
|
105
|
+
...V
|
|
110
106
|
});
|
|
111
|
-
} else
|
|
112
|
-
src:
|
|
113
|
-
alt:
|
|
114
|
-
...
|
|
115
|
-
className: e(i.image,
|
|
116
|
-
onError:
|
|
107
|
+
} else a && (H = /* @__PURE__ */ s("img", {
|
|
108
|
+
src: a,
|
|
109
|
+
alt: P,
|
|
110
|
+
...V,
|
|
111
|
+
className: e(i.image, c),
|
|
112
|
+
onError: F
|
|
117
113
|
}));
|
|
118
114
|
}
|
|
119
|
-
let
|
|
120
|
-
W === null ? K === null ? q ? (J = /* @__PURE__ */ s("span", {
|
|
115
|
+
let U = H !== null && B ? {} : z, W = H === null && g && n(g) ? t(g, "span", e(i.icon, "inline-flex"), { "aria-hidden": !0 }) : null, ke = re(), G = o.useContext(se), K = e(i.initials, G?.layout === "pie" && "invisible"), q = le(ye, be, u), J = H === null && W === null, Ae = J && u ? ee(u, { dir: ke }) : "", je = J ? h && n(h) ? t(h, "span", K, { "aria-hidden": !0 }) : Ae ? /* @__PURE__ */ s("span", {
|
|
121
116
|
"aria-hidden": "true",
|
|
122
|
-
className:
|
|
123
|
-
children:
|
|
124
|
-
})
|
|
117
|
+
className: K,
|
|
118
|
+
children: Ae
|
|
119
|
+
}) : null : null, Y, X;
|
|
120
|
+
H === null ? W === null ? je ? (Y = je, X = ce[q]) : (Y = /* @__PURE__ */ s(ie, {
|
|
125
121
|
size: "60%",
|
|
126
122
|
className: i.icon
|
|
127
|
-
}),
|
|
128
|
-
let
|
|
129
|
-
Z =
|
|
123
|
+
}), X = "bg-muted text-muted-foreground") : (Y = W, X = "bg-muted text-muted-foreground") : Y = H;
|
|
124
|
+
let Me = H !== null && M && typeof R == "string" ? l(R) : void 0, Ne = typeof I == "string" ? l(I) : void 0, Pe = x ?? (H === null ? N ?? Ne : M ? Me ?? N : void 0), Z;
|
|
125
|
+
Z = y ? {
|
|
130
126
|
"aria-hidden": !0,
|
|
131
|
-
...
|
|
132
|
-
} :
|
|
133
|
-
role:
|
|
134
|
-
"aria-label":
|
|
135
|
-
"aria-labelledby":
|
|
136
|
-
...
|
|
137
|
-
} :
|
|
138
|
-
role:
|
|
139
|
-
...
|
|
127
|
+
...U
|
|
128
|
+
} : Pe !== void 0 || S !== void 0 ? {
|
|
129
|
+
role: b ?? "img",
|
|
130
|
+
"aria-label": Pe,
|
|
131
|
+
"aria-labelledby": S,
|
|
132
|
+
...U
|
|
133
|
+
} : H !== null || b !== void 0 ? {
|
|
134
|
+
role: b,
|
|
135
|
+
...U
|
|
140
136
|
} : {
|
|
141
137
|
"aria-hidden": !0,
|
|
142
|
-
...
|
|
138
|
+
...U
|
|
143
139
|
};
|
|
144
|
-
let
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
140
|
+
let Fe = v && n(v) ? t(v, "span", e(i.badge, "absolute bottom-0 end-0 inline-flex")) : null, Ie = Fe !== null, Q = d ?? G?.size ?? (T ? T.size : "medium"), Le = f ?? T?.shape ?? "circular", Re = de(Q), ze = {
|
|
141
|
+
"data-size": String(Q),
|
|
142
|
+
"data-shape": Le,
|
|
143
|
+
"data-color": q,
|
|
144
|
+
"data-active": p,
|
|
145
|
+
"data-active-appearance": m
|
|
146
|
+
}, $ = e(i.visual, "inline-flex items-center justify-center overflow-hidden shrink-0 font-bold", fe(Le, Re), pe(Q), X, p === "active" && he[m], p === "inactive" && "opacity-60 transition-opacity motion-reduce:transition-none");
|
|
147
|
+
return Ie ? /* @__PURE__ */ me("span", {
|
|
148
|
+
ref: Se,
|
|
149
|
+
...ze,
|
|
150
|
+
...w,
|
|
151
|
+
className: e(i.root, "relative inline-flex shrink-0", xe),
|
|
149
152
|
children: [/* @__PURE__ */ s("span", {
|
|
150
|
-
ref:
|
|
153
|
+
ref: A,
|
|
151
154
|
...Z,
|
|
152
155
|
className: $,
|
|
153
|
-
children:
|
|
154
|
-
}),
|
|
156
|
+
children: Y
|
|
157
|
+
}), /* @__PURE__ */ s(ae.Provider, {
|
|
158
|
+
value: ue(Re),
|
|
159
|
+
children: Fe
|
|
160
|
+
})]
|
|
155
161
|
}) : /* @__PURE__ */ s("span", {
|
|
156
|
-
ref:
|
|
162
|
+
ref: Oe,
|
|
157
163
|
...Z,
|
|
158
|
-
...
|
|
159
|
-
|
|
160
|
-
|
|
164
|
+
...ze,
|
|
165
|
+
...w,
|
|
166
|
+
className: e(i.root, $, xe),
|
|
167
|
+
children: Y
|
|
161
168
|
});
|
|
162
169
|
};
|
|
163
|
-
|
|
170
|
+
f.displayName = "Avatar";
|
|
164
171
|
//#endregion
|
|
165
|
-
export {
|
|
172
|
+
export { f as Avatar };
|
|
166
173
|
|
|
167
174
|
//# sourceMappingURL=Avatar.mjs.map
|