@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.
- package/CHANGELOG.md +779 -0
- package/dist/Layout.d.ts +60 -8
- package/dist/Layout.d.ts.map +1 -1
- package/dist/Layout.js +59 -24
- package/dist/Layout.js.map +1 -1
- package/dist/LayoutOverlayManager.d.ts +274 -19
- package/dist/LayoutOverlayManager.d.ts.map +1 -1
- package/dist/LayoutOverlayManager.js +373 -82
- package/dist/LayoutOverlayManager.js.map +1 -1
- package/dist/WelcomeTour.d.ts +2 -0
- package/dist/WelcomeTour.d.ts.map +1 -0
- package/dist/WelcomeTour.js +8 -0
- package/dist/WelcomeTour.js.map +1 -0
- package/dist/components/Backdrop.d.ts +75 -0
- package/dist/components/Backdrop.d.ts.map +1 -0
- package/dist/components/Backdrop.js +69 -0
- package/dist/components/Backdrop.js.map +1 -0
- package/dist/components/Contact/show-contact-modal.d.ts +5 -0
- package/dist/components/Contact/show-contact-modal.d.ts.map +1 -0
- package/dist/components/Contact/show-contact-modal.js +37 -0
- package/dist/components/Contact/show-contact-modal.js.map +1 -0
- package/dist/components/ContactModal.d.ts +1 -0
- package/dist/components/ContactModal.d.ts.map +1 -0
- package/dist/components/ContactModal.js +2 -0
- package/dist/components/ContactModal.js.map +1 -0
- package/dist/components/Dialog.d.ts +54 -7
- package/dist/components/Dialog.d.ts.map +1 -1
- package/dist/components/Dialog.js +8 -2
- package/dist/components/Dialog.js.map +1 -1
- package/dist/components/Header.d.ts +38 -2
- package/dist/components/Header.d.ts.map +1 -1
- package/dist/components/Header.js +9 -4
- package/dist/components/Header.js.map +1 -1
- package/dist/components/NotificationCenter/NotificationPanel.d.ts +3 -0
- package/dist/components/NotificationCenter/NotificationPanel.d.ts.map +1 -0
- package/dist/components/NotificationCenter/NotificationPanel.js +19 -0
- package/dist/components/NotificationCenter/NotificationPanel.js.map +1 -0
- package/dist/components/NotificationCenter/NotificationPanelHeader.d.ts +3 -0
- package/dist/components/NotificationCenter/NotificationPanelHeader.d.ts.map +1 -0
- package/dist/components/NotificationCenter/NotificationPanelHeader.js +16 -0
- package/dist/components/NotificationCenter/NotificationPanelHeader.js.map +1 -0
- package/dist/components/NotificationCenter/NotificationsPanelFooter.d.ts +4 -0
- package/dist/components/NotificationCenter/NotificationsPanelFooter.d.ts.map +1 -0
- package/dist/components/NotificationCenter/NotificationsPanelFooter.js +12 -0
- package/dist/components/NotificationCenter/NotificationsPanelFooter.js.map +1 -0
- package/dist/components/NotificationCenter/dictionary.d.ts +2 -0
- package/dist/components/NotificationCenter/dictionary.d.ts.map +1 -0
- package/dist/components/NotificationCenter/dictionary.js +43 -0
- package/dist/components/NotificationCenter/dictionary.js.map +1 -0
- package/dist/components/NotificationCenter/index.d.ts +2 -0
- package/dist/components/NotificationCenter/index.d.ts.map +1 -0
- package/dist/components/NotificationCenter/index.js +34 -0
- package/dist/components/NotificationCenter/index.js.map +1 -0
- package/dist/components/NotificationCenter/styled.d.ts +3 -0
- package/dist/components/NotificationCenter/styled.d.ts.map +1 -0
- package/dist/components/NotificationCenter/styled.js +74 -0
- package/dist/components/NotificationCenter/styled.js.map +1 -0
- package/dist/components/NotificationCenter/types.d.ts +21 -0
- package/dist/components/NotificationCenter/types.d.ts.map +1 -0
- package/dist/components/NotificationCenter/types.js.map +1 -0
- package/dist/components/NotificationCenter/utils.d.ts +5 -0
- package/dist/components/NotificationCenter/utils.d.ts.map +1 -0
- package/dist/components/NotificationCenter/utils.js +18 -0
- package/dist/components/NotificationCenter/utils.js.map +1 -0
- package/dist/components/OverlayContent.d.ts +27 -1
- package/dist/components/OverlayContent.d.ts.map +1 -1
- package/dist/components/OverlayContent.js +8 -4
- package/dist/components/OverlayContent.js.map +1 -1
- package/dist/components/PortalSwitcher.d.ts +19 -1
- package/dist/components/PortalSwitcher.d.ts.map +1 -1
- package/dist/components/PortalSwitcher.js +16 -31
- package/dist/components/PortalSwitcher.js.map +1 -1
- package/dist/components/PrivacyPolicyMessage/hooks.d.ts +10 -0
- package/dist/components/PrivacyPolicyMessage/hooks.d.ts.map +1 -0
- package/dist/components/PrivacyPolicyMessage/hooks.js +33 -0
- package/dist/components/PrivacyPolicyMessage/hooks.js.map +1 -0
- package/dist/components/PrivacyPolicyMessage/index.d.ts +7 -0
- package/dist/components/PrivacyPolicyMessage/index.d.ts.map +1 -0
- package/dist/components/PrivacyPolicyMessage/index.js +5 -0
- package/dist/components/PrivacyPolicyMessage/index.js.map +1 -0
- package/dist/components/Rate/FeedbackModal.d.ts +8 -0
- package/dist/components/Rate/FeedbackModal.d.ts.map +1 -0
- package/dist/components/Rate/FeedbackModal.js +52 -0
- package/dist/components/Rate/FeedbackModal.js.map +1 -0
- package/dist/components/Rate/hook.d.ts +3 -0
- package/dist/components/Rate/hook.d.ts.map +1 -0
- package/dist/components/Rate/hook.js +48 -0
- package/dist/components/Rate/hook.js.map +1 -0
- package/dist/components/Rate/index.d.ts +10 -0
- package/dist/components/Rate/index.d.ts.map +1 -0
- package/dist/components/Rate/index.js +16 -0
- package/dist/components/Rate/index.js.map +1 -0
- package/dist/components/Rate/on-nps-submit.d.ts +7 -0
- package/dist/components/Rate/on-nps-submit.d.ts.map +1 -0
- package/dist/components/Rate/on-nps-submit.js +8 -0
- package/dist/components/Rate/on-nps-submit.js.map +1 -0
- package/dist/components/Rate/show-rate-us-modals.d.ts +17 -0
- package/dist/components/Rate/show-rate-us-modals.d.ts.map +1 -0
- package/dist/components/Rate/show-rate-us-modals.js +14 -0
- package/dist/components/Rate/show-rate-us-modals.js.map +1 -0
- package/dist/components/Rate/utils.d.ts +2 -0
- package/dist/components/Rate/utils.d.ts.map +1 -0
- package/dist/components/Rate/utils.js +10 -0
- package/dist/components/Rate/utils.js.map +1 -0
- package/dist/components/Toaster.d.ts +35 -0
- package/dist/components/Toaster.d.ts.map +1 -1
- package/dist/components/Toaster.js +32 -4
- package/dist/components/Toaster.js.map +1 -1
- package/dist/components/TypeForm/hook.d.ts +2 -0
- package/dist/components/TypeForm/hook.d.ts.map +1 -0
- package/dist/components/TypeForm/hook.js +11 -0
- package/dist/components/TypeForm/hook.js.map +1 -0
- package/dist/components/TypeForm/index.d.ts +6 -0
- package/dist/components/TypeForm/index.d.ts.map +1 -0
- package/dist/components/TypeForm/index.js +23 -0
- package/dist/components/TypeForm/index.js.map +1 -0
- package/dist/components/TypeForm/show-typeform-modal.d.ts +5 -0
- package/dist/components/TypeForm/show-typeform-modal.d.ts.map +1 -0
- package/dist/components/TypeForm/show-typeform-modal.js +11 -0
- package/dist/components/TypeForm/show-typeform-modal.js.map +1 -0
- package/dist/components/TypeForm/utils.d.ts +2 -0
- package/dist/components/TypeForm/utils.d.ts.map +1 -0
- package/dist/components/TypeForm/utils.js +9 -0
- package/dist/components/TypeForm/utils.js.map +1 -0
- package/dist/components/UserMenu.d.ts +19 -2
- package/dist/components/UserMenu.d.ts.map +1 -1
- package/dist/components/UserMenu.js +12 -6
- package/dist/components/UserMenu.js.map +1 -1
- package/dist/components/error/ErrorBoundary.d.ts +25 -4
- package/dist/components/error/ErrorBoundary.d.ts.map +1 -1
- package/dist/components/error/ErrorBoundary.js +10 -1
- package/dist/components/error/ErrorBoundary.js.map +1 -1
- package/dist/components/error/ErrorManager.d.ts +22 -6
- package/dist/components/error/ErrorManager.d.ts.map +1 -1
- package/dist/components/error/ErrorManager.js +21 -1
- package/dist/components/error/ErrorManager.js.map +1 -1
- package/dist/components/error/SilentErrorBoundary.d.ts +26 -5
- package/dist/components/error/SilentErrorBoundary.d.ts.map +1 -1
- package/dist/components/error/SilentErrorBoundary.js +10 -0
- package/dist/components/error/SilentErrorBoundary.js.map +1 -1
- package/dist/components/menu/MenuContent.d.ts +20 -4
- package/dist/components/menu/MenuContent.d.ts.map +1 -1
- package/dist/components/menu/MenuContent.js +89 -88
- package/dist/components/menu/MenuContent.js.map +1 -1
- package/dist/components/menu/MenuSectionGroup.d.ts +2 -0
- package/dist/components/menu/MenuSectionGroup.d.ts.map +1 -0
- package/dist/components/menu/MenuSectionGroup.js +121 -0
- package/dist/components/menu/MenuSectionGroup.js.map +1 -0
- package/dist/components/menu/MenuSections.d.ts +17 -0
- package/dist/components/menu/MenuSections.d.ts.map +1 -1
- package/dist/components/menu/MenuSections.js +159 -39
- package/dist/components/menu/MenuSections.js.map +1 -1
- package/dist/components/menu/PageSelector.d.ts +5 -0
- package/dist/components/menu/PageSelector.d.ts.map +1 -1
- package/dist/components/menu/PageSelector.js +9 -4
- package/dist/components/menu/PageSelector.js.map +1 -1
- package/dist/components/menu/types.d.ts +219 -8
- package/dist/components/menu/types.d.ts.map +1 -1
- package/dist/components/tour/StepContainer.d.ts +37 -0
- package/dist/components/tour/StepContainer.d.ts.map +1 -0
- package/dist/components/tour/StepContainer.js +51 -0
- package/dist/components/tour/StepContainer.js.map +1 -0
- package/dist/components/tour/StepNavigation.d.ts +29 -0
- package/dist/components/tour/StepNavigation.d.ts.map +1 -0
- package/dist/components/tour/StepNavigation.js +37 -0
- package/dist/components/tour/StepNavigation.js.map +1 -0
- package/dist/components/tour/StepTitle.d.ts +17 -0
- package/dist/components/tour/StepTitle.d.ts.map +1 -0
- package/dist/components/tour/StepTitle.js +10 -0
- package/dist/components/tour/StepTitle.js.map +1 -0
- package/dist/components/tour/hook.d.ts +3 -0
- package/dist/components/tour/hook.d.ts.map +1 -0
- package/dist/components/tour/hook.js +10 -0
- package/dist/components/tour/hook.js.map +1 -0
- package/dist/components/tour/index.d.ts +5 -0
- package/dist/components/tour/index.d.ts.map +1 -0
- package/dist/components/tour/index.js +5 -0
- package/dist/components/tour/index.js.map +1 -0
- package/dist/components/tour/manager.d.ts +34 -0
- package/dist/components/tour/manager.d.ts.map +1 -0
- package/dist/components/tour/manager.js +104 -0
- package/dist/components/tour/manager.js.map +1 -0
- package/dist/components/tour/utils.d.ts +67 -0
- package/dist/components/tour/utils.d.ts.map +1 -0
- package/dist/components/tour/utils.js +60 -0
- package/dist/components/tour/utils.js.map +1 -0
- package/dist/components/user-menu-manager.d.ts +13 -0
- package/dist/components/user-menu-manager.d.ts.map +1 -0
- package/dist/components/user-menu-manager.js +36 -0
- package/dist/components/user-menu-manager.js.map +1 -0
- package/dist/dictionary.d.ts +6 -1
- package/dist/dictionary.d.ts.map +1 -1
- package/dist/dictionary.js +7 -2
- package/dist/dictionary.js.map +1 -1
- package/dist/elements.d.ts +7 -0
- package/dist/elements.d.ts.map +1 -1
- package/dist/elements.js +7 -0
- package/dist/elements.js.map +1 -1
- package/dist/index.d.ts +15 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -8
- package/dist/index.js.map +1 -1
- package/dist/layout.css +190 -35
- package/dist/svg/StarFillWithGradient.d.ts +6 -0
- package/dist/svg/StarFillWithGradient.d.ts.map +1 -0
- package/dist/svg/StarFillWithGradient.js +4 -0
- package/dist/svg/StarFillWithGradient.js.map +1 -0
- package/dist/toaster.d.ts +55 -9
- package/dist/toaster.d.ts.map +1 -1
- package/dist/toaster.js +34 -6
- package/dist/toaster.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +6 -69
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +9 -130
- package/dist/utils.js.map +1 -1
- package/package.dev.json +3 -0
- package/package.json +24 -13
- package/package.stg.json +3 -0
- package/readme.md +147 -0
- package/src/Layout.tsx +166 -58
- package/src/LayoutOverlayManager.tsx +499 -85
- package/src/WelcomeTour.tsx +8 -0
- package/src/components/Backdrop.tsx +116 -0
- package/src/components/Contact/show-contact-modal.tsx +71 -0
- package/src/components/Dialog.tsx +58 -9
- package/src/components/Header.tsx +53 -5
- package/src/components/NotificationCenter/NotificationPanel.tsx +40 -0
- package/src/components/NotificationCenter/NotificationPanelHeader.tsx +53 -0
- package/src/components/NotificationCenter/NotificationsPanelFooter.tsx +25 -0
- package/src/components/NotificationCenter/dictionary.ts +44 -0
- package/src/components/NotificationCenter/index.tsx +58 -0
- package/src/components/NotificationCenter/styled.ts +75 -0
- package/src/components/NotificationCenter/types.ts +24 -0
- package/src/components/NotificationCenter/utils.ts +20 -0
- package/src/components/OverlayContent.tsx +40 -5
- package/src/components/PortalSwitcher.tsx +33 -39
- package/src/components/PrivacyPolicyMessage/hooks.tsx +49 -0
- package/src/components/PrivacyPolicyMessage/index.tsx +21 -0
- package/src/components/Rate/FeedbackModal.tsx +86 -0
- package/src/components/Rate/hook.tsx +61 -0
- package/src/components/Rate/index.tsx +36 -0
- package/src/components/Rate/on-nps-submit.ts +18 -0
- package/src/components/Rate/show-rate-us-modals.tsx +29 -0
- package/src/components/Rate/utils.ts +11 -0
- package/src/components/Toaster.tsx +82 -3
- package/src/components/TypeForm/hook.tsx +13 -0
- package/src/components/TypeForm/index.tsx +50 -0
- package/src/components/TypeForm/show-typeform-modal.tsx +10 -0
- package/src/components/TypeForm/utils.ts +8 -0
- package/src/components/UserMenu.tsx +32 -8
- package/src/components/error/ErrorBoundary.tsx +11 -2
- package/src/components/error/ErrorManager.ts +22 -6
- package/src/components/error/SilentErrorBoundary.tsx +12 -2
- package/src/components/menu/MenuContent.tsx +102 -110
- package/src/components/menu/MenuSectionGroup.tsx +121 -0
- package/src/components/menu/MenuSections.tsx +342 -93
- package/src/components/menu/PageSelector.tsx +16 -4
- package/src/components/menu/types.ts +221 -9
- package/src/components/tour/StepContainer.tsx +92 -0
- package/src/components/tour/StepNavigation.tsx +72 -0
- package/src/components/tour/StepTitle.tsx +28 -0
- package/src/components/tour/hook.ts +12 -0
- package/src/components/tour/index.ts +6 -0
- package/src/components/tour/manager.tsx +119 -0
- package/src/components/tour/utils.tsx +119 -0
- package/src/components/user-menu-manager.ts +31 -0
- package/src/dictionary.ts +7 -2
- package/src/elements.ts +7 -0
- package/src/index.ts +15 -8
- package/src/layout.css +190 -35
- package/src/svg/StarFillWithGradient.tsx +14 -0
- package/src/toaster.tsx +90 -13
- package/src/types.ts +4 -0
- package/src/utils.ts +9 -142
- package/dist/components/BottomNotification.d.ts +0 -1
- package/dist/components/BottomNotification.d.ts.map +0 -1
- package/dist/components/BottomNotification.js +0 -2
- package/dist/components/BottomNotification.js.map +0 -1
- package/dist/components/BottomPanel.d.ts +0 -1
- package/dist/components/BottomPanel.d.ts.map +0 -1
- package/dist/components/BottomPanel.js +0 -2
- package/dist/components/BottomPanel.js.map +0 -1
- package/dist/components/SelectionList.d.ts +0 -36
- package/dist/components/SelectionList.d.ts.map +0 -1
- package/dist/components/SelectionList.js +0 -140
- package/dist/components/SelectionList.js.map +0 -1
- package/dist/components/error/ErrorFeedback.d.ts +0 -3
- package/dist/components/error/ErrorFeedback.d.ts.map +0 -1
- package/dist/components/error/ErrorFeedback.js +0 -66
- package/dist/components/error/ErrorFeedback.js.map +0 -1
- package/dist/components/menu/use-check-text-overflow.d.ts +0 -6
- package/dist/components/menu/use-check-text-overflow.d.ts.map +0 -1
- package/dist/components/menu/use-check-text-overflow.js +0 -20
- package/dist/components/menu/use-check-text-overflow.js.map +0 -1
- package/dist/components/menu/use-keyboard-controls.d.ts +0 -23
- package/dist/components/menu/use-keyboard-controls.d.ts.map +0 -1
- package/dist/components/menu/use-keyboard-controls.js +0 -49
- package/dist/components/menu/use-keyboard-controls.js.map +0 -1
- package/dist/components/tour/PortalSwitcherStep.d.ts +0 -3
- package/dist/components/tour/PortalSwitcherStep.d.ts.map +0 -1
- package/dist/components/tour/PortalSwitcherStep.js +0 -29
- package/dist/components/tour/PortalSwitcherStep.js.map +0 -1
- package/dist/components/types.d.ts +0 -15
- package/dist/components/types.d.ts.map +0 -1
- package/dist/components/types.js.map +0 -1
- package/dist/layout-context.d.ts +0 -10
- package/dist/layout-context.d.ts.map +0 -1
- package/dist/layout-context.js +0 -11
- package/dist/layout-context.js.map +0 -1
- package/dist/svg/AI.d.ts +0 -6
- package/dist/svg/AI.d.ts.map +0 -1
- package/dist/svg/AI.js +0 -9
- package/dist/svg/AI.js.map +0 -1
- package/dist/svg/EDP.d.ts +0 -6
- package/dist/svg/EDP.d.ts.map +0 -1
- package/dist/svg/EDP.js +0 -5
- package/dist/svg/EDP.js.map +0 -1
- package/dist/svg/Forbidden.d.ts +0 -6
- package/dist/svg/Forbidden.d.ts.map +0 -1
- package/dist/svg/Forbidden.js +0 -4
- package/dist/svg/Forbidden.js.map +0 -1
- package/dist/svg/HUB.d.ts +0 -6
- package/dist/svg/HUB.d.ts.map +0 -1
- package/dist/svg/HUB.js +0 -5
- package/dist/svg/HUB.js.map +0 -1
- package/dist/svg/Logo.d.ts +0 -2
- package/dist/svg/Logo.d.ts.map +0 -1
- package/dist/svg/Logo.js +0 -4
- package/dist/svg/Logo.js.map +0 -1
- package/dist/svg/NotFound.d.ts +0 -6
- package/dist/svg/NotFound.d.ts.map +0 -1
- package/dist/svg/NotFound.js +0 -4
- package/dist/svg/NotFound.js.map +0 -1
- package/dist/svg/ServerError.d.ts +0 -6
- package/dist/svg/ServerError.d.ts.map +0 -1
- package/dist/svg/ServerError.js +0 -4
- package/dist/svg/ServerError.js.map +0 -1
- package/dist/svg/Unauthenticated.d.ts +0 -6
- package/dist/svg/Unauthenticated.d.ts.map +0 -1
- package/dist/svg/Unauthenticated.js +0 -4
- package/dist/svg/Unauthenticated.js.map +0 -1
- package/src/components/BottomPanel.tsx +0 -0
- package/src/components/SelectionList.tsx +0 -272
- package/src/components/error/ErrorFeedback.tsx +0 -114
- package/src/components/menu/use-check-text-overflow.tsx +0 -26
- package/src/components/menu/use-keyboard-controls.tsx +0 -70
- package/src/components/tour/PortalSwitcherStep.tsx +0 -36
- package/src/components/types.ts +0 -15
- package/src/layout-context.tsx +0 -22
- package/src/svg/AI.tsx +0 -37
- package/src/svg/EDP.tsx +0 -35
- package/src/svg/Forbidden.tsx +0 -22
- package/src/svg/HUB.tsx +0 -35
- package/src/svg/Logo.tsx +0 -35
- package/src/svg/NotFound.tsx +0 -16
- package/src/svg/ServerError.tsx +0 -33
- package/src/svg/Unauthenticated.tsx +0 -16
- /package/dist/components/{types.js → NotificationCenter/types.js} +0 -0
- /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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
+
|