@kaizen/components 1.35.1 → 1.36.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 (153) hide show
  1. package/dist/cjs/Button/GenericButton/GenericButton.cjs +1 -1
  2. package/dist/cjs/Button/GenericButton/GenericButton.cjs.map +1 -1
  3. package/dist/cjs/KaizenProvider/KaizenProvider.cjs +6 -1
  4. package/dist/cjs/KaizenProvider/KaizenProvider.cjs.map +1 -1
  5. package/dist/cjs/Modal/ContextModal/ContextModal.cjs +9 -6
  6. package/dist/cjs/Modal/ContextModal/ContextModal.cjs.map +1 -1
  7. package/dist/cjs/MultiSelect/subcomponents/Popover/Popover.cjs +1 -1
  8. package/dist/cjs/MultiSelect/subcomponents/Popover/Popover.cjs.map +1 -1
  9. package/dist/cjs/Notification/ToastNotification/ToastNotification/ToastNotification.cjs +33 -0
  10. package/dist/cjs/Notification/ToastNotification/ToastNotification/ToastNotification.cjs.map +1 -0
  11. package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.cjs +36 -0
  12. package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.cjs.map +1 -0
  13. package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.module.scss.cjs +7 -0
  14. package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.module.scss.cjs.map +1 -0
  15. package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.cjs +42 -0
  16. package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.cjs.map +1 -0
  17. package/dist/cjs/Notification/ToastNotification/context/ToastNotificationContext.cjs +72 -0
  18. package/dist/cjs/Notification/ToastNotification/context/ToastNotificationContext.cjs.map +1 -0
  19. package/dist/cjs/Notification/ToastNotification/hooks/useToastNotification.cjs +9 -0
  20. package/dist/cjs/Notification/ToastNotification/hooks/useToastNotification.cjs.map +1 -0
  21. package/dist/cjs/RichTextEditor/RichTextEditor/RichTextEditor.cjs +6 -2
  22. package/dist/cjs/RichTextEditor/RichTextEditor/RichTextEditor.cjs.map +1 -1
  23. package/dist/cjs/__future__/Select/Select.cjs +24 -2
  24. package/dist/cjs/__future__/Select/Select.cjs.map +1 -1
  25. package/dist/cjs/dts/Modal/ContextModal/ContextModal.d.ts +2 -1
  26. package/dist/cjs/dts/MultiSelect/MultiSelect.d.ts +4 -2
  27. package/dist/cjs/dts/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.d.ts +3 -0
  28. package/dist/cjs/dts/MultiSelect/types.d.ts +6 -0
  29. package/dist/cjs/dts/Notification/ToastNotification/ToastNotification/ToastNotification.d.ts +16 -0
  30. package/dist/cjs/dts/Notification/ToastNotification/ToastNotification/index.d.ts +1 -0
  31. package/dist/cjs/dts/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.d.ts +4 -0
  32. package/dist/cjs/dts/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.d.ts +12 -0
  33. package/dist/cjs/dts/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/index.d.ts +1 -0
  34. package/dist/cjs/dts/Notification/ToastNotification/context/ToastNotificationContext.d.ts +21 -0
  35. package/dist/cjs/dts/Notification/ToastNotification/hooks/useToastNotification.d.ts +2 -0
  36. package/dist/cjs/dts/Notification/ToastNotification/index.d.ts +3 -2
  37. package/dist/cjs/dts/Notification/ToastNotification/types.d.ts +1 -9
  38. package/dist/cjs/dts/Notification/index.d.ts +1 -0
  39. package/dist/cjs/dts/RichTextEditor/RichTextEditor/RichTextEditor.d.ts +1 -1
  40. package/dist/cjs/dts/__future__/Select/Select.d.ts +5 -1
  41. package/dist/cjs/index.cjs +6 -0
  42. package/dist/cjs/index.cjs.map +1 -1
  43. package/dist/cjs/index.css +4 -3
  44. package/dist/esm/Button/GenericButton/GenericButton.mjs +1 -1
  45. package/dist/esm/Button/GenericButton/GenericButton.mjs.map +1 -1
  46. package/dist/esm/KaizenProvider/KaizenProvider.mjs +6 -1
  47. package/dist/esm/KaizenProvider/KaizenProvider.mjs.map +1 -1
  48. package/dist/esm/Modal/ContextModal/ContextModal.mjs +9 -6
  49. package/dist/esm/Modal/ContextModal/ContextModal.mjs.map +1 -1
  50. package/dist/esm/MultiSelect/subcomponents/Popover/Popover.mjs +1 -1
  51. package/dist/esm/MultiSelect/subcomponents/Popover/Popover.mjs.map +1 -1
  52. package/dist/esm/Notification/ToastNotification/ToastNotification/ToastNotification.mjs +31 -0
  53. package/dist/esm/Notification/ToastNotification/ToastNotification/ToastNotification.mjs.map +1 -0
  54. package/dist/esm/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.mjs +34 -0
  55. package/dist/esm/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.mjs.map +1 -0
  56. package/dist/esm/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.module.scss.mjs +5 -0
  57. package/dist/esm/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.module.scss.mjs.map +1 -0
  58. package/dist/esm/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.mjs +40 -0
  59. package/dist/esm/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.mjs.map +1 -0
  60. package/dist/esm/Notification/ToastNotification/context/ToastNotificationContext.mjs +69 -0
  61. package/dist/esm/Notification/ToastNotification/context/ToastNotificationContext.mjs.map +1 -0
  62. package/dist/esm/Notification/ToastNotification/hooks/useToastNotification.mjs +7 -0
  63. package/dist/esm/Notification/ToastNotification/hooks/useToastNotification.mjs.map +1 -0
  64. package/dist/esm/RichTextEditor/RichTextEditor/RichTextEditor.mjs +6 -2
  65. package/dist/esm/RichTextEditor/RichTextEditor/RichTextEditor.mjs.map +1 -1
  66. package/dist/esm/__future__/Select/Select.mjs +25 -3
  67. package/dist/esm/__future__/Select/Select.mjs.map +1 -1
  68. package/dist/esm/dts/Modal/ContextModal/ContextModal.d.ts +2 -1
  69. package/dist/esm/dts/MultiSelect/MultiSelect.d.ts +4 -2
  70. package/dist/esm/dts/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.d.ts +3 -0
  71. package/dist/esm/dts/MultiSelect/types.d.ts +6 -0
  72. package/dist/esm/dts/Notification/ToastNotification/ToastNotification/ToastNotification.d.ts +16 -0
  73. package/dist/esm/dts/Notification/ToastNotification/ToastNotification/index.d.ts +1 -0
  74. package/dist/esm/dts/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.d.ts +4 -0
  75. package/dist/esm/dts/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.d.ts +12 -0
  76. package/dist/esm/dts/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/index.d.ts +1 -0
  77. package/dist/esm/dts/Notification/ToastNotification/context/ToastNotificationContext.d.ts +21 -0
  78. package/dist/esm/dts/Notification/ToastNotification/hooks/useToastNotification.d.ts +2 -0
  79. package/dist/esm/dts/Notification/ToastNotification/index.d.ts +3 -2
  80. package/dist/esm/dts/Notification/ToastNotification/types.d.ts +1 -9
  81. package/dist/esm/dts/Notification/index.d.ts +1 -0
  82. package/dist/esm/dts/RichTextEditor/RichTextEditor/RichTextEditor.d.ts +1 -1
  83. package/dist/esm/dts/__future__/Select/Select.d.ts +5 -1
  84. package/dist/esm/index.css +5 -4
  85. package/dist/esm/index.mjs +3 -0
  86. package/dist/esm/index.mjs.map +1 -1
  87. package/dist/index.d.ts +50 -3
  88. package/dist/styles.css +1 -1
  89. package/package.json +2 -2
  90. package/src/Button/Button/_docs/Button.mdx +5 -0
  91. package/src/Button/Button/_docs/Button.stories.tsx +27 -1
  92. package/src/Button/GenericButton/GenericButton.spec.tsx +69 -0
  93. package/src/Button/GenericButton/GenericButton.tsx +1 -1
  94. package/src/DatePicker/DatePicker.spec.tsx +1 -1
  95. package/src/KaizenProvider/KaizenProvider.tsx +6 -1
  96. package/src/Modal/ContextModal/ContextModal.spec.tsx +3 -3
  97. package/src/Modal/ContextModal/ContextModal.tsx +9 -5
  98. package/src/MultiSelect/MultiSelect.spec.tsx +56 -1
  99. package/src/MultiSelect/MultiSelect.tsx +10 -3
  100. package/src/MultiSelect/_docs/MultiSelect.mdx +10 -0
  101. package/src/MultiSelect/_docs/MultiSelect.stickersheet.stories.tsx +81 -43
  102. package/src/MultiSelect/_docs/MultiSelect.stories.tsx +21 -0
  103. package/src/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.module.scss +9 -0
  104. package/src/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.tsx +8 -1
  105. package/src/MultiSelect/subcomponents/MultiSelectToggle/_docs/MultiSelectToggle.stickersheet.stories.tsx +17 -0
  106. package/src/MultiSelect/subcomponents/Popover/Popover.tsx +1 -1
  107. package/src/MultiSelect/types.ts +7 -0
  108. package/src/Notification/ToastNotification/ToastNotification/ToastNotification.spec.tsx +33 -0
  109. package/src/Notification/ToastNotification/ToastNotification/ToastNotification.tsx +48 -0
  110. package/src/Notification/ToastNotification/ToastNotification/index.ts +1 -0
  111. package/src/Notification/ToastNotification/{subcomponents/ToastNotificationsList → ToastNotificationsList}/ToastNotificationsList.module.scss +1 -1
  112. package/src/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.tsx +40 -0
  113. package/src/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.tsx +49 -0
  114. package/src/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/index.ts +1 -0
  115. package/src/Notification/ToastNotification/_docs/ToastNotification.mdx +19 -14
  116. package/src/Notification/ToastNotification/_docs/ToastNotification.stickersheet.stories.tsx +33 -70
  117. package/src/Notification/ToastNotification/_docs/ToastNotification.stories.tsx +123 -93
  118. package/src/Notification/ToastNotification/context/ToastNotificationContext.tsx +96 -0
  119. package/src/Notification/ToastNotification/hooks/useToastNotification.ts +9 -0
  120. package/src/Notification/ToastNotification/index.ts +3 -2
  121. package/src/Notification/ToastNotification/types.ts +1 -18
  122. package/src/Notification/index.ts +1 -0
  123. package/src/RichTextEditor/RichTextEditor/RichTextEditor.tsx +6 -1
  124. package/src/RichTextEditor/utils/commands/addMark.spec.ts +0 -1
  125. package/src/Tooltip/Tooltip.spec.tsx +6 -1
  126. package/src/__future__/Select/Select.spec.tsx +109 -14
  127. package/src/__future__/Select/Select.tsx +32 -3
  128. package/src/__future__/Select/_docs/Select.mdx +8 -0
  129. package/src/__future__/Select/_docs/Select.stories.tsx +29 -0
  130. package/dist/cjs/dts/Notification/ToastNotification/ToastNotification.d.ts +0 -14
  131. package/dist/cjs/dts/Notification/ToastNotification/subcomponents/ToastNotificationManager/ToastNotificationManager.d.ts +0 -7
  132. package/dist/cjs/dts/Notification/ToastNotification/subcomponents/ToastNotificationManager/index.d.ts +0 -1
  133. package/dist/cjs/dts/Notification/ToastNotification/subcomponents/ToastNotificationsList/ToastNotificationsList.d.ts +0 -11
  134. package/dist/cjs/dts/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/ToastNotificationsListContainer.d.ts +0 -7
  135. package/dist/cjs/dts/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/index.d.ts +0 -1
  136. package/dist/esm/dts/Notification/ToastNotification/ToastNotification.d.ts +0 -14
  137. package/dist/esm/dts/Notification/ToastNotification/subcomponents/ToastNotificationManager/ToastNotificationManager.d.ts +0 -7
  138. package/dist/esm/dts/Notification/ToastNotification/subcomponents/ToastNotificationManager/index.d.ts +0 -1
  139. package/dist/esm/dts/Notification/ToastNotification/subcomponents/ToastNotificationsList/ToastNotificationsList.d.ts +0 -11
  140. package/dist/esm/dts/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/ToastNotificationsListContainer.d.ts +0 -7
  141. package/dist/esm/dts/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/index.d.ts +0 -1
  142. package/src/Notification/ToastNotification/ToastNotification.spec.tsx +0 -31
  143. package/src/Notification/ToastNotification/ToastNotification.tsx +0 -43
  144. package/src/Notification/ToastNotification/subcomponents/ToastNotificationManager/ToastNotificationManager.spec.tsx +0 -144
  145. package/src/Notification/ToastNotification/subcomponents/ToastNotificationManager/ToastNotificationManager.tsx +0 -135
  146. package/src/Notification/ToastNotification/subcomponents/ToastNotificationManager/index.ts +0 -1
  147. package/src/Notification/ToastNotification/subcomponents/ToastNotificationsList/ToastNotificationsList.tsx +0 -40
  148. package/src/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/ToastNotificationsListContainer.spec.tsx +0 -73
  149. package/src/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/ToastNotificationsListContainer.tsx +0 -31
  150. package/src/Notification/ToastNotification/subcomponents/ToastNotificationsListContainer/index.ts +0 -1
  151. /package/dist/cjs/dts/Notification/ToastNotification/{subcomponents/ToastNotificationsList → ToastNotificationsList}/index.d.ts +0 -0
  152. /package/dist/esm/dts/Notification/ToastNotification/{subcomponents/ToastNotificationsList → ToastNotificationsList}/index.d.ts +0 -0
  153. /package/src/Notification/ToastNotification/{subcomponents/ToastNotificationsList → ToastNotificationsList}/index.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastNotificationsList.mjs","sources":["../../../../../src/Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.tsx"],"sourcesContent":["import React from \"react\"\nimport { createPortal } from \"react-dom\"\nimport { useToastNotificationContext } from \"../context/ToastNotificationContext\"\nimport { ToastNotificationsMap } from \"./subcomponents/ToastNotificationsMap\"\nimport styles from \"./ToastNotificationsList.module.scss\"\n\nexport const ToastNotificationsList = (): JSX.Element => {\n const { notifications, removeToastNotification } =\n useToastNotificationContext()\n\n const containers = document.querySelectorAll(\n '[data-testid=\"toast-notifications-list\"'\n )\n\n if (containers) {\n // Remove any duplicate instances\n // (eg. Storybook docs page has multiple stories each with their own context)\n containers.forEach((c, i) => {\n if (i === 0) return\n c.remove()\n })\n }\n\n return createPortal(\n <div\n data-testid=\"toast-notifications-list\"\n role=\"status\"\n className={styles.toastNotificationsList}\n >\n <ToastNotificationsMap\n notifications={notifications}\n onHide={removeToastNotification}\n container={containers[0]}\n />\n </div>,\n document.body\n )\n}\n\nToastNotificationsList.displayName = \"ToastNotificationsList\"\n"],"names":["ToastNotificationsList","_a","useToastNotificationContext","notifications","removeToastNotification","containers","document","querySelectorAll","forEach","c","i","remove","createPortal","React","createElement","role","className","styles","toastNotificationsList","ToastNotificationsMap","onHide","container","body","displayName"],"mappings":";;;;;MAMaA,sBAAsB;EAAA,MAAtBA,sBAAsB,GAAG,SAAAA,CAAA,EAAA;IAC9B,IAAAC,EAAA,GACJC,2BAA2B,CAAA,CAAE;MADvBC,aAAa,GAAAF,EAAA,CAAAE,aAAA;MAAEC,uBAAuB,GAAAH,EAAA,CAAAG,uBACf;IAE/B,IAAMC,UAAU,GAAGC,QAAQ,CAACC,gBAAgB,CAC1C,yCAAyC,CAC1C;IAED,IAAIF,UAAU,EAAE;;;MAGdA,UAAU,CAACG,OAAO,CAAC,UAACC,CAAC,EAAEC,CAAC,EAAA;QACtB,IAAIA,CAAC,KAAK,CAAC,EAAE;QACbD,CAAC,CAACE,MAAM,CAAA,CAAE;MACZ,CAAC,CAAC;IACH;IAED,oBAAOC,YAAY,eACjBC,KACc,CAAAC,aAAA,CAAA,KAAA,EAAA;MAAA,aAAA,EAAA,0BAA0B;MACtCC,IAAI,EAAC,QAAQ;MACbC,SAAS,EAAEC,MAAM,CAACC;IAAsB,CAAA,eAExCL,KAAC,CAAAC,aAAA,CAAAK,qBAAqB;MACpBhB,aAAa,EAAEA,aAAa;MAC5BiB,MAAM,EAAEhB,uBAAuB;MAC/BiB,SAAS,EAAEhB,UAAU,CAAC,CAAC;IAAC,CACxB,CAAA,CACE,EACNC,QAAQ,CAACgB,IAAI,CACd;EACH,CAAC;EAEDtB,sBAAsB,CAACuB,WAAW,GAAG,wBAAwB;EAAA,OAjChDvB,sBAAsB;AAAA;"}
