@stack-spot/portal-layout 0.0.65 → 1.0.0-stg.1768483038644

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 (363) hide show
  1. package/CHANGELOG.md +779 -0
  2. package/dist/Layout.d.ts +60 -8
  3. package/dist/Layout.d.ts.map +1 -1
  4. package/dist/Layout.js +59 -24
  5. package/dist/Layout.js.map +1 -1
  6. package/dist/LayoutOverlayManager.d.ts +274 -19
  7. package/dist/LayoutOverlayManager.d.ts.map +1 -1
  8. package/dist/LayoutOverlayManager.js +373 -82
  9. package/dist/LayoutOverlayManager.js.map +1 -1
  10. package/dist/WelcomeTour.d.ts +2 -0
  11. package/dist/WelcomeTour.d.ts.map +1 -0
  12. package/dist/WelcomeTour.js +8 -0
  13. package/dist/WelcomeTour.js.map +1 -0
  14. package/dist/components/Backdrop.d.ts +75 -0
  15. package/dist/components/Backdrop.d.ts.map +1 -0
  16. package/dist/components/Backdrop.js +69 -0
  17. package/dist/components/Backdrop.js.map +1 -0
  18. package/dist/components/Contact/show-contact-modal.d.ts +5 -0
  19. package/dist/components/Contact/show-contact-modal.d.ts.map +1 -0
  20. package/dist/components/Contact/show-contact-modal.js +37 -0
  21. package/dist/components/Contact/show-contact-modal.js.map +1 -0
  22. package/dist/components/ContactModal.d.ts +1 -0
  23. package/dist/components/ContactModal.d.ts.map +1 -0
  24. package/dist/components/ContactModal.js +2 -0
  25. package/dist/components/ContactModal.js.map +1 -0
  26. package/dist/components/Dialog.d.ts +54 -7
  27. package/dist/components/Dialog.d.ts.map +1 -1
  28. package/dist/components/Dialog.js +8 -2
  29. package/dist/components/Dialog.js.map +1 -1
  30. package/dist/components/Header.d.ts +38 -2
  31. package/dist/components/Header.d.ts.map +1 -1
  32. package/dist/components/Header.js +9 -4
  33. package/dist/components/Header.js.map +1 -1
  34. package/dist/components/NotificationCenter/NotificationPanel.d.ts +3 -0
  35. package/dist/components/NotificationCenter/NotificationPanel.d.ts.map +1 -0
  36. package/dist/components/NotificationCenter/NotificationPanel.js +19 -0
  37. package/dist/components/NotificationCenter/NotificationPanel.js.map +1 -0
  38. package/dist/components/NotificationCenter/NotificationPanelHeader.d.ts +3 -0
  39. package/dist/components/NotificationCenter/NotificationPanelHeader.d.ts.map +1 -0
  40. package/dist/components/NotificationCenter/NotificationPanelHeader.js +16 -0
  41. package/dist/components/NotificationCenter/NotificationPanelHeader.js.map +1 -0
  42. package/dist/components/NotificationCenter/NotificationsPanelFooter.d.ts +4 -0
  43. package/dist/components/NotificationCenter/NotificationsPanelFooter.d.ts.map +1 -0
  44. package/dist/components/NotificationCenter/NotificationsPanelFooter.js +12 -0
  45. package/dist/components/NotificationCenter/NotificationsPanelFooter.js.map +1 -0
  46. package/dist/components/NotificationCenter/dictionary.d.ts +2 -0
  47. package/dist/components/NotificationCenter/dictionary.d.ts.map +1 -0
  48. package/dist/components/NotificationCenter/dictionary.js +43 -0
  49. package/dist/components/NotificationCenter/dictionary.js.map +1 -0
  50. package/dist/components/NotificationCenter/index.d.ts +2 -0
  51. package/dist/components/NotificationCenter/index.d.ts.map +1 -0
  52. package/dist/components/NotificationCenter/index.js +34 -0
  53. package/dist/components/NotificationCenter/index.js.map +1 -0
  54. package/dist/components/NotificationCenter/styled.d.ts +3 -0
  55. package/dist/components/NotificationCenter/styled.d.ts.map +1 -0
  56. package/dist/components/NotificationCenter/styled.js +74 -0
  57. package/dist/components/NotificationCenter/styled.js.map +1 -0
  58. package/dist/components/NotificationCenter/types.d.ts +21 -0
  59. package/dist/components/NotificationCenter/types.d.ts.map +1 -0
  60. package/dist/components/NotificationCenter/types.js.map +1 -0
  61. package/dist/components/NotificationCenter/utils.d.ts +5 -0
  62. package/dist/components/NotificationCenter/utils.d.ts.map +1 -0
  63. package/dist/components/NotificationCenter/utils.js +18 -0
  64. package/dist/components/NotificationCenter/utils.js.map +1 -0
  65. package/dist/components/OverlayContent.d.ts +27 -1
  66. package/dist/components/OverlayContent.d.ts.map +1 -1
  67. package/dist/components/OverlayContent.js +8 -4
  68. package/dist/components/OverlayContent.js.map +1 -1
  69. package/dist/components/PortalSwitcher.d.ts +19 -1
  70. package/dist/components/PortalSwitcher.d.ts.map +1 -1
  71. package/dist/components/PortalSwitcher.js +16 -31
  72. package/dist/components/PortalSwitcher.js.map +1 -1
  73. package/dist/components/PrivacyPolicyMessage/hooks.d.ts +10 -0
  74. package/dist/components/PrivacyPolicyMessage/hooks.d.ts.map +1 -0
  75. package/dist/components/PrivacyPolicyMessage/hooks.js +33 -0
  76. package/dist/components/PrivacyPolicyMessage/hooks.js.map +1 -0
  77. package/dist/components/PrivacyPolicyMessage/index.d.ts +7 -0
  78. package/dist/components/PrivacyPolicyMessage/index.d.ts.map +1 -0
  79. package/dist/components/PrivacyPolicyMessage/index.js +5 -0
  80. package/dist/components/PrivacyPolicyMessage/index.js.map +1 -0
  81. package/dist/components/Rate/FeedbackModal.d.ts +8 -0
  82. package/dist/components/Rate/FeedbackModal.d.ts.map +1 -0
  83. package/dist/components/Rate/FeedbackModal.js +52 -0
  84. package/dist/components/Rate/FeedbackModal.js.map +1 -0
  85. package/dist/components/Rate/hook.d.ts +3 -0
  86. package/dist/components/Rate/hook.d.ts.map +1 -0
  87. package/dist/components/Rate/hook.js +48 -0
  88. package/dist/components/Rate/hook.js.map +1 -0
  89. package/dist/components/Rate/index.d.ts +10 -0
  90. package/dist/components/Rate/index.d.ts.map +1 -0
  91. package/dist/components/Rate/index.js +16 -0
  92. package/dist/components/Rate/index.js.map +1 -0
  93. package/dist/components/Rate/on-nps-submit.d.ts +7 -0
  94. package/dist/components/Rate/on-nps-submit.d.ts.map +1 -0
  95. package/dist/components/Rate/on-nps-submit.js +8 -0
  96. package/dist/components/Rate/on-nps-submit.js.map +1 -0
  97. package/dist/components/Rate/show-rate-us-modals.d.ts +17 -0
  98. package/dist/components/Rate/show-rate-us-modals.d.ts.map +1 -0
  99. package/dist/components/Rate/show-rate-us-modals.js +14 -0
  100. package/dist/components/Rate/show-rate-us-modals.js.map +1 -0
  101. package/dist/components/Rate/utils.d.ts +2 -0
  102. package/dist/components/Rate/utils.d.ts.map +1 -0
  103. package/dist/components/Rate/utils.js +10 -0
  104. package/dist/components/Rate/utils.js.map +1 -0
  105. package/dist/components/Toaster.d.ts +35 -0
  106. package/dist/components/Toaster.d.ts.map +1 -1
  107. package/dist/components/Toaster.js +32 -4
  108. package/dist/components/Toaster.js.map +1 -1
  109. package/dist/components/TypeForm/hook.d.ts +2 -0
  110. package/dist/components/TypeForm/hook.d.ts.map +1 -0
  111. package/dist/components/TypeForm/hook.js +11 -0
  112. package/dist/components/TypeForm/hook.js.map +1 -0
  113. package/dist/components/TypeForm/index.d.ts +6 -0
  114. package/dist/components/TypeForm/index.d.ts.map +1 -0
  115. package/dist/components/TypeForm/index.js +23 -0
  116. package/dist/components/TypeForm/index.js.map +1 -0
  117. package/dist/components/TypeForm/show-typeform-modal.d.ts +5 -0
  118. package/dist/components/TypeForm/show-typeform-modal.d.ts.map +1 -0
  119. package/dist/components/TypeForm/show-typeform-modal.js +11 -0
  120. package/dist/components/TypeForm/show-typeform-modal.js.map +1 -0
  121. package/dist/components/TypeForm/utils.d.ts +2 -0
  122. package/dist/components/TypeForm/utils.d.ts.map +1 -0
  123. package/dist/components/TypeForm/utils.js +9 -0
  124. package/dist/components/TypeForm/utils.js.map +1 -0
  125. package/dist/components/UserMenu.d.ts +19 -2
  126. package/dist/components/UserMenu.d.ts.map +1 -1
  127. package/dist/components/UserMenu.js +12 -6
  128. package/dist/components/UserMenu.js.map +1 -1
  129. package/dist/components/error/ErrorBoundary.d.ts +25 -4
  130. package/dist/components/error/ErrorBoundary.d.ts.map +1 -1
  131. package/dist/components/error/ErrorBoundary.js +10 -1
  132. package/dist/components/error/ErrorBoundary.js.map +1 -1
  133. package/dist/components/error/ErrorManager.d.ts +22 -6
  134. package/dist/components/error/ErrorManager.d.ts.map +1 -1
  135. package/dist/components/error/ErrorManager.js +21 -1
  136. package/dist/components/error/ErrorManager.js.map +1 -1
  137. package/dist/components/error/SilentErrorBoundary.d.ts +26 -5
  138. package/dist/components/error/SilentErrorBoundary.d.ts.map +1 -1
  139. package/dist/components/error/SilentErrorBoundary.js +10 -0
  140. package/dist/components/error/SilentErrorBoundary.js.map +1 -1
  141. package/dist/components/menu/MenuContent.d.ts +20 -4
  142. package/dist/components/menu/MenuContent.d.ts.map +1 -1
  143. package/dist/components/menu/MenuContent.js +89 -88
  144. package/dist/components/menu/MenuContent.js.map +1 -1
  145. package/dist/components/menu/MenuSectionGroup.d.ts +2 -0
  146. package/dist/components/menu/MenuSectionGroup.d.ts.map +1 -0
  147. package/dist/components/menu/MenuSectionGroup.js +121 -0
  148. package/dist/components/menu/MenuSectionGroup.js.map +1 -0
  149. package/dist/components/menu/MenuSections.d.ts +17 -0
  150. package/dist/components/menu/MenuSections.d.ts.map +1 -1
  151. package/dist/components/menu/MenuSections.js +159 -39
  152. package/dist/components/menu/MenuSections.js.map +1 -1
  153. package/dist/components/menu/PageSelector.d.ts +5 -0
  154. package/dist/components/menu/PageSelector.d.ts.map +1 -1
  155. package/dist/components/menu/PageSelector.js +9 -4
  156. package/dist/components/menu/PageSelector.js.map +1 -1
  157. package/dist/components/menu/types.d.ts +219 -8
  158. package/dist/components/menu/types.d.ts.map +1 -1
  159. package/dist/components/tour/StepContainer.d.ts +37 -0
  160. package/dist/components/tour/StepContainer.d.ts.map +1 -0
  161. package/dist/components/tour/StepContainer.js +51 -0
  162. package/dist/components/tour/StepContainer.js.map +1 -0
  163. package/dist/components/tour/StepNavigation.d.ts +29 -0
  164. package/dist/components/tour/StepNavigation.d.ts.map +1 -0
  165. package/dist/components/tour/StepNavigation.js +37 -0
  166. package/dist/components/tour/StepNavigation.js.map +1 -0
  167. package/dist/components/tour/StepTitle.d.ts +17 -0
  168. package/dist/components/tour/StepTitle.d.ts.map +1 -0
  169. package/dist/components/tour/StepTitle.js +10 -0
  170. package/dist/components/tour/StepTitle.js.map +1 -0
  171. package/dist/components/tour/hook.d.ts +3 -0
  172. package/dist/components/tour/hook.d.ts.map +1 -0
  173. package/dist/components/tour/hook.js +10 -0
  174. package/dist/components/tour/hook.js.map +1 -0
  175. package/dist/components/tour/index.d.ts +5 -0
  176. package/dist/components/tour/index.d.ts.map +1 -0
  177. package/dist/components/tour/index.js +5 -0
  178. package/dist/components/tour/index.js.map +1 -0
  179. package/dist/components/tour/manager.d.ts +34 -0
  180. package/dist/components/tour/manager.d.ts.map +1 -0
  181. package/dist/components/tour/manager.js +104 -0
  182. package/dist/components/tour/manager.js.map +1 -0
  183. package/dist/components/tour/utils.d.ts +67 -0
  184. package/dist/components/tour/utils.d.ts.map +1 -0
  185. package/dist/components/tour/utils.js +60 -0
  186. package/dist/components/tour/utils.js.map +1 -0
  187. package/dist/components/user-menu-manager.d.ts +13 -0
  188. package/dist/components/user-menu-manager.d.ts.map +1 -0
  189. package/dist/components/user-menu-manager.js +36 -0
  190. package/dist/components/user-menu-manager.js.map +1 -0
  191. package/dist/dictionary.d.ts +6 -1
  192. package/dist/dictionary.d.ts.map +1 -1
  193. package/dist/dictionary.js +7 -2
  194. package/dist/dictionary.js.map +1 -1
  195. package/dist/elements.d.ts +7 -0
  196. package/dist/elements.d.ts.map +1 -1
  197. package/dist/elements.js +7 -0
  198. package/dist/elements.js.map +1 -1
  199. package/dist/index.d.ts +15 -8
  200. package/dist/index.d.ts.map +1 -1
  201. package/dist/index.js +15 -8
  202. package/dist/index.js.map +1 -1
  203. package/dist/layout.css +190 -35
  204. package/dist/svg/StarFillWithGradient.d.ts +6 -0
  205. package/dist/svg/StarFillWithGradient.d.ts.map +1 -0
  206. package/dist/svg/StarFillWithGradient.js +4 -0
  207. package/dist/svg/StarFillWithGradient.js.map +1 -0
  208. package/dist/toaster.d.ts +55 -9
  209. package/dist/toaster.d.ts.map +1 -1
  210. package/dist/toaster.js +34 -6
  211. package/dist/toaster.js.map +1 -1
  212. package/dist/types.d.ts +5 -0
  213. package/dist/types.d.ts.map +1 -0
  214. package/dist/types.js +2 -0
  215. package/dist/types.js.map +1 -0
  216. package/dist/utils.d.ts +6 -69
  217. package/dist/utils.d.ts.map +1 -1
  218. package/dist/utils.js +9 -130
  219. package/dist/utils.js.map +1 -1
  220. package/package.dev.json +3 -0
  221. package/package.json +24 -13
  222. package/package.stg.json +3 -0
  223. package/readme.md +147 -0
  224. package/src/Layout.tsx +166 -58
  225. package/src/LayoutOverlayManager.tsx +499 -85
  226. package/src/WelcomeTour.tsx +8 -0
  227. package/src/components/Backdrop.tsx +116 -0
  228. package/src/components/Contact/show-contact-modal.tsx +71 -0
  229. package/src/components/Dialog.tsx +58 -9
  230. package/src/components/Header.tsx +53 -5
  231. package/src/components/NotificationCenter/NotificationPanel.tsx +40 -0
  232. package/src/components/NotificationCenter/NotificationPanelHeader.tsx +53 -0
  233. package/src/components/NotificationCenter/NotificationsPanelFooter.tsx +25 -0
  234. package/src/components/NotificationCenter/dictionary.ts +44 -0
  235. package/src/components/NotificationCenter/index.tsx +58 -0
  236. package/src/components/NotificationCenter/styled.ts +75 -0
  237. package/src/components/NotificationCenter/types.ts +24 -0
  238. package/src/components/NotificationCenter/utils.ts +20 -0
  239. package/src/components/OverlayContent.tsx +40 -5
  240. package/src/components/PortalSwitcher.tsx +33 -39
  241. package/src/components/PrivacyPolicyMessage/hooks.tsx +49 -0
  242. package/src/components/PrivacyPolicyMessage/index.tsx +21 -0
  243. package/src/components/Rate/FeedbackModal.tsx +86 -0
  244. package/src/components/Rate/hook.tsx +61 -0
  245. package/src/components/Rate/index.tsx +36 -0
  246. package/src/components/Rate/on-nps-submit.ts +18 -0
  247. package/src/components/Rate/show-rate-us-modals.tsx +29 -0
  248. package/src/components/Rate/utils.ts +11 -0
  249. package/src/components/Toaster.tsx +82 -3
  250. package/src/components/TypeForm/hook.tsx +13 -0
  251. package/src/components/TypeForm/index.tsx +50 -0
  252. package/src/components/TypeForm/show-typeform-modal.tsx +10 -0
  253. package/src/components/TypeForm/utils.ts +8 -0
  254. package/src/components/UserMenu.tsx +32 -8
  255. package/src/components/error/ErrorBoundary.tsx +11 -2
  256. package/src/components/error/ErrorManager.ts +22 -6
  257. package/src/components/error/SilentErrorBoundary.tsx +12 -2
  258. package/src/components/menu/MenuContent.tsx +102 -110
  259. package/src/components/menu/MenuSectionGroup.tsx +121 -0
  260. package/src/components/menu/MenuSections.tsx +342 -93
  261. package/src/components/menu/PageSelector.tsx +16 -4
  262. package/src/components/menu/types.ts +221 -9
  263. package/src/components/tour/StepContainer.tsx +92 -0
  264. package/src/components/tour/StepNavigation.tsx +72 -0
  265. package/src/components/tour/StepTitle.tsx +28 -0
  266. package/src/components/tour/hook.ts +12 -0
  267. package/src/components/tour/index.ts +6 -0
  268. package/src/components/tour/manager.tsx +119 -0
  269. package/src/components/tour/utils.tsx +119 -0
  270. package/src/components/user-menu-manager.ts +31 -0
  271. package/src/dictionary.ts +7 -2
  272. package/src/elements.ts +7 -0
  273. package/src/index.ts +15 -8
  274. package/src/layout.css +190 -35
  275. package/src/svg/StarFillWithGradient.tsx +14 -0
  276. package/src/toaster.tsx +90 -13
  277. package/src/types.ts +4 -0
  278. package/src/utils.ts +9 -142
  279. package/dist/components/BottomNotification.d.ts +0 -1
  280. package/dist/components/BottomNotification.d.ts.map +0 -1
  281. package/dist/components/BottomNotification.js +0 -2
  282. package/dist/components/BottomNotification.js.map +0 -1
  283. package/dist/components/BottomPanel.d.ts +0 -1
  284. package/dist/components/BottomPanel.d.ts.map +0 -1
  285. package/dist/components/BottomPanel.js +0 -2
  286. package/dist/components/BottomPanel.js.map +0 -1
  287. package/dist/components/SelectionList.d.ts +0 -36
  288. package/dist/components/SelectionList.d.ts.map +0 -1
  289. package/dist/components/SelectionList.js +0 -140
  290. package/dist/components/SelectionList.js.map +0 -1
  291. package/dist/components/error/ErrorFeedback.d.ts +0 -3
  292. package/dist/components/error/ErrorFeedback.d.ts.map +0 -1
  293. package/dist/components/error/ErrorFeedback.js +0 -66
  294. package/dist/components/error/ErrorFeedback.js.map +0 -1
  295. package/dist/components/menu/use-check-text-overflow.d.ts +0 -6
  296. package/dist/components/menu/use-check-text-overflow.d.ts.map +0 -1
  297. package/dist/components/menu/use-check-text-overflow.js +0 -20
  298. package/dist/components/menu/use-check-text-overflow.js.map +0 -1
  299. package/dist/components/menu/use-keyboard-controls.d.ts +0 -23
  300. package/dist/components/menu/use-keyboard-controls.d.ts.map +0 -1
  301. package/dist/components/menu/use-keyboard-controls.js +0 -49
  302. package/dist/components/menu/use-keyboard-controls.js.map +0 -1
  303. package/dist/components/tour/PortalSwitcherStep.d.ts +0 -3
  304. package/dist/components/tour/PortalSwitcherStep.d.ts.map +0 -1
  305. package/dist/components/tour/PortalSwitcherStep.js +0 -29
  306. package/dist/components/tour/PortalSwitcherStep.js.map +0 -1
  307. package/dist/components/types.d.ts +0 -15
  308. package/dist/components/types.d.ts.map +0 -1
  309. package/dist/components/types.js.map +0 -1
  310. package/dist/layout-context.d.ts +0 -10
  311. package/dist/layout-context.d.ts.map +0 -1
  312. package/dist/layout-context.js +0 -11
  313. package/dist/layout-context.js.map +0 -1
  314. package/dist/svg/AI.d.ts +0 -6
  315. package/dist/svg/AI.d.ts.map +0 -1
  316. package/dist/svg/AI.js +0 -9
  317. package/dist/svg/AI.js.map +0 -1
  318. package/dist/svg/EDP.d.ts +0 -6
  319. package/dist/svg/EDP.d.ts.map +0 -1
  320. package/dist/svg/EDP.js +0 -5
  321. package/dist/svg/EDP.js.map +0 -1
  322. package/dist/svg/Forbidden.d.ts +0 -6
  323. package/dist/svg/Forbidden.d.ts.map +0 -1
  324. package/dist/svg/Forbidden.js +0 -4
  325. package/dist/svg/Forbidden.js.map +0 -1
  326. package/dist/svg/HUB.d.ts +0 -6
  327. package/dist/svg/HUB.d.ts.map +0 -1
  328. package/dist/svg/HUB.js +0 -5
  329. package/dist/svg/HUB.js.map +0 -1
  330. package/dist/svg/Logo.d.ts +0 -2
  331. package/dist/svg/Logo.d.ts.map +0 -1
  332. package/dist/svg/Logo.js +0 -4
  333. package/dist/svg/Logo.js.map +0 -1
  334. package/dist/svg/NotFound.d.ts +0 -6
  335. package/dist/svg/NotFound.d.ts.map +0 -1
  336. package/dist/svg/NotFound.js +0 -4
  337. package/dist/svg/NotFound.js.map +0 -1
  338. package/dist/svg/ServerError.d.ts +0 -6
  339. package/dist/svg/ServerError.d.ts.map +0 -1
  340. package/dist/svg/ServerError.js +0 -4
  341. package/dist/svg/ServerError.js.map +0 -1
  342. package/dist/svg/Unauthenticated.d.ts +0 -6
  343. package/dist/svg/Unauthenticated.d.ts.map +0 -1
  344. package/dist/svg/Unauthenticated.js +0 -4
  345. package/dist/svg/Unauthenticated.js.map +0 -1
  346. package/src/components/BottomPanel.tsx +0 -0
  347. package/src/components/SelectionList.tsx +0 -272
  348. package/src/components/error/ErrorFeedback.tsx +0 -114
  349. package/src/components/menu/use-check-text-overflow.tsx +0 -26
  350. package/src/components/menu/use-keyboard-controls.tsx +0 -70
  351. package/src/components/tour/PortalSwitcherStep.tsx +0 -36
  352. package/src/components/types.ts +0 -15
  353. package/src/layout-context.tsx +0 -22
  354. package/src/svg/AI.tsx +0 -37
  355. package/src/svg/EDP.tsx +0 -35
  356. package/src/svg/Forbidden.tsx +0 -22
  357. package/src/svg/HUB.tsx +0 -35
  358. package/src/svg/Logo.tsx +0 -35
  359. package/src/svg/NotFound.tsx +0 -16
  360. package/src/svg/ServerError.tsx +0 -33
  361. package/src/svg/Unauthenticated.tsx +0 -16
  362. /package/dist/components/{types.js → NotificationCenter/types.js} +0 -0
  363. /package/src/components/{BottomNotification.tsx → ContactModal.tsx} +0 -0
