@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.
Files changed (101) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +40 -30
  3. package/.github/workflows/gh-pages-main.yml +42 -42
  4. package/.github/workflows/pr-preview.yml +40 -40
  5. package/.prettierrc +4 -0
  6. package/.vscode/extensions.json +10 -0
  7. package/.vscode/tasks.json +12 -0
  8. package/LICENSE +661 -661
  9. package/README.md +139 -139
  10. package/custom-elements.json +170 -170
  11. package/demo/app-root.ts +366 -0
  12. package/dist/demo/app-root.d.ts +22 -0
  13. package/dist/demo/app-root.js +338 -0
  14. package/dist/demo/app-root.js.map +1 -0
  15. package/dist/index.d.ts +7 -7
  16. package/dist/index.js +5 -5
  17. package/dist/src/assets/arrow-left-icon.d.ts +2 -2
  18. package/dist/src/assets/arrow-left-icon.js +2 -2
  19. package/dist/src/assets/ia-logo-icon.d.ts +2 -2
  20. package/dist/src/assets/ia-logo-icon.js +2 -2
  21. package/dist/src/modal-config.d.ts +104 -104
  22. package/dist/src/modal-config.js +23 -24
  23. package/dist/src/modal-config.js.map +1 -1
  24. package/dist/src/modal-manager-host-bridge-interface.d.ts +12 -12
  25. package/dist/src/modal-manager-host-bridge-interface.js +1 -1
  26. package/dist/src/modal-manager-host-bridge.d.ts +34 -34
  27. package/dist/src/modal-manager-host-bridge.js +62 -62
  28. package/dist/src/modal-manager-host-bridge.js.map +1 -1
  29. package/dist/src/modal-manager-interface.d.ts +27 -27
  30. package/dist/src/modal-manager-interface.js +1 -1
  31. package/dist/src/modal-manager-mode.d.ts +10 -10
  32. package/dist/src/modal-manager-mode.js +11 -11
  33. package/dist/src/modal-manager.d.ts +137 -137
  34. package/dist/src/modal-manager.js +243 -249
  35. package/dist/src/modal-manager.js.map +1 -1
  36. package/dist/src/modal-template.d.ts +41 -41
  37. package/dist/src/modal-template.js +119 -118
  38. package/dist/src/modal-template.js.map +1 -1
  39. package/dist/src/shoelace/active-elements.d.ts +15 -15
  40. package/dist/src/shoelace/active-elements.js +28 -27
  41. package/dist/src/shoelace/active-elements.js.map +1 -1
  42. package/dist/src/shoelace/modal.d.ts +24 -24
  43. package/dist/src/shoelace/modal.js +130 -131
  44. package/dist/src/shoelace/modal.js.map +1 -1
  45. package/dist/src/shoelace/tabbable.d.ts +9 -9
  46. package/dist/src/shoelace/tabbable.js +168 -169
  47. package/dist/src/shoelace/tabbable.js.map +1 -1
  48. package/dist/test/modal-config.test.d.ts +1 -1
  49. package/dist/test/modal-config.test.js +68 -69
  50. package/dist/test/modal-config.test.js.map +1 -1
  51. package/dist/test/modal-manager.test.d.ts +1 -1
  52. package/dist/test/modal-manager.test.js +306 -309
  53. package/dist/test/modal-manager.test.js.map +1 -1
  54. package/dist/test/modal-template.test.d.ts +1 -1
  55. package/dist/test/modal-template.test.js +158 -167
  56. package/dist/test/modal-template.test.js.map +1 -1
  57. package/dist/vite.config.d.ts +2 -2
  58. package/dist/vite.config.js +22 -22
  59. package/dist/vitest.config.ci.d.ts +2 -0
  60. package/dist/vitest.config.ci.js +24 -0
  61. package/dist/vitest.config.ci.js.map +1 -0
  62. package/docs/assets/css/main.css +2678 -2678
  63. package/docs/classes/_src_modal_config_.modalconfig.html +429 -429
  64. package/docs/classes/_src_modal_manager_.modalmanager.html +7702 -7702
  65. package/docs/classes/_src_modal_manager_host_bridge_.modalmanagerhostbridge.html +409 -409
  66. package/docs/classes/_src_modal_template_.modaltemplate.html +7096 -7096
  67. package/docs/enums/_src_modal_manager_mode_.modalmanagermode.html +196 -196
  68. package/docs/globals.html +150 -150
  69. package/docs/index.html +252 -252
  70. package/docs/interfaces/_src_modal_manager_host_bridge_interface_.modalmanagerhostbridgeinterface.html +210 -210
  71. package/docs/interfaces/_src_modal_manager_interface_.modalmanagerinterface.html +7095 -7095
  72. package/docs/modules/_index_.html +208 -208
  73. package/docs/modules/_src_modal_config_.html +146 -146
  74. package/docs/modules/_src_modal_manager_.html +146 -146
  75. package/docs/modules/_src_modal_manager_host_bridge_.html +146 -146
  76. package/docs/modules/_src_modal_manager_host_bridge_interface_.html +146 -146
  77. package/docs/modules/_src_modal_manager_interface_.html +146 -146
  78. package/docs/modules/_src_modal_manager_mode_.html +146 -146
  79. package/docs/modules/_src_modal_template_.html +146 -146
  80. package/docs/modules/_test_modal_config_test_.html +106 -106
  81. package/docs/modules/_test_modal_manager_test_.html +106 -106
  82. package/docs/modules/_test_modal_template_test_.html +106 -106
  83. package/eslint.config.mjs +53 -0
  84. package/index.html +33 -300
  85. package/package.json +73 -85
  86. package/renovate.json +7 -7
  87. package/src/modal-config.ts +14 -14
  88. package/src/modal-manager-host-bridge.ts +2 -2
  89. package/src/modal-manager.ts +305 -305
  90. package/src/modal-template.ts +4 -2
  91. package/src/shoelace/LICENSE.md +6 -6
  92. package/src/shoelace/active-elements.ts +3 -2
  93. package/src/shoelace/modal.ts +5 -5
  94. package/src/shoelace/tabbable.ts +4 -3
  95. package/test/modal-config.test.ts +4 -4
  96. package/test/modal-manager.test.ts +402 -393
  97. package/test/modal-template.test.ts +42 -35
  98. package/tsconfig.json +25 -21
  99. package/vitest.config.ci.ts +27 -0
  100. package/.eslintrc.js +0 -14
  101. package/karma.conf.js +0 -24
