@plexui/vue 0.9.0 → 0.11.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 (188) hide show
  1. package/dist/es/components/Alert/Alert.js +6 -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/ButtonGroup/ButtonGroup.js +7 -0
  6. package/dist/es/components/ButtonGroup/ButtonGroup.js.map +1 -1
  7. package/dist/es/components/ButtonGroup/index.js.map +1 -1
  8. package/dist/es/components/Checkbox/Checkbox.js +5 -6
  9. package/dist/es/components/Checkbox/Checkbox.js.map +1 -1
  10. package/dist/es/components/ColorPicker/ColorPicker.js +476 -0
  11. package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -0
  12. package/dist/es/components/ColorPicker/ColorWell.js +186 -0
  13. package/dist/es/components/ColorPicker/ColorWell.js.map +1 -0
  14. package/dist/es/components/ColorPicker/index.js +3 -0
  15. package/dist/es/components/ColorPicker/index.js.map +1 -0
  16. package/dist/es/components/ColorPicker/shared.js +132 -0
  17. package/dist/es/components/ColorPicker/shared.js.map +1 -0
  18. package/dist/es/components/ContextMenu/ContextMenu.js +223 -0
  19. package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -0
  20. package/dist/es/components/ContextMenu/index.js +2 -0
  21. package/dist/es/components/ContextMenu/index.js.map +1 -0
  22. package/dist/es/components/ContextMenu/shared.js +58 -0
  23. package/dist/es/components/ContextMenu/shared.js.map +1 -0
  24. package/dist/es/components/DatePicker/DatePicker.js +19 -3
  25. package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
  26. package/dist/es/components/DateRangePicker/DateRangePicker.js +1 -1
  27. package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
  28. package/dist/es/components/Dialog/Dialog.js +245 -25
  29. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  30. package/dist/es/components/Dialog/dialogSteps.js +85 -0
  31. package/dist/es/components/Dialog/dialogSteps.js.map +1 -0
  32. package/dist/es/components/Dialog/dialogViewport.js +74 -0
  33. package/dist/es/components/Dialog/dialogViewport.js.map +1 -0
  34. package/dist/es/components/Dialog/index.js +1 -1
  35. package/dist/es/components/Dialog/index.js.map +1 -1
  36. package/dist/es/components/Dialog/sheetDrag.js +2 -1
  37. package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
  38. package/dist/es/components/Field/Field.js +11 -3
  39. package/dist/es/components/Field/Field.js.map +1 -1
  40. package/dist/es/components/FieldGroup/FieldGroup.js +12 -1
  41. package/dist/es/components/FieldGroup/FieldGroup.js.map +1 -1
  42. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +2 -2
  43. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js.map +1 -1
  44. package/dist/es/components/Icon/index.js +1 -0
  45. package/dist/es/components/Icon/index.js.map +1 -1
  46. package/dist/es/components/Icon/svg/Eyedropper.js +10 -0
  47. package/dist/es/components/Icon/svg/Eyedropper.js.map +1 -0
  48. package/dist/es/components/IndexBar/IndexBar.js +215 -0
  49. package/dist/es/components/IndexBar/IndexBar.js.map +1 -0
  50. package/dist/es/components/IndexBar/index.js +2 -0
  51. package/dist/es/components/IndexBar/index.js.map +1 -0
  52. package/dist/es/components/Indicator/LoadingIndicator.js +1 -1
  53. package/dist/es/components/Indicator/LoadingIndicator.js.map +1 -1
  54. package/dist/es/components/Input/Input.js +3 -2
  55. package/dist/es/components/Input/Input.js.map +1 -1
  56. package/dist/es/components/MarkdownEditor/MarkdownEditor.js +149 -1
  57. package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
  58. package/dist/es/components/Menu/Menu.js +206 -33
  59. package/dist/es/components/Menu/Menu.js.map +1 -1
  60. package/dist/es/components/Menu/index.js +1 -1
  61. package/dist/es/components/Menu/index.js.map +1 -1
  62. package/dist/es/components/Page/Page.js +43 -11
  63. package/dist/es/components/Page/Page.js.map +1 -1
  64. package/dist/es/components/PageControl/PageControl.js +210 -0
  65. package/dist/es/components/PageControl/PageControl.js.map +1 -0
  66. package/dist/es/components/PageControl/index.js +2 -0
  67. package/dist/es/components/PageControl/index.js.map +1 -0
  68. package/dist/es/components/PhoneLayout/PhoneLayout.js +50 -0
  69. package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -0
  70. package/dist/es/components/PhoneLayout/index.js +2 -0
  71. package/dist/es/components/PhoneLayout/index.js.map +1 -0
  72. package/dist/es/components/Popover/Popover.js +5 -1
  73. package/dist/es/components/Popover/Popover.js.map +1 -1
  74. package/dist/es/components/Popover/deferredPointerDownOutside.js +59 -4
  75. package/dist/es/components/Popover/deferredPointerDownOutside.js.map +1 -1
  76. package/dist/es/components/Select/Select.js +18 -11
  77. package/dist/es/components/Select/Select.js.map +1 -1
  78. package/dist/es/components/SelectControl/SelectControl.js +1 -0
  79. package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
  80. package/dist/es/components/Sidebar/Sidebar.js +21 -6
  81. package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
  82. package/dist/es/components/Slider/Slider.js +44 -9
  83. package/dist/es/components/Slider/Slider.js.map +1 -1
  84. package/dist/es/components/Stepper/Stepper.js +195 -0
  85. package/dist/es/components/Stepper/Stepper.js.map +1 -0
  86. package/dist/es/components/Stepper/index.js +2 -0
  87. package/dist/es/components/Stepper/index.js.map +1 -0
  88. package/dist/es/components/SwipeActions/SwipeActions.js +374 -0
  89. package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -0
  90. package/dist/es/components/SwipeActions/index.js +2 -0
  91. package/dist/es/components/SwipeActions/index.js.map +1 -0
  92. package/dist/es/components/Switch/Switch.js +3 -1
  93. package/dist/es/components/Switch/Switch.js.map +1 -1
  94. package/dist/es/components/TabBar/TabBar.js +205 -0
  95. package/dist/es/components/TabBar/TabBar.js.map +1 -0
  96. package/dist/es/components/TabBar/index.js +2 -0
  97. package/dist/es/components/TabBar/index.js.map +1 -0
  98. package/dist/es/components/Tabs/Tabs.js +10 -2
  99. package/dist/es/components/Tabs/Tabs.js.map +1 -1
  100. package/dist/es/components/TagInput/TagInput.js +3 -46
  101. package/dist/es/components/TagInput/TagInput.js.map +1 -1
  102. package/dist/es/components/Textarea/Textarea.js +2 -0
  103. package/dist/es/components/Textarea/Textarea.js.map +1 -1
  104. package/dist/es/components/Tip/Tip.js +276 -0
  105. package/dist/es/components/Tip/Tip.js.map +1 -0
  106. package/dist/es/components/Tip/index.js +2 -0
  107. package/dist/es/components/Tip/index.js.map +1 -0
  108. package/dist/es/components/Toast/ToastRenderer.js +30 -13
  109. package/dist/es/components/Toast/ToastRenderer.js.map +1 -1
  110. package/dist/es/components/Toast/Toaster.js +17 -6
  111. package/dist/es/components/Toast/Toaster.js.map +1 -1
  112. package/dist/es/components/Toast/toastLifecycle.js +113 -1
  113. package/dist/es/components/Toast/toastLifecycle.js.map +1 -1
  114. package/dist/es/components/Toolbar/Toolbar.js +37 -6
  115. package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
  116. package/dist/es/components/Toolbar/index.js.map +1 -1
  117. package/dist/es/components/Tooltip/slot.js +3 -3
  118. package/dist/es/components/Tooltip/slot.js.map +1 -1
  119. package/dist/es/composables/useEscCloseStack.js +8 -4
  120. package/dist/es/composables/useEscCloseStack.js.map +1 -1
  121. package/dist/es/lib/fieldRow.js +15 -2
  122. package/dist/es/lib/fieldRow.js.map +1 -1
  123. package/dist/es/lib/floatingBoundary.js +3 -1
  124. package/dist/es/lib/floatingBoundary.js.map +1 -1
  125. package/dist/es/lib/helpers.js +21 -0
  126. package/dist/es/lib/helpers.js.map +1 -1
  127. package/dist/es/lib/menuSubmenuPlacement.js +51 -6
  128. package/dist/es/lib/menuSubmenuPlacement.js.map +1 -1
  129. package/dist/es/lib/menuTriggerCover.js +70 -0
  130. package/dist/es/lib/menuTriggerCover.js.map +1 -0
  131. package/dist/es/lib/phoneLayout.js +16 -0
  132. package/dist/es/lib/phoneLayout.js.map +1 -0
  133. package/dist/es/lib/scrollEdges.js +34 -0
  134. package/dist/es/lib/scrollEdges.js.map +1 -0
  135. package/dist/es/lib/toastRegion.js +6 -0
  136. package/dist/es/lib/toastRegion.js.map +1 -0
  137. package/dist/types/components/ButtonGroup/ButtonGroup.d.ts +13 -0
  138. package/dist/types/components/ButtonGroup/index.d.ts +1 -1
  139. package/dist/types/components/ColorPicker/ColorPicker.d.ts +244 -0
  140. package/dist/types/components/ColorPicker/ColorWell.d.ts +334 -0
  141. package/dist/types/components/ColorPicker/index.d.ts +3 -0
  142. package/dist/types/components/ColorPicker/shared.d.ts +69 -0
  143. package/dist/types/components/ContextMenu/ContextMenu.d.ts +128 -0
  144. package/dist/types/components/ContextMenu/index.d.ts +1 -0
  145. package/dist/types/components/ContextMenu/shared.d.ts +51 -0
  146. package/dist/types/components/DatePicker/DatePicker.d.ts +24 -4
  147. package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +4 -4
  148. package/dist/types/components/Dialog/Dialog.d.ts +100 -4
  149. package/dist/types/components/Dialog/dialogSteps.d.ts +10 -0
  150. package/dist/types/components/Dialog/dialogViewport.d.ts +1 -0
  151. package/dist/types/components/Dialog/index.d.ts +1 -1
  152. package/dist/types/components/Field/Field.d.ts +21 -2
  153. package/dist/types/components/FieldGroup/FieldGroup.d.ts +18 -1
  154. package/dist/types/components/Icon/index.d.ts +1 -0
  155. package/dist/types/components/Icon/svg/Eyedropper.d.ts +3 -0
  156. package/dist/types/components/IndexBar/IndexBar.d.ts +112 -0
  157. package/dist/types/components/IndexBar/index.d.ts +1 -0
  158. package/dist/types/components/Indicator/LoadingIndicator.d.ts +2 -2
  159. package/dist/types/components/Menu/Menu.d.ts +153 -40
  160. package/dist/types/components/Menu/index.d.ts +1 -1
  161. package/dist/types/components/Page/Page.d.ts +13 -5
  162. package/dist/types/components/PageControl/PageControl.d.ts +216 -0
  163. package/dist/types/components/PageControl/index.d.ts +1 -0
  164. package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +21 -0
  165. package/dist/types/components/PhoneLayout/index.d.ts +1 -0
  166. package/dist/types/components/Popover/deferredPointerDownOutside.d.ts +1 -1
  167. package/dist/types/components/Select/Select.d.ts +6 -6
  168. package/dist/types/components/Stepper/Stepper.d.ts +338 -0
  169. package/dist/types/components/Stepper/index.d.ts +1 -0
  170. package/dist/types/components/SwipeActions/SwipeActions.d.ts +135 -0
  171. package/dist/types/components/SwipeActions/index.d.ts +1 -0
  172. package/dist/types/components/TabBar/TabBar.d.ts +405 -0
  173. package/dist/types/components/TabBar/index.d.ts +1 -0
  174. package/dist/types/components/Tip/Tip.d.ts +146 -0
  175. package/dist/types/components/Tip/index.d.ts +1 -0
  176. package/dist/types/components/Toast/toastLifecycle.d.ts +34 -0
  177. package/dist/types/components/Toolbar/Toolbar.d.ts +26 -9
  178. package/dist/types/components/Toolbar/index.d.ts +1 -1
  179. package/dist/types/components/Tooltip/CopyTooltip.d.ts +1 -1
  180. package/dist/types/composables/useEscCloseStack.d.ts +2 -2
  181. package/dist/types/lib/fieldRow.d.ts +5 -0
  182. package/dist/types/lib/helpers.d.ts +6 -0
  183. package/dist/types/lib/menuSubmenuPlacement.d.ts +14 -1
  184. package/dist/types/lib/menuTriggerCover.d.ts +23 -0
  185. package/dist/types/lib/phoneLayout.d.ts +11 -0
  186. package/dist/types/lib/scrollEdges.d.ts +16 -0
  187. package/dist/types/lib/toastRegion.d.ts +5 -0
  188. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import clsx from "clsx";
