@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.
Files changed (174) hide show
  1. package/README.md +362 -60
  2. package/dist/components/data-display/Avatar.cjs +1 -1
  3. package/dist/components/data-display/Avatar.cjs.map +1 -1
  4. package/dist/components/data-display/Avatar.colors.cjs +2 -0
  5. package/dist/components/data-display/Avatar.colors.cjs.map +1 -0
  6. package/dist/components/data-display/Avatar.colors.mjs +45 -0
  7. package/dist/components/data-display/Avatar.colors.mjs.map +1 -0
  8. package/dist/components/data-display/Avatar.context.cjs +1 -1
  9. package/dist/components/data-display/Avatar.context.cjs.map +1 -1
  10. package/dist/components/data-display/Avatar.context.mjs +4 -2
  11. package/dist/components/data-display/Avatar.context.mjs.map +1 -1
  12. package/dist/components/data-display/Avatar.mjs +103 -96
  13. package/dist/components/data-display/Avatar.mjs.map +1 -1
  14. package/dist/components/data-display/Avatar.sizes.cjs +2 -0
  15. package/dist/components/data-display/Avatar.sizes.cjs.map +1 -0
  16. package/dist/components/data-display/Avatar.sizes.mjs +41 -0
  17. package/dist/components/data-display/Avatar.sizes.mjs.map +1 -0
  18. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  19. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  20. package/dist/components/data-display/AvatarGroup.context.cjs +2 -0
  21. package/dist/components/data-display/AvatarGroup.context.cjs.map +1 -0
  22. package/dist/components/data-display/AvatarGroup.context.mjs +9 -0
  23. package/dist/components/data-display/AvatarGroup.context.mjs.map +1 -0
  24. package/dist/components/data-display/AvatarGroup.mjs +65 -122
  25. package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
  26. package/dist/components/data-display/AvatarGroup.partition.cjs +2 -0
  27. package/dist/components/data-display/AvatarGroup.partition.cjs.map +1 -0
  28. package/dist/components/data-display/AvatarGroup.partition.mjs +14 -0
  29. package/dist/components/data-display/AvatarGroup.partition.mjs.map +1 -0
  30. package/dist/components/data-display/AvatarGroup.parts.cjs +2 -0
  31. package/dist/components/data-display/AvatarGroup.parts.cjs.map +1 -0
  32. package/dist/components/data-display/AvatarGroup.parts.mjs +178 -0
  33. package/dist/components/data-display/AvatarGroup.parts.mjs.map +1 -0
  34. package/dist/components/data-display/InteractionTag.cjs +1 -1
  35. package/dist/components/data-display/InteractionTag.cjs.map +1 -1
  36. package/dist/components/data-display/InteractionTag.mjs +36 -33
  37. package/dist/components/data-display/InteractionTag.mjs.map +1 -1
  38. package/dist/components/data-display/List.cjs +1 -1
  39. package/dist/components/data-display/List.cjs.map +1 -1
  40. package/dist/components/data-display/List.mjs +245 -195
  41. package/dist/components/data-display/List.mjs.map +1 -1
  42. package/dist/components/data-display/List.registry.cjs.map +1 -1
  43. package/dist/components/data-display/List.registry.mjs.map +1 -1
  44. package/dist/components/data-display/Persona.cjs +1 -1
  45. package/dist/components/data-display/Persona.cjs.map +1 -1
  46. package/dist/components/data-display/Persona.mjs +96 -37
  47. package/dist/components/data-display/Persona.mjs.map +1 -1
  48. package/dist/components/data-display/PresenceBadge.cjs +1 -1
  49. package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
  50. package/dist/components/data-display/PresenceBadge.mjs +42 -28
  51. package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
  52. package/dist/components/data-display/Tag.cjs +1 -1
  53. package/dist/components/data-display/Tag.cjs.map +1 -1
  54. package/dist/components/data-display/Tag.mjs +111 -108
  55. package/dist/components/data-display/Tag.mjs.map +1 -1
  56. package/dist/components/layout/Card.cjs +1 -1
  57. package/dist/components/layout/Card.cjs.map +1 -1
  58. package/dist/components/layout/Card.context.cjs +2 -0
  59. package/dist/components/layout/Card.context.cjs.map +1 -0
  60. package/dist/components/layout/Card.context.mjs +14 -0
  61. package/dist/components/layout/Card.context.mjs.map +1 -0
  62. package/dist/components/layout/Card.mjs +138 -92
  63. package/dist/components/layout/Card.mjs.map +1 -1
  64. package/dist/components/layout/Card.preview.cjs +2 -0
  65. package/dist/components/layout/Card.preview.cjs.map +1 -0
  66. package/dist/components/layout/Card.preview.mjs +22 -0
  67. package/dist/components/layout/Card.preview.mjs.map +1 -0
  68. package/dist/components/layout/Carousel.button.cjs +2 -0
  69. package/dist/components/layout/Carousel.button.cjs.map +1 -0
  70. package/dist/components/layout/Carousel.button.mjs +34 -0
  71. package/dist/components/layout/Carousel.button.mjs.map +1 -0
  72. package/dist/components/layout/Carousel.cjs +1 -1
  73. package/dist/components/layout/Carousel.cjs.map +1 -1
  74. package/dist/components/layout/Carousel.context.cjs +2 -0
  75. package/dist/components/layout/Carousel.context.cjs.map +1 -0
  76. package/dist/components/layout/Carousel.context.mjs +24 -0
  77. package/dist/components/layout/Carousel.context.mjs.map +1 -0
  78. package/dist/components/layout/Carousel.drag.cjs +2 -0
  79. package/dist/components/layout/Carousel.drag.cjs.map +1 -0
  80. package/dist/components/layout/Carousel.drag.mjs +79 -0
  81. package/dist/components/layout/Carousel.drag.mjs.map +1 -0
  82. package/dist/components/layout/Carousel.groups.cjs +2 -0
  83. package/dist/components/layout/Carousel.groups.cjs.map +1 -0
  84. package/dist/components/layout/Carousel.groups.mjs +23 -0
  85. package/dist/components/layout/Carousel.groups.mjs.map +1 -0
  86. package/dist/components/layout/Carousel.mjs +288 -150
  87. package/dist/components/layout/Carousel.mjs.map +1 -1
  88. package/dist/components/layout/Carousel.styles.cjs +2 -0
  89. package/dist/components/layout/Carousel.styles.cjs.map +1 -0
  90. package/dist/components/layout/Carousel.styles.mjs +30 -0
  91. package/dist/components/layout/Carousel.styles.mjs.map +1 -0
  92. package/dist/components/layout/Overflow.cjs +1 -1
  93. package/dist/components/layout/Overflow.cjs.map +1 -1
  94. package/dist/components/layout/Overflow.mjs +240 -192
  95. package/dist/components/layout/Overflow.mjs.map +1 -1
  96. package/dist/components/layout/Overflow.store.cjs +2 -0
  97. package/dist/components/layout/Overflow.store.cjs.map +1 -0
  98. package/dist/components/layout/Overflow.store.mjs +209 -0
  99. package/dist/components/layout/Overflow.store.mjs.map +1 -0
  100. package/dist/components/layout/TabList.cjs +1 -1
  101. package/dist/components/layout/TabList.cjs.map +1 -1
  102. package/dist/components/layout/TabList.mjs +163 -124
  103. package/dist/components/layout/TabList.mjs.map +1 -1
  104. package/dist/components/navigation/Breadcrumb.cjs +1 -1
  105. package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
  106. package/dist/components/navigation/Breadcrumb.mjs +239 -84
  107. package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
  108. package/dist/components/overlays/Dialog.slots.cjs +1 -1
  109. package/dist/components/overlays/Dialog.slots.cjs.map +1 -1
  110. package/dist/components/overlays/Dialog.slots.mjs +19 -15
  111. package/dist/components/overlays/Dialog.slots.mjs.map +1 -1
  112. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  113. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  114. package/dist/components/overlays/TeachingPopover.context.cjs +2 -0
  115. package/dist/components/overlays/TeachingPopover.context.cjs.map +1 -0
  116. package/dist/components/overlays/TeachingPopover.context.mjs +51 -0
  117. package/dist/components/overlays/TeachingPopover.context.mjs.map +1 -0
  118. package/dist/components/overlays/TeachingPopover.mjs +15 -185
  119. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  120. package/dist/components/overlays/TeachingPopover.parts.cjs +2 -0
  121. package/dist/components/overlays/TeachingPopover.parts.cjs.map +1 -0
  122. package/dist/components/overlays/TeachingPopover.parts.mjs +398 -0
  123. package/dist/components/overlays/TeachingPopover.parts.mjs.map +1 -0
  124. package/dist/components/overlays/TeachingPopover.root.cjs +2 -0
  125. package/dist/components/overlays/TeachingPopover.root.cjs.map +1 -0
  126. package/dist/components/overlays/TeachingPopover.root.mjs +150 -0
  127. package/dist/components/overlays/TeachingPopover.root.mjs.map +1 -0
  128. package/dist/components/overlays/TeachingPopover.stack.cjs +2 -0
  129. package/dist/components/overlays/TeachingPopover.stack.cjs.map +1 -0
  130. package/dist/components/overlays/TeachingPopover.stack.mjs +86 -0
  131. package/dist/components/overlays/TeachingPopover.stack.mjs.map +1 -0
  132. package/dist/components/table/DataGrid.cjs +1 -1
  133. package/dist/components/table/DataGrid.cjs.map +1 -1
  134. package/dist/components/table/DataGrid.mjs +540 -311
  135. package/dist/components/table/DataGrid.mjs.map +1 -1
  136. package/dist/components/table/Table.cjs +1 -1
  137. package/dist/components/table/Table.cjs.map +1 -1
  138. package/dist/components/table/Table.mjs +183 -60
  139. package/dist/components/table/Table.mjs.map +1 -1
  140. package/dist/components/table/Table.shared.cjs +2 -0
  141. package/dist/components/table/Table.shared.cjs.map +1 -0
  142. package/dist/components/table/Table.shared.mjs +65 -0
  143. package/dist/components/table/Table.shared.mjs.map +1 -0
  144. package/dist/index.cjs +1 -1
  145. package/dist/index.d.cts +2299 -213
  146. package/dist/index.d.ts +2299 -213
  147. package/dist/index.mjs +135 -127
  148. package/dist/lib/breadcrumb.cjs +2 -0
  149. package/dist/lib/breadcrumb.cjs.map +1 -0
  150. package/dist/lib/breadcrumb.mjs +26 -0
  151. package/dist/lib/breadcrumb.mjs.map +1 -0
  152. package/dist/lib/classNames.cjs +1 -1
  153. package/dist/lib/classNames.cjs.map +1 -1
  154. package/dist/lib/classNames.mjs +143 -95
  155. package/dist/lib/classNames.mjs.map +1 -1
  156. package/dist/lib/events.cjs +1 -1
  157. package/dist/lib/events.cjs.map +1 -1
  158. package/dist/lib/events.mjs +35 -8
  159. package/dist/lib/events.mjs.map +1 -1
  160. package/dist/lib/icons.cjs +1 -1
  161. package/dist/lib/icons.cjs.map +1 -1
  162. package/dist/lib/icons.mjs +34 -20
  163. package/dist/lib/icons.mjs.map +1 -1
  164. package/dist/lib/initials.cjs +2 -0
  165. package/dist/lib/initials.cjs.map +1 -0
  166. package/dist/lib/initials.mjs +21 -0
  167. package/dist/lib/initials.mjs.map +1 -0
  168. package/dist/lib/table.cjs +2 -0
  169. package/dist/lib/table.cjs.map +1 -0
  170. package/dist/lib/table.mjs +16 -0
  171. package/dist/lib/table.mjs.map +1 -0
  172. package/dist/styles.css +1 -1
  173. package/package.json +1 -1
  174. package/src/styles/tokens.css +102 -0
@@ -1,50 +1,109 @@
1
1
  "use client";
2
2
  import { cn as e } from "../../lib/cn.mjs";
3
- import { renderSlot as t, slotRendersContent as n } from "../../lib/slot.mjs";
4
- import { personaClassNames as r } from "../../lib/classNames.mjs";
5
- import { Avatar as i } from "./Avatar.mjs";
6
- import { PresenceBadge as a } from "./PresenceBadge.mjs";
7
- import "react";
8
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
3
+ import { warnOnce as t } from "../../lib/dev.mjs";
4
+ import { renderSlot as n, slotRendersContent as r } from "../../lib/slot.mjs";
5
+ import { personaClassNames as i } from "../../lib/classNames.mjs";
6
+ import { Avatar as a } from "./Avatar.mjs";
7
+ import { PresenceBadge as o } from "./PresenceBadge.mjs";
8
+ import * as s from "react";
9
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
9
10
  //#region src/components/data-display/Persona.tsx
