@plexui/ui 0.28.1 → 0.30.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 (230) hide show
  1. package/dist/es/components/Alert/Alert.js +2 -2
  2. package/dist/es/components/Alert/Alert.js.map +1 -1
  3. package/dist/es/components/Avatar/Avatar.js +3 -1
  4. package/dist/es/components/Avatar/Avatar.js.map +1 -1
  5. package/dist/es/components/Badge/index.js +1 -1
  6. package/dist/es/components/Badge/index.js.map +1 -1
  7. package/dist/es/components/Button/Button.js +4 -3
  8. package/dist/es/components/Button/Button.js.map +1 -1
  9. package/dist/es/components/Button/NavigationButton.js +10 -0
  10. package/dist/es/components/Button/NavigationButton.js.map +1 -0
  11. package/dist/es/components/Button/NavigationGlyph.js +19 -0
  12. package/dist/es/components/Button/NavigationGlyph.js.map +1 -0
  13. package/dist/es/components/Button/index.js +1 -0
  14. package/dist/es/components/Button/index.js.map +1 -1
  15. package/dist/es/components/Checkbox/Checkbox.js +2 -1
  16. package/dist/es/components/Checkbox/Checkbox.js.map +1 -1
  17. package/dist/es/components/ColorPicker/ColorPicker.js +227 -0
  18. package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -0
  19. package/dist/es/components/ColorPicker/ColorWell.js +58 -0
  20. package/dist/es/components/ColorPicker/ColorWell.js.map +1 -0
  21. package/dist/es/components/ColorPicker/index.js +3 -0
  22. package/dist/es/components/ColorPicker/index.js.map +1 -0
  23. package/dist/es/components/ColorPicker/shared.js +132 -0
  24. package/dist/es/components/ColorPicker/shared.js.map +1 -0
  25. package/dist/es/components/ContextMenu/ContextMenu.js +164 -0
  26. package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -0
  27. package/dist/es/components/ContextMenu/index.js +2 -0
  28. package/dist/es/components/ContextMenu/index.js.map +1 -0
  29. package/dist/es/components/ContextMenu/shared.js +56 -0
  30. package/dist/es/components/ContextMenu/shared.js.map +1 -0
  31. package/dist/es/components/DateInput/DateInput.js +4 -2
  32. package/dist/es/components/DateInput/DateInput.js.map +1 -1
  33. package/dist/es/components/DatePicker/Calendar.js +89 -55
  34. package/dist/es/components/DatePicker/Calendar.js.map +1 -1
  35. package/dist/es/components/DatePicker/CalendarNavigationIcon.js +13 -0
  36. package/dist/es/components/DatePicker/CalendarNavigationIcon.js.map +1 -0
  37. package/dist/es/components/DatePicker/DatePicker.js +9 -2
  38. package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
  39. package/dist/es/components/DatePicker/useCalendarGutter.js +8 -0
  40. package/dist/es/components/DatePicker/useCalendarGutter.js.map +1 -0
  41. package/dist/es/components/DateRangePicker/Calendar.js +66 -49
  42. package/dist/es/components/DateRangePicker/Calendar.js.map +1 -1
  43. package/dist/es/components/DateRangePicker/DateRangePicker.js +6 -1
  44. package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
  45. package/dist/es/components/DateRangePicker/Trigger.js +1 -1
  46. package/dist/es/components/DateRangePicker/Trigger.js.map +1 -1
  47. package/dist/es/components/Dialog/Dialog.js +136 -20
  48. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  49. package/dist/es/components/Dialog/index.js.map +1 -1
  50. package/dist/es/components/Dialog/sheetDrag.js +77 -24
  51. package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
  52. package/dist/es/components/Field/Field.js +51 -4
  53. package/dist/es/components/Field/Field.js.map +1 -1
  54. package/dist/es/components/FieldGroup/FieldGroup.js +4 -2
  55. package/dist/es/components/FieldGroup/FieldGroup.js.map +1 -1
  56. package/dist/es/components/FileUpload/FileUpload.js +43 -3
  57. package/dist/es/components/FileUpload/FileUpload.js.map +1 -1
  58. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +18 -16
  59. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js.map +1 -1
  60. package/dist/es/components/FloatingLabelSelect/FloatingLabelSelect.js +11 -6
  61. package/dist/es/components/FloatingLabelSelect/FloatingLabelSelect.js.map +1 -1
  62. package/dist/es/components/Icon/index.js +2 -0
  63. package/dist/es/components/Icon/index.js.map +1 -1
  64. package/dist/es/components/Icon/svg/Disclosure.js +5 -0
  65. package/dist/es/components/Icon/svg/Disclosure.js.map +1 -0
  66. package/dist/es/components/Icon/svg/Eyedropper.js +6 -0
  67. package/dist/es/components/Icon/svg/Eyedropper.js.map +1 -0
  68. package/dist/es/components/Indicator/LoadingIndicator.js +1 -1
  69. package/dist/es/components/Indicator/LoadingIndicator.js.map +1 -1
  70. package/dist/es/components/Input/Input.js +3 -3
  71. package/dist/es/components/Input/Input.js.map +1 -1
  72. package/dist/es/components/InputGroup/InputGroup.js +3 -1
  73. package/dist/es/components/InputGroup/InputGroup.js.map +1 -1
  74. package/dist/es/components/MarkdownEditor/MarkdownEditor.js +95 -93
  75. package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
  76. package/dist/es/components/Menu/Menu.js +306 -34
  77. package/dist/es/components/Menu/Menu.js.map +1 -1
  78. package/dist/es/components/OTPInput/OTPInput.js +4 -1
  79. package/dist/es/components/OTPInput/OTPInput.js.map +1 -1
  80. package/dist/es/components/Page/Page.js +147 -19
  81. package/dist/es/components/Page/Page.js.map +1 -1
  82. package/dist/es/components/Page/index.js.map +1 -1
  83. package/dist/es/components/PageControl/PageControl.js +146 -0
  84. package/dist/es/components/PageControl/PageControl.js.map +1 -0
  85. package/dist/es/components/PageControl/index.js +2 -0
  86. package/dist/es/components/PageControl/index.js.map +1 -0
  87. package/dist/es/components/Popover/Popover.js +75 -33
  88. package/dist/es/components/Popover/Popover.js.map +1 -1
  89. package/dist/es/components/Popover/deferredOutsidePress.js +90 -0
  90. package/dist/es/components/Popover/deferredOutsidePress.js.map +1 -0
  91. package/dist/es/components/Popover/usePopoverContext.js.map +1 -1
  92. package/dist/es/components/RadioGroup/RadioGroup.js +1 -1
  93. package/dist/es/components/RadioGroup/RadioGroup.js.map +1 -1
  94. package/dist/es/components/Select/Select.js +98 -32
  95. package/dist/es/components/Select/Select.js.map +1 -1
  96. package/dist/es/components/SelectControl/SelectControl.js +48 -29
  97. package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
  98. package/dist/es/components/SelectControl/index.js +1 -1
  99. package/dist/es/components/SelectControl/index.js.map +1 -1
  100. package/dist/es/components/ShimmerText/ShimmerText.js +17 -7
  101. package/dist/es/components/ShimmerText/ShimmerText.js.map +1 -1
  102. package/dist/es/components/Sidebar/Sidebar.js +21 -8
  103. package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
  104. package/dist/es/components/Slider/Slider.js +61 -15
  105. package/dist/es/components/Slider/Slider.js.map +1 -1
  106. package/dist/es/components/Sortable/Sortable.js +16 -6
  107. package/dist/es/components/Sortable/Sortable.js.map +1 -1
  108. package/dist/es/components/Stepper/Stepper.js +114 -0
  109. package/dist/es/components/Stepper/Stepper.js.map +1 -0
  110. package/dist/es/components/Stepper/index.js +2 -0
  111. package/dist/es/components/Stepper/index.js.map +1 -0
  112. package/dist/es/components/Switch/Switch.js +2 -2
  113. package/dist/es/components/Switch/Switch.js.map +1 -1
  114. package/dist/es/components/TabBar/TabBar.js +128 -0
  115. package/dist/es/components/TabBar/TabBar.js.map +1 -0
  116. package/dist/es/components/TabBar/index.js +2 -0
  117. package/dist/es/components/TabBar/index.js.map +1 -0
  118. package/dist/es/components/Tabs/Tabs.js +27 -11
  119. package/dist/es/components/Tabs/Tabs.js.map +1 -1
  120. package/dist/es/components/TagInput/TagInput.js +40 -4
  121. package/dist/es/components/TagInput/TagInput.js.map +1 -1
  122. package/dist/es/components/Textarea/Textarea.js +7 -1
  123. package/dist/es/components/Textarea/Textarea.js.map +1 -1
  124. package/dist/es/components/Toast/ToastRenderer.js +86 -0
  125. package/dist/es/components/Toast/ToastRenderer.js.map +1 -0
  126. package/dist/es/components/Toast/Toaster.js +31 -16
  127. package/dist/es/components/Toast/Toaster.js.map +1 -1
  128. package/dist/es/components/Toast/toastLifecycle.js +283 -0
  129. package/dist/es/components/Toast/toastLifecycle.js.map +1 -0
  130. package/dist/es/components/Toolbar/Toolbar.js +92 -0
  131. package/dist/es/components/Toolbar/Toolbar.js.map +1 -0
  132. package/dist/es/components/Toolbar/index.js +2 -0
  133. package/dist/es/components/Toolbar/index.js.map +1 -0
  134. package/dist/es/components/Tooltip/CopyTooltip.js +37 -11
  135. package/dist/es/components/Tooltip/CopyTooltip.js.map +1 -1
  136. package/dist/es/components/Tooltip/Tooltip.js +61 -9
  137. package/dist/es/components/Tooltip/Tooltip.js.map +1 -1
  138. package/dist/es/hooks/useFloatingBoundary.js +35 -0
  139. package/dist/es/hooks/useFloatingBoundary.js.map +1 -0
  140. package/dist/es/hooks/usePhoneSubmenu.js +22 -0
  141. package/dist/es/hooks/usePhoneSubmenu.js.map +1 -0
  142. package/dist/es/lib/copyToClipboard.js +16 -7
  143. package/dist/es/lib/copyToClipboard.js.map +1 -1
  144. package/dist/es/lib/fieldRow.js +7 -1
  145. package/dist/es/lib/fieldRow.js.map +1 -1
  146. package/dist/es/lib/floatingBoundary.js +90 -0
  147. package/dist/es/lib/floatingBoundary.js.map +1 -0
  148. package/dist/es/lib/focusRestore.js +56 -0
  149. package/dist/es/lib/focusRestore.js.map +1 -0
  150. package/dist/es/lib/helpers.js +0 -18
  151. package/dist/es/lib/helpers.js.map +1 -1
  152. package/dist/es/lib/inputMode.js +9 -0
  153. package/dist/es/lib/inputMode.js.map +1 -0
  154. package/dist/es/lib/menuInitialFocus.js +100 -0
  155. package/dist/es/lib/menuInitialFocus.js.map +1 -0
  156. package/dist/es/lib/menuSubmenuPlacement.js +264 -0
  157. package/dist/es/lib/menuSubmenuPlacement.js.map +1 -0
  158. package/dist/es/lib/menuTriggerCover.js +70 -0
  159. package/dist/es/lib/menuTriggerCover.js.map +1 -0
  160. package/dist/es/lib/observeTextareaWidth.js +49 -0
  161. package/dist/es/lib/observeTextareaWidth.js.map +1 -0
  162. package/dist/es/lib/scrollEdges.js +34 -0
  163. package/dist/es/lib/scrollEdges.js.map +1 -0
  164. package/dist/es/lib/selectPress.js +34 -0
  165. package/dist/es/lib/selectPress.js.map +1 -0
  166. package/dist/es/lib/sortable.js +74 -20
  167. package/dist/es/lib/sortable.js.map +1 -1
  168. package/dist/es/styles/mobile-materials.css +1 -0
  169. package/dist/es/styles/mobile-surfaces.css +1 -0
  170. package/dist/types/components/Button/Button.d.ts +2 -0
  171. package/dist/types/components/Button/NavigationButton.d.ts +8 -0
  172. package/dist/types/components/Button/NavigationGlyph.d.ts +7 -0
  173. package/dist/types/components/Button/index.d.ts +1 -0
  174. package/dist/types/components/ColorPicker/ColorPicker.d.ts +34 -0
  175. package/dist/types/components/ColorPicker/ColorWell.d.ts +32 -0
  176. package/dist/types/components/ColorPicker/index.d.ts +3 -0
  177. package/dist/types/components/ColorPicker/shared.d.ts +69 -0
  178. package/dist/types/components/ContextMenu/ContextMenu.d.ts +78 -0
  179. package/dist/types/components/ContextMenu/index.d.ts +1 -0
  180. package/dist/types/components/ContextMenu/shared.d.ts +50 -0
  181. package/dist/types/components/DatePicker/CalendarNavigationIcon.d.ts +5 -0
  182. package/dist/types/components/DatePicker/DatePicker.d.ts +7 -1
  183. package/dist/types/components/DatePicker/useCalendarGutter.d.ts +1 -0
  184. package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +2 -0
  185. package/dist/types/components/Dialog/Dialog.d.ts +17 -6
  186. package/dist/types/components/Dialog/index.d.ts +1 -1
  187. package/dist/types/components/Field/Field.d.ts +12 -2
  188. package/dist/types/components/FieldGroup/FieldGroup.d.ts +11 -2
  189. package/dist/types/components/Icon/index.d.ts +2 -0
  190. package/dist/types/components/Icon/svg/Disclosure.d.ts +6 -0
  191. package/dist/types/components/Icon/svg/Eyedropper.d.ts +6 -0
  192. package/dist/types/components/Indicator/LoadingIndicator.d.ts +1 -1
  193. package/dist/types/components/Menu/Menu.d.ts +74 -9
  194. package/dist/types/components/Page/Page.d.ts +24 -9
  195. package/dist/types/components/Page/index.d.ts +1 -1
  196. package/dist/types/components/PageControl/PageControl.d.ts +52 -0
  197. package/dist/types/components/PageControl/index.d.ts +1 -0
  198. package/dist/types/components/Popover/Popover.d.ts +11 -6
  199. package/dist/types/components/Popover/deferredOutsidePress.d.ts +14 -0
  200. package/dist/types/components/Popover/usePopoverContext.d.ts +1 -0
  201. package/dist/types/components/Select/Select.d.ts +3 -3
  202. package/dist/types/components/SelectControl/SelectControl.d.ts +2 -2
  203. package/dist/types/components/SelectControl/index.d.ts +1 -1
  204. package/dist/types/components/Sortable/Sortable.d.ts +1 -1
  205. package/dist/types/components/Stepper/Stepper.d.ts +56 -0
  206. package/dist/types/components/Stepper/index.d.ts +1 -0
  207. package/dist/types/components/Switch/Switch.d.ts +3 -1
  208. package/dist/types/components/TabBar/TabBar.d.ts +74 -0
  209. package/dist/types/components/TabBar/index.d.ts +1 -0
  210. package/dist/types/components/Toast/ToastRenderer.d.ts +3 -0
  211. package/dist/types/components/Toast/Toaster.d.ts +4 -2
  212. package/dist/types/components/Toast/toastLifecycle.d.ts +90 -0
  213. package/dist/types/components/Toolbar/Toolbar.d.ts +93 -0
  214. package/dist/types/components/Toolbar/index.d.ts +1 -0
  215. package/dist/types/components/Tooltip/Tooltip.d.ts +2 -2
  216. package/dist/types/hooks/useFloatingBoundary.d.ts +24 -0
  217. package/dist/types/hooks/usePhoneSubmenu.d.ts +3 -0
  218. package/dist/types/lib/fieldRow.d.ts +6 -0
  219. package/dist/types/lib/floatingBoundary.d.ts +9 -0
  220. package/dist/types/lib/focusRestore.d.ts +5 -0
  221. package/dist/types/lib/helpers.d.ts +1 -5
  222. package/dist/types/lib/inputMode.d.ts +7 -0
  223. package/dist/types/lib/menuInitialFocus.d.ts +9 -0
  224. package/dist/types/lib/menuSubmenuPlacement.d.ts +57 -0
  225. package/dist/types/lib/menuTriggerCover.d.ts +23 -0
  226. package/dist/types/lib/observeTextareaWidth.d.ts +2 -0
  227. package/dist/types/lib/scrollEdges.d.ts +16 -0
  228. package/dist/types/lib/selectPress.d.ts +23 -0
  229. package/dist/types/lib/sortable.d.ts +1 -1
  230. package/package.json +6 -2
