@canonical/react-ds-global 0.37.0 → 0.40.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 (204) hide show
  1. package/README.md +72 -0
  2. package/dist/esm/lib/_work_in_progress/Announcement/styles.css +51 -47
  3. package/dist/esm/lib/_work_in_progress/CategoriesSection/common/Category/styles.css +21 -17
  4. package/dist/esm/lib/_work_in_progress/CategoriesSection/styles.css +16 -12
  5. package/dist/esm/lib/_work_in_progress/ChatSection/styles.css +22 -18
  6. package/dist/esm/lib/_work_in_progress/DescriptionSection/styles.css +14 -10
  7. package/dist/esm/lib/_work_in_progress/IconSection/styles.css +18 -14
  8. package/dist/esm/lib/_work_in_progress/Label/styles.css +36 -32
  9. package/dist/esm/lib/_work_in_progress/Link/styles.css +32 -28
  10. package/dist/esm/lib/_work_in_progress/Rule/styles.css +21 -14
  11. package/dist/esm/lib/_work_in_progress/Section/styles.css +66 -62
  12. package/dist/esm/lib/_work_in_progress/SkipLink/styles.css +35 -32
  13. package/dist/esm/lib/_work_in_progress/TSection/styles.css +26 -22
  14. package/dist/esm/lib/_work_in_progress/grid/ApplicationLayout/ApplicationLayout.js +4 -1
  15. package/dist/esm/lib/_work_in_progress/grid/ApplicationLayout/ApplicationLayout.js.map +1 -1
  16. package/dist/esm/lib/_work_in_progress/grid/ApplicationLayout/styles.css +21 -17
  17. package/dist/esm/lib/_work_in_progress/grid/GridCard/GridCard.js +4 -1
  18. package/dist/esm/lib/_work_in_progress/grid/GridCard/GridCard.js.map +1 -1
  19. package/dist/esm/lib/_work_in_progress/grid/GridCard/styles.css +8 -4
  20. package/dist/esm/lib/_work_in_progress/grid/InnerGridDemo/styles.css +38 -33
  21. package/dist/esm/lib/_work_in_progress/grid/SettingsView/SettingsView.js +4 -1
  22. package/dist/esm/lib/_work_in_progress/grid/SettingsView/SettingsView.js.map +1 -1
  23. package/dist/esm/lib/_work_in_progress/grid/SettingsView/styles.css +23 -19
  24. package/dist/esm/lib/component/Accordion/common/Item/styles.css +305 -299
  25. package/dist/esm/lib/component/Accordion/styles.css +35 -31
  26. package/dist/esm/lib/component/Badge/hooks/useBadge.js +1 -1
  27. package/dist/esm/lib/component/Badge/hooks/useBadge.js.map +1 -1
  28. package/dist/esm/lib/component/Badge/styles.css +45 -41
  29. package/dist/esm/lib/component/Breadcrumbs/Breadcrumbs.js +1 -1
  30. package/dist/esm/lib/component/Breadcrumbs/Breadcrumbs.js.map +1 -1
  31. package/dist/esm/lib/component/Breadcrumbs/common/Item/styles.css +69 -65
  32. package/dist/esm/lib/component/Breadcrumbs/styles.css +30 -26
  33. package/dist/esm/lib/component/Button/styles.css +293 -260
  34. package/dist/esm/lib/component/Card/common/Content/styles.css +27 -23
  35. package/dist/esm/lib/component/Card/common/Footer/styles.css +30 -26
  36. package/dist/esm/lib/component/Card/common/Header/styles.css +25 -21
  37. package/dist/esm/lib/component/Card/common/Image/styles.css +8 -4
  38. package/dist/esm/lib/component/Card/styles.css +77 -73
  39. package/dist/esm/lib/component/Chip/Chip.js.map +1 -1
  40. package/dist/esm/lib/component/Chip/styles.css +105 -101
  41. package/dist/esm/lib/component/ContextualMenu/ContextualMenu.js +30 -22
  42. package/dist/esm/lib/component/ContextualMenu/ContextualMenu.js.map +1 -1
  43. package/dist/esm/lib/component/ContextualMenu/common/Item/Item.js +25 -2
  44. package/dist/esm/lib/component/ContextualMenu/common/Item/Item.js.map +1 -1
  45. package/dist/esm/lib/component/ContextualMenu/common/Item/styles.css +116 -106
  46. package/dist/esm/lib/component/ContextualMenu/common/SubMenu/SubMenu.js +29 -10
  47. package/dist/esm/lib/component/ContextualMenu/common/SubMenu/SubMenu.js.map +1 -1
  48. package/dist/esm/lib/component/ContextualMenu/styles.css +73 -72
  49. package/dist/esm/lib/component/Icon/styles.css +24 -20
  50. package/dist/esm/lib/component/InlineCode/styles.css +19 -15
  51. package/dist/esm/lib/component/KeyboardKey/styles.css +44 -40
  52. package/dist/esm/lib/component/Popover/Popover.js.map +1 -1
  53. package/dist/esm/lib/component/Popover/styles.css +59 -52
  54. package/dist/esm/lib/component/Tabs/common/Item/styles.css +80 -76
  55. package/dist/esm/lib/component/Tabs/styles.css +36 -32
  56. package/dist/esm/lib/component/Tile/common/Content/styles.css +28 -24
  57. package/dist/esm/lib/component/Tile/common/Header/styles.css +28 -24
  58. package/dist/esm/lib/component/Tile/styles.css +31 -27
  59. package/dist/esm/lib/component/Tooltip/TooltipEngine.js +66 -0
  60. package/dist/esm/lib/component/Tooltip/TooltipEngine.js.map +1 -0
  61. package/dist/esm/lib/component/Tooltip/index.js +1 -0
  62. package/dist/esm/lib/component/Tooltip/index.js.map +1 -1
  63. package/dist/esm/lib/component/Tooltip/styles.css +213 -208
  64. package/dist/esm/lib/component/Tooltip/withTooltip.js +11 -63
  65. package/dist/esm/lib/component/Tooltip/withTooltip.js.map +1 -1
  66. package/dist/esm/lib/group/Cards/styles.css +26 -22
  67. package/dist/esm/lib/group/KeyboardKeys/styles.css +14 -10
  68. package/dist/esm/lib/hooks/useContextualMenu/index.js +1 -0
  69. package/dist/esm/lib/hooks/useContextualMenu/index.js.map +1 -1
  70. package/dist/esm/lib/hooks/useContextualMenu/isMenuSeparator.js +11 -0
  71. package/dist/esm/lib/hooks/useContextualMenu/isMenuSeparator.js.map +1 -0
  72. package/dist/esm/lib/hooks/useContextualMenu/useContextualMenu.js +54 -34
  73. package/dist/esm/lib/hooks/useContextualMenu/useContextualMenu.js.map +1 -1
  74. package/dist/esm/lib/hooks/useDisclosure/useDisclosure.js.map +1 -1
  75. package/dist/esm/lib/hooks/useWindowDimensions/useWindowDimensions.js +1 -1
  76. package/dist/esm/lib/hooks/useWindowDimensions/useWindowDimensions.js.map +1 -1
  77. package/dist/esm/lib/hooks/useWindowFitment/useWindowFitment.js +29 -6
  78. package/dist/esm/lib/hooks/useWindowFitment/useWindowFitment.js.map +1 -1
  79. package/dist/esm/lib/index.css +79 -0
  80. package/dist/esm/lib/pattern/Modal/Context.js +10 -0
  81. package/dist/esm/lib/pattern/Modal/Context.js.map +1 -0
  82. package/dist/esm/lib/pattern/Modal/Provider.js +103 -0
  83. package/dist/esm/lib/pattern/Modal/Provider.js.map +1 -0
  84. package/dist/esm/lib/pattern/Modal/common/Content/Content.js +15 -0
  85. package/dist/esm/lib/pattern/Modal/common/Content/Content.js.map +1 -0
  86. package/dist/esm/lib/pattern/Modal/common/Content/index.js +3 -0
  87. package/dist/esm/lib/pattern/Modal/common/Content/index.js.map +1 -0
  88. package/dist/esm/lib/pattern/Modal/common/Content/styles.css +37 -0
  89. package/dist/esm/lib/pattern/Modal/common/Content/types.js +2 -0
  90. package/dist/esm/lib/pattern/Modal/common/Content/types.js.map +1 -0
  91. package/dist/esm/lib/pattern/Modal/common/Footer/Footer.js +16 -0
  92. package/dist/esm/lib/pattern/Modal/common/Footer/Footer.js.map +1 -0
  93. package/dist/esm/lib/pattern/Modal/common/Footer/index.js +3 -0
  94. package/dist/esm/lib/pattern/Modal/common/Footer/index.js.map +1 -0
  95. package/dist/esm/lib/pattern/Modal/common/Footer/styles.css +57 -0
  96. package/dist/esm/lib/pattern/Modal/common/Footer/types.js +2 -0
  97. package/dist/esm/lib/pattern/Modal/common/Footer/types.js.map +1 -0
  98. package/dist/esm/lib/pattern/Modal/common/Header/Header.js +27 -0
  99. package/dist/esm/lib/pattern/Modal/common/Header/Header.js.map +1 -0
  100. package/dist/esm/lib/pattern/Modal/common/Header/index.js +3 -0
  101. package/dist/esm/lib/pattern/Modal/common/Header/index.js.map +1 -0
  102. package/dist/esm/lib/pattern/Modal/common/Header/styles.css +79 -0
  103. package/dist/esm/lib/pattern/Modal/common/Header/types.js +2 -0
  104. package/dist/esm/lib/pattern/Modal/common/Header/types.js.map +1 -0
  105. package/dist/esm/lib/pattern/Modal/common/index.js +5 -0
  106. package/dist/esm/lib/pattern/Modal/common/index.js.map +1 -0
  107. package/dist/esm/lib/pattern/Modal/hooks/useModalContext.js +11 -0
  108. package/dist/esm/lib/pattern/Modal/hooks/useModalContext.js.map +1 -0
  109. package/dist/esm/lib/pattern/Modal/hooks/useModalState.js +15 -0
  110. package/dist/esm/lib/pattern/Modal/hooks/useModalState.js.map +1 -0
  111. package/dist/esm/lib/pattern/Modal/index.js +4 -0
  112. package/dist/esm/lib/pattern/Modal/index.js.map +1 -0
  113. package/dist/esm/lib/pattern/Modal/styles.css +119 -0
  114. package/dist/esm/lib/pattern/Modal/types.js +2 -0
  115. package/dist/esm/lib/pattern/Modal/types.js.map +1 -0
  116. package/dist/esm/lib/pattern/Modal/withModal.js +102 -0
  117. package/dist/esm/lib/pattern/Modal/withModal.js.map +1 -0
  118. package/dist/esm/lib/pattern/Timeline/common/Content/styles.css +16 -12
  119. package/dist/esm/lib/pattern/Timeline/common/Event/styles.css +116 -112
  120. package/dist/esm/lib/pattern/Timeline/styles.css +16 -12
  121. package/dist/esm/lib/pattern/index.js +1 -0
  122. package/dist/esm/lib/pattern/index.js.map +1 -1
  123. package/dist/esm/lib/subcomponent/Spinner/styles.css +38 -34
  124. package/dist/types/lib/_work_in_progress/grid/ApplicationLayout/ApplicationLayout.d.ts.map +1 -1
  125. package/dist/types/lib/_work_in_progress/grid/GridCard/GridCard.d.ts.map +1 -1
  126. package/dist/types/lib/_work_in_progress/grid/SettingsView/SettingsView.d.ts.map +1 -1
  127. package/dist/types/lib/component/Badge/types.d.ts +1 -1
  128. package/dist/types/lib/component/Badge/types.d.ts.map +1 -1
  129. package/dist/types/lib/component/Breadcrumbs/types.d.ts +2 -2
  130. package/dist/types/lib/component/Breadcrumbs/types.d.ts.map +1 -1
  131. package/dist/types/lib/component/Chip/Chip.d.ts +2 -2
  132. package/dist/types/lib/component/Chip/Chip.d.ts.map +1 -1
  133. package/dist/types/lib/component/Chip/types.d.ts +10 -8
  134. package/dist/types/lib/component/Chip/types.d.ts.map +1 -1
  135. package/dist/types/lib/component/ContextualMenu/ContextualMenu.d.ts +4 -4
  136. package/dist/types/lib/component/ContextualMenu/ContextualMenu.d.ts.map +1 -1
  137. package/dist/types/lib/component/ContextualMenu/common/Item/Item.d.ts.map +1 -1
  138. package/dist/types/lib/component/ContextualMenu/common/MenuContext.d.ts +1 -1
  139. package/dist/types/lib/component/ContextualMenu/common/MenuContext.d.ts.map +1 -1
  140. package/dist/types/lib/component/ContextualMenu/common/SubMenu/SubMenu.d.ts +9 -7
  141. package/dist/types/lib/component/ContextualMenu/common/SubMenu/SubMenu.d.ts.map +1 -1
  142. package/dist/types/lib/component/ContextualMenu/types.d.ts +15 -7
  143. package/dist/types/lib/component/ContextualMenu/types.d.ts.map +1 -1
  144. package/dist/types/lib/component/Tabs/types.d.ts +2 -2
  145. package/dist/types/lib/component/Tabs/types.d.ts.map +1 -1
  146. package/dist/types/lib/component/Tooltip/TooltipEngine.d.ts +16 -0
  147. package/dist/types/lib/component/Tooltip/TooltipEngine.d.ts.map +1 -0
  148. package/dist/types/lib/component/Tooltip/index.d.ts +1 -0
  149. package/dist/types/lib/component/Tooltip/index.d.ts.map +1 -1
  150. package/dist/types/lib/component/Tooltip/withTooltip.d.ts +9 -3
  151. package/dist/types/lib/component/Tooltip/withTooltip.d.ts.map +1 -1
  152. package/dist/types/lib/hooks/useContextualMenu/index.d.ts +1 -0
  153. package/dist/types/lib/hooks/useContextualMenu/index.d.ts.map +1 -1
  154. package/dist/types/lib/hooks/useContextualMenu/isMenuSeparator.d.ts +13 -0
  155. package/dist/types/lib/hooks/useContextualMenu/isMenuSeparator.d.ts.map +1 -0
  156. package/dist/types/lib/hooks/useContextualMenu/types.d.ts +45 -15
  157. package/dist/types/lib/hooks/useContextualMenu/types.d.ts.map +1 -1
  158. package/dist/types/lib/hooks/useContextualMenu/useContextualMenu.d.ts +5 -6
  159. package/dist/types/lib/hooks/useContextualMenu/useContextualMenu.d.ts.map +1 -1
  160. package/dist/types/lib/hooks/useDisclosure/types.d.ts +7 -2
  161. package/dist/types/lib/hooks/useDisclosure/types.d.ts.map +1 -1
  162. package/dist/types/lib/hooks/useDisclosure/useDisclosure.d.ts +1 -1
  163. package/dist/types/lib/hooks/useDisclosure/useDisclosure.d.ts.map +1 -1
  164. package/dist/types/lib/hooks/useWindowFitment/types.d.ts +12 -3
  165. package/dist/types/lib/hooks/useWindowFitment/types.d.ts.map +1 -1
  166. package/dist/types/lib/hooks/useWindowFitment/useWindowFitment.d.ts +11 -6
  167. package/dist/types/lib/hooks/useWindowFitment/useWindowFitment.d.ts.map +1 -1
  168. package/dist/types/lib/pattern/Modal/Context.d.ts +10 -0
  169. package/dist/types/lib/pattern/Modal/Context.d.ts.map +1 -0
  170. package/dist/types/lib/pattern/Modal/Provider.d.ts +63 -0
  171. package/dist/types/lib/pattern/Modal/Provider.d.ts.map +1 -0
  172. package/dist/types/lib/pattern/Modal/common/Content/Content.d.ts +17 -0
  173. package/dist/types/lib/pattern/Modal/common/Content/Content.d.ts.map +1 -0
  174. package/dist/types/lib/pattern/Modal/common/Content/index.d.ts +3 -0
  175. package/dist/types/lib/pattern/Modal/common/Content/index.d.ts.map +1 -0
  176. package/dist/types/lib/pattern/Modal/common/Content/types.d.ts +15 -0
  177. package/dist/types/lib/pattern/Modal/common/Content/types.d.ts.map +1 -0
  178. package/dist/types/lib/pattern/Modal/common/Footer/Footer.d.ts +18 -0
  179. package/dist/types/lib/pattern/Modal/common/Footer/Footer.d.ts.map +1 -0
  180. package/dist/types/lib/pattern/Modal/common/Footer/index.d.ts +3 -0
  181. package/dist/types/lib/pattern/Modal/common/Footer/index.d.ts.map +1 -0
  182. package/dist/types/lib/pattern/Modal/common/Footer/types.d.ts +16 -0
  183. package/dist/types/lib/pattern/Modal/common/Footer/types.d.ts.map +1 -0
  184. package/dist/types/lib/pattern/Modal/common/Header/Header.d.ts +24 -0
  185. package/dist/types/lib/pattern/Modal/common/Header/Header.d.ts.map +1 -0
  186. package/dist/types/lib/pattern/Modal/common/Header/index.d.ts +3 -0
  187. package/dist/types/lib/pattern/Modal/common/Header/index.d.ts.map +1 -0
  188. package/dist/types/lib/pattern/Modal/common/Header/types.d.ts +36 -0
  189. package/dist/types/lib/pattern/Modal/common/Header/types.d.ts.map +1 -0
  190. package/dist/types/lib/pattern/Modal/common/index.d.ts +4 -0
  191. package/dist/types/lib/pattern/Modal/common/index.d.ts.map +1 -0
  192. package/dist/types/lib/pattern/Modal/hooks/useModalContext.d.ts +4 -0
  193. package/dist/types/lib/pattern/Modal/hooks/useModalContext.d.ts.map +1 -0
  194. package/dist/types/lib/pattern/Modal/hooks/useModalState.d.ts +10 -0
  195. package/dist/types/lib/pattern/Modal/hooks/useModalState.d.ts.map +1 -0
  196. package/dist/types/lib/pattern/Modal/index.d.ts +4 -0
  197. package/dist/types/lib/pattern/Modal/index.d.ts.map +1 -0
  198. package/dist/types/lib/pattern/Modal/types.d.ts +122 -0
  199. package/dist/types/lib/pattern/Modal/types.d.ts.map +1 -0
  200. package/dist/types/lib/pattern/Modal/withModal.d.ts +74 -0
  201. package/dist/types/lib/pattern/Modal/withModal.d.ts.map +1 -0
  202. package/dist/types/lib/pattern/index.d.ts +1 -0
  203. package/dist/types/lib/pattern/index.d.ts.map +1 -1
  204. package/package.json +28 -18
