@canonical/react-ds-global 0.29.0 → 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 (300) hide show
  1. package/README.md +33 -0
  2. package/dist/esm/lib/_work_in_progress/IconSection/IconSection.js +1 -1
  3. package/dist/esm/lib/_work_in_progress/IconSection/IconSection.js.map +1 -1
  4. package/dist/esm/lib/_work_in_progress/index.js +13 -0
  5. package/dist/esm/lib/_work_in_progress/index.js.map +1 -0
  6. package/dist/esm/lib/component/Accordion/Accordion.js +2 -0
  7. package/dist/esm/lib/component/Accordion/Accordion.js.map +1 -1
  8. package/dist/esm/lib/component/Accordion/common/Item/styles.css +19 -50
  9. package/dist/esm/lib/component/Accordion/styles.css +5 -1
  10. package/dist/esm/lib/component/Announcement/Announcement.js +5 -3
  11. package/dist/esm/lib/component/Announcement/Announcement.js.map +1 -1
  12. package/dist/esm/lib/component/Announcement/index.js +1 -0
  13. package/dist/esm/lib/component/Announcement/index.js.map +1 -1
  14. package/dist/esm/lib/component/Announcement/styles.css +60 -36
  15. package/dist/esm/lib/component/Breadcrumbs/Breadcrumbs.js +2 -0
  16. package/dist/esm/lib/component/Breadcrumbs/Breadcrumbs.js.map +1 -1
  17. package/dist/esm/lib/component/Breadcrumbs/common/Item/Item.js +1 -1
  18. package/dist/esm/lib/component/Breadcrumbs/common/Item/Item.js.map +1 -1
  19. package/dist/esm/lib/component/Button/Button.js +13 -5
  20. package/dist/esm/lib/component/Button/Button.js.map +1 -1
  21. package/dist/esm/lib/component/Button/styles.css +135 -39
  22. package/dist/esm/lib/component/Card/Card.js +9 -6
  23. package/dist/esm/lib/component/Card/Card.js.map +1 -1
  24. package/dist/esm/lib/component/Card/common/Content/styles.css +1 -1
  25. package/dist/esm/lib/component/Card/common/Footer/Footer.js +1 -1
  26. package/dist/esm/lib/component/Card/common/Footer/styles.css +1 -1
  27. package/dist/esm/lib/component/Card/common/Header/styles.css +1 -1
  28. package/dist/esm/lib/component/Card/common/index.js +0 -1
  29. package/dist/esm/lib/component/Card/common/index.js.map +1 -1
  30. package/dist/esm/lib/component/Card/styles.css +8 -8
  31. package/dist/esm/lib/component/ContextualMenu/ContextualMenu.js +94 -0
  32. package/dist/esm/lib/component/ContextualMenu/ContextualMenu.js.map +1 -0
  33. package/dist/esm/lib/component/ContextualMenu/common/Item/Item.js +32 -0
  34. package/dist/esm/lib/component/ContextualMenu/common/Item/Item.js.map +1 -0
  35. package/dist/esm/lib/component/ContextualMenu/common/Item/index.js +2 -0
  36. package/dist/esm/lib/component/ContextualMenu/common/Item/index.js.map +1 -0
  37. package/dist/esm/lib/component/ContextualMenu/common/Item/styles.css +93 -0
  38. package/dist/esm/lib/component/ContextualMenu/common/Item/types.js.map +1 -0
  39. package/dist/esm/lib/component/ContextualMenu/common/MenuContext.js +12 -0
  40. package/dist/esm/lib/component/ContextualMenu/common/MenuContext.js.map +1 -0
  41. package/dist/esm/lib/component/ContextualMenu/common/SubMenu/SubMenu.js +109 -0
  42. package/dist/esm/lib/component/ContextualMenu/common/SubMenu/SubMenu.js.map +1 -0
  43. package/dist/esm/lib/component/ContextualMenu/common/SubMenu/index.js +2 -0
  44. package/dist/esm/lib/component/ContextualMenu/common/SubMenu/index.js.map +1 -0
  45. package/dist/esm/lib/component/ContextualMenu/index.js +2 -0
  46. package/dist/esm/lib/component/ContextualMenu/index.js.map +1 -0
  47. package/dist/esm/lib/component/ContextualMenu/styles.css +86 -0
  48. package/dist/esm/lib/component/ContextualMenu/types.js.map +1 -0
  49. package/dist/esm/lib/component/Icon/Icon.js +3 -0
  50. package/dist/esm/lib/component/Icon/Icon.js.map +1 -1
  51. package/dist/esm/lib/component/InlineCode/InlineCode.js +2 -0
  52. package/dist/esm/lib/component/InlineCode/InlineCode.js.map +1 -1
  53. package/dist/esm/lib/component/KeyboardKey/KeyboardKey.js +2 -0
  54. package/dist/esm/lib/component/KeyboardKey/KeyboardKey.js.map +1 -1
  55. package/dist/esm/lib/component/Popover/Popover.js +50 -0
  56. package/dist/esm/lib/component/Popover/Popover.js.map +1 -0
  57. package/dist/esm/lib/component/Popover/index.js +2 -0
  58. package/dist/esm/lib/component/Popover/index.js.map +1 -0
  59. package/dist/esm/lib/component/Popover/styles.css +65 -0
  60. package/dist/esm/lib/component/Popover/types.js +2 -0
  61. package/dist/esm/lib/component/Popover/types.js.map +1 -0
  62. package/dist/esm/lib/component/Tabs/Tabs.js +27 -0
  63. package/dist/esm/lib/component/Tabs/Tabs.js.map +1 -0
  64. package/dist/esm/lib/component/Tabs/common/Item/Item.js +20 -0
  65. package/dist/esm/lib/component/Tabs/common/Item/Item.js.map +1 -0
  66. package/dist/esm/lib/component/Tabs/common/Item/index.js +3 -0
  67. package/dist/esm/lib/component/Tabs/common/Item/index.js.map +1 -0
  68. package/dist/esm/lib/component/Tabs/common/Item/styles.css +75 -0
  69. package/dist/esm/lib/component/Tabs/common/Item/types.js +2 -0
  70. package/dist/esm/lib/component/Tabs/common/Item/types.js.map +1 -0
  71. package/dist/esm/lib/component/Tabs/common/index.js +2 -0
  72. package/dist/esm/lib/component/Tabs/common/index.js.map +1 -0
  73. package/dist/esm/lib/component/Tabs/index.js +3 -0
  74. package/dist/esm/lib/component/Tabs/index.js.map +1 -0
  75. package/dist/esm/lib/component/Tabs/styles.css +37 -0
  76. package/dist/esm/lib/component/Tabs/types.js +2 -0
  77. package/dist/esm/lib/component/Tabs/types.js.map +1 -0
  78. package/dist/esm/lib/component/Tile/Tile.js +6 -1
  79. package/dist/esm/lib/component/Tile/Tile.js.map +1 -1
  80. package/dist/esm/lib/component/Tile/common/Content/styles.css +17 -8
  81. package/dist/esm/lib/component/Tile/common/Header/styles.css +15 -12
  82. package/dist/esm/lib/component/Tile/styles.css +19 -53
  83. package/dist/esm/lib/component/Tooltip/Tooltip.js +6 -4
  84. package/dist/esm/lib/component/Tooltip/Tooltip.js.map +1 -1
  85. package/dist/esm/lib/component/Tooltip/common/TooltipArea/TooltipArea.js +47 -25
  86. package/dist/esm/lib/component/Tooltip/common/TooltipArea/TooltipArea.js.map +1 -1
  87. package/dist/esm/lib/component/Tooltip/styles.css +146 -81
  88. package/dist/esm/lib/component/Tooltip/withTooltip.js +3 -3
  89. package/dist/esm/lib/component/Tooltip/withTooltip.js.map +1 -1
  90. package/dist/esm/lib/component/index.js +17 -0
  91. package/dist/esm/lib/component/index.js.map +1 -0
  92. package/dist/esm/lib/group/KeyboardKeys/KeyboardKeys.js +3 -0
  93. package/dist/esm/lib/group/KeyboardKeys/KeyboardKeys.js.map +1 -1
  94. package/dist/esm/lib/group/index.js +3 -0
  95. package/dist/esm/lib/group/index.js.map +1 -0
  96. package/dist/esm/lib/hooks/index.js +2 -1
  97. package/dist/esm/lib/hooks/index.js.map +1 -1
  98. package/dist/esm/lib/hooks/useContextualMenu/index.js +3 -0
  99. package/dist/esm/lib/hooks/useContextualMenu/index.js.map +1 -0
  100. package/dist/esm/lib/hooks/useContextualMenu/types.js +2 -0
  101. package/dist/esm/lib/hooks/useContextualMenu/types.js.map +1 -0
  102. package/dist/esm/lib/hooks/useContextualMenu/useContextualMenu.js +175 -0
  103. package/dist/esm/lib/hooks/useContextualMenu/useContextualMenu.js.map +1 -0
  104. package/dist/esm/lib/hooks/useDisclosure/index.js +3 -0
  105. package/dist/esm/lib/hooks/useDisclosure/index.js.map +1 -0
  106. package/dist/esm/lib/hooks/useDisclosure/types.js +2 -0
  107. package/dist/esm/lib/hooks/useDisclosure/types.js.map +1 -0
  108. package/dist/esm/lib/hooks/useDisclosure/useDisclosure.js +230 -0
  109. package/dist/esm/lib/hooks/useDisclosure/useDisclosure.js.map +1 -0
  110. package/dist/esm/lib/hooks/useResizeObserver/useResizeObserver.js +37 -7
  111. package/dist/esm/lib/hooks/useResizeObserver/useResizeObserver.js.map +1 -1
  112. package/dist/esm/lib/hooks/useWindowDimensions/useWindowDimensions.js +9 -0
  113. package/dist/esm/lib/hooks/useWindowDimensions/useWindowDimensions.js.map +1 -1
  114. package/dist/esm/lib/hooks/useWindowFitment/index.js +1 -0
  115. package/dist/esm/lib/hooks/useWindowFitment/index.js.map +1 -1
  116. package/dist/esm/lib/hooks/useWindowFitment/readingDirection.js +25 -0
  117. package/dist/esm/lib/hooks/useWindowFitment/readingDirection.js.map +1 -0
  118. package/dist/esm/lib/hooks/useWindowFitment/useWindowFitment.js +211 -21
  119. package/dist/esm/lib/hooks/useWindowFitment/useWindowFitment.js.map +1 -1
  120. package/dist/esm/lib/index.js +8 -25
  121. package/dist/esm/lib/index.js.map +1 -1
  122. package/dist/esm/lib/pattern/index.js +3 -0
  123. package/dist/esm/lib/pattern/index.js.map +1 -0
  124. package/dist/esm/lib/subcomponent/Spinner/Spinner.js +35 -0
  125. package/dist/esm/lib/subcomponent/Spinner/Spinner.js.map +1 -0
  126. package/dist/esm/lib/subcomponent/Spinner/index.js +2 -0
  127. package/dist/esm/lib/subcomponent/Spinner/index.js.map +1 -0
  128. package/dist/esm/lib/subcomponent/Spinner/styles.css +50 -0
  129. package/dist/esm/lib/subcomponent/Spinner/types.js +2 -0
  130. package/dist/esm/lib/subcomponent/Spinner/types.js.map +1 -0
  131. package/dist/esm/lib/subcomponent/index.js +3 -0
  132. package/dist/esm/lib/subcomponent/index.js.map +1 -0
  133. package/dist/esm/lib/types/link.js +2 -0
  134. package/dist/esm/lib/types/link.js.map +1 -0
  135. package/dist/types/lib/_work_in_progress/Link/types.d.ts +1 -1
  136. package/dist/types/lib/_work_in_progress/Link/types.d.ts.map +1 -1
  137. package/dist/types/lib/_work_in_progress/index.d.ts +12 -0
  138. package/dist/types/lib/_work_in_progress/index.d.ts.map +1 -0
  139. package/dist/types/lib/component/Accordion/Accordion.d.ts +2 -0
  140. package/dist/types/lib/component/Accordion/Accordion.d.ts.map +1 -1
  141. package/dist/types/lib/component/Announcement/Announcement.d.ts +2 -2
  142. package/dist/types/lib/component/Announcement/Announcement.d.ts.map +1 -1
  143. package/dist/types/lib/component/Announcement/index.d.ts.map +1 -1
  144. package/dist/types/lib/component/Announcement/types.d.ts +17 -6
  145. package/dist/types/lib/component/Announcement/types.d.ts.map +1 -1
  146. package/dist/types/lib/component/Breadcrumbs/Breadcrumbs.d.ts +3 -1
  147. package/dist/types/lib/component/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  148. package/dist/types/lib/component/Breadcrumbs/common/Item/Item.d.ts +1 -1
  149. package/dist/types/lib/component/Breadcrumbs/common/Item/Item.d.ts.map +1 -1
  150. package/dist/types/lib/component/Breadcrumbs/common/Item/types.d.ts +8 -13
  151. package/dist/types/lib/component/Breadcrumbs/common/Item/types.d.ts.map +1 -1
  152. package/dist/types/lib/component/Breadcrumbs/types.d.ts +8 -1
  153. package/dist/types/lib/component/Breadcrumbs/types.d.ts.map +1 -1
  154. package/dist/types/lib/component/Button/Button.d.ts +3 -1
  155. package/dist/types/lib/component/Button/Button.d.ts.map +1 -1
  156. package/dist/types/lib/component/Button/types.d.ts +8 -4
  157. package/dist/types/lib/component/Button/types.d.ts.map +1 -1
  158. package/dist/types/lib/component/Card/Card.d.ts +3 -5
  159. package/dist/types/lib/component/Card/Card.d.ts.map +1 -1
  160. package/dist/types/lib/component/Card/common/Footer/Footer.d.ts +1 -1
  161. package/dist/types/lib/component/Card/common/Footer/types.d.ts +1 -1
  162. package/dist/types/lib/component/Card/common/index.d.ts +0 -1
  163. package/dist/types/lib/component/Card/common/index.d.ts.map +1 -1
  164. package/dist/types/lib/component/ContextualMenu/ContextualMenu.d.ts +15 -0
  165. package/dist/types/lib/component/ContextualMenu/ContextualMenu.d.ts.map +1 -0
  166. package/dist/types/lib/component/ContextualMenu/common/Item/Item.d.ts +14 -0
  167. package/dist/types/lib/component/ContextualMenu/common/Item/Item.d.ts.map +1 -0
  168. package/dist/types/lib/component/ContextualMenu/common/Item/index.d.ts +3 -0
  169. package/dist/types/lib/component/ContextualMenu/common/Item/index.d.ts.map +1 -0
  170. package/dist/types/lib/component/ContextualMenu/common/Item/types.d.ts +11 -0
  171. package/dist/types/lib/component/ContextualMenu/common/Item/types.d.ts.map +1 -0
  172. package/dist/types/lib/component/ContextualMenu/common/MenuContext.d.ts +19 -0
  173. package/dist/types/lib/component/ContextualMenu/common/MenuContext.d.ts.map +1 -0
  174. package/dist/types/lib/component/ContextualMenu/common/SubMenu/SubMenu.d.ts +15 -0
  175. package/dist/types/lib/component/ContextualMenu/common/SubMenu/SubMenu.d.ts.map +1 -0
  176. package/dist/types/lib/component/ContextualMenu/common/SubMenu/index.d.ts +2 -0
  177. package/dist/types/lib/component/ContextualMenu/common/SubMenu/index.d.ts.map +1 -0
  178. package/dist/types/lib/component/ContextualMenu/index.d.ts +3 -0
  179. package/dist/types/lib/component/ContextualMenu/index.d.ts.map +1 -0
  180. package/dist/types/lib/component/ContextualMenu/types.d.ts +30 -0
  181. package/dist/types/lib/component/ContextualMenu/types.d.ts.map +1 -0
  182. package/dist/types/lib/component/Icon/Icon.d.ts +3 -0
  183. package/dist/types/lib/component/Icon/Icon.d.ts.map +1 -1
  184. package/dist/types/lib/component/InlineCode/InlineCode.d.ts +2 -0
  185. package/dist/types/lib/component/InlineCode/InlineCode.d.ts.map +1 -1
  186. package/dist/types/lib/component/KeyboardKey/KeyboardKey.d.ts +2 -0
  187. package/dist/types/lib/component/KeyboardKey/KeyboardKey.d.ts.map +1 -1
  188. package/dist/types/lib/component/Popover/Popover.d.ts +16 -0
  189. package/dist/types/lib/component/Popover/Popover.d.ts.map +1 -0
  190. package/dist/types/lib/component/Popover/index.d.ts +3 -0
  191. package/dist/types/lib/component/Popover/index.d.ts.map +1 -0
  192. package/dist/types/lib/component/Popover/types.d.ts +24 -0
  193. package/dist/types/lib/component/Popover/types.d.ts.map +1 -0
  194. package/dist/types/lib/component/Tabs/Tabs.d.ts +18 -0
  195. package/dist/types/lib/component/Tabs/Tabs.d.ts.map +1 -0
  196. package/dist/types/lib/component/Tabs/common/Item/Item.d.ts +15 -0
  197. package/dist/types/lib/component/Tabs/common/Item/Item.d.ts.map +1 -0
  198. package/dist/types/lib/component/Tabs/common/Item/index.d.ts +3 -0
  199. package/dist/types/lib/component/Tabs/common/Item/index.d.ts.map +1 -0
  200. package/dist/types/lib/component/Tabs/common/Item/types.d.ts +18 -0
  201. package/dist/types/lib/component/Tabs/common/Item/types.d.ts.map +1 -0
  202. package/dist/types/lib/component/Tabs/common/index.d.ts +2 -0
  203. package/dist/types/lib/component/Tabs/common/index.d.ts.map +1 -0
  204. package/dist/types/lib/component/Tabs/index.d.ts +3 -0
  205. package/dist/types/lib/component/Tabs/index.d.ts.map +1 -0
  206. package/dist/types/lib/component/Tabs/types.d.ts +46 -0
  207. package/dist/types/lib/component/Tabs/types.d.ts.map +1 -0
  208. package/dist/types/lib/component/Tile/Tile.d.ts +2 -0
  209. package/dist/types/lib/component/Tile/Tile.d.ts.map +1 -1
  210. package/dist/types/lib/component/Tile/common/Content/types.d.ts +1 -1
  211. package/dist/types/lib/component/Tile/common/Header/types.d.ts +1 -1
  212. package/dist/types/lib/component/Tile/types.d.ts +4 -5
  213. package/dist/types/lib/component/Tile/types.d.ts.map +1 -1
  214. package/dist/types/lib/component/Tooltip/Tooltip.d.ts +1 -1
  215. package/dist/types/lib/component/Tooltip/Tooltip.d.ts.map +1 -1
  216. package/dist/types/lib/component/Tooltip/common/TooltipArea/TooltipArea.d.ts +2 -2
  217. package/dist/types/lib/component/Tooltip/common/TooltipArea/TooltipArea.d.ts.map +1 -1
  218. package/dist/types/lib/component/Tooltip/common/TooltipArea/types.d.ts +14 -2
  219. package/dist/types/lib/component/Tooltip/common/TooltipArea/types.d.ts.map +1 -1
  220. package/dist/types/lib/component/Tooltip/types.d.ts +6 -0
  221. package/dist/types/lib/component/Tooltip/types.d.ts.map +1 -1
  222. package/dist/types/lib/component/Tooltip/withTooltip.d.ts +10 -3
  223. package/dist/types/lib/component/Tooltip/withTooltip.d.ts.map +1 -1
  224. package/dist/types/lib/component/index.d.ts +16 -0
  225. package/dist/types/lib/component/index.d.ts.map +1 -0
  226. package/dist/types/lib/group/KeyboardKeys/KeyboardKeys.d.ts +3 -0
  227. package/dist/types/lib/group/KeyboardKeys/KeyboardKeys.d.ts.map +1 -1
  228. package/dist/types/lib/group/index.d.ts +2 -0
  229. package/dist/types/lib/group/index.d.ts.map +1 -0
  230. package/dist/types/lib/hooks/index.d.ts +2 -1
  231. package/dist/types/lib/hooks/index.d.ts.map +1 -1
  232. package/dist/types/lib/hooks/useContextualMenu/index.d.ts +3 -0
  233. package/dist/types/lib/hooks/useContextualMenu/index.d.ts.map +1 -0
  234. package/dist/types/lib/hooks/useContextualMenu/types.d.ts +71 -0
  235. package/dist/types/lib/hooks/useContextualMenu/types.d.ts.map +1 -0
  236. package/dist/types/lib/hooks/useContextualMenu/useContextualMenu.d.ts +20 -0
  237. package/dist/types/lib/hooks/useContextualMenu/useContextualMenu.d.ts.map +1 -0
  238. package/dist/types/lib/hooks/useDisclosure/index.d.ts +3 -0
  239. package/dist/types/lib/hooks/useDisclosure/index.d.ts.map +1 -0
  240. package/dist/types/lib/hooks/useDisclosure/types.d.ts +103 -0
  241. package/dist/types/lib/hooks/useDisclosure/types.d.ts.map +1 -0
  242. package/dist/types/lib/hooks/useDisclosure/useDisclosure.d.ts +32 -0
  243. package/dist/types/lib/hooks/useDisclosure/useDisclosure.d.ts.map +1 -0
  244. package/dist/types/lib/hooks/useResizeObserver/useResizeObserver.d.ts +6 -0
  245. package/dist/types/lib/hooks/useResizeObserver/useResizeObserver.d.ts.map +1 -1
  246. package/dist/types/lib/hooks/useWindowDimensions/useWindowDimensions.d.ts.map +1 -1
  247. package/dist/types/lib/hooks/useWindowFitment/index.d.ts +1 -0
  248. package/dist/types/lib/hooks/useWindowFitment/index.d.ts.map +1 -1
  249. package/dist/types/lib/hooks/useWindowFitment/readingDirection.d.ts +14 -0
  250. package/dist/types/lib/hooks/useWindowFitment/readingDirection.d.ts.map +1 -0
  251. package/dist/types/lib/hooks/useWindowFitment/types.d.ts +75 -4
  252. package/dist/types/lib/hooks/useWindowFitment/types.d.ts.map +1 -1
  253. package/dist/types/lib/hooks/useWindowFitment/useWindowFitment.d.ts +44 -2
  254. package/dist/types/lib/hooks/useWindowFitment/useWindowFitment.d.ts.map +1 -1
  255. package/dist/types/lib/index.d.ts +5 -25
  256. package/dist/types/lib/index.d.ts.map +1 -1
  257. package/dist/types/lib/pattern/index.d.ts +2 -0
  258. package/dist/types/lib/pattern/index.d.ts.map +1 -0
  259. package/dist/types/lib/subcomponent/Spinner/Spinner.d.ts +24 -0
  260. package/dist/types/lib/subcomponent/Spinner/Spinner.d.ts.map +1 -0
  261. package/dist/types/lib/subcomponent/Spinner/index.d.ts +3 -0
  262. package/dist/types/lib/subcomponent/Spinner/index.d.ts.map +1 -0
  263. package/dist/types/lib/subcomponent/Spinner/types.d.ts +17 -0
  264. package/dist/types/lib/subcomponent/Spinner/types.d.ts.map +1 -0
  265. package/dist/types/lib/subcomponent/index.d.ts +2 -0
  266. package/dist/types/lib/subcomponent/index.d.ts.map +1 -0
  267. package/dist/types/lib/types/index.d.ts +1 -0
  268. package/dist/types/lib/types/index.d.ts.map +1 -1
  269. package/dist/types/lib/types/link.d.ts +26 -0
  270. package/dist/types/lib/types/link.d.ts.map +1 -0
  271. package/package.json +16 -19
  272. package/dist/esm/lib/component/Card/common/Thumbnail/Thumbnail.js +0 -21
  273. package/dist/esm/lib/component/Card/common/Thumbnail/Thumbnail.js.map +0 -1
  274. package/dist/esm/lib/component/Card/common/Thumbnail/index.js +0 -2
  275. package/dist/esm/lib/component/Card/common/Thumbnail/index.js.map +0 -1
  276. package/dist/esm/lib/component/Card/common/Thumbnail/styles.css +0 -39
  277. package/dist/esm/lib/component/Card/common/Thumbnail/types.js.map +0 -1
  278. package/dist/esm/lib/hooks/usePopup/index.js +0 -3
  279. package/dist/esm/lib/hooks/usePopup/index.js.map +0 -1
  280. package/dist/esm/lib/hooks/usePopup/types.js.map +0 -1
  281. package/dist/esm/lib/hooks/usePopup/usePopup.js +0 -93
  282. package/dist/esm/lib/hooks/usePopup/usePopup.js.map +0 -1
  283. package/dist/esm/storybook/decorators.js +0 -16
  284. package/dist/esm/storybook/decorators.js.map +0 -1
  285. package/dist/types/lib/component/Card/common/Thumbnail/Thumbnail.d.ts +0 -23
  286. package/dist/types/lib/component/Card/common/Thumbnail/Thumbnail.d.ts.map +0 -1
  287. package/dist/types/lib/component/Card/common/Thumbnail/index.d.ts +0 -3
  288. package/dist/types/lib/component/Card/common/Thumbnail/index.d.ts.map +0 -1
  289. package/dist/types/lib/component/Card/common/Thumbnail/types.d.ts +0 -27
  290. package/dist/types/lib/component/Card/common/Thumbnail/types.d.ts.map +0 -1
  291. package/dist/types/lib/hooks/usePopup/index.d.ts +0 -3
  292. package/dist/types/lib/hooks/usePopup/index.d.ts.map +0 -1
  293. package/dist/types/lib/hooks/usePopup/types.d.ts +0 -65
  294. package/dist/types/lib/hooks/usePopup/types.d.ts.map +0 -1
  295. package/dist/types/lib/hooks/usePopup/usePopup.d.ts +0 -19
  296. package/dist/types/lib/hooks/usePopup/usePopup.d.ts.map +0 -1
  297. package/dist/types/storybook/decorators.d.ts +0 -15
  298. package/dist/types/storybook/decorators.d.ts.map +0 -1
  299. /package/dist/esm/lib/component/{Card/common/Thumbnail → ContextualMenu/common/Item}/types.js +0 -0
  300. /package/dist/esm/lib/{hooks/usePopup → component/ContextualMenu}/types.js +0 -0