@@ -5,7 +5,7 @@ import { useEffect, useRef, useState } from "react";
5
5
  import { mergeRefs } from "react-merge-refs";
6
6
  import { useResizeObserver } from "usehooks-ts";
7
7
  import {} from "../../types.js";
8
- import { CheckCircle, Info, Warning } from "../Icon/index.js";
8
+ import { CheckCircle, Info, Warning, X } from "../Icon/index.js";
9
9
  import { Button } from "../Button/index.js";
10
10
  import s from "@plexui/styles/components/Alert/Alert.module.css";
11
11
  export const Alert = ({ color = "primary", variant = "outline", title, description, actions, actionsPlacement, indicator, className, actionsClassName, onDismiss, banner = false, ref, ...restProps }) => {
@@ -22,7 +22,7 @@ export const Alert = ({ color = "primary", variant = "outline", title, descripti
22
22
  setActionsAutoPlacement(placement);
23
23
  }
24
24
  }, [containerWidth]);
25
- return (_jsxs("div", { ref: mergeRefs([ref, containerRef]), className: clsx(s.Alert, className), "data-variant": variant, "data-color": color, role: color === "danger" ? "alert" : undefined, "data-actions-placement": actionsPlacement ?? actionsAutoPlacement, "data-banner": banner ? "" : undefined, ...restProps, children: [indicator === false ? null : (_jsx("div", { className: s.Indicator, children: indicator ?? _jsx(Indicator, { color: color }) })), _jsxs("div", { className: s.Content, children: [_jsxs("div", { className: s.Message, children: [title && _jsx("div", { className: s.Title, children: title }), description && _jsx("div", { className: s.Description, children: description })] }), (actions || onDismiss) && (_jsxs("div", { className: clsx(s.Actions, actionsClassName), ref: actionsRef, children: [actions, onDismiss && (_jsx(Button, { type: "button", onClick: onDismiss, color: color, variant: "soft", pill: true, children: "Dismiss" }))] }))] })] }));
25
+ return (_jsxs("div", { ref: mergeRefs([ref, containerRef]), className: clsx(s.Alert, className), "data-variant": variant, "data-color": color, role: color === "danger" ? "alert" : undefined, "data-actions-placement": actionsPlacement ?? actionsAutoPlacement, "data-banner": banner ? "" : undefined, ...restProps, children: [indicator === false ? null : (_jsx("div", { className: s.Indicator, children: indicator ?? _jsx(Indicator, { color: color }) })), _jsxs("div", { className: s.Content, children: [_jsxs("div", { className: s.Message, children: [title && _jsx("div", { className: s.Title, children: title }), description && _jsx("div", { className: s.Description, children: description })] }), (actions || onDismiss) && (_jsxs("div", { className: clsx(s.Actions, actionsClassName), ref: actionsRef, children: [actions, onDismiss && (_jsx(Button, { type: "button", onClick: onDismiss, color: color, variant: "soft", pill: true, className: s.DismissButton, children: "Dismiss" }))] }))] }), onDismiss && (_jsx(Button, { type: "button", onClick: onDismiss, color: "secondary", variant: "soft", size: "sm", uniform: true, pill: true, "aria-label": "Dismiss", className: s.CloseButton, children: _jsx(X, {}) }))] }));
26
26
  };
