@internetarchive/modal-manager 2.0.4 → 2.0.5-webdev-8155.2
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/.editorconfig +29 -29
- package/.github/workflows/ci.yml +40 -30
- package/.github/workflows/gh-pages-main.yml +42 -42
- package/.github/workflows/pr-preview.yml +40 -40
- package/.prettierrc +4 -0
- package/.vscode/extensions.json +10 -0
- package/.vscode/tasks.json +12 -0
- package/LICENSE +661 -661
- package/README.md +139 -139
- package/custom-elements.json +170 -170
- package/demo/app-root.ts +366 -0
- package/dist/demo/app-root.d.ts +22 -0
- package/dist/demo/app-root.js +338 -0
- package/dist/demo/app-root.js.map +1 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +5 -5
- package/dist/src/assets/arrow-left-icon.d.ts +2 -2
- package/dist/src/assets/arrow-left-icon.js +2 -2
- package/dist/src/assets/ia-logo-icon.d.ts +2 -2
- package/dist/src/assets/ia-logo-icon.js +2 -2
- package/dist/src/modal-config.d.ts +104 -104
- package/dist/src/modal-config.js +23 -24
- package/dist/src/modal-config.js.map +1 -1
- package/dist/src/modal-manager-host-bridge-interface.d.ts +12 -12
- package/dist/src/modal-manager-host-bridge-interface.js +1 -1
- package/dist/src/modal-manager-host-bridge.d.ts +34 -34
- package/dist/src/modal-manager-host-bridge.js +62 -62
- package/dist/src/modal-manager-host-bridge.js.map +1 -1
- package/dist/src/modal-manager-interface.d.ts +27 -27
- package/dist/src/modal-manager-interface.js +1 -1
- package/dist/src/modal-manager-mode.d.ts +10 -10
- package/dist/src/modal-manager-mode.js +11 -11
- package/dist/src/modal-manager.d.ts +137 -137
- package/dist/src/modal-manager.js +243 -249
- package/dist/src/modal-manager.js.map +1 -1
- package/dist/src/modal-template.d.ts +41 -41
- package/dist/src/modal-template.js +119 -118
- package/dist/src/modal-template.js.map +1 -1
- package/dist/src/shoelace/active-elements.d.ts +15 -15
- package/dist/src/shoelace/active-elements.js +28 -27
- package/dist/src/shoelace/active-elements.js.map +1 -1
- package/dist/src/shoelace/modal.d.ts +24 -24
- package/dist/src/shoelace/modal.js +130 -131
- package/dist/src/shoelace/modal.js.map +1 -1
- package/dist/src/shoelace/tabbable.d.ts +9 -9
- package/dist/src/shoelace/tabbable.js +168 -169
- package/dist/src/shoelace/tabbable.js.map +1 -1
- package/dist/test/modal-config.test.d.ts +1 -1
- package/dist/test/modal-config.test.js +68 -69
- package/dist/test/modal-config.test.js.map +1 -1
- package/dist/test/modal-manager.test.d.ts +1 -1
- package/dist/test/modal-manager.test.js +306 -309
- package/dist/test/modal-manager.test.js.map +1 -1
- package/dist/test/modal-template.test.d.ts +1 -1
- package/dist/test/modal-template.test.js +158 -167
- package/dist/test/modal-template.test.js.map +1 -1
- package/dist/vite.config.d.ts +2 -2
- package/dist/vite.config.js +22 -22
- package/dist/vitest.config.ci.d.ts +2 -0
- package/dist/vitest.config.ci.js +24 -0
- package/dist/vitest.config.ci.js.map +1 -0
- package/docs/assets/css/main.css +2678 -2678
- package/docs/classes/_src_modal_config_.modalconfig.html +429 -429
- package/docs/classes/_src_modal_manager_.modalmanager.html +7702 -7702
- package/docs/classes/_src_modal_manager_host_bridge_.modalmanagerhostbridge.html +409 -409
- package/docs/classes/_src_modal_template_.modaltemplate.html +7096 -7096
- package/docs/enums/_src_modal_manager_mode_.modalmanagermode.html +196 -196
- package/docs/globals.html +150 -150
- package/docs/index.html +252 -252
- package/docs/interfaces/_src_modal_manager_host_bridge_interface_.modalmanagerhostbridgeinterface.html +210 -210
- package/docs/interfaces/_src_modal_manager_interface_.modalmanagerinterface.html +7095 -7095
- package/docs/modules/_index_.html +208 -208
- package/docs/modules/_src_modal_config_.html +146 -146
- package/docs/modules/_src_modal_manager_.html +146 -146
- package/docs/modules/_src_modal_manager_host_bridge_.html +146 -146
- package/docs/modules/_src_modal_manager_host_bridge_interface_.html +146 -146
- package/docs/modules/_src_modal_manager_interface_.html +146 -146
- package/docs/modules/_src_modal_manager_mode_.html +146 -146
- package/docs/modules/_src_modal_template_.html +146 -146
- package/docs/modules/_test_modal_config_test_.html +106 -106
- package/docs/modules/_test_modal_manager_test_.html +106 -106
- package/docs/modules/_test_modal_template_test_.html +106 -106
- package/eslint.config.mjs +53 -0
- package/index.html +33 -300
- package/package.json +73 -85
- package/renovate.json +7 -7
- package/src/modal-config.ts +14 -14
- package/src/modal-manager-host-bridge.ts +2 -2
- package/src/modal-manager.ts +305 -305
- package/src/modal-template.ts +4 -2
- package/src/shoelace/LICENSE.md +6 -6
- package/src/shoelace/active-elements.ts +3 -2
- package/src/shoelace/modal.ts +5 -5
- package/src/shoelace/tabbable.ts +4 -3
- package/test/modal-config.test.ts +4 -4
- package/test/modal-manager.test.ts +402 -393
- package/test/modal-template.test.ts +42 -35
- package/tsconfig.json +25 -21
- package/vitest.config.ci.ts +27 -0
- package/.eslintrc.js +0 -14
- package/karma.conf.js +0 -24
package/dist/src/modal-config.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration to show a modal
|
|
3
|
-
*
|
|
4
|
-
* @export
|
|
5
|
-
* @class ModalConfig
|
|
6
|
-
*/
|
|
7
|
-
export class ModalConfig {
|
|
8
|
-
constructor(options) {
|
|
9
|
-
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Configuration to show a modal
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @class ModalConfig
|
|
6
|
+
*/
|
|
7
|
+
export class ModalConfig {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.title = options?.title;
|
|
10
|
+
this.subtitle = options?.subtitle;
|
|
11
|
+
this.headline = options?.headline;
|
|
12
|
+
this.message = options?.message;
|
|
13
|
+
this.headerColor = options?.headerColor ?? '#55A183';
|
|
14
|
+
this.bodyColor = options?.bodyColor ?? '#fbfbfd';
|
|
15
|
+
this.showProcessingIndicator = options?.showProcessingIndicator ?? false;
|
|
16
|
+
this.processingImageMode = options?.processingImageMode ?? 'complete';
|
|
17
|
+
this.showCloseButton = options?.showCloseButton ?? true;
|
|
18
|
+
this.showLeftNavButton = options?.showLeftNavButton ?? false;
|
|
19
|
+
this.leftNavButtonText = options?.leftNavButtonText ?? '';
|
|
20
|
+
this.showHeaderLogo = options?.showHeaderLogo ?? true;
|
|
21
|
+
this.closeOnBackdropClick = options?.closeOnBackdropClick ?? true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
25
24
|
//# sourceMappingURL=modal-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-config.js","sourceRoot":"","sources":["../../src/modal-config.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IA8FtB,YAAY,OAcX
|
|
1
|
+
{"version":3,"file":"modal-config.js","sourceRoot":"","sources":["../../src/modal-config.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IA8FtB,YAAY,OAcX;QACC,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,CAAC;QAEhC,IAAI,CAAC,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,SAAS,CAAC;QACrD,IAAI,CAAC,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,SAAS,CAAC;QACjD,IAAI,CAAC,uBAAuB,GAAG,OAAO,EAAE,uBAAuB,IAAI,KAAK,CAAC;QACzE,IAAI,CAAC,mBAAmB,GAAG,OAAO,EAAE,mBAAmB,IAAI,UAAU,CAAC;QACtE,IAAI,CAAC,eAAe,GAAG,OAAO,EAAE,eAAe,IAAI,IAAI,CAAC;QACxD,IAAI,CAAC,iBAAiB,GAAG,OAAO,EAAE,iBAAiB,IAAI,KAAK,CAAC;QAC7D,IAAI,CAAC,iBAAiB,GAAG,OAAO,EAAE,iBAAiB,IAAI,EAAE,CAAC;QAC1D,IAAI,CAAC,cAAc,GAAG,OAAO,EAAE,cAAc,IAAI,IAAI,CAAC;QACtD,IAAI,CAAC,oBAAoB,GAAG,OAAO,EAAE,oBAAoB,IAAI,IAAI,CAAC;IACpE,CAAC;CACF","sourcesContent":["import type { TemplateResult } from 'lit';\n\n/**\n * Configuration to show a modal\n *\n * @export\n * @class ModalConfig\n */\nexport class ModalConfig {\n /**\n * The title that shows in the header\n *\n * @type {(TemplateResult | string | undefined)}\n * @memberof ModalConfig\n */\n title?: TemplateResult | string;\n\n /**\n * The subtitle shown in the header under the title\n *\n * @type {(TemplateResult | string | undefined)}\n * @memberof ModalConfig\n */\n subtitle?: TemplateResult | string;\n\n /**\n * The headline shown at the top of the content section\n *\n * @type {(TemplateResult | string | undefined)}\n * @memberof ModalConfig\n */\n headline?: TemplateResult | string;\n\n /**\n * The text shown below the headline in the content section\n *\n * @type {(TemplateResult | string | undefined)}\n * @memberof ModalConfig\n */\n message?: TemplateResult | string;\n\n /**\n * The background color of the header\n *\n * @memberof ModalConfig\n */\n headerColor: string;\n\n /**\n * The background color of the body\n *\n * @memberof ModalConfig\n */\n bodyColor: string;\n\n /**\n * Show or hide the processing indicator\n *\n * @memberof ModalConfig\n */\n showProcessingIndicator: boolean;\n\n /**\n * Set the processing image mode\n *\n * @memberof ModalConfig\n */\n processingImageMode: 'processing' | 'complete';\n\n /**\n * Show the close button\n *\n * @memberof ModalConfig\n */\n showCloseButton: boolean;\n\n /**\n * Show the left nav button\n *\n * @memberof ModalConfig\n */\n showLeftNavButton: boolean;\n\n /**\n * Left nav button text\n */\n leftNavButtonText: string;\n\n /**\n * Show the close button\n *\n * @memberof ModalConfig\n */\n showHeaderLogo: boolean;\n\n /**\n * Close the modal if the user taps on the background\n *\n * @memberof ModalConfig\n */\n closeOnBackdropClick: boolean;\n\n constructor(options?: {\n title?: TemplateResult | string;\n subtitle?: TemplateResult | string;\n headline?: TemplateResult | string;\n message?: TemplateResult | string;\n headerColor?: string;\n bodyColor?: string;\n showProcessingIndicator?: boolean;\n processingImageMode?: 'processing' | 'complete';\n showCloseButton?: boolean;\n showLeftNavButton?: boolean;\n leftNavButtonText?: string;\n showHeaderLogo?: boolean;\n closeOnBackdropClick?: boolean;\n }) {\n this.title = options?.title;\n this.subtitle = options?.subtitle;\n this.headline = options?.headline;\n this.message = options?.message;\n\n this.headerColor = options?.headerColor ?? '#55A183';\n this.bodyColor = options?.bodyColor ?? '#fbfbfd';\n this.showProcessingIndicator = options?.showProcessingIndicator ?? false;\n this.processingImageMode = options?.processingImageMode ?? 'complete';\n this.showCloseButton = options?.showCloseButton ?? true;\n this.showLeftNavButton = options?.showLeftNavButton ?? false;\n this.leftNavButtonText = options?.leftNavButtonText ?? '';\n this.showHeaderLogo = options?.showHeaderLogo ?? true;\n this.closeOnBackdropClick = options?.closeOnBackdropClick ?? true;\n }\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ModalManagerMode } from './modal-manager-mode';
|
|
2
|
-
/**
|
|
3
|
-
* The ModalManagerHostBridgeInterface is a delegate interface for
|
|
4
|
-
* the host to implement environment-specific changes when the modal
|
|
5
|
-
* is open or closed.
|
|
6
|
-
*
|
|
7
|
-
* A default implementation is provided, but can be overridden if
|
|
8
|
-
* it does not work for the environment.
|
|
9
|
-
*/
|
|
10
|
-
export interface ModalManagerHostBridgeInterface {
|
|
11
|
-
handleModeChange(mode: ModalManagerMode): void;
|
|
12
|
-
}
|
|
1
|
+
import { ModalManagerMode } from './modal-manager-mode';
|
|
2
|
+
/**
|
|
3
|
+
* The ModalManagerHostBridgeInterface is a delegate interface for
|
|
4
|
+
* the host to implement environment-specific changes when the modal
|
|
5
|
+
* is open or closed.
|
|
6
|
+
*
|
|
7
|
+
* A default implementation is provided, but can be overridden if
|
|
8
|
+
* it does not work for the environment.
|
|
9
|
+
*/
|
|
10
|
+
export interface ModalManagerHostBridgeInterface {
|
|
11
|
+
handleModeChange(mode: ModalManagerMode): void;
|
|
12
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=modal-manager-host-bridge-interface.js.map
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { ModalManagerHostBridgeInterface } from './modal-manager-host-bridge-interface';
|
|
2
|
-
import { ModalManagerInterface } from './modal-manager-interface';
|
|
3
|
-
import { ModalManagerMode } from './modal-manager-mode';
|
|
4
|
-
/**
|
|
5
|
-
* The `ModalManagerHostBridge` is a bridge between the `ModalManager` and the
|
|
6
|
-
* host that sets up environment-specific changes when the modal opens and closes.
|
|
7
|
-
*
|
|
8
|
-
* For instance, when the modal opens, this adds a class to the `<body>` tag for styling
|
|
9
|
-
* and adds a `resize` listener to fix a Safari shadow root issue.
|
|
10
|
-
*
|
|
11
|
-
* Consumers can create their own `ModalManagerHostBridgeInterface` classes and pass
|
|
12
|
-
* them into the `ModalManager` if this one does not work for their environment.
|
|
13
|
-
*
|
|
14
|
-
* @export
|
|
15
|
-
* @class ModalManagerHostBridge
|
|
16
|
-
* @implements {ModalManagerHostBridgeInterface}
|
|
17
|
-
*/
|
|
18
|
-
export declare class ModalManagerHostBridge implements ModalManagerHostBridgeInterface {
|
|
19
|
-
private modalManager;
|
|
20
|
-
constructor(modalManager: ModalManagerInterface);
|
|
21
|
-
/**
|
|
22
|
-
* Handle the mode change
|
|
23
|
-
*
|
|
24
|
-
* @private
|
|
25
|
-
* @memberof ModalManager
|
|
26
|
-
*/
|
|
27
|
-
handleModeChange(mode: ModalManagerMode): void;
|
|
28
|
-
private windowResizeThrottler;
|
|
29
|
-
private updateModalContainerHeight;
|
|
30
|
-
private stopDocumentScroll;
|
|
31
|
-
private resumeDocumentScroll;
|
|
32
|
-
private startResizeListener;
|
|
33
|
-
private stopResizeListener;
|
|
34
|
-
}
|
|
1
|
+
import { ModalManagerHostBridgeInterface } from './modal-manager-host-bridge-interface';
|
|
2
|
+
import { ModalManagerInterface } from './modal-manager-interface';
|
|
3
|
+
import { ModalManagerMode } from './modal-manager-mode';
|
|
4
|
+
/**
|
|
5
|
+
* The `ModalManagerHostBridge` is a bridge between the `ModalManager` and the
|
|
6
|
+
* host that sets up environment-specific changes when the modal opens and closes.
|
|
7
|
+
*
|
|
8
|
+
* For instance, when the modal opens, this adds a class to the `<body>` tag for styling
|
|
9
|
+
* and adds a `resize` listener to fix a Safari shadow root issue.
|
|
10
|
+
*
|
|
11
|
+
* Consumers can create their own `ModalManagerHostBridgeInterface` classes and pass
|
|
12
|
+
* them into the `ModalManager` if this one does not work for their environment.
|
|
13
|
+
*
|
|
14
|
+
* @export
|
|
15
|
+
* @class ModalManagerHostBridge
|
|
16
|
+
* @implements {ModalManagerHostBridgeInterface}
|
|
17
|
+
*/
|
|
18
|
+
export declare class ModalManagerHostBridge implements ModalManagerHostBridgeInterface {
|
|
19
|
+
private modalManager;
|
|
20
|
+
constructor(modalManager: ModalManagerInterface);
|
|
21
|
+
/**
|
|
22
|
+
* Handle the mode change
|
|
23
|
+
*
|
|
24
|
+
* @private
|
|
25
|
+
* @memberof ModalManager
|
|
26
|
+
*/
|
|
27
|
+
handleModeChange(mode: ModalManagerMode): void;
|
|
28
|
+
private windowResizeThrottler;
|
|
29
|
+
private updateModalContainerHeight;
|
|
30
|
+
private stopDocumentScroll;
|
|
31
|
+
private resumeDocumentScroll;
|
|
32
|
+
private startResizeListener;
|
|
33
|
+
private stopResizeListener;
|
|
34
|
+
}
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { throttle } from 'throttle-debounce';
|
|
2
|
-
import { ModalManagerMode } from './modal-manager-mode';
|
|
3
|
-
/**
|
|
4
|
-
* The `ModalManagerHostBridge` is a bridge between the `ModalManager` and the
|
|
5
|
-
* host that sets up environment-specific changes when the modal opens and closes.
|
|
6
|
-
*
|
|
7
|
-
* For instance, when the modal opens, this adds a class to the `<body>` tag for styling
|
|
8
|
-
* and adds a `resize` listener to fix a Safari shadow root issue.
|
|
9
|
-
*
|
|
10
|
-
* Consumers can create their own `ModalManagerHostBridgeInterface` classes and pass
|
|
11
|
-
* them into the `ModalManager` if this one does not work for their environment.
|
|
12
|
-
*
|
|
13
|
-
* @export
|
|
14
|
-
* @class ModalManagerHostBridge
|
|
15
|
-
* @implements {ModalManagerHostBridgeInterface}
|
|
16
|
-
*/
|
|
17
|
-
export class ModalManagerHostBridge {
|
|
18
|
-
constructor(modalManager) {
|
|
19
|
-
this.windowResizeThrottler = throttle(100, this.updateModalContainerHeight, { noLeading: false, noTrailing: false }).bind(this);
|
|
20
|
-
this.modalManager = modalManager;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Handle the mode change
|
|
24
|
-
*
|
|
25
|
-
* @private
|
|
26
|
-
* @memberof ModalManager
|
|
27
|
-
*/
|
|
28
|
-
handleModeChange(mode) {
|
|
29
|
-
switch (mode) {
|
|
30
|
-
case ModalManagerMode.Open:
|
|
31
|
-
this.startResizeListener();
|
|
32
|
-
this.stopDocumentScroll();
|
|
33
|
-
break;
|
|
34
|
-
case ModalManagerMode.Closed:
|
|
35
|
-
this.stopResizeListener();
|
|
36
|
-
this.resumeDocumentScroll();
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// This is a workaround for Safari. Safari does not update shadowRoot elements calculated
|
|
41
|
-
// based on the viewport size (ie. `calc(100vh - 10px)`). It does an initial calculation correctly,
|
|
42
|
-
// but resizing the window does not cause the calculation to update. Firefox and Chrome both handle
|
|
43
|
-
// this correctly.
|
|
44
|
-
// It doesn't matter what css variable you set, it is just forcing Safari to do an update.
|
|
45
|
-
// Also note that the value has to change on each update for Safari to do the update,
|
|
46
|
-
// ie. you can't just set a static value.
|
|
47
|
-
updateModalContainerHeight() {
|
|
48
|
-
this.modalManager.style.setProperty('--containerHeight', `${window.innerHeight}px`);
|
|
49
|
-
}
|
|
50
|
-
stopDocumentScroll() {
|
|
51
|
-
document.body.classList.add('modal-manager-open');
|
|
52
|
-
}
|
|
53
|
-
resumeDocumentScroll() {
|
|
54
|
-
document.body.classList.remove('modal-manager-open');
|
|
55
|
-
}
|
|
56
|
-
startResizeListener() {
|
|
57
|
-
window.addEventListener('resize', this.windowResizeThrottler);
|
|
58
|
-
}
|
|
59
|
-
stopResizeListener() {
|
|
60
|
-
window.removeEventListener('resize', this.windowResizeThrottler);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
import { throttle } from 'throttle-debounce';
|
|
2
|
+
import { ModalManagerMode } from './modal-manager-mode';
|
|
3
|
+
/**
|
|
4
|
+
* The `ModalManagerHostBridge` is a bridge between the `ModalManager` and the
|
|
5
|
+
* host that sets up environment-specific changes when the modal opens and closes.
|
|
6
|
+
*
|
|
7
|
+
* For instance, when the modal opens, this adds a class to the `<body>` tag for styling
|
|
8
|
+
* and adds a `resize` listener to fix a Safari shadow root issue.
|
|
9
|
+
*
|
|
10
|
+
* Consumers can create their own `ModalManagerHostBridgeInterface` classes and pass
|
|
11
|
+
* them into the `ModalManager` if this one does not work for their environment.
|
|
12
|
+
*
|
|
13
|
+
* @export
|
|
14
|
+
* @class ModalManagerHostBridge
|
|
15
|
+
* @implements {ModalManagerHostBridgeInterface}
|
|
16
|
+
*/
|
|
17
|
+
export class ModalManagerHostBridge {
|
|
18
|
+
constructor(modalManager) {
|
|
19
|
+
this.windowResizeThrottler = throttle(100, this.updateModalContainerHeight, { noLeading: false, noTrailing: false }).bind(this);
|
|
20
|
+
this.modalManager = modalManager;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Handle the mode change
|
|
24
|
+
*
|
|
25
|
+
* @private
|
|
26
|
+
* @memberof ModalManager
|
|
27
|
+
*/
|
|
28
|
+
handleModeChange(mode) {
|
|
29
|
+
switch (mode) {
|
|
30
|
+
case ModalManagerMode.Open:
|
|
31
|
+
this.startResizeListener();
|
|
32
|
+
this.stopDocumentScroll();
|
|
33
|
+
break;
|
|
34
|
+
case ModalManagerMode.Closed:
|
|
35
|
+
this.stopResizeListener();
|
|
36
|
+
this.resumeDocumentScroll();
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// This is a workaround for Safari. Safari does not update shadowRoot elements calculated
|
|
41
|
+
// based on the viewport size (ie. `calc(100vh - 10px)`). It does an initial calculation correctly,
|
|
42
|
+
// but resizing the window does not cause the calculation to update. Firefox and Chrome both handle
|
|
43
|
+
// this correctly.
|
|
44
|
+
// It doesn't matter what css variable you set, it is just forcing Safari to do an update.
|
|
45
|
+
// Also note that the value has to change on each update for Safari to do the update,
|
|
46
|
+
// ie. you can't just set a static value.
|
|
47
|
+
updateModalContainerHeight() {
|
|
48
|
+
this.modalManager.style.setProperty('--containerHeight', `${window.innerHeight}px`);
|
|
49
|
+
}
|
|
50
|
+
stopDocumentScroll() {
|
|
51
|
+
document.body.classList.add('modal-manager-open');
|
|
52
|
+
}
|
|
53
|
+
resumeDocumentScroll() {
|
|
54
|
+
document.body.classList.remove('modal-manager-open');
|
|
55
|
+
}
|
|
56
|
+
startResizeListener() {
|
|
57
|
+
window.addEventListener('resize', this.windowResizeThrottler);
|
|
58
|
+
}
|
|
59
|
+
stopResizeListener() {
|
|
60
|
+
window.removeEventListener('resize', this.windowResizeThrottler);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
63
|
//# sourceMappingURL=modal-manager-host-bridge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-manager-host-bridge.js","sourceRoot":"","sources":["../../src/modal-manager-host-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,sBAAsB;IAGjC,YAAY,YAAmC;QAuBvC,0BAAqB,GAAyB,QAAQ,CAC5D,GAAG,EACH,IAAI,CAAC,0BAA0B,EAC/B,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CACxC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QA1BX,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,IAAsB;QACrC,QAAQ,IAAI,EAAE;
|
|
1
|
+
{"version":3,"file":"modal-manager-host-bridge.js","sourceRoot":"","sources":["../../src/modal-manager-host-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,sBAAsB;IAGjC,YAAY,YAAmC;QAuBvC,0BAAqB,GAAyB,QAAQ,CAC5D,GAAG,EACH,IAAI,CAAC,0BAA0B,EAC/B,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CACxC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QA1BX,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,IAAsB;QACrC,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,gBAAgB,CAAC,IAAI;gBACxB,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBAC3B,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBAC1B,MAAM;YACR,KAAK,gBAAgB,CAAC,MAAM;gBAC1B,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBAC1B,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAC5B,MAAM;QACV,CAAC;IACH,CAAC;IAQD,yFAAyF;IACzF,mGAAmG;IACnG,mGAAmG;IACnG,kBAAkB;IAClB,0FAA0F;IAC1F,qFAAqF;IACrF,yCAAyC;IACjC,0BAA0B;QAChC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CACjC,mBAAmB,EACnB,GAAG,MAAM,CAAC,WAAW,IAAI,CAC1B,CAAC;IACJ,CAAC;IAEO,kBAAkB;QACxB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACpD,CAAC;IAEO,oBAAoB;QAC1B,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IACvD,CAAC;IAEO,mBAAmB;QACzB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAChE,CAAC;IAEO,kBAAkB;QACxB,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["import { throttle } from 'throttle-debounce';\n\nimport { ModalManagerHostBridgeInterface } from './modal-manager-host-bridge-interface';\nimport { ModalManagerInterface } from './modal-manager-interface';\nimport { ModalManagerMode } from './modal-manager-mode';\n\n/**\n * The `ModalManagerHostBridge` is a bridge between the `ModalManager` and the\n * host that sets up environment-specific changes when the modal opens and closes.\n *\n * For instance, when the modal opens, this adds a class to the `<body>` tag for styling\n * and adds a `resize` listener to fix a Safari shadow root issue.\n *\n * Consumers can create their own `ModalManagerHostBridgeInterface` classes and pass\n * them into the `ModalManager` if this one does not work for their environment.\n *\n * @export\n * @class ModalManagerHostBridge\n * @implements {ModalManagerHostBridgeInterface}\n */\nexport class ModalManagerHostBridge implements ModalManagerHostBridgeInterface {\n private modalManager: ModalManagerInterface;\n\n constructor(modalManager: ModalManagerInterface) {\n this.modalManager = modalManager;\n }\n\n /**\n * Handle the mode change\n *\n * @private\n * @memberof ModalManager\n */\n handleModeChange(mode: ModalManagerMode): void {\n switch (mode) {\n case ModalManagerMode.Open:\n this.startResizeListener();\n this.stopDocumentScroll();\n break;\n case ModalManagerMode.Closed:\n this.stopResizeListener();\n this.resumeDocumentScroll();\n break;\n }\n }\n\n private windowResizeThrottler: throttle<() => void> = throttle(\n 100,\n this.updateModalContainerHeight,\n { noLeading: false, noTrailing: false },\n ).bind(this);\n\n // This is a workaround for Safari. Safari does not update shadowRoot elements calculated\n // based on the viewport size (ie. `calc(100vh - 10px)`). It does an initial calculation correctly,\n // but resizing the window does not cause the calculation to update. Firefox and Chrome both handle\n // this correctly.\n // It doesn't matter what css variable you set, it is just forcing Safari to do an update.\n // Also note that the value has to change on each update for Safari to do the update,\n // ie. you can't just set a static value.\n private updateModalContainerHeight(): void {\n this.modalManager.style.setProperty(\n '--containerHeight',\n `${window.innerHeight}px`,\n );\n }\n\n private stopDocumentScroll(): void {\n document.body.classList.add('modal-manager-open');\n }\n\n private resumeDocumentScroll(): void {\n document.body.classList.remove('modal-manager-open');\n }\n\n private startResizeListener(): void {\n window.addEventListener('resize', this.windowResizeThrottler);\n }\n\n private stopResizeListener(): void {\n window.removeEventListener('resize', this.windowResizeThrottler);\n }\n}\n"]}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
-
import { ModalConfig } from './modal-config';
|
|
3
|
-
import { ModalManagerMode } from './modal-manager-mode';
|
|
4
|
-
export interface ModalManagerInterface extends LitElement {
|
|
5
|
-
/**
|
|
6
|
-
* Get the current modal mode.
|
|
7
|
-
*/
|
|
8
|
-
getMode(): ModalManagerMode;
|
|
9
|
-
/**
|
|
10
|
-
* Show a modal from a given ModalConfig
|
|
11
|
-
*
|
|
12
|
-
* @param config ModalConfig
|
|
13
|
-
* @param customModalContent TemplateResult | undefined
|
|
14
|
-
* @param userClosedModalCallback () => void | undefined an optional callback when the modal is closed
|
|
15
|
-
* @param userPressedLeftNavButtonCallback () => void | undefined an optional callback when the left nav button is pressed
|
|
16
|
-
*/
|
|
17
|
-
showModal(options: {
|
|
18
|
-
config: ModalConfig;
|
|
19
|
-
customModalContent?: TemplateResult;
|
|
20
|
-
userClosedModalCallback?: () => void;
|
|
21
|
-
userPressedLeftNavButtonCallback?: () => void;
|
|
22
|
-
}): Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Close the currently open modal
|
|
25
|
-
*/
|
|
26
|
-
closeModal(): void;
|
|
27
|
-
}
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
import { ModalConfig } from './modal-config';
|
|
3
|
+
import { ModalManagerMode } from './modal-manager-mode';
|
|
4
|
+
export interface ModalManagerInterface extends LitElement {
|
|
5
|
+
/**
|
|
6
|
+
* Get the current modal mode.
|
|
7
|
+
*/
|
|
8
|
+
getMode(): ModalManagerMode;
|
|
9
|
+
/**
|
|
10
|
+
* Show a modal from a given ModalConfig
|
|
11
|
+
*
|
|
12
|
+
* @param config ModalConfig
|
|
13
|
+
* @param customModalContent TemplateResult | undefined
|
|
14
|
+
* @param userClosedModalCallback () => void | undefined an optional callback when the modal is closed
|
|
15
|
+
* @param userPressedLeftNavButtonCallback () => void | undefined an optional callback when the left nav button is pressed
|
|
16
|
+
*/
|
|
17
|
+
showModal(options: {
|
|
18
|
+
config: ModalConfig;
|
|
19
|
+
customModalContent?: TemplateResult;
|
|
20
|
+
userClosedModalCallback?: () => void;
|
|
21
|
+
userPressedLeftNavButtonCallback?: () => void;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Close the currently open modal
|
|
25
|
+
*/
|
|
26
|
+
closeModal(): void;
|
|
27
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=modal-manager-interface.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Various modes the modal can be in
|
|
3
|
-
*
|
|
4
|
-
* @export
|
|
5
|
-
* @enum {number}
|
|
6
|
-
*/
|
|
7
|
-
export declare enum ModalManagerMode {
|
|
8
|
-
Open = "open",
|
|
9
|
-
Closed = "closed"
|
|
10
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Various modes the modal can be in
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @enum {number}
|
|
6
|
+
*/
|
|
7
|
+
export declare enum ModalManagerMode {
|
|
8
|
+
Open = "open",
|
|
9
|
+
Closed = "closed"
|
|
10
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Various modes the modal can be in
|
|
3
|
-
*
|
|
4
|
-
* @export
|
|
5
|
-
* @enum {number}
|
|
6
|
-
*/
|
|
7
|
-
export var ModalManagerMode;
|
|
8
|
-
(function (ModalManagerMode) {
|
|
9
|
-
ModalManagerMode["Open"] = "open";
|
|
10
|
-
ModalManagerMode["Closed"] = "closed";
|
|
11
|
-
})(ModalManagerMode || (ModalManagerMode = {}));
|
|
1
|
+
/**
|
|
2
|
+
* Various modes the modal can be in
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @enum {number}
|
|
6
|
+
*/
|
|
7
|
+
export var ModalManagerMode;
|
|
8
|
+
(function (ModalManagerMode) {
|
|
9
|
+
ModalManagerMode["Open"] = "open";
|
|
10
|
+
ModalManagerMode["Closed"] = "closed";
|
|
11
|
+
})(ModalManagerMode || (ModalManagerMode = {}));
|
|
12
12
|
//# sourceMappingURL=modal-manager-mode.js.map
|