@@ -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
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
10
- this.title = options === null || options === void 0 ? void 0 : options.title;
11
- this.subtitle = options === null || options === void 0 ? void 0 : options.subtitle;
12
- this.headline = options === null || options === void 0 ? void 0 : options.headline;
13
- this.message = options === null || options === void 0 ? void 0 : options.message;
14
- this.headerColor = (_a = options === null || options === void 0 ? void 0 : options.headerColor) !== null && _a !== void 0 ? _a : '#55A183';
15
- this.bodyColor = (_b = options === null || options === void 0 ? void 0 : options.bodyColor) !== null && _b !== void 0 ? _b : '#fbfbfd';
16
- this.showProcessingIndicator = (_c = options === null || options === void 0 ? void 0 : options.showProcessingIndicator) !== null && _c !== void 0 ? _c : false;
17
- this.processingImageMode = (_d = options === null || options === void 0 ? void 0 : options.processingImageMode) !== null && _d !== void 0 ? _d : 'complete';
18
- this.showCloseButton = (_e = options === null || options === void 0 ? void 0 : options.showCloseButton) !== null && _e !== void 0 ? _e : true;
19
- this.showLeftNavButton = (_f = options === null || options === void 0 ? void 0 : options.showLeftNavButton) !== null && _f !== void 0 ? _f : false;
20
- this.leftNavButtonText = (_g = options === null || options === void 0 ? void 0 : options.leftNavButtonText) !== null && _g !== void 0 ? _g : '';
21
- this.showHeaderLogo = (_h = options === null || options === void 0 ? void 0 : options.showHeaderLogo) !== null && _h !== void 0 ? _h : true;
22
- this.closeOnBackdropClick = (_j = options === null || options === void 0 ? void 0 : options.closeOnBackdropClick) !== null && _j !== void 0 ? _j : true;
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;;QACC,IAAI,CAAC,KAAK,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC;QAEhC,IAAI,CAAC,WAAW,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,mCAAI,SAAS,CAAC;QACrD,IAAI,CAAC,SAAS,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,mCAAI,SAAS,CAAC;QACjD,IAAI,CAAC,uBAAuB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,uBAAuB,mCAAI,KAAK,CAAC;QACzE,IAAI,CAAC,mBAAmB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,mBAAmB,mCAAI,UAAU,CAAC;QACtE,IAAI,CAAC,eAAe,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,mCAAI,IAAI,CAAC;QACxD,IAAI,CAAC,iBAAiB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,mCAAI,KAAK,CAAC;QAC7D,IAAI,CAAC,iBAAiB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,mCAAI,EAAE,CAAC;QAC1D,IAAI,CAAC,cAAc,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,mCAAI,IAAI,CAAC;QACtD,IAAI,CAAC,oBAAoB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,oBAAoB,mCAAI,IAAI,CAAC;IACpE,CAAC;CACF","sourcesContent":["import { 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 | undefined)}\n * @memberof ModalConfig\n */\n title?: TemplateResult;\n\n /**\n * The subtitle shown in the header under the title\n *\n * @type {(TemplateResult | undefined)}\n * @memberof ModalConfig\n */\n subtitle?: TemplateResult;\n\n /**\n * The headline shown at the top of the content section\n *\n * @type {(TemplateResult | undefined)}\n * @memberof ModalConfig\n */\n headline?: TemplateResult;\n\n /**\n * The text shown below the headline in the content section\n *\n * @type {(TemplateResult | undefined)}\n * @memberof ModalConfig\n */\n message?: TemplateResult;\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, currently `processing` or `complete`\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;\n subtitle?: TemplateResult;\n headline?: TemplateResult;\n message?: TemplateResult;\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
+ {"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;YACZ,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;SACT;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
+ {"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