27
27
  export const Indicator = ({ color }) => {
28
28
  // Choose a default icon based on the color (which signals intention)
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../../../src/components/Alert/Alert.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAA4B,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAsC,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,CAAC,MAAM,kDAAkD,CAAA;AAyChE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EACpB,KAAK,GAAG,SAAS,EACjB,OAAO,GAAG,SAAS,EACnB,KAAK,EACL,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,MAAM,GAAG,KAAK,EACd,GAAG,EACH,GAAG,SAAS,EACD,EAAE,EAAE;IACf,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,C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,SAAS,EAAE,CAAC,CAAC,OAAO,aACtB,KAAK,IAAI,cAAK,SAAS,EAAE,CAAC,CAAC,KAAK,YAAG,KAAK,GAAO,EAC/C,WAAW,IAAI,cAAK,SAAS,EAAE,CAAC,CAAC,WAAW,YAAG,WAAW,GAAO,IAC9D,EACL,CAAC,OAAO,IAAI,SAAS,CAAC,IAAI,CACzB,eAAK,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,gBAAgB,CAAC,EAAE,GAAG,EAAE,UAAU,aAC/D,OAAO,EACP,SAAS,IAAI,CACZ,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,EAAC,IAAI,8BAElE,CACV,IACG,CACP,IACG,IACF,CACP,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,KAAK,EAAkC,EAAE,EAAE;IACrE,qEAAqE;IACrE,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,KAAC,OAAO,KAAG,CAAA;QACpB,KAAK,SAAS;YACZ,OAAO,KAAC,WAAW,KAAG,CAAA;QACxB;YACE,OAAO,KAAC,IAAI,KAAG,CAAA;IACnB,CAAC;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { type ReactNode, type Ref, useEffect, useRef, useState } from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\nimport { useResizeObserver } from \"usehooks-ts\"\nimport { type SemanticColors, type Variants } from \"../../types\"\nimport { CheckCircle, Info, Warning } from \"../Icon\"\nimport { Button } from \"../Button\"\nimport s from \"@plexui/styles/components/Alert/Alert.module.css\"\n\nexport type AlertProps = {\n /**\n * Color for the button\n * @default primary\n */\n color?: SemanticColors<\n \"primary\" | \"danger\" | \"success\" | \"info\" | \"discovery\" | \"caution\" | \"warning\"\n >\n /**\n * Style variant for the Button\n * @default fill\n */\n variant?: Variants<\"solid\" | \"soft\" | \"outline\">\n /** Title displayed in the alert. */\n title?: ReactNode\n /** Description text displayed in the alert */\n description?: ReactNode\n /** Actions associated with the Alert. */\n actions?: ReactNode\n /** Sets the placement of `actions` always on the end or the bottom. Default behavior is automatic placement based on sizing. */\n actionsPlacement?: \"end\" | \"bottom\"\n /** Optional override for the default indicator of the alert. When `false`, no indicator is shown. */\n indicator?: ReactNode | false\n /** Class applied to the alert container */\n className?: string\n /** Class applied to the actions container */\n actionsClassName?: string\n /** Callback when dismiss button is clicked. Shows dismiss button when provided. */\n onDismiss?: () => void\n /**\n * A full-width strip across the top or bottom of a page or panel (offline,\n * read-only, a new version): square corners and lines above and below only.\n * @default false\n */\n banner?: boolean\n /** Ref applied to the alert container */\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Alert = ({\n color = \"primary\",\n variant = \"outline\",\n title,\n description,\n actions,\n actionsPlacement,\n indicator,\n className,\n actionsClassName,\n onDismiss,\n banner = false,\n ref,\n ...restProps\n}: AlertProps) => {\n const containerRef = useRef<HTMLDivElement>(null)\n const actionsRef = useRef<HTMLDivElement>(null)\n const [actionsAutoPlacement, setActionsAutoPlacement] = useState<\"end\" | \"bottom\">(\"end\")\n // @ts-expect-error -- Type issue in usehooks-ts\n const { width: containerWidth } = useResizeObserver({ ref: containerRef })\n\n useEffect(() => {\n const actionsWidth = actionsRef.current?.clientWidth ?? 0\n\n if (actionsWidth && containerWidth) {\n // If actions are larger than a third of the container width, wrap them.\n const placement = actionsWidth > containerWidth / 3 ? \"bottom\" : \"end\"\n setActionsAutoPlacement(placement)\n }\n }, [containerWidth])\n\n return (\n <div\n ref={mergeRefs([ref, containerRef])}\n className={clsx(s.Alert, className)}\n data-variant={variant}\n data-color={color}\n role={color === \"danger\" ? \"alert\" : undefined}\n data-actions-placement={actionsPlacement ?? actionsAutoPlacement}\n data-banner={banner ? \"\" : undefined}\n {...restProps}\n >\n {indicator === false ? null : (\n <div className={s.Indicator}>{indicator ?? <Indicator color={color} />}</div>\n )}\n <div className={s.Content}>\n <div className={s.Message}>\n {title && <div className={s.Title}>{title}</div>}\n {description && <div className={s.Description}>{description}</div>}\n </div>\n {(actions || onDismiss) && (\n <div className={clsx(s.Actions, actionsClassName)} ref={actionsRef}>\n {actions}\n {onDismiss && (\n <Button type=\"button\" onClick={onDismiss} color={color} variant=\"soft\" pill>\n Dismiss\n </Button>\n )}\n </div>\n )}\n </div>\n </div>\n )\n}\n\nexport const Indicator = ({ color }: { color: AlertProps[\"color\"] }) => {\n // Choose a default icon based on the color (which signals intention)\n switch (color) {\n case \"warning\":\n case \"caution\":\n case \"danger\":\n return <Warning />\n case \"success\":\n return <CheckCircle />\n default:\n return <Info />\n }\n}\n"]}
1
+ {"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../../../src/components/Alert/Alert.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAA4B,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAsC,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,CAAC,MAAM,kDAAkD,CAAA;AAyChE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EACpB,KAAK,GAAG,SAAS,EACjB,OAAO,GAAG,SAAS,EACnB,KAAK,EACL,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,MAAM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OAAO,KAAC,IAAI,KAAG,CAAA;IACnB,CAAC;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { type ReactNode, type Ref, useEffect, useRef, useState } from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\nimport { useResizeObserver } from \"usehooks-ts\"\nimport { type SemanticColors, type Variants } from \"../../types\"\nimport { CheckCircle, Info, Warning, X } from \"../Icon\"\nimport { Button } from \"../Button\"\nimport s from \"@plexui/styles/components/Alert/Alert.module.css\"\n\nexport type AlertProps = {\n /**\n * Color for the button\n * @default primary\n */\n color?: SemanticColors<\n \"primary\" | \"danger\" | \"success\" | \"info\" | \"discovery\" | \"caution\" | \"warning\"\n >\n /**\n * Style variant for the Button\n * @default fill\n */\n variant?: Variants<\"solid\" | \"soft\" | \"outline\">\n /** Title displayed in the alert. */\n title?: ReactNode\n /** Description text displayed in the alert */\n description?: ReactNode\n /** Actions associated with the Alert. */\n actions?: ReactNode\n /** Sets the placement of `actions` always on the end or the bottom. Default behavior is automatic placement based on sizing. */\n actionsPlacement?: \"end\" | \"bottom\"\n /** Optional override for the default indicator of the alert. When `false`, no indicator is shown. */\n indicator?: ReactNode | false\n /** Class applied to the alert container */\n className?: string\n /** Class applied to the actions container */\n actionsClassName?: string\n /** Callback when dismiss button is clicked. Shows dismiss button when provided. */\n onDismiss?: () => void\n /**\n * A full-width strip across the top or bottom of a page or panel (offline,\n * read-only, a new version): square corners and lines above and below only.\n * @default false\n */\n banner?: boolean\n /** Ref applied to the alert container */\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Alert = ({\n color = \"primary\",\n variant = \"outline\",\n title,\n description,\n actions,\n actionsPlacement,\n indicator,\n className,\n actionsClassName,\n onDismiss,\n banner = false,\n ref,\n ...restProps\n}: AlertProps) => {\n const containerRef = useRef<HTMLDivElement>(null)\n const actionsRef = useRef<HTMLDivElement>(null)\n const [actionsAutoPlacement, setActionsAutoPlacement] = useState<\"end\" | \"bottom\">(\"end\")\n // @ts-expect-error -- Type issue in usehooks-ts\n const { width: containerWidth } = useResizeObserver({ ref: containerRef })\n\n useEffect(() => {\n const actionsWidth = actionsRef.current?.clientWidth ?? 0\n\n if (actionsWidth && containerWidth) {\n // If actions are larger than a third of the container width, wrap them.\n const placement = actionsWidth > containerWidth / 3 ? \"bottom\" : \"end\"\n setActionsAutoPlacement(placement)\n }\n }, [containerWidth])\n\n return (\n <div\n ref={mergeRefs([ref, containerRef])}\n className={clsx(s.Alert, className)}\n data-variant={variant}\n data-color={color}\n role={color === \"danger\" ? \"alert\" : undefined}\n data-actions-placement={actionsPlacement ?? actionsAutoPlacement}\n data-banner={banner ? \"\" : undefined}\n {...restProps}\n >\n {indicator === false ? null : (\n <div className={s.Indicator}>{indicator ?? <Indicator color={color} />}</div>\n )}\n <div className={s.Content}>\n <div className={s.Message}>\n {title && <div className={s.Title}>{title}</div>}\n {description && <div className={s.Description}>{description}</div>}\n </div>\n {(actions || onDismiss) && (\n <div className={clsx(s.Actions, actionsClassName)} ref={actionsRef}>\n {actions}\n {onDismiss && (\n <Button type=\"button\" onClick={onDismiss} color={color} variant=\"soft\" pill className={s.DismissButton}>\n Dismiss\n </Button>\n )}\n </div>\n )}\n </div>\n {/* On a phone the alert is dismissed with a close button in its corner, as an iOS tip is */}\n {onDismiss && (\n <Button type=\"button\" onClick={onDismiss} color=\"secondary\" variant=\"soft\" size=\"sm\" uniform pill aria-label=\"Dismiss\" className={s.CloseButton}>\n <X />\n </Button>\n )}\n </div>\n )\n}\n\nexport const Indicator = ({ color }: { color: AlertProps[\"color\"] }) => {\n // Choose a default icon based on the color (which signals intention)\n switch (color) {\n case \"warning\":\n case \"caution\":\n case \"danger\":\n return <Warning />\n case \"success\":\n return <CheckCircle />\n default:\n return <Info />\n }\n}\n"]}
@@ -53,8 +53,10 @@ const AvatarImage = ({ url, status, onLoad, onError, }) => {
53
53
  onLoad();
54
54
  }, src: url, className: s.AvatarImage, "data-loaded": status === "loaded" ? "" : undefined, onLoad: onLoad, onError: onError, alt: "", role: "presentation" }) }));
55
55
  };
56
+ // The first character of the name, past any leading space and whole even when it is an emoji (a surrogate pair)
57
+ const initialOf = (name) => (Array.from(name.trim())[0] ?? "").toUpperCase();
56
58
  const AvatarInitial = ({ name = "" }) => {
57
- const firstInitial = useMemo(() => name.charAt(0).toUpperCase(), [name]);
59
+ const firstInitial = useMemo(() => initialOf(name), [name]);
58
60
  return _jsx("span", { className: s.AvatarInitial, children: firstInitial });
59
61
  };
60
62
  const AvatarOverflowCount = ({ count }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../../../src/components/Avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAsC,MAAM,aAAa,CAAA;AAChE,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAiClE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAkB,EAAE,EAAE;IAC3C,yDAAyD;IACzD,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAEtD,gGAAgG;IAChG,OAAO,eAAC,WAAW,OAAK,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,GAAI,CAAA;AAChF,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAkB,EAAE,EAAE;IAChD,MAAM,EACJ,SAAS,EACT,IAAI,EACJ,aAAa,EACb,IAAI,EACJ,KAAK,GAAG,WAAW,EACnB,OAAO,GAAG,MAAM,EAChB,QAAQ,EACR,IAAI;IACJ,kBAAkB;IAClB,GAAG,SAAS,EACb,GAAG,KAAK,CAAA;IACT,MAAM,CAAC,WAAW,EAAE,cAAc,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C,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAExE,OAAO,eAAM,SAAS,EAAE,CAAC,CAAC,aAAa,YAAG,YAAY,GAAQ,CAAA;AAChE,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG,CAAC,EAAE,KAAK,EAAqB,EAAE,EAAE;IAC3D,MAAM,cAAc,GAAG,OAAO,CAAS,GAAG,EAAE;QAC1C,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE;YACjC,QAAQ,EAAE,SAAS;YACnB,cAAc,EAAE,OAAO;YACvB,qBAAqB,EAAE,CAAC;SACzB,CAAC;aACC,MAAM,CAAC,KAAK,CAAC;aACb,iBAAiB,EAAE,CAAA;IACxB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAEX,OAAO,CACL,gBAAM,SAAS,EAAE,CAAC,CAAC,mBAAmB,uBAAqB,cAAc,CAAC,MAAM,aAC9E,eAAM,SAAS,EAAE,CAAC,CAAC,yBAAyB,kBAAU,EACrD,cAAc,IACV,CACR,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { useMemo, useState } from \"react\"\nimport { toCssVariables } from \"../../lib/helpers\"\nimport { type SemanticColors, type Variants } from \"../../types\"\nimport s from \"@plexui/styles/components/Avatar/Avatar.module.css\"\n\ntype ImageStatus = undefined | \"error\" | \"loaded\"\n\nexport type AvatarProps = {\n /** Class name applied to the avatar */\n className?: string\n /** Size of the avatar's width & height, in pixels. */\n size?: number\n /** Display a formatted count of overflow objects. */\n overflowCount?: number\n /** Name used to display initials from */\n name?: string\n /**\n * Color used for the avatar\n * @default secondary\n */\n color?: SemanticColors<\"primary\" | \"secondary\" | \"success\" | \"info\" | \"discovery\" | \"danger\">\n /**\n * Style variant of the avatar\n * @default soft\n */\n variant?: Variants<\"soft\" | \"solid\">\n /** URL of the image to display as the avatar */\n imageUrl?: string\n /** Icon to render in the avatar circle */\n Icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>\n /** Optional click handler, which also enables semantic interactions */\n onClick?: () => void\n /** Optional pointer handler, which also enables semantic interactions */\n onPointerDown?: () => void\n}\n\nexport const Avatar = (props: AvatarProps) => {\n // Validate the image url before sending to the component\n const validImageUrl = validateImageUrl(props.imageUrl)\n\n // Keying off of imageUrl allows us to refresh imageStatus automatically through React rendering\n return <AvatarInner {...props} imageUrl={validImageUrl} key={validImageUrl} />\n}\n\nexport const AvatarInner = (props: AvatarProps) => {\n const {\n className,\n size,\n overflowCount,\n name,\n color = \"secondary\",\n variant = \"soft\",\n imageUrl,\n Icon,\n // asChild support\n ...restProps\n } = props\n const [imageStatus, setImageStatus] = useState<ImageStatus>()\n const isInteractive = !!(restProps.onPointerDown || restProps.onClick)\n const TagName = isInteractive ? \"button\" : \"span\"\n\n return (\n <TagName\n className={clsx(s.Avatar, className)}\n style={toCssVariables({\n \"avatar-size\": size,\n })}\n role={isInteractive ? undefined : \"presentation\"}\n // An interactive avatar is a button; name it by the full name, not the initial\n aria-label={isInteractive ? name : undefined}\n data-color={color}\n data-variant={variant}\n type={isInteractive ? \"button\" : undefined}\n {...restProps}\n >\n {(() => {\n // Render a placeholder layer (initials / overflow / icon) behind the\n // image so slow networks never leave the avatar visually empty while\n // the image is loading. The image overlays it once loaded and hides\n // it when it fails — either way the avatar is never blank.\n const placeholder = overflowCount ? (\n <AvatarOverflowCount count={overflowCount} />\n ) : Icon ? (\n <Icon className={s.AvatarIcon} />\n ) : (\n <AvatarInitial name={name} />\n )\n\n if (imageUrl && imageStatus !== \"error\") {\n return (\n <>\n {placeholder}\n <AvatarImage\n status={imageStatus}\n url={imageUrl}\n onError={() => setImageStatus(\"error\")}\n onLoad={() => setImageStatus(\"loaded\")}\n />\n </>\n )\n }\n return placeholder\n })()}\n </TagName>\n )\n}\n\nconst validateImageUrl = (imageUrl?: string): string | undefined => {\n if (!imageUrl) {\n return\n }\n\n // Avoid specific pattern of images from gravatar.com, which use a pair of initials, instead of a single initial.\n if (imageUrl.includes(\"gravatar.com\") && imageUrl.includes(\"cdn.auth0.com\")) {\n return\n }\n\n return imageUrl\n}\n\nconst AvatarImage = ({\n url,\n status,\n onLoad,\n onError,\n}: {\n url: string\n status: ImageStatus\n onLoad: () => void\n onError: () => void\n}) => {\n return (\n <span className={s.AvatarImageContainer}>\n <img\n // An image that loaded before hydration fired its load event before\n // React listened for it, and React does not replay it: read the\n // element instead\n ref={(img) => {\n if (img && status !== \"loaded\" && img.complete && img.naturalWidth > 0) onLoad()\n }}\n src={url}\n className={s.AvatarImage}\n data-loaded={status === \"loaded\" ? \"\" : undefined}\n onLoad={onLoad}\n onError={onError}\n alt=\"\"\n role=\"presentation\"\n />\n </span>\n )\n}\n\nconst AvatarInitial = ({ name = \"\" }: { name?: string }) => {\n const firstInitial = useMemo(() => name.charAt(0).toUpperCase(), [name])\n\n return <span className={s.AvatarInitial}>{firstInitial}</span>\n}\n\nconst AvatarOverflowCount = ({ count }: { count: number }) => {\n const formattedCount = useMemo<string>(() => {\n return new Intl.NumberFormat(\"en\", {\n notation: \"compact\",\n compactDisplay: \"short\",\n maximumFractionDigits: 0,\n })\n .format(count)\n .toLocaleLowerCase()\n }, [count])\n\n return (\n <span className={s.AvatarOverflowCount} data-letter-count={formattedCount.length}>\n <span className={s.AvatarOverflowCountSymbol}>+</span>\n {formattedCount}\n </span>\n )\n}\n"]}
