@stack-spot/portal-layout 0.0.65 → 1.0.0-dev.1768482785050

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,5 +1,5 @@
1
+ import { Action } from '@stack-spot/portal-components/SelectionList'
1
2
  import { ReactElement, ReactNode } from 'react'
2
- import { Action } from '../types'
3
3
 
4
4
  interface BaseMenuItem {
5
5
  hidden?: boolean,
@@ -19,47 +19,111 @@ interface BaseMenuItem {
19
19
  }
20
20
 
21
21
  export interface ItemGroup extends BaseMenuItem {
22
+ /**
23
+ * The label for this group.
24
+ */
22
25
  label: string,
26
+ /**
27
+ * The items in this group.
28
+ */
23
29
  children: MenuItem[],
30
+ /**
31
+ * Whether it should start opened or not.
32
+ */
24
33
  open?: boolean,
34
+ showAsTitle?: boolean,
25
35
  }
26
36
 
27
37
  export interface MenuAction extends Action, BaseMenuItem {
38
+ /**
39
+ * Whether this menu item is currently active or not.
40
+ */
28
41
  active?: boolean,
29
42
  }
30
43
 
31
44
  export type MenuItem = ItemGroup | MenuAction
32
45
 
33
- export interface MenuButton extends Action {
34
- icon?: ReactElement,
35
- }
36
-
37
46
  export interface SelectorItem extends Action {
47
+ /**
48
+ * A unique id for this item.
49
+ */
38
50
  key: string,
51
+ /**
52
+ * An icon to place at the left side of the item.
53
+ */
39
54
  icon?: ReactElement,
40
55
  }
41
56
 
42
57
  export interface Selector {
58
+ /**
59
+ * The current value. Must correspond to a `key` in `options`.
60
+ */
43
61
  value?: string,
62
+ /**
63
+ * A series of options to show in the selector.
64
+ */
44
65
  options: SelectorItem[],
66
+ /**
67
+ * An extra button to show after the list of options.
68
+ */
45
69
  button?: Action,
70
+ /**
71
+ * A title of this selector.
72
+ */
46
73
  title?: string,
74
+ /**
75
+ * A subtitle for this selector.
76
+ */
47
77
  subtitle?: string,
78
+ /**
79
+ * Whether or not the options for this selector are loading.
80
+ */
48
81
  loading?: boolean,
49
82
  }
50
83
 
51
84
  export interface MenuSectionContent {
85
+ /**
86
+ * A link to go back.
87
+ */
52
88
  goBack?: Action,
89
+ /**
90
+ * A title for this menu.
91
+ */
53
92
  title?: string,
93
+ /**
94
+ * A subtitle for this menu.
95
+ */
54
96
  subtitle?: string,
97
+ /**
98
+ * A custom React Node to add right after the menu title.
99
+ */
55
100
  afterTitle?: React.ReactNode,
101
+ /**
102
+ * A page selector.
103
+ */
56
104
  pageSelector?: Selector,
105
+ /**
106
+ * The menu options, may contain subgroups.
107
+ */
57
108
  options?: MenuItem[],
109
+ /**
110
+ * Whether or not the options for this menu are loading.
111
+ */
58
112
  loading?: boolean,
113
+ /**
114
+ * An error to show instead of the menu.
115
+ */
59
116
  error?: string,
60
117
  }
61
118
 
62
119
  export interface MenuSection extends Action {
120
+ /**
121
+ * Type should not be present in menu section items
122
+ */
123
+ type?: never,
124
+ /**
125
+ * The icon for this section.
126
+ */
63
127
  icon: ReactElement,
64
128
  /**
65
129
  * The content or a function that creates the content.
@@ -74,32 +138,173 @@ export interface MenuSection extends Action {
74
138
  * This should be used when the content you want to render is not the default content
75
139
  */
76
140
  customContent?: ReactNode,
141
+ /**
142
+ * Whether or not this section is currently active.
143
+ */
77
144
  active?: boolean,
78
- onOpen?: () => void,
145
+ /**
146
+ * A css class to pass to the <li> tag.
147
+ */
148
+ className?: string,
149
+ hidden?: boolean,
150
+ /**
151
+ * The items in this group. This property will create a accordion to include the items
152
+ */
153
+ children?: MenuSection[],
154
+ /**
155
+ * initial value to accordion when using children prop
156
+ */
157
+ open?: boolean,
158
+ /**
159
+ * Badge to show at the right of the item.
160
+ */
161
+ badge?: ReactElement,
162
+ /**
163
+ * If true, when the section menu is collapsed, if this item has children, it will be replaced by its children and lose the
164
+ * collapse/expand behavior.
165
+ * @default true
166
+ */
167
+ replaceWithChildrenWhenCollapsed?: boolean,
168
+ }
169
+
170
+ export interface MenuSectionCustomItem {
171
+ /**
172
+ * Type to indicate the element is a custom item.
173
+ */
174
+ type: 'custom-element',
175
+ /**
176
+ * Children to be rendered
177
+ */
178
+ children?: ReactNode,
179
+ /**
180
+ * A css class to pass to the <div> tag.
181
+ */
79
182
  className?: string,
183
+ /**
184
+ * A boolean indicating whether or not the element should be visible.
185
+ */
80
186
  hidden?: boolean,
187
+ /**
188
+ * The icon for this section.
189
+ */
190
+ icon: ReactElement,
191
+
192
+ content?: never,
193
+ customContent?: never,
194
+ active?: never,
195
+ open?: never,
196
+ badge?: never,
197
+ label?: never,
198
+ onClick?: never,
199
+ href?: never,
200
+ target?: never,
201
+ lang?: never,
202
+ hrefLang?: never,
203
+ title?: never,
81
204
  }
82
205
 
83
206
  interface BaseMenuProps {
84
- sections?: MenuSection[],
207
+ /**
208
+ * The sections of the menu.
209
+ */
210
+ sections?: (MenuSection | MenuSectionCustomItem)[],
211
+ /**
212
+ * The content of the menu as a React Element. Use this to create anything you want as the menu content, but prefer using `content`
213
+ * instead, which is a predefined menu.
214
+ */
85
215
  customContent?: ReactNode,
216
+ /**
217
+ * Options for the settings button.
218
+ */
86
219
  settings?: {
220
+ /**
221
+ * Whether or not to show the settings button.
222
+ */
223
+ show?: boolean,
224
+ /**
225
+ * A function to call when the button is clicked.
226
+ */
227
+ onClick?: () => void,
228
+ /**
229
+ * A url to go to when the button is clicked.
230
+ */
231
+ href?: string,
232
+ /**
233
+ * Whether or not this button represents the page currently active.
234
+ */
235
+ active?: boolean,
236
+ /**
237
+ * A css class to pass to the button.
238
+ */
239
+ className?: string,
240
+ },
241
+ /**
242
+ * Options for the rate button.
243
+ */
244
+ rateUs?: {
245
+ /**
246
+ * Whether or not to show the rate button.
247
+ */
248
+ show?: boolean,
249
+ /**
250
+ * A function to call when the button is clicked.
251
+ */
252
+ onClick?: () => void,
253
+ /**
254
+ * A url to go to when the button is clicked.
255
+ */
256
+ href?: string,
257
+ /**
258
+ * Whether or not this button represents the page currently active.
259
+ */
260
+ active?: boolean,
261
+ /**
262
+ * A css class to pass to the button.
263
+ */
264
+ className?: string,
265
+ },
266
+ /**
267
+ * Options for the contact us button.
268
+ */
269
+ contactUs?: {
270
+ /**
271
+ * Whether or not to show the rate button.
272
+ */
87
273
  show?: boolean,
274
+ /**
275
+ * A function to call when the button is clicked.
276
+ */
88
277
  onClick?: () => void,
278
+ /**
279
+ * A url to go to when the button is clicked.
280
+ */
89
281
  href?: string,
282
+ /**
283
+ * Whether or not this button represents the page currently active.
284
+ */
90
285
  active?: boolean,
286
+ /**
287
+ * A css class to pass to the button.
288
+ */
91
289
  className?: string,
290
+ /**
291
+ * Target of the URL to open.
292
+ */
293
+ target?: React.AnchorHTMLAttributes<HTMLAnchorElement>['target'],
92
294
  },
93
295
  }
94
296
 
95
297
  export interface MenuPropsWithStaticContent extends BaseMenuProps {
298
+ /**
299
+ * The config for creating the menu content.
300
+ */
96
301
  content?: MenuSectionContent,
97
302
  }
98
303
 
99
304
  export interface MenuPropsWithDynamicContent extends BaseMenuProps {
100
305
  /**
101
- * The function that creates the content. It will be called only when the content is rendered, i.e. only when the content really needs to
102
- * be rendered.
306
+ * The function that creates a config to render a menu content. It will be called only when the content is rendered, i.e. only when the
307
+ * content really needs to be rendered.
103
308
  *
104
309
  * Tip: this function can be a React Hook.
105
310
  */
@@ -108,6 +313,13 @@ export interface MenuPropsWithDynamicContent extends BaseMenuProps {
108
313
  * Identifies each content that might be rendered by the menu. This prevents React Hook errors when the content is a React Hook function.
109
314
  */
110
315
  contentKey: React.Key,
316
+ /**
317
+ * The function that creates a config to render a third level nav menu content. It will be called only when the content is rendered,
318
+ * i.e. only when the content really needs to be rendered.
319
+ *
320
+ * Tip: this function can be a React Hook.
321
+ */
322
+ innerContent?: MenuSectionContent | (() => MenuSectionContent | undefined),
111
323
  }
112
324
 
113
325
  export type MenuProps = MenuPropsWithStaticContent | MenuPropsWithDynamicContent
@@ -0,0 +1,92 @@
1
+ import { theme } from '@stack-spot/portal-theme'
2
+ import React, { ReactNode } from 'react'
3
+ import { styled } from 'styled-components'
4
+ import { NavigationProps, StepNavigation } from './StepNavigation'
5
+ import { StepTitle } from './StepTitle'
6
+ import { useTour } from './hook'
7
+
8
+ interface StepContainerProps {
9
+ children: ReactNode,
10
+ /**
11
+ * The unique identifier for the step.
12
+ */
13
+ stepKey: string,
14
+ /**
15
+ * The title for the step.
16
+ */
17
+ title: string,
18
+ /**
19
+ * The position of the tour overlay related to the content being explained.
20
+ */
21
+ position?: PointingArrowPosition,
22
+ /**
23
+ * The CSS 'right' property to adjust the horizontal position of the overlay.
24
+ */
25
+ right?: React.CSSProperties['right'],
26
+ /**
27
+ * The CSS 'top' property to adjust the vertical position of the overlay.
28
+ */
29
+ top?: React.CSSProperties['top'],
30
+ /**
31
+ * A customizable set of buttons for navigating the tour steps.
32
+ */
33
+ customNavigation?: Omit<NavigationProps, 'stepKey'>,
34
+ }
35
+
36
+ /**
37
+ * Tutorial: the overlay component for showing a step on React Tour.
38
+ * @param props the react props for the component {@link StepContainerProps}.
39
+ */
40
+ export const StepContainer = ({ title, stepKey, customNavigation, position = 'bottom', top, right, children }: StepContainerProps) => {
41
+ const { closeTour } = useTour()
42
+ return (
43
+ <BoxWithPointingArrow $position={position} $top={top} $right={right}>
44
+ <StepTitle title={title} onClose={() => closeTour()} />
45
+ {children}
46
+ <StepNavigation stepKey={stepKey} {...(customNavigation || {})} />
47
+ </BoxWithPointingArrow>
48
+ )
49
+ }
50
+
51
+ export type PointingArrowPosition = 'right' | 'top' | 'left' | 'bottom'
52
+
53
+ const BoxWithPointingArrow = styled.div < {
54
+ $position: PointingArrowPosition,
55
+ $top?: React.CSSProperties['top'],
56
+ $right?: React.CSSProperties['right'],
57
+ } > `
58
+ position: relative;
59
+ width: 100%;
60
+ background-color: ${theme.color.inverse[500]};
61
+ &::after {
62
+ content: '';
63
+ position: absolute;
64
+ border-width: 10px;
65
+ border-style: solid;
66
+ border-color: transparent;
67
+ border-right-color: ${theme.color.inverse[500]};
68
+ ${({ $position, $top }) => $position === 'right' ?
69
+ `
70
+ top: ${$top || '16px'};
71
+ right: 100%;
72
+ ` : ''}
73
+ ${({ $position, $right }) => $position === 'top' ?
74
+ `
75
+ top: 100%;
76
+ right: ${$right || '16px'};
77
+ transform: rotate(-90deg);
78
+ ` : ''}
79
+ ${({ $position, $top }) => $position === 'left' ?
80
+ `
81
+ top: ${$top || '16px'};
82
+ left: 100%;
83
+ transform: rotate(180deg);
84
+ ` : ''}
85
+ ${({ $position, $right }) => $position === 'bottom' ?
86
+ `
87
+ bottom: 100%;
88
+ right: ${$right || '16px'};
89
+ transform: rotate(90deg);
90
+ ` : ''}
91
+ }
92
+ `
@@ -0,0 +1,72 @@
1
+ import { Button, Flex, Text } from '@citric/core'
2
+ import '@stack-spot/portal-theme/dist/theme.css'
3
+ import { useTranslate } from '@stack-spot/portal-translate'
4
+ import { useTour } from './hook'
5
+
6
+ interface CustomNavigationButton {
7
+ /**
8
+ * The text content to render.
9
+ */
10
+ text: string,
11
+ onClick?: () => void,
12
+ }
13
+
14
+ export interface NavigationProps {
15
+ /**
16
+ * The unique identifier of the step.
17
+ */
18
+ stepKey: string,
19
+ /**
20
+ * The text and click handler for the button "next".
21
+ */
22
+ nextButton?: CustomNavigationButton,
23
+ /**
24
+ * The text and click handler for the button "previous".
25
+ */
26
+ prevButton?: CustomNavigationButton,
27
+ }
28
+
29
+ /**
30
+ * Tutorial: the component in a React Tour overlay that shows the next and previous buttons (for step navigation).
31
+ * @param props the react props for the component {@link NavigationProps}.
32
+ */
33
+ export const StepNavigation = ({ stepKey, nextButton, prevButton }: NavigationProps) => {
34
+ const { currentStep, steps, prevStep, finishStep } = useTour()
35
+ const t = useTranslate(translations)
36
+
37
+ return <Flex w={12} px={5} py={2} mt="-1px" bg="inverse.500" justifyContent="space-between" alignItems="center">
38
+ { steps.length > 1 &&
39
+ <Text appearance="microtext1" colorScheme="inverse.contrastText">{currentStep + 1} {t.of} {steps.length}</Text>
40
+ }
41
+ <Flex sx={{ gap: '8px' }}>
42
+ {currentStep >= 1 &&
43
+ <Button sx={{ paddingInline: '20px' }} onClick={() => {
44
+ prevStep?.()
45
+ prevButton?.onClick?.()
46
+ }} size="sm" appearance="text" colorScheme="light">
47
+ {prevButton?.text || t.back}
48
+ </Button>}
49
+ <Button sx={{ paddingInline: '20px' }} onClick={() => {
50
+ nextButton?.onClick?.()
51
+ finishStep(stepKey)
52
+ }} size="sm" colorScheme="light">
53
+ {nextButton?.text || (currentStep < steps.length - 1 ? t.next : t.done)}
54
+ </Button>
55
+ </Flex>
56
+ </Flex>
57
+ }
58
+
59
+ const translations = {
60
+ en: {
61
+ of: 'of',
62
+ back: 'Back',
63
+ next: 'Next',
64
+ done: 'Done',
65
+ },
66
+ pt: {
67
+ of: 'de',
68
+ back: 'Voltar',
69
+ next: 'Próximo',
70
+ done: 'Finalizado',
71
+ },
72
+ }
@@ -0,0 +1,28 @@
1
+ import { Flex, IconBox, Text } from '@citric/core'
2
+ import { TimesMini } from '@citric/icons'
3
+ import { IconButton } from '@citric/ui'
4
+
5
+ interface StepTitleProps {
6
+ /**
7
+ * The step's title.
8
+ */
9
+ title: string,
10
+ /**
11
+ * A function to run once the step is closed.
12
+ */
13
+ onClose?: () => void,
14
+ }
15
+
16
+ /**
17
+ * Tutorial: the component in a React Tour overlay that renders the title.
18
+ * @param props the react props for the component {@link StepTitleProps}.
19
+ */
20
+ export const StepTitle = ({ title, onClose }: StepTitleProps) =>
21
+ <Flex w={12} px={5} py={3} flexWrap="nowrap" justifyContent="space-between" alignItems="center">
22
+ <Text appearance="body2" colorScheme="inverse.contrastText" weight="medium"> {title} </Text>
23
+ <IconButton onClick={onClose} sx={{ r: 'full', p: 0 }} >
24
+ <IconBox size="xs" colorIcon="inverse.contrastText">
25
+ <TimesMini />
26
+ </IconBox>
27
+ </IconButton>
28
+ </Flex>
@@ -0,0 +1,12 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { TourConfigExtra, tourManager } from './manager'
3
+
4
+ export const useTour = () => {
5
+ const [tourConfig, setTourConfig] = useState<TourConfigExtra>(tourManager.config)
6
+
7
+ useEffect(() => tourManager.subscribe((config) => {
8
+ setTourConfig(config)
9
+ }), [])
10
+
11
+ return tourConfig
12
+ }
@@ -0,0 +1,6 @@
1
+
2
+ export { useTour } from './hook'
3
+ export { TourConfig, TourConfigListener, tourManager, TourStep, WelcomeTour } from './manager'
4
+ export { StepContainer } from './StepContainer'
5
+ export { getTourCookie, hasFinishedTourStep, isNewTourStep, StackspotTourStep, tourStepBuilder } from './utils'
6
+
@@ -0,0 +1,119 @@
1
+ import WelcomeTour, { ReactourProps, ReactourStep } from 'reactour'
2
+ import { StackspotTourStep, finishTourStep, isNewTourStep, tourStepBuilder } from './utils'
3
+
4
+ export type TourConfig = Omit<ReactourProps, 'children'>
5
+ export type TourStep = ReactourStep
6
+
7
+ /**
8
+ * Tutorial: the default configuration for a React Tour.
9
+ */
10
+ const defaultTourConfig: TourConfig = Object.freeze({
11
+ steps: [],
12
+ isOpen: true,
13
+ onRequestClose: () => '',
14
+ showButtons: false,
15
+ showNavigation: false,
16
+ showNavigationNumber: false,
17
+ showNumber: false,
18
+ showCloseButton: false,
19
+ disableFocusLock: true,
20
+ })
21
+
22
+
23
+ export type TourConfigExtra = TourConfig & {
24
+ currentStep: number,
25
+ finishStep: (stepSelector: string) => void,
26
+ addStep: (step: StackspotTourStep) => void,
27
+ closeTour: () => void,
28
+ }
29
+
30
+ type TourConfigListener = (config: TourConfigExtra) => void
31
+
32
+
33
+ /**
34
+ * TourManager: provides state management for React Tour.
35
+ */
36
+ class TourManager {
37
+
38
+ private _steps: TourStep[] = []
39
+ private _currentStep = 0
40
+ private observers: TourConfigListener[] = []
41
+
42
+ get config(): TourConfigExtra {
43
+ const config = {
44
+ ...defaultTourConfig,
45
+ goToStep: this._currentStep,
46
+ update: `${this._currentStep}`,
47
+ steps: this._steps,
48
+ isOpen: !!this._steps.length && (this._currentStep < this._steps.length),
49
+ currentStep: this._currentStep,
50
+ nextStep: () => this.nextStep(),
51
+ prevStep: () => this.prevStep(),
52
+ finishStep: (stepSelector: string) => this.finishStep(stepSelector),
53
+ addStep: (step: StackspotTourStep) => this.addStep(step),
54
+ closeTour: () => this.closeTour(),
55
+ }
56
+ return config
57
+ }
58
+
59
+ get currentStep() {
60
+ return this._currentStep
61
+ }
62
+
63
+ get steps() {
64
+ return this._steps
65
+ }
66
+
67
+ addStep(step: StackspotTourStep) {
68
+ this.addRawStep(tourStepBuilder(step))
69
+ }
70
+
71
+ addRawStep(step: TourStep) {
72
+ const stepAlreadyAdded = this._steps.some(it => it.selector == step.selector)
73
+ if (!stepAlreadyAdded && isNewTourStep(step)) {
74
+ this._steps = [...this._steps, step]
75
+ this.notify()
76
+ }
77
+ }
78
+
79
+ nextStep() {
80
+ this._currentStep = this._currentStep + 1
81
+ this.notify()
82
+ }
83
+
84
+ prevStep() {
85
+ this._currentStep = this._currentStep - 1
86
+ this.notify()
87
+ }
88
+
89
+ finishStep(stepSelector: string) {
90
+ finishTourStep(stepSelector)
91
+ this.nextStep()
92
+ }
93
+
94
+ closeTour() {
95
+ this.steps.forEach((step) => step.selector && finishTourStep(step.selector))
96
+ this._currentStep = this.steps.length
97
+ this.notify()
98
+ }
99
+
100
+ subscribe(updateFn: TourConfigListener) {
101
+ this.observers.push(updateFn)
102
+ this.notify()
103
+ return () => this.pullListener(updateFn)
104
+ }
105
+
106
+ private pullListener(updateFn: TourConfigListener) {
107
+ this.observers = this.observers.filter((obs) => obs !== updateFn)
108
+ }
109
+
110
+ private notify() {
111
+ this.observers.forEach((updateFn) => updateFn(this.config))
112
+ }
113
+
114
+ }
115
+
116
+ const tourManager = new TourManager()
117
+
118
+ export { TourConfigListener, WelcomeTour, tourManager }
119
+