@@ -1,21 +1,35 @@
1
1
  /* Component tokens — sourced from @canonical/design-tokens */
2
2
  :root {
3
- --button-color-background: var(--color-foreground-secondary);
4
- --button-color-background-hover: var(--color-foreground-secondary-hover);
5
- --button-color-background-active: var(--color-foreground-secondary-active);
3
+ /* Channel fallbacks used when no importance modifier is applied. Primary is
4
+ the default hierarchy, so a bare `<button class="ds button">` reads as the
5
+ filled primary look: the primary foreground fills the background and the
6
+ label takes the on-fill contrast colour. */
7
+ --button-color-background: var(
8
+ --modifier-color-foreground-primary,
9
+ var(--color-foreground-primary)
10
+ );
11
+ --button-color-background-hover: var(--color-foreground-primary-hover);
12
+ --button-color-background-active: var(--color-foreground-primary-active);
13
+ --button-color-background-disabled: var(--color-foreground-primary-disabled);
14
+ /* Neutral text is the normal text colour. The filled default reads as
15
+ contrast on the fill because `.primary` (the default importance, applied by
16
+ the component) overrides text/icon to the on-fill contrast tokens; ghost
17
+ importances keep this normal colour, so they stay visible. */
6
18
  --button-color-text: var(--color-text);
7
- --button-color-border: var(--color-border-high-contrast);
8
- --button-color-border-hover: var(--button-color-border);
9
- --button-color-border-active: var(--button-color-border);
10
-
11
- --button-margin-left: var(--spacing-horizontal-large);
12
- --button-margin-bottom: var(--spacing-input-margin-bottom);
13
- --button-padding-vertical: var(--spacing-input-padding-vertical);
14
- --button-padding-horizontal: var(--spacing-horizontal-large);
15
- --button-border-width: var(--spacing-border-width);
16
- --button-font-size: var(--font-size-default);
17
- --button-font-weight: var(--font-weight-default);
18
- --button-line-height: var(--line-height-default);
19
+ --button-color-border: var(--color-border-highlighted, var(--color-border));
20
+
21
+ /* Inline padding (Figma):
22
+ - end (right): always dimension-200 (16px) — the label always sits 16px
23
+ from the trailing edge.
24
+ - start (left): dimension-200 (16px) with no icon; dimension-100 (8px) when
25
+ an icon leads (the icon then sits closer to the edge), with a
26
+ dimension-100 (8px) gap between the icon and the label. */
27
+ --button-padding-inline-end: var(--dimension-200);
28
+ --button-padding-inline-start: var(--dimension-200);
29
+ --button-gap: var(--dimension-100);
30
+ --button-border-width: var(--dimension-stroke-thickness-medium);
31
+ /* Label weight — the button label is medium, not the `.p` body weight. */
32
+ --button-font-weight: var(--font-weight-medium, var(--font-weight-default));
19
33
  }