1
+ {"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../../../src/components/Avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAsC,MAAM,aAAa,CAAA;AAChE,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAiClE,MAAM,CAAC,MAAM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BAAM,SAAS,EAAE,CAAC,CAAC,mBAAmB,uBAAqB,cAAc,CAAC,MAAM,aAC9E,eAAM,SAAS,EAAE,CAAC,CAAC,yBAAyB,kBAAU,EACrD,cAAc,IACV,CACR,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { useMemo, useState } from \"react\"\nimport { toCssVariables } from \"../../lib/helpers\"\nimport { type SemanticColors, type Variants } from \"../../types\"\nimport s from \"@plexui/styles/components/Avatar/Avatar.module.css\"\n\ntype ImageStatus = undefined | \"error\" | \"loaded\"\n\nexport type AvatarProps = {\n /** Class name applied to the avatar */\n className?: string\n /** Size of the avatar's width & height, in pixels. */\n size?: number\n /** Display a formatted count of overflow objects. */\n overflowCount?: number\n /** Name used to display initials from */\n name?: string\n /**\n * Color used for the avatar\n * @default secondary\n */\n color?: SemanticColors<\"primary\" | \"secondary\" | \"success\" | \"info\" | \"discovery\" | \"danger\">\n /**\n * Style variant of the avatar\n * @default soft\n */\n variant?: Variants<\"soft\" | \"solid\">\n /** URL of the image to display as the avatar */\n imageUrl?: string\n /** Icon to render in the avatar circle */\n Icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>\n /** Optional click handler, which also enables semantic interactions */\n onClick?: () => void\n /** Optional pointer handler, which also enables semantic interactions */\n onPointerDown?: () => void\n}\n\nexport const Avatar = (props: AvatarProps) => {\n // Validate the image url before sending to the component\n const validImageUrl = validateImageUrl(props.imageUrl)\n\n // Keying off of imageUrl allows us to refresh imageStatus automatically through React rendering\n return <AvatarInner {...props} imageUrl={validImageUrl} key={validImageUrl} />\n}\n\nexport const AvatarInner = (props: AvatarProps) => {\n const {\n className,\n size,\n overflowCount,\n name,\n color = \"secondary\",\n variant = \"soft\",\n imageUrl,\n Icon,\n // asChild support\n ...restProps\n } = props\n const [imageStatus, setImageStatus] = useState<ImageStatus>()\n const isInteractive = !!(restProps.onPointerDown || restProps.onClick)\n const TagName = isInteractive ? \"button\" : \"span\"\n\n return (\n <TagName\n className={clsx(s.Avatar, className)}\n style={toCssVariables({\n \"avatar-size\": size,\n })}\n role={isInteractive ? undefined : \"presentation\"}\n // An interactive avatar is a button; name it by the full name, not the initial\n aria-label={isInteractive ? name : undefined}\n data-color={color}\n data-variant={variant}\n type={isInteractive ? \"button\" : undefined}\n {...restProps}\n >\n {(() => {\n // Render a placeholder layer (initials / overflow / icon) behind the\n // image so slow networks never leave the avatar visually empty while\n // the image is loading. The image overlays it once loaded and hides\n // it when it fails — either way the avatar is never blank.\n const placeholder = overflowCount ? (\n <AvatarOverflowCount count={overflowCount} />\n ) : Icon ? (\n <Icon className={s.AvatarIcon} />\n ) : (\n <AvatarInitial name={name} />\n )\n\n if (imageUrl && imageStatus !== \"error\") {\n return (\n <>\n {placeholder}\n <AvatarImage\n status={imageStatus}\n url={imageUrl}\n onError={() => setImageStatus(\"error\")}\n onLoad={() => setImageStatus(\"loaded\")}\n />\n </>\n )\n }\n return placeholder\n })()}\n </TagName>\n )\n}\n\nconst validateImageUrl = (imageUrl?: string): string | undefined => {\n if (!imageUrl) {\n return\n }\n\n // Avoid specific pattern of images from gravatar.com, which use a pair of initials, instead of a single initial.\n if (imageUrl.includes(\"gravatar.com\") && imageUrl.includes(\"cdn.auth0.com\")) {\n return\n }\n\n return imageUrl\n}\n\nconst AvatarImage = ({\n url,\n status,\n onLoad,\n onError,\n}: {\n url: string\n status: ImageStatus\n onLoad: () => void\n onError: () => void\n}) => {\n return (\n <span className={s.AvatarImageContainer}>\n <img\n // An image that loaded before hydration fired its load event before\n // React listened for it, and React does not replay it: read the\n // element instead\n ref={(img) => {\n if (img && status !== \"loaded\" && img.complete && img.naturalWidth > 0) onLoad()\n }}\n src={url}\n className={s.AvatarImage}\n data-loaded={status === \"loaded\" ? \"\" : undefined}\n onLoad={onLoad}\n onError={onError}\n alt=\"\"\n role=\"presentation\"\n />\n </span>\n )\n}\n\n// The first character of the name, past any leading space and whole even when it is an emoji (a surrogate pair)\nconst initialOf = (name: string): string => (Array.from(name.trim())[0] ?? \"\").toUpperCase()\n\nconst AvatarInitial = ({ name = \"\" }: { name?: string }) => {\n const firstInitial = useMemo(() => initialOf(name), [name])\n\n return <span className={s.AvatarInitial}>{firstInitial}</span>\n}\n\nconst AvatarOverflowCount = ({ count }: { count: number }) => {\n const formattedCount = useMemo<string>(() => {\n return new Intl.NumberFormat(\"en\", {\n notation: \"compact\",\n compactDisplay: \"short\",\n maximumFractionDigits: 0,\n })\n .format(count)\n .toLocaleLowerCase()\n }, [count])\n\n return (\n <span className={s.AvatarOverflowCount} data-letter-count={formattedCount.length}>\n <span className={s.AvatarOverflowCountSymbol}>+</span>\n {formattedCount}\n </span>\n )\n}\n"]}
@@ -8,7 +8,7 @@ import s from "@plexui/styles/components/Badge/Badge.module.css";
8
8
  export const Badge = ({ children, className, variant = "soft", color = "secondary", size = "sm", pill, onRemove, removeLabel = "Remove", removable = false, ...restMaybeAsChildProps }) => {
9
9
  let remove = null;
10
10
  if (onRemove) {
11
- remove = (_jsx("button", { type: "button", className: s.Remove, "aria-label": removeLabel, onClick: onRemove, children: _jsx(X, {}) }));
11
+ remove = (_jsx("button", { type: "button", "data-badge-remove": "", className: s.Remove, "aria-label": removeLabel, onClick: onRemove, children: _jsx(X, {}) }));
12
12
  }
13
13
  else if (removable) {
14
14
  remove = (_jsx("span", { className: s.Remove, "aria-hidden": "true", children: _jsx(X, {}) }));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Badge/index.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAA0C,MAAM,OAAO,CAAA;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAkD,MAAM,aAAa,CAAA;AAC5E,OAAO,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AAC3B,OAAO,CAAC,MAAM,kDAAkD,CAAA;AA+ChE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EACpB,QAAQ,EACR,SAAS,EACT,OAAO,GAAG,MAAM,EAChB,KAAK,GAAG,WAAW,EACnB,IAAI,GAAG,IAAI,EACX,IAAI,EACJ,QAAQ,EACR,WAAW,GAAG,QAAQ,EACtB,SAAS,GAAG,KAAK,EACjB,GAAG,qBAAqB,EACb,EAAE,EAAE;IACf,IAAI,MAAM,GAAc,IAAI,CAAA;IAE5B,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,GAAG,CACP,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,CAAC,CAAC,MAAM,gBAAc,WAAW,EAAE,OAAO,EAAE,QAAQ,YACnF,KAAC,CAAC,KAAG,GACE,CACV,CAAA;IACH,CAAC;SAAM,IAAI,SAAS,EAAE,CAAC;QACrB,MAAM,GAAG,CACP,eAAM,SAAS,EAAE,CAAC,CAAC,MAAM,iBAAc,MAAM,YAC3C,KAAC,CAAC,KAAG,GACA,CACR,CAAA;IACH,CAAC;IAED,OAAO,CACL,cACE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,gBACvB,KAAK,eACN,IAAI,eACJ,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,kBAClB,OAAO,KACjB,qBAAqB,YAExB,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GACzD,CACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport { type MouseEventHandler, type ReactNode } from \"react\"\nimport { wrapTextNodeSiblings } from \"../../lib/renderHelpers\"\nimport { type SemanticColors, type Sizes, type Variants } from \"../../types\"\nimport { X } from \"../Icon\"\nimport s from \"@plexui/styles/components/Badge/Badge.module.css\"\n\nexport type BadgeProps = {\n /** Content rendered inside the badge */\n children: ReactNode\n /** Class applied to the badge */\n className?: string\n /**\n * Visual style of the badge\n * @default soft\n */\n variant?: Variants<\"solid\" | \"soft\" | \"outline\">\n /**\n * Size scale of the badge\n *\n * | sm | md | lg | xl |\n * | ------- | ------- | ------- | ------- |\n * | `20px` | `22px` | `24px` | `32px` |\n * @default sm\n */\n size?: Sizes<\"sm\" | \"md\" | \"lg\" | \"xl\">\n /**\n * Determines if the badge should be a fully rounded pill shape\n * @default false\n */\n pill?: boolean\n /**\n * Color of the badge, related to its meaning or intent\n * @default secondary\n */\n color?: SemanticColors<\n \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"discovery\" | \"caution\"\n >\n /** Adds a cross at the end of the badge that calls this when pressed */\n onRemove?: MouseEventHandler<HTMLButtonElement>\n /**\n * Accessible name of the cross\n * @default Remove\n */\n removeLabel?: string\n /**\n * Shows the cross as a mark, for a badge inside a control that takes the press\n * @default false\n */\n removable?: boolean\n}\n\nexport const Badge = ({\n children,\n className,\n variant = \"soft\",\n color = \"secondary\",\n size = \"sm\",\n pill,\n onRemove,\n removeLabel = \"Remove\",\n removable = false,\n ...restMaybeAsChildProps\n}: BadgeProps) => {\n let remove: ReactNode = null\n\n if (onRemove) {\n remove = (\n <button type=\"button\" className={s.Remove} aria-label={removeLabel} onClick={onRemove}>\n <X />\n </button>\n )\n } else if (removable) {\n remove = (\n <span className={s.Remove} aria-hidden=\"true\">\n <X />\n </span>\n )\n }\n\n return (\n <div\n className={clsx(s.Badge, className)}\n data-color={color}\n data-size={size}\n data-pill={pill ? \"\" : undefined}\n data-variant={variant}\n {...restMaybeAsChildProps}\n >\n {wrapTextNodeSiblings(remove ? [children, remove] : children)}\n </div>\n )\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Badge/index.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAA0C,MAAM,OAAO,CAAA;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAkD,MAAM,aAAa,CAAA;AAC5E,OAAO,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AAC3B,OAAO,CAAC,MAAM,kDAAkD,CAAA;AA+ChE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EACpB,QAAQ,EACR,SAAS,EACT,OAAO,GAAG,MAAM,EAChB,KAAK,GAAG,WAAW,EACnB,IAAI,GAAG,IAAI,EACX,IAAI,EACJ,QAAQ,EACR,WAAW,GAAG,QAAQ,EACtB,SAAS,GAAG,KAAK,EACjB,GAAG,qBAAqB,EACb,EAAE,EAAE;IACf,IAAI,MAAM,GAAc,IAAI,CAAA;IAE5B,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,GAAG,CACP,iBAAQ,IAAI,EAAC,QAAQ,uBAAmB,EAAE,EAAC,SAAS,EAAE,CAAC,CAAC,MAAM,gBAAc,WAAW,EAAE,OAAO,EAAE,QAAQ,YACxG,KAAC,CAAC,KAAG,GACE,CACV,CAAA;IACH,CAAC;SAAM,IAAI,SAAS,EAAE,CAAC;QACrB,MAAM,GAAG,CACP,eAAM,SAAS,EAAE,CAAC,CAAC,MAAM,iBAAc,MAAM,YAC3C,KAAC,CAAC,KAAG,GACA,CACR,CAAA;IACH,CAAC;IAED,OAAO,CACL,cACE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,gBACvB,KAAK,eACN,IAAI,eACJ,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,kBAClB,OAAO,KACjB,qBAAqB,YAExB,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GACzD,CACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport { type MouseEventHandler, type ReactNode } from \"react\"\nimport { wrapTextNodeSiblings } from \"../../lib/renderHelpers\"\nimport { type SemanticColors, type Sizes, type Variants } from \"../../types\"\nimport { X } from \"../Icon\"\nimport s from \"@plexui/styles/components/Badge/Badge.module.css\"\n\nexport type BadgeProps = {\n /** Content rendered inside the badge */\n children: ReactNode\n /** Class applied to the badge */\n className?: string\n /**\n * Visual style of the badge\n * @default soft\n */\n variant?: Variants<\"solid\" | \"soft\" | \"outline\">\n /**\n * Size scale of the badge\n *\n * | sm | md | lg | xl |\n * | ------- | ------- | ------- | ------- |\n * | `20px` | `22px` | `24px` | `32px` |\n * @default sm\n */\n size?: Sizes<\"sm\" | \"md\" | \"lg\" | \"xl\">\n /**\n * Determines if the badge should be a fully rounded pill shape\n * @default false\n */\n pill?: boolean\n /**\n * Color of the badge, related to its meaning or intent\n * @default secondary\n */\n color?: SemanticColors<\n \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"discovery\" | \"caution\"\n >\n /** Adds a cross at the end of the badge that calls this when pressed */\n onRemove?: MouseEventHandler<HTMLButtonElement>\n /**\n * Accessible name of the cross\n * @default Remove\n */\n removeLabel?: string\n /**\n * Shows the cross as a mark, for a badge inside a control that takes the press\n * @default false\n */\n removable?: boolean\n}\n\nexport const Badge = ({\n children,\n className,\n variant = \"soft\",\n color = \"secondary\",\n size = \"sm\",\n pill,\n onRemove,\n removeLabel = \"Remove\",\n removable = false,\n ...restMaybeAsChildProps\n}: BadgeProps) => {\n let remove: ReactNode = null\n\n if (onRemove) {\n remove = (\n <button type=\"button\" data-badge-remove=\"\" className={s.Remove} aria-label={removeLabel} onClick={onRemove}>\n <X />\n </button>\n )\n } else if (removable) {\n remove = (\n <span className={s.Remove} aria-hidden=\"true\">\n <X />\n </span>\n )\n }\n\n return (\n <div\n className={clsx(s.Badge, className)}\n data-color={color}\n data-size={size}\n data-pill={pill ? \"\" : undefined}\n data-variant={variant}\n {...restMaybeAsChildProps}\n >\n {wrapTextNodeSiblings(remove ? [children, remove] : children)}\n </div>\n )\n}\n"]}