@@ -0,0 +1,5 @@
1
+ var styles = {
2
+ "toastNotificationsList": "ToastNotificationsList-module_toastNotificationsList__APiSP"
3
+ };
4
+ export { styles as default };
5
+ //# sourceMappingURL=ToastNotificationsList.module.scss.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastNotificationsList.module.scss.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -0,0 +1,40 @@
1
+ import { __rest, __assign } from 'tslib';
2
+ import React from 'react';
3
+ import { createPortal } from 'react-dom';
4
+ import { GenericNotification } from '../../../../subcomponents/GenericNotification/GenericNotification.mjs';
5
+ const ToastNotificationsMap = /*#__PURE__*/function () {
6
+ const ToastNotificationsMap = function (_a) {
7
+ var notifications = _a.notifications,
8
+ defaultOnHide = _a.onHide,
9
+ container = _a.container;
10
+ if (!container) return null;
11
+ // To consolidate all notifications into a single list when there are multiple contexts,
12
+ // this list cannot render with a container (must be portalled into one).
13
+ return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(React.Fragment, null, notifications.map(function (_a) {
14
+ var id = _a.id,
15
+ type = _a.type,
16
+ title = _a.title,
17
+ persistent = _a.persistent,
18
+ onHide = _a.onHide,
19
+ message = _a.message,
20
+ restProps = __rest(_a, ["id", "type", "title", "persistent", "onHide", "message"]);
21
+ return /*#__PURE__*/React.createElement(GenericNotification, __assign({
22
+ key: id,
23
+ style: "toast",
24
+ type: type,
25
+ title: title,
26
+ persistent: persistent,
27
+ onHide: function () {
28
+ if (typeof onHide !== "undefined") {
29
+ onHide();
30
+ }
31
+ defaultOnHide(id);
32
+ }
33
+ }, restProps), message);
34
+ })), container);
35
+ };
36
+ ToastNotificationsMap.displayName = "ToastNotificationsMap";
37
+ return ToastNotificationsMap;
38
+ }();
39
+ export { ToastNotificationsMap };
40
+ //# sourceMappingURL=ToastNotificationsMap.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastNotificationsMap.mjs","sources":["../../../../../../../src/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.tsx"],"sourcesContent":["import React, { HTMLAttributes } from \"react\"\nimport { createPortal } from \"react-dom\"\nimport { GenericNotification } from \"~components/Notification/subcomponents/GenericNotification\"\nimport { OverrideClassName } from \"~types/OverrideClassName\"\nimport { ToastNotificationObj } from \"../../../types\"\n\nexport type ToastNotificationsMapProps = {\n notifications: ToastNotificationObj[]\n onHide: (notificationId: string) => void\n container: Element | null\n} & OverrideClassName<HTMLAttributes<HTMLDivElement>>\n\nexport const ToastNotificationsMap = ({\n notifications,\n onHide: defaultOnHide,\n container,\n}: ToastNotificationsMapProps): JSX.Element | null => {\n if (!container) return null\n\n // To consolidate all notifications into a single list when there are multiple contexts,\n // this list cannot render with a container (must be portalled into one).\n return createPortal(\n <>\n {notifications.map(\n ({ id, type, title, persistent, onHide, message, ...restProps }) => (\n <GenericNotification\n key={id}\n style=\"toast\"\n type={type}\n title={title}\n persistent={persistent}\n onHide={(): void => {\n if (typeof onHide !== \"undefined\") {\n onHide()\n }\n defaultOnHide(id)\n }}\n {...restProps}\n >\n {message}\n </GenericNotification>\n )\n )}\n </>,\n container\n )\n}\n\nToastNotificationsMap.displayName = \"ToastNotificationsMap\"\n"],"names":["ToastNotificationsMap","_a","notifications","defaultOnHide","onHide","container","createPortal","React","createElement","Fragment","map","id","type","title","persistent","message","restProps","__rest","GenericNotification","__assign","key","style","displayName"],"mappings":";;;;MAYaA,qBAAqB;EAAA,MAArBA,qBAAqB,GAAG,SAAAA,CAACC,EAIT,EAAA;IAH3B,IAAAC,aAAa,mBAAA;MACLC,aAAa,GAAAF,EAAA,CAAAG,MAAA;MACrBC,SAAS,GAAAJ,EAAA,CAAAI,SAAA;IAET,IAAI,CAACA,SAAS,EAAE,OAAO,IAAI;;;IAI3B,oBAAOC,YAAY,eACjBC,KACG,CAAAC,aAAA,CAAAD,KAAA,CAAAE,QAAA,EAAA,IAAA,EAAAP,aAAa,CAACQ,GAAG,CAChB,UAACT,EAA8D,EAAA;MAA5D,IAAAU,EAAE,QAAA;QAAEC,IAAI,UAAA;QAAEC,KAAK,WAAA;QAAEC,UAAU,gBAAA;QAAEV,MAAM,YAAA;QAAEW,OAAO,aAAA;QAAKC,SAAS,GAA5DC,MAAA,CAAAhB,EAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAAA,YAAA,EAAA,QAAA,EAAA,SAAA,CAA8D,CAAF;MAAO,oBAClEM,KAAC,CAAAC,aAAA,CAAAU,mBAAmB,EAClBC,QAAA,CAAA;QAAAC,GAAG,EAAET,EAAE;QACPU,KAAK,EAAC,OAAO;QACbT,IAAI,EAAEA,IAAI;QACVC,KAAK,EAAEA,KAAK;QACZC,UAAU,EAAEA,UAAU;QACtBV,MAAM,EAAE,SAAAA,CAAA,EAAA;UACN,IAAI,OAAOA,MAAM,KAAK,WAAW,EAAE;YACjCA,MAAM,EAAE;UACT;UACDD,aAAa,CAACQ,EAAE,CAAC;QACnB;SACIK,SAAS,CAAA,EAEZD,OAAO,CACY;IACvB,CAAA,CACF,CACA,EACHV,SAAS,CACV;EACH,CAAC;EAEDL,qBAAqB,CAACsB,WAAW,GAAG,uBAAuB;EAAA,OApC9CtB,qBAAqB;AAAA;"}
@@ -0,0 +1,69 @@
1
+ import { __assign, __spreadArray } from 'tslib';
2
+ import React, { useContext, useState } from 'react';
3
+ import { v4 } from 'uuid';
4
+ var ToastNotificationContext = /*#__PURE__*/React.createContext(null);
5
+ var useToastNotificationContext = function () {
6
+ var context = useContext(ToastNotificationContext);
7
+ if (!context) {
8
+ throw new Error("useToastNotificationContext must be used within the ToastNotificationContext.Provider");
9
+ }
10
+ return context;
11
+ };
12
+ const ToastNotificationProvider = /*#__PURE__*/function () {
13
+ const ToastNotificationProvider = function (_a) {
14
+ var children = _a.children;
15
+ var _b = useState([]),
16
+ notifications = _b[0],
17
+ setNotifications = _b[1];
18
+ var addToastNotification = function (notification) {
19
+ var uuid = v4();
20
+ var notificationWithId = __assign({
21
+ id: uuid
22
+ }, notification);
23
+ var notificationExists = notifications.find(function (_a) {
24
+ var id = _a.id;
25
+ return id === notification.id;
26
+ });
27
+ if (!notificationExists) {
28
+ setNotifications(function (existing) {
29
+ return __spreadArray(__spreadArray([], existing, true), [notificationWithId], false);
30
+ });
31
+ }
32
+ };
33
+ var updateToastNotification = function (notification) {
34
+ var notificationIndex = notifications.findIndex(function (_a) {
35
+ var id = _a.id;
36
+ return id === notification.id;
37
+ });
38
+ var copy = notifications.slice();
39
+ copy.splice(notificationIndex, 1, notification); // Mutation to insert notification over itself
40
+ setNotifications(copy);
41
+ };
42
+ var removeToastNotification = function (notificationID) {
43
+ var notificationIndex = notifications.findIndex(function (_a) {
44
+ var id = _a.id;
45
+ return id === notificationID;
46
+ });
47
+ var copy = notifications.slice();
48
+ copy.splice(notificationIndex, 1); // Mutation
49
+ setNotifications(copy);
50
+ };
51
+ var clearToastNotifications = function () {
52
+ setNotifications([]);
53
+ };
54
+ var value = {
55
+ notifications: notifications,
56
+ addToastNotification: addToastNotification,
57
+ updateToastNotification: updateToastNotification,
58
+ removeToastNotification: removeToastNotification,
59
+ clearToastNotifications: clearToastNotifications
60
+ };
61
+ return /*#__PURE__*/React.createElement(ToastNotificationContext.Provider, {
62
+ value: value
63
+ }, children);
64
+ };
65
+ ToastNotificationProvider.displayName = "ToastNotificationProvider";
66
+ return ToastNotificationProvider;
67
+ }();
68
+ export { ToastNotificationProvider, useToastNotificationContext };
69
+ //# sourceMappingURL=ToastNotificationContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastNotificationContext.mjs","sources":["../../../../../src/Notification/ToastNotification/context/ToastNotificationContext.tsx"],"sourcesContent":["import React, { useContext, useState } from \"react\"\nimport { v4 as uuidv4 } from \"uuid\"\nimport { ToastNotificationObj } from \"../types\"\n\ntype ToastNotificationObjOptionalId = Omit<ToastNotificationObj, \"id\"> & {\n id?: string\n}\n\nexport type ToastNotificationContextValue = {\n notifications: ToastNotificationObj[]\n addToastNotification: (notification: ToastNotificationObjOptionalId) => void\n updateToastNotification: (notification: ToastNotificationObj) => void\n removeToastNotification: (notificationId: string) => void\n clearToastNotifications: () => void\n}\n\nconst ToastNotificationContext =\n React.createContext<ToastNotificationContextValue | null>(null)\n\nexport const useToastNotificationContext =\n (): ToastNotificationContextValue => {\n const context = useContext(ToastNotificationContext)\n\n if (!context) {\n throw new Error(\n \"useToastNotificationContext must be used within the ToastNotificationContext.Provider\"\n )\n }\n\n return context\n }\n\ntype ToastNotificationProviderProps = {\n children: React.ReactNode\n}\n\nexport const ToastNotificationProvider = ({\n children,\n}: ToastNotificationProviderProps): JSX.Element | null => {\n const [notifications, setNotifications] = useState<ToastNotificationObj[]>([])\n\n const addToastNotification: ToastNotificationContextValue[\"addToastNotification\"] =\n notification => {\n const uuid = uuidv4()\n const notificationWithId = { id: uuid, ...notification }\n\n const notificationExists = notifications.find(\n ({ id }) => id === notification.id\n )\n\n if (!notificationExists) {\n setNotifications(existing => [...existing, notificationWithId])\n }\n }\n\n const updateToastNotification = (\n notification: ToastNotificationObj\n ): void => {\n const notificationIndex = notifications.findIndex(\n ({ id }) => id === notification.id\n )\n\n const copy = notifications.slice()\n copy.splice(notificationIndex, 1, notification) // Mutation to insert notification over itself\n setNotifications(copy)\n }\n\n const removeToastNotification = (notificationID: string): void => {\n const notificationIndex = notifications.findIndex(\n ({ id }) => id === notificationID\n )\n const copy = notifications.slice()\n copy.splice(notificationIndex, 1) // Mutation\n setNotifications(copy)\n }\n\n const clearToastNotifications = (): void => {\n setNotifications([])\n }\n\n const value = {\n notifications,\n addToastNotification,\n updateToastNotification,\n removeToastNotification,\n clearToastNotifications,\n } satisfies ToastNotificationContextValue\n\n return (\n <ToastNotificationContext.Provider value={value}>\n {children}\n </ToastNotificationContext.Provider>\n )\n}\n\nToastNotificationProvider.displayName = \"ToastNotificationProvider\"\n"],"names":["ToastNotificationContext","React","createContext","useToastNotificationContext","context","useContext","Error","ToastNotificationProvider","_a","children","_b","useState","notifications","setNotifications","addToastNotification","notification","uuid","uuidv4","notificationWithId","id","notificationExists","find","existing","__spreadArray","updateToastNotification","notificationIndex","findIndex","copy","slice","splice","removeToastNotification","notificationID","clearToastNotifications","value","createElement","Provider","displayName"],"mappings":";;;AAgBA,IAAMA,wBAAwB,gBAC5BC,KAAK,CAACC,aAAa,CAAuC,IAAI,CAAC;AAEpD,IAAAC,2BAA2B,GACtC,SAAAA,CAAA,EAAA;EACE,IAAMC,OAAO,GAAGC,UAAU,CAACL,wBAAwB,CAAC;EAEpD,IAAI,CAACI,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CACb,uFAAuF,CACxF;EACF;EAED,OAAOF,OAAO;AAChB,CAAC;AAAA,MAMUG,yBAAyB;EAAA,MAAzBA,yBAAyB,GAAG,SAAAA,CAACC,EAET,EAAA;IAD/B,IAAAC,QAAQ,GAAAD,EAAA,CAAAC,QAAA;IAEF,IAAAC,EAAA,GAAoCC,QAAQ,CAAyB,EAAE,CAAC;MAAvEC,aAAa,GAAAF,EAAA,CAAA,CAAA,CAAA;MAAEG,gBAAgB,GAAAH,EAAA,CAAA,CAAA,CAAwC;IAE9E,IAAMI,oBAAoB,GACxB,SAAAA,CAAAC,YAAY,EAAA;MACV,IAAMC,IAAI,GAAGC,EAAM,EAAE;MACrB,IAAMC,kBAAkB;QAAKC,EAAE,EAAEH;MAAI,CAAK,EAAAD,YAAY,CAAE;MAExD,IAAMK,kBAAkB,GAAGR,aAAa,CAACS,IAAI,CAC3C,UAACb,EAAM,EAAA;QAAJ,IAAAW,EAAE,GAAAX,EAAA,CAAAW,EAAA;QAAO,OAAAA,EAAE,KAAKJ,YAAY,CAACI,EAAE;MAAtB,CAAsB,CACnC;MAED,IAAI,CAACC,kBAAkB,EAAE;QACvBP,gBAAgB,CAAC,UAAAS,QAAQ,EAAI;UAAA,OAAAC,aAAA,CAAAA,aAAA,CAAA,EAAA,EAAID,QAAQ,EAAA,IA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C,QAAQ,EAAA;MAACF,KAAK,EAAEA;KAAK,EAC5CxB,QAAQ,CACyB;EAExC,CAAC;EAEDF,yBAAyB,CAAC6B,WAAW,GAAG,2BAA2B;EAAA,OA3DtD7B,yBAAyB;AAAA;"}
@@ -0,0 +1,7 @@
1
+ import { useToastNotificationContext } from '../context/ToastNotificationContext.mjs';
2
+ var useToastNotification = function () {
3
+ var context = useToastNotificationContext();
4
+ return context;
5
+ };
6
+ export { useToastNotification };
7
+ //# sourceMappingURL=useToastNotification.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToastNotification.mjs","sources":["../../../../../src/Notification/ToastNotification/hooks/useToastNotification.ts"],"sourcesContent":["import {\n ToastNotificationContextValue,\n useToastNotificationContext,\n} from \"../context/ToastNotificationContext\"\n\nexport const useToastNotification = (): ToastNotificationContextValue => {\n const context = useToastNotificationContext()\n return context\n}\n"],"names":["useToastNotification","context","useToastNotificationContext"],"mappings":";AAKa,IAAAA,oBAAoB,GAAG,SAAAA,CAAA,EAAA;EAClC,IAAMC,OAAO,GAAGC,2BAA2B,EAAE;EAC7C,OAAOD,OAAO;AAChB,CAAA;"}
@@ -5,6 +5,9 @@ import { FieldMessage } from '../../FieldMessage/FieldMessage.mjs';
5
5
  import { Label } from '../../Label/Label.mjs';