20
34
 
21
35
  /* ==========================================================================
@@ -23,54 +37,98 @@
23
37
  ========================================================================== */
24
38
 
25
39
  /*
26
- Modifier channel variables (from @canonical/design-tokens):
27
- --modifier-color-foreground-primary filled background (constructive, destructive, caution)
28
- --modifier-color-text text colour
29
- --modifier-color-border border colour
30
- --modifier-color-icon icon colour
31
- --modifier-color-focusRing focus ring colour
40
+ The button reads the modifier CHANNEL generically — it is not aware of any
41
+ particular importance/anticipation class or combination:
42
+
43
+ --modifier-surface which foreground fills the background (importance:
44
+ filled for primary, ghost for secondary/tertiary).
45
+ --modifier-outline 1 when a border shows, 0 when it does not (importance).
46
+ --modifier-color-* the colour itself (anticipation/emphasis): text, icon,
47
+ border. `.primary` overrides text/icon with the on-fill
48
+ contrast tokens.
49
+
50
+ Interaction states read the per-state surface/text channels supplied by the
51
+ states shim (`--modifier-surface-{hover,active,disabled}`,
52
+ `--modifier-color-text-disabled`), which resolve to the explicit state tokens
53
+ and recolour per anticipation.
32
54
  */
33
55
 