@@ -10,7 +10,7 @@ import { useLinkComponent } from "../PlexUIProvider/internal.js";
10
10
  import { TransitionGroup } from "../Transition/TransitionGroup.js";
11
11
  import s from "@plexui/styles/components/Button/Button.module.css";
12
12
  export const Button = (props) => {
13
- const { type = "button", color = "primary", variant = "solid", pill = false, uniform = false, size = "md", iconSize, gutterSize, loading, selected, block, opticallyAlign, children, className, onClick, disabled, disabledTone,
13
+ const { type = "button", color = "primary", variant = "solid", pill = false, mobileMaterial, uniform = false, size = "md", iconSize, gutterSize, loading, selected, block, opticallyAlign, children, className, onClick, disabled, disabledTone,
14
14
  // Defaults to `loading` state
15
15
  inert = loading, ...restProps } = props;
16
16
  const isInert = disabled || inert;
@@ -20,13 +20,13 @@ export const Button = (props) => {
20
20
  }
21
21
  onClick?.(e);
22
22
  }, [onClick, disabled]);
23
- return (_jsxs("button", { type: type, className: clsx(s.Button, className), "data-color": color, "data-variant": variant, "data-pill": pill ? "" : undefined, "data-uniform": uniform ? "" : undefined, "data-size": size, "data-gutter-size": gutterSize, "data-icon-size": iconSize, "data-loading": loading ? "" : undefined, "data-selected": selected ? "" : undefined, "data-block": block ? "" : undefined, "data-optically-align": opticallyAlign, onPointerEnter: handlePressableMouseEnter,
23
+ return (_jsxs("button", { type: type, className: clsx(s.Button, className), "data-color": color, "data-variant": variant, "data-pill": pill ? "" : undefined, "data-mobile-material": mobileMaterial, "data-uniform": uniform ? "" : undefined, "data-size": size, "data-gutter-size": gutterSize, "data-icon-size": iconSize, "data-loading": loading ? "" : undefined, "data-selected": selected ? "" : undefined, "data-block": block ? "" : undefined, "data-optically-align": opticallyAlign, onPointerEnter: handlePressableMouseEnter,
24
24
  // Non-visual, accessible disablement
25
25
  // NOTE: Do not use literal `inert` because that is incorrect semantically
26
26
  disabled: isInert, "aria-disabled": isInert, tabIndex: isInert ? -1 : undefined, "data-disabled": disabled ? "" : undefined, "data-disabled-tone": disabled ? disabledTone : undefined, onClick: handleClick, ...restProps, children: [_jsx(TransitionGroup, { className: s.ButtonLoader, enterDuration: 250, exitDuration: 150, children: loading && _jsx(LoadingIndicator, {}, "loader") }), _jsx("span", { className: s.ButtonInner, children: wrapTextNodeSiblings(children) })] }));
27
27
  };
28
28
  export const ButtonLink = ((props) => {
29
- const { color = "primary", variant = "solid", pill = false, size = "md", gutterSize, iconSize, external, block, opticallyAlign, children, className, disabled, disabledTone, onClick, onPointerEnter, as: OverrideComponent, href, to, ...restProps } = props;
29
+ const { color = "primary", variant = "solid", pill = false, mobileMaterial, size = "md", gutterSize, iconSize, external, block, opticallyAlign, children, className, disabled, disabledTone, onClick, onPointerEnter, as: OverrideComponent, href, to, ...restProps } = props;
30
30
  const isExternal = external ?? /^https?:\/\//.test(href ?? to ?? "");
31
31
  const DefaultComponent = useLinkComponent();
32
32
  const LinkComponent = OverrideComponent || (isExternal ? "a" : DefaultComponent);
@@ -41,6 +41,7 @@ export const ButtonLink = ((props) => {
41
41
  "data-color": color,
42
42
  "data-variant": variant,
43
43
  "data-pill": pill ? "" : undefined,
44
+ "data-mobile-material": mobileMaterial,
44
45
  "data-block": block ? "" : undefined,
45
46
  "data-optically-align": opticallyAlign,
46
47
  "data-size": size,
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAML,WAAW,GACZ,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAoE,MAAM,aAAa,CAAA;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,CAAC,MAAM,oDAAoD,CAAA;AA+FlE,MAAM,CAAC,MAAM,MAA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AW,YAAG,oBAAoB,CAAC,QAAQ,CAAC,GAAQ,GAClE,CACR,CAAA;IACH,CAAC;IAED,MAAM,SAAS,GAAG;QAChB,GAAG,CAAC,UAAU;YACZ,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,qBAAqB,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE;YACpE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QACjB,GAAG,WAAW;QACd,GAAG,SAAS;KACb,CAAA;IAED,OAAO,CACL,KAAC,aAAa,OAAK,SAAS,YAC1B,eAAM,SAAS,EAAE,CAAC,CAAC,WAAW,YAAG,oBAAoB,CAAC,QAAQ,CAAC,GAAQ,GACzD,CACjB,CAAA;AACH,CAAC,CAAe,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport {\n type ButtonHTMLAttributes,\n type ComponentProps,\n type ComponentType,\n type MouseEventHandler,\n type ReactNode,\n useCallback,\n} from \"react\"\nimport { handlePressableMouseEnter } from \"../../lib/helpers\"\nimport { wrapTextNodeSiblings } from \"../../lib/renderHelpers\"\nimport { type ControlSize, type SemanticColors, type Sizes, type Variants } from \"../../types\"\nimport { LoadingIndicator } from \"../Indicator\"\nimport { useLinkComponent } from \"../PlexUIProvider/internal\"\nimport { TransitionGroup } from \"../Transition/TransitionGroup\"\nimport s from \"@plexui/styles/components/Button/Button.module.css\"\n\ntype CommonProps = {\n /**\n * Color for the button\n * @default primary\n */\n color?: SemanticColors<\n \"primary\" | \"secondary\" | \"danger\" | \"success\" | \"info\" | \"discovery\" | \"caution\" | \"warning\"\n >\n /**\n * Style variant for the Button\n * @default \"solid\"\n */\n variant?: Variants<\"solid\" | \"soft\" | \"outline\" | \"ghost\">\n /**\n * Determines if the button should be a fully rounded pill shape\n * @default false\n */\n pill?: boolean\n /**\n * Disables the button visually and from interactions\n * @default false\n */\n disabled?: boolean\n /**\n * Controls the visual tone when the button is disabled. \"relaxed\" will use a default cursor instead of not-allowed.\n */\n disabledTone?: \"relaxed\"\n /**\n * Determines if the button should take up 100% of available width\n * @default false\n */\n block?: boolean\n /**\n * Applies a negative margin using the current gutter to optically align the button\n * with surrounding content.\n */\n opticallyAlign?: \"start\" | \"end\"\n /**\n * Controls size of the button, specifically height, but also includes defaults for `gutterSize`, `iconSize`, `font-size`, etc.\n *\n * | 3xs | 2xs | xs | sm | md | lg | xl | 2xl | 3xl |\n * | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |\n * | `22px` | `24px` | `26px` | `28px` | `32px` | `36px` | `40px` | `44px` | `48px` |\n * @default md\n */\n size?: ControlSize\n /**\n * Controls the size of icons within the button, defaults to value from `size`.\n *\n * | xs | sm | md | lg | xl | 2xl |\n * | ------ | ------ | ------ | ------ | ------ | ------ |\n * | `14px` | `16px` | `18px` | `20px` | `22px` | `24px` |\n */\n iconSize?: Sizes<\"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\">\n /**\n * Controls gutter on the edges of the button, defaults to value from `size`.\n *\n * | 3xs | 2xs | xs | sm | md | lg | xl |\n * | ------ | ------ | ------ | ------ | ------ | ------ | ------ |\n * | `4px` | `6px` | `8px` | `10px` | `12px` | `14px` | `16px` |\n */\n gutterSize?: Sizes<\"3xs\" | \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\">\n /** Custom class applied to the Button element */\n className?: string\n /** Content rendered inside of the Button */\n children: React.ReactNode\n}\n\nexport type ButtonProps = CommonProps & {\n /**\n * Determines if the button should have matching width and height, based on the `size`.\n * @default false\n */\n uniform?: boolean\n /**\n * Displays selected styles on the button, varying by `variant\n * @default false\n */\n selected?: boolean\n /**\n * Displays loading indicator on top of button contents\n * @default false\n */\n loading?: boolean\n /**\n * Determines whether the button should be made inert, without introducing visual change.\n * @default false\n */\n inert?: boolean\n /** Ref for the button */\n ref?: React.Ref<HTMLButtonElement | null>\n} & ButtonHTMLAttributes<HTMLButtonElement>\n\nexport const Button = (props: ButtonProps) => {\n const {\n type = \"button\",\n color = \"primary\",\n variant = \"solid\",\n pill = false,\n uniform = false,\n size = \"md\",\n iconSize,\n gutterSize,\n loading,\n selected,\n block,\n opticallyAlign,\n children,\n className,\n onClick,\n disabled,\n disabledTone,\n // Defaults to `loading` state\n inert = loading,\n ...restProps\n } = props\n\n const isInert = disabled || inert\n\n const handleClick: MouseEventHandler<HTMLButtonElement> = useCallback(\n (e) => {\n if (disabled) {\n return\n }\n onClick?.(e)\n },\n [onClick, disabled],\n )\n\n return (\n <button\n type={type}\n className={clsx(s.Button, className)}\n data-color={color}\n data-variant={variant}\n data-pill={pill ? \"\" : undefined}\n data-uniform={uniform ? \"\" : undefined}\n data-size={size}\n data-gutter-size={gutterSize}\n data-icon-size={iconSize}\n data-loading={loading ? \"\" : undefined}\n data-selected={selected ? \"\" : undefined}\n data-block={block ? \"\" : undefined}\n data-optically-align={opticallyAlign}\n onPointerEnter={handlePressableMouseEnter}\n // Non-visual, accessible disablement\n // NOTE: Do not use literal `inert` because that is incorrect semantically\n disabled={isInert}\n aria-disabled={isInert}\n tabIndex={isInert ? -1 : undefined}\n // Visual disablement\n data-disabled={disabled ? \"\" : undefined}\n data-disabled-tone={disabled ? disabledTone : undefined}\n onClick={handleClick}\n {...restProps}\n >\n <TransitionGroup className={s.ButtonLoader} enterDuration={250} exitDuration={150}>\n {loading && <LoadingIndicator key=\"loader\" />}\n </TransitionGroup>\n <span className={s.ButtonInner}>{wrapTextNodeSiblings(children)}</span>\n </button>\n )\n}\n\ntype ButtonLink = <\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends ComponentType<any> | \"a\" = PlexUI.LinkComponent,\n>(\n props: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"href\"> &\n CommonProps & {\n /**\n * Explicity specify that the link is an external link. This should be\n * automatically detected based on the URL, but in some cases (e.g.\n * my-app://foo) you may want to explicitly set this.\n */\n external?: boolean\n /**\n * Override the default component used for the link. This is useful for\n * using a routing library, or SSR rendering.\n * purposes.\n *\n * @default 'a'\n */\n as?: T\n } & ComponentProps<T>,\n) => ReactNode\n\nexport const ButtonLink = ((\n props: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"href\"> &\n CommonProps & {\n href?: string\n to?: string\n external?: boolean\n as?: PlexUI.LinkComponent\n },\n) => {\n const {\n color = \"primary\",\n variant = \"solid\",\n pill = false,\n size = \"md\",\n gutterSize,\n iconSize,\n external,\n block,\n opticallyAlign,\n children,\n className,\n disabled,\n disabledTone,\n onClick,\n onPointerEnter,\n as: OverrideComponent,\n href,\n to,\n ...restProps\n } = props\n\n const isExternal = external ?? /^https?:\\/\\//.test(href ?? to ?? \"\")\n const DefaultComponent = useLinkComponent()\n const LinkComponent = OverrideComponent || (isExternal ? \"a\" : DefaultComponent)\n\n const sharedProps = {\n \"className\": clsx(s.Button, className),\n disabled,\n \"aria-disabled\": disabled,\n \"tabIndex\": disabled ? -1 : undefined,\n // Visual disablement (inert not supported in links, always applied)\n \"data-disabled\": disabled ? \"\" : undefined,\n \"data-disabled-tone\": disabled ? disabledTone : undefined,\n \"data-color\": color,\n \"data-variant\": variant,\n \"data-pill\": pill ? \"\" : undefined,\n \"data-block\": block ? \"\" : undefined,\n \"data-optically-align\": opticallyAlign,\n \"data-size\": size,\n \"data-gutter-size\": gutterSize,\n \"data-icon-size\": iconSize,\n \"onClick\": disabled ? undefined : onClick,\n \"onPointerEnter\": (evt: React.PointerEvent<HTMLAnchorElement>) => {\n handlePressableMouseEnter(evt)\n onPointerEnter?.(evt)\n },\n }\n\n if (disabled) {\n // Don't thread down stuff that isn't valid for a span - just keep the event handlers\n const eventProps = Object.fromEntries(\n Object.entries(restProps).filter(\n ([key, value]) => key.startsWith(\"on\") && typeof value === \"function\",\n ),\n )\n return (\n <span role=\"link\" {...sharedProps} {...eventProps}>\n <span className={s.ButtonInner}>{wrapTextNodeSiblings(children)}</span>\n </span>\n )\n }\n\n const linkProps = {\n ...(isExternal\n ? { target: \"_blank\", rel: \"noopener noreferrer\", href: href ?? to }\n : { href, to }),\n ...sharedProps,\n ...restProps,\n }\n\n return (\n <LinkComponent {...linkProps}>\n <span className={s.ButtonInner}>{wrapTextNodeSiblings(children)}</span>\n </LinkComponent>\n )\n}) as ButtonLink\n"]}
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAML,WAAW,GACZ,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAoE,MAAM,aAAa,CAAA;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAiGlE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAkB,EAAE,EAAE;IAC3C,MAAM,EACJ,IAAI,GAAG,QAAQ,EACf,KAAK,GAAG,SAAS,EACjB,OAAO,GAAG,OAAO,EACjB,IAAI,GAAG,KAAK,EACZ,cAAc,EACd,OAAO,GAAG,KAAK,EACf,IAAI,GAAG,IAAI,EACX,QAAQ,EACR,UAAU,EACV,OAAO,EACP,QAAQ,EACR,KAAK,EACL,cAAc,EACd,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,YAAY;IACZ,8BAA8B;IAC9B,KAAK,GAAG,OAAO,EACf,GAAG,SAAS,EACb,GAAG,KAAK,CAAA;IAET,MAAM,OAAO,GAAG,QAAQ,IAAI,KAAK,CAAA;IAEjC,MAAM,WAAW,GAAyC,WAAW,CACnE,CAAC,CAAC,EAAE,EA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Q,GACzD,CACjB,CAAA;AACH,CAAC,CAAe,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport {\n type ButtonHTMLAttributes,\n type ComponentProps,\n type ComponentType,\n type MouseEventHandler,\n type ReactNode,\n useCallback,\n} from \"react\"\nimport { handlePressableMouseEnter } from \"../../lib/helpers\"\nimport { wrapTextNodeSiblings } from \"../../lib/renderHelpers\"\nimport { type ControlSize, type SemanticColors, type Sizes, type Variants } from \"../../types\"\nimport { LoadingIndicator } from \"../Indicator\"\nimport { useLinkComponent } from \"../PlexUIProvider/internal\"\nimport { TransitionGroup } from \"../Transition/TransitionGroup\"\nimport s from \"@plexui/styles/components/Button/Button.module.css\"\n\ntype CommonProps = {\n /**\n * Color for the button\n * @default primary\n */\n color?: SemanticColors<\n \"primary\" | \"secondary\" | \"danger\" | \"success\" | \"info\" | \"discovery\" | \"caution\" | \"warning\"\n >\n /**\n * Style variant for the Button\n * @default \"solid\"\n */\n variant?: Variants<\"solid\" | \"soft\" | \"outline\" | \"ghost\">\n /**\n * Determines if the button should be a fully rounded pill shape\n * @default false\n */\n pill?: boolean\n /** Phone surface for neutral soft/ghost buttons. Desktop keeps the chosen variant. */\n mobileMaterial?: \"glass\" | \"flat\"\n /**\n * Disables the button visually and from interactions\n * @default false\n */\n disabled?: boolean\n /**\n * Controls the visual tone when the button is disabled. \"relaxed\" will use a default cursor instead of not-allowed.\n */\n disabledTone?: \"relaxed\"\n /**\n * Determines if the button should take up 100% of available width\n * @default false\n */\n block?: boolean\n /**\n * Applies a negative margin using the current gutter to optically align the button\n * with surrounding content.\n */\n opticallyAlign?: \"start\" | \"end\"\n /**\n * Controls size of the button, specifically height, but also includes defaults for `gutterSize`, `iconSize`, `font-size`, etc.\n *\n * | 3xs | 2xs | xs | sm | md | lg | xl | 2xl | 3xl |\n * | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |\n * | `22px` | `24px` | `26px` | `28px` | `32px` | `36px` | `40px` | `44px` | `48px` |\n * @default md\n */\n size?: ControlSize\n /**\n * Controls the size of icons within the button, defaults to value from `size`.\n *\n * | xs | sm | md | lg | xl | 2xl |\n * | ------ | ------ | ------ | ------ | ------ | ------ |\n * | `14px` | `16px` | `18px` | `20px` | `22px` | `24px` |\n */\n iconSize?: Sizes<\"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\">\n /**\n * Controls gutter on the edges of the button, defaults to value from `size`.\n *\n * | 3xs | 2xs | xs | sm | md | lg | xl |\n * | ------ | ------ | ------ | ------ | ------ | ------ | ------ |\n * | `4px` | `6px` | `8px` | `10px` | `12px` | `14px` | `16px` |\n */\n gutterSize?: Sizes<\"3xs\" | \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\">\n /** Custom class applied to the Button element */\n className?: string\n /** Content rendered inside of the Button */\n children: React.ReactNode\n}\n\nexport type ButtonProps = CommonProps & {\n /**\n * Determines if the button should have matching width and height, based on the `size`.\n * @default false\n */\n uniform?: boolean\n /**\n * Displays selected styles on the button, varying by `variant\n * @default false\n */\n selected?: boolean\n /**\n * Displays loading indicator on top of button contents\n * @default false\n */\n loading?: boolean\n /**\n * Determines whether the button should be made inert, without introducing visual change.\n * @default false\n */\n inert?: boolean\n /** Ref for the button */\n ref?: React.Ref<HTMLButtonElement | null>\n} & ButtonHTMLAttributes<HTMLButtonElement>\n\nexport const Button = (props: ButtonProps) => {\n const {\n type = \"button\",\n color = \"primary\",\n variant = \"solid\",\n pill = false,\n mobileMaterial,\n uniform = false,\n size = \"md\",\n iconSize,\n gutterSize,\n loading,\n selected,\n block,\n opticallyAlign,\n children,\n className,\n onClick,\n disabled,\n disabledTone,\n // Defaults to `loading` state\n inert = loading,\n ...restProps\n } = props\n\n const isInert = disabled || inert\n\n const handleClick: MouseEventHandler<HTMLButtonElement> = useCallback(\n (e) => {\n if (disabled) {\n return\n }\n onClick?.(e)\n },\n [onClick, disabled],\n )\n\n return (\n <button\n type={type}\n className={clsx(s.Button, className)}\n data-color={color}\n data-variant={variant}\n data-pill={pill ? \"\" : undefined}\n data-mobile-material={mobileMaterial}\n data-uniform={uniform ? \"\" : undefined}\n data-size={size}\n data-gutter-size={gutterSize}\n data-icon-size={iconSize}\n data-loading={loading ? \"\" : undefined}\n data-selected={selected ? \"\" : undefined}\n data-block={block ? \"\" : undefined}\n data-optically-align={opticallyAlign}\n onPointerEnter={handlePressableMouseEnter}\n // Non-visual, accessible disablement\n // NOTE: Do not use literal `inert` because that is incorrect semantically\n disabled={isInert}\n aria-disabled={isInert}\n tabIndex={isInert ? -1 : undefined}\n // Visual disablement\n data-disabled={disabled ? \"\" : undefined}\n data-disabled-tone={disabled ? disabledTone : undefined}\n onClick={handleClick}\n {...restProps}\n >\n <TransitionGroup className={s.ButtonLoader} enterDuration={250} exitDuration={150}>\n {loading && <LoadingIndicator key=\"loader\" />}\n </TransitionGroup>\n <span className={s.ButtonInner}>{wrapTextNodeSiblings(children)}</span>\n </button>\n )\n}\n\ntype ButtonLink = <\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends ComponentType<any> | \"a\" = PlexUI.LinkComponent,\n>(\n props: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"href\"> &\n CommonProps & {\n /**\n * Explicity specify that the link is an external link. This should be\n * automatically detected based on the URL, but in some cases (e.g.\n * my-app://foo) you may want to explicitly set this.\n */\n external?: boolean\n /**\n * Override the default component used for the link. This is useful for\n * using a routing library, or SSR rendering.\n * purposes.\n *\n * @default 'a'\n */\n as?: T\n } & ComponentProps<T>,\n) => ReactNode\n\nexport const ButtonLink = ((\n props: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"href\"> &\n CommonProps & {\n href?: string\n to?: string\n external?: boolean\n as?: PlexUI.LinkComponent\n },\n) => {\n const {\n color = \"primary\",\n variant = \"solid\",\n pill = false,\n mobileMaterial,\n size = \"md\",\n gutterSize,\n iconSize,\n external,\n block,\n opticallyAlign,\n children,\n className,\n disabled,\n disabledTone,\n onClick,\n onPointerEnter,\n as: OverrideComponent,\n href,\n to,\n ...restProps\n } = props\n\n const isExternal = external ?? /^https?:\\/\\//.test(href ?? to ?? \"\")\n const DefaultComponent = useLinkComponent()\n const LinkComponent = OverrideComponent || (isExternal ? \"a\" : DefaultComponent)\n\n const sharedProps = {\n \"className\": clsx(s.Button, className),\n disabled,\n \"aria-disabled\": disabled,\n \"tabIndex\": disabled ? -1 : undefined,\n // Visual disablement (inert not supported in links, always applied)\n \"data-disabled\": disabled ? \"\" : undefined,\n \"data-disabled-tone\": disabled ? disabledTone : undefined,\n \"data-color\": color,\n \"data-variant\": variant,\n \"data-pill\": pill ? \"\" : undefined,\n \"data-mobile-material\": mobileMaterial,\n \"data-block\": block ? \"\" : undefined,\n \"data-optically-align\": opticallyAlign,\n \"data-size\": size,\n \"data-gutter-size\": gutterSize,\n \"data-icon-size\": iconSize,\n \"onClick\": disabled ? undefined : onClick,\n \"onPointerEnter\": (evt: React.PointerEvent<HTMLAnchorElement>) => {\n handlePressableMouseEnter(evt)\n onPointerEnter?.(evt)\n },\n }\n\n if (disabled) {\n // Don't thread down stuff that isn't valid for a span - just keep the event handlers\n const eventProps = Object.fromEntries(\n Object.entries(restProps).filter(\n ([key, value]) => key.startsWith(\"on\") && typeof value === \"function\",\n ),\n )\n return (\n <span role=\"link\" {...sharedProps} {...eventProps}>\n <span className={s.ButtonInner}>{wrapTextNodeSiblings(children)}</span>\n </span>\n )\n }\n\n const linkProps = {\n ...(isExternal\n ? { target: \"_blank\", rel: \"noopener noreferrer\", href: href ?? to }\n : { href, to }),\n ...sharedProps,\n ...restProps,\n }\n\n return (\n <LinkComponent {...linkProps}>\n <span className={s.ButtonInner}>{wrapTextNodeSiblings(children)}</span>\n </LinkComponent>\n )\n}) as ButtonLink\n"]}
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import clsx from "clsx";
4
+ import { Button } from "./Button.js";
5
+ import { NavigationGlyph } from "./NavigationGlyph.js";
6
+ import s from "@plexui/styles/components/Button/NavigationButton.module.css";
7
+ const labels = { back: "Back", close: "Close", confirm: "Confirm" };
8
+ /** A semantic Button with a shared toolbar target and a role-specific glyph. */
9
+ export const NavigationButton = ({ action, color = action === "confirm" ? "primary" : "secondary", variant = action === "confirm" ? "solid" : "soft", mobileMaterial = action === "confirm" ? undefined : "glass", size = "lg", className, ...props }) => (_jsx(Button, { ...props, color: color, variant: variant, mobileMaterial: mobileMaterial, size: size, className: clsx(s.NavigationButton, className), uniform: true, pill: true, "aria-label": props["aria-label"] ?? labels[action], "data-navigation-action": action, children: _jsx(NavigationGlyph, { action: action }) }));
10
+ //# sourceMappingURL=NavigationButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigationButton.js","sourceRoot":"","sources":["../../../../src/components/Button/NavigationButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,EAAoB,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,eAAe,EAAyB,MAAM,mBAAmB,CAAA;AAC1E,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAO5E,MAAM,MAAM,GAAqC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAA;AAErG,gFAAgF;AAChF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAC7B,MAAM,EACN,KAAK,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,EACtD,OAAO,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EACjD,cAAc,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EAC3D,IAAI,GAAG,IAAI,EACX,SAAS,EACT,GAAG,KAAK,EACY,EAAE,EAAE,CAAC,CACzB,KAAC,MAAM,OACC,KAAK,EACT,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAC9C,OAAO,QACP,IAAI,sBACQ,KAAK,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,4BACzB,MAAM,YAE9B,KAAC,eAAe,IAAC,MAAM,EAAE,MAAM,GAAI,GAC9B,CACZ,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Button, type ButtonProps } from \"./Button\"\nimport { NavigationGlyph, type NavigationAction } from \"./NavigationGlyph\"\nimport s from \"@plexui/styles/components/Button/NavigationButton.module.css\"\n\nexport type NavigationButtonProps = Omit<ButtonProps, \"children\" | \"uniform\" | \"pill\" | \"iconSize\"> & {\n /** Visual role only; the caller owns navigation, dismissal and submission. */\n action: NavigationAction\n}\n\nconst labels: Record<NavigationAction, string> = { back: \"Back\", close: \"Close\", confirm: \"Confirm\" }\n\n/** A semantic Button with a shared toolbar target and a role-specific glyph. */\nexport const NavigationButton = ({\n action,\n color = action === \"confirm\" ? \"primary\" : \"secondary\",\n variant = action === \"confirm\" ? \"solid\" : \"soft\",\n mobileMaterial = action === \"confirm\" ? undefined : \"glass\",\n size = \"lg\",\n className,\n ...props\n}: NavigationButtonProps) => (\n <Button\n {...props}\n color={color}\n variant={variant}\n mobileMaterial={mobileMaterial}\n size={size}\n className={clsx(s.NavigationButton, className)}\n uniform\n pill\n aria-label={props[\"aria-label\"] ?? labels[action]}\n data-navigation-action={action}\n >\n <NavigationGlyph action={action} />\n </Button>\n)\n"]}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import ChevronLeft from "../Icon/svg/ChevronLeftMd.js";
3
+ import Check from "../Icon/svg/CheckMd.js";
4
+ import s from "@plexui/styles/components/Button/NavigationButton.module.css";
5
+ /** Shared by NavigationButton and the standard Dialog close action. */
6
+ export const NavigationGlyph = ({ action }) => {
7
+ const attributes = {
8
+ className: s.NavigationGlyph,
9
+ "aria-hidden": true,
10
+ "data-navigation-glyph": action,
11
+ "data-no-autosize": "",
12
+ };
13
+ if (action === "back")
14
+ return _jsx(ChevronLeft, { ...attributes });
15
+ if (action === "confirm")
16
+ return _jsx(Check, { ...attributes });
17
+ return (_jsx("svg", { ...attributes, viewBox: "0 0 20 20", width: "20", height: "20", children: _jsx("path", { fill: "currentColor", d: "M5.16 5.16a.62.62 0 0 1 .88 0L10 9.12l3.96-3.96a.62.62 0 1 1 .88.88L10.88 10l3.96 3.96a.62.62 0 1 1-.88.88L10 10.88l-3.96 3.96a.62.62 0 1 1-.88-.88L9.12 10 5.16 6.04a.62.62 0 0 1 0-.88" }) }));
18
+ };
19
+ //# sourceMappingURL=NavigationGlyph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigationGlyph.js","sourceRoot":"","sources":["../../../../src/components/Button/NavigationGlyph.tsx"],"names":[],"mappings":";AACA,OAAO,WAAW,MAAM,2BAA2B,CAAA;AACnD,OAAO,KAAK,MAAM,qBAAqB,CAAA;AACvC,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAM5E,uEAAuE;AACvE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAE,MAAM,EAAwB,EAAE,EAAE;IAChE,MAAM,UAAU,GAAwG;QACpH,SAAS,EAAE,CAAC,CAAC,eAAe;QAC5B,aAAa,EAAE,IAAI;QACnB,uBAAuB,EAAE,MAAM;QAC/B,kBAAkB,EAAE,EAAE;KACzB,CAAA;IACD,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,KAAC,WAAW,OAAK,UAAU,GAAI,CAAA;IAC7D,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,KAAC,KAAK,OAAK,UAAU,GAAI,CAAA;IAC1D,OAAO,CACH,iBAAS,UAAU,EAAE,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,YAC3D,eAAM,IAAI,EAAC,cAAc,EAAC,CAAC,EAAC,0LAA0L,GAAG,GACvN,CACT,CAAA;AACL,CAAC,CAAA","sourcesContent":["import type { SVGProps } from \"react\"\nimport ChevronLeft from \"../Icon/svg/ChevronLeftMd\"\nimport Check from \"../Icon/svg/CheckMd\"\nimport s from \"@plexui/styles/components/Button/NavigationButton.module.css\"\n\nexport type NavigationAction = \"back\" | \"close\" | \"confirm\"\n\ntype NavigationGlyphProps = { action: NavigationAction }\n\n/** Shared by NavigationButton and the standard Dialog close action. */\nexport const NavigationGlyph = ({ action }: NavigationGlyphProps) => {\n const attributes: SVGProps<SVGSVGElement> & { \"data-navigation-glyph\": NavigationAction; \"data-no-autosize\": string } = {\n className: s.NavigationGlyph,\n \"aria-hidden\": true,\n \"data-navigation-glyph\": action,\n \"data-no-autosize\": \"\",\n }\n if (action === \"back\") return <ChevronLeft {...attributes} />\n if (action === \"confirm\") return <Check {...attributes} />\n return (\n <svg {...attributes} viewBox=\"0 0 20 20\" width=\"20\" height=\"20\">\n <path fill=\"currentColor\" d=\"M5.16 5.16a.62.62 0 0 1 .88 0L10 9.12l3.96-3.96a.62.62 0 1 1 .88.88L10.88 10l3.96 3.96a.62.62 0 1 1-.88.88L10 10.88l-3.96 3.96a.62.62 0 1 1-.88-.88L9.12 10 5.16 6.04a.62.62 0 0 1 0-.88\" />\n </svg>\n )\n}\n"]}
@@ -1,3 +1,4 @@
1
1
  export { Button, ButtonLink } from "./Button.js";
2
2
  export { CopyButton } from "./CopyButton.js";
3
+ export { NavigationButton } from "./NavigationButton.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAoB,MAAM,UAAU,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAwB,MAAM,cAAc,CAAA","sourcesContent":["export { Button, ButtonLink, type ButtonProps } from \"./Button\"\nexport { CopyButton, type CopyButtonProps } from \"./CopyButton\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAoB,MAAM,UAAU,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAwB,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAA8B,MAAM,oBAAoB,CAAA","sourcesContent":["export { Button, ButtonLink, type ButtonProps } from \"./Button\"\nexport { CopyButton, type CopyButtonProps } from \"./CopyButton\"\nexport { NavigationButton, type NavigationButtonProps } from \"./NavigationButton\"\n"]}
@@ -4,6 +4,7 @@ import clsx from "clsx";
4
4
  import { Checkbox as RadixCheckbox } from "radix-ui";
5
5
  import { useId } from "react";
6
6
  import s from "@plexui/styles/components/Checkbox/Checkbox.module.css";
7
+ import { Check, Minus } from "../Icon/index.js";
7
8
  export const Checkbox = ({ className, label, description, id: propsId, disabled, orientation = "left", pill = false, variant = "solid", ...restProps }) => {
8
9
  const reactId = useId();
9
10
  const id = propsId ?? reactId;
@@ -16,6 +17,6 @@ export const Checkbox = ({ className, label, description, id: propsId, disabled,
16
17
  if (!event.defaultPrevented && event.detail > 1)
17
18
  event.preventDefault();
18
19
  }, children: label }));
19
- return (_jsxs("div", { "data-disabled": disabled ? "" : undefined, "data-has-label": label ? "" : undefined, "data-orientation": orientation, className: clsx(className, s.Container), children: [_jsx(RadixCheckbox.Root, { className: s.Checkbox, id: id, disabled: disabled, "data-pill": pill ? "" : undefined, "data-variant": variant, ...restProps, "aria-describedby": ariaDescribedBy, children: _jsx(RadixCheckbox.Indicator, { className: s.CheckMark, forceMount: true }) }), descriptionId ? (_jsxs("div", { className: s.LabelGroup, children: [labelElement, _jsx("span", { id: descriptionId, className: s.Description, children: description })] })) : (labelElement)] }));
20
+ return (_jsxs("div", { "data-disabled": disabled ? "" : undefined, "data-has-label": label ? "" : undefined, "data-orientation": orientation, className: clsx(className, s.Container), children: [_jsx(RadixCheckbox.Root, { className: s.Checkbox, id: id, disabled: disabled, "data-pill": pill ? "" : undefined, "data-variant": variant, ...restProps, "aria-describedby": ariaDescribedBy, children: _jsx("span", { className: s.IndicatorBox, "aria-hidden": "true", children: _jsxs(RadixCheckbox.Indicator, { className: variant === "ghost" ? s.GhostMark : s.CheckMark, forceMount: true, children: [_jsx(Check, { className: s.MarkCheck }), _jsx(Minus, { className: s.MarkDash })] }) }) }), descriptionId ? (_jsxs("div", { className: s.LabelGroup, children: [labelElement, _jsx("span", { id: descriptionId, className: s.Description, children: description })] })) : (labelElement)] }));
20
21
  };