2
2
  import { defineComponent, h, onBeforeUnmount, onMounted, ref, watch, } from "vue";
3
- import { CheckCircle, Info, Warning } from "../Icon/index.js";
3
+ import { CheckCircle, Info, Warning, X } from "../Icon/index.js";
4
4
  import { Button } from "../Button/index.js";
5
5
  import { hasContent } from "../../lib/slotContent.js";
6
6
  import s from "@plexui/styles/components/Alert/Alert.module.css";
@@ -111,11 +111,15 @@ const AlertComponent = defineComponent({
111
111
  ? h("div", { class: clsx(s.Actions, props.actionsClassName), ref: actionsRef }, [
112
112
  actions,
113
113
  props.onDismiss
114
- ? h(Button, { type: "button", onClick: props.onDismiss, color, variant: "soft", pill: true }, { default: () => "Dismiss" })
114
+ ? h(Button, { type: "button", onClick: props.onDismiss, color, variant: "soft", pill: true, class: s.DismissButton }, { default: () => "Dismiss" })
115
115
  : null,
116
116
  ])
117
117
  : null,
118
118
  ]),
119
+ // On a phone the alert is dismissed with a close button in its corner, as an iOS tip is
120
+ props.onDismiss
121
+ ? h(Button, { "type": "button", "onClick": props.onDismiss, "color": "secondary", "variant": "soft", "size": "sm", "uniform": true, "pill": true, "aria-label": "Dismiss", "class": s.CloseButton }, { default: () => [h(X)] })
122
+ : null,
119
123
  ]);
120
124
  };