34
56
  .ds.button {
57
+ position: relative;
35
58
  display: inline-flex;
36
59
  align-items: center;
37
60
  justify-content: center;
38
- gap: var(--spacing-horizontal-small, 0.5rem);
61
+ gap: var(--button-gap);
39
62
  cursor: pointer;
40
63
 
41
64
  color: var(--modifier-color-text, var(--button-color-text));
42
- background-color: var(
43
- --modifier-color-foreground-primary,
44
- var(--button-color-background)
45
- );
65
+ background-color: var(--modifier-surface, var(--button-color-background));
46
66
  border-color: var(--modifier-color-border, var(--button-color-border));
47
67
  border-style: solid;
48
- border-width: var(--button-border-width);
49
-
50
- font-size: var(--button-font-size);
68
+ /* The outline flag (0/1) toggles the border on: multiplying the width means
69
+ a borderless importance simply resolves to 0 with no separate rule. */
70
+ border-width: calc(var(--modifier-outline, 0) * var(--button-border-width));
71
+
72
+ /* Typography and block padding come from the `.p` baseline utility on the
73
+ element (font-size, snapped line-height, and the padding-block nudges that
74
+ align the box to the baseline grid). The button only overrides the label
75
+ weight and its own inline padding — declaring font-size/line-height/
76
+ padding-block here would bypass the baseline-grid maths. */
51
77
  font-weight: var(--button-font-weight);
52
- line-height: var(--button-line-height);
53
- margin-block-end: var(--button-margin-bottom);
54
- margin-inline-end: var(--button-margin-left);
55
- padding-block: var(--button-padding-vertical);
56
- padding-inline: var(--button-padding-horizontal);
78
+ padding-inline: var(--button-padding-inline-start)
79
+ var(--button-padding-inline-end);
57
80
 
58
81
  text-align: center;
59
82
  text-decoration: none;
60
83
 
84
+ /* Fast colour transition on state change (hover/active/disabled). */
85
+ transition:
86
+ background-color var(--motion-duration-fast) var(--motion-easing-standard),
87
+ color var(--motion-duration-fast) var(--motion-easing-standard),
88
+ border-color var(--motion-duration-fast) var(--motion-easing-standard);
89
+
90
+ /* A leading icon tightens the start padding to dimension-100; the gap between
91
+ the icon and label is already dimension-100. */
92
+ &:has(> .icon) {
93
+ --button-padding-inline-start: var(--dimension-100);
94
+ }
95
+
96
+ /* State fallbacks resolve to the default (primary) surface states when no
97
+ importance modifier supplies `--modifier-surface-*`. */
61
98
  &:hover:not(:disabled) {
62
- background-color: var(--button-color-background-hover);
63
- border-color: var(--button-color-border-hover);
99
+ background-color: var(
100
+ --modifier-surface-hover,
101
+ var(--button-color-background-hover)
102
+ );
64
103
  }
65
104
 
66
105
  &:active:not(:disabled) {
67
- background-color: var(--button-color-background-active);
68
- border-color: var(--button-color-border-active);
106
+ background-color: var(
107
+ --modifier-surface-active,
108
+ var(--button-color-background-active)
109
+ );
69
110
  }
70
111
 
112
+ /* Keyboard focus ring — driven by the modifier focusRing channel so it
113
+ recolours per anticipation; falls back to the base focus ring token. */
114
+ &:focus-visible {
115
+ outline: var(--focus-outline-width, 2px) solid
116
+ var(--modifier-color-focusRing, var(--color-focusRing, currentColor));
117
+ outline-offset: var(--focus-outline-offset, 2px);
118
+ }
119
+
120
+ /* Disabled — explicit disabled tokens (not the computed deltas): the surface,
121
+ text and border each resolve to their `-disabled` token. Primary supplies
122
+ the on-fill disabled text via `--modifier-color-text-disabled`; ghost
123
+ importances fall back to the plain disabled text colour. */
71
124
  &:disabled {
72
125
  cursor: not-allowed;
73
- opacity: 0.5;
126
+ color: var(--modifier-color-text-disabled, var(--color-text-disabled));
127
+ background-color: var(
128
+ --modifier-surface-disabled,
129
+ var(--button-color-background-disabled)
130
+ );
131
+ border-color: var(--color-border-disabled);
74
132
  }
75
133
  }