21
22
  //# sourceMappingURL=Checkbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;AACpD,OAAO,EAA0C,KAAK,EAAE,MAAM,OAAO,CAAA;AACrE,OAAO,CAAC,MAAM,wDAAwD,CAAA;AAiDtE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,SAAS,EACT,KAAK,EACL,WAAW,EACX,EAAE,EAAE,OAAO,EACX,QAAQ,EACR,WAAW,GAAG,MAAM,EACpB,IAAI,GAAG,KAAK,EACZ,OAAO,GAAG,OAAO,EACjB,GAAG,SAAS,EACE,EAAE,EAAE;IAClB,MAAM,OAAO,GAAG,KAAK,EAAE,CAAA;IACvB,MAAM,EAAE,GAAG,OAAO,IAAI,OAAO,CAAA;IAC7B,wEAAwE;IACxE,mCAAmC;IACnC,MAAM,aAAa,GAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE,o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,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Checkbox as RadixCheckbox } from \"radix-ui\"\nimport { type FocusEventHandler, type ReactNode, useId } from \"react\"\nimport s from \"@plexui/styles/components/Checkbox/Checkbox.module.css\"\n\nexport type CheckboxProps = {\n /** The `id` of the checkbox. */\n id?: string\n /** The state of the checkbox when it is initially rendered. Use when you do not need to control its state. */\n defaultChecked?: boolean | \"indeterminate\"\n /** The controlled state of the checkbox. Must be used in conjunction with `onCheckedChange`. */\n checked?: boolean | \"indeterminate\"\n /** Optional accessible label rendered to the right of the checkbox. */\n label?: ReactNode\n /** Optional second line below the label. Linked via `aria-describedby`. */\n description?: ReactNode\n /** Event handler called when the state of the checkbox changes. */\n onCheckedChange?: (nextState: boolean) => void\n /** Event handler called when the checkbox looses focus. */\n onBlur?: FocusEventHandler<HTMLButtonElement>\n /** Event handler called when the checkbox gains focus. */\n onFocus?: FocusEventHandler<HTMLButtonElement>\n /** When `true`, prevents the user from interacting with the checkbox. */\n disabled?: boolean\n /** When `true`, indicates that the user must check the checkbox before the owning form can be submitted. */\n required?: boolean\n /** The name of the checkbox. Submitted with its owning form as part of a name/value pair. */\n name?: string\n /** The value given as data when submitted with a `name`. */\n value?: string\n /** CSS classes applied to wrapper node */\n className?: string\n /**\n * The orientation of the checkbox relative to the label.\n *\n * @default \"left\"\n */\n orientation?: \"left\" | \"right\"\n /**\n * Determines if the checkbox should be a fully rounded pill shape.\n * @default false\n */\n pill?: boolean\n /**\n * Visual style variant for the checkbox indicator.\n * - `\"solid\"` — filled background when checked (default)\n * - `\"ghost\"` — no border or background, checkmark only\n * @default \"solid\"\n */\n variant?: \"solid\" | \"ghost\"\n}\n\nexport const Checkbox = ({\n className,\n label,\n description,\n id: propsId,\n disabled,\n orientation = \"left\",\n pill = false,\n variant = \"solid\",\n ...restProps\n}: CheckboxProps) => {\n const reactId = useId()\n const id = propsId ?? reactId\n // The description only renders next to a label; it comes before any ids\n // the caller (a Field, say) passes\n const descriptionId = label && description ? `${id}-label-description` : undefined\n const ariaDescribedBy =\n [descriptionId, (restProps as { \"aria-describedby\"?: string })[\"aria-describedby\"]].filter(Boolean).join(\" \") ||\n undefined\n const labelElement = label && (\n <label\n htmlFor={id}\n className={s.Label}\n onMouseDown={(event) => {\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault()\n }}\n >\n {label}\n </label>\n )\n\n return (\n <div\n data-disabled={disabled ? \"\" : undefined}\n data-has-label={label ? \"\" : undefined}\n data-orientation={orientation}\n className={clsx(className, s.Container)}\n >\n <RadixCheckbox.Root\n className={s.Checkbox}\n id={id}\n disabled={disabled}\n data-pill={pill ? \"\" : undefined}\n data-variant={variant}\n {...restProps}\n aria-describedby={ariaDescribedBy}\n >\n <RadixCheckbox.Indicator className={s.CheckMark} forceMount />\n </RadixCheckbox.Root>\n {descriptionId ? (\n <div className={s.LabelGroup}>\n {labelElement}\n <span id={descriptionId} className={s.Description}>\n {description}\n </span>\n </div>\n ) : (\n labelElement\n )}\n </div>\n )\n}\n"]}