@@ -0,0 +1,24 @@
1
+ import type React from "react";
2
+ import type { HeaderProps } from "./types.js";
3
+ import "./styles.css";
4
+ /**
5
+ * Modal.Header subcomponent
6
+ *
7
+ * Carries the modal title and the optional dismiss control. The title describes
8
+ * what the modal is for, giving the user context on what triggered it. Both the
9
+ * title id (which names the dialog) and the dismiss wiring come from the Modal
10
+ * context, so a composed header needs no props of its own.
11
+ *
12
+ * The title is not a heading element: headings structure the page's document
13
+ * outline, and a modal opens from anywhere in it, so no heading level would be
14
+ * right everywhere. The title names the dialog through `aria-labelledby`
15
+ * instead, which is what a screen reader announces when the modal opens.
16
+ *
17
+ * @implements ds:global.subcomponent.modal-header
18
+ */
19
+ declare const Header: {
20
+ ({ children, titleId, undismissible, dismissLabel, onDismiss, className, ...props }: HeaderProps): React.ReactElement;
21
+ displayName: string;
22
+ };
23
+ export default Header;
24
+ //# sourceMappingURL=Header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/pattern/Modal/common/Header/Header.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,cAAc,CAAC;AAItB;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,MAAM;yFAQT,WAAW,GAAG,KAAK,CAAC,YAAY;;CAsBlC,CAAC;AAIF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { default as Header } from "./Header.js";
2
+ export type * from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/pattern/Modal/common/Header/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,mBAAmB,YAAY,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { ComponentProps, ReactNode } from "react";
2
+ type OwnProps = {
3
+ /**
4
+ * The modal title. It tells the user what triggered the modal.
5
+ *
6
+ * The title is deliberately not a heading element: the modal is a layer on
7
+ * top of the page, not part of its document outline, so it names the dialog
8
+ * through `aria-labelledby` instead.
9
+ *
10
+ */
11
+ children?: ReactNode;
12
+ /**
13
+ * `id` set on the title element so the dialog can point its
14
+ * `aria-labelledby` at it. Defaults to the id supplied by the Modal context;
15
+ */
16
+ titleId?: string;
17
+ /**
18
+ * Hides the close button, so the visible way out is an action in the footer.
19
+ */
20
+ undismissible?: boolean;
21
+ /** Accessible name for the close button. */
22
+ dismissLabel?: string;
23
+ /**
24
+ * Called when the close button is pressed. Defaults to closing the dialog
25
+ * through the Modal's context; set it only to override that.
26
+ */
27
+ onDismiss?: () => void;
28
+ };
29
+ /**
30
+ * Props for the Modal.Header subcomponent
31
+ *
32
+ * @implements ds:global.subcomponent.modal-header
33
+ */
34
+ export type HeaderProps = OwnProps & Omit<ComponentProps<"header">, keyof OwnProps>;
35
+ export {};
36
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/pattern/Modal/common/Header/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,KAAK,QAAQ,GAAG;IACd;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAChC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./Content/index.js";
2
+ export * from "./Footer/index.js";
3
+ export * from "./Header/index.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/pattern/Modal/common/index.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ModalContextValue } from "../types.js";
2
+ /** Reads the shared modal API. Throws if used outside a Modal. */
3
+ export declare const useModalContext: () => ModalContextValue;
4
+ //# sourceMappingURL=useModalContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useModalContext.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/pattern/Modal/hooks/useModalContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,kEAAkE;AAClE,eAAO,MAAM,eAAe,QAAO,iBAMlC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { RefObject } from "react";
2
+ import type { ModalContextValue } from "../types.js";
3
+ /**
4
+ * The provider state threaded to the composed subcomponents: the id that names
5
+ * the dialog, and the dismissal that closes it. Centralising it here keeps the
6
+ * provider free of state logic.
7
+ */
8
+ declare const useModalState: (dialogRef: RefObject<HTMLDialogElement | null>) => ModalContextValue;
9
+ export default useModalState;
10
+ //# sourceMappingURL=useModalState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useModalState.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/pattern/Modal/hooks/useModalState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;GAIG;AACH,QAAA,MAAM,aAAa,GACjB,WAAW,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,KAC7C,iBAMF,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default as Modal } from "./Provider.js";
2
+ export type * from "./types.js";
3
+ export { default as withModal } from "./withModal.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pattern/Modal/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAC;AACjD,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,122 @@
1
+ import type { ComponentProps, MouseEventHandler, ReactElement, ReactNode, RefCallback, RefObject } from "react";
2
+ type OwnProps = {
3
+ /**
4
+ * The handle on the underlying `<dialog>`, and the only way the modal opens:
5
+ * `ref.current?.showModal()`, with `ref.current?.close()` closing it. The prop
6
+ * is required because the modal is only ever opened through `showModal()`, so
7
+ * a modal with no ref is a modal that can never open — every modal needs a ref:
8
+ * withModal hands its factory the ref to attach and a
9
+ * directly-composed modal driven by a trigger takes a stored ref. Requiring the prop turns
10
+ * the withModal factory's duty — attaching the ref it receives —
11
+ * into a compile error instead of a silent nothing.
12
+ *
13
+ * `showModal()` throws on a dialog that is already open. A trigger sitting
14
+ * on the page cannot be clicked while the modal holds it inert, so it needs
15
+ * no guard; anything that can fire twice — a keyboard shortcut, an effect —
16
+ * should check `ref.current.open` first.
17
+ */
18
+ ref: RefCallback<HTMLDialogElement> | RefObject<HTMLDialogElement | null>;
19
+ /**
20
+ * Whether clicking the backdrop dismisses the modal. Defaults to `false`, so
21
+ * backdrop dismissal is opt-in. Independent of the header's `undismissible`.
22
+ */
23
+ closeOnBackdropClick?: boolean;
24
+ /**
25
+ * The composed sections — `Modal.Header`, `Modal.Content` and
26
+ * `Modal.Footer`, in that order. The header and footer are optional; the
27
+ * content carries the main information the modal conveys.
28
+ */
29
+ children: ReactNode;
30
+ };
31
+ /**
32
+ * Props for the Modal pattern
33
+ *
34
+ * @implements ds:global.pattern.modal
35
+ *
36
+ * `open` is omitted because a `<dialog>` carrying the `open` attribute is
37
+ * *non-modal*: no top layer, no backdrop, no focus trap. The modal is only
38
+ * ever opened through `showModal()`, so the open state lives in the DOM
39
+ * element and not in a prop. Use the `ref` to open or close it.
40
+ *
41
+ * `onClose` is *not* omitted: the native `close` event is how a consumer hears
42
+ * that the modal is gone, whichever way out the user took, and it replaces the
43
+ * `onOpenChange` callback a controlled modal would need. It does not say *which*
44
+ * way out that was — an action that needs to be told apart from a dismissal
45
+ * should close the modal with `ref.current?.close(value)` and read
46
+ * `event.currentTarget.returnValue`.
47
+ */
48
+ export type ModalProps = OwnProps & Omit<ComponentProps<"dialog">, keyof OwnProps | "open">;
49
+ /**
50
+ * The shared modal API threaded to the composed subcomponents through the
51
+ * Modal context: the id the dialog's `aria-labelledby` points at (set on the
52
+ * Header's title, which is what gives the dialog its accessible name), and
53
+ * the dismissal that closes the dialog (what the Header's close button calls).
54
+ */
55
+ export interface ModalContextValue {
56
+ /**
57
+ * The id the dialog's `aria-labelledby` points at. The Header sets it on the
58
+ * title, which is what gives the dialog its accessible name.
59
+ */
60
+ titleId: string;
61
+ /** Closes the dialog. What the Header's close button calls. */
62
+ onDismiss: () => void;
63
+ }
64
+ /**
65
+ * The one requirement {@link withModal} places on the component it wraps: it
66
+ * must accept an `onClick` handler. The HOC composes its open handler onto
67
+ * the trigger itself — no wrapper element — so a trigger that accepts
68
+ * `onClick` but never forwards it to a clickable element never opens its
69
+ * modal. An `onClick` the consumer passes still runs: the HOC calls it first,
70
+ * then opens the modal.
71
+ *
72
+ * The event is typed against plain `Element` so triggers rooted at any
73
+ * element — `<button>`, `<a>`, a clickable `<span>` — satisfy the constraint:
74
+ * React's event handlers are bivariant (the `bivarianceHack`), so a
75
+ * `MouseEventHandler<HTMLButtonElement>` prop fits where a
76
+ * `MouseEventHandler<Element>` is expected.
77
+ */
78
+ export type WithModalTriggerProps = {
79
+ onClick?: MouseEventHandler<Element>;
80
+ };
81
+ /**
82
+ * The props the modal element returned by a {@link WithModalRender} carries:
83
+ * everything `Modal` accepts — including the required `ref`, which the factory
84
+ * sets on the `<Modal>` so the trigger can open it.
85
+ */
86
+ export type WithModalModalProps = ModalProps;
87
+ /**
88
+ * What {@link withModal} hands a {@link WithModalRender} function: a props
89
+ * object.
90
+ */
91
+ export type WithModalRenderProps = {
92
+ /** Closes the modal. What a footer button wires its `onClick` to. */
93
+ close: () => void;
94
+ /**
95
+ * The handle on the `<dialog>` the trigger opens. The factory MUST set it
96
+ * on the `<Modal>` it returns — `<Modal ref={ref}>`. `Modal` requires its
97
+ * `ref`, so a factory that forgets it fails to compile.
98
+ */
99
+ ref: RefObject<HTMLDialogElement | null>;
100
+ };
101
+ /**
102
+ * The second argument of {@link withModal}: a render contract. The HOC calls
103
+ * it during render with a {@link WithModalRenderProps} object — `{ close,
104
+ * ref }` — and it returns the complete `<Modal>` element.
105
+ *
106
+ * **Every factory must attach the `ref` it receives to the `<Modal>` it
107
+ * returns.** The trigger opens the dialog through that ref. `Modal` requires
108
+ * its `ref`, so a factory that forgets it fails to compile:
109
+ *
110
+ * `({ ref }) => <Modal ref={ref}>…</Modal>`
111
+ *
112
+ * or, with a footer button that closes the modal:
113
+ *
114
+ * `({ close, ref }) => <Modal ref={ref}><Modal.Footer><Button onClick={close}>Got it</Button></Modal.Footer></Modal>`
115
+ *
116
+ * A footer action can only close. If it must do more — submit data, close
117
+ * conditionally, open another modal — skip the HOC and compose `Modal`
118
+ * directly, driving it through its `ref`.
119
+ */
120
+ export type WithModalRender = (props: WithModalRenderProps) => ReactElement<WithModalModalProps>;
121
+ export {};
122
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pattern/Modal/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,WAAW,EACX,SAAS,EACV,MAAM,OAAO,CAAC;AAEf,KAAK,QAAQ,GAAG;IACd;;;;;;;;;;;;;;OAcG;IACH,GAAG,EAAE,WAAW,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAC1E;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAC/B,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,+DAA+D;IAC/D,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;CACtC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,qEAAqE;IACrE,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;;OAIG;IACH,GAAG,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,eAAe,GAAG,CAC5B,KAAK,EAAE,oBAAoB,KACxB,YAAY,CAAC,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,74 @@
1
+ import type { ComponentType } from "react";
2
+ import type { WithModalRender, WithModalTriggerProps } from "./types.js";
3
+ /**
4
+ * Wraps a trigger with a modal. Click the trigger → the modal opens.
5
+ *
6
+ * **The wrapped component must accept `onClick`** and forward it to the
7
+ * clickable element at its root — the HOC composes its open handler onto the
8
+ * trigger itself, with no wrapper element in between. An `onClick` the
9
+ * consumer passes keeps working: it runs first, then the modal opens.
10
+ *
11
+ * The second argument is a function: the HOC calls it with a props object
12
+ * carrying `close` and `ref`, and it returns a complete `<Modal>` element —
13
+ * sections, props and all:
14
+ *
15
+ * ```tsx
16
+ * const OpenButton = withModal(
17
+ * Button,
18
+ * ({ ref }) => (
19
+ * <Modal ref={ref}>
20
+ * <Modal.Content>Hello</Modal.Content>
21
+ * </Modal>
22
+ * ),
23
+ * );
24
+ * <OpenButton>Open</OpenButton>;
25
+ * ```
26
+ *
27
+ * Everything `Modal` accepts lives on the element the function returns —
28
+ * `closeOnBackdropClick`, `aria-label`, `className` — so the consumer sees the
29
+ * real modal, not an options bag. **One duty comes with that freedom: the
30
+ * factory must attach the `ref` it receives to the `<Modal>`** (`<Modal
31
+ * ref={ref}>`). The trigger opens the dialog through that ref — and `Modal`
32
+ * requires its `ref`, so a factory that forgets it fails to compile.
33
+ *
34
+ * **How it closes:** the header's X button and Escape always work. Add
35
+ * `closeOnBackdropClick` to the modal element and a backdrop click works too.
36
+ *
37
+ * **Footer buttons can only close the modal.** That is the one and only
38
+ * action this HOC provides — wire one to the `close` the function receives:
39
+ *
40
+ * ```tsx
41
+ * const confirmationModal: WithModalRender = ({ close, ref }) => (
42
+ * <Modal ref={ref}>
43
+ * <Modal.Footer>
44
+ * <Button onClick={close}>Got it</Button>
45
+ * </Modal.Footer>
46
+ * </Modal>
47
+ * );
48
+ *
49
+ * const OpenButton = withModal(Button, confirmationModal);
50
+ * ```
51
+ *
52
+ * If an action needs to do more than close — save data, open another modal,
53
+ * close conditionally — don't use this HOC: compose `Modal` directly and drive
54
+ * it through its `ref`.
55
+ *
56
+ * `withModal` is meant for static content and belongs at module scope, called
57
+ * once. The function it is handed is invoked on every render of the trigger,
58
+ * but at module scope it can only see module-level values, so what it returns
59
+ * is the same on every render. If the modal must show data from the parent —
60
+ * for example a different `userId` depending on which user is selected —
61
+ * don't call this HOC inside the component; compose `Modal` directly and
62
+ * drive it through its `ref`.
63
+ *
64
+ * A pure composition wrapper: it renders the wrapped component and the modal
65
+ * as siblings, so it carries no root element of its own.
66
+ *
67
+ * `import { withModal } from "@canonical/react-ds-global";`
68
+ *
69
+ * @param Component The trigger component to wrap (e.g. `Button`). It must accept `onClick` and forward it to its root element; clicking it opens the modal.
70
+ * @param modal A {@link WithModalRender} function: it receives `{ close, ref }`, must attach `ref` to the `<Modal>` it returns, and the trigger opens it.
71
+ */
72
+ declare const withModal: <TProps extends WithModalTriggerProps>(Component: ComponentType<TProps>, modal: WithModalRender) => ComponentType<TProps>;
73
+ export default withModal;
74
+ //# sourceMappingURL=withModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withModal.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pattern/Modal/withModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,QAAA,MAAM,SAAS,GAAI,MAAM,SAAS,qBAAqB,EACrD,WAAW,aAAa,CAAC,MAAM,CAAC,EAChC,OAAO,eAAe,KACrB,aAAa,CAAC,MAAM,CAyCtB,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,2 +1,3 @@
1
+ export * from "./Modal/index.js";
1
2
  export * from "./Timeline/index.js";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/pattern/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/pattern/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,20 @@