76
134
 
@@ -85,6 +143,44 @@
85
143
  flex-shrink: 0;
86
144
  width: var(--icon-size, 1em);
87
145
  height: var(--icon-size, 1em);
146
+
147
+ /* The icon has its own colour channel (distinct from the label text): on a
148
+ filled primary it is the on-fill contrast icon, on ghost importances the
149
+ modifier icon colour. Icons drawn with `currentColor` follow this. */
150
+ color: var(--modifier-color-icon, var(--modifier-color-text, currentColor));
151
+ }
152
+
153
+ .ds.button:disabled > .icon {
154
+ color: var(--modifier-color-icon-disabled, var(--color-icon-disabled));
155
+ }
156
+
157
+ /* ==========================================================================
158
+ Loading State
159
+ ========================================================================== */
160
+
161
+ /* Loading replaces the label with a Spinner but keeps the button's width: the
162
+ icon and label stay in the DOM (hidden, so their box still reserves space)
163
+ and the Spinner is overlaid centred on top. A loading button is disabled (so
164
+ it can't be re-triggered), but it must not *read* as disabled — it is
165
+ working, not unavailable — so it keeps the enabled surface, text and border
166
+ colours, overriding the :disabled greying above. */
167
+ .ds.button.loading {
168
+ color: var(--modifier-color-text, var(--button-color-text));
169
+ background-color: var(--modifier-surface, var(--button-color-background));
170
+ border-color: var(--modifier-color-border, var(--button-color-border));
171
+
172
+ & > .icon,
173
+ & > .label {
174
+ visibility: hidden;
175
+ }
176
+
177
+ & > .loading-spinner {
178
+ position: absolute;
179
+ inset: 0;
180
+ display: inline-flex;
181
+ align-items: center;
182
+ justify-content: center;
183
+ }
88
184
  }