1
+ {"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;AACpD,OAAO,EAA0C,KAAK,EAAE,MAAM,OAAO,CAAA;AACrE,OAAO,CAAC,MAAM,wDAAwD,CAAA;AACtE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAiDtC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,SAAS,EACT,KAAK,EACL,WAAW,EACX,EAAE,EAAE,OAAO,EACX,QAAQ,EACR,WAAW,GAAG,MAAM,EACpB,IAAI,GAAG,KAAK,EACZ,OAAO,GAAG,OAAO,EACjB,GAAG,SAAS,EACE,EAAE,EAAE;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,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,UAAU,mBAC7F,KAAC,KAAK,IAAC,SAAS,EAAE,CAAC,CAAC,SAAS,GAAI,EACjC,KAAC,KAAK,IAAC,SAAS,EAAE,CAAC,CAAC,QAAQ,GAAI,IACR,GACrB,GACY,EACpB,aAAa,CAAC,CAAC,CAAC,CACf,eAAK,SAAS,EAAE,CAAC,CAAC,UAAU,aACzB,YAAY,EACb,eAAM,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC,WAAW,YAC9C,WAAW,GACP,IACH,CACP,CAAC,CAAC,CAAC,CACF,YAAY,CACb,IACG,CACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Checkbox as RadixCheckbox } from \"radix-ui\"\nimport { type FocusEventHandler, type ReactNode, useId } from \"react\"\nimport s from \"@plexui/styles/components/Checkbox/Checkbox.module.css\"\nimport { Check, Minus } from \"../Icon\"\n\nexport type CheckboxProps = {\n /** The `id` of the checkbox. */\n id?: string\n /** The state of the checkbox when it is initially rendered. Use when you do not need to control its state. */\n defaultChecked?: boolean | \"indeterminate\"\n /** The controlled state of the checkbox. Must be used in conjunction with `onCheckedChange`. */\n checked?: boolean | \"indeterminate\"\n /** Optional accessible label rendered to the right of the checkbox. */\n label?: ReactNode\n /** Optional second line below the label. Linked via `aria-describedby`. */\n description?: ReactNode\n /** Event handler called when the state of the checkbox changes. */\n onCheckedChange?: (nextState: boolean) => void\n /** Event handler called when the checkbox looses focus. */\n onBlur?: FocusEventHandler<HTMLButtonElement>\n /** Event handler called when the checkbox gains focus. */\n onFocus?: FocusEventHandler<HTMLButtonElement>\n /** When `true`, prevents the user from interacting with the checkbox. */\n disabled?: boolean\n /** When `true`, indicates that the user must check the checkbox before the owning form can be submitted. */\n required?: boolean\n /** The name of the checkbox. Submitted with its owning form as part of a name/value pair. */\n name?: string\n /** The value given as data when submitted with a `name`. */\n value?: string\n /** CSS classes applied to wrapper node */\n className?: string\n /**\n * The orientation of the checkbox relative to the label.\n *\n * @default \"left\"\n */\n orientation?: \"left\" | \"right\"\n /**\n * Determines if the checkbox should be a fully rounded pill shape.\n * @default false\n */\n pill?: boolean\n /**\n * Visual style variant for the checkbox indicator.\n * - `\"solid\"` — filled background when checked (default)\n * - `\"ghost\"` — no border or background, checkmark only\n * @default \"solid\"\n */\n variant?: \"solid\" | \"ghost\"\n}\n\nexport const Checkbox = ({\n className,\n label,\n description,\n id: propsId,\n disabled,\n orientation = \"left\",\n pill = false,\n variant = \"solid\",\n ...restProps\n}: CheckboxProps) => {\n const reactId = useId()\n const id = propsId ?? reactId\n // The description only renders next to a label; it comes before any ids\n // the caller (a Field, say) passes\n const descriptionId = label && description ? `${id}-label-description` : undefined\n const ariaDescribedBy =\n [descriptionId, (restProps as { \"aria-describedby\"?: string })[\"aria-describedby\"]].filter(Boolean).join(\" \") ||\n undefined\n const labelElement = label && (\n <label\n htmlFor={id}\n className={s.Label}\n onMouseDown={(event) => {\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault()\n }}\n >\n {label}\n </label>\n )\n\n return (\n <div\n data-disabled={disabled ? \"\" : undefined}\n data-has-label={label ? \"\" : undefined}\n data-orientation={orientation}\n className={clsx(className, s.Container)}\n >\n <RadixCheckbox.Root\n className={s.Checkbox}\n id={id}\n disabled={disabled}\n data-pill={pill ? \"\" : undefined}\n data-variant={variant}\n {...restProps}\n aria-describedby={ariaDescribedBy}\n >\n <span className={s.IndicatorBox} aria-hidden=\"true\">\n {/* The mark is the PlexUI Check icon, and Minus when indeterminate: white on a solid box,\n in the text color for a ghost. */}\n <RadixCheckbox.Indicator className={variant === \"ghost\" ? s.GhostMark : s.CheckMark} forceMount>\n <Check className={s.MarkCheck} />\n <Minus className={s.MarkDash} />\n </RadixCheckbox.Indicator>\n </span>\n </RadixCheckbox.Root>\n {descriptionId ? (\n <div className={s.LabelGroup}>\n {labelElement}\n <span id={descriptionId} className={s.Description}>\n {description}\n </span>\n </div>\n ) : (\n labelElement\n )}\n </div>\n )\n}\n"]}