@@ -1,14 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /* eslint-disable react-hooks/rules-of-hooks */
3
3
  import { Button } from '@citric/core';
4
+ import { focusAccessibleElement, focusFirstChild } from '@stack-spot/portal-components';
5
+ import { last } from 'lodash';
4
6
  import { useLayoutEffect, useState } from 'react';
5
7
  import { Dialog } from './components/Dialog.js';
6
8
  import { CLOSE_OVERLAY_ID, OverlayContent } from './components/OverlayContent.js';
7
9
  import { getDictionary } from './dictionary.js';
8
10
  import { elementIds, getLayoutElements } from './elements.js';
9
11
  import { ElementNotFound, LayoutError } from './errors.js';
10
- import { showToaster as showReactToaster } from './toaster.js';
11
- import { focusAccessibleElement, focusFirstChild, valueOfLayoutVar } from './utils.js';
12
+ import { closeReactToaster, showToaster as showReactToaster } from './toaster.js';
13
+ import { valueOfLayoutVar } from './utils.js';
12
14
  function multipleCallsWarning(type, timeMS) {
13
15
  return `
14
16
  Attempted to show a modal or rightPanel while a ${type} was still being closed. Closing a ${type} takes only ${timeMS}ms, so this action
@@ -31,12 +33,6 @@ class LayoutOverlayManager {
31
33
  writable: true,
32
34
  value: void 0
33
35
  });
34
- Object.defineProperty(this, "onModalClose", {
35
- enumerable: true,
36
- configurable: true,
37
- writable: true,
38
- value: void 0
39
- });
40
36
  /**
41
37
  * Last element with focus before an overlay is shown.
42
38
  */
@@ -46,53 +42,111 @@ class LayoutOverlayManager {
46
42
  writable: true,
47
43
  value: null
48
44
  });
49
- Object.defineProperty(this, "showToaster", {
45
+ Object.defineProperty(this, "modals", {
46
+ enumerable: true,
47
+ configurable: true,
48
+ writable: true,
49
+ value: []
50
+ });
51
+ Object.defineProperty(this, "panels", {
52
+ enumerable: true,
53
+ configurable: true,
54
+ writable: true,
55
+ value: []
56
+ });
57
+ /**
58
+ * Closes the toaster with the specified id.
59
+ * @param id the id of the toaster to close.
60
+ */
61
+ Object.defineProperty(this, "closeToaster", {
50
62
  enumerable: true,
51
63
  configurable: true,
52
64
  writable: true,
53
- value: showReactToaster
65
+ value: closeReactToaster
54
66
  });
55
67
  }
56
- setupElements() {
57
- this.elements = getLayoutElements();
58
- this.elements.backdrop?.addEventListener('mousedown', (event) => {
59
- if (this.isModalOpen())
60
- !this.elements?.modal?.contains?.(event.target) && this.closeModal();
61
- else if (this.isRightPanelOpen())
62
- !this.elements?.rightPanel?.contains?.(event.target) && this.closeRightPanel();
63
- else
68
+ closeCustomBackdrops(elements) {
69
+ // this is the easiest way to close each custom backdrop by calling their respective "onClose" callbacks. This is a hidden button
70
+ // that exists in every <Backdrop> component.
71
+ elements.forEach(element => element.querySelector('[data-custom-backdrop-close]')?.click?.());
72
+ }
73
+ onClickBackdrop(event) {
74
+ if (this.isModalOpen())
75
+ !this.elements?.modal?.contains?.(event.target) && this.closeModal();
76
+ else if (this.isRightPanelOpen())
77
+ !this.elements?.rightPanel?.contains?.(event.target) && this.closeRightPanel();
78
+ else {
79
+ const customBackdrops = this.getAllVisibleCustomBackdrops();
80
+ if (customBackdrops.length) {
81
+ let isClickInside = false;
82
+ customBackdrops.forEach((element) => {
83
+ if (element.contains(event.target))
84
+ isClickInside = true;
85
+ });
86
+ if (!isClickInside)
87
+ this.closeCustomBackdrops(customBackdrops);
88
+ }
89
+ else {
64
90
  this.setMainContentInteractivity(true);
65
- });
66
- this.elements.backdrop?.addEventListener('keydown', (event) => {
67
- if (event.key !== 'Escape')
68
- return;
69
- if (this.isModalOpen())
70
- this.closeModal();
71
- if (this.isRightPanelOpen())
72
- this.closeRightPanel();
91
+ }
92
+ }
93
+ }
94
+ onPressKeyInBackdrop(event) {
95
+ if (event.key !== 'Escape')
96
+ return;
97
+ if (this.isModalOpen())
98
+ this.closeModal();
99
+ if (this.isRightPanelOpen())
100
+ this.closeRightPanel();
101
+ else {
102
+ const customBackdrops = this.getAllVisibleCustomBackdrops();
103
+ if (customBackdrops.length)
104
+ this.closeCustomBackdrops(customBackdrops);
73
105
  else
74
106
  this.setMainContentInteractivity(true);
75
- event.preventDefault();
76
- });
107
+ }
108
+ event.preventDefault();
109
+ }
110
+ setupElements() {
111
+ this.elements = getLayoutElements();
112
+ this.elements.backdrop?.addEventListener('mousedown', (event) => this.onClickBackdrop(event));
113
+ this.elements.backdrop?.addEventListener('keydown', (event) => this.onPressKeyInBackdrop(event));
77
114
  this.setInteractivity(this.elements?.modal, false);
78
115
  this.setInteractivity(this.elements?.rightPanel, false);
79
116
  this.setInteractivity(this.elements?.bottomDialog, false);
80
117
  }
81
- // this should actually be like Kotlin's "internal", i.e. private to any user of the lib, but public to the lib itself.
82
- // @ts-ignore
118
+ getAllVisibleCustomBackdrops() {
119
+ return document.querySelectorAll('[data-custom-backdrop-visibility=true]');
120
+ }
121
+ /**
122
+ * Setup the overlay layout elements.
123
+ * @returns the content for the modal, rightPanel and bottomDialog.
124
+ * @internal
125
+ */
83
126
  useOverlays() {
84
127
  useLayoutEffect(() => {
85
128
  if (!this.elements)
86
129
  this.setupElements();
87
130
  }, []);
88
- const [modal, setModal] = useState();
89
- const [rightPanel, setRightPanel] = useState();
131
+ const [modal, setModal] = useState([]);
132
+ const [rightPanel, setRightPanel] = useState([]);
90
133
  const [bottomDialog, setBottomDialog] = useState();
91
- this.setContent.modal = setModal;
92
- this.setContent.rightPanel = setRightPanel;
134
+ this.setContent.modal = (content) => {
135
+ this.modals = content;
136
+ setModal(content);
137
+ };
138
+ this.setContent.rightPanel = (content) => {
139
+ this.panels = content;
140
+ setRightPanel(content);
141
+ };
93
142
  this.setContent.bottomDialog = setBottomDialog;
94
143
  return { modal, rightPanel, bottomDialog };
95
144
  }
145
+ /**
146
+ * Enables or disables the interactivity of an element.
147
+ * @param element the element to have its interactivity changed.
148
+ * @param interactive false to disable interactivity, true to enable.
149
+ */
96
150
  setInteractivity(element, interactive) {
97
151
  if (interactive) {
98
152
  element?.removeAttribute('inert');
@@ -109,88 +163,226 @@ class LayoutOverlayManager {
109
163
  this.setInteractivity(this.elements?.menu, interactive);
110
164
  this.elements?.backdrop?.setAttribute('class', interactive ? '' : 'visible');
111
165
  }
112
- showOverlay(element, extraClasses = [], blockMainContent = true) {
166
+ showOverlay(element, extraClasses = [], blockMainContent = true, manageClasses = true, ignoreFirstFocusOnCloseButton = true) {
113
167
  this.lastActiveElement = document.activeElement;
114
- element?.classList.add('visible', ...extraClasses);
168
+ if (manageClasses)
169
+ element?.classList.add('visible', ...extraClasses);
115
170
  this.setInteractivity(element, true);
116
171
  if (blockMainContent)
117
172
  this.setMainContentInteractivity(false);
118
- setTimeout(() => focusFirstChild(element, { priority: [['input', 'textarea', 'select', 'other', 'button']], ignore: `#${CLOSE_OVERLAY_ID}` }), 50);
173
+ setTimeout(() => focusFirstChild(element, {
174
+ priority: [['input', 'textarea', 'select', 'other', 'button']],
175
+ ...(ignoreFirstFocusOnCloseButton ? { ignore: `#${CLOSE_OVERLAY_ID}` } : {}),
176
+ }), 50);
119
177
  }