6
6
  import { InlineNotification } from '../../Notification/InlineNotification/InlineNotification.mjs';
7
7
  import '../../Notification/GlobalNotification/GlobalNotification.mjs';
8
+ import '../../Notification/ToastNotification/ToastNotification/ToastNotification.mjs';
9
+ import '../../Notification/ToastNotification/ToastNotificationsList/ToastNotificationsList.mjs';
10
+ import '../../Notification/ToastNotification/context/ToastNotificationContext.mjs';
8
11
  import * as ProseMirrorState from 'prosemirror-state';
9
12
  import 'prosemirror-view';
10
13
  import { useRichTextEditor } from '../utils/core/hooks/useRichTextEditor.mjs';
@@ -37,6 +40,7 @@ const RichTextEditor = /*#__PURE__*/function () {
37
40
  defaultValue = _a.defaultValue,
38
41
  labelText = _a.labelText,
39
42
  labelledBy = _a["aria-labelledby"],
43
+ describedBy = _a["aria-describedby"],
40
44
  classNameOverride = _a.classNameOverride,
41
45
  controls = _a.controls,
42
46
  _b = _a.rows,
@@ -47,7 +51,7 @@ const RichTextEditor = /*#__PURE__*/function () {
47
51
  description = _a.description,
48
52
  _c = _a.status,
49
53
  status = _c === void 0 ? "default" : _c,
50
- restProps = __rest(_a, ["onChange", "defaultValue", "labelText", "aria-labelledby", "classNameOverride", "controls", "rows", "dataError", "onDataError", "validationMessage", "description", "status"]);
54
+ restProps = __rest(_a, ["onChange", "defaultValue", "labelText", "aria-labelledby", "aria-describedby", "classNameOverride", "controls", "rows", "dataError", "onDataError", "validationMessage", "description", "status"]);
51
55
  var reactId = useId();
52
56
  var schema = useState(createSchemaFromControls(controls))[0];
53
57
  var labelId = useState(labelledBy || reactId)[0];
@@ -94,7 +98,7 @@ const RichTextEditor = /*#__PURE__*/function () {
94
98
  }, [editorState]);
95
99
  var validationMessageAria = validationMessage ? "".concat(editorId, "-rte-validation-message") : "";
96
100
  var descriptionAria = description ? "".concat(editorId, "-rte-description") : "";
97
- var ariaDescribedBy = "".concat(validationMessageAria, " ").concat(descriptionAria);
101
+ var ariaDescribedBy = classnames(validationMessageAria, descriptionAria, describedBy);
98
102
  return /*#__PURE__*/React.createElement(React.Fragment, null, !labelledBy && labelText && /*#__PURE__*/React.createElement(Label, {
99
103
  id: labelId,
100
104
  labelText: labelText
@@ -1 +1 @@
1
- {"version":3,"file":"RichTextEditor.mjs","sources":["../../../../src/RichTextEditor/RichTextEditor/RichTextEditor.tsx"],"sourcesContent":["import React, {\n useState,\n useEffect,\n HTMLAttributes,\n ReactNode,\n useId,\n} from \"react\"\nimport classnames from \"classnames\"\nimport { FieldMessage } from \"~components/FieldMessage\"\nimport { Label } from \"~components/Label\"\nimport { InlineNotification } from \"~components/Notification\"\nimport { OverrideClassName } from \"~types/OverrideClassName\"\nimport { ToolbarItems, EditorContentArray, EditorRows } from \"../types\"\nimport { useRichTextEditor } from \"../utils/core\"\nimport { createLinkManager } from \"../utils/plugins\"\nimport {\n ProseMirrorCommands,\n ProseMirrorHistory,\n ProseMirrorKeymap,\n ProseMirrorModel,\n ProseMirrorState,\n} from \"../utils/prosemirror\"\nimport { createSchemaFromControls } from \"./schema\"\nimport { ToggleIconButton } from \"./subcomponents/ToggleIconButton\"\nimport { Toolbar } from \"./subcomponents/Toolbar\"\nimport { ToolbarSection } from \"./subcomponents/ToolbarSection\"\nimport { buildControlMap } from \"./utils/controlmap\"\nimport { buildInputRules } from \"./utils/inputrules\"\nimport { buildKeymap } from \"./utils/keymap\"\nimport styles from \"./RichTextEditor.module.scss\"\n\ntype BaseRichTextEditorProps = {\n onChange: (content: ProseMirrorState.EditorState) => void\n defaultValue: EditorContentArray\n controls?: ToolbarItems[]\n /**\n * Sets a default min-height for the editable area in units of body paragraph line height, similar to the 'rows' attribute on <textarea>.\n * The editable area will autogrow, so this only affects the component when the content doesn't exceed this height.\n */\n rows?: EditorRows\n dataError?: React.ReactElement\n onDataError?: () => void\n status?: \"default\" | \"error\" | \"caution\"\n /**\n * A descriptive message for `error` or `caution` states\n */\n validationMessage?: React.ReactNode\n /**\n * A description that provides context\n */\n description?: React.ReactNode\n} & OverrideClassName<\n Omit<HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\">\n>\n\ntype WithLabelText = {\n labelText: ReactNode\n \"aria-labelledby\"?: never\n}\n\ntype WithLabelledBy = {\n labelText?: never\n \"aria-labelledby\": string\n}\n\nexport type RichTextEditorProps = BaseRichTextEditorProps &\n (WithLabelText | WithLabelledBy)\n/**\n * {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3081896752/Rich+Text+Editor Guidance} |\n * {@link https://cultureamp.design/?path=/docs/components-richtexteditor--docs Storybook}\n */\nexport const RichTextEditor = ({\n onChange,\n defaultValue,\n labelText,\n \"aria-labelledby\": labelledBy,\n classNameOverride,\n controls,\n rows = 3,\n dataError,\n onDataError,\n validationMessage,\n description,\n status = \"default\",\n ...restProps\n}: RichTextEditorProps): JSX.Element => {\n const reactId = useId()\n const [schema] = useState<ProseMirrorModel.Schema>(\n createSchemaFromControls(controls)\n )\n const [labelId] = useState<string>(labelledBy || reactId)\n const [editorId] = useState<string>(reactId)\n\n const useRichTextEditorResult = (():\n | ReturnType<typeof useRichTextEditor>\n | Error => {\n try {\n return useRichTextEditor(\n ProseMirrorState.EditorState.create({\n doc: ProseMirrorModel.Node.fromJSON(schema, {\n type: \"doc\",\n // we're converting empty arrays to the ProseMirror default \"empty\" state because when\n // given an empty array ProseMirror returns undefined, breaking the type\n content:\n defaultValue?.length > 0 ? defaultValue : [{ type: \"paragraph\" }],\n }),\n schema,\n plugins: getPlugins(controls, schema),\n }),\n { \"aria-labelledby\": labelId, role: \"textbox\" }\n )\n } catch {\n return new Error(\"Bad data error\")\n }\n })()\n\n if (useRichTextEditorResult instanceof Error) {\n onDataError && onDataError()\n return (\n <InlineNotification\n headingProps={{\n children: \"Error\",\n variant: \"heading-6\",\n }}\n type=\"negative\"\n persistent\n >\n {dataError || \"Something went wrong\"}\n </InlineNotification>\n )\n }\n\n const [editorRef, editorState, dispatchTransaction] = useRichTextEditorResult\n\n const controlMap = buildControlMap(schema, editorState, controls)\n\n useEffect(() => {\n onChange(editorState)\n // Including `onContentChange` in the dependencies here will cause a 'Maximum update depth exceeded' issue\n }, [editorState])\n\n const validationMessageAria = validationMessage\n ? `${editorId}-rte-validation-message`\n : \"\"\n const descriptionAria = description ? `${editorId}-rte-description` : \"\"\n\n const ariaDescribedBy = `${validationMessageAria} ${descriptionAria}`\n\n return (\n <>\n {!labelledBy && labelText && <Label id={labelId} labelText={labelText} />}\n {/* TODO: add a bit of margin here once we have a classNameOverride on Label */}\n <div className={classnames(styles.editorWrapper, styles[status])}>\n {controls && (\n <Toolbar\n aria-controls={editorId}\n aria-label=\"Text formatting\"\n classNameOverride={styles.toolbar}\n >\n {controlMap.map((section, index) => (\n <ToolbarSection key={index}>\n {section.map((controlConfig, controlKeyIndex) => (\n <ToggleIconButton\n key={controlKeyIndex}\n icon={controlConfig.icon}\n disabled={controlConfig.disabled}\n label={controlConfig.label}\n isActive={controlConfig.isActive}\n onClick={(): void =>\n dispatchTransaction(controlConfig.action)\n }\n />\n ))}\n </ToolbarSection>\n ))}\n </Toolbar>\n )}\n <div\n id={editorId}\n ref={editorRef}\n className={classnames(\n styles.editor,\n styles[`rows${rows}`],\n classNameOverride,\n controls != null && controls.length > 0 && styles.hasToolbar\n )}\n aria-describedby={ariaDescribedBy}\n {...restProps}\n />\n </div>\n\n {validationMessage && (\n <FieldMessage\n id={validationMessageAria}\n message={validationMessage}\n status={status}\n />\n )}\n\n {description && (\n <FieldMessage id={descriptionAria} message={description} />\n )}\n </>\n )\n}\n\nRichTextEditor.displayName = \"RichTextEditor\"\n\nfunction getPlugins(\n controls: ToolbarItems[] | undefined,\n schema: ProseMirrorModel.Schema\n): Array<\n | ProseMirrorState.Plugin<unknown>\n | ProseMirrorState.Plugin<{\n transform: ProseMirrorState.Transaction\n from: number\n to: number\n text: string\n } | null>\n> {\n const allControlNames: string[] = controls\n ? controls.reduce((acc: string[], c: ToolbarItems) => [...acc, c.name], [])\n : []\n const plugins = [\n ProseMirrorHistory.history(),\n ProseMirrorKeymap.keymap(buildKeymap(schema)),\n ProseMirrorKeymap.keymap(ProseMirrorCommands.baseKeymap),\n buildInputRules(schema),\n ]\n\n if (allControlNames.includes(\"link\")) {\n plugins.push(\n createLinkManager({\n markType: schema.marks.link,\n })\n )\n }\n\n return plugins\n}\n"],"names":["RichTextEditor","_a","onChange","defaultValue","labelText","labelledBy","classNameOverride","controls","_b","rows","dataError","onDataError","validationMessage","description","_c","status","restProps","__rest","reactId","useId","schema","useState","createSchemaFromControls","labelId","editorId","useRichTextEditorResult","useRichTextEditor","ProseMirrorState","EditorState","create","doc","ProseMirrorModel","Node","fromJSON","type","content","length","plugins","getPlugins","role","Error","React","createElement","InlineNotification","headingProps","children","variant","persistent","editorRef","editorState","dispatchTransaction","controlMap","buildControlMap","useEffect","validationMessageAria","concat","descriptionAria","ariaDescribedBy","Fragment","Label","id","className","classnames","styles","editorWrapper","Toolbar","toolbar","map","section","index","ToolbarSection","key","controlConfig","controlKeyIndex","ToggleIconButton","icon","disabled","label","isActive","onClick","action","__assign","ref","editor","hasToolbar","FieldMessage","message","displayName","allControlNames","reduce","acc","c","name","ProseMirrorHistory","history","ProseMirrorKeymap","keymap","buildKeymap","ProseMirrorCommands","baseKeymap","buildInputRules","includes","push","createLinkManager","markType","marks","link"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA;;;AAGG;AAHH,MAIaA,cAAc;EAAA,MAAdA,cAAc,GAAG,SAAAA,CAACC,EAcT,EAAA;IAbpB,IAAAC,QAAQ,cAAA;MACRC,YAAY,kBAAA;MACZC,SAAS,eAAA;MACUC,UAAU,wBAAA;MAC7BC,iBAAiB,uBAAA;MACjBC,QAAQ,cAAA;MACRC,EAAA,GAAAP,EAAA,CAAAQ,IAAQ;MAARA,IAAI,GAAGD,EAAA,KAAA,KAAA,CAAA,GAAA,CAAC,KAAA;MACRE,SAAS,eAAA;MACTC,WAAW,iBAAA;MACXC,iBAAiB,GAAAX,EAAA,CAAAW,iBAAA;MACjBC,WAAW,GAAAZ,EAAA,CAAAY,WAAA;MACXC,EAAkB,GAAAb,EAAA,CAAAc,MAAA;MAAlBA,MAAM,GAAGD,EAAA,KAAA,KAAA,CAAA,GAAA,SAAS,KAAA;MACfE,SAAS,GAbiBC,MAAA,CAAAhB,EAAA,EAAA,CAAA,UAAA,EAAA,cAAA,EAAA,WAAA,EAAA,iBAAA,EAAA,mBAAA,EAAA,UAAA,EAAA,MAAA,EAAA,WAAA,EAAA,aAAA,EAAA,mBAAA,EAAA,aAAA,EAAA,QAAA,CAc9B,CADa;IAEZ,IAAMiB,OAAO,GAAGC,KAAK,EAAE;IAChB,IAAAC,MAAM,GAAIC,QAAQ,CACvBC,wBAAwB,CAACf,QAAQ,CAAC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AAUA,CACjB/B,QAAoC,EACpCa,MAA+B,EAAA;EAU/B,IAAMoE,eAAe,GAAajF,QAAQ,GACtCA,QAAQ,CAACkF,MAAM,CAAC,UAACC,GAAa,EAAEC,CAAe,EAAA;IAAK,uCAAID,GAAG,EAAA,IAAA,CAAA,EAAA,CAAEC,CAAC,CAACC,IAAI;EAAC,CAAA,EAAE,EAAE,CAAC,GACzE,EAAE;EACN,IAAMvD,OAAO,GAAG,CACdwD,kBAAkB,CAACC,OAAO,CAAE,CAAA,EAC5BC,iBAAiB,CAACC,MAAM,CAACC,WAAW,CAAC7E,MAAM,CAAC,CAAC,EAC7C2E,iBAAiB,CAACC,MAAM,CAACE,mBAAmB,CAACC,UAAU,CAAC,EACxDC,eAAe,CAAChF,MAAM,CAAC,CACxB;EAED,IAAIoE,eAAe,CAACa,QAAQ,CAAC,MAAM,CAAC,EAAE;IACpChE,OAAO,CAACiE,IAAI,CACVC,iBAAiB,CAAC;MAChBC,QAAQ,EAAEpF,MAAM,CAACqF,KAAK,CAACC;IACxB,CAAA,CAAC,CACH;EACF;EAED,OAAOrE,OAAO;AAChB;"}
1
+ {"version":3,"file":"RichTextEditor.mjs","sources":["../../../../src/RichTextEditor/RichTextEditor/RichTextEditor.tsx"],"sourcesContent":["import React, {\n useState,\n useEffect,\n HTMLAttributes,\n ReactNode,\n useId,\n} from \"react\"\nimport classnames from \"classnames\"\nimport { FieldMessage } from \"~components/FieldMessage\"\nimport { Label } from \"~components/Label\"\nimport { InlineNotification } from \"~components/Notification\"\nimport { OverrideClassName } from \"~types/OverrideClassName\"\nimport { ToolbarItems, EditorContentArray, EditorRows } from \"../types\"\nimport { useRichTextEditor } from \"../utils/core\"\nimport { createLinkManager } from \"../utils/plugins\"\nimport {\n ProseMirrorCommands,\n ProseMirrorHistory,\n ProseMirrorKeymap,\n ProseMirrorModel,\n ProseMirrorState,\n} from \"../utils/prosemirror\"\nimport { createSchemaFromControls } from \"./schema\"\nimport { ToggleIconButton } from \"./subcomponents/ToggleIconButton\"\nimport { Toolbar } from \"./subcomponents/Toolbar\"\nimport { ToolbarSection } from \"./subcomponents/ToolbarSection\"\nimport { buildControlMap } from \"./utils/controlmap\"\nimport { buildInputRules } from \"./utils/inputrules\"\nimport { buildKeymap } from \"./utils/keymap\"\nimport styles from \"./RichTextEditor.module.scss\"\n\ntype BaseRichTextEditorProps = {\n onChange: (content: ProseMirrorState.EditorState) => void\n defaultValue: EditorContentArray\n controls?: ToolbarItems[]\n /**\n * Sets a default min-height for the editable area in units of body paragraph line height, similar to the 'rows' attribute on <textarea>.\n * The editable area will autogrow, so this only affects the component when the content doesn't exceed this height.\n */\n rows?: EditorRows\n dataError?: React.ReactElement\n onDataError?: () => void\n status?: \"default\" | \"error\" | \"caution\"\n /**\n * A descriptive message for `error` or `caution` states\n */\n validationMessage?: React.ReactNode\n /**\n * A description that provides context\n */\n description?: React.ReactNode\n} & OverrideClassName<\n Omit<HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\">\n>\n\ntype WithLabelText = {\n labelText: ReactNode\n \"aria-labelledby\"?: never\n}\n\ntype WithLabelledBy = {\n labelText?: never\n \"aria-labelledby\": string\n}\n\nexport type RichTextEditorProps = BaseRichTextEditorProps &\n (WithLabelText | WithLabelledBy)\n/**\n * {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3081896752/Rich+Text+Editor Guidance} |\n * {@link https://cultureamp.design/?path=/docs/components-richtexteditor--docs Storybook}\n */\nexport const RichTextEditor = ({\n onChange,\n defaultValue,\n labelText,\n \"aria-labelledby\": labelledBy,\n \"aria-describedby\": describedBy,\n classNameOverride,\n controls,\n rows = 3,\n dataError,\n onDataError,\n validationMessage,\n description,\n status = \"default\",\n ...restProps\n}: RichTextEditorProps): JSX.Element => {\n const reactId = useId()\n const [schema] = useState<ProseMirrorModel.Schema>(\n createSchemaFromControls(controls)\n )\n const [labelId] = useState<string>(labelledBy || reactId)\n const [editorId] = useState<string>(reactId)\n\n const useRichTextEditorResult = (():\n | ReturnType<typeof useRichTextEditor>\n | Error => {\n try {\n return useRichTextEditor(\n ProseMirrorState.EditorState.create({\n doc: ProseMirrorModel.Node.fromJSON(schema, {\n type: \"doc\",\n // we're converting empty arrays to the ProseMirror default \"empty\" state because when\n // given an empty array ProseMirror returns undefined, breaking the type\n content:\n defaultValue?.length > 0 ? defaultValue : [{ type: \"paragraph\" }],\n }),\n schema,\n plugins: getPlugins(controls, schema),\n }),\n { \"aria-labelledby\": labelId, role: \"textbox\" }\n )\n } catch {\n return new Error(\"Bad data error\")\n }\n })()\n\n if (useRichTextEditorResult instanceof Error) {\n onDataError && onDataError()\n return (\n <InlineNotification\n headingProps={{\n children: \"Error\",\n variant: \"heading-6\",\n }}\n type=\"negative\"\n persistent\n >\n {dataError || \"Something went wrong\"}\n </InlineNotification>\n )\n }\n\n const [editorRef, editorState, dispatchTransaction] = useRichTextEditorResult\n\n const controlMap = buildControlMap(schema, editorState, controls)\n\n useEffect(() => {\n onChange(editorState)\n // Including `onContentChange` in the dependencies here will cause a 'Maximum update depth exceeded' issue\n }, [editorState])\n\n const validationMessageAria = validationMessage\n ? `${editorId}-rte-validation-message`\n : \"\"\n const descriptionAria = description ? `${editorId}-rte-description` : \"\"\n\n const ariaDescribedBy = classnames(\n validationMessageAria,\n descriptionAria,\n describedBy\n )\n\n return (\n <>\n {!labelledBy && labelText && <Label id={labelId} labelText={labelText} />}\n {/* TODO: add a bit of margin here once we have a classNameOverride on Label */}\n <div className={classnames(styles.editorWrapper, styles[status])}>\n {controls && (\n <Toolbar\n aria-controls={editorId}\n aria-label=\"Text formatting\"\n classNameOverride={styles.toolbar}\n >\n {controlMap.map((section, index) => (\n <ToolbarSection key={index}>\n {section.map((controlConfig, controlKeyIndex) => (\n <ToggleIconButton\n key={controlKeyIndex}\n icon={controlConfig.icon}\n disabled={controlConfig.disabled}\n label={controlConfig.label}\n isActive={controlConfig.isActive}\n onClick={(): void =>\n dispatchTransaction(controlConfig.action)\n }\n />\n ))}\n </ToolbarSection>\n ))}\n </Toolbar>\n )}\n <div\n id={editorId}\n ref={editorRef}\n className={classnames(\n styles.editor,\n styles[`rows${rows}`],\n classNameOverride,\n controls != null && controls.length > 0 && styles.hasToolbar\n )}\n aria-describedby={ariaDescribedBy}\n {...restProps}\n />\n </div>\n\n {validationMessage && (\n <FieldMessage\n id={validationMessageAria}\n message={validationMessage}\n status={status}\n />\n )}\n\n {description && (\n <FieldMessage id={descriptionAria} message={description} />\n )}\n </>\n )\n}\n\nRichTextEditor.displayName = \"RichTextEditor\"\n\nfunction getPlugins(\n controls: ToolbarItems[] | undefined,\n schema: ProseMirrorModel.Schema\n): Array<\n | ProseMirrorState.Plugin<unknown>\n | ProseMirrorState.Plugin<{\n transform: ProseMirrorState.Transaction\n from: number\n to: number\n text: string\n } | null>\n> {\n const allControlNames: string[] = controls\n ? controls.reduce((acc: string[], c: ToolbarItems) => [...acc, c.name], [])\n : []\n const plugins = [\n ProseMirrorHistory.history(),\n ProseMirrorKeymap.keymap(buildKeymap(schema)),\n ProseMirrorKeymap.keymap(ProseMirrorCommands.baseKeymap),\n buildInputRules(schema),\n ]\n\n if (allControlNames.includes(\"link\")) {\n plugins.push(\n createLinkManager({\n markType: schema.marks.link,\n })\n )\n }\n\n return plugins\n}\n"],"names":["RichTextEditor","_a","onChange","defaultValue","labelText","labelledBy","describedBy","classNameOverride","controls","_b","rows","dataError","onDataError","validationMessage","description","_c","status","restProps","__rest","reactId","useId","schema","useState","createSchemaFromControls","labelId","editorId","useRichTextEditorResult","useRichTextEditor","ProseMirrorState","EditorState","create","doc","ProseMirrorModel","Node","fromJSON","type","content","length","plugins","getPlugins","role","Error","React","createElement","InlineNotification","headingProps","children","variant","persistent","editorRef","editorState","dispatchTransaction","controlMap","buildControlMap","useEffect","validationMessageAria","concat","descriptionAria","ariaDescribedBy","classnames","Fragment","Label","id","className","styles","editorWrapper","Toolbar","toolbar","map","section","index","ToolbarSection","key","controlConfig","controlKeyIndex","ToggleIconButton","icon","disabled","label","isActive","onClick","action","__assign","ref","editor","hasToolbar","FieldMessage","message","displayName","allControlNames","reduce","acc","c","name","ProseMirrorHistory","history","ProseMirrorKeymap","keymap","buildKeymap","ProseMirrorCommands","baseKeymap","buildInputRules","includes","push","createLinkManager","markType","marks","link"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA;;;AAGG;AAHH,MAIaA,cAAc;EAAA,MAAdA,cAAc,GAAG,SAAAA,CAACC,EAeT,EAAA;IAdpB,IAAAC,QAAQ,cAAA;MACRC,YAAY,kBAAA;MACZC,SAAS,GAAAH,EAAA,CAAAG,SAAA;MACUC,UAAU,GAAAJ,EAAA,CAAA,iBAAA,CAAA;MACTK,WAAW,GAAAL,EAAA,CAAA,kBAAA,CAAA;MAC/BM,iBAAiB,GAAAN,EAAA,CAAAM,iBAAA;MACjBC,QAAQ,GAAAP,EAAA,CAAAO,QAAA;MACRC,EAAQ,GAAAR,EAAA,CAAAS,IAAA;MAARA,IAAI,GAAAD,EAAA,KAAA,KAAA,CAAA,GAAG,CAAC,GAAAA,EAAA;MACRE,SAAS,GAAAV,EAAA,CAAAU,SAAA;MACTC,WAAW,GAAAX,EAAA,CAAAW,WAAA;MACXC,iBAAiB,GAAAZ,EAAA,CAAAY,iBAAA;MACjBC,WAAW,iBAAA;MACXC,EAAA,GAAAd,EAAA,CAAAe,MAAkB;MAAlBA,MAAM,GAAGD,EAAA,KAAA,KAAA,CAAA,GAAA,SAAS,KAAA;MACfE,SAAS,GAdiBC,MAAA,CAAAjB,EAAA,EAAA,CAAA,UAAA,EAAA,cAAA,EAAA,WAAA,EAAA,iBAAA,EAAA,kBAAA,EAAA,mBAAA,EAAA,UAAA,EAAA,MAAA,EAAA,WAAA,EAAA,aAAA,EAAA,mBAAA,EAAA,aAAA,EAAA,QAAA,CAe9B,CADa;IAEZ,IAAMkB,OAAO,GAAGC,KAAK,EAAE;IAChB,IAAAC,MAAM,GAAIC,QAAQ,CACvBC,wBAAwB,CAAC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,QAAoC,EACpCa,MAA+B,EAAA;EAU/B,IAAMoE,eAAe,GAAajF,QAAQ,GACtCA,QAAQ,CAACkF,MAAM,CAAC,UAACC,GAAa,EAAEC,CAAe,EAAA;IAAK,uCAAID,GAAG,EAAA,IAAA,CAAA,EAAA,CAAEC,CAAC,CAACC,IAAI;EAAC,CAAA,EAAE,EAAE,CAAC,GACzE,EAAE;EACN,IAAMvD,OAAO,GAAG,CACdwD,kBAAkB,CAACC,OAAO,CAAE,CAAA,EAC5BC,iBAAiB,CAACC,MAAM,CAACC,WAAW,CAAC7E,MAAM,CAAC,CAAC,EAC7C2E,iBAAiB,CAACC,MAAM,CAACE,mBAAmB,CAACC,UAAU,CAAC,EACxDC,eAAe,CAAChF,MAAM,CAAC,CACxB;EAED,IAAIoE,eAAe,CAACa,QAAQ,CAAC,MAAM,CAAC,EAAE;IACpChE,OAAO,CAACiE,IAAI,CACVC,iBAAiB,CAAC;MAChBC,QAAQ,EAAEpF,MAAM,CAACqF,KAAK,CAACC;IACxB,CAAA,CAAC,CACH;EACF;EAED,OAAOrE,OAAO;AAChB;"}
@@ -1,5 +1,5 @@
1
1
  import { __rest, __assign } from 'tslib';
2
- import React, { useId } from 'react';
2
+ import React, { useId, useState, useEffect } from 'react';
3
3
  import { useButton } from '@react-aria/button';
4
4
  import { useSelect, HiddenSelect } from '@react-aria/select';
5
5
  import { useSelectState } from '@react-stately/select';
@@ -43,11 +43,13 @@ const Select = /*#__PURE__*/function () {
43
43
  description = _a.description,
44
44
  placeholder = _a.placeholder,
45
45
  isDisabled = _a.isDisabled,
46
- restProps = __rest(_a, ["label", "items", "id", "trigger", "children", "status", "validationMessage", "isReversed", "isFullWidth", "disabledValues", "classNameOverride", "selectedKey", "description", "placeholder", "isDisabled"]);
46
+ portalContainerId = _a.portalContainerId,
47
+ restProps = __rest(_a, ["label", "items", "id", "trigger", "children", "status", "validationMessage", "isReversed", "isFullWidth", "disabledValues", "classNameOverride", "selectedKey", "description", "placeholder", "isDisabled", "portalContainerId"]);
47
48
  var refs = useFloating().refs;
48
49
  var triggerRef = refs.reference;
49
50
  var id = propsId !== null && propsId !== void 0 ? propsId : useId();
50
51
  var descriptionId = "".concat(id, "--description");
52
+ var popoverId = "".concat(id, "--popover");
51
53
  var disabledKeys = getDisabledKeysFromItems(items);
52
54
  var ariaSelectProps = __assign({
53
55
  label: label,
@@ -62,11 +64,20 @@ const Select = /*#__PURE__*/function () {
62
64
  var state = useSelectState(ariaSelectProps);
63
65
  var _c = useSelect(ariaSelectProps, state, triggerRef),
64
66
  labelProps = _c.labelProps,
65
- triggerProps = _c.triggerProps,
67
+ reactAriaTriggerProps = _c.triggerProps,
66
68
  valueProps = _c.valueProps,
67
69
  menuProps = _c.menuProps,
68
70
  errorMessageProps = _c.errorMessageProps,
69
71
  descriptionProps = _c.descriptionProps;
72
+ // Hack incoming:
73
+ // react-aria/useSelect wants to prefix the combobox's accessible name with the value of the select.
74
+ // We use role=combobox, meaning screen readers will read the value.
75
+ // So we're modifying the `aria-labelledby` property to remove the value element id.
76
+ // Issue: https://github.com/adobe/react-spectrum/issues/4091
77
+ var reactAriaLabelledBy = reactAriaTriggerProps["aria-labelledby"];
78
+ var triggerProps = __assign(__assign({}, reactAriaTriggerProps), {
79
+ "aria-labelledby": reactAriaLabelledBy === null || reactAriaLabelledBy === void 0 ? void 0 : reactAriaLabelledBy.substring(reactAriaLabelledBy.indexOf(" ") + 1)
80
+ });
70
81
  var buttonProps = useButton(triggerProps, triggerRef).buttonProps;
71
82
  var selectToggleProps = __assign(__assign({}, buttonProps), {
72
83
  label: label,
@@ -80,6 +91,15 @@ const Select = /*#__PURE__*/function () {
80
91
  isReversed: isReversed,
81
92
  ref: refs.setReference
82
93
  });
94
+ var _d = useState(),
95
+ portalContainer = _d[0],
96
+ setPortalContainer = _d[1];
97
+ useEffect(function () {
98
+ if (portalContainerId) {
99
+ var portalElement = document.getElementById(portalContainerId);
100
+ portalElement && setPortalContainer(portalElement);
101
+ }
102
+ }, []);
83
103
  return /*#__PURE__*/React.createElement("div", {
84
104
  className: classnames(!isFullWidth && styles.notFullWidth, classNameOverride)
85
105
  }, /*#__PURE__*/React.createElement(HiddenSelect, {
@@ -90,6 +110,8 @@ const Select = /*#__PURE__*/function () {
90
110
  }), /*#__PURE__*/React.createElement("div", {
91
111
  className: styles.container
92
112
  }, trigger === undefined ? /*#__PURE__*/React.createElement(SelectToggle, __assign({}, selectToggleProps)) : trigger(selectToggleProps, selectToggleProps.ref), state.isOpen && /*#__PURE__*/React.createElement(Popover, {
113
+ id: popoverId,
114
+ portalContainer: portalContainer,
93
115
  refs: refs,
94
116
  focusOnProps: {
95
117
  onEscapeKey: state.close,
@@ -1 +1 @@
1
- {"version":3,"file":"Select.mjs","sources":["../../../../src/__future__/Select/Select.tsx"],"sourcesContent":["import React, { useId } from \"react\"\nimport { UseFloatingReturn } from \"@floating-ui/react-dom\"\nimport { useButton } from \"@react-aria/button\"\nimport { HiddenSelect, useSelect } from \"@react-aria/select\"\nimport {\n useSelectState,\n SelectProps as AriaSelectProps,\n} from \"@react-stately/select\"\nimport { Key } from \"@react-types/shared\"\nimport classnames from \"classnames\"\nimport { FieldMessage } from \"~components/FieldMessage\"\nimport {\n Popover,\n useFloating,\n} from \"~components/MultiSelect/subcomponents/Popover\"\nimport { OverrideClassName } from \"~types/OverrideClassName\"\nimport { SelectProvider } from \"./context\"\nimport {\n ListBox,\n ListBoxSection,\n ListItem,\n Option,\n SectionDivider,\n SelectPopoverContents,\n SelectPopoverContentsProps,\n SelectToggle,\n SelectToggleProps,\n} from \"./subcomponents\"\nimport { SelectItem, SelectOption } from \"./types\"\nimport { getDisabledKeysFromItems } from \"./utils/getDisabledKeysFromItems\"\nimport { transformSelectItemToCollectionElement } from \"./utils/transformSelectItemToCollectionElement\"\nimport styles from \"./Select.module.scss\"\n\ntype OmittedAriaSelectProps = \"children\" | \"items\"\n\nexport type SelectProps<Option extends SelectOption = SelectOption> = {\n /**\n * Item objects in the collection.\n */\n items: Array<SelectItem<Option>>\n id?: string\n trigger?: (\n selectToggleProps: SelectToggleProps & {\n ref: UseFloatingReturn<HTMLButtonElement>[\"refs\"][\"setReference\"]\n },\n // @deprecated: This arg is unnecessary now, but provided for legacy usages\n ref: UseFloatingReturn<HTMLButtonElement>[\"refs\"][\"setReference\"]\n ) => JSX.Element\n children?: SelectPopoverContentsProps<Option>[\"children\"]\n /**\n * Updates the styling of the validation FieldMessage.\n */\n status?: \"error\" | \"caution\"\n /**\n * A descriptive message for the 'status' states.\n */\n validationMessage?: React.ReactNode | undefined\n /**\n * Use the `reversed` styles.\n */\n isReversed?: boolean\n /**\n * Use the `fullWidth` styles.\n */\n isFullWidth?: boolean\n /**\n * @deprecated: Either define `disabled` in your `Option` (in `items`), or use `disabledKeys`\n */\n disabledValues?: Key[]\n} & OverrideClassName<Omit<AriaSelectProps<Option>, OmittedAriaSelectProps>>\n\n/**\n * {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3081896474/Select Guidance} |\n * {@link https://cultureamp.design/?path=/docs/components-select--docs Storybook}\n */\nexport const Select = <Option extends SelectOption = SelectOption>({\n label,\n items,\n id: propsId,\n trigger,\n children,\n status,\n validationMessage,\n isReversed,\n isFullWidth,\n disabledValues,\n classNameOverride,\n selectedKey,\n description,\n placeholder,\n isDisabled,\n ...restProps\n}: SelectProps<Option>): JSX.Element => {\n const { refs } = useFloating<HTMLButtonElement>()\n const triggerRef = refs.reference\n\n const id = propsId ?? useId()\n const descriptionId = `${id}--description`\n\n const disabledKeys = getDisabledKeysFromItems(items)\n\n const ariaSelectProps: AriaSelectProps<SelectItem<Option>> = {\n label,\n items,\n children: transformSelectItemToCollectionElement,\n disabledKeys: disabledValues ?? disabledKeys,\n selectedKey:\n typeof selectedKey === \"number\" ? selectedKey.toString() : selectedKey,\n description,\n placeholder,\n isDisabled,\n ...restProps,\n }\n\n const state = useSelectState(ariaSelectProps)\n\n const {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n errorMessageProps,\n descriptionProps,\n } = useSelect(ariaSelectProps, state, triggerRef)\n\n const { buttonProps } = useButton(triggerProps, triggerRef)\n const selectToggleProps = {\n ...buttonProps,\n label,\n labelProps,\n value: state?.selectedItem?.rendered,\n valueProps,\n isOpen: state.isOpen,\n placeholder,\n status,\n isDisabled: triggerProps.isDisabled,\n isReversed,\n ref: refs.setReference,\n }\n\n return (\n <div\n className={classnames(\n !isFullWidth && styles.notFullWidth,\n classNameOverride\n )}\n >\n <HiddenSelect\n label={label}\n name={id}\n state={state}\n triggerRef={triggerRef}\n />\n\n <div className={styles.container}>\n {trigger === undefined ? (\n <SelectToggle {...selectToggleProps} />\n ) : (\n trigger(selectToggleProps, selectToggleProps.ref)\n )}\n {state.isOpen && (\n <Popover\n refs={refs}\n focusOnProps={{\n onEscapeKey: state.close,\n onClickOutside: state.close,\n noIsolation: true,\n }}\n >\n <SelectProvider<Option> state={state}>\n <SelectPopoverContents menuProps={menuProps}>\n {children}\n </SelectPopoverContents>\n </SelectProvider>\n </Popover>\n )}\n </div>\n\n {validationMessage && (\n <FieldMessage\n {...errorMessageProps}\n message={validationMessage}\n status={status}\n reversed={isReversed}\n />\n )}\n\n {description && (\n <FieldMessage\n {...descriptionProps}\n id={descriptionId}\n message={description}\n reversed={isReversed}\n />\n )}\n </div>\n )\n}\n\nSelect.displayName = \"Select\"\n\nSelect.Section = ListBoxSection\nSelect.SectionDivider = SectionDivider\nSelect.Option = Option\nSelect.ItemDefaultRender = ListItem\n\n// @deprecated Legacy exported aliases\nSelect.TriggerButton = SelectToggle\nSelect.ListBox = ListBox\n"],"names":["Select","_a","label","items","propsId","id","trigger","children","status","validationMessage","isReversed","isFullWidth","disabledValues","classNameOverride","selectedKey","description","placeholder","isDisabled","restProps","__rest","refs","useFloating","triggerRef","reference","useId","descriptionId","concat","disabledKeys","getDisabledKeysFromItems","ariaSelectProps","transformSelectItemToCollectionElement","toString","state","useSelectState","_c","useSelect","labelProps","triggerProps","valueProps","menuProps","errorMessageProps","descriptionProps","buttonProps","useButton","selectToggleProps","__assign","value","selectedItem","_b","rendered","isOpen","ref","setReference","React","createElement","className","classnames","styles","notFullWidth","HiddenSelect","name","container","undefined","SelectToggle","Popover","focusOnProps","onEscapeKey","close","onClickOutside","noIsolation","SelectProvider","SelectPopoverContents","FieldMessage","message","reversed","displayName","Section","ListBoxSection","SectionDivider","Option","ItemDefaultRender","ListItem","TriggerButton","ListBox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuEA;;;AAGG;AAHH,MAIaA,MAAM;EAAA,MAANA,MAAM,GAAG,SAAAA,CAA6CC,EAiB7C,EAAA;;IAhBpB,IAAAC,KAAK,WAAA;MACLC,KAAK,WAAA;MACDC,OAAO,GAAAH,EAAA,CAAAI,EAAA;MACXC,OAAO,GAAAL,EAAA,CAAAK,OAAA;MACPC,QAAQ,GAAAN,EAAA,CAAAM,QAAA;MACRC,MAAM,GAAAP,EAAA,CAAAO,MAAA;MACNC,iBAAiB,GAAAR,EAAA,CAAAQ,iBAAA;MACjBC,UAAU,GAAAT,EAAA,CAAAS,UAAA;MACVC,WAAW,GAAAV,EAAA,CAAAU,WAAA;MACXC,cAAc,GAAAX,EAAA,CAAAW,cAAA;MACdC,iBAAiB,GAAAZ,EAAA,CAAAY,iBAAA;MACjBC,WAAW,GAAAb,EAAA,CAAAa,WAAA;MACXC,WAAW,iBAAA;MACXC,WAAW,iBAAA;MACXC,UAAU,gBAAA;MACPC,SAAS,GAhBqDC,MAAA,CAAAlB,EAAA,EAAA,CAAA,OAAA,EAAA,OAAA,EAAA,IAAA,EAAA,SAAA,EAAA,UAAA,EAAA,QAAA,EAAA,mBAAA,EAAA,YAAA,EAAA,aAAA,EAAA,gBAAA,EAAA,mBAAA,EAAA,aAAA,EAAA,aAAA,EAAA,aAAA,EAAA,YAAA,CAiBlE,CADa;IAEJ,IAAAmB,IAAI,GAAKC,WAAW,CAAqB,CAAA,KAArC;IACZ,IAAMC,UAAU,GAAGF,IAAI,CAACG,SAAS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;MACd;IAAA,CAAA,eAEDhB,KAAA,CAAAC,aAAA,CAACgB,cAAc,EAAA;MAAStC,KAAK,EAAEA;IAAK,CAAA,eAClCqB,KAAC,CAAAC,aAAA,CAAAiB,qBAAqB,EAAC;MAAAhC,SAAS,EAAEA;KAC/B,EAAAhC,QAAQ,CACa,CACT,CAEpB,CACG,EAELE,iBAAiB,iBAChB4C,KAAA,CAAAC,aAAA,CAACkB,YAAY,EACP3B,QAAA,CAAA,CAAA,CAAA,EAAAL,iBAAiB;MACrBiC,OAAO,EAAEhE,iBAAiB;MAC1BD,MAAM,EAAEA,MAAM;MACdkE,QAAQ,EAAEhE;OAEb,EAEAK,WAAW,iBACVsC,KAAC,CAAAC,aAAA,CAAAkB,YAAY,eACP/B,gBAAgB,EAAA;MACpBpC,EAAE,EAAEoB,aAAa;MACjBgD,OAAO,EAAE1D,WAAW;MACpB2D,QAAQ,EAAEhE;IACV,CAAA,CAAA,CACH,CACG;EAEV,CAAC;EAEDV,MAAM,CAAC2E,WAAW,GAAG,QAAQ;EAE7B3E,MAAM,CAAC4E,OAAO,GAAGC,cAAc;EAC/B7E,MAAM,CAAC8E,cAAc,GAAGA,cAAc;EACtC9E,MAAM,CAAC+E,MAAM,GAAGA,MAAM;EACtB/E,MAAM,CAACgF,iBAAiB,GAAGC,QAAQ;EAEnC;EACAjF,MAAM,CAACkF,aAAa,GAAGnB,YAAY;EACnC/D,MAAM,CAACmF,OAAO,GAAGA,OAAO;EAAA,OArIXnF,MAAM;AAAA;"}
1
+ {"version":3,"file":"Select.mjs","sources":["../../../../src/__future__/Select/Select.tsx"],"sourcesContent":["import React, { useEffect, useId, useState } from \"react\"\nimport { UseFloatingReturn } from \"@floating-ui/react-dom\"\nimport { useButton } from \"@react-aria/button\"\nimport { HiddenSelect, useSelect } from \"@react-aria/select\"\nimport {\n useSelectState,\n SelectProps as AriaSelectProps,\n} from \"@react-stately/select\"\nimport { Key } from \"@react-types/shared\"\nimport classnames from \"classnames\"\nimport { FieldMessage } from \"~components/FieldMessage\"\nimport {\n Popover,\n useFloating,\n} from \"~components/MultiSelect/subcomponents/Popover\"\nimport { OverrideClassName } from \"~types/OverrideClassName\"\nimport { SelectProvider } from \"./context\"\nimport {\n ListBox,\n ListBoxSection,\n ListItem,\n Option,\n SectionDivider,\n SelectPopoverContents,\n SelectPopoverContentsProps,\n SelectToggle,\n SelectToggleProps,\n} from \"./subcomponents\"\nimport { SelectItem, SelectOption } from \"./types\"\nimport { getDisabledKeysFromItems } from \"./utils/getDisabledKeysFromItems\"\nimport { transformSelectItemToCollectionElement } from \"./utils/transformSelectItemToCollectionElement\"\nimport styles from \"./Select.module.scss\"\n\ntype OmittedAriaSelectProps = \"children\" | \"items\"\n\nexport type SelectProps<Option extends SelectOption = SelectOption> = {\n /**\n * Item objects in the collection.\n */\n items: Array<SelectItem<Option>>\n id?: string\n trigger?: (\n selectToggleProps: SelectToggleProps & {\n ref: UseFloatingReturn<HTMLButtonElement>[\"refs\"][\"setReference\"]\n },\n // @deprecated: This arg is unnecessary now, but provided for legacy usages\n ref: UseFloatingReturn<HTMLButtonElement>[\"refs\"][\"setReference\"]\n ) => JSX.Element\n children?: SelectPopoverContentsProps<Option>[\"children\"]\n /**\n * Updates the styling of the validation FieldMessage.\n */\n status?: \"error\" | \"caution\"\n /**\n * A descriptive message for the 'status' states.\n */\n validationMessage?: React.ReactNode | undefined\n /**\n * Use the `reversed` styles.\n */\n isReversed?: boolean\n /**\n * Use the `fullWidth` styles.\n */\n isFullWidth?: boolean\n /**\n * @deprecated: Either define `disabled` in your `Option` (in `items`), or use `disabledKeys`\n */\n disabledValues?: Key[]\n /**\n * Creates a portal for the Popover to the matching element id\n */\n portalContainerId?: string\n} & OverrideClassName<Omit<AriaSelectProps<Option>, OmittedAriaSelectProps>>\n\n/**\n * {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3081896474/Select Guidance} |\n * {@link https://cultureamp.design/?path=/docs/components-select--docs Storybook}\n */\nexport const Select = <Option extends SelectOption = SelectOption>({\n label,\n items,\n id: propsId,\n trigger,\n children,\n status,\n validationMessage,\n isReversed,\n isFullWidth,\n disabledValues,\n classNameOverride,\n selectedKey,\n description,\n placeholder,\n isDisabled,\n portalContainerId,\n ...restProps\n}: SelectProps<Option>): JSX.Element => {\n const { refs } = useFloating<HTMLButtonElement>()\n const triggerRef = refs.reference\n const id = propsId ?? useId()\n const descriptionId = `${id}--description`\n const popoverId = `${id}--popover`\n\n const disabledKeys = getDisabledKeysFromItems(items)\n\n const ariaSelectProps: AriaSelectProps<SelectItem<Option>> = {\n label,\n items,\n children: transformSelectItemToCollectionElement,\n disabledKeys: disabledValues ?? disabledKeys,\n selectedKey:\n typeof selectedKey === \"number\" ? selectedKey.toString() : selectedKey,\n description,\n placeholder,\n isDisabled,\n ...restProps,\n }\n\n const state = useSelectState(ariaSelectProps)\n\n const {\n labelProps,\n triggerProps: reactAriaTriggerProps,\n valueProps,\n menuProps,\n errorMessageProps,\n descriptionProps,\n } = useSelect(ariaSelectProps, state, triggerRef)\n\n // Hack incoming:\n // react-aria/useSelect wants to prefix the combobox's accessible name with the value of the select.\n // We use role=combobox, meaning screen readers will read the value.\n // So we're modifying the `aria-labelledby` property to remove the value element id.\n // Issue: https://github.com/adobe/react-spectrum/issues/4091\n const reactAriaLabelledBy = reactAriaTriggerProps[\"aria-labelledby\"]\n const triggerProps = {\n ...reactAriaTriggerProps,\n \"aria-labelledby\": reactAriaLabelledBy?.substring(\n reactAriaLabelledBy.indexOf(\" \") + 1\n ),\n }\n\n const { buttonProps } = useButton(triggerProps, triggerRef)\n const selectToggleProps = {\n ...buttonProps,\n label,\n labelProps,\n value: state?.selectedItem?.rendered,\n valueProps,\n isOpen: state.isOpen,\n placeholder,\n status,\n isDisabled: triggerProps.isDisabled,\n isReversed,\n ref: refs.setReference,\n }\n\n const [portalContainer, setPortalContainer] = useState<HTMLElement>()\n\n useEffect(() => {\n if (portalContainerId) {\n const portalElement = document.getElementById(portalContainerId)\n portalElement && setPortalContainer(portalElement)\n }\n }, [])\n\n return (\n <div\n className={classnames(\n !isFullWidth && styles.notFullWidth,\n classNameOverride\n )}\n >\n <HiddenSelect\n label={label}\n name={id}\n state={state}\n triggerRef={triggerRef}\n />\n\n <div className={styles.container}>\n {trigger === undefined ? (\n <SelectToggle {...selectToggleProps} />\n ) : (\n trigger(selectToggleProps, selectToggleProps.ref)\n )}\n {state.isOpen && (\n <Popover\n id={popoverId}\n portalContainer={portalContainer}\n refs={refs}\n focusOnProps={{\n onEscapeKey: state.close,\n onClickOutside: state.close,\n noIsolation: true,\n }}\n >\n <SelectProvider<Option> state={state}>\n <SelectPopoverContents menuProps={menuProps}>\n {children}\n </SelectPopoverContents>\n </SelectProvider>\n </Popover>\n )}\n </div>\n\n {validationMessage && (\n <FieldMessage\n {...errorMessageProps}\n message={validationMessage}\n status={status}\n reversed={isReversed}\n />\n )}\n\n {description && (\n <FieldMessage\n {...descriptionProps}\n id={descriptionId}\n message={description}\n reversed={isReversed}\n />\n )}\n </div>\n )\n}\n\nSelect.displayName = \"Select\"\n\nSelect.Section = ListBoxSection\nSelect.SectionDivider = SectionDivider\nSelect.Option = Option\nSelect.ItemDefaultRender = ListItem\n\n// @deprecated Legacy exported aliases\nSelect.TriggerButton = SelectToggle\nSelect.ListBox = ListBox\n"],"names":["Select","_a","label","items","propsId","id","trigger","children","status","validationMessage","isReversed","isFullWidth","disabledValues","classNameOverride","selectedKey","description","placeholder","isDisabled","portalContainerId","restProps","__rest","refs","useFloating","triggerRef","reference","useId","descriptionId","concat","popoverId","disabledKeys","getDisabledKeysFromItems","ariaSelectProps","transformSelectItemToCollectionElement","toString","state","useSelectState","_c","useSelect","labelProps","reactAriaTriggerProps","triggerProps","valueProps","menuProps","errorMessageProps","descriptionProps","reactAriaLabelledBy","__assign","substring","indexOf","buttonProps","useButton","selectToggleProps","value","selectedItem","_b","rendered","isOpen","ref","setReference","_d","useState","portalContainer","setPortalContainer","useEffect","portalElement","document","getElementById","React","createElement","className","classnames","styles","notFullWidth","HiddenSelect","name","container","undefined","SelectToggle","Popover","focusOnProps","onEscapeKey","close","onClickOutside","noIsolation","SelectProvider","SelectPopoverContents","FieldMessage","message","reversed","displayName","Section","ListBoxSection","SectionDivider","Option","ItemDefaultRender","ListItem","TriggerButton","ListBox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2EA;;;AAGG;AAHH,MAIaA,MAAM;EAAA,MAANA,MAAM,GAAG,SAAAA,CAA6CC,EAkB7C,EAAA;;IAjBpB,IAAAC,KAAK,WAAA;MACLC,KAAK,WAAA;MACDC,OAAO,GAAAH,EAAA,CAAAI,EAAA;MACXC,OAAO,GAAAL,EAAA,CAAAK,OAAA;MACPC,QAAQ,GAAAN,EAAA,CAAAM,QAAA;MACRC,MAAM,GAAAP,EAAA,CAAAO,MAAA;MACNC,iBAAiB,GAAAR,EAAA,CAAAQ,iBAAA;MACjBC,UAAU,GAAAT,EAAA,CAAAS,UAAA;MACVC,WAAW,iBAAA;MACXC,cAAc,GAAAX,EAAA,CAAAW,cAAA;MACdC,iBAAiB,GAAAZ,EAAA,CAAAY,iBAAA;MACjBC,WAAW,GAAAb,EAAA,CAAAa,WAAA;MACXC,WAAW,GAAAd,EAAA,CAAAc,WAAA;MACXC,WAAW,GAAAf,EAAA,CAAAe,WAAA;MACXC,UAAU,GAAAhB,EAAA,CAAAgB,UAAA;MACVC,iBAAiB,uBAAA;MACdC,SAAS,GAjBqDC,MAAA,CAAAnB,EAAA,EAAA,CAAA,OAAA,EAAA,OAAA,EAAA,IAAA,EAAA,SAAA,EAAA,UAAA,EAAA,QAAA,EAAA,mBAAA,EAAA,YAAA,EAAA,aAAA,EAAA,gBAAA,EAAA,mBAAA,EAAA,aAAA,EAAA,aAAA,EAAA,aAAA,EAAA,YAAA,EAAA,mBAAA,CAkBlE,CADa;IAEJ,IAAAoB,IAAI,GAAKC,WAAW,CAAqB,CAAA,KAArC;IACZ,IAAMC,UAAU,GAAGF,IAAI,CAACG,SAA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WAAW,iBACVoD,KAAC,CAAAC,aAAA,CAAAkB,YAAY,eACP1C,gBAAgB,EAAA;MACpBvC,EAAE,EAAEqB,aAAa;MACjB6D,OAAO,EAAExE,WAAW;MACpByE,QAAQ,EAAE9E;IACV,CAAA,CAAA,CACH,CACG;EAEV,CAAC;EAEDV,MAAM,CAACyF,WAAW,GAAG,QAAQ;EAE7BzF,MAAM,CAAC0F,OAAO,GAAGC,cAAc;EAC/B3F,MAAM,CAAC4F,cAAc,GAAGA,cAAc;EACtC5F,MAAM,CAAC6F,MAAM,GAAGA,MAAM;EACtB7F,MAAM,CAAC8F,iBAAiB,GAAGC,QAAQ;EAEnC;EACA/F,MAAM,CAACgG,aAAa,GAAGnB,YAAY;EACnC7E,MAAM,CAACiG,OAAO,GAAGA,OAAO;EAAA,OA9JXjG,MAAM;AAAA;"}
@@ -4,6 +4,7 @@ export type ContextModalSecondaryActionProps = {
4
4
  onSecondaryAction: () => void;
5
5
  } | {
6
6
  secondaryLabel?: undefined;
7
+ onSecondaryAction?: never;
7
8
  };
8
9
  export type ContextModalProps = Readonly<{
9
10
  isOpen: boolean;
@@ -35,6 +36,6 @@ export type ContextModalProps = Readonly<{
35
36
  * {@link https://cultureamp.design/?path=/docs/components-modals--contextmodal--docs Storybook}
36
37
  */
37
38
  export declare const ContextModal: {
38
- ({ isOpen, unpadded, layout, title, onConfirm, onAfterLeave, confirmLabel, confirmWorking, renderBackground, children, contentHeader, image, ...props }: ContextModalProps): JSX.Element;
39
+ ({ isOpen, unpadded, layout, title, onConfirm, onDismiss: propsOnDismiss, onAfterLeave, confirmLabel, confirmWorking, renderBackground, children, contentHeader, image, secondaryLabel, onSecondaryAction, ...props }: ContextModalProps): JSX.Element;
39
40
  displayName: string;
40
41
  };
@@ -2,7 +2,7 @@ import { HTMLAttributes } from "react";
2
2
  import { FieldMessageProps } from "../FieldMessage";
3
3
  import { OverrideClassName } from "../types/OverrideClassName";
4
4
  import { MultiSelectOptionsProps } from "./subcomponents/MultiSelectOptions";
5
- import { MultiSelectOption } from "./types";
5
+ import { MultiSelectOption, ValidationMessage } from "./types";
6
6
  export type MultiSelectProps = {
7
7
  label: string;
8
8
  items: MultiSelectOptionsProps["options"];
@@ -14,8 +14,10 @@ export type MultiSelectProps = {
14
14
  onSelectedValuesChange: MultiSelectOptionsProps["onChange"];
15
15
  isOpen: boolean;
16
16
  onOpenChange: (isOpen: boolean) => void;
17
+ /** A status and message to provide context to the validation issue */
18
+ validationMessage?: ValidationMessage;
17
19
  } & OverrideClassName<HTMLAttributes<HTMLDivElement>>;
18
20
  export declare const MultiSelect: {
19
- ({ id: propsId, label, items, selectedValues, description, onSelectedValuesChange, isOpen, onOpenChange, classNameOverride, ...restProps }: MultiSelectProps): JSX.Element;
21
+ ({ id: propsId, label, items, selectedValues, description, onSelectedValuesChange, isOpen, onOpenChange, classNameOverride, validationMessage, ...restProps }: MultiSelectProps): JSX.Element;
20
22
  displayName: string;
21
23
  };
@@ -1,4 +1,5 @@
1
1
  import React, { HTMLAttributes } from "react";
2
+ import { FieldMessageProps } from "../../../FieldMessage";
2
3
  import { OverrideClassName } from "../../../types/OverrideClassName";
3
4
  import { MultiSelectOption } from "../../types";
4
5
  export type MultiSelectToggleProps = {
@@ -7,6 +8,7 @@ export type MultiSelectToggleProps = {
7
8
  ["aria-controls"]: string;
8
9
  selectedOptions: MultiSelectOption[];
9
10
  isOpen?: boolean;
11
+ status?: FieldMessageProps["status"];
10
12
  onRemoveOption: (optionValue: MultiSelectOption["value"]) => void;
11
13
  onRemoveAllOptions: () => void;
12
14
  } & OverrideClassName<HTMLAttributes<HTMLDivElement>>;
@@ -16,6 +18,7 @@ export declare const MultiSelectToggle: React.ForwardRefExoticComponent<{
16
18
  "aria-controls": string;
17
19
  selectedOptions: MultiSelectOption[];
18
20
  isOpen?: boolean | undefined;
21
+ status?: FieldMessageProps["status"];
19
22
  onRemoveOption: (optionValue: MultiSelectOption["value"]) => void;
20
23
  onRemoveAllOptions: () => void;
21
24
  } & Omit<React.HTMLAttributes<HTMLDivElement>, "className"> & {
@@ -1,4 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { FieldMessageStatus } from "../FieldMessage";
1
3
  export type MultiSelectOption = {
2
4
  label: string;
3
5
  value: string | number;
4
6
  };
7
+ export type ValidationMessage = {
8
+ status?: Extract<FieldMessageStatus, "error" | "caution">;
9
+ message: string | React.ReactElement;
10
+ };
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import { ToastNotificationObj } from "../types";
3
+ export type ToastNotificationProps = Omit<ToastNotificationObj, "id" | "message" | "persistent"> & {
4
+ children: React.ReactNode;
5
+ id?: string;
6
+ /**
7
+ * Removes the dismiss trigger. Functions the same as `persistent` in `addToastNotification`.
8
+ * If this is true you will need to manage the removal of notifications manually.
9
+ * @default false
10
+ */
11
+ hideCloseIcon?: boolean;
12
+ };
13
+ export declare const ToastNotification: {
14
+ ({ id: propsId, hideCloseIcon, type, title, onHide, children, ...restProps }: ToastNotificationProps): null;
15
+ displayName: string;
16
+ };
@@ -0,0 +1 @@
1
+ export * from "./ToastNotification";
@@ -0,0 +1,4 @@
1
+ export declare const ToastNotificationsList: {
2
+ (): JSX.Element;
3
+ displayName: string;
4
+ };
@@ -0,0 +1,12 @@
1
+ import { HTMLAttributes } from "react";
2
+ import { OverrideClassName } from "../../../../../types/OverrideClassName";
3
+ import { ToastNotificationObj } from "../../../types";
4
+ export type ToastNotificationsMapProps = {
5
+ notifications: ToastNotificationObj[];
6
+ onHide: (notificationId: string) => void;
7
+ container: Element | null;
8
+ } & OverrideClassName<HTMLAttributes<HTMLDivElement>>;
9
+ export declare const ToastNotificationsMap: {
10
+ ({ notifications, onHide: defaultOnHide, container, }: ToastNotificationsMapProps): JSX.Element | null;
11
+ displayName: string;
12
+ };
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { ToastNotificationObj } from "../types";
3
+ type ToastNotificationObjOptionalId = Omit<ToastNotificationObj, "id"> & {
4
+ id?: string;
5
+ };
6
+ export type ToastNotificationContextValue = {
7
+ notifications: ToastNotificationObj[];
8
+ addToastNotification: (notification: ToastNotificationObjOptionalId) => void;
9
+ updateToastNotification: (notification: ToastNotificationObj) => void;
10
+ removeToastNotification: (notificationId: string) => void;
11
+ clearToastNotifications: () => void;
12
+ };
13
+ export declare const useToastNotificationContext: () => ToastNotificationContextValue;
14
+ type ToastNotificationProviderProps = {
15
+ children: React.ReactNode;
16
+ };
17
+ export declare const ToastNotificationProvider: {
18
+ ({ children, }: ToastNotificationProviderProps): JSX.Element | null;
19
+ displayName: string;
20
+ };
21
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ToastNotificationContextValue } from "../context/ToastNotificationContext";
2
+ export declare const useToastNotification: () => ToastNotificationContextValue;
@@ -1,3 +1,4 @@
1
1
  export * from "./ToastNotification";
2
- export * from "./subcomponents/ToastNotificationManager";
3
- export * from "./subcomponents/ToastNotificationsList";
2
+ export * from "./ToastNotificationsList";
3
+ export * from "./hooks/useToastNotification";
4
+ export * from "./types";
@@ -1,8 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { DataAttributes } from "../../types/DataAttributes";
3
3
  import { NotificationType } from "../types";
4
- type Modify<T, R> = Omit<T, keyof R> & R;
5
- export type ToastNotification = {
4
+ export type ToastNotificationObj = {
6
5
  id: string;
7
6
  type: NotificationType;
8
7
  title: string;
@@ -14,10 +13,3 @@ export type ToastNotification = {
14
13
  */
15
14
  persistent?: boolean;
16
15
  } & DataAttributes;
17
- export type ToastNotificationWithOptionals = Modify<ToastNotification, {
18
- id?: string;
19
- }>;
20
- export type AddToastNotification = (notification: ToastNotificationWithOptionals) => void;
21
- export type RemoveToastNotification = (notificationId: string) => void;
22
- export type ClearToastNotifications = () => void;
23
- export {};
@@ -1,2 +1,3 @@
1
1
  export * from "./InlineNotification";
2
2
  export * from "./GlobalNotification";
3
+ export * from "./ToastNotification";
@@ -37,7 +37,7 @@ export type RichTextEditorProps = BaseRichTextEditorProps & (WithLabelText | Wit
37
37
  * {@link https://cultureamp.design/?path=/docs/components-richtexteditor--docs Storybook}
38
38
  */
39
39
  export declare const RichTextEditor: {
40
- ({ onChange, defaultValue, labelText, "aria-labelledby": labelledBy, classNameOverride, controls, rows, dataError, onDataError, validationMessage, description, status, ...restProps }: RichTextEditorProps): JSX.Element;
40
+ ({ onChange, defaultValue, labelText, "aria-labelledby": labelledBy, "aria-describedby": describedBy, classNameOverride, controls, rows, dataError, onDataError, validationMessage, description, status, ...restProps }: RichTextEditorProps): JSX.Element;
41
41
  displayName: string;
42
42
  };
43
43
  export {};