@mattermost/compass-ui 0.1.0-alpha.6 → 0.1.0-alpha.8

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 (268) hide show
  1. package/dist/components/action-button/ActionButton.cjs.map +1 -1
  2. package/dist/components/action-button/ActionButton.d.ts +1 -0
  3. package/dist/components/action-button/ActionButton.d.ts.map +1 -1
  4. package/dist/components/action-button/ActionButton.js.map +1 -1
  5. package/dist/components/admin-panel/AdminPanel.cjs.map +1 -1
  6. package/dist/components/admin-panel/AdminPanel.d.ts +1 -0
  7. package/dist/components/admin-panel/AdminPanel.d.ts.map +1 -1
  8. package/dist/components/admin-panel/AdminPanel.js.map +1 -1
  9. package/dist/components/admin-panel-header/AdminPanelHeader.cjs.map +1 -1
  10. package/dist/components/admin-panel-header/AdminPanelHeader.d.ts +1 -0
  11. package/dist/components/admin-panel-header/AdminPanelHeader.d.ts.map +1 -1
  12. package/dist/components/admin-panel-header/AdminPanelHeader.js.map +1 -1
  13. package/dist/components/button/Button.cjs +1 -1
  14. package/dist/components/button/Button.cjs.map +1 -1
  15. package/dist/components/button/Button.d.ts +7 -5
  16. package/dist/components/button/Button.d.ts.map +1 -1
  17. package/dist/components/button/Button.js +29 -27
  18. package/dist/components/button/Button.js.map +1 -1
  19. package/dist/components/button/Button.module.css +1 -1
  20. package/dist/components/button/Button.module.scss.cjs +1 -1
  21. package/dist/components/button/Button.module.scss.js +13 -12
  22. package/dist/components/button/Button.module.scss.js.map +1 -1
  23. package/dist/components/card-button/CardButton.cjs +2 -0
  24. package/dist/components/card-button/CardButton.cjs.map +1 -0
  25. package/dist/components/card-button/CardButton.d.ts +20 -0
  26. package/dist/components/card-button/CardButton.d.ts.map +1 -0
  27. package/dist/components/card-button/CardButton.js +45 -0
  28. package/dist/components/card-button/CardButton.js.map +1 -0
  29. package/dist/components/card-button/CardButton.module.css +1 -0
  30. package/dist/components/card-button/CardButton.module.scss.cjs +2 -0
  31. package/dist/components/card-button/CardButton.module.scss.cjs.map +1 -0
  32. package/dist/components/card-button/CardButton.module.scss.js +13 -0
  33. package/dist/components/card-button/CardButton.module.scss.js.map +1 -0
  34. package/dist/components/card-button/CardButtonGroup.cjs +2 -0
  35. package/dist/components/card-button/CardButtonGroup.cjs.map +1 -0
  36. package/dist/components/card-button/CardButtonGroup.d.ts +13 -0
  37. package/dist/components/card-button/CardButtonGroup.d.ts.map +1 -0
  38. package/dist/components/card-button/CardButtonGroup.js +85 -0
  39. package/dist/components/card-button/CardButtonGroup.js.map +1 -0
  40. package/dist/components/card-button/CardButtonGroup.module.css +1 -0
  41. package/dist/components/card-button/CardButtonGroup.module.scss.cjs +2 -0
  42. package/dist/components/card-button/CardButtonGroup.module.scss.cjs.map +1 -0
  43. package/dist/components/card-button/CardButtonGroup.module.scss.js +7 -0
  44. package/dist/components/card-button/CardButtonGroup.module.scss.js.map +1 -0
  45. package/dist/components/card-button/index.cjs +2 -0
  46. package/dist/components/card-button/index.d.ts +5 -0
  47. package/dist/components/card-button/index.d.ts.map +1 -0
  48. package/dist/components/card-button/index.js +7 -0
  49. package/dist/components/card-button/index.js.map +1 -0
  50. package/dist/components/chip/Chip.cjs +1 -1
  51. package/dist/components/chip/Chip.cjs.map +1 -1
  52. package/dist/components/chip/Chip.d.ts +4 -2
  53. package/dist/components/chip/Chip.d.ts.map +1 -1
  54. package/dist/components/chip/Chip.js +66 -66
  55. package/dist/components/chip/Chip.js.map +1 -1
  56. package/dist/components/chip/Chip.module.css +1 -1
  57. package/dist/components/chip/Chip.module.scss.cjs +1 -1
  58. package/dist/components/chip/Chip.module.scss.js +12 -12
  59. package/dist/components/emoji-button/EmojiButton.cjs +2 -0
  60. package/dist/components/emoji-button/EmojiButton.cjs.map +1 -0
  61. package/dist/components/emoji-button/EmojiButton.d.ts +30 -0
  62. package/dist/components/emoji-button/EmojiButton.d.ts.map +1 -0
  63. package/dist/components/emoji-button/EmojiButton.js +35 -0
  64. package/dist/components/emoji-button/EmojiButton.js.map +1 -0
  65. package/dist/components/emoji-button/EmojiButton.module.css +1 -0
  66. package/dist/components/emoji-button/EmojiButton.module.scss.cjs +2 -0
  67. package/dist/components/emoji-button/EmojiButton.module.scss.cjs.map +1 -0
  68. package/dist/components/emoji-button/EmojiButton.module.scss.js +15 -0
  69. package/dist/components/emoji-button/EmojiButton.module.scss.js.map +1 -0
  70. package/dist/components/emoji-button/index.cjs +2 -0
  71. package/dist/components/emoji-button/index.cjs.map +1 -0
  72. package/dist/components/emoji-button/index.d.ts +3 -0
  73. package/dist/components/emoji-button/index.d.ts.map +1 -0
  74. package/dist/components/emoji-button/index.js +6 -0
  75. package/dist/components/emoji-popover/EmojiPopover.cjs +2 -0
  76. package/dist/components/emoji-popover/EmojiPopover.cjs.map +1 -0
  77. package/dist/components/emoji-popover/EmojiPopover.d.ts +34 -0
  78. package/dist/components/emoji-popover/EmojiPopover.d.ts.map +1 -0
  79. package/dist/components/emoji-popover/EmojiPopover.js +244 -0
  80. package/dist/components/emoji-popover/EmojiPopover.js.map +1 -0
  81. package/dist/components/emoji-popover/EmojiPopover.module.css +1 -0
  82. package/dist/components/emoji-popover/EmojiPopover.module.scss.cjs +2 -0
  83. package/dist/components/emoji-popover/EmojiPopover.module.scss.cjs.map +1 -0
  84. package/dist/components/emoji-popover/EmojiPopover.module.scss.js +27 -0
  85. package/dist/components/emoji-popover/EmojiPopover.module.scss.js.map +1 -0
  86. package/dist/components/{message-reactions → emoji-popover}/index.cjs +1 -1
  87. package/dist/components/emoji-popover/index.cjs.map +1 -0
  88. package/dist/components/emoji-popover/index.d.ts +3 -0
  89. package/dist/components/emoji-popover/index.d.ts.map +1 -0
  90. package/dist/components/emoji-popover/index.js +5 -0
  91. package/dist/components/emoji-popover/index.js.map +1 -0
  92. package/dist/components/global-banner/GlobalBanner.cjs.map +1 -1
  93. package/dist/components/global-banner/GlobalBanner.d.ts +1 -1
  94. package/dist/components/global-banner/GlobalBanner.d.ts.map +1 -1
  95. package/dist/components/global-banner/GlobalBanner.js.map +1 -1
  96. package/dist/components/global-header/GlobalHeader.module.css +1 -1
  97. package/dist/components/global-header/GlobalHeader.module.scss.cjs +1 -1
  98. package/dist/components/global-header/GlobalHeader.module.scss.js +16 -16
  99. package/dist/components/icon-button/IconButton.cjs +1 -1
  100. package/dist/components/icon-button/IconButton.cjs.map +1 -1
  101. package/dist/components/icon-button/IconButton.d.ts +3 -1
  102. package/dist/components/icon-button/IconButton.d.ts.map +1 -1
  103. package/dist/components/icon-button/IconButton.js +37 -35
  104. package/dist/components/icon-button/IconButton.js.map +1 -1
  105. package/dist/components/menu-group-heading/MenuGroupHeading.cjs +2 -0
  106. package/dist/components/menu-group-heading/MenuGroupHeading.cjs.map +1 -0
  107. package/dist/components/menu-group-heading/MenuGroupHeading.d.ts +11 -0
  108. package/dist/components/menu-group-heading/MenuGroupHeading.d.ts.map +1 -0
  109. package/dist/components/menu-group-heading/MenuGroupHeading.js +20 -0
  110. package/dist/components/menu-group-heading/MenuGroupHeading.js.map +1 -0
  111. package/dist/components/menu-group-heading/MenuGroupHeading.module.css +1 -0
  112. package/dist/components/menu-group-heading/MenuGroupHeading.module.scss.cjs +2 -0
  113. package/dist/components/menu-group-heading/MenuGroupHeading.module.scss.cjs.map +1 -0
  114. package/dist/components/menu-group-heading/MenuGroupHeading.module.scss.js +8 -0
  115. package/dist/components/menu-group-heading/MenuGroupHeading.module.scss.js.map +1 -0
  116. package/dist/components/menu-group-heading/index.cjs +2 -0
  117. package/dist/components/menu-group-heading/index.cjs.map +1 -0
  118. package/dist/components/menu-group-heading/index.d.ts +3 -0
  119. package/dist/components/menu-group-heading/index.d.ts.map +1 -0
  120. package/dist/components/menu-group-heading/index.js +5 -0
  121. package/dist/components/menu-group-heading/index.js.map +1 -0
  122. package/dist/components/menu-item/MenuItem.cjs.map +1 -1
  123. package/dist/components/menu-item/MenuItem.d.ts +2 -2
  124. package/dist/components/menu-item/MenuItem.d.ts.map +1 -1
  125. package/dist/components/menu-item/MenuItem.js.map +1 -1
  126. package/dist/components/message-separator/MessageSeparator.cjs +1 -1
  127. package/dist/components/message-separator/MessageSeparator.cjs.map +1 -1
  128. package/dist/components/message-separator/MessageSeparator.d.ts +1 -1
  129. package/dist/components/message-separator/MessageSeparator.js +1 -1
  130. package/dist/components/message-separator/MessageSeparator.js.map +1 -1
  131. package/dist/components/modal/Modal.cjs +1 -1
  132. package/dist/components/modal/Modal.cjs.map +1 -1
  133. package/dist/components/modal/Modal.d.ts +43 -11
  134. package/dist/components/modal/Modal.d.ts.map +1 -1
  135. package/dist/components/modal/Modal.js +56 -74
  136. package/dist/components/modal/Modal.js.map +1 -1
  137. package/dist/components/modal/Modal.module.css +1 -1
  138. package/dist/components/modal/Modal.module.scss.cjs +1 -1
  139. package/dist/components/modal/Modal.module.scss.js +12 -25
  140. package/dist/components/modal/Modal.module.scss.js.map +1 -1
  141. package/dist/components/modal/index.d.ts +1 -1
  142. package/dist/components/modal/index.d.ts.map +1 -1
  143. package/dist/components/modal-footer/ModalFooter.cjs +2 -0
  144. package/dist/components/modal-footer/ModalFooter.cjs.map +1 -0
  145. package/dist/components/modal-footer/ModalFooter.d.ts +29 -0
  146. package/dist/components/modal-footer/ModalFooter.d.ts.map +1 -0
  147. package/dist/components/modal-footer/ModalFooter.js +31 -0
  148. package/dist/components/modal-footer/ModalFooter.js.map +1 -0
  149. package/dist/components/modal-footer/ModalFooter.module.css +1 -0
  150. package/dist/components/modal-footer/ModalFooter.module.scss.cjs +2 -0
  151. package/dist/components/modal-footer/ModalFooter.module.scss.cjs.map +1 -0
  152. package/dist/components/modal-footer/ModalFooter.module.scss.js +17 -0
  153. package/dist/components/modal-footer/ModalFooter.module.scss.js.map +1 -0
  154. package/dist/components/modal-footer/index.cjs +2 -0
  155. package/dist/components/modal-footer/index.cjs.map +1 -0
  156. package/dist/components/modal-footer/index.d.ts +3 -0
  157. package/dist/components/modal-footer/index.d.ts.map +1 -0
  158. package/dist/components/modal-footer/index.js +5 -0
  159. package/dist/components/modal-footer/index.js.map +1 -0
  160. package/dist/components/modal-header/ModalHeader.cjs +2 -0
  161. package/dist/components/modal-header/ModalHeader.cjs.map +1 -0
  162. package/dist/components/modal-header/ModalHeader.d.ts +38 -0
  163. package/dist/components/modal-header/ModalHeader.d.ts.map +1 -0
  164. package/dist/components/modal-header/ModalHeader.js +74 -0
  165. package/dist/components/modal-header/ModalHeader.js.map +1 -0
  166. package/dist/components/modal-header/ModalHeader.module.css +1 -0
  167. package/dist/components/modal-header/ModalHeader.module.scss.cjs +2 -0
  168. package/dist/components/modal-header/ModalHeader.module.scss.cjs.map +1 -0
  169. package/dist/components/modal-header/ModalHeader.module.scss.js +19 -0
  170. package/dist/components/modal-header/ModalHeader.module.scss.js.map +1 -0
  171. package/dist/components/modal-header/index.cjs +2 -0
  172. package/dist/components/modal-header/index.cjs.map +1 -0
  173. package/dist/components/modal-header/index.d.ts +3 -0
  174. package/dist/components/modal-header/index.d.ts.map +1 -0
  175. package/dist/components/modal-header/index.js +5 -0
  176. package/dist/components/modal-header/index.js.map +1 -0
  177. package/dist/components/popover-notice/PopoverNotice.cjs.map +1 -1
  178. package/dist/components/popover-notice/PopoverNotice.d.ts +1 -1
  179. package/dist/components/popover-notice/PopoverNotice.d.ts.map +1 -1
  180. package/dist/components/popover-notice/PopoverNotice.js.map +1 -1
  181. package/dist/components/reaction-button/ReactionButton.cjs +2 -0
  182. package/dist/components/reaction-button/ReactionButton.cjs.map +1 -0
  183. package/dist/components/reaction-button/ReactionButton.d.ts +17 -0
  184. package/dist/components/reaction-button/ReactionButton.d.ts.map +1 -0
  185. package/dist/components/reaction-button/ReactionButton.js +42 -0
  186. package/dist/components/reaction-button/ReactionButton.js.map +1 -0
  187. package/dist/components/reaction-button/ReactionButton.module.css +1 -0
  188. package/dist/components/reaction-button/ReactionButton.module.scss.cjs +2 -0
  189. package/dist/components/reaction-button/ReactionButton.module.scss.cjs.map +1 -0
  190. package/dist/components/reaction-button/ReactionButton.module.scss.js +12 -0
  191. package/dist/components/reaction-button/ReactionButton.module.scss.js.map +1 -0
  192. package/dist/components/reaction-button/index.cjs +2 -0
  193. package/dist/components/reaction-button/index.cjs.map +1 -0
  194. package/dist/components/reaction-button/index.d.ts +3 -0
  195. package/dist/components/reaction-button/index.d.ts.map +1 -0
  196. package/dist/components/reaction-button/index.js +5 -0
  197. package/dist/components/reaction-button/index.js.map +1 -0
  198. package/dist/components/reactions-row/ReactionsRow.cjs +2 -0
  199. package/dist/components/reactions-row/ReactionsRow.cjs.map +1 -0
  200. package/dist/components/{message-reactions/MessageReactions.d.ts → reactions-row/ReactionsRow.d.ts} +5 -5
  201. package/dist/components/reactions-row/ReactionsRow.d.ts.map +1 -0
  202. package/dist/components/reactions-row/ReactionsRow.js +71 -0
  203. package/dist/components/reactions-row/ReactionsRow.js.map +1 -0
  204. package/dist/components/reactions-row/ReactionsRow.module.css +1 -0
  205. package/dist/components/reactions-row/ReactionsRow.module.scss.cjs +2 -0
  206. package/dist/components/reactions-row/ReactionsRow.module.scss.cjs.map +1 -0
  207. package/dist/components/reactions-row/ReactionsRow.module.scss.js +14 -0
  208. package/dist/components/reactions-row/ReactionsRow.module.scss.js.map +1 -0
  209. package/dist/components/reactions-row/index.cjs +2 -0
  210. package/dist/components/reactions-row/index.cjs.map +1 -0
  211. package/dist/components/reactions-row/index.d.ts +3 -0
  212. package/dist/components/reactions-row/index.d.ts.map +1 -0
  213. package/dist/components/reactions-row/index.js +5 -0
  214. package/dist/components/reactions-row/index.js.map +1 -0
  215. package/dist/components/right-sidebar-header/RightSidebarHeader.cjs.map +1 -1
  216. package/dist/components/right-sidebar-header/RightSidebarHeader.d.ts +1 -1
  217. package/dist/components/right-sidebar-header/RightSidebarHeader.d.ts.map +1 -1
  218. package/dist/components/right-sidebar-header/RightSidebarHeader.js.map +1 -1
  219. package/dist/components/section-notice/SectionNotice.cjs.map +1 -1
  220. package/dist/components/section-notice/SectionNotice.d.ts +1 -1
  221. package/dist/components/section-notice/SectionNotice.d.ts.map +1 -1
  222. package/dist/components/section-notice/SectionNotice.js.map +1 -1
  223. package/dist/components/spinner/Spinner.cjs +1 -1
  224. package/dist/components/spinner/Spinner.cjs.map +1 -1
  225. package/dist/components/spinner/Spinner.d.ts +1 -1
  226. package/dist/components/spinner/Spinner.d.ts.map +1 -1
  227. package/dist/components/spinner/Spinner.js +17 -17
  228. package/dist/components/spinner/Spinner.js.map +1 -1
  229. package/dist/components/tag/Tag.cjs.map +1 -1
  230. package/dist/components/tag/Tag.d.ts +1 -1
  231. package/dist/components/tag/Tag.d.ts.map +1 -1
  232. package/dist/components/tag/Tag.js.map +1 -1
  233. package/dist/components/text-input/TextInput.cjs.map +1 -1
  234. package/dist/components/text-input/TextInput.d.ts +1 -1
  235. package/dist/components/text-input/TextInput.d.ts.map +1 -1
  236. package/dist/components/text-input/TextInput.js.map +1 -1
  237. package/dist/components/thread-footer/ThreadFooter.module.css +1 -1
  238. package/dist/components/thread-footer/ThreadFooter.module.scss.cjs +1 -1
  239. package/dist/components/thread-footer/ThreadFooter.module.scss.js +19 -19
  240. package/dist/components/tooltip/Tooltip.cjs.map +1 -1
  241. package/dist/components/tooltip/Tooltip.d.ts +1 -1
  242. package/dist/components/tooltip/Tooltip.d.ts.map +1 -1
  243. package/dist/components/tooltip/Tooltip.js.map +1 -1
  244. package/dist/components/tour-point/TourPoint.module.css +1 -1
  245. package/dist/components/tour-point/TourPoint.module.scss.cjs +1 -1
  246. package/dist/components/tour-point/TourPoint.module.scss.js +28 -28
  247. package/dist/index.cjs +1 -1
  248. package/dist/index.css +24 -8
  249. package/dist/index.d.ts +8 -1
  250. package/dist/index.d.ts.map +1 -1
  251. package/dist/index.js +192 -175
  252. package/dist/index.js.map +1 -1
  253. package/package.json +25 -4
  254. package/dist/components/message-reactions/MessageReactions.cjs +0 -2
  255. package/dist/components/message-reactions/MessageReactions.cjs.map +0 -1
  256. package/dist/components/message-reactions/MessageReactions.d.ts.map +0 -1
  257. package/dist/components/message-reactions/MessageReactions.js +0 -85
  258. package/dist/components/message-reactions/MessageReactions.js.map +0 -1
  259. package/dist/components/message-reactions/MessageReactions.module.css +0 -1
  260. package/dist/components/message-reactions/MessageReactions.module.scss.cjs +0 -2
  261. package/dist/components/message-reactions/MessageReactions.module.scss.cjs.map +0 -1
  262. package/dist/components/message-reactions/MessageReactions.module.scss.js +0 -18
  263. package/dist/components/message-reactions/MessageReactions.module.scss.js.map +0 -1
  264. package/dist/components/message-reactions/index.d.ts +0 -3
  265. package/dist/components/message-reactions/index.d.ts.map +0 -1
  266. package/dist/components/message-reactions/index.js +0 -5
  267. /package/dist/components/{message-reactions → card-button}/index.cjs.map +0 -0
  268. /package/dist/components/{message-reactions → emoji-button}/index.js.map +0 -0