89
185
 
90
186
  /* ==========================================================================
@@ -1,9 +1,11 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Content, Footer, Header, Image, Thumbnail } from "./common/index.js";
2
+ import { Content, Footer, Header, Image } from "./common/index.js";
3
3
  import "./styles.css";
4
- // The Card establishes its own `.surface` context so its background steps when
5
- // nested inside another surface or card.
6
- const componentCssClassName = "ds card surface";
4
+ // The Card is NOT a surface: it establishes no `.surface` context of its own,
5
+ // so on a surface it takes the same background (no step) and reads as flush
6
+ // with its container. It stays delimited by its border, radius, and the
7
+ // dividers between its sections.
8
+ const componentCssClassName = "ds card";
7
9
  /**
8
10
  * The card is a container that is designed to represent data objects that share
9
11
  * the same structure. Unlike the more flexible Tile, a card is designed to have
@@ -11,13 +13,14 @@ const componentCssClassName = "ds card surface";
11
13
  * predictable structure that allows the user to compare attributes across data
12
14
  * objects.
13
15
  *
14
- * @implements dso:global.component.card
16
+ * `import { Card } from "@canonical/react-ds-global";`
17
+ *
18
+ * @implements ds:global.component.card
15
19
  */
16
20
  const Card = ({ className, children, ...props }) => (_jsx("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: children }));
17
21
  Card.Content = Content;
18
22
  Card.Footer = Footer;
19
23
  Card.Header = Header;
20
24
  Card.Image = Image;
21
- Card.Thumbnail = Thumbnail;
22
25
  export default Card;
23
26
  //# sourceMappingURL=Card.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Card.js","sourceRoot":"","sources":["../../../../../src/lib/component/Card/Card.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,cAAc,CAAC;AAEtB,+EAA+E;AAC/E,yCAAyC;AACzC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,IAAI,GAAG,CAAC,EACZ,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACE,EAAsB,EAAE,CAAC,CACnC,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,YAER,QAAQ,GACL,CACP,CAAC;AAEF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;AAE3B,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Card.js","sourceRoot":"","sources":["../../../../../src/lib/component/Card/Card.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,cAAc,CAAC;AAEtB,8EAA8E;AAC9E,4EAA4E;AAC5E,wEAAwE;AACxE,iCAAiC;AACjC,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAExC;;;;;;;;;;GAUG;AACH,MAAM,IAAI,GAAG,CAAC,EACZ,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACE,EAAsB,EAAE,CAAC,CACnC,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,YAER,QAAQ,GACL,CACP,CAAC;AAEF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAEnB,eAAe,IAAI,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Card.Content styles
3
- * @implements dso:global.subcomponent.card-content
3
+ * @implements ds:global.subcomponent.card-content
4
4
  *
5
5
  * DSL anatomy: layout.type stack, direction vertical.
6
6
  * A content-bearing section: it pads itself (the card frame applies no general
@@ -5,7 +5,7 @@ const componentCssClassName = "ds card-footer";
5
5
  * Footer component for Card. A padded content-bearing section pinned to the
6
6
  * bottom of the card, for actions or supplementary information.
7
7
  *
8
- * @implements dso:global.subcomponent.card-footer
8
+ * @implements ds:global.subcomponent.card-footer
9
9
  */
10
10
  const Footer = ({ children, className, ...props }) => {
11
11
  return (_jsx("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: children }));
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Card.Footer styles
3
- * @implements dso:global.subcomponent.card-footer
3
+ * @implements ds:global.subcomponent.card-footer
4
4
  *
5
5
  * A content-bearing section: it pads itself (the card frame applies no general
6
6
  * padding). Vertical padding is in baseline multiples.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Card.Header styles
3
- * @implements dso:global.subcomponent.card-header
3
+ * @implements ds:global.subcomponent.card-header
4
4
  *
5
5
  * DSL anatomy: layout.type flow, space-between; title uses font/weight/semibold.
6
6
  * A content-bearing section: it pads itself (the card frame applies no general
@@ -2,5 +2,4 @@ export * from "./Content/index.js";
2
2
  export * from "./Footer/index.js";
3
3
  export * from "./Header/index.js";
4
4
  export * from "./Image/index.js";
5
- export * from "./Thumbnail/index.js";
6
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/component/Card/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/component/Card/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Card styles
3
- * @implements dso:global.component.card
3
+ * @implements ds:global.component.card
4
4
  *
5
- * The Card establishes its own `.surface` context (applied by the component),
6
- * so its background reads the surface channel and auto-steps when a card is
7
- * nested inside another surface or card (surface 1 -> base, 2 -> layer2,
8
- * 3 -> layer3). Colour tokens follow the Figma spec.
5
+ * The Card is NOT a surface: it establishes no `.surface` context and sets no
6
+ * background of its own, so on a surface it takes the same background as its
7
+ * container (no step) and reads as flush. It stays delimited by its border,
8
+ * radius, and the dividers between its sections. Colour tokens follow the Figma
9
+ * spec.
9
10
  */
10
11
  :root {
11
12
  --card-color-border: var(--color-border-muted);
@@ -18,9 +19,8 @@
18
19
  display: flex;
19
20
  flex-direction: column;
20
21
 
21
- /* Background from the surface channel (the component adds `.surface`, so the
22
- channel is established on this element and steps with nesting). */
23
- background: var(--surface-color-background, var(--color-background));
22
+ /* No background of its own: the card is not a surface, so it inherits its
23
+ container's background and blends with the surface it sits on. */
24
24
 
25
25
  border: var(--card-border-width) solid var(--card-color-border);
26
26
  border-radius: var(--card-border-radius);
@@ -0,0 +1,94 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { getItemId } from "@canonical/utils";
3
+ import { useMemo } from "react";
4
+ import { createPortal } from "react-dom";
5
+ import { MENU_PLACEMENT, useContextualMenu } from "../../hooks/index.js";
6
+ import MenuContext from "./common/MenuContext.js";
7
+ import SubMenu from "./common/SubMenu/index.js";
8
+ import "./styles.css";
9
+ const componentCssClassName = "ds contextual-menu";
10
+ /**
11
+ * A contextual menu presents a list of grouped actions anchored to a trigger.
12
+ * It opens on click, positions itself with viewport-fitment, and supports full
13
+ * keyboard navigation including arrow traversal across groups.
14
+ *
15
+ * `import { ContextualMenu } from "@canonical/react-ds-global";`
16
+ *
17
+ * @implements dso:global.component.contextual-menu
18
+ */
19
+ const ContextualMenu = ({ trigger, groups, label, className, preferredDirections, distance, gutter, maxWidth, autoFit, wrap, onSelect, open, onOpenChange, ...props }) => {
20
+ // A synthetic root holds the groups so the tree is menu -> group -> item.
21
+ // MUST be stable across renders: the hook annotates it (memoised on `root`)
22
+ // and the open effect keys on the annotated root, so a fresh object each
23
+ // render re-fires that effect every render → dispatch → re-render → freeze.
24
+ const root = useMemo(() => ({ key: "contextual-menu-root", items: groups }), [groups]);
25
+ const menu = useContextualMenu({
26
+ root,
27
+ isOpen: open,
28
+ // Open toward the trigger's leading edge, top-aligned, flipping side/
29
+ // alignment as space runs out. MENU_PLACEMENT is logical (inline-*), so the
30
+ // hook mirrors it in RTL automatically — no direction read here.
31
+ preferredDirections: preferredDirections ?? MENU_PLACEMENT,
32
+ distance,
33
+ gutter,
34
+ maxWidth,
35
+ autoFit: autoFit ?? true,
36
+ wrap,
37
+ onShow: () => onOpenChange?.(true),
38
+ onHide: () => onOpenChange?.(false),
39
+ });
40
+ const { isOpen, close, targetRef, popupRef, popupPositionStyle, popupId, bestPosition, annotatedRoot, getNodeStatus, highlightItem, getTriggerProps, getMenuProps, getGroupProps, getItemProps, } = menu;
41
+ const triggerProps = getTriggerProps();
42
+ const annotatedGroups = annotatedRoot.items ?? [];
43
+ // The shared menu API threaded to every (nested) level. One state, one
44
+ // highlight path, one keyboard handler — submenus are render-only. Memoised so
45
+ // the context value is stable across renders; an unstable value would re-render
46
+ // every SubMenu (and re-run their positioning) on every commit.
47
+ const menuContextValue = useMemo(() => ({
48
+ getItemProps,
49
+ getMenuProps,
50
+ getGroupProps,
51
+ getNodeStatus,
52
+ highlightItem,
53
+ close,
54
+ onSelectItem: (item) => {
55
+ onSelect?.(item);
56
+ close();
57
+ },
58
+ }), [
59
+ getItemProps,
60
+ getMenuProps,
61
+ getGroupProps,
62
+ getNodeStatus,
63
+ highlightItem,
64
+ close,
65
+ onSelect,
66
+ ]);
67
+ // With no explicit `label`, the menu is named by its trigger — so the trigger
68
+ // needs a stable id the menu can point `aria-labelledby` at (pointing at the
69
+ // menu's own id would leave it unnamed).
70
+ const triggerId = `${popupId}-trigger`;
71
+ // getMenuProps returns a generic prop bag from the headless navigation hook
72
+ // (loose event-handler and ref types); it is spread onto the menu container.
73
+ const menuProps = getMenuProps({
74
+ label,
75
+ labelledBy: label ? undefined : triggerId,
76
+ // Compose the positioning ref with the menu's keyboard ref.
77
+ ref: popupRef,
78
+ });
79
+ const menuElement = (_jsx("div", { className: [
80
+ `${componentCssClassName}__surface`,
81
+ "modal",
82
+ bestPosition?.positionName,
83
+ ]
84
+ .filter(Boolean)
85
+ .join(" "), id: popupId, "aria-hidden": !isOpen, style: popupPositionStyle, ...menuProps, children: annotatedGroups.map((group) => (_jsx("div", { className: "group", ...getGroupProps({ label: group.label }), children: (group.items ?? []).map((item) => (
86
+ // SubMenu renders the item and, if it is a submenu parent, its
87
+ // nested popup (recursively). Leaves render as a plain item.
88
+ _jsx(SubMenu, { item: item }, getItemId(item)))) }, getItemId(group)))) }));
89
+ return (_jsx(MenuContext.Provider, { value: menuContextValue, children: _jsxs("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ref: targetRef, ...props, children: [_jsx("button", { type: "button", id: triggerId, className: "trigger", ...triggerProps, children: trigger }), typeof window !== "undefined"
90
+ ? createPortal(menuElement, document.body)
91
+ : menuElement] }) }));
92
+ };
93
+ export default ContextualMenu;
94
+ //# sourceMappingURL=ContextualMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextualMenu.js","sourceRoot":"","sources":["../../../../../src/lib/component/ContextualMenu/ContextualMenu.tsx"],"names":[],"mappings":"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"}
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Icon } from "../../../Icon/index.js";
3
+ import "./styles.css";
4
+ const componentCssClassName = "ds contextual-menu-item";
5
+ /**
6
+ * A single contextual-menu entry. By default it renders an optional leading
7
+ * icon, the label, and an optional right-aligned slot (badge or shortcut). When
8
+ * the item opts into a custom renderer (`displayItemsType: "custom"` with a
9
+ * `Component`), that component owns the item's content instead.
10
+ *
11
+ * @implements dso:global.subcomponent.contextual-menu-item
12
+ */
13
+ const Item = ({ item, itemProps, onSelect }) => {
14
+ const { label, disabled, slot, icon, className, displayItemsType, Component, items, } = item;
15
+ // An item with children is a submenu trigger; it shows a trailing caret.
16
+ const hasSubmenu = !!items?.length;
17
+ const handleKeyDown = (event) => {
18
+ if (event.key === "Enter" || event.key === " ") {
19
+ event.preventDefault();
20
+ if (!disabled)
21
+ onSelect();
22
+ }
23
+ };
24
+ const content = displayItemsType === "custom" && Component ? (_jsx(Component, { item: item })) : (_jsxs(_Fragment, { children: [icon ? _jsx("span", { className: "icon", children: icon }) : null, _jsx("span", { className: "label", children: label }), slot ? _jsx("span", { className: "slot", children: slot }) : null, hasSubmenu ? (_jsx("span", { className: "caret", "aria-hidden": "true", children: _jsx(Icon, { icon: "chevron-right" }) })) : null] }));
25
+ return (
26
+ // biome-ignore lint/a11y/noStaticElementInteractions: the div carries role="menuitem" (from itemProps) with roving tabindex, the correct WAI-ARIA menu pattern (a <button> cannot be a menuitem)
27
+ _jsx("div", { className: [componentCssClassName, disabled && "disabled", className]
28
+ .filter(Boolean)
29
+ .join(" "), ...itemProps, onClick: disabled ? undefined : onSelect, onKeyDown: handleKeyDown, children: content }));
30
+ };
31
+ export default Item;
32
+ //# sourceMappingURL=Item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/ContextualMenu/common/Item/Item.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAa,EAAsB,EAAE;IAC5E,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,KAAK,GACN,GAAG,IAAI,CAAC;IAET,yEAAyE;IACzE,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC;IAEnC,MAAM,aAAa,GAAG,CAAC,KAA0B,EAAE,EAAE;QACnD,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YAC/C,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,IAAI,CAAC,QAAQ;gBAAE,QAAQ,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,OAAO,GACX,gBAAgB,KAAK,QAAQ,IAAI,SAAS,CAAC,CAAC,CAAC,CAC3C,KAAC,SAAS,IAAC,IAAI,EAAE,IAAI,GAAI,CAC1B,CAAC,CAAC,CAAC,CACF,8BAEG,IAAI,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,MAAM,YAAE,IAAI,GAAQ,CAAC,CAAC,CAAC,IAAI,EACnD,eAAM,SAAS,EAAC,OAAO,YAAE,KAAK,GAAQ,EACrC,IAAI,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,MAAM,YAAE,IAAI,GAAQ,CAAC,CAAC,CAAC,IAAI,EAIlD,UAAU,CAAC,CAAC,CAAC,CACZ,eAAM,SAAS,EAAC,OAAO,iBAAa,MAAM,YACxC,KAAC,IAAI,IAAC,IAAI,EAAC,eAAe,GAAG,GACxB,CACR,CAAC,CAAC,CAAC,IAAI,IACP,CACJ,CAAC;IAEJ,OAAO;IACL,iMAAiM;IACjM,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,QAAQ,IAAI,UAAU,EAAE,SAAS,CAAC;aAClE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,KACR,SAAS,EACb,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EACxC,SAAS,EAAE,aAAa,YAEvB,OAAO,GACJ,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from "./Item.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/ContextualMenu/common/Item/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,93 @@
1
+ /* Component tokens — sourced from @canonical/design-tokens.
2
+ Mapped strictly to the Figma "Contextual menu item" frame:
3
+ px = dimension-200 (16px), py = dimension-050 (4px), gap = dimension-050 (4px)
4
+ between icon<->text and text<->caret, text = color-text (black),
5
+ fills = color-foreground-ghost/-active, line-height 24px.
6
+ No min-height — the item is padding + line-height. */
7
+ :root {
8
+ --contextual-menu-item-color-text: var(--color-text);
9
+ --contextual-menu-item-color-text-disabled: var(--color-text-disabled);
10
+ --contextual-menu-item-color-background: var(--color-foreground-ghost);
11
+ --contextual-menu-item-color-background-hover: var(
12
+ --color-foreground-ghost-hover
13
+ );
14
+ --contextual-menu-item-color-background-active: var(
15
+ --color-foreground-ghost-active
16
+ );
17
+ --contextual-menu-item-padding-block: var(--dimension-050);
18
+ --contextual-menu-item-padding-inline: var(--dimension-200);
19
+ /* 4px gap: icon<->text and text<->caret (per the spec). */
20
+ --contextual-menu-item-gap: var(--dimension-050);
21
+ }
22
+
23
+ .ds.contextual-menu-item {
24
+ display: flex;
25
+ /* Icon and first line of text are centre-aligned (Figma annotation). */
26
+ align-items: center;
27
+ gap: var(--contextual-menu-item-gap);
28
+ padding-block: var(--contextual-menu-item-padding-block);
29
+ padding-inline: var(--contextual-menu-item-padding-inline);
30
+ color: var(--contextual-menu-item-color-text);
31
+ background-color: var(--contextual-menu-item-color-background);
32
+ line-height: var(--line-height-text, var(--dimension-300));
33
+ cursor: pointer;
34
+ user-select: none;
35
+
36
+ &:hover {
37
+ background-color: var(--contextual-menu-item-color-background-hover);
38
+ }
39
+
40
+ /* The highlighted (roving) item shows the active fill — matching the Figma
41
+ "Active" state — so keyboard focus is visible without a separate outline. */
42
+ &:focus-visible,
43
+ &[tabindex="0"] {
44
+ background-color: var(--contextual-menu-item-color-background-active);
45
+ outline: none;
46
+ }
47
+
48
+ > .label {
49
+ flex: 1 1 auto;
50
+ }
51
+
52
+ /* The slot (badge / keyboard shortcut) sits right-aligned. */
53
+ > .slot {
54
+ flex: 0 0 auto;
55
+ margin-inline-start: auto;
56
+ opacity: 0.7;
57
+ }
58
+
59
+ /* The submenu caret sits on the trailing edge in a fixed icon box (Figma:
60
+ 16px chevron in a 24px-tall wrapper). It always follows the reading
61
+ direction — chevron-right in LTR, mirrored to point left in RTL — rather
62
+ than flipping per-item with the side the submenu opens on, so sibling carets
63
+ stay consistent. */
64
+ > .caret {
65
+ flex: 0 0 auto;
66
+ margin-inline-start: auto;
67
+ display: inline-flex;
68
+ align-items: center;
69
+ justify-content: center;
70
+ inline-size: var(--dimension-200);
71
+ block-size: var(--dimension-300);
72
+
73
+ & > svg {
74
+ inline-size: var(--dimension-200, 16px);
75
+ block-size: var(--dimension-200, 16px);
76
+ }
77
+ }
78
+
79
+ &.disabled {
80
+ color: var(--contextual-menu-item-color-text-disabled);
81
+ background-color: var(--contextual-menu-item-color-background);
82
+ cursor: not-allowed;
83
+ pointer-events: none;
84
+ }
85
+ }
86
+
87
+ /* Mirror the `›` caret glyph to `‹` for right-to-left reading. Keyed on any
88
+ `[dir="rtl"]` ANCESTOR of the item — which, because the menu is portalled to
89
+ the body, must be `<html>` or `<body>` (a wrapper `<div dir>` is escaped by
90
+ the portal). Set `dir="rtl"` on `<html>` (or `<body>`) and it mirrors. */
91
+ [dir="rtl"] .ds.contextual-menu-item > .caret {
92
+ transform: scaleX(-1);
93
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/ContextualMenu/common/Item/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import { createContext, useContext } from "react";
2
+ const MenuContext = createContext(null);
3
+ /** Read the shared menu API. Throws if used outside a ContextualMenu. */
4
+ export const useMenuContext = () => {
5
+ const value = useContext(MenuContext);
6
+ if (!value) {
7
+ throw new Error("useMenuContext must be used within a ContextualMenu.");
8
+ }
9
+ return value;
10
+ };
11
+ export default MenuContext;
12
+ //# sourceMappingURL=MenuContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuContext.js","sourceRoot":"","sources":["../../../../../../src/lib/component/ContextualMenu/common/MenuContext.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAyBlD,MAAM,WAAW,GAAG,aAAa,CAA0B,IAAI,CAAC,CAAC;AAEjE,yEAAyE;AACzE,MAAM,CAAC,MAAM,cAAc,GAAG,GAAqB,EAAE;IACnD,MAAM,KAAK,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}