@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,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 {
|
|
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, "
|
|
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:
|
|
65
|
+
value: closeReactToaster
|
|
54
66
|
});
|
|
55
67
|
}
|
|
56
|
-
|
|
57
|
-
this.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
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
|
-
|
|
82
|
-
|
|
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 =
|
|
92
|
-
|
|
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
|
-
|
|
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, {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
140
|
-
this.
|
|
141
|
-
this.
|
|
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
|
-
|
|
144
|
-
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
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({
|
|
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({
|
|
320
|
+
await this.showDialog({
|
|
321
|
+
ignoreFirstFocusOnCloseButton: !!options.validation,
|
|
322
|
+
options: {
|
|
323
|
+
...options,
|
|
324
|
+
confirm: showButton ? (confirm || t.confirm) : undefined,
|
|
325
|
+
},
|
|
326
|
+
});
|
|
167
327
|
}
|
|
168
|
-
|
|
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: [
|
|
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
|
-
|
|
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
|
-
|
|
184
|
-
this.
|
|
185
|
-
this.
|
|
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.
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
this.
|
|
208
|
-
|
|
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(
|
|
219
|
-
|
|
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.
|
|
226
|
-
if (
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
this.
|
|
230
|
-
|
|
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(
|
|
241
|
-
|
|
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
|