@@ -0,0 +1,20 @@
1
+ import { ButtonHTMLAttributes, ReactNode } from 'react';
2
+ export interface CardButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'title'> {
3
+ /** Leading icon. Pass `<Icon glyph={<SomeIcon />} size="24" />` — the slot does not resize raw SVG children. */
4
+ icon: ReactNode;
5
+ /** Primary label. */
6
+ title: ReactNode;
7
+ /** Secondary line under the title. */
8
+ description?: ReactNode;
9
+ /** Selected / checked appearance with trailing check. Default: false. */
10
+ selected?: boolean;
11
+ className?: string;
12
+ }
13
+ /**
14
+ * Card Buttons present a mutually exclusive (or single) choice as a compact
15
+ * card: leading icon, title, optional description, and a check when selected.
16
+ * Pair with `CardButtonGroup` for side-by-side radiogroups (visibility,
17
+ * access mode, etc.).
18
+ */
19
+ export default function CardButton({ icon, title, description, selected, className, type, role, disabled, ...rest }: CardButtonProps): import("react/jsx-runtime").JSX.Element;
20
+ //# sourceMappingURL=CardButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardButton.d.ts","sourceRoot":"","sources":["../../../src/components/card-button/CardButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAK7D,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IAC3E,gHAAgH;IAChH,IAAI,EAAE,SAAS,CAAC;IAChB,qBAAqB;IACrB,KAAK,EAAE,SAAS,CAAC;IACjB,sCAAsC;IACtC,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,KAAK,EACL,WAAW,EACX,QAAgB,EAChB,SAAc,EACd,IAAe,EACf,IAAI,EACJ,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,eAAe,2CAoCjB"}
@@ -0,0 +1,45 @@
1
+ import { jsxs as c, jsx as t } from "react/jsx-runtime";
2
+ import __p from "@mattermost/compass-icons/components/check-circle.js";const p=__p&&__p.default?__p.default:__p;
3
+ import _ from "../icon/Icon.js";
4
+ import a from "./CardButton.module.scss.js";
5
+ function C({
6
+ icon: e,
7
+ title: i,
8
+ description: n,
9
+ selected: r = !1,
10
+ className: d = "",
11
+ type: l = "button",
12
+ role: o,
13
+ disabled: u,
14
+ ...m
15
+ }) {
16
+ const s = o === "radio", h = [
17
+ a["card-button"],
18
+ r && a["card-button--selected"],
19
+ d
20
+ ].filter(Boolean).join(" ");
21
+ return /* @__PURE__ */ c(
22
+ "button",
23
+ {
24
+ type: l,
25
+ role: o,
26
+ disabled: u,
27
+ className: h,
28
+ "aria-checked": s ? r : void 0,
29
+ "aria-pressed": s ? void 0 : r,
30
+ ...m,
31
+ children: [
32
+ /* @__PURE__ */ t("span", { className: a["card-button__icon"], "aria-hidden": !0, children: e }),
33
+ /* @__PURE__ */ c("span", { className: a["card-button__text"], children: [
34
+ /* @__PURE__ */ t("span", { className: a["card-button__title"], children: i }),
35
+ n != null && /* @__PURE__ */ t("span", { className: a["card-button__description"], children: n })
36
+ ] }),
37
+ /* @__PURE__ */ t("span", { className: a["card-button__check"], "aria-hidden": !0, children: /* @__PURE__ */ t(_, { glyph: /* @__PURE__ */ t(p, {}), size: "20" }) })
38
+ ]
39
+ }
40
+ );
41
+ }
42
+ export {
43
+ C as default
44
+ };
45
+ //# sourceMappingURL=CardButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardButton.js","sources":["../../../src/components/card-button/CardButton.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes, ReactNode } from 'react';\nimport CheckCircleIcon from '@mattermost/compass-icons/components/check-circle';\nimport Icon from '@/components/icon/Icon';\nimport styles from './CardButton.module.scss';\n\nexport interface CardButtonProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'title'> {\n /** Leading icon. Pass `<Icon glyph={<SomeIcon />} size=\"24\" />` — the slot does not resize raw SVG children. */\n icon: ReactNode;\n /** Primary label. */\n title: ReactNode;\n /** Secondary line under the title. */\n description?: ReactNode;\n /** Selected / checked appearance with trailing check. Default: false. */\n selected?: boolean;\n className?: string;\n}\n\n/**\n * Card Buttons present a mutually exclusive (or single) choice as a compact\n * card: leading icon, title, optional description, and a check when selected.\n * Pair with `CardButtonGroup` for side-by-side radiogroups (visibility,\n * access mode, etc.).\n */\nexport default function CardButton({\n icon,\n title,\n description,\n selected = false,\n className = '',\n type = 'button',\n role,\n disabled,\n ...rest\n}: CardButtonProps) {\n const isRadio = role === 'radio';\n const rootClass = [\n styles['card-button'],\n selected && styles['card-button--selected'],\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <button\n type={type}\n role={role}\n disabled={disabled}\n className={rootClass}\n aria-checked={isRadio ? selected : undefined}\n aria-pressed={!isRadio ? selected : undefined}\n {...rest}\n >\n <span className={styles['card-button__icon']} aria-hidden>\n {icon}\n </span>\n <span className={styles['card-button__text']}>\n <span className={styles['card-button__title']}>{title}</span>\n {description != null && (\n <span className={styles['card-button__description']}>\n {description}\n </span>\n )}\n </span>\n <span className={styles['card-button__check']} aria-hidden>\n <Icon glyph={<CheckCircleIcon />} size=\"20\" />\n </span>\n </button>\n );\n}\n"],"names":["CardButton","icon","title","description","selected","className","type","role","disabled","rest","isRadio","rootClass","styles","jsxs","jsx","Icon","CheckCircleIcon"],"mappings":";;;;AAwBA,SAAwBA,EAAW;AAAA,EACjC,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,MAAAC,IAAO;AAAA,EACP,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,GAAoB;AAClB,QAAMC,IAAUH,MAAS,SACnBI,IAAY;AAAA,IAChBC,EAAO,aAAa;AAAA,IACpBR,KAAYQ,EAAO,uBAAuB;AAAA,IAC1CP;AAAA,EAAA,EAEC,OAAO,OAAO,EACd,KAAK,GAAG;AAEX,SACE,gBAAAQ;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAAP;AAAA,MACA,MAAAC;AAAA,MACA,UAAAC;AAAA,MACA,WAAWG;AAAA,MACX,gBAAcD,IAAUN,IAAW;AAAA,MACnC,gBAAeM,IAAqB,SAAXN;AAAA,MACxB,GAAGK;AAAA,MAEJ,UAAA;AAAA,QAAA,gBAAAK,EAAC,UAAK,WAAWF,EAAO,mBAAmB,GAAG,eAAW,IACtD,UAAAX,GACH;AAAA,QACA,gBAAAY,EAAC,QAAA,EAAK,WAAWD,EAAO,mBAAmB,GACzC,UAAA;AAAA,UAAA,gBAAAE,EAAC,QAAA,EAAK,WAAWF,EAAO,oBAAoB,GAAI,UAAAV,GAAM;AAAA,UACrDC,KAAe,QACd,gBAAAW,EAAC,QAAA,EAAK,WAAWF,EAAO,0BAA0B,GAC/C,UAAAT,EAAA,CACH;AAAA,QAAA,GAEJ;AAAA,0BACC,QAAA,EAAK,WAAWS,EAAO,oBAAoB,GAAG,eAAW,IACxD,UAAA,gBAAAE,EAACC,GAAA,EAAK,OAAO,gBAAAD,EAACE,GAAA,CAAA,CAAgB,GAAI,MAAK,MAAK,EAAA,CAC9C;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -0,0 +1 @@
1
+ ._card-button_1l92t_2{-webkit-appearance:none;-moz-appearance:none;appearance:none;box-sizing:border-box;display:flex;flex-direction:row;align-items:center;gap:var(--spacing-m);margin:0;padding:var(--spacing-m) var(--spacing-xl) var(--spacing-m) var(--spacing-m);border:1px solid rgba(var(--center-channel-color-rgb),.16);border-radius:var(--radius-s);background-color:var(--center-channel-bg);box-shadow:var(--elevation-1);cursor:pointer;text-align:left;color:var(--center-channel-color);outline:2px solid color-mix(in srgb,var(--focus-ring-color) 0%,transparent);outline-offset:0;transition:border-color var(--duration-quick) var(--ease-transition),box-shadow var(--duration-quick) var(--ease-transition),background-color var(--duration-quick) var(--ease-transition),outline-color var(--duration-quick) var(--ease-transition),outline-offset var(--duration-quick) var(--ease-transition)}._card-button_1l92t_2:hover:not(:disabled):not(._card-button--selected_1l92t_22){border-color:rgba(var(--center-channel-color-rgb),.24);box-shadow:var(--elevation-2)}._card-button_1l92t_2:focus-visible{outline-color:var(--focus-ring-color);outline-offset:3px}._card-button_1l92t_2:disabled{cursor:not-allowed;opacity:.48}._card-button--selected_1l92t_22{border-color:rgba(var(--button-bg-rgb),.32)}._card-button--selected_1l92t_22 ._card-button__icon_1l92t_37{background-color:rgba(var(--button-bg-rgb),.08);color:var(--button-bg)}._card-button--selected_1l92t_22 ._card-button__check_1l92t_41{visibility:visible}._card-button__icon_1l92t_37{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;padding:var(--spacing-xs);border-radius:var(--radius-full);background-color:rgba(var(--center-channel-color-rgb),.08);color:rgba(var(--center-channel-color-rgb),.56)}._card-button__text_1l92t_54{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;align-items:flex-start;gap:0}._card-button__title_1l92t_62{font-family:var(--font-family-body);font-size:var(--font-size-100);font-weight:var(--font-weight-semibold);line-height:var(--line-height-100);color:var(--center-channel-color)}._card-button__description_1l92t_69{font-family:var(--font-family-body);font-size:var(--font-size-75);font-weight:var(--font-weight-regular);line-height:var(--line-height-75);color:rgba(var(--center-channel-color-rgb),.72)}._card-button__check_1l92t_41{flex-shrink:0;display:inline-flex;align-items:center;color:var(--button-bg);visibility:hidden}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./CardButton.module.css');const t={"card-button":"_card-button_1l92t_2","card-button--selected":"_card-button--selected_1l92t_22","card-button__icon":"_card-button__icon_1l92t_37","card-button__check":"_card-button__check_1l92t_41","card-button__text":"_card-button__text_1l92t_54","card-button__title":"_card-button__title_1l92t_62","card-button__description":"_card-button__description_1l92t_69"};exports.default=t;
2
+ //# sourceMappingURL=CardButton.module.scss.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardButton.module.scss.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import './CardButton.module.css';const t = {
2
+ "card-button": "_card-button_1l92t_2",
3
+ "card-button--selected": "_card-button--selected_1l92t_22",
4
+ "card-button__icon": "_card-button__icon_1l92t_37",
5
+ "card-button__check": "_card-button__check_1l92t_41",
6
+ "card-button__text": "_card-button__text_1l92t_54",
7
+ "card-button__title": "_card-button__title_1l92t_62",
8
+ "card-button__description": "_card-button__description_1l92t_69"
9
+ };
10
+ export {
11
+ t as default
12
+ };
13
+ //# sourceMappingURL=CardButton.module.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardButton.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=require("react/jsx-runtime"),k=require("react"),E=require("./CardButtonGroup.module.scss.cjs");function h(n){return[...n.querySelectorAll('[role="radio"]')]}function m(n){return h(n).filter(o=>!o.disabled)}function b(n,o){const a=h(n);if(a.length===0)return;const u=m(n),l=u.find(r=>r.getAttribute("aria-checked")==="true")??a.find(r=>r.getAttribute("aria-checked")==="true"),f=o&&a.includes(o)&&!o.disabled?o:l??u[0]??a[0];a.forEach(r=>{r.tabIndex=r===f?0:-1})}function S({children:n,className:o="",role:a="radiogroup",onKeyDown:u,onFocus:l,...f}){const r=k.useRef(null);k.useLayoutEffect(()=>{const e=r.current;e!=null&&b(e)},[n]);const p=e=>{l==null||l(e);const c=e.currentTarget;if(h(c).length===0)return;const t=e.target;if(!(t instanceof HTMLElement))return;const i=t.closest('[role="radio"]');i==null||!c.contains(i)||b(c,i)},A=e=>{if(u==null||u(e),e.defaultPrevented)return;const c=r.current;if(c==null)return;const t=m(c);if(t.length===0)return;const i=document.activeElement;if(!(i instanceof HTMLElement)||!c.contains(i))return;const v=i.closest('[role="radio"]'),g=t.findIndex(s=>s===v);if(g<0)return;const d=s=>{e.preventDefault(),b(c,s),s.focus({focusVisible:!0}),s.getAttribute("aria-checked")!=="true"&&s.click()};switch(e.key){case"ArrowRight":case"ArrowDown":d(t[(g+1)%t.length]);break;case"ArrowLeft":case"ArrowUp":d(t[(g-1+t.length)%t.length]);break;case"Home":d(t[0]);break;case"End":d(t[t.length-1]);break}};return R.jsx("div",{role:a,className:[E.default["card-button-group"],o].filter(Boolean).join(" "),...f,ref:r,onKeyDown:A,onFocus:p,children:n})}exports.default=S;
2
+ //# sourceMappingURL=CardButtonGroup.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardButtonGroup.cjs","sources":["../../../src/components/card-button/CardButtonGroup.tsx"],"sourcesContent":["import {\n useLayoutEffect,\n useRef,\n type FocusEvent,\n type HTMLAttributes,\n type KeyboardEvent,\n type ReactNode,\n} from 'react';\nimport styles from './CardButtonGroup.module.scss';\n\nexport interface CardButtonGroupProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n className?: string;\n}\n\nfunction radiosIn(group: ParentNode): HTMLButtonElement[] {\n return [...group.querySelectorAll<HTMLButtonElement>('[role=\"radio\"]')];\n}\n\nfunction enabledRadiosIn(group: ParentNode): HTMLButtonElement[] {\n return radiosIn(group).filter((radio) => !radio.disabled);\n}\n\nfunction syncRadioTabStops(group: HTMLElement, preferred?: HTMLButtonElement) {\n const radios = radiosIn(group);\n if (radios.length === 0) return;\n\n const enabled = enabledRadiosIn(group);\n const checked =\n enabled.find((radio) => radio.getAttribute('aria-checked') === 'true') ??\n radios.find((radio) => radio.getAttribute('aria-checked') === 'true');\n const tabStop =\n preferred && radios.includes(preferred) && !preferred.disabled\n ? preferred\n : (checked ?? enabled[0] ?? radios[0]);\n\n radios.forEach((radio) => {\n radio.tabIndex = radio === tabStop ? 0 : -1;\n });\n}\n\n/**\n * Lays out Card Buttons in a horizontal row (Figma Card Button Group).\n * Defaults to `role=\"radiogroup\"` — set child cards to `role=\"radio\"`.\n * When children use `role=\"radio\"`, applies the ARIA radio keyboard model\n * (roving tabindex + arrow selection with wrapping).\n */\nexport default function CardButtonGroup({\n children,\n className = '',\n role = 'radiogroup',\n onKeyDown,\n onFocus,\n ...rest\n}: CardButtonGroupProps) {\n const ref = useRef<HTMLDivElement>(null);\n\n useLayoutEffect(() => {\n const group = ref.current;\n if (group == null) return;\n syncRadioTabStops(group);\n }, [children]);\n\n const handleFocus = (e: FocusEvent<HTMLDivElement>) => {\n onFocus?.(e);\n const group = e.currentTarget;\n if (radiosIn(group).length === 0) return;\n const target = e.target;\n if (!(target instanceof HTMLElement)) return;\n const radio = target.closest<HTMLButtonElement>('[role=\"radio\"]');\n if (radio == null || !group.contains(radio)) return;\n syncRadioTabStops(group, radio);\n };\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n const group = ref.current;\n if (group == null) return;\n const radios = enabledRadiosIn(group);\n if (radios.length === 0) return;\n\n const active = document.activeElement;\n if (!(active instanceof HTMLElement) || !group.contains(active)) return;\n const radio = active.closest<HTMLButtonElement>('[role=\"radio\"]');\n const index = radios.findIndex((r) => r === radio);\n if (index < 0) return;\n\n const selectRadio = (next: HTMLButtonElement) => {\n e.preventDefault();\n syncRadioTabStops(group, next);\n next.focus({ focusVisible: true } as FocusOptions);\n if (next.getAttribute('aria-checked') !== 'true') {\n next.click();\n }\n };\n\n switch (e.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n selectRadio(radios[(index + 1) % radios.length]);\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n selectRadio(radios[(index - 1 + radios.length) % radios.length]);\n break;\n case 'Home':\n selectRadio(radios[0]);\n break;\n case 'End':\n selectRadio(radios[radios.length - 1]);\n break;\n default:\n break;\n }\n };\n\n return (\n <div\n role={role}\n className={[styles['card-button-group'], className]\n .filter(Boolean)\n .join(' ')}\n {...rest}\n ref={ref}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n >\n {children}\n </div>\n );\n}\n"],"names":["radiosIn","group","enabledRadiosIn","radio","syncRadioTabStops","preferred","radios","enabled","checked","tabStop","CardButtonGroup","children","className","role","onKeyDown","onFocus","rest","ref","useRef","useLayoutEffect","handleFocus","target","handleKeyDown","active","index","r","selectRadio","next","jsx","styles"],"mappings":"mNAeA,SAASA,EAASC,EAAwC,CACxD,MAAO,CAAC,GAAGA,EAAM,iBAAoC,gBAAgB,CAAC,CACxE,CAEA,SAASC,EAAgBD,EAAwC,CAC/D,OAAOD,EAASC,CAAK,EAAE,OAAQE,GAAU,CAACA,EAAM,QAAQ,CAC1D,CAEA,SAASC,EAAkBH,EAAoBI,EAA+B,CAC5E,MAAMC,EAASN,EAASC,CAAK,EAC7B,GAAIK,EAAO,SAAW,EAAG,OAEzB,MAAMC,EAAUL,EAAgBD,CAAK,EAC/BO,EACJD,EAAQ,KAAMJ,GAAUA,EAAM,aAAa,cAAc,IAAM,MAAM,GACrEG,EAAO,KAAMH,GAAUA,EAAM,aAAa,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AeC,GAA4B,CAC/C,EAAE,eAAA,EACFvB,EAAkBH,EAAO0B,CAAI,EAC7BA,EAAK,MAAM,CAAE,aAAc,EAAA,CAAsB,EAC7CA,EAAK,aAAa,cAAc,IAAM,QACxCA,EAAK,MAAA,CAET,EAEA,OAAQ,EAAE,IAAA,CACR,IAAK,aACL,IAAK,YACHD,EAAYpB,GAAQkB,EAAQ,GAAKlB,EAAO,MAAM,CAAC,EAC/C,MACF,IAAK,YACL,IAAK,UACHoB,EAAYpB,GAAQkB,EAAQ,EAAIlB,EAAO,QAAUA,EAAO,MAAM,CAAC,EAC/D,MACF,IAAK,OACHoB,EAAYpB,EAAO,CAAC,CAAC,EACrB,MACF,IAAK,MACHoB,EAAYpB,EAAOA,EAAO,OAAS,CAAC,CAAC,EACrC,KAEA,CAEN,EAEA,OACEsB,EAAAA,IAAC,MAAA,CACC,KAAAf,EACA,UAAW,CAACgB,UAAO,mBAAmB,EAAGjB,CAAS,EAC/C,OAAO,OAAO,EACd,KAAK,GAAG,EACV,GAAGI,EACJ,IAAAC,EACA,UAAWK,EACX,QAASF,EAER,SAAAT,CAAA,CAAA,CAGP"}
@@ -0,0 +1,13 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ export interface CardButtonGroupProps extends HTMLAttributes<HTMLDivElement> {
3
+ children: ReactNode;
4
+ className?: string;
5
+ }
6
+ /**
7
+ * Lays out Card Buttons in a horizontal row (Figma Card Button Group).
8
+ * Defaults to `role="radiogroup"` — set child cards to `role="radio"`.
9
+ * When children use `role="radio"`, applies the ARIA radio keyboard model
10
+ * (roving tabindex + arrow selection with wrapping).
11
+ */
12
+ export default function CardButtonGroup({ children, className, role, onKeyDown, onFocus, ...rest }: CardButtonGroupProps): import("react/jsx-runtime").JSX.Element;
13
+ //# sourceMappingURL=CardButtonGroup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardButtonGroup.d.ts","sourceRoot":"","sources":["../../../src/components/card-button/CardButtonGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EAEnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,MAAM,WAAW,oBAAqB,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC1E,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA4BD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,QAAQ,EACR,SAAc,EACd,IAAmB,EACnB,SAAS,EACT,OAAO,EACP,GAAG,IAAI,EACR,EAAE,oBAAoB,2CA8EtB"}
@@ -0,0 +1,85 @@
1
+ import { jsx as E } from "react/jsx-runtime";
2
+ import { useRef as v, useLayoutEffect as R } from "react";
3
+ import w from "./CardButtonGroup.module.scss.js";
4
+ function h(n) {
5
+ return [...n.querySelectorAll('[role="radio"]')];
6
+ }
7
+ function m(n) {
8
+ return h(n).filter((o) => !o.disabled);
9
+ }
10
+ function b(n, o) {
11
+ const a = h(n);
12
+ if (a.length === 0) return;
13
+ const s = m(n), l = s.find((r) => r.getAttribute("aria-checked") === "true") ?? a.find((r) => r.getAttribute("aria-checked") === "true"), f = o && a.includes(o) && !o.disabled ? o : l ?? s[0] ?? a[0];
14
+ a.forEach((r) => {
15
+ r.tabIndex = r === f ? 0 : -1;
16
+ });
17
+ }
18
+ function y({
19
+ children: n,
20
+ className: o = "",
21
+ role: a = "radiogroup",
22
+ onKeyDown: s,
23
+ onFocus: l,
24
+ ...f
25
+ }) {
26
+ const r = v(null);
27
+ R(() => {
28
+ const e = r.current;
29
+ e != null && b(e);
30
+ }, [n]);
31
+ const k = (e) => {
32
+ l == null || l(e);
33
+ const c = e.currentTarget;
34
+ if (h(c).length === 0) return;
35
+ const t = e.target;
36
+ if (!(t instanceof HTMLElement)) return;
37
+ const i = t.closest('[role="radio"]');
38
+ i == null || !c.contains(i) || b(c, i);
39
+ }, p = (e) => {
40
+ if (s == null || s(e), e.defaultPrevented) return;
41
+ const c = r.current;
42
+ if (c == null) return;
43
+ const t = m(c);
44
+ if (t.length === 0) return;
45
+ const i = document.activeElement;
46
+ if (!(i instanceof HTMLElement) || !c.contains(i)) return;
47
+ const A = i.closest('[role="radio"]'), g = t.findIndex((u) => u === A);
48
+ if (g < 0) return;
49
+ const d = (u) => {
50
+ e.preventDefault(), b(c, u), u.focus({ focusVisible: !0 }), u.getAttribute("aria-checked") !== "true" && u.click();
51
+ };
52
+ switch (e.key) {
53
+ case "ArrowRight":
54
+ case "ArrowDown":
55
+ d(t[(g + 1) % t.length]);
56
+ break;
57
+ case "ArrowLeft":
58
+ case "ArrowUp":
59
+ d(t[(g - 1 + t.length) % t.length]);
60
+ break;
61
+ case "Home":
62
+ d(t[0]);
63
+ break;
64
+ case "End":
65
+ d(t[t.length - 1]);
66
+ break;
67
+ }
68
+ };
69
+ return /* @__PURE__ */ E(
70
+ "div",
71
+ {
72
+ role: a,
73
+ className: [w["card-button-group"], o].filter(Boolean).join(" "),
74
+ ...f,
75
+ ref: r,
76
+ onKeyDown: p,
77
+ onFocus: k,
78
+ children: n
79
+ }
80
+ );
81
+ }
82
+ export {
83
+ y as default
84
+ };
85
+ //# sourceMappingURL=CardButtonGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardButtonGroup.js","sources":["../../../src/components/card-button/CardButtonGroup.tsx"],"sourcesContent":["import {\n useLayoutEffect,\n useRef,\n type FocusEvent,\n type HTMLAttributes,\n type KeyboardEvent,\n type ReactNode,\n} from 'react';\nimport styles from './CardButtonGroup.module.scss';\n\nexport interface CardButtonGroupProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n className?: string;\n}\n\nfunction radiosIn(group: ParentNode): HTMLButtonElement[] {\n return [...group.querySelectorAll<HTMLButtonElement>('[role=\"radio\"]')];\n}\n\nfunction enabledRadiosIn(group: ParentNode): HTMLButtonElement[] {\n return radiosIn(group).filter((radio) => !radio.disabled);\n}\n\nfunction syncRadioTabStops(group: HTMLElement, preferred?: HTMLButtonElement) {\n const radios = radiosIn(group);\n if (radios.length === 0) return;\n\n const enabled = enabledRadiosIn(group);\n const checked =\n enabled.find((radio) => radio.getAttribute('aria-checked') === 'true') ??\n radios.find((radio) => radio.getAttribute('aria-checked') === 'true');\n const tabStop =\n preferred && radios.includes(preferred) && !preferred.disabled\n ? preferred\n : (checked ?? enabled[0] ?? radios[0]);\n\n radios.forEach((radio) => {\n radio.tabIndex = radio === tabStop ? 0 : -1;\n });\n}\n\n/**\n * Lays out Card Buttons in a horizontal row (Figma Card Button Group).\n * Defaults to `role=\"radiogroup\"` — set child cards to `role=\"radio\"`.\n * When children use `role=\"radio\"`, applies the ARIA radio keyboard model\n * (roving tabindex + arrow selection with wrapping).\n */\nexport default function CardButtonGroup({\n children,\n className = '',\n role = 'radiogroup',\n onKeyDown,\n onFocus,\n ...rest\n}: CardButtonGroupProps) {\n const ref = useRef<HTMLDivElement>(null);\n\n useLayoutEffect(() => {\n const group = ref.current;\n if (group == null) return;\n syncRadioTabStops(group);\n }, [children]);\n\n const handleFocus = (e: FocusEvent<HTMLDivElement>) => {\n onFocus?.(e);\n const group = e.currentTarget;\n if (radiosIn(group).length === 0) return;\n const target = e.target;\n if (!(target instanceof HTMLElement)) return;\n const radio = target.closest<HTMLButtonElement>('[role=\"radio\"]');\n if (radio == null || !group.contains(radio)) return;\n syncRadioTabStops(group, radio);\n };\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n const group = ref.current;\n if (group == null) return;\n const radios = enabledRadiosIn(group);\n if (radios.length === 0) return;\n\n const active = document.activeElement;\n if (!(active instanceof HTMLElement) || !group.contains(active)) return;\n const radio = active.closest<HTMLButtonElement>('[role=\"radio\"]');\n const index = radios.findIndex((r) => r === radio);\n if (index < 0) return;\n\n const selectRadio = (next: HTMLButtonElement) => {\n e.preventDefault();\n syncRadioTabStops(group, next);\n next.focus({ focusVisible: true } as FocusOptions);\n if (next.getAttribute('aria-checked') !== 'true') {\n next.click();\n }\n };\n\n switch (e.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n selectRadio(radios[(index + 1) % radios.length]);\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n selectRadio(radios[(index - 1 + radios.length) % radios.length]);\n break;\n case 'Home':\n selectRadio(radios[0]);\n break;\n case 'End':\n selectRadio(radios[radios.length - 1]);\n break;\n default:\n break;\n }\n };\n\n return (\n <div\n role={role}\n className={[styles['card-button-group'], className]\n .filter(Boolean)\n .join(' ')}\n {...rest}\n ref={ref}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n >\n {children}\n </div>\n );\n}\n"],"names":["radiosIn","group","enabledRadiosIn","radio","syncRadioTabStops","preferred","radios","enabled","checked","tabStop","CardButtonGroup","children","className","role","onKeyDown","onFocus","rest","ref","useRef","useLayoutEffect","handleFocus","target","handleKeyDown","active","index","r","selectRadio","next","jsx","styles"],"mappings":";;;AAeA,SAASA,EAASC,GAAwC;AACxD,SAAO,CAAC,GAAGA,EAAM,iBAAoC,gBAAgB,CAAC;AACxE;AAEA,SAASC,EAAgBD,GAAwC;AAC/D,SAAOD,EAASC,CAAK,EAAE,OAAO,CAACE,MAAU,CAACA,EAAM,QAAQ;AAC1D;AAEA,SAASC,EAAkBH,GAAoBI,GAA+B;AAC5E,QAAMC,IAASN,EAASC,CAAK;AAC7B,MAAIK,EAAO,WAAW,EAAG;AAEzB,QAAMC,IAAUL,EAAgBD,CAAK,GAC/BO,IACJD,EAAQ,KAAK,CAACJ,MAAUA,EAAM,aAAa,cAAc,MAAM,MAAM,KACrEG,EAAO,KAAK,CAACH,MAAUA,EAAM,aAAa,cAAc,MAAM,MAAM,GAChEM,IACJJ,KAAaC,EAAO,SAASD,CAAS,KAAK,CAACA,EAAU,WAClDA,IACCG,KAAWD,EAAQ,CAAC,KAAKD,EAAO,CAAC;AAExC,EAAAA,EAAO,QAAQ,CAACH,MAAU;AACxB,IAAAA,EAAM,WAAWA,MAA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,GAAA,CAAsB,GAC7CA,EAAK,aAAa,cAAc,MAAM,UACxCA,EAAK,MAAA;AAAA,IAET;AAEA,YAAQ,EAAE,KAAA;AAAA,MACR,KAAK;AAAA,MACL,KAAK;AACH,QAAAD,EAAYpB,GAAQkB,IAAQ,KAAKlB,EAAO,MAAM,CAAC;AAC/C;AAAA,MACF,KAAK;AAAA,MACL,KAAK;AACH,QAAAoB,EAAYpB,GAAQkB,IAAQ,IAAIlB,EAAO,UAAUA,EAAO,MAAM,CAAC;AAC/D;AAAA,MACF,KAAK;AACH,QAAAoB,EAAYpB,EAAO,CAAC,CAAC;AACrB;AAAA,MACF,KAAK;AACH,QAAAoB,EAAYpB,EAAOA,EAAO,SAAS,CAAC,CAAC;AACrC;AAAA,IAEA;AAAA,EAEN;AAEA,SACE,gBAAAsB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAAf;AAAA,MACA,WAAW,CAACgB,EAAO,mBAAmB,GAAGjB,CAAS,EAC/C,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,MACV,GAAGI;AAAA,MACJ,KAAAC;AAAA,MACA,WAAWK;AAAA,MACX,SAASF;AAAA,MAER,UAAAT;AAAA,IAAA;AAAA,EAAA;AAGP;"}
@@ -0,0 +1 @@
1
+ ._card-button-group_1cufe_2{display:flex;flex-direction:row;align-items:stretch;gap:var(--spacing-xs);width:100%}._card-button-group_1cufe_2>*{flex:1 1 0;min-width:0}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./CardButtonGroup.module.css');const e={"card-button-group":"_card-button-group_1cufe_2"};exports.default=e;
2
+ //# sourceMappingURL=CardButtonGroup.module.scss.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardButtonGroup.module.scss.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import './CardButtonGroup.module.css';const t = {
2
+ "card-button-group": "_card-button-group_1cufe_2"
3
+ };
4
+ export {
5
+ t as default
6
+ };
7
+ //# sourceMappingURL=CardButtonGroup.module.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardButtonGroup.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./CardButton.cjs"),r=require("./CardButtonGroup.cjs");exports.CardButton=t.default;exports.CardButtonGroup=r.default;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,5 @@
1
+ export { default as CardButton } from './CardButton';
2
+ export type { CardButtonProps } from './CardButton';
3
+ export { default as CardButtonGroup } from './CardButtonGroup';
4
+ export type { CardButtonGroupProps } from './CardButtonGroup';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/card-button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { default as r } from "./CardButton.js";
2
+ import { default as u } from "./CardButtonGroup.js";
3
+ export {
4
+ r as CardButton,
5
+ u as CardButtonGroup
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),j=require("react"),__q=require("@mattermost/compass-icons/components/close-circle.js"),q=__q?.default??__q,M=require("../icon/Icon.cjs"),A=require("../user-avatar/UserAvatar.cjs"),I=require("../../utils/string.cjs"),g=require("./ChipGroup.cjs"),u=require("./Chip.module.scss.cjs"),D={small:"10",medium:"12","medium-compact":"12",large:"16"},k={small:"12",medium:"16","medium-compact":"16",large:"20"};function y(n){return typeof n=="string"||typeof n=="number"?String(n).trim():Array.isArray(n)?n.map(y).filter(Boolean).join(" "):""}function w(n){var d;const s=(m,b)=>{let e=m;for(;e;){if(e instanceof HTMLElement&&e.dataset.chip!=null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return e;e=b==="next"?e.nextElementSibling:e.previousElementSibling}return null},l=n.parentElement,o=l==null?void 0:l.nextElementSibling,r=o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement?o:null;return s(n.nextElementSibling,"next")??s(n.previousElementSibling,"previous")??r??(l==null?void 0:l.querySelector("input, textarea"))??((d=l==null?void 0:l.parentElement)==null?void 0:d.querySelector("input, textarea"))??null}function L({children:n,size:s="medium",leadingIcon:l,leadingAvatar:o,onRemove:r,error:d=!1,colored:m=!1,className:b="",...e}){const x=j.useContext(g.ChipGroupContext),h=D[s],T=k[s],f=y(n),S=e["aria-label"]??(r!=null&&f!==""?`${f}. Press Delete to remove.`:f!==""?f:void 0),p=r!=null,_=t=>{const c=t.currentTarget.closest("[data-chip]"),i=c instanceof HTMLElement?w(c):null,v=t.currentTarget;r==null||r(t),window.setTimeout(()=>{v.isConnected||i==null||i.isConnected&&(i.dataset.chip!=null?g.activateChip(i):i.focus({focusVisible:!0}))},0)},C=[u.default.chip,u.default[`chip--size-${I.toKebab(s)}`],d&&u.default["chip--error"],m&&u.default["chip--colored"],b].filter(Boolean).join(" "),E=t=>{var c,i;(c=e.onKeyDown)==null||c.call(e,t),!(x||!p||t.defaultPrevented)&&(t.key==="Delete"||t.key==="Backspace"||t.key==="Enter"||t.key===" ")&&(t.preventDefault(),(i=t.currentTarget.querySelector("[data-chip-remove]"))==null||i.click())};return a.jsxs("div",{className:C,...e,role:p?"button":e.role,tabIndex:p?x?-1:0:e.tabIndex,"aria-label":p?S:e["aria-label"],"data-chip":"",onKeyDown:E,children:[o!=null?a.jsx("span",{className:u.default["chip__avatar-slot"],children:a.jsx(A.default,{src:o.src,alt:o.alt,size:T})}):l!=null?a.jsx("span",{className:u.default["chip__icon-slot"],"aria-hidden":!0,children:a.jsx(M.default,{glyph:l,size:h})}):null,a.jsx("span",{className:u.default.chip__label,children:n}),r!=null?a.jsx("button",{type:"button",className:u.default.chip__remove,"data-chip-remove":"",tabIndex:-1,"aria-hidden":!0,onMouseDown:t=>{t.preventDefault()},onClick:_,children:a.jsx(q,{size:Number(h),"aria-hidden":!0})}):null]})}exports.default=L;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),q=require("react"),__M=require("@mattermost/compass-icons/components/close-circle.js"),M=__M?.default??__M,A=require("../icon/Icon.cjs"),I=require("../user-avatar/UserAvatar.cjs"),D=require("../../utils/string.cjs"),y=require("./ChipGroup.cjs"),a=require("./Chip.module.scss.cjs"),k={small:"10",medium:"12",large:"16"},w={small:"12",medium:"16",large:"20"};function T(t){return typeof t=="string"||typeof t=="number"?String(t).trim():Array.isArray(t)?t.map(T).filter(Boolean).join(" "):""}function L(t){var r;const s=(b,h)=>{let n=b;for(;n;){if(n instanceof HTMLElement&&n.dataset.chip!=null||n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;n=h==="next"?n.nextElementSibling:n.previousElementSibling}return null},l=t.parentElement,c=l==null?void 0:l.nextElementSibling,f=c instanceof HTMLInputElement||c instanceof HTMLTextAreaElement?c:null;return s(t.nextElementSibling,"next")??s(t.previousElementSibling,"previous")??f??(l==null?void 0:l.querySelector("input, textarea"))??((r=l==null?void 0:l.parentElement)==null?void 0:r.querySelector("input, textarea"))??null}function N({children:t,size:s="medium",compact:l=!1,leadingIcon:c,leadingAvatar:f,onRemove:r,error:b=!1,colored:h=!1,className:n="",...i}){const x=q.useContext(y.ChipGroupContext),g=k[s],S=w[s],p=T(t),_=i["aria-label"]??(r!=null&&p!==""?`${p}. Press Delete to remove.`:p!==""?p:void 0),m=r!=null,C=e=>{const d=e.currentTarget.closest("[data-chip]"),u=d instanceof HTMLElement?L(d):null,j=e.currentTarget;r==null||r(e),window.setTimeout(()=>{j.isConnected||u==null||u.isConnected&&(u.dataset.chip!=null?y.activateChip(u):u.focus({focusVisible:!0}))},0)},E=[a.default.chip,a.default[`chip--size-${D.toKebab(s)}`],l&&a.default["chip--compact"],b&&a.default["chip--error"],h&&a.default["chip--colored"],n].filter(Boolean).join(" "),v=e=>{var d,u;(d=i.onKeyDown)==null||d.call(i,e),!(x||!m||e.defaultPrevented)&&(e.key==="Delete"||e.key==="Backspace"||e.key==="Enter"||e.key===" ")&&(e.preventDefault(),(u=e.currentTarget.querySelector("[data-chip-remove]"))==null||u.click())};return o.jsxs("div",{className:E,...i,role:m?"button":i.role,tabIndex:m?x?-1:0:i.tabIndex,"aria-label":m?_:i["aria-label"],"data-chip":"",onKeyDown:v,children:[f!=null?o.jsx("span",{className:a.default["chip__avatar-slot"],children:o.jsx(I.default,{src:f.src,alt:f.alt,size:S})}):c!=null?o.jsx("span",{className:a.default["chip__icon-slot"],"aria-hidden":!0,children:o.jsx(A.default,{glyph:c,size:g})}):null,o.jsx("span",{className:a.default.chip__label,children:t}),r!=null?o.jsx("button",{type:"button",className:a.default.chip__remove,"data-chip-remove":"",tabIndex:-1,"aria-hidden":!0,onMouseDown:e=>{e.preventDefault()},onClick:C,children:o.jsx(M,{size:Number(g),"aria-hidden":!0})}):null]})}exports.default=N;
2
2
  //# sourceMappingURL=Chip.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Chip.cjs","sources":["../../../src/components/chip/Chip.tsx"],"sourcesContent":["import { useContext, type HTMLAttributes, type KeyboardEvent, type MouseEvent, type ReactNode } from 'react';\nimport CloseCircleIcon from '@mattermost/compass-icons/components/close-circle';\nimport Icon from '@/components/icon/Icon';\nimport type { IconSize } from '@/components/icon/Icon';\nimport UserAvatar from '@/components/user-avatar/UserAvatar';\nimport type { UserAvatarSize } from '@/components/user-avatar/UserAvatar';\nimport { toKebab } from '@/utils/string';\nimport { activateChip, ChipGroupContext } from './ChipGroup';\nimport styles from './Chip.module.scss';\n\nexport type ChipSize = 'small' | 'medium' | 'medium-compact' | 'large';\n\nexport interface ChipProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'children'\n> {\n /** Chip label. */\n children: ReactNode;\n /** Visual size. Default: Medium. */\n size?: ChipSize;\n /** Leading icon from @mattermost/compass-icons. */\n leadingIcon?: ReactNode;\n /** Leading avatar. Overrides leading-icon when both are provided. */\n leadingAvatar?: { src: string; alt: string };\n /** When provided, shows the remove (×) control and calls this on click. */\n onRemove?: (e: MouseEvent<HTMLButtonElement>) => void;\n /** Shows an error border. */\n error?: boolean;\n /** Adds a colored background overlay. */\n colored?: boolean;\n className?: string;\n}\n\nconst ICON_SIZE_MAP: Record<ChipSize, IconSize> = {\n small: '10',\n medium: '12',\n 'medium-compact': '12',\n large: '16',\n};\n\nconst AVATAR_SIZE_MAP: Record<ChipSize, UserAvatarSize> = {\n small: '12',\n medium: '16',\n 'medium-compact': '16',\n large: '20',\n};\n\nfunction labelTextFromChildren(children: ReactNode): string {\n if (typeof children === 'string' || typeof children === 'number') {\n return String(children).trim();\n }\n if (Array.isArray(children)) {\n return children.map(labelTextFromChildren).filter(Boolean).join(' ');\n }\n return '';\n}\n\nfunction focusTargetAfterRemove(chipEl: HTMLElement): HTMLElement | null {\n const scan = (\n start: Element | null,\n direction: 'next' | 'previous',\n ): HTMLElement | null => {\n let el: Element | null = start;\n while (el) {\n if (el instanceof HTMLElement && el.dataset.chip != null) {\n return el;\n }\n if (\n el instanceof HTMLInputElement ||\n el instanceof HTMLTextAreaElement\n ) {\n return el;\n }\n el =\n direction === 'next' ? el.nextElementSibling : el.previousElementSibling;\n }\n return null;\n };\n\n const parent = chipEl.parentElement;\n const afterGroup = parent?.nextElementSibling;\n const groupSiblingInput =\n afterGroup instanceof HTMLInputElement ||\n afterGroup instanceof HTMLTextAreaElement\n ? afterGroup\n : null;\n\n return (\n scan(chipEl.nextElementSibling, 'next') ??\n scan(chipEl.previousElementSibling, 'previous') ??\n groupSiblingInput ??\n parent?.querySelector('input, textarea') ??\n parent?.parentElement?.querySelector('input, textarea') ??\n null\n );\n}\n\n/**\n * Chips are compact, self-contained tokens that represent a selection — a person added to an\n * invite, a filter applied to a search, a chosen value in a tokenizing input. Each Chip\n * stands on its own and is removable or selectable, depending on context.\n */\nexport default function Chip({\n children,\n size = 'medium',\n leadingIcon,\n leadingAvatar,\n onRemove,\n error = false,\n colored = false,\n className = '',\n ...rest\n}: ChipProps) {\n const grouped = useContext(ChipGroupContext);\n const iconSize = ICON_SIZE_MAP[size];\n const avatarSize = AVATAR_SIZE_MAP[size];\n const labelText = labelTextFromChildren(children);\n const groupedAriaLabel =\n rest['aria-label'] ??\n (onRemove != null && labelText !== ''\n ? `${labelText}. Press Delete to remove.`\n : labelText !== ''\n ? labelText\n : undefined);\n const removable = onRemove != null;\n\n const handleRemove = (e: MouseEvent<HTMLButtonElement>) => {\n const chipEl = e.currentTarget.closest('[data-chip]');\n const nextFocus =\n chipEl instanceof HTMLElement ? focusTargetAfterRemove(chipEl) : null;\n const removeButton = e.currentTarget;\n onRemove?.(e);\n window.setTimeout(() => {\n if (removeButton.isConnected || nextFocus == null) return;\n if (!nextFocus.isConnected) return;\n if (nextFocus.dataset.chip != null) {\n activateChip(nextFocus);\n } else {\n nextFocus.focus({ focusVisible: true } as FocusOptions);\n }\n }, 0);\n };\n\n const rootClass = [\n styles.chip,\n styles[`chip--size-${toKebab(size)}`],\n error && styles['chip--error'],\n colored && styles['chip--colored'],\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n rest.onKeyDown?.(e);\n if (grouped || !removable || e.defaultPrevented) return;\n if (\n e.key === 'Delete' ||\n e.key === 'Backspace' ||\n e.key === 'Enter' ||\n e.key === ' '\n ) {\n e.preventDefault();\n e.currentTarget\n .querySelector<HTMLButtonElement>('[data-chip-remove]')\n ?.click();\n }\n };\n\n return (\n <div\n className={rootClass}\n {...rest}\n role={removable ? 'button' : rest.role}\n tabIndex={removable ? (grouped ? -1 : 0) : rest.tabIndex}\n aria-label={removable ? groupedAriaLabel : rest['aria-label']}\n data-chip=\"\"\n onKeyDown={handleKeyDown}\n >\n {leadingAvatar != null ? (\n <span className={styles['chip__avatar-slot']}>\n <UserAvatar\n src={leadingAvatar.src}\n alt={leadingAvatar.alt}\n size={avatarSize}\n />\n </span>\n ) : leadingIcon != null ? (\n <span className={styles['chip__icon-slot']} aria-hidden>\n <Icon glyph={leadingIcon} size={iconSize} />\n </span>\n ) : null}\n <span className={styles['chip__label']}>{children}</span>\n {onRemove != null ? (\n <button\n type=\"button\"\n className={styles['chip__remove']}\n data-chip-remove=\"\"\n tabIndex={-1}\n aria-hidden\n onMouseDown={(e) => {\n e.preventDefault();\n }}\n onClick={handleRemove}\n >\n <CloseCircleIcon size={Number(iconSize)} aria-hidden />\n </button>\n ) : null}\n </div>\n );\n}\n"],"names":["ICON_SIZE_MAP","AVATAR_SIZE_MAP","labelTextFromChildren","children","focusTargetAfterRemove","chipEl","scan","start","direction","el","parent","afterGroup","groupSiblingInput","_a","Chip","size","leadingIcon","leadingAvatar","onRemove","error","colored","className","rest","grouped","useContext","ChipGroupContext","iconSize","avatarSize","labelText","groupedAriaLabel","removable","handleRemove","e","nextFocus","removeButton","activateChip","rootClass","styles","toKebab","handleKeyDown","_b","jsxs","jsx","UserAvatar","Icon","CloseCircleIcon"],"mappings":"gZAiCMA,EAA4C,CAChD,MAAO,KACP,OAAQ,KACR,iBAAkB,KAClB,MAAO,IACT,EAEMC,EAAoD,CACxD,MAAO,KACP,OAAQ,KACR,iBAAkB,KAClB,MAAO,IACT,EAEA,SAASC,EAAsBC,EAA6B,CAC1D,OAA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AA,QAAO,iBAAiB,EAAG,cAAW,GACrD,eAACO,EAAAA,QAAA,CAAK,MAAO5B,EAAa,KAAMU,CAAA,CAAU,EAC5C,EACE,WACH,OAAA,CAAK,UAAWW,EAAAA,QAAO,YAAiB,SAAAlC,EAAS,EACjDe,GAAY,KACXwB,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,UAAWL,EAAAA,QAAO,aAClB,mBAAiB,GACjB,SAAU,GACV,cAAW,GACX,YAAcL,GAAM,CAClBA,EAAE,eAAA,CACJ,EACA,QAASD,EAET,eAACc,EAAA,CAAgB,KAAM,OAAOnB,CAAQ,EAAG,cAAW,EAAA,CAAC,CAAA,CAAA,EAErD,IAAA,CAAA,CAAA,CAGV"}
1
+ {"version":3,"file":"Chip.cjs","sources":["../../../src/components/chip/Chip.tsx"],"sourcesContent":["import { useContext, type HTMLAttributes, type KeyboardEvent, type MouseEvent, type ReactNode } from 'react';\nimport CloseCircleIcon from '@mattermost/compass-icons/components/close-circle';\nimport Icon from '@/components/icon/Icon';\nimport type { IconSize } from '@/components/icon/Icon';\nimport UserAvatar from '@/components/user-avatar/UserAvatar';\nimport type { UserAvatarSize } from '@/components/user-avatar/UserAvatar';\nimport { toKebab } from '@/utils/string';\nimport { activateChip, ChipGroupContext } from './ChipGroup';\nimport styles from './Chip.module.scss';\n\nexport type ChipSize = 'small' | 'medium' | 'large';\n\nexport interface ChipProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'children'\n> {\n /** Chip label. */\n children: ReactNode;\n /** Visual size. Default: Medium. */\n size?: ChipSize;\n /** Reduces vertical and horizontal padding. */\n compact?: boolean;\n /** Leading icon from @mattermost/compass-icons. */\n leadingIcon?: ReactNode;\n /** Leading avatar. Overrides leading-icon when both are provided. */\n leadingAvatar?: { src: string; alt: string };\n /** When provided, shows the remove (×) control and calls this on click. */\n onRemove?: (e: MouseEvent<HTMLButtonElement>) => void;\n /** Shows an error border. */\n error?: boolean;\n /** Adds a colored background overlay. */\n colored?: boolean;\n className?: string;\n}\n\nconst ICON_SIZE_MAP: Record<ChipSize, IconSize> = {\n small: '10',\n medium: '12',\n large: '16',\n};\n\nconst AVATAR_SIZE_MAP: Record<ChipSize, UserAvatarSize> = {\n small: '12',\n medium: '16',\n large: '20',\n};\n\nfunction labelTextFromChildren(children: ReactNode): string {\n if (typeof children === 'string' || typeof children === 'number') {\n return String(children).trim();\n }\n if (Array.isArray(children)) {\n return children.map(labelTextFromChildren).filter(Boolean).join(' ');\n }\n return '';\n}\n\nfunction focusTargetAfterRemove(chipEl: HTMLElement): HTMLElement | null {\n const scan = (\n start: Element | null,\n direction: 'next' | 'previous',\n ): HTMLElement | null => {\n let el: Element | null = start;\n while (el) {\n if (el instanceof HTMLElement && el.dataset.chip != null) {\n return el;\n }\n if (\n el instanceof HTMLInputElement ||\n el instanceof HTMLTextAreaElement\n ) {\n return el;\n }\n el =\n direction === 'next' ? el.nextElementSibling : el.previousElementSibling;\n }\n return null;\n };\n\n const parent = chipEl.parentElement;\n const afterGroup = parent?.nextElementSibling;\n const groupSiblingInput =\n afterGroup instanceof HTMLInputElement ||\n afterGroup instanceof HTMLTextAreaElement\n ? afterGroup\n : null;\n\n return (\n scan(chipEl.nextElementSibling, 'next') ??\n scan(chipEl.previousElementSibling, 'previous') ??\n groupSiblingInput ??\n parent?.querySelector('input, textarea') ??\n parent?.parentElement?.querySelector('input, textarea') ??\n null\n );\n}\n\n/**\n * Chips are compact, self-contained tokens that represent a selection — a person added to an\n * invite, a filter applied to a search, a chosen value in a tokenizing input. Each Chip\n * stands on its own and is removable or selectable, depending on context.\n */\nexport default function Chip({\n children,\n size = 'medium',\n compact = false,\n leadingIcon,\n leadingAvatar,\n onRemove,\n error = false,\n colored = false,\n className = '',\n ...rest\n}: ChipProps) {\n const grouped = useContext(ChipGroupContext);\n const iconSize = ICON_SIZE_MAP[size];\n const avatarSize = AVATAR_SIZE_MAP[size];\n const labelText = labelTextFromChildren(children);\n const groupedAriaLabel =\n rest['aria-label'] ??\n (onRemove != null && labelText !== ''\n ? `${labelText}. Press Delete to remove.`\n : labelText !== ''\n ? labelText\n : undefined);\n const removable = onRemove != null;\n\n const handleRemove = (e: MouseEvent<HTMLButtonElement>) => {\n const chipEl = e.currentTarget.closest('[data-chip]');\n const nextFocus =\n chipEl instanceof HTMLElement ? focusTargetAfterRemove(chipEl) : null;\n const removeButton = e.currentTarget;\n onRemove?.(e);\n window.setTimeout(() => {\n if (removeButton.isConnected || nextFocus == null) return;\n if (!nextFocus.isConnected) return;\n if (nextFocus.dataset.chip != null) {\n activateChip(nextFocus);\n } else {\n nextFocus.focus({ focusVisible: true } as FocusOptions);\n }\n }, 0);\n };\n\n const rootClass = [\n styles.chip,\n styles[`chip--size-${toKebab(size)}`],\n compact && styles['chip--compact'],\n error && styles['chip--error'],\n colored && styles['chip--colored'],\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n rest.onKeyDown?.(e);\n if (grouped || !removable || e.defaultPrevented) return;\n if (\n e.key === 'Delete' ||\n e.key === 'Backspace' ||\n e.key === 'Enter' ||\n e.key === ' '\n ) {\n e.preventDefault();\n e.currentTarget\n .querySelector<HTMLButtonElement>('[data-chip-remove]')\n ?.click();\n }\n };\n\n return (\n <div\n className={rootClass}\n {...rest}\n role={removable ? 'button' : rest.role}\n tabIndex={removable ? (grouped ? -1 : 0) : rest.tabIndex}\n aria-label={removable ? groupedAriaLabel : rest['aria-label']}\n data-chip=\"\"\n onKeyDown={handleKeyDown}\n >\n {leadingAvatar != null ? (\n <span className={styles['chip__avatar-slot']}>\n <UserAvatar\n src={leadingAvatar.src}\n alt={leadingAvatar.alt}\n size={avatarSize}\n />\n </span>\n ) : leadingIcon != null ? (\n <span className={styles['chip__icon-slot']} aria-hidden>\n <Icon glyph={leadingIcon} size={iconSize} />\n </span>\n ) : null}\n <span className={styles['chip__label']}>{children}</span>\n {onRemove != null ? (\n <button\n type=\"button\"\n className={styles['chip__remove']}\n data-chip-remove=\"\"\n tabIndex={-1}\n aria-hidden\n onMouseDown={(e) => {\n e.preventDefault();\n }}\n onClick={handleRemove}\n >\n <CloseCircleIcon size={Number(iconSize)} aria-hidden />\n </button>\n ) : null}\n </div>\n );\n}\n"],"names":["ICON_SIZE_MAP","AVATAR_SIZE_MAP","labelTextFromChildren","children","focusTargetAfterRemove","chipEl","scan","start","direction","el","parent","afterGroup","groupSiblingInput","_a","Chip","size","compact","leadingIcon","leadingAvatar","onRemove","error","colored","className","rest","grouped","useContext","ChipGroupContext","iconSize","avatarSize","labelText","groupedAriaLabel","removable","handleRemove","nextFocus","removeButton","activateChip","rootClass","styles","toKebab","handleKeyDown","_b","jsxs","jsx","UserAvatar","Icon","CloseCircleIcon"],"mappings":"gZAmCMA,EAA4C,CAChD,MAAO,KACP,OAAQ,KACR,MAAO,IACT,EAEMC,EAAoD,CACxD,MAAO,KACP,OAAQ,KACR,MAAO,IACT,EAEA,SAASC,EAAsBC,EAA6B,CAC1D,OAAI,OAAOA,GAAa,UAAY,OAAOA,GAAa,SAC/C,OAAOA,CAAQ,EAAE,KAAA,EAEtB,MAAM,QAAQA,CAAQ,EACjBA,EAAS,IAAID,CAAqB,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EAE9D,EACT,CAEA,SAASE,EAAuBC,EAAyC,OACvE,MAAMC,EAAO,CACXC,EACAC,IACuB,CACvB,IAAIC,EAAqBF,EACzB,KAAOE,GAAI,CAIT,GAHIA,aAAc,aAAeA,EAAG,QAAQ,MAAQ,MAIlDA,aAAc,kBACdA,aAAc,oBAEd,OAAOA,EAETA,EACED,IAAc,OAASC,EAAG,mBAAqBA,EAAG,sBACtD,CACA,OAAO,IACT,EAEMC,EAASL,EAAO,cAChBM,EAAaD,GAAA,YAAAA,EAAQ,mBACrBE,EACJD,aAAsB,kBACtBA,aAAsB,oBAClBA,EACA,KAEN,OACEL,EAAKD,EAAO,mBAAoB,MAAM,GACtCC,EAAKD,EAAO,uBAAwB,UAAU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AAAU,EAAiB,GACb,EAAAC,GAAW,CAACO,GAAa,EAAE,oBAE7B,EAAE,MAAQ,UACV,EAAE,MAAQ,aACV,EAAE,MAAQ,SACV,EAAE,MAAQ,OAEV,EAAE,eAAA,GACFS,EAAA,EAAE,cACC,cAAiC,oBAAoB,IADxD,MAAAA,EAEI,QAER,EAEA,OACEC,EAAAA,KAAC,MAAA,CACC,UAAWL,EACV,GAAGb,EACJ,KAAMQ,EAAY,SAAWR,EAAK,KAClC,SAAUQ,EAAaP,EAAU,GAAK,EAAKD,EAAK,SAChD,aAAYQ,EAAYD,EAAmBP,EAAK,YAAY,EAC5D,YAAU,GACV,UAAWgB,EAEV,SAAA,CAAArB,GAAiB,KAChBwB,EAAAA,IAAC,OAAA,CAAK,UAAWL,UAAO,mBAAmB,EACzC,SAAAK,EAAAA,IAACC,EAAAA,QAAA,CACC,IAAKzB,EAAc,IACnB,IAAKA,EAAc,IACnB,KAAMU,CAAA,CAAA,EAEV,EACEX,GAAe,KACjByB,EAAAA,IAAC,OAAA,CAAK,UAAWL,EAAAA,QAAO,iBAAiB,EAAG,cAAW,GACrD,eAACO,EAAAA,QAAA,CAAK,MAAO3B,EAAa,KAAMU,CAAA,CAAU,EAC5C,EACE,WACH,OAAA,CAAK,UAAWU,EAAAA,QAAO,YAAiB,SAAAlC,EAAS,EACjDgB,GAAY,KACXuB,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,UAAWL,EAAAA,QAAO,aAClB,mBAAiB,GACjB,SAAU,GACV,cAAW,GACX,YAAc,GAAM,CAClB,EAAE,eAAA,CACJ,EACA,QAASL,EAET,eAACa,EAAA,CAAgB,KAAM,OAAOlB,CAAQ,EAAG,cAAW,EAAA,CAAC,CAAA,CAAA,EAErD,IAAA,CAAA,CAAA,CAGV"}
@@ -1,10 +1,12 @@
1
1
  import { HTMLAttributes, MouseEvent, ReactNode } from 'react';
2
- export type ChipSize = 'small' | 'medium' | 'medium-compact' | 'large';
2
+ export type ChipSize = 'small' | 'medium' | 'large';
3
3
  export interface ChipProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
4
4
  /** Chip label. */
5
5
  children: ReactNode;
6
6
  /** Visual size. Default: Medium. */
7
7
  size?: ChipSize;
8
+ /** Reduces vertical and horizontal padding. */
9
+ compact?: boolean;
8
10
  /** Leading icon from @mattermost/compass-icons. */
9
11
  leadingIcon?: ReactNode;
10
12
  /** Leading avatar. Overrides leading-icon when both are provided. */
@@ -25,5 +27,5 @@ export interface ChipProps extends Omit<HTMLAttributes<HTMLDivElement>, 'childre
25
27
  * invite, a filter applied to a search, a chosen value in a tokenizing input. Each Chip
26
28
  * stands on its own and is removable or selectable, depending on context.
27
29
  */
28
- export default function Chip({ children, size, leadingIcon, leadingAvatar, onRemove, error, colored, className, ...rest }: ChipProps): import("react/jsx-runtime").JSX.Element;
30
+ export default function Chip({ children, size, compact, leadingIcon, leadingAvatar, onRemove, error, colored, className, ...rest }: ChipProps): import("react/jsx-runtime").JSX.Element;
29
31
  //# sourceMappingURL=Chip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../../src/components/chip/Chip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,cAAc,EAAsB,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAU7G,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,gBAAgB,GAAG,OAAO,CAAC;AAEvE,MAAM,WAAW,SAAU,SAAQ,IAAI,CACrC,cAAc,CAAC,cAAc,CAAC,EAC9B,UAAU,CACX;IACC,kBAAkB;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,oCAAoC;IACpC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,mDAAmD;IACnD,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,qEAAqE;IACrE,aAAa,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,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K,CAAC,EAAE,OAAO,CAAC;IAChB,yCAAyC;IACzC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAgED;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,QAAQ,EACR,IAAe,EACf,OAAe,EACf,WAAW,EACX,aAAa,EACb,QAAQ,EACR,KAAa,EACb,OAAe,EACf,SAAc,EACd,GAAG,IAAI,EACR,EAAE,SAAS,2CAmGX"}
@@ -1,97 +1,97 @@
1
- import { jsxs as v, jsx as c } from "react/jsx-runtime";
2
- import { useContext as A } from "react";
3
- import __I from "@mattermost/compass-icons/components/close-circle.js";const I=__I&&__I.default?__I.default:__I;
4
- import M from "../icon/Icon.js";
5
- import D from "../user-avatar/UserAvatar.js";
6
- import { toKebab as k } from "../../utils/string.js";
7
- import { ChipGroupContext as w, activateChip as L } from "./ChipGroup.js";
8
- import i from "./Chip.module.scss.js";
9
- const N = {
1
+ import { jsxs as A, jsx as c } from "react/jsx-runtime";
2
+ import { useContext as I } from "react";
3
+ import __M from "@mattermost/compass-icons/components/close-circle.js";const M=__M&&__M.default?__M.default:__M;
4
+ import D from "../icon/Icon.js";
5
+ import k from "../user-avatar/UserAvatar.js";
6
+ import { toKebab as w } from "../../utils/string.js";
7
+ import { ChipGroupContext as L, activateChip as N } from "./ChipGroup.js";
8
+ import o from "./Chip.module.scss.js";
9
+ const H = {
10
10
  small: "10",
11
11
  medium: "12",
12
- "medium-compact": "12",
13
12
  large: "16"
14
- }, H = {
13
+ }, j = {
15
14
  small: "12",
16
15
  medium: "16",
17
- "medium-compact": "16",
18
16
  large: "20"
19
17
  };
20
- function y(n) {
21
- return typeof n == "string" || typeof n == "number" ? String(n).trim() : Array.isArray(n) ? n.map(y).filter(Boolean).join(" ") : "";
18
+ function T(t) {
19
+ return typeof t == "string" || typeof t == "number" ? String(t).trim() : Array.isArray(t) ? t.map(T).filter(Boolean).join(" ") : "";
22
20
  }
23
- function j(n) {
24
- var m;
25
- const u = (d, b) => {
26
- let e = d;
27
- for (; e; ) {
28
- if (e instanceof HTMLElement && e.dataset.chip != null || e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement)
29
- return e;
30
- e = b === "next" ? e.nextElementSibling : e.previousElementSibling;
21
+ function z(t) {
22
+ var r;
23
+ const s = (b, h) => {
24
+ let n = b;
25
+ for (; n; ) {
26
+ if (n instanceof HTMLElement && n.dataset.chip != null || n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement)
27
+ return n;
28
+ n = h === "next" ? n.nextElementSibling : n.previousElementSibling;
31
29
  }
32
30
  return null;
33
- }, l = n.parentElement, a = l == null ? void 0 : l.nextElementSibling, r = a instanceof HTMLInputElement || a instanceof HTMLTextAreaElement ? a : null;
34
- return u(n.nextElementSibling, "next") ?? u(n.previousElementSibling, "previous") ?? r ?? (l == null ? void 0 : l.querySelector("input, textarea")) ?? ((m = l == null ? void 0 : l.parentElement) == null ? void 0 : m.querySelector("input, textarea")) ?? null;
31
+ }, l = t.parentElement, u = l == null ? void 0 : l.nextElementSibling, m = u instanceof HTMLInputElement || u instanceof HTMLTextAreaElement ? u : null;
32
+ return s(t.nextElementSibling, "next") ?? s(t.previousElementSibling, "previous") ?? m ?? (l == null ? void 0 : l.querySelector("input, textarea")) ?? ((r = l == null ? void 0 : l.parentElement) == null ? void 0 : r.querySelector("input, textarea")) ?? null;
35
33
  }
36
- function Z({
37
- children: n,
38
- size: u = "medium",
39
- leadingIcon: l,
40
- leadingAvatar: a,
34
+ function $({
35
+ children: t,
36
+ size: s = "medium",
37
+ compact: l = !1,
38
+ leadingIcon: u,
39
+ leadingAvatar: m,
41
40
  onRemove: r,
42
- error: m = !1,
43
- colored: d = !1,
44
- className: b = "",
45
- ...e
41
+ error: b = !1,
42
+ colored: h = !1,
43
+ className: n = "",
44
+ ...i
46
45
  }) {
47
- const h = A(w), x = N[u], T = H[u], p = y(n), g = e["aria-label"] ?? (r != null && p !== "" ? `${p}. Press Delete to remove.` : p !== "" ? p : void 0), f = r != null, E = (t) => {
48
- const s = t.currentTarget.closest("[data-chip]"), o = s instanceof HTMLElement ? j(s) : null, _ = t.currentTarget;
49
- r == null || r(t), window.setTimeout(() => {
50
- _.isConnected || o == null || o.isConnected && (o.dataset.chip != null ? L(o) : o.focus({ focusVisible: !0 }));
46
+ const x = I(L), y = H[s], g = j[s], f = T(t), E = i["aria-label"] ?? (r != null && f !== "" ? `${f}. Press Delete to remove.` : f !== "" ? f : void 0), d = r != null, S = (e) => {
47
+ const p = e.currentTarget.closest("[data-chip]"), a = p instanceof HTMLElement ? z(p) : null, v = e.currentTarget;
48
+ r == null || r(e), window.setTimeout(() => {
49
+ v.isConnected || a == null || a.isConnected && (a.dataset.chip != null ? N(a) : a.focus({ focusVisible: !0 }));
51
50
  }, 0);
52
- }, S = [
53
- i.chip,
54
- i[`chip--size-${k(u)}`],
55
- m && i["chip--error"],
56
- d && i["chip--colored"],
57
- b
58
- ].filter(Boolean).join(" "), C = (t) => {
59
- var s, o;
60
- (s = e.onKeyDown) == null || s.call(e, t), !(h || !f || t.defaultPrevented) && (t.key === "Delete" || t.key === "Backspace" || t.key === "Enter" || t.key === " ") && (t.preventDefault(), (o = t.currentTarget.querySelector("[data-chip-remove]")) == null || o.click());
51
+ }, C = [
52
+ o.chip,
53
+ o[`chip--size-${w(s)}`],
54
+ l && o["chip--compact"],
55
+ b && o["chip--error"],
56
+ h && o["chip--colored"],
57
+ n
58
+ ].filter(Boolean).join(" "), _ = (e) => {
59
+ var p, a;
60
+ (p = i.onKeyDown) == null || p.call(i, e), !(x || !d || e.defaultPrevented) && (e.key === "Delete" || e.key === "Backspace" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), (a = e.currentTarget.querySelector("[data-chip-remove]")) == null || a.click());
61
61
  };
62
- return /* @__PURE__ */ v(
62
+ return /* @__PURE__ */ A(
63
63
  "div",
64
64
  {
65
- className: S,
66
- ...e,
67
- role: f ? "button" : e.role,
68
- tabIndex: f ? h ? -1 : 0 : e.tabIndex,
69
- "aria-label": f ? g : e["aria-label"],
65
+ className: C,
66
+ ...i,
67
+ role: d ? "button" : i.role,
68
+ tabIndex: d ? x ? -1 : 0 : i.tabIndex,
69
+ "aria-label": d ? E : i["aria-label"],
70
70
  "data-chip": "",
71
- onKeyDown: C,
71
+ onKeyDown: _,
72
72
  children: [
73
- a != null ? /* @__PURE__ */ c("span", { className: i["chip__avatar-slot"], children: /* @__PURE__ */ c(
74
- D,
73
+ m != null ? /* @__PURE__ */ c("span", { className: o["chip__avatar-slot"], children: /* @__PURE__ */ c(
74
+ k,
75
75
  {
76
- src: a.src,
77
- alt: a.alt,
78
- size: T
76
+ src: m.src,
77
+ alt: m.alt,
78
+ size: g
79
79
  }
80
- ) }) : l != null ? /* @__PURE__ */ c("span", { className: i["chip__icon-slot"], "aria-hidden": !0, children: /* @__PURE__ */ c(M, { glyph: l, size: x }) }) : null,
81
- /* @__PURE__ */ c("span", { className: i.chip__label, children: n }),
80
+ ) }) : u != null ? /* @__PURE__ */ c("span", { className: o["chip__icon-slot"], "aria-hidden": !0, children: /* @__PURE__ */ c(D, { glyph: u, size: y }) }) : null,
81
+ /* @__PURE__ */ c("span", { className: o.chip__label, children: t }),
82
82
  r != null ? /* @__PURE__ */ c(
83
83
  "button",
84
84
  {
85
85
  type: "button",
86
- className: i.chip__remove,
86
+ className: o.chip__remove,
87
87
  "data-chip-remove": "",
88
88
  tabIndex: -1,
89
89
  "aria-hidden": !0,
90
- onMouseDown: (t) => {
91
- t.preventDefault();
90
+ onMouseDown: (e) => {
91
+ e.preventDefault();
92
92
  },
93
- onClick: E,
94
- children: /* @__PURE__ */ c(I, { size: Number(x), "aria-hidden": !0 })
93
+ onClick: S,
94
+ children: /* @__PURE__ */ c(M, { size: Number(y), "aria-hidden": !0 })
95
95
  }
96
96
  ) : null
97
97
  ]
@@ -99,6 +99,6 @@ function Z({
99
99
  );
100
100
  }
101
101
  export {
102
- Z as default
102
+ $ as default
103
103
  };
104
104
  //# sourceMappingURL=Chip.js.map