121
125
  },
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../../../src/components/Alert/Alert.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EACL,eAAe,EACf,CAAC,EACD,eAAe,EACf,SAAS,EACT,GAAG,EACH,KAAK,GAKN,MAAM,KAAK,CAAA;AAEZ,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,CAAC,MAAM,kDAAkD,CAAA;AAchE,+EAA+E;AAC/E,MAAM,SAAS,GAAG,CAAC,KAAiB,EAAE,EAAE;IACtC,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC,OAAO,CAAC,CAAA;QACnB,KAAK,SAAS;YACZ,OAAO,CAAC,CAAC,WAAW,CAAC,CAAA;QACvB;YACE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAA;IAClB,CA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,CAAC,CAAA;AAOF,qFAAqF;AACrF,MAAM,CAAC,MAAM,KAAK,GAAG,cAA4E,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n type HTMLAttributes,\n type PropType,\n type VNodeArrayChildren,\n type VNodeChild,\n} from \"vue\"\nimport type { SemanticColors, Variants } from \"@plexui/styles/types\"\nimport { CheckCircle, Info, Warning } from \"../Icon/index.js\"\nimport { Button } from \"../Button/index.js\"\nimport { hasContent } from \"../../lib/slotContent.js\"\nimport s from \"@plexui/styles/components/Alert/Alert.module.css\"\n\n// Vue port of packages/ui/src/components/Alert/Alert.tsx. ReactNode props\n// are slots (`title`, `description`, `actions`, `indicator`), with string\n// props as fallback for `title` and `description`. `:indicator=\"false\"`\n// hides the indicator. `onDismiss` stays a function prop (`@dismiss` in\n// templates) because its presence adds the Dismiss button.\n// The actions auto placement mirrors usehooks-ts `useResizeObserver`: it\n// reacts to the container's content-box width only.\n\nexport type AlertColor = SemanticColors<\n \"primary\" | \"danger\" | \"success\" | \"info\" | \"discovery\" | \"caution\" | \"warning\"\n>\n\n/** Default indicator icon, chosen from the color (which signals intention). */\nconst Indicator = (color: AlertColor) => {\n switch (color) {\n case \"warning\":\n case \"caution\":\n case \"danger\":\n return h(Warning)\n case \"success\":\n return h(CheckCircle)\n default:\n return h(Info)\n }\n}\n\n// usehooks-ts `extractSize` for the content box\nconst contentBoxSize = (entry: ResizeObserverEntry, sizeType: \"inlineSize\" | \"blockSize\") => {\n const box = entry.contentBoxSize as ReadonlyArray<ResizeObserverSize> | ResizeObserverSize | undefined\n if (!box) return entry.contentRect[sizeType === \"inlineSize\" ? \"width\" : \"height\"]\n // Firefox once reported a single object instead of an array\n return Array.isArray(box) ? box[0]?.[sizeType] : (box as ResizeObserverSize)[sizeType]\n}\n\nconst AlertComponent = defineComponent({\n name: \"Alert\",\n props: {\n /** Color of the alert. @default \"primary\" */\n color: { type: String as PropType<AlertColor>, default: \"primary\" },\n /** Style variant. @default \"outline\" */\n variant: { type: String as PropType<Variants<\"solid\" | \"soft\" | \"outline\">>, default: \"outline\" },\n /** Title displayed in the alert (or the `title` slot). */\n title: String,\n /** Description text displayed in the alert (or the `description` slot). */\n description: String,\n /** Places `actions` at the end or the bottom. Automatic from sizing when unset. */\n actionsPlacement: String as PropType<\"end\" | \"bottom\">,\n /** `false` hides the indicator. Use the `indicator` slot to replace it. */\n indicator: { type: Boolean, default: undefined },\n /** Class applied to the actions container */\n actionsClassName: String,\n /** Shows the Dismiss button; called when it is clicked. */\n onDismiss: Function as PropType<(event: MouseEvent) => void>,\n /** A full-width strip across a page or panel: square corners, lines above and below only. @default false */\n banner: { type: Boolean, default: false },\n },\n setup(props, { slots }) {\n const containerRef = ref<HTMLDivElement | null>(null)\n const actionsRef = ref<HTMLDivElement | null>(null)\n const actionsAutoPlacement = ref<\"end\" | \"bottom\">(\"end\")\n const containerWidth = ref<number | undefined>(undefined)\n\n let observer: ResizeObserver | undefined\n onMounted(() => {\n const container = containerRef.value\n if (!container) return\n if (typeof window === \"undefined\" || !(\"ResizeObserver\" in window)) return\n let previousWidth: number | undefined\n let previousHeight: number | undefined\n observer = new ResizeObserver(([entry]) => {\n if (!entry) return\n const width = contentBoxSize(entry, \"inlineSize\")\n const height = contentBoxSize(entry, \"blockSize\")\n if (width !== previousWidth || height !== previousHeight) {\n previousWidth = width\n previousHeight = height\n containerWidth.value = width\n }\n })\n observer.observe(container, { box: \"content-box\" })\n })\n onBeforeUnmount(() => observer?.disconnect())\n\n watch(containerWidth, (width) => {\n const actionsWidth = actionsRef.value?.clientWidth ?? 0\n\n if (actionsWidth && width) {\n // If actions are larger than a third of the container width, wrap them.\n actionsAutoPlacement.value = actionsWidth > width / 3 ? \"bottom\" : \"end\"\n }\n })\n\n return () => {\n const { color } = props\n const title: VNodeChild = slots.title ? slots.title() : props.title\n const description: VNodeChild = slots.description ? slots.description() : props.description\n const actions = slots.actions?.()\n const showActions = hasContent(actions) || !!props.onDismiss\n\n return h(\n \"div\",\n {\n \"ref\": containerRef,\n \"class\": s.Alert,\n \"data-variant\": props.variant,\n \"data-color\": color,\n \"role\": color === \"danger\" ? \"alert\" : undefined,\n \"data-actions-placement\": props.actionsPlacement ?? actionsAutoPlacement.value,\n \"data-banner\": props.banner ? \"\" : undefined,\n },\n [\n props.indicator === false\n ? null\n : h(\"div\", { class: s.Indicator }, slots.indicator ? slots.indicator() : [Indicator(color)]),\n h(\"div\", { class: s.Content }, [\n h(\"div\", { class: s.Message }, [\n hasContent([title as VNodeArrayChildren]) ? h(\"div\", { class: s.Title }, [title]) : null,\n hasContent([description as VNodeArrayChildren])\n ? h(\"div\", { class: s.Description }, [description])\n : null,\n ]),\n showActions\n ? h(\"div\", { class: clsx(s.Actions, props.actionsClassName), ref: actionsRef }, [\n actions,\n props.onDismiss\n ? h(\n Button,\n { type: \"button\", onClick: props.onDismiss, color, variant: \"soft\", pill: true },\n { default: () => \"Dismiss\" },\n )\n : null,\n ])\n : null,\n ]),\n ],\n )\n }\n },\n})\n\ntype AlertOwnProps = InstanceType<typeof AlertComponent>[\"$props\"]\n\n/** Alert props plus the native <div> attributes that fall through to it, as in React. */\nexport type AlertProps = AlertOwnProps & Omit<HTMLAttributes, keyof AlertOwnProps>\n\n/** Inline message with a semantic color, optional title, description and actions. */\nexport const Alert = AlertComponent as typeof AlertComponent & { new (): { $props: AlertProps } }\n"]}
1
+ {"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../../../src/components/Alert/Alert.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EACL,eAAe,EACf,CAAC,EACD,eAAe,EACf,SAAS,EACT,GAAG,EACH,KAAK,GAKN,MAAM,KAAK,CAAA;AAEZ,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAA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AAG,EAAE,UAAU,EAAE,EAAE;4BAC5E,OAAO;4BACP,KAAK,CAAC,SAAS;gCACb,CAAC,CAAC,CAAC,CACC,MAAM,EACN,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,aAAa,EAAE,EACxG,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAC7B;gCACH,CAAC,CAAC,IAAI;yBACT,CAAC;wBACJ,CAAC,CAAC,IAAI;iBACT,CAAC;gBACF,wFAAwF;gBACxF,KAAK,CAAC,SAAS;oBACb,CAAC,CAAC,CAAC,CACC,MAAM,EACN,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,WAAW,EAAE,EACvL,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAC1B;oBACH,CAAC,CAAC,IAAI;aACT,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF,qFAAqF;AACrF,MAAM,CAAC,MAAM,KAAK,GAAG,cAA4E,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n type HTMLAttributes,\n type PropType,\n type VNodeArrayChildren,\n type VNodeChild,\n} from \"vue\"\nimport type { SemanticColors, Variants } from \"@plexui/styles/types\"\nimport { CheckCircle, Info, Warning, X } from \"../Icon/index.js\"\nimport { Button } from \"../Button/index.js\"\nimport { hasContent } from \"../../lib/slotContent.js\"\nimport s from \"@plexui/styles/components/Alert/Alert.module.css\"\n\n// Vue port of packages/ui/src/components/Alert/Alert.tsx. ReactNode props\n// are slots (`title`, `description`, `actions`, `indicator`), with string\n// props as fallback for `title` and `description`. `:indicator=\"false\"`\n// hides the indicator. `onDismiss` stays a function prop (`@dismiss` in\n// templates) because its presence adds the Dismiss button.\n// The actions auto placement mirrors usehooks-ts `useResizeObserver`: it\n// reacts to the container's content-box width only.\n\nexport type AlertColor = SemanticColors<\n \"primary\" | \"danger\" | \"success\" | \"info\" | \"discovery\" | \"caution\" | \"warning\"\n>\n\n/** Default indicator icon, chosen from the color (which signals intention). */\nconst Indicator = (color: AlertColor) => {\n switch (color) {\n case \"warning\":\n case \"caution\":\n case \"danger\":\n return h(Warning)\n case \"success\":\n return h(CheckCircle)\n default:\n return h(Info)\n }\n}\n\n// usehooks-ts `extractSize` for the content box\nconst contentBoxSize = (entry: ResizeObserverEntry, sizeType: \"inlineSize\" | \"blockSize\") => {\n const box = entry.contentBoxSize as ReadonlyArray<ResizeObserverSize> | ResizeObserverSize | undefined\n if (!box) return entry.contentRect[sizeType === \"inlineSize\" ? \"width\" : \"height\"]\n // Firefox once reported a single object instead of an array\n return Array.isArray(box) ? box[0]?.[sizeType] : (box as ResizeObserverSize)[sizeType]\n}\n\nconst AlertComponent = defineComponent({\n name: \"Alert\",\n props: {\n /** Color of the alert. @default \"primary\" */\n color: { type: String as PropType<AlertColor>, default: \"primary\" },\n /** Style variant. @default \"outline\" */\n variant: { type: String as PropType<Variants<\"solid\" | \"soft\" | \"outline\">>, default: \"outline\" },\n /** Title displayed in the alert (or the `title` slot). */\n title: String,\n /** Description text displayed in the alert (or the `description` slot). */\n description: String,\n /** Places `actions` at the end or the bottom. Automatic from sizing when unset. */\n actionsPlacement: String as PropType<\"end\" | \"bottom\">,\n /** `false` hides the indicator. Use the `indicator` slot to replace it. */\n indicator: { type: Boolean, default: undefined },\n /** Class applied to the actions container */\n actionsClassName: String,\n /** Shows the Dismiss button; called when it is clicked. */\n onDismiss: Function as PropType<(event: MouseEvent) => void>,\n /** A full-width strip across a page or panel: square corners, lines above and below only. @default false */\n banner: { type: Boolean, default: false },\n },\n setup(props, { slots }) {\n const containerRef = ref<HTMLDivElement | null>(null)\n const actionsRef = ref<HTMLDivElement | null>(null)\n const actionsAutoPlacement = ref<\"end\" | \"bottom\">(\"end\")\n const containerWidth = ref<number | undefined>(undefined)\n\n let observer: ResizeObserver | undefined\n onMounted(() => {\n const container = containerRef.value\n if (!container) return\n if (typeof window === \"undefined\" || !(\"ResizeObserver\" in window)) return\n let previousWidth: number | undefined\n let previousHeight: number | undefined\n observer = new ResizeObserver(([entry]) => {\n if (!entry) return\n const width = contentBoxSize(entry, \"inlineSize\")\n const height = contentBoxSize(entry, \"blockSize\")\n if (width !== previousWidth || height !== previousHeight) {\n previousWidth = width\n previousHeight = height\n containerWidth.value = width\n }\n })\n observer.observe(container, { box: \"content-box\" })\n })\n onBeforeUnmount(() => observer?.disconnect())\n\n watch(containerWidth, (width) => {\n const actionsWidth = actionsRef.value?.clientWidth ?? 0\n\n if (actionsWidth && width) {\n // If actions are larger than a third of the container width, wrap them.\n actionsAutoPlacement.value = actionsWidth > width / 3 ? \"bottom\" : \"end\"\n }\n })\n\n return () => {\n const { color } = props\n const title: VNodeChild = slots.title ? slots.title() : props.title\n const description: VNodeChild = slots.description ? slots.description() : props.description\n const actions = slots.actions?.()\n const showActions = hasContent(actions) || !!props.onDismiss\n\n return h(\n \"div\",\n {\n \"ref\": containerRef,\n \"class\": s.Alert,\n \"data-variant\": props.variant,\n \"data-color\": color,\n \"role\": color === \"danger\" ? \"alert\" : undefined,\n \"data-actions-placement\": props.actionsPlacement ?? actionsAutoPlacement.value,\n \"data-banner\": props.banner ? \"\" : undefined,\n },\n [\n props.indicator === false\n ? null\n : h(\"div\", { class: s.Indicator }, slots.indicator ? slots.indicator() : [Indicator(color)]),\n h(\"div\", { class: s.Content }, [\n h(\"div\", { class: s.Message }, [\n hasContent([title as VNodeArrayChildren]) ? h(\"div\", { class: s.Title }, [title]) : null,\n hasContent([description as VNodeArrayChildren])\n ? h(\"div\", { class: s.Description }, [description])\n : null,\n ]),\n showActions\n ? h(\"div\", { class: clsx(s.Actions, props.actionsClassName), ref: actionsRef }, [\n actions,\n props.onDismiss\n ? h(\n Button,\n { type: \"button\", onClick: props.onDismiss, color, variant: \"soft\", pill: true, class: s.DismissButton },\n { default: () => \"Dismiss\" },\n )\n : null,\n ])\n : null,\n ]),\n // On a phone the alert is dismissed with a close button in its corner, as an iOS tip is\n props.onDismiss\n ? h(\n Button,\n { \"type\": \"button\", \"onClick\": props.onDismiss, \"color\": \"secondary\", \"variant\": \"soft\", \"size\": \"sm\", \"uniform\": true, \"pill\": true, \"aria-label\": \"Dismiss\", \"class\": s.CloseButton },\n { default: () => [h(X)] },\n )\n : null,\n ],\n )\n }\n },\n})\n\ntype AlertOwnProps = InstanceType<typeof AlertComponent>[\"$props\"]\n\n/** Alert props plus the native <div> attributes that fall through to it, as in React. */\nexport type AlertProps = AlertOwnProps & Omit<HTMLAttributes, keyof AlertOwnProps>\n\n/** Inline message with a semantic color, optional title, description and actions. */\nexport const Alert = AlertComponent as typeof AlertComponent & { new (): { $props: AlertProps } }\n"]}
@@ -39,7 +39,9 @@ const renderImage = (url, status, onLoad, onError, imgRef) => h("span", { class:
39
39
  "role": "presentation",
40
40
  }),