120
- hideOverlay(element) {
121
- element?.setAttribute('class', '');
178
+ hideOverlay(element, manageClasses = true) {
179
+ if (manageClasses)
180
+ element?.setAttribute('class', '');
122
181
  this.setInteractivity(element, false);
123
182
  this.setMainContentInteractivity(true);
124
183
  }
184
+ /**
185
+ * Shows the backdrop. The element passed as parameter must be a child of backdrop. Some accessibility features will be attached to
186
+ * the element.
187
+ *
188
+ * Consider using the component <Backdrop> from this library instead of calling this function directly.
189
+ * @param element the element to show inside the backdrop. It must already be a child of the backdrop.
190
+ */
191
+ showBackdrop(element) {
192
+ this.showOverlay(element, [], true, false);
193
+ }
194
+ /**
195
+ * Closes the backdrop. The element passed as parameter must be a child of backdrop. Some accessibility features will be run on the
196
+ * element.
197
+ *
198
+ * Consider using the component <Backdrop> from this library instead of calling this function directly.
199
+ * @param element the element showing inside the backdrop. It must be a child of the backdrop.
200
+ */
201
+ closeBackdrop(element) {
202
+ this.hideOverlay(element, false);
203
+ const lastActiveElement = this.lastActiveElement;
204
+ lastActiveElement?.focus?.();
205
+ }
206
+ /**
207
+ * @returns true if the modal is currently opened. False otherwise.
208
+ */
125
209
  isModalOpen() {
126
210
  return this.elements?.modal?.classList.contains('visible') ?? false;
127
211
  }
212
+ /**
213
+ * @returns the number of modals currently tracked.
214
+ */
215
+ getNumberOfOpenModals() {
216
+ return this.modals.length;
217
+ }
218
+ /**
219
+ * @returns the number of right panels currently tracked.
220
+ */
221
+ getNumberOfOpenRightPanels() {
222
+ return this.panels.length;
223
+ }
224
+ /**
225
+ * @returns true if the right panel is currently opened. False otherwise.
226
+ */
128
227
  isRightPanelOpen() {
129
228
  return this.elements?.rightPanel?.classList.contains('visible') ?? false;
130
229
  }
230
+ /**
231
+ * @returns true if the bottom dialog is currently opened. False otherwise.
232
+ */
131
233
  isBottomDialogOpen() {
132
234
  return this.elements?.bottomDialog?.classList.contains('visible') ?? false;
133
235
  }
134
- showCustomModal(content, { size = 'medium', onClose } = {}) {
236
+ /**
237
+ * Opens a modal with custom content.
238
+ *
239
+ * Attention: the modal state must be declared within the modal. If the state is declared outside the modal, its content won't be updated
240
+ * accordingly. To force an update of an outside state, you need to call `showCustomModal` again with the new state value.
241
+ *
242
+ * @param content a react element with the modal content.
243
+ * @param options the modal options {@link CustomModalOptions}.
244
+ */
245
+ showCustomModal(content, { size = 'medium', onClose, ignoreFirstFocusOnCloseButton = true, stack = false, id } = {}) {
135
246
  if (!this.elements?.modal)
136
247
  throw new ElementNotFound('modal', elementIds.modal);
137
248
  if (!this.setContent.modal)
138
249
  throw new LayoutError('unable to show modal, because it has not been setup yet.');
139
- this.onModalClose = onClose;
140
- this.setContent.modal(content);
141
- this.showOverlay(this.elements.modal, [size]);
250
+ const modal = { element: content, onClose, size, stack, id };
251
+ const currentModalSize = last(this.modals)?.size;
252
+ this.setContent.modal(stack ? [...this.modals, modal] : [modal]);
253
+ // we should remove the previous size, if any, before showing the modal
254
+ if (currentModalSize)
255
+ this.elements.modal.classList.remove(currentModalSize);
256
+ this.showOverlay(this.elements.modal, [size], true, true, ignoreFirstFocusOnCloseButton);
142
257
  }
143
- showModal({ size, ...props }) {
144
- this.showCustomModal(_jsx(OverlayContent, { ...props, onClose: () => this.closeModal(), type: "modal" }), { size, onClose: props.onClose });
258
+ /**
259
+ * Opens a modal.
260
+ *
261
+ * Attention: the modal state must be declared within the modal. If the state is declared outside the modal, its content won't be updated
262
+ * accordingly. To force an update of an outside state, you need to call `showModal` again with the new state value.
263
+ *
264
+ * @param options the modal options: {@link OverlayContentProps} & { size: {@link ModalSize} }.
265
+ */
266
+ showModal({ size, ignoreFirstFocusOnCloseButton, stack, onGoBack, id, ...props }) {
267
+ const handleBack = onGoBack ?? ((stack && this.modals.length >= 1) ? () => this.popModal() : undefined);
268
+ this.showCustomModal(_jsx(OverlayContent, { ...props, onGoBack: handleBack, onClose: () => this.closeModal(), type: "modal" }), { size, onClose: props.onClose, ignoreFirstFocusOnCloseButton, stack, id });
145
269
  }
146
- showDialog(options) {
270
+ showDialog({ ignoreFirstFocusOnCloseButton = false, options, size = 'small' }) {
147
271
  let dialogResult = false;
148
272
  return new Promise((resolve, reject) => {
149
273
  try {
150
- this.showCustomModal(_jsx(Dialog, { ...options, onCancel: () => this.closeModal(), onConfirm: () => {
151
- dialogResult = true;
152
- this.closeModal();
153
- } }), { size: 'small', onClose: () => resolve(dialogResult) });
274
+ if (options.type === 'panel') {
275
+ this.showCustomRightPanel(_jsx(Dialog, { ...options, onCancel: () => this.closeModal(), onConfirm: () => {
276
+ dialogResult = true;
277
+ this.closeModal();
278
+ } }), { size: size, onClose: () => resolve(dialogResult) });
279
+ }
280
+ else {
281
+ this.showCustomModal(_jsx(Dialog, { ...options, onCancel: () => this.closeModal(), onConfirm: () => {
282
+ dialogResult = true;
283
+ this.closeModal();
284
+ } }), { size, onClose: () => resolve(dialogResult), ignoreFirstFocusOnCloseButton });
285
+ }
154
286
  }
155
287
  catch (error) {
156
288
  reject(error);
157
289
  }
158
290
  });
159
291
  }
160
- confirm({ confirm, cancel, ...options }) {
292
+ /**
293
+ * Shows a confirmation dialog and returns a promise that resolves as soon as the dialog is closed. The result of the promise is true if
294
+ * the user confirms and false otherwise.
295
+ *
296
+ * If you need the user to type something to confirm the action, use the property `validate` in the options parameter.
297
+ * @param options the dialog options and its size: {@link DialogOptions}.
298
+ * @returns a promise that resolves with the user's answer.
299
+ */
300
+ confirm({ confirm, cancel, size, ...options }) {
161
301
  const t = getDictionary();
162
- return this.showDialog({ ...options, confirm: confirm || t.confirm, cancel: cancel || t.cancel });
302
+ return this.showDialog({
303
+ ignoreFirstFocusOnCloseButton: !!options.validation,
304
+ size,
305
+ options: {
306
+ ...options,
307
+ confirm: confirm || t.confirm,
308
+ cancel: cancel || t.cancel,
309
+ },
310
+ });
163
311
  }
312
+ /**
313
+ * Shows an alert dialog and returns a promise that resolves as soon as the dialog is closed.
314
+ *
315
+ * @param options the dialog options: {@link AlertOptions}.
316
+ * @returns a promise that resolves to undefined as soon as the dialog is closed.
317
+ */
164
318
  async alert({ confirm, showButton = true, ...options }) {
165
319
  const t = getDictionary();
166
- await this.showDialog({ ...options, confirm: showButton ? (confirm || t.confirm) : undefined });
320
+ await this.showDialog({
321
+ ignoreFirstFocusOnCloseButton: !!options.validation,
322
+ options: {
323
+ ...options,
324
+ confirm: showButton ? (confirm || t.confirm) : undefined,
325
+ },
326
+ });
167
327
  }
168
- showBottomDialog({ message, cancel, confirm }) {
328
+ /**
329
+ * Shows a message at the bottom of the window and asks the user to confirm or decline it. The return value is a promise that resolves as
330
+ * soon as the user presses one of the buttons. The result of the promise is true if the user confirms and false otherwise.
331
+ *
332
+ * Differently than `confirm` and `alert`, this message can only be closed if the user clicks one of the buttons or `closeBottomDialog`
333
+ * is called.
334
+ *
335
+ * @param options the dialog options: {@link BottomDialogOptions}.
336
+ * @returns a promise that resolves with the user's answer.
337
+ */
338
+ showBottomDialog({ children, cancel, confirm }) {
169
339
  if (!this.elements?.bottomDialog)
170
340
  throw new ElementNotFound('bottom dialog', elementIds.bottomDialog);
171
341
  if (!this.setContent.bottomDialog)
172
342
  throw new LayoutError('unable to show bottom dialog, because it has not been setup yet.');
173
343
  return new Promise((resolve) => {
174
- this.setContent.bottomDialog?.(_jsxs(_Fragment, { children: [message, _jsxs("div", { className: "btn-group", children: [cancel && _jsx(Button, { onClick: () => resolve(false), colorScheme: "light", appearance: "outlined", children: cancel }), confirm && _jsx(Button, { onClick: () => resolve(true), colorScheme: "light", children: confirm })] })] }));
175
- this.showOverlay(this.elements?.bottomDialog, undefined, false);
344
+ this.setContent.bottomDialog?.(_jsxs(_Fragment, { children: [children, _jsxs("div", { className: "btn-group", children: [cancel && _jsx(Button, { onClick: () => resolve(false), colorScheme: "light", appearance: "outlined", children: cancel }), confirm && _jsx(Button, { onClick: () => resolve(true), colorScheme: "light", children: confirm })] })] }));
345
+ this.showOverlay(this.elements?.bottomDialog, undefined, false, true, true);
176
346
  });
177
347
  }
178
- showCustomRightPanel(content, { size = 'medium', onClose } = {}) {
348
+ /**
349
+ * Opens a right panel with custom content.
350
+ *
351
+ * Attention: the right panel state must be declared within the right panel. If the state is declared outside the right panel, its content
352
+ * won't be updated accordingly. To force an update of an outside state, you need to call `showCustomRightPanel` again with the new state
353
+ * value.
354
+ *
355
+ * @param content a react element with the modal content.
356
+ * @param options the modal options {@link CustomModalOptions}.
357
+ */
358
+ showCustomRightPanel(content, { size = 'medium', onClose, ignoreFirstFocusOnCloseButton = true, stack = false, id } = {}) {
179
359
  if (!this.elements?.rightPanel)
180
360
  throw new ElementNotFound('right panel overlay', elementIds.rightPanel);
181
361
  if (!this.setContent.rightPanel)
182
362
  throw new LayoutError('unable to show right panel overlay, because it has not been setup yet.');
183
- this.onModalClose = onClose;
184
- this.setContent.rightPanel(content);
185
- this.elements?.rightPanel.classList.add(size);
363
+ const panel = { element: content, onClose, size, stack, id };
364
+ const currentPanelSize = last(this.modals)?.size;
365
+ this.setContent.rightPanel(stack ? [...this.panels, panel] : [panel]);
366
+ // we should remove the previous size, if any, before showing the panel
367
+ if (currentPanelSize)
368
+ this.elements.rightPanel.classList.remove(currentPanelSize);
186
369
  setTimeout(() => {
187
- this.showOverlay(this.elements?.rightPanel);
370
+ this.showOverlay(this.elements?.rightPanel, [size], true, true, ignoreFirstFocusOnCloseButton);
188
371
  });
189
372
  }
190
- showRightPanel({ size, ...props }) {
191
- this.showCustomRightPanel(_jsx(OverlayContent, { ...props, onClose: () => this.closeRightPanel(), type: "panel" }), { size, onClose: props.onClose });
192
- }
193
373
  /**
374
+ * Opens a right panel.
375
+ *
376
+ * Attention: the right panel state must be declared within the right panel. If the state is declared outside the right panel, its content
377
+ * won't be updated accordingly. To force an update of an outside state, you need to call `showRightPanel` again with the new state value.
378
+ *
379
+ * @param options the modal options: {@link OverlayContentProps} & { size: {@link ModalSize} }.
380
+ */
381
+ showRightPanel({ size, ignoreFirstFocusOnCloseButton, stack, onGoBack, id, ...props }) {
382
+ const handleBack = onGoBack ?? ((stack && this.panels.length >= 1) ? () => this.popRightPanel() : undefined);
383
+ this.showCustomRightPanel(_jsx(OverlayContent, { ...props, onGoBack: handleBack, onClose: () => this.closeRightPanel(), type: "panel" }), { size, onClose: props.onClose, ignoreFirstFocusOnCloseButton, stack, id });
384
+ }
385
+ /*
194
386
  * Focus the element that had focus before the last overlay was opened. If the element is not visible anymore, another one that makes
195
387
  * sense (accessibility-wise) is focused.
196
388
  */
@@ -198,59 +390,158 @@ class LayoutOverlayManager {
198
390
  focusAccessibleElement(this.lastActiveElement);
199
391
  this.lastActiveElement = null;
200
392
  }
393
+ /**
394
+ * Closes all opened modals.
395
+ * @param runCloseListener whether or not to run the function `onClose` passed to `showModal` or `showCustomModal`. Defaults to true.
396
+ */
201
397
  closeModal(runCloseListener = true) {
202
398
  this.elements?.modal?.classList.remove('visible');
203
- this.elements?.backdrop?.setAttribute('class', '');
204
- if (runCloseListener && this.onModalClose) {
205
- const onClose = this.onModalClose;
206
- // setting it to undefined before running it prevents nested calls to closeModal from generating infinite loops.
207
- this.onModalClose = undefined;
208
- onClose();
399
+ const shouldHideBackdrop = this.panels.length === 0;
400
+ if (shouldHideBackdrop)
401
+ this.elements?.backdrop?.setAttribute('class', '');
402
+ if (runCloseListener) {
403
+ this.modals.forEach((modal) => {
404
+ const onClose = modal.onClose;
405
+ // setting it to undefined before running it prevents nested calls to closeModal from generating infinite loops.
406
+ modal.onClose = undefined;
407
+ onClose?.();
408
+ });
209
409
  }
210
410
  const animationMS = parseFloat(valueOfLayoutVar('--modal-animation-duration')) * 1000;
211
411
  setTimeout(() => {
212
- if (this.elements?.backdrop?.classList.contains('visible')) {
412
+ if (shouldHideBackdrop && this.elements?.backdrop?.classList.contains('visible')) {
213
413
  // eslint-disable-next-line no-console
214
414
  console.warn(multipleCallsWarning('modal', animationMS));
215
415
  this.elements?.modal?.classList.remove('visible');
216
416
  }
217
417
  if (this.setContent.modal)
218
- this.setContent.modal(undefined);
219
- this.hideOverlay(this.elements?.modal);
418
+ this.setContent.modal([]);
419
+ if (shouldHideBackdrop)
420
+ this.hideOverlay(this.elements?.modal);
220
421
  this.focusLastActiveElement();
221
422
  }, animationMS);
222
423
  }
424
+ /**
425
+ * Closes the top-most modal in the stack. Will behave like `closeModal` if only a single modal exists in the stack.
426
+ * @param amount number of modals to pop. Defaults to 1.
427
+ * @param runCloseListener whether or not to run the function `onClose` passed to `showModal` or `showCustomModal`. Defaults to true.
428
+ */
429
+ popModal(amount = 1, runCloseListener = true) {
430
+ if (amount <= 0)
431
+ return;
432
+ if (this.modals.length <= amount)
433
+ return this.closeModal(runCloseListener);
434
+ for (let i = 0; i < amount; i++) {
435
+ const modalToClose = this.modals.pop(); // "!": because of the second "if", the array can't have less than "amount + 1" elements
436
+ if (runCloseListener)
437
+ modalToClose.onClose?.();
438
+ this.elements?.modal?.classList.remove(modalToClose.size);
439
+ }
440
+ const topModal = last(this.modals); // "!": because of the second "if", the array can't have less than "amount + 1" elements
441
+ this.elements?.modal?.classList.add(topModal.size);
442
+ this.setContent.modal?.([...this.modals]);
443
+ }
444
+ /**
445
+ * Close all modals in the stack of modal until the modal with the given id is found. If no modal with the given id is found, nothing
446
+ * happens.
447
+ * @param id the id of the modal to pop to.
448
+ * @param inclusive when true, the modal with the given id is also popped. Defaults to false.
449
+ */
450
+ popModalTo(id, inclusive = false) {
451
+ const index = this.modals.findIndex(m => m.id === id);
452
+ if (index >= 0)
453
+ this.popModal(this.modals.length - index - (inclusive ? 0 : 1));
454
+ }
455
+ /**
456
+ * Closes all opened right panels.
457
+ * @param runCloseListener whether or not to run the function `onClose` passed to `showRightPanel` or `showCustomRightPanel`. Defaults to
458
+ * true.
459
+ */
223
460
  closeRightPanel(runCloseListener = true) {
224
461
  this.elements?.rightPanel?.classList.remove('visible');
225
- this.elements?.backdrop?.setAttribute('class', '');
226
- if (runCloseListener && this.onModalClose) {
227
- const onClose = this.onModalClose;
228
- // setting it to undefined before running it prevents nested calls to closeRightPanel from generating infinite loops.
229
- this.onModalClose = undefined;
230
- onClose();
462
+ const shouldHideBackdrop = this.modals.length === 0;
463
+ if (shouldHideBackdrop)
464
+ this.elements?.backdrop?.setAttribute('class', '');
465
+ if (runCloseListener) {
466
+ this.panels.forEach((panel) => {
467
+ const onClose = panel.onClose;
468
+ // setting it to undefined before running it prevents nested calls to closeRightPanel from generating infinite loops.
469
+ panel.onClose = undefined;
470
+ onClose?.();
471
+ });
231
472
  }
232
473
  const animationMS = parseFloat(valueOfLayoutVar('--right-panel-animation-duration')) * 1000;
233
474
  setTimeout(() => {
234
- if (this.elements?.backdrop?.classList.contains('visible')) {
475
+ if (shouldHideBackdrop && this.elements?.backdrop?.classList.contains('visible')) {
235
476
  // eslint-disable-next-line no-console
236
477
  console.warn(multipleCallsWarning('rightPanel', animationMS));
237
478
  this.elements?.rightPanel?.classList.remove('visible');
238
479
  }
239
480
  if (this.setContent.rightPanel)
240
- this.setContent.rightPanel(undefined);
241
- this.hideOverlay(this.elements?.rightPanel);
481
+ this.setContent.rightPanel([]);
482
+ if (shouldHideBackdrop)
483
+ this.hideOverlay(this.elements?.rightPanel);
242
484
  this.focusLastActiveElement();
243
485
  }, animationMS);
244
486
  }
487
+ /**
488
+ * Closes the top-most modal in the stack. Will behave like `closeModal` if only a single modal exists in the stack.
489
+ * @param runCloseListener whether or not to run the function `onClose` passed to `showModal` or `showCustomModal`. Defaults to true.
490
+ */
491
+ popRightPanel(amount = 1, runCloseListener = true) {
492
+ if (amount <= 0)
493
+ return;
494
+ if (this.panels.length <= amount)
495
+ return this.closeRightPanel(runCloseListener);
496
+ for (let i = 0; i < amount; i++) {
497
+ const panelToClose = this.panels.pop(); // "!": because of the second "if", the array can't have less than "amount + 1" elements
498
+ if (runCloseListener)
499
+ panelToClose.onClose?.();
500
+ this.elements?.rightPanel?.classList.remove(panelToClose.size);
501
+ }
502
+ const topPanel = last(this.panels); // "!": because of the second "if", the array can't have less than "amount + 1" elements
503
+ this.elements?.rightPanel?.classList.add(topPanel.size);
504
+ this.setContent.rightPanel?.([...this.panels]);
505
+ }
506
+ /**
507
+ * Close all right panels in the stack of panels until the panel with the given id is found. If no panel with the given id is found,
508
+ * nothing happens.
509
+ * @param id the id of the right panel to pop to.
510
+ * @param inclusive when true, the right panel with the given id is also popped. Defaults to false.
511
+ */
512
+ popRightPanelTo(id, inclusive = false) {
513
+ const index = this.panels.findIndex(m => m.id === id);
514
+ if (index >= 0)
515
+ this.popRightPanel(this.panels.length - index - (inclusive ? 0 : 1));
516
+ }
517
+ /**
518
+ * Closes the bottom dialog if it's open.
519
+ */
245
520
  closeBottomDialog() {
246
521
  this.hideOverlay(this.elements?.bottomDialog);
247
522
  }
523
+ /**
524
+ * Verifies if the HTML element passed as parameter is inside the modal.
525
+ * @param element the HTML element to check.
526
+ * @returns true if `element` is inside the modal; false otherwise.
527
+ */
248
528
  isInsideModal(element) {
249
529
  return !!this.elements?.modal?.contains(element);
250
530
  }
531
+ /**
532
+ * Verifies if the HTML element passed as parameter is inside the right panel.
533
+ * @param element the HTML element to check.
534
+ * @returns true if `element` is inside the right panel; false otherwise.
535
+ */
251
536
  isInsideRightPanel(element) {
252
537
  return !!this.elements?.rightPanel?.contains(element);
253
538
  }
539
+ showToaster(options) {
540
+ return showReactToaster(options);
541
+ }
254
542
  }
543
+ /**
544
+ * Manages overlay components of the layout like: modal, rightPanel, bottomDialog and toaster.
545
+ */
255
546
  export const overlay = new LayoutOverlayManager();
256
547
  //# sourceMappingURL=LayoutOverlayManager.js.map