1
1
  {
2
2
  "name": "@canonical/react-ds-global",
3
- "version": "0.37.0",
3
+ "version": "0.40.0",
4
4
  "type": "module",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/types/index.d.ts",
8
+ "style": "dist/esm/lib/index.css",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/types/index.d.ts",
12
+ "default": "./dist/esm/index.js"
13
+ },
14
+ "./index.css": "./dist/esm/lib/index.css",
15
+ "./package.json": "./package.json",
16
+ "./dist/*": "./dist/*"
17
+ },
8
18
  "files": [
9
19
  "dist"
10
20
  ],
@@ -43,26 +53,26 @@
43
53
  "test:vitest:watch": "vitest"
44
54
  },
45
55
  "dependencies": {
46
- "@canonical/design-tokens": "0.8.1",
47
- "@canonical/ds-assets": "^0.37.0",
48
- "@canonical/react-hooks": "^0.37.0",
49
- "@canonical/storybook-config": "^0.37.0",
50
- "@canonical/styles": "^0.37.0",
51
- "@canonical/utils": "^0.37.0",
56
+ "@canonical/design-tokens": "0.10.0",
57
+ "@canonical/ds-assets": "^0.40.0",
58
+ "@canonical/ds-utils": "^0.40.0",
59
+ "@canonical/react-hooks": "^0.40.0",
60
+ "@canonical/storybook-config": "^0.40.0",
61
+ "@canonical/styles": "^0.40.0",
52
62
  "react": "^19.2.4",
53
63
  "react-dom": "^19.2.4"
54
64
  },