10
- function c(e) {
11
- return e === "extra-small" || e === "small" ? "small" : "medium";
11
+ function u(e) {
12
+ return e === "extra-small" || e === "small" ? "small" : e === "huge" ? "large" : "medium";
12
13
  }
13
- var l = ({ name: l, secondaryText: u, src: d, size: f = "medium", status: p, avatar: m, badge: h, className: g, ref: _, ...v }) => {
14
- let y = h && n(h) ? t(h, "span") : p ? /* @__PURE__ */ o(a, {
15
- status: p,
16
- size: c(f)
17
- }) : null;
18
- return /* @__PURE__ */ s("div", {
19
- ref: _,
20
- className: e(r.root, "inline-flex items-center gap-3", g),
21
- ...v,
22
- children: [/* @__PURE__ */ s("div", {
14
+ function d(e) {
15
+ return e === "extra-small" || e === "small" ? "medium" : e === "medium" || e === "large" ? "large" : "extra-large";
16
+ }
17
+ var f = {
18
+ "extra-small": {
19
+ primary: "text-caption-1",
20
+ other: "text-caption-2"
21
+ },
22
+ small: {
23
+ primary: "text-body-1",
24
+ other: "text-caption-1"
25
+ },
26
+ medium: {
27
+ primary: "text-body-1",
28
+ other: "text-caption-1"
29
+ },
30
+ large: {
31
+ primary: "text-subtitle-2",
32
+ other: "text-body-1"
33
+ },
34
+ "extra-large": {
35
+ primary: "text-subtitle-1",
36
+ other: "text-body-1"
37
+ },
38
+ huge: {
39
+ primary: "text-title-3",
40
+ other: "text-body-2"
41
+ }
42
+ }, p = {
43
+ after: "inline-flex items-center gap-3",
44
+ before: "inline-flex flex-row-reverse items-center gap-3",
45
+ below: "inline-flex flex-col items-center gap-2"
46
+ }, m = ({ name: m, primaryText: h, secondaryText: g, tertiaryText: _, quaternaryText: v, textPosition: y = "after", textAlignment: b, presenceOnly: x = !1, src: S, size: C = "medium", status: w, avatar: T, badge: E, className: D, ref: O, ...k }) => {
47
+ let A = b ?? (y === "below" ? "center" : "start"), j = h === void 0 ? !!m : r(h);
48
+ s.useEffect(() => {
49
+ j || t("Persona:unnamed", "Persona: it has neither a `name` nor a `primaryText`, so nothing names the person. Pass one of them.");
50
+ }, [j]);
51
+ let M = E && r(E) ? n(E, "span") : w ? /* @__PURE__ */ c(o, {
52
+ status: w,
53
+ size: x ? d(C) : u(C)
54
+ }) : null, N = f[C], P = [
55
+ {
56
+ key: "primaryText",
57
+ slot: h ?? m,
58
+ className: e(i.primaryText, N.primary, "font-semibold")
59
+ },
60
+ {
61
+ key: "secondaryText",
62
+ slot: g,
63
+ className: e(i.secondaryText, N.other, "text-muted-foreground")
64
+ },
65
+ {
66
+ key: "tertiaryText",
67
+ slot: _,
68
+ className: e(i.tertiaryText, N.other, "text-muted-foreground")
69
+ },
70
+ {
71
+ key: "quaternaryText",
72
+ slot: v,
73
+ className: e(i.quaternaryText, N.other, "text-muted-foreground")
74
+ }
75
+ ];
76
+ return /* @__PURE__ */ l("div", {
77
+ ref: O,
78
+ "data-size": C,
79
+ "data-text-position": y,
80
+ "data-text-alignment": A,
81
+ "data-presence-only": x ? "" : void 0,
82
+ className: e(i.root, p[y], D),
83
+ ...k,
84
+ children: [x ? M && /* @__PURE__ */ c("span", {
85
+ className: e(i.badge, "inline-flex shrink-0"),
86
+ children: M
87
+ }) : /* @__PURE__ */ l("div", {
23
88
  className: "relative inline-flex shrink-0",
24
- children: [m && n(m) ? t(m, "span", r.avatar) : /* @__PURE__ */ o(i, {
25
- src: d,
26
- name: l,
27
- size: f,
89
+ children: [T && r(T) ? n(T, "span", i.avatar) : /* @__PURE__ */ c(a, {
90
+ src: S,
91
+ name: m,
92
+ size: C === "huge" ? 72 : C,
28
93
  decorative: !0,
29
- className: r.avatar
30
- }), y && /* @__PURE__ */ o("span", {
31
- className: e(r.badge, "absolute bottom-0 end-0 inline-flex"),
32
- children: y
33
- })]
34
- }), /* @__PURE__ */ s("div", {
35
- className: "flex flex-col",
36
- children: [/* @__PURE__ */ o("span", {
37
- className: e(r.primaryText, "font-semibold text-body-1"),
38
- children: l
39
- }), u && /* @__PURE__ */ o("span", {
40
- className: e(r.secondaryText, "text-caption-1 text-muted-foreground"),
41
- children: u
94
+ className: i.avatar
95
+ }), M && /* @__PURE__ */ c("span", {
96
+ className: e(i.badge, "absolute bottom-0 end-0 inline-flex"),
97
+ children: M
42
98
  })]
99
+ }), /* @__PURE__ */ c("div", {
100
+ className: e("flex flex-col", A === "center" ? "items-center text-center" : "items-start text-start"),
101
+ children: P.map(({ key: e, slot: t, className: i }) => t !== void 0 && r(t) && n(t, "span", i, { key: e }))
43
102
  })]
44
103
  });
45
104
  };
46
- l.displayName = "Persona";
105
+ m.displayName = "Persona";
47
106
  //#endregion
48
- export { l as Persona };
107
+ export { m as Persona };
49
108
 
50
109
  //# sourceMappingURL=Persona.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Persona.mjs","names":["derivePresenceSize","size","Persona","props","badgeNode","badge","slotRendersContent","renderSlot","status","PresenceBadge","cn","personaClassNames","className","avatar","Avatar","name","secondaryText"],"sources":["../../../src/components/data-display/Persona.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { personaClassNames } from '../../lib/classNames';\nimport type { PresenceStatus, Size, Slot } from '../../lib/types';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport { Avatar } from './Avatar';\nimport { PresenceBadge } from './PresenceBadge';\n\n/** Properties for the Persona component. */\nexport interface PersonaProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Display name of the person. */\n name: string;\n /** Secondary text such as job title or email. */\n secondaryText?: string;\n /** URL of the person's avatar image. */\n src?: string;\n /** Size of the persona avatar.\n * @default 'medium'\n */\n size?: Size;\n /** Presence status shown as a badge on the avatar. Ignored when a `badge` is given. */\n status?: PresenceStatus;\n /**\n * Slot for a custom avatar element, replacing the built-in one. The name is already visible\n * next to it, so make a custom avatar decorative (e.g. `<Avatar decorative … />`). A value that\n * renders nothing (`null`, `false`, `''`, `0`, `NaN`, or an array, `Set` or generator of only\n * such items) counts as not given.\n */\n avatar?: Slot<'span'>;\n /**\n * Slot for a custom badge element. Takes precedence over `status`. A value that renders nothing\n * (`null`, `false`, `''`, `0`, `NaN`, e.g. `badge={count && <CounterBadge count={count} />}`,\n * or an array, `Set` or generator of only such items) counts as not given.\n */\n badge?: Slot<'span'>;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nfunction derivePresenceSize(size: Size): Size {\n return size === 'extra-small' || size === 'small' ? 'small' : 'medium';\n}\n\n/**\n * A person's avatar next to their name and optional secondary text (job title, email), with an\n * optional presence badge.\n *\n * The built-in avatar is decorative (`<Avatar decorative>`): the visible name is announced once,\n * not a second time as the avatar's image name. The presence badge stays exposed as a named image.\n *\n * @example\n * <Persona name=\"Jane Doe\" secondaryText=\"Designer\" status=\"available\" />\n */\nexport const Persona = ({\n name,\n secondaryText,\n src,\n size = 'medium',\n status,\n avatar,\n badge,\n className,\n ref,\n ...props\n}: PersonaProps) => {\n // A slot that renders nothing (`badge={count && …}` with count 0, an empty `.map()` result) is\n // not given (C-SLOTS), so the status badge and the built-in avatar apply.\n const badgeNode =\n badge && slotRendersContent(badge) ? (\n renderSlot(badge, 'span')\n ) : status ? (\n <PresenceBadge status={status} size={derivePresenceSize(size)} />\n ) : null;\n\n return (\n <div\n ref={ref}\n className={cn(personaClassNames.root, 'inline-flex items-center gap-3', className)}\n {...props}\n >\n <div className=\"relative inline-flex shrink-0\">\n {avatar && slotRendersContent(avatar) ? (\n renderSlot(avatar, 'span', personaClassNames.avatar)\n ) : (\n <Avatar\n src={src}\n name={name}\n size={size}\n decorative\n className={personaClassNames.avatar}\n />\n )}\n {badgeNode && (\n <span className={cn(personaClassNames.badge, 'absolute bottom-0 end-0 inline-flex')}>\n {badgeNode}\n </span>\n )}\n </div>\n <div className=\"flex flex-col\">\n <span className={cn(personaClassNames.primaryText, 'font-semibold text-body-1')}>\n {name}\n </span>\n {secondaryText && (\n <span\n className={cn(personaClassNames.secondaryText, 'text-caption-1 text-muted-foreground')}\n >\n {secondaryText}\n </span>\n )}\n </div>\n </div>\n );\n};\n\nPersona.displayName = 'Persona';\n"],"mappings":";;;;;;;;;AAuCA,SAASA,EAAmB,GAAkB;CAC5C,OAAOC,MAAS,iBAAiBA,MAAS,UAAU,UAAU;AAChE;AAYA,IAAaC,KAAW,EACtB,SACA,kBACA,QACA,UAAO,UACP,WACA,WACA,UACA,cACA,QACA,GAAGC,QACe;CAGlB,IAAMC,IACJC,KAASC,EAAmBD,CAAK,IAC/BE,EAAWF,GAAO,MAAM,IACtBG,IACF,kBAACC,GAAD;EAAuB;EAAQ,MAAMT,EAAmBC,CAAI;CAAI,CAAA,IAC9D;CAEN,OACE,kBAAC,OAAD;EACO;EACL,WAAWS,EAAGC,EAAkB,MAAM,kCAAkCC,CAAS;EACjF,GAAIT;EAHN,UAAA,CAKE,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACGU,KAAUP,EAAmBO,CAAM,IAClCN,EAAWM,GAAQ,QAAQF,EAAkB,MAAM,IAEnD,kBAACG,GAAD;IACO;IACC;IACA;IACN,YAAA;IACA,WAAWH,EAAkB;GAC9B,CAAA,GAEFP,KACC,kBAAC,QAAD;IAAM,WAAWM,EAAGC,EAAkB,OAAO,qCAAqC;IAC/E,UAAAP;GACG,CAAA,CAEL;EACL,CAAA,GAAA,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,QAAD;IAAM,WAAWM,EAAGC,EAAkB,aAAa,2BAA2B;IAC3E,UAAAI;GACG,CAAA,GACLC,KACC,kBAAC,QAAD;IACE,WAAWN,EAAGC,EAAkB,eAAe,sCAAsC;IAEpF,UAAAK;GACG,CAAA,CAEL;EACF,CAAA,CAAA;;AAET;AAEA,EAAQ,cAAc"}
1
+ {"version":3,"file":"Persona.mjs","names":["React","derivePresenceSize","size","derivePresenceOnlySize","textClasses","positionClasses","Persona","props","resolvedAlignment","textAlignment","textPosition","hasPrimary","primaryText","name","slotRendersContent","warnOnce","badgeNode","badge","renderSlot","status","PresenceBadge","presenceOnly","text","lines","cn","personaClassNames","secondaryText","tertiaryText","quaternaryText","className","avatar","Avatar","lineClass","slot"],"sources":["../../../src/components/data-display/Persona.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { personaClassNames } from '../../lib/classNames';\nimport { warnOnce } from '../../lib/dev';\nimport type { PresenceStatus, Size, Slot } from '../../lib/types';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport { Avatar } from './Avatar';\nimport { PresenceBadge } from './PresenceBadge';\n\n/** The size of a Persona: the Avatar sizes, and `huge` (a 72px avatar). */\nexport type PersonaSize = Size | 'huge';\n\n/** Properties for the Persona component. */\nexport interface PersonaProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Display name of the person. It gives the avatar its initials and the first text line its text\n * (unless `primaryText` is given). A persona with neither `name` nor `primaryText` warns in\n * development.\n */\n name?: string;\n /**\n * The first text line (the name). A string, an element or an object of `<span>` attributes.\n * @default the `name`\n */\n primaryText?: Slot<'span'>;\n /** The second text line, such as a job title or email. */\n secondaryText?: Slot<'span'>;\n /** The third text line, such as a location. */\n tertiaryText?: Slot<'span'>;\n /** The fourth text line, such as a status message. */\n quaternaryText?: Slot<'span'>;\n /**\n * Where the text sits relative to the avatar, in reading order: after it, before it, or below it.\n * @default 'after'\n */\n textPosition?: 'after' | 'before' | 'below';\n /**\n * How the text lines align with each other.\n * @default 'start' ('center' when the text is below the avatar)\n */\n textAlignment?: 'start' | 'center';\n /**\n * Shows only the presence badge (from `status` or `badge`) in place of the avatar. The text\n * stays.\n * @default false\n */\n presenceOnly?: boolean;\n /** URL of the person's avatar image. */\n src?: string;\n /**\n * Size of the persona: its avatar and its text.\n * @default 'medium'\n */\n size?: PersonaSize;\n /** Presence status shown as a badge on the avatar. Ignored when a `badge` is given. */\n status?: PresenceStatus;\n /**\n * Slot for a custom avatar element, replacing the built-in one. The name is already visible\n * next to it, so make a custom avatar decorative (e.g. `<Avatar decorative … />`). A value that\n * renders nothing (`null`, `false`, `''`, `0`, `NaN`, or an array, `Set` or generator of only\n * such items) counts as not given.\n */\n avatar?: Slot<'span'>;\n /**\n * Slot for a custom badge element. Takes precedence over `status`. A value that renders nothing\n * (`null`, `false`, `''`, `0`, `NaN`, e.g. `badge={count && <CounterBadge count={count} />}`,\n * or an array, `Set` or generator of only such items) counts as not given.\n */\n badge?: Slot<'span'>;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nfunction derivePresenceSize(size: PersonaSize): Size {\n if (size === 'extra-small' || size === 'small') return 'small';\n return size === 'huge' ? 'large' : 'medium';\n}\n\n/** The size of the presence badge that stands alone (`presenceOnly`). */\nfunction derivePresenceOnlySize(size: PersonaSize): Size {\n if (size === 'extra-small' || size === 'small') return 'medium';\n if (size === 'medium' || size === 'large') return 'large';\n return 'extra-large';\n}\n\n/** Type steps of the first line and of the other lines, per size. Literal strings only. */\nconst textClasses: Readonly<Record<PersonaSize, { primary: string; other: string }>> = {\n 'extra-small': { primary: 'text-caption-1', other: 'text-caption-2' },\n small: { primary: 'text-body-1', other: 'text-caption-1' },\n medium: { primary: 'text-body-1', other: 'text-caption-1' },\n large: { primary: 'text-subtitle-2', other: 'text-body-1' },\n 'extra-large': { primary: 'text-subtitle-1', other: 'text-body-1' },\n huge: { primary: 'text-title-3', other: 'text-body-2' },\n};\n\n/** The layout of the root per text position. Logical: `flex-row-reverse` mirrors in RTL by itself. */\nconst positionClasses = {\n after: 'inline-flex items-center gap-3',\n before: 'inline-flex flex-row-reverse items-center gap-3',\n below: 'inline-flex flex-col items-center gap-2',\n} as const;\n\n/**\n * A person's avatar next to their name and up to three more text lines (job title, location,\n * status), with an optional presence badge. The text can sit after, before or below the avatar\n * (`textPosition`), `presenceOnly` swaps the avatar for the presence badge, and the text scales with\n * `size` up to `huge`.\n *\n * The built-in avatar is decorative (`<Avatar decorative>`): the visible name is announced once,\n * not a second time as the avatar's image name. The presence badge stays exposed as a named image.\n *\n * @example\n * <Persona name=\"Jane Doe\" secondaryText=\"Designer\" tertiaryText=\"Oslo\" status=\"available\" />\n */\nexport const Persona = ({\n name,\n primaryText,\n secondaryText,\n tertiaryText,\n quaternaryText,\n textPosition = 'after',\n textAlignment,\n presenceOnly = false,\n src,\n size = 'medium',\n status,\n avatar,\n badge,\n className,\n ref,\n ...props\n}: PersonaProps) => {\n const resolvedAlignment = textAlignment ?? (textPosition === 'below' ? 'center' : 'start');\n const hasPrimary = primaryText !== undefined ? slotRendersContent(primaryText) : !!name;\n React.useEffect(() => {\n if (!hasPrimary) {\n warnOnce(\n 'Persona:unnamed',\n 'Persona: it has neither a `name` nor a `primaryText`, so nothing names the person. Pass one of them.',\n );\n }\n }, [hasPrimary]);\n\n // A slot that renders nothing (`badge={count && …}` with count 0, an empty `.map()` result) is\n // not given (C-SLOTS), so the status badge and the built-in avatar apply.\n const badgeNode =\n badge && slotRendersContent(badge) ? (\n renderSlot(badge, 'span')\n ) : status ? (\n <PresenceBadge\n status={status}\n size={presenceOnly ? derivePresenceOnlySize(size) : derivePresenceSize(size)}\n />\n ) : null;\n\n const text = textClasses[size];\n const lines = [\n {\n key: 'primaryText',\n slot: primaryText ?? name,\n className: cn(personaClassNames.primaryText, text.primary, 'font-semibold'),\n },\n {\n key: 'secondaryText',\n slot: secondaryText,\n className: cn(personaClassNames.secondaryText, text.other, 'text-muted-foreground'),\n },\n {\n key: 'tertiaryText',\n slot: tertiaryText,\n className: cn(personaClassNames.tertiaryText, text.other, 'text-muted-foreground'),\n },\n {\n key: 'quaternaryText',\n slot: quaternaryText,\n className: cn(personaClassNames.quaternaryText, text.other, 'text-muted-foreground'),\n },\n ] as const;\n\n return (\n <div\n ref={ref}\n data-size={size}\n data-text-position={textPosition}\n data-text-alignment={resolvedAlignment}\n data-presence-only={presenceOnly ? '' : undefined}\n className={cn(personaClassNames.root, positionClasses[textPosition], className)}\n {...props}\n >\n {presenceOnly ? (\n badgeNode && (\n <span className={cn(personaClassNames.badge, 'inline-flex shrink-0')}>{badgeNode}</span>\n )\n ) : (\n <div className=\"relative inline-flex shrink-0\">\n {avatar && slotRendersContent(avatar) ? (\n renderSlot(avatar, 'span', personaClassNames.avatar)\n ) : (\n <Avatar\n src={src}\n name={name}\n size={size === 'huge' ? 72 : size}\n decorative\n className={personaClassNames.avatar}\n />\n )}\n {badgeNode && (\n <span className={cn(personaClassNames.badge, 'absolute bottom-0 end-0 inline-flex')}>\n {badgeNode}\n </span>\n )}\n </div>\n )}\n <div\n className={cn(\n 'flex flex-col',\n resolvedAlignment === 'center' ? 'items-center text-center' : 'items-start text-start',\n )}\n >\n {lines.map(\n ({ key, slot, className: lineClass }) =>\n slot !== undefined &&\n slotRendersContent(slot) &&\n renderSlot(slot, 'span', lineClass, { key }),\n )}\n </div>\n </div>\n );\n};\n\nPersona.displayName = 'Persona';\n"],"mappings":";;;;;;;;;;AAyEA,SAASC,EAAmB,GAAyB;CAEnD,OADIC,MAAS,iBAAiBA,MAAS,UAAgB,UAChDA,MAAS,SAAS,UAAU;AACrC;AAGA,SAASC,EAAuB,GAAyB;CAGvD,OAFID,MAAS,iBAAiBA,MAAS,UAAgB,WACnDA,MAAS,YAAYA,MAAS,UAAgB,UAC3C;AACT;AAGA,IAAME,IAAiF;CACrF,eAAe;EAAE,SAAS;EAAkB,OAAO;CAAiB;CACpE,OAAO;EAAE,SAAS;EAAe,OAAO;CAAiB;CACzD,QAAQ;EAAE,SAAS;EAAe,OAAO;CAAiB;CAC1D,OAAO;EAAE,SAAS;EAAmB,OAAO;CAAc;CAC1D,eAAe;EAAE,SAAS;EAAmB,OAAO;CAAc;CAClE,MAAM;EAAE,SAAS;EAAgB,OAAO;CAAc;AACxD,GAGMC,IAAkB;CACtB,OAAO;CACP,QAAQ;CACR,OAAO;AACT,GAcaC,KAAW,EACtB,SACA,gBACA,kBACA,iBACA,mBACA,kBAAe,SACf,kBACA,kBAAe,IACf,QACA,UAAO,UACP,WACA,WACA,UACA,cACA,QACA,GAAGC,QACe;CAClB,IAAMC,IAAoBC,MAAkBC,MAAiB,UAAU,WAAW,UAC5EC,IAAaC,MAAgB,KAAA,IAA8C,CAAC,CAACC,IAApCC,EAAmBF,CAAW;CAC7E,EAAM,gBAAgB;EACpB,AAAKD,KACHI,EACE,mBACA,sGACF;CAEJ,GAAG,CAACJ,CAAU,CAAC;CAIf,IAAMK,IACJC,KAASH,EAAmBG,CAAK,IAC/BC,EAAWD,GAAO,MAAM,IACtBE,IACF,kBAACC,GAAD;EACU;EACR,MAAMC,IAAelB,EAAuBD,CAAI,IAAID,EAAmBC,CAAI;CAC5E,CAAA,IACC,MAEAoB,IAAOlB,EAAYF,IACnBqB,IAAQ;EACZ;GACE,KAAK;GACL,MAAMX,KAAeC;GACrB,WAAWW,EAAGC,EAAkB,aAAaH,EAAK,SAAS,eAAe;EAC5E;EACA;GACE,KAAK;GACL,MAAMI;GACN,WAAWF,EAAGC,EAAkB,eAAeH,EAAK,OAAO,uBAAuB;EACpF;EACA;GACE,KAAK;GACL,MAAMK;GACN,WAAWH,EAAGC,EAAkB,cAAcH,EAAK,OAAO,uBAAuB;EACnF;EACA;GACE,KAAK;GACL,MAAMM;GACN,WAAWJ,EAAGC,EAAkB,gBAAgBH,EAAK,OAAO,uBAAuB;EACrF;CACF;CAEA,OACE,kBAAC,OAAD;EACO;EACL,aAAWpB;EACX,sBAAoBQ;EACpB,uBAAqBF;EACrB,sBAAoBa,IAAe,KAAK,KAAA;EACxC,WAAWG,EAAGC,EAAkB,MAAMpB,EAAgBK,IAAemB,CAAS;EAC9E,GAAItB;EAPN,UAAA,CASGc,IACCL,KACE,kBAAC,QAAD;GAAM,WAAWQ,EAAGC,EAAkB,OAAO,sBAAsB;GAAI,UAAAT;EAAgB,CAAA,IAGzF,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACGc,KAAUhB,EAAmBgB,CAAM,IAClCZ,EAAWY,GAAQ,QAAQL,EAAkB,MAAM,IAEnD,kBAACM,GAAD;IACO;IACC;IACN,MAAM7B,MAAS,SAAS,KAAKA;IAC7B,YAAA;IACA,WAAWuB,EAAkB;GAC9B,CAAA,GAEFT,KACC,kBAAC,QAAD;IAAM,WAAWQ,EAAGC,EAAkB,OAAO,qCAAqC;IAC/E,UAAAT;GACG,CAAA,CAEL;EAEP,CAAA,GAAA,kBAAC,OAAD;GACE,WAAWQ,EACT,iBACAhB,MAAsB,WAAW,6BAA6B,wBAChE;GAEC,UAAAe,EAAM,KACJ,EAAE,QAAK,SAAM,WAAWS,QACvBC,MAAS,KAAA,KACTnB,EAAmBmB,CAAI,KACvBf,EAAWe,GAAM,QAAQD,GAAW,EAAE,OAAI,CAAC,CAC/C;EACG,CAAA,CACF;;AAET;AAEA,EAAQ,cAAc"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/classNames.cjs"),r=require("../../lib/styles.cjs"),i=require("../../lib/icons.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("react/jsx-runtime");var s={available:{glyph:`check`,Icon:i.PresenceAvailableIcon,className:`bg-presence-available text-presence-glyph`},busy:{glyph:`solid`,Icon:i.PresenceBusyIcon,className:`bg-presence-busy text-presence-busy`},away:{glyph:`clock`,Icon:i.PresenceAwayIcon,className:`bg-presence-away text-presence-glyph`},offline:{glyph:`ring-x`,Icon:i.PresenceOfflineIcon,className:`bg-background text-presence-offline`},dnd:{glyph:`bar`,Icon:i.PresenceDndIcon,className:`bg-presence-busy text-presence-glyph`},oof:{glyph:`arrow`,Icon:i.PresenceOofIcon,className:`bg-presence-oof text-presence-glyph`}},c={available:`Available`,busy:`Busy`,away:`Away`,offline:`Offline`,dnd:`Do not disturb`,oof:`Out of office`},l={"extra-small":`size-2`,small:`size-2.5`,medium:`size-3`,large:`size-4`,"extra-large":`size-5`},u=({status:e,size:i=`medium`,className:a,ref:u,...d})=>{let{glyph:f,Icon:p,className:m}=s[e];return(0,o.jsx)(`span`,{ref:u,role:`img`,"aria-label":c[e],"data-glyph":f,...d,className:t.cn(n.presenceBadgeClassNames.root,`inline-flex shrink-0 items-center justify-center rounded-full ring-2 ring-background`,`forced-colors:border`,r.forcedColors.border,l[i],m,a),children:(0,o.jsx)(p,{size:`100%`,className:t.cn(n.presenceBadgeClassNames.icon,`size-full`,f===`arrow`&&`wave-rtl:-scale-x-100`)})})};u.displayName=`PresenceBadge`,exports.PresenceBadge=u;
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/classNames.cjs"),i=require("../../lib/styles.cjs"),a=require("../../lib/icons.cjs"),o=require("./Avatar.context.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l={available:{glyph:`check`,Icon:a.PresenceAvailableIcon,className:`bg-presence-available text-presence-glyph`},busy:{glyph:`solid`,Icon:a.PresenceBusyIcon,className:`bg-presence-busy text-presence-busy`},away:{glyph:`clock`,Icon:a.PresenceAwayIcon,className:`bg-presence-away text-presence-glyph`},offline:{glyph:`ring-x`,Icon:a.PresenceOfflineIcon,className:`bg-background text-presence-offline`},"do-not-disturb":{glyph:`bar`,Icon:a.PresenceDndIcon,className:`bg-presence-busy text-presence-glyph`},"out-of-office":{glyph:`arrow`,Icon:a.PresenceOofIcon,className:`bg-presence-oof text-presence-glyph`}},u={available:`Available`,busy:`Busy`,away:`Away`,offline:`Offline`,"do-not-disturb":`Do not disturb`,"out-of-office":`Out of office`},d={dnd:`do-not-disturb`,oof:`out-of-office`};function f(e){if(e===`dnd`||e===`oof`){let t=d[e];return n.warnDeprecated(`PresenceBadge`,`status '${e}'`,`status '${t}'`),t}return e}var p={"extra-small":`size-2`,small:`size-2.5`,medium:`size-3`,large:`size-4`,"extra-large":`size-5`},m=({status:e=`available`,size:n,className:a,ref:d,...m})=>{let h=s.useContext(o.AvatarBadgeSizeContext),g=n??h??`medium`,_=f(e),{glyph:v,Icon:y,className:b}=l[_];return(0,c.jsx)(`span`,{ref:d,role:`img`,"aria-label":u[_],"data-glyph":v,"data-status":_,...m,className:t.cn(r.presenceBadgeClassNames.root,`inline-flex shrink-0 items-center justify-center rounded-full ring-2 ring-background`,`forced-colors:border`,i.forcedColors.border,p[g],b,a),children:(0,c.jsx)(y,{size:`100%`,className:t.cn(r.presenceBadgeClassNames.icon,`size-full`,v===`arrow`&&`wave-rtl:-scale-x-100`)})})};m.displayName=`PresenceBadge`,exports.PresenceBadge=m;
2
2
  //# sourceMappingURL=PresenceBadge.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PresenceBadge.cjs","names":["PresenceAvailableIcon","PresenceBusyIcon","PresenceAwayIcon","PresenceOfflineIcon","PresenceDndIcon","PresenceOofIcon","cn","presenceBadgeClassNames","forcedColors","require_runtime","require_cn","require_classNames","require_styles","require_icons","react","react_jsx_runtime","statusStyles","statusLabels","sizeClasses","PresenceBadge","props","statusClassName","status","glyph","size","className","Icon"],"sources":["../../../src/components/data-display/PresenceBadge.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { presenceBadgeClassNames } from '../../lib/classNames';\nimport {\n PresenceAvailableIcon,\n PresenceAwayIcon,\n PresenceBusyIcon,\n PresenceDndIcon,\n PresenceOfflineIcon,\n PresenceOofIcon,\n} from '../../lib/icons';\nimport type { IconComponent } from '../../lib/icons';\nimport { forcedColors } from '../../lib/styles';\nimport type { PresenceStatus, Size } from '../../lib/types';\n\n/** Properties for the PresenceBadge component. */\nexport interface PresenceBadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Presence status to display. */\n status: PresenceStatus;\n /** Size of the presence indicator.\n * @default 'medium'\n */\n size?: Size;\n /** Ref to the root `<span>`. */\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n/** The shape drawn for a status, exposed as `data-glyph` (styling hook and test contract). */\ntype PresenceGlyph = 'check' | 'solid' | 'clock' | 'ring-x' | 'bar' | 'arrow';\n\n/**\n * Per status: the glyph name, its shared icon (src/lib/icons.tsx, drawn in a 16×16 box that the\n * badge circle fills) and the colors. Busy is a full disc in `currentColor`: forced-colors mode\n * replaces the background with Canvas but forces `color` to CanvasText, so busy stays a solid dot\n * instead of an empty ring.\n */\nconst statusStyles: Record<\n PresenceStatus,\n { glyph: PresenceGlyph; Icon: IconComponent; className: string }\n> = {\n available: {\n glyph: 'check',\n Icon: PresenceAvailableIcon,\n className: 'bg-presence-available text-presence-glyph',\n },\n busy: {\n glyph: 'solid',\n Icon: PresenceBusyIcon,\n className: 'bg-presence-busy text-presence-busy',\n },\n away: {\n glyph: 'clock',\n Icon: PresenceAwayIcon,\n className: 'bg-presence-away text-presence-glyph',\n },\n offline: {\n glyph: 'ring-x',\n Icon: PresenceOfflineIcon,\n className: 'bg-background text-presence-offline',\n },\n dnd: { glyph: 'bar', Icon: PresenceDndIcon, className: 'bg-presence-busy text-presence-glyph' },\n oof: { glyph: 'arrow', Icon: PresenceOofIcon, className: 'bg-presence-oof text-presence-glyph' },\n};\n\nconst statusLabels: Record<PresenceStatus, string> = {\n available: 'Available',\n busy: 'Busy',\n away: 'Away',\n offline: 'Offline',\n dnd: 'Do not disturb',\n oof: 'Out of office',\n};\n\nconst sizeClasses: Record<Size, string> = {\n 'extra-small': 'size-2', // 8px\n small: 'size-2.5', // 10px\n medium: 'size-3', // 12px\n large: 'size-4', // 16px\n 'extra-large': 'size-5', // 20px\n};\n\n/**\n * A person's availability as a small badge, usually placed on an `Avatar` (`badge` prop).\n *\n * Every status has its own shape, so it is not conveyed by color alone: available (check),\n * busy (solid), away (clock), offline (hollow ring with an X), do not disturb (bar), out of office\n * (arrow, mirrored in right-to-left layouts). A background-colored ring separates it from the\n * avatar. It is a named image (`role=\"img\"`, `aria-label` = the status name; pass `aria-label` to\n * localise or extend it) and never a live region.\n *\n * @example\n * <PresenceBadge status=\"busy\" />\n */\nexport const PresenceBadge = ({\n status,\n size = 'medium',\n className,\n ref,\n ...props\n}: PresenceBadgeProps) => {\n const { glyph, Icon, className: statusClassName } = statusStyles[status];\n\n return (\n <span\n ref={ref}\n role=\"img\"\n aria-label={statusLabels[status]}\n data-glyph={glyph}\n {...props}\n className={cn(\n presenceBadgeClassNames.root,\n 'inline-flex shrink-0 items-center justify-center rounded-full ring-2 ring-background',\n 'forced-colors:border',\n forcedColors.border,\n sizeClasses[size],\n statusClassName,\n className,\n )}\n >\n <Icon\n size=\"100%\"\n className={cn(\n presenceBadgeClassNames.icon,\n 'size-full',\n glyph === 'arrow' && 'wave-rtl:-scale-x-100',\n )}\n />\n </span>\n );\n};\n\nPresenceBadge.displayName = 'PresenceBadge';\n"],"mappings":"uRAoCA,IAAMgB,EAGF,CACF,UAAW,CACT,MAAO,QACP,KAAMhB,EAAAA,sBACN,UAAW,2CACb,EACA,KAAM,CACJ,MAAO,QACP,KAAMC,EAAAA,iBACN,UAAW,qCACb,EACA,KAAM,CACJ,MAAO,QACP,KAAMC,EAAAA,iBACN,UAAW,sCACb,EACA,QAAS,CACP,MAAO,SACP,KAAMC,EAAAA,oBACN,UAAW,qCACb,EACA,IAAK,CAAE,MAAO,MAAO,KAAMC,EAAAA,gBAAiB,UAAW,sCAAuC,EAC9F,IAAK,CAAE,MAAO,QAAS,KAAMC,EAAAA,gBAAiB,UAAW,qCAAsC,CACjG,EAEMY,EAA+C,CACnD,UAAW,YACX,KAAM,OACN,KAAM,OACN,QAAS,UACT,IAAK,iBACL,IAAK,eACP,EAEMC,EAAoC,CACxC,cAAe,SACf,MAAO,WACP,OAAQ,SACR,MAAO,SACP,cAAe,QACjB,EAcaC,GAAiB,CAC5B,SACA,OAAO,SACP,YACA,MACA,GAAGC,KACqB,CACxB,GAAM,CAAE,QAAO,OAAM,UAAWC,GAAoBL,EAAaM,GAEjE,OACE,EAAAP,EAAA,IAAA,CAAC,OAAD,CACO,MACL,KAAK,MACL,aAAYE,EAAaK,GACzB,aAAYC,EACZ,GAAIH,EACJ,UAAWd,EAAAA,GACTC,EAAAA,wBAAwB,KACxB,uFACA,uBACAC,EAAAA,aAAa,OACbU,EAAYM,GACZH,EACAI,CACF,EAEA,UAAA,EAAAV,EAAA,IAAA,CAACW,EAAD,CACE,KAAK,OACL,UAAWpB,EAAAA,GACTC,EAAAA,wBAAwB,KACxB,YACAgB,IAAU,SAAW,uBACvB,CACD,CAAA,CACG,CAAA,CAEV,EAEA,EAAc,YAAc"}
1
+ {"version":3,"file":"PresenceBadge.cjs","names":["PresenceAvailableIcon","PresenceBusyIcon","PresenceAwayIcon","PresenceOfflineIcon","PresenceDndIcon","PresenceOofIcon","React","AvatarBadgeSizeContext","cn","presenceBadgeClassNames","forcedColors","require_runtime","require_cn","require_dev","require_classNames","require_styles","require_icons","require_Avatar_context","react","react_jsx_runtime","statusStyles","statusLabels","DEPRECATED_STATUS_NAMES","normalizePresenceStatus","status","current","sizeClasses","PresenceBadge","statusProp","sizeProp","props","avatarBadgeSize","size","statusClassName","glyph","className","Icon"],"sources":["../../../src/components/data-display/PresenceBadge.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { presenceBadgeClassNames } from '../../lib/classNames';\nimport {\n PresenceAvailableIcon,\n PresenceAwayIcon,\n PresenceBusyIcon,\n PresenceDndIcon,\n PresenceOfflineIcon,\n PresenceOofIcon,\n} from '../../lib/icons';\nimport type { IconComponent } from '../../lib/icons';\nimport { warnDeprecated } from '../../lib/dev';\nimport { AvatarBadgeSizeContext } from './Avatar.context';\nimport { forcedColors } from '../../lib/styles';\nimport type { DeprecatedPresenceStatus, PresenceStatus, Size } from '../../lib/types';\n\n/** Properties for the PresenceBadge component. */\nexport interface PresenceBadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n /**\n * Presence status to display. `'dnd'` and `'oof'` are deprecated aliases of `'do-not-disturb'`\n * and `'out-of-office'`: they render the same and warn once in development (removed in 1.0).\n * @default 'available'\n */\n status?: PresenceStatus;\n /**\n * Size of the presence indicator. In the `badge` slot of an Avatar it is sized from the avatar.\n * @default 'medium'\n */\n size?: Size;\n /** Ref to the root `<span>`. */\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n/** The shape drawn for a status, exposed as `data-glyph` (styling hook and test contract). */\ntype PresenceGlyph = 'check' | 'solid' | 'clock' | 'ring-x' | 'bar' | 'arrow';\n\n/**\n * Per status: the glyph name, its shared icon (src/lib/icons.tsx, drawn in a 16×16 box that the\n * badge circle fills) and the colors. Busy is a full disc in `currentColor`: forced-colors mode\n * replaces the background with Canvas but forces `color` to CanvasText, so busy stays a solid dot\n * instead of an empty ring.\n */\nconst statusStyles: Record<\n Exclude<PresenceStatus, DeprecatedPresenceStatus>,\n { glyph: PresenceGlyph; Icon: IconComponent; className: string }\n> = {\n available: {\n glyph: 'check',\n Icon: PresenceAvailableIcon,\n className: 'bg-presence-available text-presence-glyph',\n },\n busy: {\n glyph: 'solid',\n Icon: PresenceBusyIcon,\n className: 'bg-presence-busy text-presence-busy',\n },\n away: {\n glyph: 'clock',\n Icon: PresenceAwayIcon,\n className: 'bg-presence-away text-presence-glyph',\n },\n offline: {\n glyph: 'ring-x',\n Icon: PresenceOfflineIcon,\n className: 'bg-background text-presence-offline',\n },\n 'do-not-disturb': {\n glyph: 'bar',\n Icon: PresenceDndIcon,\n className: 'bg-presence-busy text-presence-glyph',\n },\n 'out-of-office': {\n glyph: 'arrow',\n Icon: PresenceOofIcon,\n className: 'bg-presence-oof text-presence-glyph',\n },\n};\n\nconst statusLabels: Record<Exclude<PresenceStatus, DeprecatedPresenceStatus>, string> = {\n available: 'Available',\n busy: 'Busy',\n away: 'Away',\n offline: 'Offline',\n 'do-not-disturb': 'Do not disturb',\n 'out-of-office': 'Out of office',\n};\n\nconst DEPRECATED_STATUS_NAMES = {\n dnd: 'do-not-disturb',\n oof: 'out-of-office',\n} as const;\n\n/** Maps the deprecated spellings to their Fluent names; warns once for an alias. */\nfunction normalizePresenceStatus(\n status: PresenceStatus,\n): Exclude<PresenceStatus, DeprecatedPresenceStatus> {\n if (status === 'dnd' || status === 'oof') {\n const current = DEPRECATED_STATUS_NAMES[status];\n warnDeprecated('PresenceBadge', `status '${status}'`, `status '${current}'`);\n return current;\n }\n return status;\n}\n\nconst sizeClasses: Record<Size, string> = {\n 'extra-small': 'size-2', // 8px\n small: 'size-2.5', // 10px\n medium: 'size-3', // 12px\n large: 'size-4', // 16px\n 'extra-large': 'size-5', // 20px\n};\n\n/**\n * A person's availability as a small badge, usually placed on an `Avatar` (`badge` prop).\n *\n * Every status has its own shape, so it is not conveyed by color alone: available (check),\n * busy (solid), away (clock), offline (hollow ring with an X), do not disturb (bar), out of office\n * (arrow, mirrored in right-to-left layouts). A background-colored ring separates it from the\n * avatar. It is a named image (`role=\"img\"`, `aria-label` = the status name; pass `aria-label` to\n * localise or extend it) and never a live region.\n *\n * @example\n * <PresenceBadge status=\"busy\" />\n * <PresenceBadge status=\"do-not-disturb\" />\n */\nexport const PresenceBadge = ({\n status: statusProp = 'available',\n size: sizeProp,\n className,\n ref,\n ...props\n}: PresenceBadgeProps) => {\n const avatarBadgeSize = React.useContext(AvatarBadgeSizeContext);\n const size = sizeProp ?? avatarBadgeSize ?? 'medium';\n const status = normalizePresenceStatus(statusProp);\n const { glyph, Icon, className: statusClassName } = statusStyles[status];\n\n return (\n <span\n ref={ref}\n role=\"img\"\n aria-label={statusLabels[status]}\n data-glyph={glyph}\n data-status={status}\n {...props}\n className={cn(\n presenceBadgeClassNames.root,\n 'inline-flex shrink-0 items-center justify-center rounded-full ring-2 ring-background',\n 'forced-colors:border',\n forcedColors.border,\n sizeClasses[size],\n statusClassName,\n className,\n )}\n >\n <Icon\n size=\"100%\"\n className={cn(\n presenceBadgeClassNames.icon,\n 'size-full',\n glyph === 'arrow' && 'wave-rtl:-scale-x-100',\n )}\n />\n </span>\n );\n};\n\nPresenceBadge.displayName = 'PresenceBadge';\n"],"mappings":"wVA2CA,IAAMoB,EAGF,CACF,UAAW,CACT,MAAO,QACP,KAAMpB,EAAAA,sBACN,UAAW,2CACb,EACA,KAAM,CACJ,MAAO,QACP,KAAMC,EAAAA,iBACN,UAAW,qCACb,EACA,KAAM,CACJ,MAAO,QACP,KAAMC,EAAAA,iBACN,UAAW,sCACb,EACA,QAAS,CACP,MAAO,SACP,KAAMC,EAAAA,oBACN,UAAW,qCACb,EACA,iBAAkB,CAChB,MAAO,MACP,KAAMC,EAAAA,gBACN,UAAW,sCACb,EACA,gBAAiB,CACf,MAAO,QACP,KAAMC,EAAAA,gBACN,UAAW,qCACb,CACF,EAEMgB,EAAkF,CACtF,UAAW,YACX,KAAM,OACN,KAAM,OACN,QAAS,UACT,iBAAkB,iBAClB,gBAAiB,eACnB,EAEMC,EAA0B,CAC9B,IAAK,iBACL,IAAK,eACP,EAGA,SAASC,EACP,EACmD,CACnD,GAAIC,IAAW,OAASA,IAAW,MAAO,CACxC,IAAMC,EAAUH,EAAwBE,GAExC,OADAX,EAAA,eAAe,gBAAiB,WAAWW,EAAO,GAAI,WAAWC,EAAQ,EAAE,EACpEA,CACT,CACA,OAAOD,CACT,CAEA,IAAME,EAAoC,CACxC,cAAe,SACf,MAAO,WACP,OAAQ,SACR,MAAO,SACP,cAAe,QACjB,EAeaC,GAAiB,CAC5B,OAAQC,EAAa,YACrB,KAAMC,EACN,YACA,MACA,GAAGC,KACqB,CACxB,IAAMC,EAAkBzB,EAAM,WAAWC,EAAAA,sBAAsB,EACzDyB,EAAOH,GAAYE,GAAmB,SACtCP,EAASD,EAAwBK,CAAU,EAC3C,CAAE,QAAO,OAAM,UAAWK,GAAoBb,EAAaI,GAEjE,OACE,EAAAL,EAAA,IAAA,CAAC,OAAD,CACO,MACL,KAAK,MACL,aAAYE,EAAaG,GACzB,aAAYU,EACZ,cAAaV,EACb,GAAIM,EACJ,UAAWtB,EAAAA,GACTC,EAAAA,wBAAwB,KACxB,uFACA,uBACAC,EAAAA,aAAa,OACbgB,EAAYM,GACZC,EACAE,CACF,EAEA,UAAA,EAAAhB,EAAA,IAAA,CAACiB,EAAD,CACE,KAAK,OACL,UAAW5B,EAAAA,GACTC,EAAAA,wBAAwB,KACxB,YACAyB,IAAU,SAAW,uBACvB,CACD,CAAA,CACG,CAAA,CAEV,EAEA,EAAc,YAAc"}
@@ -1,72 +1,86 @@
1
1
  "use client";
2
2
  import { cn as e } from "../../lib/cn.mjs";
3
- import { presenceBadgeClassNames as t } from "../../lib/classNames.mjs";
4
- import { forcedColors as n } from "../../lib/styles.mjs";
5
- import { PresenceAvailableIcon as r, PresenceAwayIcon as i, PresenceBusyIcon as a, PresenceDndIcon as o, PresenceOfflineIcon as s, PresenceOofIcon as c } from "../../lib/icons.mjs";
6
- import "react";
7
- import { jsx as l } from "react/jsx-runtime";
3
+ import { warnDeprecated as t } from "../../lib/dev.mjs";
4
+ import { presenceBadgeClassNames as n } from "../../lib/classNames.mjs";
5
+ import { forcedColors as r } from "../../lib/styles.mjs";
6
+ import { PresenceAvailableIcon as i, PresenceAwayIcon as a, PresenceBusyIcon as o, PresenceDndIcon as s, PresenceOfflineIcon as c, PresenceOofIcon as l } from "../../lib/icons.mjs";
7
+ import { AvatarBadgeSizeContext as u } from "./Avatar.context.mjs";
8
+ import * as d from "react";
9
+ import { jsx as f } from "react/jsx-runtime";
8
10
  //#region src/components/data-display/PresenceBadge.tsx
9
- var u = {
11
+ var p = {
10
12
  available: {
11
13
  glyph: "check",
12
- Icon: r,
14
+ Icon: i,
13
15
  className: "bg-presence-available text-presence-glyph"
14
16
  },
15
17
  busy: {
16
18
  glyph: "solid",
17
- Icon: a,
19
+ Icon: o,
18
20
  className: "bg-presence-busy text-presence-busy"
19
21
  },
20
22
  away: {
21
23
  glyph: "clock",
22
- Icon: i,
24
+ Icon: a,
23
25
  className: "bg-presence-away text-presence-glyph"
24
26
  },
25
27
  offline: {
26
28
  glyph: "ring-x",
27
- Icon: s,
29
+ Icon: c,
28
30
  className: "bg-background text-presence-offline"
29
31
  },
30
- dnd: {
32
+ "do-not-disturb": {
31
33
  glyph: "bar",
32
- Icon: o,
34
+ Icon: s,
33
35
  className: "bg-presence-busy text-presence-glyph"
34
36
  },
35
- oof: {
37
+ "out-of-office": {
36
38
  glyph: "arrow",
37
- Icon: c,
39
+ Icon: l,
38
40
  className: "bg-presence-oof text-presence-glyph"
39
41
  }
40
- }, d = {
42
+ }, m = {
41
43
  available: "Available",
42
44
  busy: "Busy",
43
45
  away: "Away",
44
46
  offline: "Offline",
45
- dnd: "Do not disturb",
46
- oof: "Out of office"
47
- }, f = {
47
+ "do-not-disturb": "Do not disturb",
48
+ "out-of-office": "Out of office"
49
+ }, h = {
50
+ dnd: "do-not-disturb",
51
+ oof: "out-of-office"
52
+ };
53
+ function g(e) {
54
+ if (e === "dnd" || e === "oof") {
55
+ let n = h[e];
56
+ return t("PresenceBadge", `status '${e}'`, `status '${n}'`), n;
57
+ }
58
+ return e;
59
+ }
60
+ var _ = {
48
61
  "extra-small": "size-2",
49
62
  small: "size-2.5",
50
63
  medium: "size-3",
51
64
  large: "size-4",
52
65
  "extra-large": "size-5"
53
- }, p = ({ status: r, size: i = "medium", className: a, ref: o, ...s }) => {
54
- let { glyph: c, Icon: p, className: m } = u[r];
55
- return /* @__PURE__ */ l("span", {
66
+ }, v = ({ status: t = "available", size: i, className: a, ref: o, ...s }) => {
67
+ let c = d.useContext(u), l = i ?? c ?? "medium", h = g(t), { glyph: v, Icon: y, className: b } = p[h];
68
+ return /* @__PURE__ */ f("span", {
56
69
  ref: o,
57
70
  role: "img",
58
- "aria-label": d[r],
59
- "data-glyph": c,
71
+ "aria-label": m[h],
72
+ "data-glyph": v,
73
+ "data-status": h,
60
74
  ...s,
61
- className: e(t.root, "inline-flex shrink-0 items-center justify-center rounded-full ring-2 ring-background", "forced-colors:border", n.border, f[i], m, a),
62
- children: /* @__PURE__ */ l(p, {
75
+ className: e(n.root, "inline-flex shrink-0 items-center justify-center rounded-full ring-2 ring-background", "forced-colors:border", r.border, _[l], b, a),
76
+ children: /* @__PURE__ */ f(y, {
63
77
  size: "100%",
64
- className: e(t.icon, "size-full", c === "arrow" && "wave-rtl:-scale-x-100")
78
+ className: e(n.icon, "size-full", v === "arrow" && "wave-rtl:-scale-x-100")
65
79
  })
66
80
  });
67
81
  };
68
- p.displayName = "PresenceBadge";
82
+ v.displayName = "PresenceBadge";
69
83
  //#endregion
70
- export { p as PresenceBadge };
84
+ export { v as PresenceBadge };
71
85
 
72
86
  //# sourceMappingURL=PresenceBadge.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PresenceBadge.mjs","names":["statusStyles","PresenceAvailableIcon","PresenceBusyIcon","PresenceAwayIcon","PresenceOfflineIcon","PresenceDndIcon","PresenceOofIcon","statusLabels","sizeClasses","PresenceBadge","props","statusClassName","status","glyph","cn","presenceBadgeClassNames","forcedColors","size","className","Icon"],"sources":["../../../src/components/data-display/PresenceBadge.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { presenceBadgeClassNames } from '../../lib/classNames';\nimport {\n PresenceAvailableIcon,\n PresenceAwayIcon,\n PresenceBusyIcon,\n PresenceDndIcon,\n PresenceOfflineIcon,\n PresenceOofIcon,\n} from '../../lib/icons';\nimport type { IconComponent } from '../../lib/icons';\nimport { forcedColors } from '../../lib/styles';\nimport type { PresenceStatus, Size } from '../../lib/types';\n\n/** Properties for the PresenceBadge component. */\nexport interface PresenceBadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Presence status to display. */\n status: PresenceStatus;\n /** Size of the presence indicator.\n * @default 'medium'\n */\n size?: Size;\n /** Ref to the root `<span>`. */\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n/** The shape drawn for a status, exposed as `data-glyph` (styling hook and test contract). */\ntype PresenceGlyph = 'check' | 'solid' | 'clock' | 'ring-x' | 'bar' | 'arrow';\n\n/**\n * Per status: the glyph name, its shared icon (src/lib/icons.tsx, drawn in a 16×16 box that the\n * badge circle fills) and the colors. Busy is a full disc in `currentColor`: forced-colors mode\n * replaces the background with Canvas but forces `color` to CanvasText, so busy stays a solid dot\n * instead of an empty ring.\n */\nconst statusStyles: Record<\n PresenceStatus,\n { glyph: PresenceGlyph; Icon: IconComponent; className: string }\n> = {\n available: {\n glyph: 'check',\n Icon: PresenceAvailableIcon,\n className: 'bg-presence-available text-presence-glyph',\n },\n busy: {\n glyph: 'solid',\n Icon: PresenceBusyIcon,\n className: 'bg-presence-busy text-presence-busy',\n },\n away: {\n glyph: 'clock',\n Icon: PresenceAwayIcon,\n className: 'bg-presence-away text-presence-glyph',\n },\n offline: {\n glyph: 'ring-x',\n Icon: PresenceOfflineIcon,\n className: 'bg-background text-presence-offline',\n },\n dnd: { glyph: 'bar', Icon: PresenceDndIcon, className: 'bg-presence-busy text-presence-glyph' },\n oof: { glyph: 'arrow', Icon: PresenceOofIcon, className: 'bg-presence-oof text-presence-glyph' },\n};\n\nconst statusLabels: Record<PresenceStatus, string> = {\n available: 'Available',\n busy: 'Busy',\n away: 'Away',\n offline: 'Offline',\n dnd: 'Do not disturb',\n oof: 'Out of office',\n};\n\nconst sizeClasses: Record<Size, string> = {\n 'extra-small': 'size-2', // 8px\n small: 'size-2.5', // 10px\n medium: 'size-3', // 12px\n large: 'size-4', // 16px\n 'extra-large': 'size-5', // 20px\n};\n\n/**\n * A person's availability as a small badge, usually placed on an `Avatar` (`badge` prop).\n *\n * Every status has its own shape, so it is not conveyed by color alone: available (check),\n * busy (solid), away (clock), offline (hollow ring with an X), do not disturb (bar), out of office\n * (arrow, mirrored in right-to-left layouts). A background-colored ring separates it from the\n * avatar. It is a named image (`role=\"img\"`, `aria-label` = the status name; pass `aria-label` to\n * localise or extend it) and never a live region.\n *\n * @example\n * <PresenceBadge status=\"busy\" />\n */\nexport const PresenceBadge = ({\n status,\n size = 'medium',\n className,\n ref,\n ...props\n}: PresenceBadgeProps) => {\n const { glyph, Icon, className: statusClassName } = statusStyles[status];\n\n return (\n <span\n ref={ref}\n role=\"img\"\n aria-label={statusLabels[status]}\n data-glyph={glyph}\n {...props}\n className={cn(\n presenceBadgeClassNames.root,\n 'inline-flex shrink-0 items-center justify-center rounded-full ring-2 ring-background',\n 'forced-colors:border',\n forcedColors.border,\n sizeClasses[size],\n statusClassName,\n className,\n )}\n >\n <Icon\n size=\"100%\"\n className={cn(\n presenceBadgeClassNames.icon,\n 'size-full',\n glyph === 'arrow' && 'wave-rtl:-scale-x-100',\n )}\n />\n </span>\n );\n};\n\nPresenceBadge.displayName = 'PresenceBadge';\n"],"mappings":";;;;;;;;AAoCA,IAAMA,IAGF;CACF,WAAW;EACT,OAAO;EACP,MAAMC;EACN,WAAW;CACb;CACA,MAAM;EACJ,OAAO;EACP,MAAMC;EACN,WAAW;CACb;CACA,MAAM;EACJ,OAAO;EACP,MAAMC;EACN,WAAW;CACb;CACA,SAAS;EACP,OAAO;EACP,MAAMC;EACN,WAAW;CACb;CACA,KAAK;EAAE,OAAO;EAAO,MAAMC;EAAiB,WAAW;CAAuC;CAC9F,KAAK;EAAE,OAAO;EAAS,MAAMC;EAAiB,WAAW;CAAsC;AACjG,GAEMC,IAA+C;CACnD,WAAW;CACX,MAAM;CACN,MAAM;CACN,SAAS;CACT,KAAK;CACL,KAAK;AACP,GAEMC,IAAoC;CACxC,eAAe;CACf,OAAO;CACP,QAAQ;CACR,OAAO;CACP,eAAe;AACjB,GAcaC,KAAiB,EAC5B,WACA,UAAO,UACP,cACA,QACA,GAAGC,QACqB;CACxB,IAAM,EAAE,UAAO,SAAM,WAAWC,MAAoBX,EAAaY;CAEjE,OACE,kBAAC,QAAD;EACO;EACL,MAAK;EACL,cAAYL,EAAaK;EACzB,cAAYC;EACZ,GAAIH;EACJ,WAAWI,EACTC,EAAwB,MACxB,wFACA,wBACAC,EAAa,QACbR,EAAYS,IACZN,GACAO,CACF;EAEA,UAAA,kBAACC,GAAD;GACE,MAAK;GACL,WAAWL,EACTC,EAAwB,MACxB,aACAF,MAAU,WAAW,uBACvB;EACD,CAAA;CACG,CAAA;AAEV;AAEA,EAAc,cAAc"}
1
+ {"version":3,"file":"PresenceBadge.mjs","names":["React","statusStyles","PresenceAvailableIcon","PresenceBusyIcon","PresenceAwayIcon","PresenceOfflineIcon","PresenceDndIcon","PresenceOofIcon","statusLabels","DEPRECATED_STATUS_NAMES","normalizePresenceStatus","status","current","warnDeprecated","sizeClasses","PresenceBadge","statusProp","sizeProp","props","avatarBadgeSize","AvatarBadgeSizeContext","size","statusClassName","glyph","cn","presenceBadgeClassNames","forcedColors","className","Icon"],"sources":["../../../src/components/data-display/PresenceBadge.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { presenceBadgeClassNames } from '../../lib/classNames';\nimport {\n PresenceAvailableIcon,\n PresenceAwayIcon,\n PresenceBusyIcon,\n PresenceDndIcon,\n PresenceOfflineIcon,\n PresenceOofIcon,\n} from '../../lib/icons';\nimport type { IconComponent } from '../../lib/icons';\nimport { warnDeprecated } from '../../lib/dev';\nimport { AvatarBadgeSizeContext } from './Avatar.context';\nimport { forcedColors } from '../../lib/styles';\nimport type { DeprecatedPresenceStatus, PresenceStatus, Size } from '../../lib/types';\n\n/** Properties for the PresenceBadge component. */\nexport interface PresenceBadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n /**\n * Presence status to display. `'dnd'` and `'oof'` are deprecated aliases of `'do-not-disturb'`\n * and `'out-of-office'`: they render the same and warn once in development (removed in 1.0).\n * @default 'available'\n */\n status?: PresenceStatus;\n /**\n * Size of the presence indicator. In the `badge` slot of an Avatar it is sized from the avatar.\n * @default 'medium'\n */\n size?: Size;\n /** Ref to the root `<span>`. */\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n/** The shape drawn for a status, exposed as `data-glyph` (styling hook and test contract). */\ntype PresenceGlyph = 'check' | 'solid' | 'clock' | 'ring-x' | 'bar' | 'arrow';\n\n/**\n * Per status: the glyph name, its shared icon (src/lib/icons.tsx, drawn in a 16×16 box that the\n * badge circle fills) and the colors. Busy is a full disc in `currentColor`: forced-colors mode\n * replaces the background with Canvas but forces `color` to CanvasText, so busy stays a solid dot\n * instead of an empty ring.\n */\nconst statusStyles: Record<\n Exclude<PresenceStatus, DeprecatedPresenceStatus>,\n { glyph: PresenceGlyph; Icon: IconComponent; className: string }\n> = {\n available: {\n glyph: 'check',\n Icon: PresenceAvailableIcon,\n className: 'bg-presence-available text-presence-glyph',\n },\n busy: {\n glyph: 'solid',\n Icon: PresenceBusyIcon,\n className: 'bg-presence-busy text-presence-busy',\n },\n away: {\n glyph: 'clock',\n Icon: PresenceAwayIcon,\n className: 'bg-presence-away text-presence-glyph',\n },\n offline: {\n glyph: 'ring-x',\n Icon: PresenceOfflineIcon,\n className: 'bg-background text-presence-offline',\n },\n 'do-not-disturb': {\n glyph: 'bar',\n Icon: PresenceDndIcon,\n className: 'bg-presence-busy text-presence-glyph',\n },\n 'out-of-office': {\n glyph: 'arrow',\n Icon: PresenceOofIcon,\n className: 'bg-presence-oof text-presence-glyph',\n },\n};\n\nconst statusLabels: Record<Exclude<PresenceStatus, DeprecatedPresenceStatus>, string> = {\n available: 'Available',\n busy: 'Busy',\n away: 'Away',\n offline: 'Offline',\n 'do-not-disturb': 'Do not disturb',\n 'out-of-office': 'Out of office',\n};\n\nconst DEPRECATED_STATUS_NAMES = {\n dnd: 'do-not-disturb',\n oof: 'out-of-office',\n} as const;\n\n/** Maps the deprecated spellings to their Fluent names; warns once for an alias. */\nfunction normalizePresenceStatus(\n status: PresenceStatus,\n): Exclude<PresenceStatus, DeprecatedPresenceStatus> {\n if (status === 'dnd' || status === 'oof') {\n const current = DEPRECATED_STATUS_NAMES[status];\n warnDeprecated('PresenceBadge', `status '${status}'`, `status '${current}'`);\n return current;\n }\n return status;\n}\n\nconst sizeClasses: Record<Size, string> = {\n 'extra-small': 'size-2', // 8px\n small: 'size-2.5', // 10px\n medium: 'size-3', // 12px\n large: 'size-4', // 16px\n 'extra-large': 'size-5', // 20px\n};\n\n/**\n * A person's availability as a small badge, usually placed on an `Avatar` (`badge` prop).\n *\n * Every status has its own shape, so it is not conveyed by color alone: available (check),\n * busy (solid), away (clock), offline (hollow ring with an X), do not disturb (bar), out of office\n * (arrow, mirrored in right-to-left layouts). A background-colored ring separates it from the\n * avatar. It is a named image (`role=\"img\"`, `aria-label` = the status name; pass `aria-label` to\n * localise or extend it) and never a live region.\n *\n * @example\n * <PresenceBadge status=\"busy\" />\n * <PresenceBadge status=\"do-not-disturb\" />\n */\nexport const PresenceBadge = ({\n status: statusProp = 'available',\n size: sizeProp,\n className,\n ref,\n ...props\n}: PresenceBadgeProps) => {\n const avatarBadgeSize = React.useContext(AvatarBadgeSizeContext);\n const size = sizeProp ?? avatarBadgeSize ?? 'medium';\n const status = normalizePresenceStatus(statusProp);\n const { glyph, Icon, className: statusClassName } = statusStyles[status];\n\n return (\n <span\n ref={ref}\n role=\"img\"\n aria-label={statusLabels[status]}\n data-glyph={glyph}\n data-status={status}\n {...props}\n className={cn(\n presenceBadgeClassNames.root,\n 'inline-flex shrink-0 items-center justify-center rounded-full ring-2 ring-background',\n 'forced-colors:border',\n forcedColors.border,\n sizeClasses[size],\n statusClassName,\n className,\n )}\n >\n <Icon\n size=\"100%\"\n className={cn(\n presenceBadgeClassNames.icon,\n 'size-full',\n glyph === 'arrow' && 'wave-rtl:-scale-x-100',\n )}\n />\n </span>\n );\n};\n\nPresenceBadge.displayName = 'PresenceBadge';\n"],"mappings":";;;;;;;;;;AA2CA,IAAMC,IAGF;CACF,WAAW;EACT,OAAO;EACP,MAAMC;EACN,WAAW;CACb;CACA,MAAM;EACJ,OAAO;EACP,MAAMC;EACN,WAAW;CACb;CACA,MAAM;EACJ,OAAO;EACP,MAAMC;EACN,WAAW;CACb;CACA,SAAS;EACP,OAAO;EACP,MAAMC;EACN,WAAW;CACb;CACA,kBAAkB;EAChB,OAAO;EACP,MAAMC;EACN,WAAW;CACb;CACA,iBAAiB;EACf,OAAO;EACP,MAAMC;EACN,WAAW;CACb;AACF,GAEMC,IAAkF;CACtF,WAAW;CACX,MAAM;CACN,MAAM;CACN,SAAS;CACT,kBAAkB;CAClB,iBAAiB;AACnB,GAEMC,IAA0B;CAC9B,KAAK;CACL,KAAK;AACP;AAGA,SAASC,EACP,GACmD;CACnD,IAAIC,MAAW,SAASA,MAAW,OAAO;EACxC,IAAMC,IAAUH,EAAwBE;EAExC,OADAE,EAAe,iBAAiB,WAAWF,EAAO,IAAI,WAAWC,EAAQ,EAAE,GACpEA;CACT;CACA,OAAOD;AACT;AAEA,IAAMG,IAAoC;CACxC,eAAe;CACf,OAAO;CACP,QAAQ;CACR,OAAO;CACP,eAAe;AACjB,GAeaC,KAAiB,EAC5B,QAAQC,IAAa,aACrB,MAAMC,GACN,cACA,QACA,GAAGC,QACqB;CACxB,IAAMC,IAAkBnB,EAAM,WAAWoB,CAAsB,GACzDC,IAAOJ,KAAYE,KAAmB,UACtCR,IAASD,EAAwBM,CAAU,GAC3C,EAAE,UAAO,SAAM,WAAWM,MAAoBrB,EAAaU;CAEjE,OACE,kBAAC,QAAD;EACO;EACL,MAAK;EACL,cAAYH,EAAaG;EACzB,cAAYY;EACZ,eAAaZ;EACb,GAAIO;EACJ,WAAWM,EACTC,EAAwB,MACxB,wFACA,wBACAC,EAAa,QACbZ,EAAYO,IACZC,GACAK,CACF;EAEA,UAAA,kBAACC,GAAD;GACE,MAAK;GACL,WAAWJ,EACTC,EAAwB,MACxB,aACAF,MAAU,WAAW,uBACvB;EACD,CAAA;CACG,CAAA;AAEV;AAEA,EAAc,cAAc"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../lib/composeEventHandlers.cjs"),o=require("../../lib/classNames.cjs"),s=require("../../hooks/useEventCallback.cjs"),c=require("../../hooks/useId.cjs"),l=require("../../hooks/useMergedRefs.cjs"),u=require("../../lib/styles.cjs"),d=require("../button/Button.cjs"),f=require("../button/Button.slots.cjs"),p=require("../../lib/icons.cjs"),m=require("../../lib/mergeProps.cjs"),h=require("../../lib/labelInName.cjs"),g=require("../../lib/events.cjs"),_=require("./TagGroup.context.cjs"),v=require("./Avatar.context.cjs"),y=require("./tagStyles.cjs");let b=require("react");b=e.__toESM(b,1);let x=require("react/jsx-runtime");var S=new Set([`type`,`disabled`,`autoFocus`,`form`,`formAction`,`formEncType`,`formMethod`,`formNoValidate`,`formTarget`,`name`,`value`]),C=/^on[A-Z]/,w=new Set([`aria-label`,`aria-labelledby`]),T=()=>{};function E(e){let t={},n=!1;for(let[r,i]of Object.entries(e))w.has(r)?i!==void 0&&(n=!0):t[r]=i;return{props:t,ignoredName:n}}var D=`inline-flex items-center justify-center`;function O(e){if(typeof e!=`object`||!e||b.isValidElement(e)||Symbol.iterator in e)return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function k(e,t){return(0,x.jsx)(p.DismissIcon,{size:e,className:t})}function A(e,r){if(!i.slotRendersContent(e))return{buttonProps:null,content:k(r,o.tagClassNames.dismissIcon),warning:null,ignoredName:!1,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1};let a=n.getElementType(e);if(b.isValidElement(e)&&(a===`button`||a===d.Button)){let{children:n,dangerouslySetInnerHTML:s,...c}=e.props,l=a===d.Button,u=c;if(l){u={};for(let[e,t]of Object.entries(c))f.BUTTON_OWN_PROP_KEYS.has(e)||(u[e]=t)}let p=l?c.icon:void 0,{props:m,ignoredName:g}=E(u),_=i.slotRendersContent(p)?i.renderSlot(p,`span`,t.cn(o.tagClassNames.dismissIcon,D),{"aria-hidden":!0}):null,v=s==null?i.materialiseSlotContent(n):(0,x.jsx)(`span`,{className:D,dangerouslySetInnerHTML:s});return{buttonProps:m,content:_||i.slotRendersContent(v)?f.placeButtonIcon(_,v,l&&c.iconPosition):k(r,o.tagClassNames.dismissIcon),warning:`button-element`,ignoredName:g,contentMayName:!0,literalTextLabel:h.hasTextLabel(v),disabledFocusable:l&&!!c.disabledFocusable}}if(O(e)){let n=e.as===d.Button,a=e.as===`button`||n||Object.keys(e).some(e=>S.has(e)||C.test(e)),s={},c={},l={},u=!1;for(let[t,r]of Object.entries(e))t===`as`?r!==`button`&&!n&&(c.as=r):n&&f.BUTTON_OWN_PROP_KEYS.has(t)?l[t]=r:w.has(t)?r!==void 0&&(u=!0):t===`children`||t===`dangerouslySetInnerHTML`?c[t]=r:a||t.startsWith(`aria-`)&&t!==`aria-hidden`?s[t]=r:c[t]=r;let p=i.slotRendersContent(l.icon);return p?c.children=f.placeButtonIcon(i.renderSlot(l.icon,`span`,t.cn(o.tagClassNames.dismissIcon,D)),i.materialiseSlotContent(c.children),l.iconPosition):i.slotWrapsDefaultContent(c.as??`span`,c)&&(c.children=k(r)),{buttonProps:a||Object.keys(s).length>0?s:null,content:i.renderSlot(c,`span`,t.cn(!p&&o.tagClassNames.dismissIcon,D),{"aria-hidden":!0}),warning:a?`button-object`:null,ignoredName:u,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!!l.disabledFocusable}}return{buttonProps:null,content:i.renderSlot(e,`span`,t.cn(o.tagClassNames.dismissIcon,D),{"aria-hidden":!0}),warning:null,ignoredName:!1,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1}}var j=new Set([`button`,`fieldset`,`input`,`optgroup`,`option`,`select`,`textarea`]),M=new Set([`button`,`data`,`input`,`li`,`meter`,`option`,`progress`,`select`,`textarea`]),ee={disabled:!0,"aria-disabled":void 0,"data-disabled":void 0,"data-disabled-focusable":void 0};function N(e,t){return typeof e==`string`&&Object.hasOwn(t,e)}function te(e){e.preventDefault(),e.stopPropagation()}function P({buttonProps:e,content:t,contentMayName:n,literalTextLabel:r,disabledFocusable:i,disabled:o,dismissLabel:s,contentId:u,dismissName:d,buttonRef:p}){let m=c.useId(`tag-dismiss`),g=c.useId(`tag-dismiss-text`),{ref:v,...y}=e,S=b.useRef(null),C=l.useMergedRefs(S,p,v);_.useDismissControlFocus(S);let[w,E]=b.useState(null),D=b.useCallback(e=>w?h.observeTextLabel(w,e):T,[w]),O=b.useSyncExternalStore(D,()=>w?h.hasRenderedTextLabel(w):r,()=>r),k=n&&O,A=_.useHeldFocus(o),j=o?A.held?f.MERGED_DISABLED_FOCUSABLE_PROPS:ee:i?f.MERGED_DISABLED_FOCUSABLE_PROPS:void 0,M=d!==void 0;return(0,x.jsxs)(`button`,{...y,ref:C,type:y.type??`button`,...j,"aria-label":M?d:void 0,"aria-labelledby":M?void 0:`${k?g:m} ${u}`,onFocus:a.composeEventHandlers(y.onFocus,A.onFocus,{checkDefaultPrevented:!1}),onBlur:a.composeEventHandlers(y.onBlur,A.onBlur,{checkDefaultPrevented:!1}),children:[!M&&(0,x.jsx)(`span`,{id:m,className:`sr-only`,children:s}),n?(0,x.jsx)(`span`,{id:g,ref:E,className:`inline-flex items-center justify-center gap-[inherit]`,children:t}):t]})}P.displayName=`TagDismissButton`;var ne=new Set([`a`,`button`,`input`,`select`,`textarea`,`li`]),re='Tag: `as="button"` with `dismissible` puts the Dismiss button inside a button. Use InteractionTag instead: `InteractionTag.Primary` for the action, `InteractionTag.Secondary` for Dismiss.',ie='Tag: a dismissible tag rendered as a link (`as="a"` or a link component) puts the Dismiss button inside the link. Put the link in the tag\'s content: `<Tag dismissible><a href>…</a></Tag>`.',ae='TagGroup: a tag in a `role="list"` group is not a list item (its element is a link, a button or a component). Put a link in the tag\'s content (`<Tag><a href>…</a></Tag>`), or wrap the tag in an element with `role="listitem"`.';function oe(e){for(let t=e;t&&!t.matches(`[data-wave-tag-group]`);t=t.parentElement)if(t.getAttribute(`role`)===`listitem`||t.localName===`li`)return!0;return!1}var F=e=>{let{as:n,appearance:d,size:f,shape:p,disabled:h,selected:S=!1,value:C,media:w,icon:T,secondaryText:E,dismissible:D,onDismiss:O,dismissIcon:k,dismissLabel:ee=`Dismiss`,className:F,children:se,role:ce,hidden:le,onClick:ue,onFocus:de,onBlur:fe,onKeyDown:pe,ref:me,...he}=e,I=n??`span`,L=c.useId(`tag-content`),R=_.useTagGroupContext(),z=b.useContext(_.TagHostContext),B=b.useRef(null),ge=l.useMergedRefs(B,me),V=b.useRef(null),_e=b.useRef(null),H=N(f,y.tagSizeClasses)?f:R?.size??`medium`,U=N(d,y.tagAppearanceClasses)?d:R?.appearance??`filled`,ve=N(p,y.tagShapeClasses)?p:R?.shape??`circular`,W=(R?.disabled??!1)||h===!0,G=D??R?.dismissible??!1,K=S&&!W?`selected`:U,ye=R?.dimDisabled??!0,be=_.useTagGroupItem(B,C,{reported:G&&(R?.reportsDismissals??!1)}),xe=I===`a`,Se=xe&&W,Ce=I===`button`,q=_.useHeldFocus((xe||Ce)&&W),J=Ce&&q.held,{buttonProps:we,content:Te,warning:Y,ignoredName:Ee,contentMayName:De,literalTextLabel:Oe,disabledFocusable:ke}=A(G?k:void 0,y.TAG_DISMISS_GLYPH_SIZE[H]);b.useEffect(()=>{Y===`button-element`?r.warnOnce(`Tag:dismissIcon-button`,"Tag: `dismissIcon` received a button. Its props were merged into the built-in dismiss button (a button cannot contain another button), which is named by its text label (or `dismissLabel`) and the tag content. Pass icon content instead, e.g. `dismissIcon={<CloseIcon />}`, and handle the dismissal in `onDismiss`."):Y===`button-object`&&r.warnDeprecated(`Tag`,`dismissIcon={{ onClick, type, disabled, … }} (button props on the slot object)`,`onDismiss and icon content in dismissIcon`,"Its props are merged onto the built-in dismiss button, which is named by `dismissLabel` and the tag content.")},[Y]);let Ae=D===void 0&&!(R?.dismissible??!1)&&(O!==void 0||k!==void 0);b.useEffect(()=>{Ae&&r.warnOnce(`Tag:dismiss-without-dismissible`,"Tag: `onDismiss` and `dismissIcon` take effect only with `dismissible`; no dismiss button was rendered. Add `dismissible` to render it.")},[Ae]),b.useEffect(()=>{Ee&&r.warnOnce(`Tag:dismissIcon-name`,'Tag: `aria-label`/`aria-labelledby` on `dismissIcon` are ignored. The dismiss button is named by `dismissLabel` (default "Dismiss") and the tag content, e.g. "Dismiss Cherry"; set `dismissLabel` to change or localise it.')},[Ee]),b.useEffect(()=>{if(!G||!r.isDev||r.hasWarned(`Tag:nested-button`))return;let e=B.current?.localName;e===`button`?r.warnOnce(`Tag:nested-button`,re):e===`a`&&r.warnOnce(`Tag:nested-button`,ie)});let je=R?.mode===`list`;b.useEffect(()=>{if(!je||!r.isDev||r.hasWarned(`TagGroup:list-item`))return;let e=B.current;e&&!oe(e)&&r.warnOnce(`TagGroup:list-item`,ae)});let Me=i.slotRendersContent(w),Ne=i.slotRendersContent(T),X=i.materialiseSlotContent(E),Pe=i.slotRendersContent(X),Fe=b.useMemo(()=>({size:y.TAG_AVATAR_SIZE[H]}),[H]),Ie=e=>typeof I!=`string`||e.has(I),Z={};Ie(j)&&(W||h!==void 0)&&(Z.disabled=W&&!J),J&&(Z[`aria-disabled`]=!0,Z[`data-disabled-focusable`]=``),C!==void 0&&Ie(M)&&(Z.value=C),Se&&(Z[`aria-disabled`]=!0,q.held?Z[`data-disabled-focusable`]=``:(Z.href=void 0,Z.role=`link`));let Le=je&&typeof I==`string`&&!ne.has(I)?`listitem`:void 0,Re=C!==void 0&&(R?.hiddenValues?.has(C)??!1),ze=Se||J?e=>{g.isOwnEvent(e)?te(e):ue?.(e)}:ue,Be=s.useEventCallback(e=>{let t=V.current,n=_e.current;t&&n&&_.isDismissKey(e)&&t.contains(e.target)&&!g.isEditableTarget(e.target)&&(e.preventDefault(),n.click())}),Q={type:`button`,"data-wave-tag-dismiss":``,className:t.cn(o.tagClassNames.dismissButton,y.TAG_DISMISS_BASE_CLASSES,y.tagDismissSizeClasses[H],!W&&[`disabled:opacity-50`,`aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100`,y.tagDismissStateClasses[K]],u.focusRing,y.tagDismissRingClasses[H],K===`selected`&&`focus-visible:outline-primary-foreground`,z?.dismissButtonClassName),onKeyDown:e=>{if(e.target===e.currentTarget){if(_.isRepeatedActivation(e)){e.preventDefault();return}_.isDismissKey(e)&&(e.preventDefault(),e.currentTarget.click())}}};(O||R)&&(Q.onClick=e=>{g.isOwnEvent(e)&&(O?.(),R?.dismiss(be))});let Ve=we?m.mergeProps(Q,we):Q,$=(0,x.jsx)(`span`,{id:L,ref:V,className:t.cn(o.tagClassNames.primaryText,`inline-flex items-center gap-1`,Pe&&`text-caption-1 leading-3.5`),children:se});return(0,x.jsxs)(I,{"data-size":H,"data-appearance":U,"data-shape":ve,"data-selected":S?``:void 0,"data-disabled":W?``:void 0,"data-wave-tag-item":``,role:ce??Le,hidden:Re||le,...he,...Z,ref:ge,className:t.cn(o.tagClassNames.root,y.TAG_ROOT_BASE_CLASSES,y.tagSizeClasses[H],y.tagStartInsetClasses[H][Me?`media`:Ne?`icon`:`text`],y.tagEndInsetClasses[H][G?`dismiss`:`text`],K===`selected`?[y.TAG_SELECTED_CLASSES,u.forcedColors.selectedContainer]:y.tagAppearanceClasses[U],W&&[ye&&`opacity-50 focus-visible:opacity-100 has-focus-visible:opacity-100`,u.forcedColors.disabled],y.tagShapeClasses[ve],F),onClick:ze,onKeyDown:a.composeEventHandlers(pe,Be),onFocus:a.composeEventHandlers(de,q.onFocus,{checkDefaultPrevented:!1}),onBlur:a.composeEventHandlers(fe,q.onBlur,{checkDefaultPrevented:!1}),children:[Me&&(0,x.jsx)(v.AvatarSizeContext.Provider,{value:Fe,children:i.renderSlot(w,`span`,t.cn(o.tagClassNames.media,y.tagMediaClasses[H]))}),Ne&&i.renderSlot(T,`span`,t.cn(o.tagClassNames.icon,y.tagIconClasses[H]),{"aria-hidden":!0}),Pe?(0,x.jsxs)(`span`,{className:y.TAG_TEXT_COLUMN_CLASSES,children:[$,(0,x.jsx)(`span`,{className:t.cn(o.tagClassNames.secondaryText,y.TAG_SECONDARY_TEXT_CLASSES),children:X})]}):$,G&&(0,x.jsx)(P,{buttonProps:Ve,content:Te,contentMayName:De,literalTextLabel:Oe,disabledFocusable:ke,disabled:W,dismissLabel:ee,contentId:L,dismissName:z?.dismissName,buttonRef:_e})]})};F.displayName=`Tag`,exports.Tag=F;
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../lib/composeEventHandlers.cjs"),o=require("../../lib/classNames.cjs"),s=require("../../hooks/useEventCallback.cjs"),c=require("../../hooks/useId.cjs"),l=require("../../hooks/useMergedRefs.cjs"),u=require("../../lib/styles.cjs"),d=require("../button/Button.cjs"),f=require("../button/Button.slots.cjs"),p=require("../../lib/icons.cjs"),m=require("../../lib/mergeProps.cjs"),h=require("../../lib/labelInName.cjs"),g=require("../../lib/events.cjs"),_=require("./TagGroup.context.cjs"),v=require("./Avatar.context.cjs"),y=require("./tagStyles.cjs");let b=require("react");b=e.__toESM(b,1);let x=require("react/jsx-runtime");var S=new Set([`type`,`disabled`,`autoFocus`,`form`,`formAction`,`formEncType`,`formMethod`,`formNoValidate`,`formTarget`,`name`,`value`]),C=/^on[A-Z]/,w=new Set([`aria-label`,`aria-labelledby`]),T=()=>{};function E(e){let t={},n=!1;for(let[r,i]of Object.entries(e))w.has(r)?i!==void 0&&(n=!0):t[r]=i;return{props:t,ignoredName:n}}var D=`inline-flex items-center justify-center`;function O(e){if(typeof e!=`object`||!e||b.isValidElement(e)||Symbol.iterator in e)return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function k(e,t){return(0,x.jsx)(p.DismissIcon,{size:e,className:t})}function A(e,r){if(!i.slotRendersContent(e))return{buttonProps:null,content:k(r,o.tagClassNames.dismissIcon),warning:null,ignoredName:!1,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1};let a=n.getElementType(e);if(b.isValidElement(e)&&(a===`button`||a===d.Button)){let{children:n,dangerouslySetInnerHTML:s,...c}=e.props,l=a===d.Button,u=c;if(l){u={};for(let[e,t]of Object.entries(c))f.BUTTON_OWN_PROP_KEYS.has(e)||(u[e]=t)}let p=l?c.icon:void 0,{props:m,ignoredName:g}=E(u),_=i.slotRendersContent(p)?i.renderSlot(p,`span`,t.cn(o.tagClassNames.dismissIcon,D),{"aria-hidden":!0}):null,v=s==null?i.materialiseSlotContent(n):(0,x.jsx)(`span`,{className:D,dangerouslySetInnerHTML:s});return{buttonProps:m,content:_||i.slotRendersContent(v)?f.placeButtonIcon(_,v,l&&c.iconPosition):k(r,o.tagClassNames.dismissIcon),warning:`button-element`,ignoredName:g,contentMayName:!0,literalTextLabel:h.hasTextLabel(v),disabledFocusable:l&&!!c.disabledFocusable}}if(O(e)){let n=e.as===d.Button,a=e.as===`button`||n||Object.keys(e).some(e=>S.has(e)||C.test(e)),s={},c={},l={},u=!1;for(let[t,r]of Object.entries(e))t===`as`?r!==`button`&&!n&&(c.as=r):n&&f.BUTTON_OWN_PROP_KEYS.has(t)?l[t]=r:w.has(t)?r!==void 0&&(u=!0):t===`children`||t===`dangerouslySetInnerHTML`?c[t]=r:a||t.startsWith(`aria-`)&&t!==`aria-hidden`?s[t]=r:c[t]=r;let p=i.slotRendersContent(l.icon);return p?c.children=f.placeButtonIcon(i.renderSlot(l.icon,`span`,t.cn(o.tagClassNames.dismissIcon,D)),i.materialiseSlotContent(c.children),l.iconPosition):i.slotWrapsDefaultContent(c.as??`span`,c)&&(c.children=k(r)),{buttonProps:a||Object.keys(s).length>0?s:null,content:i.renderSlot(c,`span`,t.cn(!p&&o.tagClassNames.dismissIcon,D),{"aria-hidden":!0}),warning:a?`button-object`:null,ignoredName:u,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!!l.disabledFocusable}}return{buttonProps:null,content:i.renderSlot(e,`span`,t.cn(o.tagClassNames.dismissIcon,D),{"aria-hidden":!0}),warning:null,ignoredName:!1,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1}}var j=new Set([`button`,`fieldset`,`input`,`optgroup`,`option`,`select`,`textarea`]),M=new Set([`button`,`data`,`input`,`li`,`meter`,`option`,`progress`,`select`,`textarea`]),ee={disabled:!0,"aria-disabled":void 0,"data-disabled":void 0,"data-disabled-focusable":void 0};function N(e,t){return typeof e==`string`&&Object.hasOwn(t,e)}function te(e){e.preventDefault(),e.stopPropagation()}function P({buttonProps:e,content:t,contentMayName:n,literalTextLabel:r,disabledFocusable:i,disabled:o,dismissLabel:s,contentId:u,dismissName:d,buttonRef:p}){let m=c.useId(`tag-dismiss`),g=c.useId(`tag-dismiss-text`),{ref:v,...y}=e,S=b.useRef(null),C=l.useMergedRefs(S,p,v);_.useDismissControlFocus(S);let[w,E]=b.useState(null),D=b.useCallback(e=>w?h.observeTextLabel(w,e):T,[w]),O=b.useSyncExternalStore(D,()=>w?h.hasRenderedTextLabel(w):r,()=>r),k=n&&O,A=_.useHeldFocus(o),j=o?A.held?f.MERGED_DISABLED_FOCUSABLE_PROPS:ee:i?f.MERGED_DISABLED_FOCUSABLE_PROPS:void 0,M=d!==void 0;return(0,x.jsxs)(`button`,{...y,ref:C,type:y.type??`button`,...j,"aria-label":M?d:void 0,"aria-labelledby":M?void 0:`${k?g:m} ${u}`,onFocus:a.composeEventHandlers(y.onFocus,A.onFocus,{checkDefaultPrevented:!1}),onBlur:a.composeEventHandlers(y.onBlur,A.onBlur,{checkDefaultPrevented:!1}),children:[!M&&(0,x.jsx)(`span`,{id:m,className:`sr-only`,children:s}),n?(0,x.jsx)(`span`,{id:g,ref:E,className:`inline-flex items-center justify-center gap-[inherit]`,children:t}):t]})}P.displayName=`TagDismissButton`;var ne=new Set([`a`,`button`,`input`,`select`,`textarea`,`li`]),re='Tag: `as="button"` with `dismissible` puts the Dismiss button inside a button. Use InteractionTag instead: `InteractionTag.Primary` for the action, `InteractionTag.Secondary` for Dismiss.',ie='Tag: a dismissible tag rendered as a link (`as="a"` or a link component) puts the Dismiss button inside the link. Put the link in the tag\'s content: `<Tag dismissible><a href>…</a></Tag>`.',ae='TagGroup: a tag in a `role="list"` group is not a list item (its element is a link, a button or a component). Put a link in the tag\'s content (`<Tag><a href>…</a></Tag>`), or wrap the tag in an element with `role="listitem"`.';function oe(e){for(let t=e;t&&!t.matches(`[data-wave-tag-group]`);t=t.parentElement)if(t.getAttribute(`role`)===`listitem`||t.localName===`li`)return!0;return!1}var F=e=>{let{as:n,appearance:d,size:f,shape:p,disabled:h,selected:S=!1,value:C,media:w,icon:T,secondaryText:E,dismissible:D,onDismiss:O,dismissIcon:k,dismissLabel:ee=`Dismiss`,className:F,children:se,role:ce,hidden:le,onClick:ue,onFocus:de,onBlur:fe,onKeyDown:pe,ref:me,...he}=e,I=n??`span`,L=c.useId(`tag-content`),R=_.useTagGroupContext(),z=b.useContext(_.TagHostContext),B=b.useRef(null),ge=l.useMergedRefs(B,me),_e=b.useRef(null),ve=b.useRef(null),V=N(f,y.tagSizeClasses)?f:R?.size??`medium`,H=N(d,y.tagAppearanceClasses)?d:R?.appearance??`filled`,U=N(p,y.tagShapeClasses)?p:R?.shape??`circular`,W=(R?.disabled??!1)||h===!0,G=D??R?.dismissible??!1,K=S&&!W?`selected`:H,ye=R?.dimDisabled??!0,be=_.useTagGroupItem(B,C,{reported:G&&(R?.reportsDismissals??!1)}),xe=I===`a`,Se=xe&&W,Ce=I===`button`,q=_.useHeldFocus((xe||Ce)&&W),J=Ce&&q.held,{buttonProps:we,content:Te,warning:Y,ignoredName:Ee,contentMayName:De,literalTextLabel:Oe,disabledFocusable:ke}=A(G?k:void 0,y.TAG_DISMISS_GLYPH_SIZE[V]);b.useEffect(()=>{Y===`button-element`?r.warnOnce(`Tag:dismissIcon-button`,"Tag: `dismissIcon` received a button. Its props were merged into the built-in dismiss button (a button cannot contain another button), which is named by its text label (or `dismissLabel`) and the tag content. Pass icon content instead, e.g. `dismissIcon={<CloseIcon />}`, and handle the dismissal in `onDismiss`."):Y===`button-object`&&r.warnDeprecated(`Tag`,`dismissIcon={{ onClick, type, disabled, … }} (button props on the slot object)`,`onDismiss and icon content in dismissIcon`,"Its props are merged onto the built-in dismiss button, which is named by `dismissLabel` and the tag content.")},[Y]);let Ae=D===void 0&&!(R?.dismissible??!1)&&(O!==void 0||k!==void 0);b.useEffect(()=>{Ae&&r.warnOnce(`Tag:dismiss-without-dismissible`,"Tag: `onDismiss` and `dismissIcon` take effect only with `dismissible`; no dismiss button was rendered. Add `dismissible` to render it.")},[Ae]),b.useEffect(()=>{Ee&&r.warnOnce(`Tag:dismissIcon-name`,'Tag: `aria-label`/`aria-labelledby` on `dismissIcon` are ignored. The dismiss button is named by `dismissLabel` (default "Dismiss") and the tag content, e.g. "Dismiss Cherry"; set `dismissLabel` to change or localise it.')},[Ee]),b.useEffect(()=>{if(!G||!r.isDev||r.hasWarned(`Tag:nested-button`))return;let e=B.current?.localName;e===`button`?r.warnOnce(`Tag:nested-button`,re):e===`a`&&r.warnOnce(`Tag:nested-button`,ie)});let je=R?.mode===`list`;b.useEffect(()=>{if(!je||!r.isDev||r.hasWarned(`TagGroup:list-item`))return;let e=B.current;e&&!oe(e)&&r.warnOnce(`TagGroup:list-item`,ae)});let Me=i.slotRendersContent(w),Ne=i.slotRendersContent(T),X=i.materialiseSlotContent(E),Pe=i.slotRendersContent(X),Fe=b.useMemo(()=>({size:y.TAG_AVATAR_SIZE[V],shape:U===`rounded`?`square`:`circular`}),[V,U]),Ie=e=>typeof I!=`string`||e.has(I),Z={};Ie(j)&&(W||h!==void 0)&&(Z.disabled=W&&!J),J&&(Z[`aria-disabled`]=!0,Z[`data-disabled-focusable`]=``),C!==void 0&&Ie(M)&&(Z.value=C),Se&&(Z[`aria-disabled`]=!0,q.held?Z[`data-disabled-focusable`]=``:(Z.href=void 0,Z.role=`link`));let Le=je&&typeof I==`string`&&!ne.has(I)?`listitem`:void 0,Re=C!==void 0&&(R?.hiddenValues?.has(C)??!1),ze=Se||J?e=>{g.isOwnEvent(e)?te(e):ue?.(e)}:ue,Be=s.useEventCallback(e=>{let t=_e.current,n=ve.current;t&&n&&_.isDismissKey(e)&&t.contains(e.target)&&!g.isEditableTarget(e.target)&&(e.preventDefault(),n.click())}),Q={type:`button`,"data-wave-tag-dismiss":``,className:t.cn(o.tagClassNames.dismissButton,y.TAG_DISMISS_BASE_CLASSES,y.tagDismissSizeClasses[V],!W&&[`disabled:opacity-50`,`aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100`,y.tagDismissStateClasses[K]],u.focusRing,y.tagDismissRingClasses[V],K===`selected`&&`focus-visible:outline-primary-foreground`,z?.dismissButtonClassName),onKeyDown:e=>{if(e.target===e.currentTarget){if(_.isRepeatedActivation(e)){e.preventDefault();return}_.isDismissKey(e)&&(e.preventDefault(),e.currentTarget.click())}}};(O||R)&&(Q.onClick=e=>{g.isOwnEvent(e)&&(O?.(),R?.dismiss(be))});let Ve=we?m.mergeProps(Q,we):Q,$=(0,x.jsx)(`span`,{id:L,ref:_e,className:t.cn(o.tagClassNames.primaryText,`inline-flex items-center gap-1`,Pe&&`text-caption-1 leading-3.5`),children:se});return(0,x.jsxs)(I,{"data-size":V,"data-appearance":H,"data-shape":U,"data-selected":S?``:void 0,"data-disabled":W?``:void 0,"data-wave-tag-item":``,role:ce??Le,hidden:Re||le,...he,...Z,ref:ge,className:t.cn(o.tagClassNames.root,y.TAG_ROOT_BASE_CLASSES,y.tagSizeClasses[V],y.tagStartInsetClasses[V][Me?`media`:Ne?`icon`:`text`],y.tagEndInsetClasses[V][G?`dismiss`:`text`],K===`selected`?[y.TAG_SELECTED_CLASSES,u.forcedColors.selectedContainer]:y.tagAppearanceClasses[H],W&&[ye&&`opacity-50 focus-visible:opacity-100 has-focus-visible:opacity-100`,u.forcedColors.disabled],y.tagShapeClasses[U],F),onClick:ze,onKeyDown:a.composeEventHandlers(pe,Be),onFocus:a.composeEventHandlers(de,q.onFocus,{checkDefaultPrevented:!1}),onBlur:a.composeEventHandlers(fe,q.onBlur,{checkDefaultPrevented:!1}),children:[Me&&(0,x.jsx)(v.AvatarSizeContext.Provider,{value:Fe,children:i.renderSlot(w,`span`,t.cn(o.tagClassNames.media,y.tagMediaClasses[V]))}),Ne&&i.renderSlot(T,`span`,t.cn(o.tagClassNames.icon,y.tagIconClasses[V]),{"aria-hidden":!0}),Pe?(0,x.jsxs)(`span`,{className:y.TAG_TEXT_COLUMN_CLASSES,children:[$,(0,x.jsx)(`span`,{className:t.cn(o.tagClassNames.secondaryText,y.TAG_SECONDARY_TEXT_CLASSES),children:X})]}):$,G&&(0,x.jsx)(P,{buttonProps:Ve,content:Te,contentMayName:De,literalTextLabel:Oe,disabledFocusable:ke,disabled:W,dismissLabel:ee,contentId:L,dismissName:z?.dismissName,buttonRef:ve})]})};F.displayName=`Tag`,exports.Tag=F;
2
2
  //# sourceMappingURL=Tag.cjs.map