41
41
  ]);
42
- const renderInitial = (name = "") => h("span", { class: s.AvatarInitial }, name.charAt(0).toUpperCase());
42
+ // The first character of the name, past any leading space and whole even when it is an emoji (a surrogate pair)
43
+ const initialOf = (name) => (Array.from(name.trim())[0] ?? "").toUpperCase();
44
+ const renderInitial = (name = "") => h("span", { class: s.AvatarInitial }, initialOf(name));
43
45
  const renderOverflowCount = (count) => {
44
46
  const formattedCount = new Intl.NumberFormat("en", {
45
47
  notation: "compact",
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../../../src/components/Av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C,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EACjC;gBACE,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC;gBAC9B,OAAO,EAAE,cAAc,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;gBACtD,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc;gBAClD,+EAA+E;gBAC/E,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;gBACpD,YAAY,EAAE,KAAK,CAAC,KAAK;gBACzB,cAAc,EAAE,KAAK,CAAC,OAAO;gBAC7B,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;gBAC5C,GAAG,SAAS;aACb,EACD,QAAQ,CACT,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,eAAe,CAAC;IACtC,IAAI,EAAE,QAAQ;IACd,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,WAAW;IAClB,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,oEAAoE;QACpE,iEAAiE;QACjE,OAAO,GAAG,EAAE;YACV,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;YACtD,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC,CAAA;QAC5F,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAUF,MAAM,CAAC,MAAM,MAAM,GAAG,eAA+E,CAAA","sourcesContent":["import { defineComponent, h, onMounted, ref, type Component, type HTMLAttributes, type PropType, type Ref, type VNode } from \"vue\"\nimport type { SemanticColors, Variants } from \"@plexui/styles/types\"\nimport { toCssVariables } from \"../../lib/helpers.js\"\nimport s from \"@plexui/styles/components/Avatar/Avatar.module.css\"\n\n// Vue port of packages/ui/src/components/Avatar/Avatar.tsx. Props, defaults\n// and rendered attributes match React 1:1 (checked by the parity tests).\n//\n// React spreads every prop it does not use (`onClick`, `onPointerDown`, `id`,\n// `style`, ...) onto the root after its own attributes. Here those arrive as\n// `attrs` and are spread last the same way, so a caller's `role`, `type` or\n// `style` wins. A `click` or `pointerdown` listener makes the avatar a button.\n\ntype ImageStatus = undefined | \"error\" | \"loaded\"\n\nexport type AvatarColor = SemanticColors<\"primary\" | \"secondary\" | \"success\" | \"info\" | \"discovery\" | \"danger\">\n\nconst avatarProps = {\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 /** Color used for the avatar. @default \"secondary\" */\n color: { type: String as PropType<AvatarColor>, default: \"secondary\" },\n /** Style variant of the avatar. @default \"soft\" */\n variant: { type: String as PropType<Variants<\"soft\" | \"solid\">>, default: \"soft\" },\n /** URL of the image to display as the avatar */\n imageUrl: String,\n /** Icon component to render in the avatar circle (e.g. `Robot` from `@plexui/vue/components/Icon`) */\n Icon: [Object, Function] as PropType<Component>,\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 renderImage = (\n url: string,\n status: ImageStatus,\n onLoad: () => void,\n onError: () => void,\n imgRef: Ref<HTMLImageElement | null>,\n) =>\n h(\"span\", { class: s.AvatarImageContainer }, [\n h(\"img\", {\n \"ref\": imgRef,\n \"onLoad\": onLoad,\n \"onError\": onError,\n \"src\": url,\n \"class\": s.AvatarImage,\n \"data-loaded\": status === \"loaded\" ? \"\" : undefined,\n \"alt\": \"\",\n \"role\": \"presentation\",\n }),\n ])\n\nconst renderInitial = (name = \"\") => h(\"span\", { class: s.AvatarInitial }, name.charAt(0).toUpperCase())\n\nconst renderOverflowCount = (count: number) => {\n const formattedCount = new Intl.NumberFormat(\"en\", {\n notation: \"compact\",\n compactDisplay: \"short\",\n maximumFractionDigits: 0,\n })\n .format(count)\n .toLocaleLowerCase()\n\n return h(\"span\", { \"class\": s.AvatarOverflowCount, \"data-letter-count\": formattedCount.length }, [\n h(\"span\", { class: s.AvatarOverflowCountSymbol }, \"+\"),\n formattedCount,\n ])\n}\n\nconst AvatarInner = defineComponent({\n name: \"AvatarInner\",\n inheritAttrs: false,\n props: avatarProps,\n setup(props, { attrs }) {\n const imageStatus = ref<ImageStatus>()\n const img = ref<HTMLImageElement | null>(null)\n\n // An image that loaded before hydration fired its load event before Vue\n // listened for it: read the element instead, as React does\n onMounted(() => {\n if (img.value && imageStatus.value !== \"loaded\" && img.value.complete && img.value.naturalWidth > 0) {\n imageStatus.value = \"loaded\"\n }\n })\n\n return () => {\n const { class: className, ...restAttrs } = attrs\n const isInteractive = !!(attrs.onPointerdown || attrs.onClick)\n const { imageUrl, overflowCount, Icon } = props\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, so the avatar is never blank.\n const placeholder = overflowCount\n ? renderOverflowCount(overflowCount)\n : Icon\n ? h(Icon, { class: s.AvatarIcon })\n : renderInitial(props.name)\n\n const children: VNode[] =\n imageUrl && imageStatus.value !== \"error\"\n ? [\n placeholder,\n renderImage(\n imageUrl,\n imageStatus.value,\n () => (imageStatus.value = \"loaded\"),\n () => (imageStatus.value = \"error\"),\n img,\n ),\n ]\n : [placeholder]\n\n return h(\n isInteractive ? \"button\" : \"span\",\n {\n \"class\": [s.Avatar, className],\n \"style\": toCssVariables({ \"avatar-size\": props.size }),\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 ? props.name : undefined,\n \"data-color\": props.color,\n \"data-variant\": props.variant,\n \"type\": isInteractive ? \"button\" : undefined,\n ...restAttrs,\n },\n children,\n )\n }\n },\n})\n\nconst AvatarComponent = defineComponent({\n name: \"Avatar\",\n inheritAttrs: false,\n props: avatarProps,\n setup(props, { attrs }) {\n // Keying off of imageUrl remounts the avatar when it changes, which\n // resets the image status, as React's `key={validImageUrl}` does\n return () => {\n const validImageUrl = validateImageUrl(props.imageUrl)\n return h(AvatarInner, { ...attrs, ...props, imageUrl: validImageUrl, key: validImageUrl })\n }\n },\n})\n\ntype AvatarOwnProps = InstanceType<typeof AvatarComponent>[\"$props\"]\n\n/**\n * Avatar props plus the attributes and listeners that fall through to the root,\n * as React's rest props do. `onClick` / `onPointerdown` make the avatar interactive.\n */\nexport type AvatarProps = AvatarOwnProps & Omit<HTMLAttributes, keyof AvatarOwnProps>\n\nexport const Avatar = AvatarComponent as typeof AvatarComponent & { new (): { $props: AvatarProps } }\n"]}
1
+ {"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../../../src/components/Avatar/Avatar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAA4E,MAAM,KAAK,CAAA;AAElI,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAclE,MAAM,WAAW,GAAG;IAClB,sDAAsD;IACtD,IAAI,EAAE,MAAM;IACZ,qDAAqD;IACrD,aAAa,EAAE,MAAM;IACrB,yCAAyC;IACzC,IAAI,EAAE,MAAM;IACZ,sDAAsD;IACtD,KAAK,EAAE,EAAE,IAAI,EAAE,MAA+B,EAAE,OAAO,EAAE,WAAW,EAAE;IACtE,mDAAmD;IACnD,OAAO,EAAE,EAAE,IAAI,EAAE,MAA8C,EAAE,OAAO,EAAE,MAAM,EAAE;IAClF,gDAAgD;IAChD,QA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E,KAAK,CAAC,KAAK;gBACzB,cAAc,EAAE,KAAK,CAAC,OAAO;gBAC7B,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;gBAC5C,GAAG,SAAS;aACb,EACD,QAAQ,CACT,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,eAAe,CAAC;IACtC,IAAI,EAAE,QAAQ;IACd,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,WAAW;IAClB,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,oEAAoE;QACpE,iEAAiE;QACjE,OAAO,GAAG,EAAE;YACV,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;YACtD,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC,CAAA;QAC5F,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAUF,MAAM,CAAC,MAAM,MAAM,GAAG,eAA+E,CAAA","sourcesContent":["import { defineComponent, h, onMounted, ref, type Component, type HTMLAttributes, type PropType, type Ref, type VNode } from \"vue\"\nimport type { SemanticColors, Variants } from \"@plexui/styles/types\"\nimport { toCssVariables } from \"../../lib/helpers.js\"\nimport s from \"@plexui/styles/components/Avatar/Avatar.module.css\"\n\n// Vue port of packages/ui/src/components/Avatar/Avatar.tsx. Props, defaults\n// and rendered attributes match React 1:1 (checked by the parity tests).\n//\n// React spreads every prop it does not use (`onClick`, `onPointerDown`, `id`,\n// `style`, ...) onto the root after its own attributes. Here those arrive as\n// `attrs` and are spread last the same way, so a caller's `role`, `type` or\n// `style` wins. A `click` or `pointerdown` listener makes the avatar a button.\n\ntype ImageStatus = undefined | \"error\" | \"loaded\"\n\nexport type AvatarColor = SemanticColors<\"primary\" | \"secondary\" | \"success\" | \"info\" | \"discovery\" | \"danger\">\n\nconst avatarProps = {\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 /** Color used for the avatar. @default \"secondary\" */\n color: { type: String as PropType<AvatarColor>, default: \"secondary\" },\n /** Style variant of the avatar. @default \"soft\" */\n variant: { type: String as PropType<Variants<\"soft\" | \"solid\">>, default: \"soft\" },\n /** URL of the image to display as the avatar */\n imageUrl: String,\n /** Icon component to render in the avatar circle (e.g. `Robot` from `@plexui/vue/components/Icon`) */\n Icon: [Object, Function] as PropType<Component>,\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 renderImage = (\n url: string,\n status: ImageStatus,\n onLoad: () => void,\n onError: () => void,\n imgRef: Ref<HTMLImageElement | null>,\n) =>\n h(\"span\", { class: s.AvatarImageContainer }, [\n h(\"img\", {\n \"ref\": imgRef,\n \"onLoad\": onLoad,\n \"onError\": onError,\n \"src\": url,\n \"class\": s.AvatarImage,\n \"data-loaded\": status === \"loaded\" ? \"\" : undefined,\n \"alt\": \"\",\n \"role\": \"presentation\",\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 renderInitial = (name = \"\") => h(\"span\", { class: s.AvatarInitial }, initialOf(name))\n\nconst renderOverflowCount = (count: number) => {\n const formattedCount = new Intl.NumberFormat(\"en\", {\n notation: \"compact\",\n compactDisplay: \"short\",\n maximumFractionDigits: 0,\n })\n .format(count)\n .toLocaleLowerCase()\n\n return h(\"span\", { \"class\": s.AvatarOverflowCount, \"data-letter-count\": formattedCount.length }, [\n h(\"span\", { class: s.AvatarOverflowCountSymbol }, \"+\"),\n formattedCount,\n ])\n}\n\nconst AvatarInner = defineComponent({\n name: \"AvatarInner\",\n inheritAttrs: false,\n props: avatarProps,\n setup(props, { attrs }) {\n const imageStatus = ref<ImageStatus>()\n const img = ref<HTMLImageElement | null>(null)\n\n // An image that loaded before hydration fired its load event before Vue\n // listened for it: read the element instead, as React does\n onMounted(() => {\n if (img.value && imageStatus.value !== \"loaded\" && img.value.complete && img.value.naturalWidth > 0) {\n imageStatus.value = \"loaded\"\n }\n })\n\n return () => {\n const { class: className, ...restAttrs } = attrs\n const isInteractive = !!(attrs.onPointerdown || attrs.onClick)\n const { imageUrl, overflowCount, Icon } = props\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, so the avatar is never blank.\n const placeholder = overflowCount\n ? renderOverflowCount(overflowCount)\n : Icon\n ? h(Icon, { class: s.AvatarIcon })\n : renderInitial(props.name)\n\n const children: VNode[] =\n imageUrl && imageStatus.value !== \"error\"\n ? [\n placeholder,\n renderImage(\n imageUrl,\n imageStatus.value,\n () => (imageStatus.value = \"loaded\"),\n () => (imageStatus.value = \"error\"),\n img,\n ),\n ]\n : [placeholder]\n\n return h(\n isInteractive ? \"button\" : \"span\",\n {\n \"class\": [s.Avatar, className],\n \"style\": toCssVariables({ \"avatar-size\": props.size }),\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 ? props.name : undefined,\n \"data-color\": props.color,\n \"data-variant\": props.variant,\n \"type\": isInteractive ? \"button\" : undefined,\n ...restAttrs,\n },\n children,\n )\n }\n },\n})\n\nconst AvatarComponent = defineComponent({\n name: \"Avatar\",\n inheritAttrs: false,\n props: avatarProps,\n setup(props, { attrs }) {\n // Keying off of imageUrl remounts the avatar when it changes, which\n // resets the image status, as React's `key={validImageUrl}` does\n return () => {\n const validImageUrl = validateImageUrl(props.imageUrl)\n return h(AvatarInner, { ...attrs, ...props, imageUrl: validImageUrl, key: validImageUrl })\n }\n },\n})\n\ntype AvatarOwnProps = InstanceType<typeof AvatarComponent>[\"$props\"]\n\n/**\n * Avatar props plus the attributes and listeners that fall through to the root,\n * as React's rest props do. `onClick` / `onPointerdown` make the avatar interactive.\n */\nexport type AvatarProps = AvatarOwnProps & Omit<HTMLAttributes, keyof AvatarOwnProps>\n\nexport const Avatar = AvatarComponent as typeof AvatarComponent & { new (): { $props: AvatarProps } }\n"]}
@@ -7,12 +7,19 @@ const ButtonGroupComponent = defineComponent({
7
7
  props: {
8
8
  /** Direction of the joined buttons. @default "horizontal" */
9
9
  orientation: { type: String, default: "horizontal" },
10
+ /**
11
+ * Phone surface (below 768px, with touch.css). `"glass"` makes the group one glass capsule, the Button Group
12
+ * of the iOS 27 kit, for controls over the content; a group in a Toolbar is one already. `"flat"` keeps the
13
+ * joined buttons in a Toolbar.
14
+ */
15
+ mobileMaterial: String,
10
16
  },
11
17
  setup(props, { slots }) {
12
18
  return () => h("div", {
13
19
  "role": "group",
14
20
  "data-slot": "button-group",
15
21
  "data-orientation": props.orientation,
22
+ "data-mobile-material": props.mobileMaterial,
16
23
  "class": s.Root,
17
24
  }, slots.default?.());
18
25
  },
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonGroup.js","sourceRoot":"","sources":["../../../../src/components/ButtonGroup/ButtonGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAsC,MAAM,KAAK,CAAA;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAY5E,MAAM,oBAAoB,GAAG,eAAe,CAAC;IAC3C,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE;QACL,6DAA6D;QAC7D,W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,EAAE,WAAW,EAAE,mBAAmB,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,EAAE,CAAA;YACjG,IAAI,CAAC,KAAK,CAAC,OAAO;gBAAE,OAAO,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YAChE,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YAClD,OAAO,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QACvD,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { defineComponent, h, type HTMLAttributes, type PropType } from \"vue\"\nimport { Separator } from \"../Separator/index.js\"\nimport { firstElementChild, mergeSlotProps } from \"../Tooltip/slot.js\"\nimport s from \"@plexui/styles/components/ButtonGroup/ButtonGroup.module.css\"\n\n// Vue port of packages/ui/src/components/ButtonGroup/ButtonGroup.tsx.\n// Exports are flat (`ButtonGroupSeparator` for `ButtonGroup.Separator`, ...).\n// React spreads the remaining props after its own attributes, so caller\n// attributes win; Vue's attribute fallthrough merges them the same way.\n// `asChild` merges the way Radix's Slot does (the slot's class comes first,\n// the child's own props win, the child's handlers run first), which Reka's\n// Slot does not, hence the Tooltip's slot helpers.\n\nexport type ButtonGroupOrientation = \"horizontal\" | \"vertical\"\n\nconst ButtonGroupComponent = defineComponent({\n name: \"ButtonGroup\",\n props: {\n /** Direction of the joined buttons. @default \"horizontal\" */\n orientation: { type: String as PropType<ButtonGroupOrientation>, default: \"horizontal\" },\n },\n setup(props, { slots }) {\n return () =>\n h(\n \"div\",\n {\n \"role\": \"group\",\n \"data-slot\": \"button-group\",\n \"data-orientation\": props.orientation,\n \"class\": s.Root,\n },\n slots.default?.(),\n )\n },\n})\n\ntype ButtonGroupOwnProps = InstanceType<typeof ButtonGroupComponent>[\"$props\"]\n\n/** ButtonGroup props plus the native <div> attributes that fall through to it, as in React. */\nexport type ButtonGroupProps = ButtonGroupOwnProps & Omit<HTMLAttributes, keyof ButtonGroupOwnProps>\n\n/** Joins buttons, inputs and other controls into a single visual unit. */\nexport const ButtonGroup = ButtonGroupComponent as typeof ButtonGroupComponent & {\n new (): { $props: ButtonGroupProps }\n}\n\n/** Thin divider between items (React `ButtonGroup.Separator`). Other props go to `Separator`. */\nexport const ButtonGroupSeparator = defineComponent({\n name: \"ButtonGroupSeparator\",\n props: {\n /**\n * When omitted, uses `\"vertical\"`, the axis that looks right between\n * horizontal items. Pass explicitly inside a vertical group.\n */\n orientation: String as PropType<ButtonGroupOrientation>,\n },\n setup(props) {\n return () =>\n h(Separator, {\n \"data-slot\": \"button-group-separator\",\n \"orientation\": props.orientation ?? \"vertical\",\n \"class\": s.Separator,\n })\n },\n})\n\nexport type ButtonGroupSeparatorProps = InstanceType<typeof ButtonGroupSeparator>[\"$props\"] & {\n decorative?: boolean\n}\n\n/** Muted label sharing the group's joined geometry (React `ButtonGroup.Text`). */\nexport const ButtonGroupText = defineComponent({\n name: \"ButtonGroupText\",\n inheritAttrs: false,\n props: {\n /**\n * Render the passed child (label, span, ...) instead of a `<div>`, while\n * keeping the group's visual treatment.\n * @default false\n */\n asChild: { type: Boolean, default: false },\n },\n setup(props, { attrs, slots }) {\n return () => {\n const { class: className, ...restAttrs } = attrs\n const ownProps = { \"data-slot\": \"button-group-text\", \"class\": [s.Text, className], ...restAttrs }\n if (!props.asChild) return h(\"div\", ownProps, slots.default?.())\n const child = firstElementChild(slots.default?.())\n return child ? mergeSlotProps(child, ownProps) : null\n }\n },\n})\n\nexport type ButtonGroupTextProps = InstanceType<typeof ButtonGroupText>[\"$props\"] & HTMLAttributes\n"]}
1
+ {"version":3,"file":"ButtonGroup.js","sourceRoot":"","sources":["../../../../src/components/ButtonGroup/ButtonGroup.ts"],"names":[],"mappings":"AAAA,OAAO,E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AAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;IAC7C,IAAI,EAAE,iBAAiB;IACvB,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE;QACL;;;;WAIG;QACH,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;KAC3C;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;QAC3B,OAAO,GAAG,EAAE;YACV,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAA;YAChD,MAAM,QAAQ,GAAG,EAAE,WAAW,EAAE,mBAAmB,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,EAAE,CAAA;YACjG,IAAI,CAAC,KAAK,CAAC,OAAO;gBAAE,OAAO,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YAChE,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YAClD,OAAO,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QACvD,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { defineComponent, h, type HTMLAttributes, type PropType } from \"vue\"\nimport { Separator } from \"../Separator/index.js\"\nimport { firstElementChild, mergeSlotProps } from \"../Tooltip/slot.js\"\nimport s from \"@plexui/styles/components/ButtonGroup/ButtonGroup.module.css\"\n\n// Vue port of packages/ui/src/components/ButtonGroup/ButtonGroup.tsx.\n// Exports are flat (`ButtonGroupSeparator` for `ButtonGroup.Separator`, ...).\n// React spreads the remaining props after its own attributes, so caller\n// attributes win; Vue's attribute fallthrough merges them the same way.\n// `asChild` merges the way Radix's Slot does (the slot's class comes first,\n// the child's own props win, the child's handlers run first), which Reka's\n// Slot does not, hence the Tooltip's slot helpers.\n\nexport type ButtonGroupOrientation = \"horizontal\" | \"vertical\"\n\nexport type ButtonGroupMobileMaterial = \"glass\" | \"flat\"\n\nconst ButtonGroupComponent = defineComponent({\n name: \"ButtonGroup\",\n props: {\n /** Direction of the joined buttons. @default \"horizontal\" */\n orientation: { type: String as PropType<ButtonGroupOrientation>, default: \"horizontal\" },\n /**\n * Phone surface (below 768px, with touch.css). `\"glass\"` makes the group one glass capsule, the Button Group\n * of the iOS 27 kit, for controls over the content; a group in a Toolbar is one already. `\"flat\"` keeps the\n * joined buttons in a Toolbar.\n */\n mobileMaterial: String as PropType<ButtonGroupMobileMaterial>,\n },\n setup(props, { slots }) {\n return () =>\n h(\n \"div\",\n {\n \"role\": \"group\",\n \"data-slot\": \"button-group\",\n \"data-orientation\": props.orientation,\n \"data-mobile-material\": props.mobileMaterial,\n \"class\": s.Root,\n },\n slots.default?.(),\n )\n },\n})\n\ntype ButtonGroupOwnProps = InstanceType<typeof ButtonGroupComponent>[\"$props\"]\n\n/** ButtonGroup props plus the native <div> attributes that fall through to it, as in React. */\nexport type ButtonGroupProps = ButtonGroupOwnProps & Omit<HTMLAttributes, keyof ButtonGroupOwnProps>\n\n/** Joins buttons, inputs and other controls into a single visual unit. */\nexport const ButtonGroup = ButtonGroupComponent as typeof ButtonGroupComponent & {\n new (): { $props: ButtonGroupProps }\n}\n\n/** Thin divider between items (React `ButtonGroup.Separator`). Other props go to `Separator`. */\nexport const ButtonGroupSeparator = defineComponent({\n name: \"ButtonGroupSeparator\",\n props: {\n /**\n * When omitted, uses `\"vertical\"`, the axis that looks right between\n * horizontal items. Pass explicitly inside a vertical group.\n */\n orientation: String as PropType<ButtonGroupOrientation>,\n },\n setup(props) {\n return () =>\n h(Separator, {\n \"data-slot\": \"button-group-separator\",\n \"orientation\": props.orientation ?? \"vertical\",\n \"class\": s.Separator,\n })\n },\n})\n\nexport type ButtonGroupSeparatorProps = InstanceType<typeof ButtonGroupSeparator>[\"$props\"] & {\n decorative?: boolean\n}\n\n/** Muted label sharing the group's joined geometry (React `ButtonGroup.Text`). */\nexport const ButtonGroupText = defineComponent({\n name: \"ButtonGroupText\",\n inheritAttrs: false,\n props: {\n /**\n * Render the passed child (label, span, ...) instead of a `<div>`, while\n * keeping the group's visual treatment.\n * @default false\n */\n asChild: { type: Boolean, default: false },\n },\n setup(props, { attrs, slots }) {\n return () => {\n const { class: className, ...restAttrs } = attrs\n const ownProps = { \"data-slot\": \"button-group-text\", \"class\": [s.Text, className], ...restAttrs }\n if (!props.asChild) return h(\"div\", ownProps, slots.default?.())\n const child = firstElementChild(slots.default?.())\n return child ? mergeSlotProps(child, ownProps) : null\n }\n },\n})\n\nexport type ButtonGroupTextProps = InstanceType<typeof ButtonGroupText>[\"$props\"] & HTMLAttributes\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ButtonGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,eAAe,GAKhB,MAAM,kBAAkB,CAAA","sourcesContent":["export {\n ButtonGroup,\n ButtonGroupSeparator,\n ButtonGroupText,\n type ButtonGroupOrientation,\n type ButtonGroupProps,\n type ButtonGroupSeparatorProps,\n type ButtonGroupTextProps,\n} from \"./ButtonGroup.js\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ButtonGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,eAAe,GAMhB,MAAM,kBAAkB,CAAA","sourcesContent":["export {\n ButtonGroup,\n ButtonGroupSeparator,\n ButtonGroupText,\n type ButtonGroupMobileMaterial,\n type ButtonGroupOrientation,\n type ButtonGroupProps,\n type ButtonGroupSeparatorProps,\n type ButtonGroupTextProps,\n} from \"./ButtonGroup.js\"\n"]}
@@ -147,12 +147,11 @@ const CheckboxComponent = defineComponent({
147
147
  // a long list of boxes cleared at once forces one style pass per box.
148
148
  {
149
149
  default: () => h("span", { class: s.IndicatorBox, "aria-hidden": "true" }, [
150
- // A ghost marks the choice with the PlexUI icons of a list row, not with drawn arms.
151
- props.variant === "ghost"
152
- ? h(RekaCheckboxIndicator, { class: s.GhostMark, forceMount: true }, {
153
- default: () => [h(Check, { class: s.GhostCheck }), h(Minus, { class: s.GhostDash })],
154
- })
155
- : h(RekaCheckboxIndicator, { class: s.CheckMark, forceMount: true }),
150
+ // The mark is the PlexUI Check icon, and Minus when indeterminate: white on a solid
151
+ // box, in the text color for a ghost.
152
+ h(RekaCheckboxIndicator, { class: props.variant === "ghost" ? s.GhostMark : s.CheckMark, forceMount: true }, {
153
+ default: () => [h(Check, { class: s.MarkCheck }), h(Minus, { class: s.MarkDash })],
154
+ }),
156
155
  ]),
157
156
  }),
158
157
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../../src/components/Checkbox/Checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAiB,MAAM,KAAK,CAAA;AAC/F,OAAO,EAAE,iBAAiB,IAAI,qBAAqB,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAA;AACtG,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACvH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,oBAAoB,CAAA;AAC9E,OAAO,CAAC,MAAM,wDAAwD,CAAA;AACtE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAY/C,MAAM,iBAAiB,GAAG,eAAe,CAAC;IACxC,IAAI,EAAE,UAAU;IAChB,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE;QACL,gCAA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,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI;wBAC7B,MAAM,EAAE,IAAI;wBACZ,UAAU,EAAE,CAAC,CAAC;wBACd,OAAO,EAAE,gBAAgB,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;qBACjF,CAAC;oBACJ,CAAC,CAAC,IAAI;gBACR,aAAa;oBACX,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE,EAAE;wBAChC,YAAY;wBACZ,CAAC,CACC,MAAM,EACN,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,WAAW,EAAE,EAC3C,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAC5D;qBACF,CAAC;oBACJ,CAAC,CAAC,YAAY;aACjB,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAMF,MAAM,CAAC,MAAM,QAAQ,GAAG,iBAAiB,CAAA","sourcesContent":["import { computed, defineComponent, h, onMounted, ref, useId, watch, type PropType } from \"vue\"\nimport { CheckboxIndicator as RekaCheckboxIndicator, CheckboxRoot as RekaCheckboxRoot } from \"reka-ui\"\nimport { bubbleInputStyle, useBubbleInputEffect, useCheckedTracker, useIsFormControl, useSize } from \"./bubbleInput.js\"\nimport { ControlButton, isListener, type Listeners } from \"./ControlButton.js\"\nimport s from \"@plexui/styles/components/Checkbox/Checkbox.module.css\"\nimport { Check, Minus } from \"../Icon/index.js\"\n\n// Vue port of packages/ui/src/components/Checkbox/Checkbox.tsx on Reka UI's\n// Checkbox (state, role, aria-checked, Enter handling, indicator presence).\n// Where Reka's DOM differs from Radix's, Radix's is rendered (see the parity\n// tests): the button carries `value`, no `aria-disabled` and no `aria-label`\n// copied from the label text; the hidden form input is Radix's BubbleInput;\n// the consumer's handlers run before the toggle and can cancel it; a form\n// reset restores the initial state.\n\nexport type CheckedState = boolean | \"indeterminate\"\n\nconst CheckboxComponent = defineComponent({\n name: \"Checkbox\",\n inheritAttrs: false,\n props: {\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: { type: [Boolean, String] as PropType<CheckedState>, default: undefined },\n /** The controlled state of the checkbox. Bind with `v-model:checked`. */\n checked: { type: [Boolean, String] as PropType<CheckedState>, default: undefined },\n /** Optional accessible label rendered to the right of the checkbox. The `label` slot takes rich content. */\n label: String,\n /** Optional second line below the label, linked via `aria-describedby`. The `description` slot takes rich content. */\n description: String,\n /** When `true`, prevents the user from interacting with the checkbox. */\n disabled: { type: Boolean, default: false },\n /** When `true`, indicates that the user must check the checkbox before the owning form can be submitted. */\n required: { type: Boolean, default: undefined },\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`. @default \"on\" */\n value: String,\n /** The orientation of the checkbox relative to the label. @default \"left\" */\n orientation: { type: String as PropType<\"left\" | \"right\">, default: \"left\" },\n /** Determines if the checkbox should be a fully rounded pill shape. @default false */\n pill: { type: Boolean, default: false },\n /** Visual style: `\"solid\"` fills the box when checked, `\"ghost\"` shows the checkmark only. @default \"solid\" */\n variant: { type: String as PropType<\"solid\" | \"ghost\">, default: \"solid\" },\n },\n emits: {\n /** The state of the checkbox changed */\n \"update:checked\": (checked: CheckedState) => typeof checked === \"boolean\" || checked === \"indeterminate\",\n /** The checkbox gained focus */\n focus: (event: FocusEvent) => { void event; return true },\n /** The checkbox lost focus */\n blur: (event: FocusEvent) => { void event; return true },\n },\n setup(props, { attrs, slots, emit }) {\n const generatedId = useId()\n const container = ref<HTMLDivElement | null>(null)\n const control = ref<HTMLButtonElement | null>(null)\n const bubbleInput = ref<HTMLInputElement | null>(null)\n useCheckedTracker(bubbleInput)\n\n // Radix's useControllableState: controlled while `checked` is set, and\n // only actual changes are reported\n const internalChecked = ref<CheckedState>(props.defaultChecked ?? false)\n const checked = computed(() => props.checked ?? internalChecked.value)\n // The state a click asks for (Reka's toggle sets it), for the user click\n let requestedChecked = true\n const setChecked = (next: CheckedState) => {\n requestedChecked = next === true\n if (next === checked.value) return\n if (props.checked === undefined) internalChecked.value = next\n emit(\"update:checked\", next)\n }\n\n const initialChecked = checked.value\n const isFormControl = useIsFormControl(control, () => attrs.form)\n const controlSize = useSize(() => (isFormControl.value ? control.value : null))\n const onUserClick = useBubbleInputEffect(bubbleInput, () => checked.value, true)\n\n onMounted(() => {\n control.value = (container.value?.firstElementChild as HTMLButtonElement | null) ?? null\n })\n\n // Like a native checkbox, a form reset restores the initial state\n watch(control, (button, _, onCleanup) => {\n const form = button?.form\n if (!form) return\n const reset = () => setChecked(initialChecked)\n form.addEventListener(\"reset\", reset)\n onCleanup(() => form.removeEventListener(\"reset\", reset))\n })\n\n // In a form, the button's click stops here; the input's click bubbles instead\n const afterClick = (event: Event) => {\n const hasConsumerStoppedPropagation = event.cancelBubble\n onUserClick({ requestedChecked, hasConsumerStoppedPropagation })\n if (bubbleInput.value && isFormControl.value && !hasConsumerStoppedPropagation) event.stopPropagation()\n }\n\n // Prevents text selection when double-clicking the label\n const handleLabelMouseDown = (event: MouseEvent) => {\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault()\n }\n\n return () => {\n const { class: className, form, ...rest } = attrs\n const id = props.id ?? generatedId\n const hasLabel = Boolean(slots.label || props.label)\n // The description only renders next to a label; it comes before any ids\n // the caller (a Field, say) passes\n const descriptionId = hasLabel && (slots.description || props.description) ? `${id}-label-description` : undefined\n const indeterminateDefault = props.defaultChecked === \"indeterminate\" ? false : props.defaultChecked\n const inputDefaultChecked = indeterminateDefault ?? (initialChecked === \"indeterminate\" ? false : initialChecked)\n\n // The consumer's listeners compose with Reka's; other attributes land\n // on the button after the component's own, as `{...restProps}` does\n const listeners: Listeners = {\n onFocus: (event: FocusEvent) => emit(\"focus\", event),\n onBlur: (event: FocusEvent) => emit(\"blur\", event),\n }\n const buttonAttrs: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(rest)) {\n if (isListener(key)) listeners[key] = value\n else buttonAttrs[key] = value\n }\n const ariaDescribedBy =\n [descriptionId, buttonAttrs[\"aria-describedby\"] as string | undefined].filter(Boolean).join(\" \") || undefined\n const labelElement = hasLabel\n ? h(\"label\", { for: id, class: s.Label, onMousedown: handleLabelMouseDown }, slots.label ? slots.label() : props.label)\n : null\n\n return h(\n \"div\",\n {\n \"ref\": container,\n \"data-disabled\": props.disabled ? \"\" : undefined,\n \"data-has-label\": hasLabel ? \"\" : undefined,\n \"data-orientation\": props.orientation,\n \"class\": [className, s.Container],\n },\n [\n h(\n RekaCheckboxRoot as never,\n {\n \"asChild\": true,\n \"modelValue\": checked.value,\n \"onUpdate:modelValue\": setChecked,\n \"disabled\": props.disabled,\n // Passed even when unset, so Reka renders no aria-required=\"false\"\n \"required\": props.required,\n },\n {\n default: () =>\n h(\n ControlButton,\n {\n \"listeners\": listeners,\n \"after\": { onClick: afterClick },\n \"class\": s.Checkbox,\n \"id\": id,\n \"data-pill\": props.pill ? \"\" : undefined,\n \"data-variant\": props.variant,\n \"value\": props.value ?? \"on\",\n // Reka marks a disabled checkbox aria-disabled; Radix does not\n \"aria-disabled\": undefined,\n ...buttonAttrs,\n \"aria-describedby\": ariaDescribedBy,\n },\n // Mounted for good: on every uncheck Presence reads computed style, and\n // a long list of boxes cleared at once forces one style pass per box.\n {\n default: () => h(\"span\", { class: s.IndicatorBox, \"aria-hidden\": \"true\" }, [\n // A ghost marks the choice with the PlexUI icons of a list row, not with drawn arms.\n props.variant === \"ghost\"\n ? h(RekaCheckboxIndicator, { class: s.GhostMark, forceMount: true }, {\n default: () => [h(Check, { class: s.GhostCheck }), h(Minus, { class: s.GhostDash })],\n })\n : h(RekaCheckboxIndicator, { class: s.CheckMark, forceMount: true }),\n ]),\n },\n ),\n },\n ),\n isFormControl.value\n ? h(\"input\", {\n \"ref\": bubbleInput,\n \"type\": \"checkbox\",\n \"aria-hidden\": \"true\",\n \"^checked\": inputDefaultChecked ? \"\" : undefined,\n \"required\": props.required,\n \"disabled\": props.disabled,\n \"name\": props.name,\n \"^value\": props.value ?? \"on\",\n \"form\": form,\n \"tabindex\": -1,\n \"style\": bubbleInputStyle(controlSize.value, { transform: \"translateX(-100%)\" }),\n })\n : null,\n descriptionId\n ? h(\"div\", { class: s.LabelGroup }, [\n labelElement,\n h(\n \"span\",\n { id: descriptionId, class: s.Description },\n slots.description ? slots.description() : props.description,\n ),\n ])\n : labelElement,\n ],\n )\n }\n },\n})\n\ntype CheckboxOwnProps = InstanceType<typeof CheckboxComponent>[\"$props\"]\n\nexport type CheckboxProps = CheckboxOwnProps\n\nexport const Checkbox = CheckboxComponent\n"]}
1
+ {"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../../src/components/Checkbox/Checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAiB,MAAM,KAAK,CAAA;AAC/F,OAAO,EAAE,iBAAiB,IAAI,qBAAqB,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAA;AACtG,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACvH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,oBAAoB,CAAA;AAC9E,OAAO,CAAC,MAAM,wDAAwD,CAAA;AACtE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAY/C,MAAM,iBAAiB,GAAG,eAAe,CAAC;IACxC,IAAI,EAAE,UAAU;IAChB,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE;QACL,gCAAgC;QAChC,EAAE,EAAE,MAAM;QACV,8GAA8G;QAC9G,cAAc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gB,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;qBACjF,CAAC;oBACJ,CAAC,CAAC,IAAI;gBACR,aAAa;oBACX,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE,EAAE;wBAChC,YAAY;wBACZ,CAAC,CACC,MAAM,EACN,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,WAAW,EAAE,EAC3C,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAC5D;qBACF,CAAC;oBACJ,CAAC,CAAC,YAAY;aACjB,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAMF,MAAM,CAAC,MAAM,QAAQ,GAAG,iBAAiB,CAAA","sourcesContent":["import { computed, defineComponent, h, onMounted, ref, useId, watch, type PropType } from \"vue\"\nimport { CheckboxIndicator as RekaCheckboxIndicator, CheckboxRoot as RekaCheckboxRoot } from \"reka-ui\"\nimport { bubbleInputStyle, useBubbleInputEffect, useCheckedTracker, useIsFormControl, useSize } from \"./bubbleInput.js\"\nimport { ControlButton, isListener, type Listeners } from \"./ControlButton.js\"\nimport s from \"@plexui/styles/components/Checkbox/Checkbox.module.css\"\nimport { Check, Minus } from \"../Icon/index.js\"\n\n// Vue port of packages/ui/src/components/Checkbox/Checkbox.tsx on Reka UI's\n// Checkbox (state, role, aria-checked, Enter handling, indicator presence).\n// Where Reka's DOM differs from Radix's, Radix's is rendered (see the parity\n// tests): the button carries `value`, no `aria-disabled` and no `aria-label`\n// copied from the label text; the hidden form input is Radix's BubbleInput;\n// the consumer's handlers run before the toggle and can cancel it; a form\n// reset restores the initial state.\n\nexport type CheckedState = boolean | \"indeterminate\"\n\nconst CheckboxComponent = defineComponent({\n name: \"Checkbox\",\n inheritAttrs: false,\n props: {\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: { type: [Boolean, String] as PropType<CheckedState>, default: undefined },\n /** The controlled state of the checkbox. Bind with `v-model:checked`. */\n checked: { type: [Boolean, String] as PropType<CheckedState>, default: undefined },\n /** Optional accessible label rendered to the right of the checkbox. The `label` slot takes rich content. */\n label: String,\n /** Optional second line below the label, linked via `aria-describedby`. The `description` slot takes rich content. */\n description: String,\n /** When `true`, prevents the user from interacting with the checkbox. */\n disabled: { type: Boolean, default: false },\n /** When `true`, indicates that the user must check the checkbox before the owning form can be submitted. */\n required: { type: Boolean, default: undefined },\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`. @default \"on\" */\n value: String,\n /** The orientation of the checkbox relative to the label. @default \"left\" */\n orientation: { type: String as PropType<\"left\" | \"right\">, default: \"left\" },\n /** Determines if the checkbox should be a fully rounded pill shape. @default false */\n pill: { type: Boolean, default: false },\n /** Visual style: `\"solid\"` fills the box when checked, `\"ghost\"` shows the checkmark only. @default \"solid\" */\n variant: { type: String as PropType<\"solid\" | \"ghost\">, default: \"solid\" },\n },\n emits: {\n /** The state of the checkbox changed */\n \"update:checked\": (checked: CheckedState) => typeof checked === \"boolean\" || checked === \"indeterminate\",\n /** The checkbox gained focus */\n focus: (event: FocusEvent) => { void event; return true },\n /** The checkbox lost focus */\n blur: (event: FocusEvent) => { void event; return true },\n },\n setup(props, { attrs, slots, emit }) {\n const generatedId = useId()\n const container = ref<HTMLDivElement | null>(null)\n const control = ref<HTMLButtonElement | null>(null)\n const bubbleInput = ref<HTMLInputElement | null>(null)\n useCheckedTracker(bubbleInput)\n\n // Radix's useControllableState: controlled while `checked` is set, and\n // only actual changes are reported\n const internalChecked = ref<CheckedState>(props.defaultChecked ?? false)\n const checked = computed(() => props.checked ?? internalChecked.value)\n // The state a click asks for (Reka's toggle sets it), for the user click\n let requestedChecked = true\n const setChecked = (next: CheckedState) => {\n requestedChecked = next === true\n if (next === checked.value) return\n if (props.checked === undefined) internalChecked.value = next\n emit(\"update:checked\", next)\n }\n\n const initialChecked = checked.value\n const isFormControl = useIsFormControl(control, () => attrs.form)\n const controlSize = useSize(() => (isFormControl.value ? control.value : null))\n const onUserClick = useBubbleInputEffect(bubbleInput, () => checked.value, true)\n\n onMounted(() => {\n control.value = (container.value?.firstElementChild as HTMLButtonElement | null) ?? null\n })\n\n // Like a native checkbox, a form reset restores the initial state\n watch(control, (button, _, onCleanup) => {\n const form = button?.form\n if (!form) return\n const reset = () => setChecked(initialChecked)\n form.addEventListener(\"reset\", reset)\n onCleanup(() => form.removeEventListener(\"reset\", reset))\n })\n\n // In a form, the button's click stops here; the input's click bubbles instead\n const afterClick = (event: Event) => {\n const hasConsumerStoppedPropagation = event.cancelBubble\n onUserClick({ requestedChecked, hasConsumerStoppedPropagation })\n if (bubbleInput.value && isFormControl.value && !hasConsumerStoppedPropagation) event.stopPropagation()\n }\n\n // Prevents text selection when double-clicking the label\n const handleLabelMouseDown = (event: MouseEvent) => {\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault()\n }\n\n return () => {\n const { class: className, form, ...rest } = attrs\n const id = props.id ?? generatedId\n const hasLabel = Boolean(slots.label || props.label)\n // The description only renders next to a label; it comes before any ids\n // the caller (a Field, say) passes\n const descriptionId = hasLabel && (slots.description || props.description) ? `${id}-label-description` : undefined\n const indeterminateDefault = props.defaultChecked === \"indeterminate\" ? false : props.defaultChecked\n const inputDefaultChecked = indeterminateDefault ?? (initialChecked === \"indeterminate\" ? false : initialChecked)\n\n // The consumer's listeners compose with Reka's; other attributes land\n // on the button after the component's own, as `{...restProps}` does\n const listeners: Listeners = {\n onFocus: (event: FocusEvent) => emit(\"focus\", event),\n onBlur: (event: FocusEvent) => emit(\"blur\", event),\n }\n const buttonAttrs: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(rest)) {\n if (isListener(key)) listeners[key] = value\n else buttonAttrs[key] = value\n }\n const ariaDescribedBy =\n [descriptionId, buttonAttrs[\"aria-describedby\"] as string | undefined].filter(Boolean).join(\" \") || undefined\n const labelElement = hasLabel\n ? h(\"label\", { for: id, class: s.Label, onMousedown: handleLabelMouseDown }, slots.label ? slots.label() : props.label)\n : null\n\n return h(\n \"div\",\n {\n \"ref\": container,\n \"data-disabled\": props.disabled ? \"\" : undefined,\n \"data-has-label\": hasLabel ? \"\" : undefined,\n \"data-orientation\": props.orientation,\n \"class\": [className, s.Container],\n },\n [\n h(\n RekaCheckboxRoot as never,\n {\n \"asChild\": true,\n \"modelValue\": checked.value,\n \"onUpdate:modelValue\": setChecked,\n \"disabled\": props.disabled,\n // Passed even when unset, so Reka renders no aria-required=\"false\"\n \"required\": props.required,\n },\n {\n default: () =>\n h(\n ControlButton,\n {\n \"listeners\": listeners,\n \"after\": { onClick: afterClick },\n \"class\": s.Checkbox,\n \"id\": id,\n \"data-pill\": props.pill ? \"\" : undefined,\n \"data-variant\": props.variant,\n \"value\": props.value ?? \"on\",\n // Reka marks a disabled checkbox aria-disabled; Radix does not\n \"aria-disabled\": undefined,\n ...buttonAttrs,\n \"aria-describedby\": ariaDescribedBy,\n },\n // Mounted for good: on every uncheck Presence reads computed style, and\n // a long list of boxes cleared at once forces one style pass per box.\n {\n default: () => h(\"span\", { class: s.IndicatorBox, \"aria-hidden\": \"true\" }, [\n // The mark is the PlexUI Check icon, and Minus when indeterminate: white on a solid\n // box, in the text color for a ghost.\n h(RekaCheckboxIndicator, { class: props.variant === \"ghost\" ? s.GhostMark : s.CheckMark, forceMount: true }, {\n default: () => [h(Check, { class: s.MarkCheck }), h(Minus, { class: s.MarkDash })],\n }),\n ]),\n },\n ),\n },\n ),\n isFormControl.value\n ? h(\"input\", {\n \"ref\": bubbleInput,\n \"type\": \"checkbox\",\n \"aria-hidden\": \"true\",\n \"^checked\": inputDefaultChecked ? \"\" : undefined,\n \"required\": props.required,\n \"disabled\": props.disabled,\n \"name\": props.name,\n \"^value\": props.value ?? \"on\",\n \"form\": form,\n \"tabindex\": -1,\n \"style\": bubbleInputStyle(controlSize.value, { transform: \"translateX(-100%)\" }),\n })\n : null,\n descriptionId\n ? h(\"div\", { class: s.LabelGroup }, [\n labelElement,\n h(\n \"span\",\n { id: descriptionId, class: s.Description },\n slots.description ? slots.description() : props.description,\n ),\n ])\n : labelElement,\n ],\n )\n }\n },\n})\n\ntype CheckboxOwnProps = InstanceType<typeof CheckboxComponent>[\"$props\"]\n\nexport type CheckboxProps = CheckboxOwnProps\n\nexport const Checkbox = CheckboxComponent\n"]}