55
65
  "devDependencies": {
56
- "@biomejs/biome": "2.4.9",
57
- "@canonical/biome-config": "^0.37.0",
58
- "@canonical/ds-types": "^0.37.0",
59
- "@canonical/router-core": "^0.37.0",
60
- "@canonical/router-react": "^0.37.0",
61
- "@canonical/storybook-addon-utils": "^0.37.0",
62
- "@canonical/storybook-helpers": "^0.37.0",
63
- "@canonical/typescript-config-react": "^0.37.0",
64
- "@canonical/vitest-config-react": "^0.37.0",
65
- "@canonical/webarchitect": "^0.37.0",
66
+ "@biomejs/biome": "2.5.13",
67
+ "@canonical/biome-config": "^0.40.0",
68
+ "@canonical/ds-types": "^0.40.0",
69
+ "@canonical/router-core": "^0.40.0",
70
+ "@canonical/router-react": "^0.40.0",
71
+ "@canonical/storybook-addon-utils": "^0.40.0",
72
+ "@canonical/storybook-helpers": "^0.40.0",
73
+ "@canonical/typescript-config-react": "^0.40.0",
74
+ "@canonical/vitest-config-react": "^0.40.0",
75
+ "@canonical/webarchitect": "^0.40.0",
66
76
  "@chromatic-com/storybook": "^5.0.1",
67
77
  "@storybook/addon-docs": "^10.3.1",
68
78
  "@storybook/react-vite": "^10.3.1",
@@ -80,5 +90,5 @@
80
90
  "vite": "^8.0.1",
81
91
  "vitest": "^4.0.18"
82
92
  },
83
- "gitHead": "ac8383bdb4be1bcd6fa6c4960a1e3d78c0279688"
93
+ "gitHead": "9136b71518260c5f33e7619da087198c931e4c13"
84
94
  }