@molecule/app-ui-angular 1.0.6 → 1.1.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/README.md +11710 -1117
- package/dist/components/accordion.component.d.ts +114 -0
- package/dist/components/accordion.component.d.ts.map +1 -0
- package/dist/components/accordion.component.js +286 -0
- package/dist/components/accordion.component.js.map +1 -0
- package/dist/components/alert.component.d.ts +81 -37
- package/dist/components/alert.component.d.ts.map +1 -1
- package/dist/components/alert.component.js +232 -146
- package/dist/components/alert.component.js.map +1 -1
- package/dist/components/auth-guard.component.d.ts +94 -0
- package/dist/components/auth-guard.component.d.ts.map +1 -0
- package/dist/components/auth-guard.component.js +212 -0
- package/dist/components/auth-guard.component.js.map +1 -0
- package/dist/components/avatar.component.d.ts +97 -0
- package/dist/components/avatar.component.d.ts.map +1 -0
- package/dist/components/avatar.component.js +216 -0
- package/dist/components/avatar.component.js.map +1 -0
- package/dist/components/badge.component.d.ts +27 -12
- package/dist/components/badge.component.d.ts.map +1 -1
- package/dist/components/badge.component.js +47 -47
- package/dist/components/badge.component.js.map +1 -1
- package/dist/components/button.component.d.ts +96 -14
- package/dist/components/button.component.d.ts.map +1 -1
- package/dist/components/button.component.js +232 -87
- package/dist/components/button.component.js.map +1 -1
- package/dist/components/card.component.d.ts +135 -0
- package/dist/components/card.component.d.ts.map +1 -0
- package/dist/components/card.component.js +291 -0
- package/dist/components/card.component.js.map +1 -0
- package/dist/components/checkbox.component.d.ts +97 -29
- package/dist/components/checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox.component.js +222 -117
- package/dist/components/checkbox.component.js.map +1 -1
- package/dist/components/confirm-button.component.d.ts +130 -0
- package/dist/components/confirm-button.component.d.ts.map +1 -0
- package/dist/components/confirm-button.component.js +322 -0
- package/dist/components/confirm-button.component.js.map +1 -0
- package/dist/components/confirm-dialog.component.d.ts +60 -0
- package/dist/components/confirm-dialog.component.d.ts.map +1 -0
- package/dist/components/confirm-dialog.component.js +152 -0
- package/dist/components/confirm-dialog.component.js.map +1 -0
- package/dist/components/controlled-checked.directive.d.ts +45 -0
- package/dist/components/controlled-checked.directive.d.ts.map +1 -0
- package/dist/components/controlled-checked.directive.js +74 -0
- package/dist/components/controlled-checked.directive.js.map +1 -0
- package/dist/components/dropdown.component.d.ts +313 -0
- package/dist/components/dropdown.component.d.ts.map +1 -0
- package/dist/components/dropdown.component.js +919 -0
- package/dist/components/dropdown.component.js.map +1 -0
- package/dist/components/empty-state.component.d.ts +73 -0
- package/dist/components/empty-state.component.d.ts.map +1 -0
- package/dist/components/empty-state.component.js +180 -0
- package/dist/components/empty-state.component.js.map +1 -0
- package/dist/components/floating-input.component.d.ts +86 -0
- package/dist/components/floating-input.component.d.ts.map +1 -0
- package/dist/components/floating-input.component.js +167 -0
- package/dist/components/floating-input.component.js.map +1 -0
- package/dist/components/form-field.component.d.ts +111 -0
- package/dist/components/form-field.component.d.ts.map +1 -0
- package/dist/components/form-field.component.js +300 -0
- package/dist/components/form-field.component.js.map +1 -0
- package/dist/components/form.component.d.ts +77 -0
- package/dist/components/form.component.d.ts.map +1 -0
- package/dist/components/form.component.js +222 -0
- package/dist/components/form.component.js.map +1 -0
- package/dist/components/icon.component.d.ts +85 -0
- package/dist/components/icon.component.d.ts.map +1 -0
- package/dist/components/icon.component.js +187 -0
- package/dist/components/icon.component.js.map +1 -0
- package/dist/components/index.d.ts +49 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +49 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/input.component.d.ts +157 -54
- package/dist/components/input.component.d.ts.map +1 -1
- package/dist/components/input.component.js +437 -222
- package/dist/components/input.component.js.map +1 -1
- package/dist/components/label.component.d.ts +29 -0
- package/dist/components/label.component.d.ts.map +1 -0
- package/dist/components/label.component.js +60 -0
- package/dist/components/label.component.js.map +1 -0
- package/dist/components/language-picker.component.d.ts +124 -0
- package/dist/components/language-picker.component.d.ts.map +1 -0
- package/dist/components/language-picker.component.js +305 -0
- package/dist/components/language-picker.component.js.map +1 -0
- package/dist/components/layout.component.d.ts +167 -0
- package/dist/components/layout.component.d.ts.map +1 -0
- package/dist/components/layout.component.js +364 -0
- package/dist/components/layout.component.js.map +1 -0
- package/dist/components/load-error-banner.component.d.ts +103 -0
- package/dist/components/load-error-banner.component.d.ts.map +1 -0
- package/dist/components/load-error-banner.component.js +263 -0
- package/dist/components/load-error-banner.component.js.map +1 -0
- package/dist/components/modal.component.d.ts +125 -95
- package/dist/components/modal.component.d.ts.map +1 -1
- package/dist/components/modal.component.js +458 -271
- package/dist/components/modal.component.js.map +1 -1
- package/dist/components/molecule/alert.component.d.ts +77 -0
- package/dist/components/molecule/alert.component.d.ts.map +1 -0
- package/dist/components/molecule/alert.component.js +229 -0
- package/dist/components/molecule/alert.component.js.map +1 -0
- package/dist/components/molecule/badge.component.d.ts +27 -0
- package/dist/components/molecule/badge.component.d.ts.map +1 -0
- package/dist/components/molecule/badge.component.js +79 -0
- package/dist/components/molecule/badge.component.js.map +1 -0
- package/dist/components/molecule/button.component.d.ts +38 -0
- package/dist/components/molecule/button.component.d.ts.map +1 -0
- package/dist/components/molecule/button.component.js +137 -0
- package/dist/components/molecule/button.component.js.map +1 -0
- package/dist/components/molecule/checkbox.component.d.ts +53 -0
- package/dist/components/molecule/checkbox.component.d.ts.map +1 -0
- package/dist/components/molecule/checkbox.component.js +166 -0
- package/dist/components/molecule/checkbox.component.js.map +1 -0
- package/dist/components/molecule/index.d.ts +18 -0
- package/dist/components/molecule/index.d.ts.map +1 -0
- package/dist/components/molecule/index.js +18 -0
- package/dist/components/molecule/index.js.map +1 -0
- package/dist/components/molecule/input.component.d.ts +93 -0
- package/dist/components/molecule/input.component.d.ts.map +1 -0
- package/dist/components/molecule/input.component.js +314 -0
- package/dist/components/molecule/input.component.js.map +1 -0
- package/dist/components/molecule/modal.component.d.ts +148 -0
- package/dist/components/molecule/modal.component.d.ts.map +1 -0
- package/dist/components/molecule/modal.component.js +382 -0
- package/dist/components/molecule/modal.component.js.map +1 -0
- package/dist/components/molecule/radio-group.component.d.ts +63 -0
- package/dist/components/molecule/radio-group.component.d.ts.map +1 -0
- package/dist/components/molecule/radio-group.component.js +208 -0
- package/dist/components/molecule/radio-group.component.js.map +1 -0
- package/dist/components/molecule/select.component.d.ts +72 -0
- package/dist/components/molecule/select.component.d.ts.map +1 -0
- package/dist/components/molecule/select.component.js +274 -0
- package/dist/components/molecule/select.component.js.map +1 -0
- package/dist/components/molecule/spinner.component.d.ts +42 -0
- package/dist/components/molecule/spinner.component.d.ts.map +1 -0
- package/dist/components/molecule/spinner.component.js +122 -0
- package/dist/components/molecule/spinner.component.js.map +1 -0
- package/dist/components/molecule/switch.component.d.ts +54 -0
- package/dist/components/molecule/switch.component.d.ts.map +1 -0
- package/dist/components/molecule/switch.component.js +148 -0
- package/dist/components/molecule/switch.component.js.map +1 -0
- package/dist/components/molecule/toast.component.d.ts +98 -0
- package/dist/components/molecule/toast.component.d.ts.map +1 -0
- package/dist/components/molecule/toast.component.js +305 -0
- package/dist/components/molecule/toast.component.js.map +1 -0
- package/dist/components/molecule/tooltip.component.d.ts +77 -0
- package/dist/components/molecule/tooltip.component.d.ts.map +1 -0
- package/dist/components/molecule/tooltip.component.js +316 -0
- package/dist/components/molecule/tooltip.component.js.map +1 -0
- package/dist/components/optimistic-toggle-button.component.d.ts +125 -0
- package/dist/components/optimistic-toggle-button.component.d.ts.map +1 -0
- package/dist/components/optimistic-toggle-button.component.js +296 -0
- package/dist/components/optimistic-toggle-button.component.js.map +1 -0
- package/dist/components/page-header.component.d.ts +77 -0
- package/dist/components/page-header.component.d.ts.map +1 -0
- package/dist/components/page-header.component.js +225 -0
- package/dist/components/page-header.component.js.map +1 -0
- package/dist/components/page-shell.component.d.ts +101 -0
- package/dist/components/page-shell.component.d.ts.map +1 -0
- package/dist/components/page-shell.component.js +221 -0
- package/dist/components/page-shell.component.js.map +1 -0
- package/dist/components/pagination.component.d.ts +137 -0
- package/dist/components/pagination.component.d.ts.map +1 -0
- package/dist/components/pagination.component.js +419 -0
- package/dist/components/pagination.component.js.map +1 -0
- package/dist/components/panel-close.component.d.ts +43 -0
- package/dist/components/panel-close.component.d.ts.map +1 -0
- package/dist/components/panel-close.component.js +75 -0
- package/dist/components/panel-close.component.js.map +1 -0
- package/dist/components/progress.component.d.ts +84 -0
- package/dist/components/progress.component.d.ts.map +1 -0
- package/dist/components/progress.component.js +219 -0
- package/dist/components/progress.component.js.map +1 -0
- package/dist/components/prompt-dialog.component.d.ts +121 -0
- package/dist/components/prompt-dialog.component.d.ts.map +1 -0
- package/dist/components/prompt-dialog.component.js +332 -0
- package/dist/components/prompt-dialog.component.js.map +1 -0
- package/dist/components/radio-group.component.d.ts +66 -34
- package/dist/components/radio-group.component.d.ts.map +1 -1
- package/dist/components/radio-group.component.js +157 -134
- package/dist/components/radio-group.component.js.map +1 -1
- package/dist/components/responsive-app-shell.component.d.ts +408 -0
- package/dist/components/responsive-app-shell.component.d.ts.map +1 -0
- package/dist/components/responsive-app-shell.component.js +1144 -0
- package/dist/components/responsive-app-shell.component.js.map +1 -0
- package/dist/components/select.component.d.ts +135 -38
- package/dist/components/select.component.d.ts.map +1 -1
- package/dist/components/select.component.js +373 -181
- package/dist/components/select.component.js.map +1 -1
- package/dist/components/separator.component.d.ts +39 -0
- package/dist/components/separator.component.d.ts.map +1 -0
- package/dist/components/separator.component.js +73 -0
- package/dist/components/separator.component.js.map +1 -0
- package/dist/components/sidebar-user-card.component.d.ts +106 -0
- package/dist/components/sidebar-user-card.component.d.ts.map +1 -0
- package/dist/components/sidebar-user-card.component.js +277 -0
- package/dist/components/sidebar-user-card.component.js.map +1 -0
- package/dist/components/skeleton.component.d.ts +100 -0
- package/dist/components/skeleton.component.d.ts.map +1 -0
- package/dist/components/skeleton.component.js +214 -0
- package/dist/components/skeleton.component.js.map +1 -0
- package/dist/components/spinner.component.d.ts +36 -19
- package/dist/components/spinner.component.d.ts.map +1 -1
- package/dist/components/spinner.component.js +69 -71
- package/dist/components/spinner.component.js.map +1 -1
- package/dist/components/switch.component.d.ts +72 -29
- package/dist/components/switch.component.d.ts.map +1 -1
- package/dist/components/switch.component.js +168 -95
- package/dist/components/switch.component.js.map +1 -1
- package/dist/components/table.component.d.ts +193 -0
- package/dist/components/table.component.d.ts.map +1 -0
- package/dist/components/table.component.js +550 -0
- package/dist/components/table.component.js.map +1 -0
- package/dist/components/tabs.component.d.ts +140 -0
- package/dist/components/tabs.component.d.ts.map +1 -0
- package/dist/components/tabs.component.js +390 -0
- package/dist/components/tabs.component.js.map +1 -0
- package/dist/components/template-outlet.directive.d.ts +50 -0
- package/dist/components/template-outlet.directive.d.ts.map +1 -0
- package/dist/components/template-outlet.directive.js +81 -0
- package/dist/components/template-outlet.directive.js.map +1 -0
- package/dist/components/textarea.component.d.ts +151 -0
- package/dist/components/textarea.component.d.ts.map +1 -0
- package/dist/components/textarea.component.js +340 -0
- package/dist/components/textarea.component.js.map +1 -0
- package/dist/components/theme-toggle.component.d.ts +58 -0
- package/dist/components/theme-toggle.component.d.ts.map +1 -0
- package/dist/components/theme-toggle.component.js +124 -0
- package/dist/components/theme-toggle.component.js.map +1 -0
- package/dist/components/toast.component.d.ts +237 -49
- package/dist/components/toast.component.d.ts.map +1 -1
- package/dist/components/toast.component.js +636 -201
- package/dist/components/toast.component.js.map +1 -1
- package/dist/components/tooltip.component.d.ts +95 -45
- package/dist/components/tooltip.component.d.ts.map +1 -1
- package/dist/components/tooltip.component.js +372 -221
- package/dist/components/tooltip.component.js.map +1 -1
- package/dist/components/user-menu-popover.component.d.ts +283 -0
- package/dist/components/user-menu-popover.component.d.ts.map +1 -0
- package/dist/components/user-menu-popover.component.js +646 -0
- package/dist/components/user-menu-popover.component.js.map +1 -0
- package/dist/components/user-menu.component.d.ts +95 -0
- package/dist/components/user-menu.component.d.ts.map +1 -0
- package/dist/components/user-menu.component.js +218 -0
- package/dist/components/user-menu.component.js.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-is-desktop.d.ts +22 -0
- package/dist/hooks/use-is-desktop.d.ts.map +1 -0
- package/dist/hooks/use-is-desktop.js +37 -0
- package/dist/hooks/use-is-desktop.js.map +1 -0
- package/dist/index.d.ts +32 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -17
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utilities/dom-context.d.ts +42 -0
- package/dist/utilities/dom-context.d.ts.map +1 -0
- package/dist/utilities/dom-context.js +66 -0
- package/dist/utilities/dom-context.js.map +1 -0
- package/dist/utilities/focus.d.ts +32 -0
- package/dist/utilities/focus.d.ts.map +1 -0
- package/dist/utilities/focus.js +47 -0
- package/dist/utilities/focus.js.map +1 -0
- package/dist/utilities/form-field-context.d.ts +34 -0
- package/dist/utilities/form-field-context.d.ts.map +1 -0
- package/dist/utilities/form-field-context.js +28 -0
- package/dist/utilities/form-field-context.js.map +1 -0
- package/dist/utilities/form-submit-error.d.ts +17 -0
- package/dist/utilities/form-submit-error.d.ts.map +1 -0
- package/dist/utilities/form-submit-error.js +42 -0
- package/dist/utilities/form-submit-error.js.map +1 -0
- package/dist/utilities/icon-markup.d.ts +17 -0
- package/dist/utilities/icon-markup.d.ts.map +1 -0
- package/dist/utilities/icon-markup.js +46 -0
- package/dist/utilities/icon-markup.js.map +1 -0
- package/dist/utilities/ids.d.ts +15 -0
- package/dist/utilities/ids.d.ts.map +1 -0
- package/dist/utilities/ids.js +19 -0
- package/dist/utilities/ids.js.map +1 -0
- package/dist/utilities/index.d.ts +11 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +11 -0
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/initials.d.ts +13 -0
- package/dist/utilities/initials.d.ts.map +1 -0
- package/dist/utilities/initials.js +23 -0
- package/dist/utilities/initials.js.map +1 -0
- package/dist/utilities/node-value.d.ts +31 -0
- package/dist/utilities/node-value.d.ts.map +1 -0
- package/dist/utilities/node-value.js +37 -0
- package/dist/utilities/node-value.js.map +1 -0
- package/dist/utilities/optimistic-value.d.ts +81 -0
- package/dist/utilities/optimistic-value.d.ts.map +1 -0
- package/dist/utilities/optimistic-value.js +154 -0
- package/dist/utilities/optimistic-value.js.map +1 -0
- package/dist/utilities/render-icon.d.ts +77 -7
- package/dist/utilities/render-icon.d.ts.map +1 -1
- package/dist/utilities/render-icon.js +123 -33
- package/dist/utilities/render-icon.js.map +1 -1
- package/dist/utilities/rest-attrs.d.ts +21 -0
- package/dist/utilities/rest-attrs.d.ts.map +1 -0
- package/dist/utilities/rest-attrs.js +37 -0
- package/dist/utilities/rest-attrs.js.map +1 -0
- package/dist/utilities/style.d.ts +23 -0
- package/dist/utilities/style.d.ts.map +1 -0
- package/dist/utilities/style.js +86 -0
- package/dist/utilities/style.js.map +1 -0
- package/package.json +6 -4
|
@@ -1,375 +1,562 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Modal component (React parity): a `document.body` portal dialog.
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { t } from '@molecule/app-i18n';
|
|
6
|
+
import { Component, ElementRef, EventEmitter, inject, Output, ViewChild, } from '@angular/core';
|
|
7
|
+
import { useTranslation } from '@molecule/app-angular';
|
|
9
8
|
import { getClassMap } from '@molecule/app-ui';
|
|
10
|
-
import {
|
|
9
|
+
import { createScrollLock, getFocusableElements } from '../utilities/focus.js';
|
|
10
|
+
import { MolIconSvg, resolveIcon } from '../utilities/render-icon.js';
|
|
11
|
+
import { moveRestAttributes } from '../utilities/rest-attrs.js';
|
|
12
|
+
import { styleText } from '../utilities/style.js';
|
|
11
13
|
import * as i0 from "@angular/core";
|
|
12
|
-
const _c0 = ["
|
|
13
|
-
const _c1 = ["
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const _c0 = ["overlay"];
|
|
15
|
+
const _c1 = ["wrapper"];
|
|
16
|
+
const _c2 = ["dialog"];
|
|
17
|
+
const _c3 = ["footerSlot"];
|
|
18
|
+
const _c4 = ["*", [["", "slot", "footer"]]];
|
|
19
|
+
const _c5 = ["*", "[slot=footer]"];
|
|
20
|
+
function Modal_Conditional_6_Conditional_3_Template(rf, ctx) { if (rf & 1) {
|
|
21
|
+
const _r1 = i0.ɵɵgetCurrentView();
|
|
22
|
+
i0.ɵɵelementStart(0, "button", 10);
|
|
23
|
+
i0.ɵɵlistener("click", function Modal_Conditional_6_Conditional_3_Template_button_click_0_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.requestCloseFromButton($event)); });
|
|
24
|
+
i0.ɵɵnamespaceSVG();
|
|
25
|
+
i0.ɵɵelement(1, "svg", 11);
|
|
26
|
+
i0.ɵɵelementEnd();
|
|
18
27
|
} if (rf & 2) {
|
|
19
|
-
const ctx_r1 = i0.ɵɵnextContext(
|
|
20
|
-
i0.ɵɵclassMap(ctx_r1.
|
|
28
|
+
const ctx_r1 = i0.ɵɵnextContext(2);
|
|
29
|
+
i0.ɵɵclassMap(ctx_r1.cm().dialogClose);
|
|
30
|
+
i0.ɵɵattribute("aria-label", ctx_r1.closeText());
|
|
21
31
|
i0.ɵɵadvance();
|
|
22
|
-
i0.ɵɵ
|
|
23
|
-
} }
|
|
24
|
-
function MoleculeModal_Conditional_0_Conditional_3_Conditional_2_Template(rf, ctx) { if (rf & 1) {
|
|
25
|
-
i0.ɵɵdomElement(0, "div");
|
|
32
|
+
i0.ɵɵproperty("data", ctx_r1.closeIcon());
|
|
26
33
|
} }
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
i0.ɵɵ
|
|
30
|
-
i0.ɵɵ
|
|
31
|
-
i0.ɵɵ
|
|
32
|
-
i0.ɵɵ
|
|
34
|
+
function Modal_Conditional_6_Template(rf, ctx) { if (rf & 1) {
|
|
35
|
+
i0.ɵɵelementStart(0, "div")(1, "h2", 8);
|
|
36
|
+
i0.ɵɵtext(2);
|
|
37
|
+
i0.ɵɵelementEnd();
|
|
38
|
+
i0.ɵɵconditionalCreate(3, Modal_Conditional_6_Conditional_3_Template, 2, 4, "button", 9);
|
|
39
|
+
i0.ɵɵelementEnd();
|
|
33
40
|
} if (rf & 2) {
|
|
34
|
-
const ctx_r1 = i0.ɵɵnextContext(
|
|
35
|
-
i0.ɵɵclassMap(ctx_r1.
|
|
36
|
-
i0.ɵɵattribute("aria-label", ctx_r1.closeAriaLabel);
|
|
41
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
42
|
+
i0.ɵɵclassMap(ctx_r1.cm().dialogHeader);
|
|
37
43
|
i0.ɵɵadvance();
|
|
38
|
-
i0.ɵɵ
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
i0.ɵɵ
|
|
42
|
-
i0.ɵɵconditionalCreate(1, MoleculeModal_Conditional_0_Conditional_3_Conditional_1_Template, 2, 3, "h2", 4)(2, MoleculeModal_Conditional_0_Conditional_3_Conditional_2_Template, 1, 0, "div");
|
|
43
|
-
i0.ɵɵconditionalCreate(3, MoleculeModal_Conditional_0_Conditional_3_Conditional_3_Template, 2, 4, "button", 5);
|
|
44
|
-
i0.ɵɵdomElementEnd();
|
|
45
|
-
} if (rf & 2) {
|
|
46
|
-
const ctx_r1 = i0.ɵɵnextContext(2);
|
|
47
|
-
i0.ɵɵclassMap(ctx_r1.headerClass);
|
|
44
|
+
i0.ɵɵclassMap(ctx_r1.cm().dialogTitle);
|
|
45
|
+
i0.ɵɵproperty("id", ctx_r1.titleId);
|
|
46
|
+
i0.ɵɵadvance();
|
|
47
|
+
i0.ɵɵtextInterpolate(ctx_r1.title);
|
|
48
48
|
i0.ɵɵadvance();
|
|
49
|
-
i0.ɵɵconditional(ctx_r1.title ? 1 : ctx_r1.showCloseButton ? 2 : -1);
|
|
50
|
-
i0.ɵɵadvance(2);
|
|
51
49
|
i0.ɵɵconditional(ctx_r1.showCloseButton ? 3 : -1);
|
|
52
50
|
} }
|
|
53
|
-
function
|
|
54
|
-
i0.ɵɵ
|
|
55
|
-
i0.ɵɵ
|
|
56
|
-
i0.ɵɵ
|
|
51
|
+
function Modal_Conditional_7_Conditional_0_Template(rf, ctx) { if (rf & 1) {
|
|
52
|
+
const _r3 = i0.ɵɵgetCurrentView();
|
|
53
|
+
i0.ɵɵelementStart(0, "button", 10);
|
|
54
|
+
i0.ɵɵlistener("click", function Modal_Conditional_7_Conditional_0_Template_button_click_0_listener($event) { i0.ɵɵrestoreView(_r3); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.requestCloseFromButton($event)); });
|
|
55
|
+
i0.ɵɵnamespaceSVG();
|
|
56
|
+
i0.ɵɵelement(1, "svg", 11);
|
|
57
|
+
i0.ɵɵelementEnd();
|
|
57
58
|
} if (rf & 2) {
|
|
58
59
|
const ctx_r1 = i0.ɵɵnextContext(2);
|
|
59
|
-
i0.ɵɵclassMap(ctx_r1.
|
|
60
|
+
i0.ɵɵclassMap(ctx_r1.cm().dialogCloseFloating);
|
|
61
|
+
i0.ɵɵattribute("aria-label", ctx_r1.closeText());
|
|
62
|
+
i0.ɵɵadvance();
|
|
63
|
+
i0.ɵɵproperty("data", ctx_r1.closeIcon());
|
|
60
64
|
} }
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
i0.ɵɵdomElement(0, "div", 0);
|
|
64
|
-
i0.ɵɵdomElementStart(1, "div", 1);
|
|
65
|
-
i0.ɵɵdomListener("click", function MoleculeModal_Conditional_0_Template_div_click_1_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.onOverlayClick($event)); });
|
|
66
|
-
i0.ɵɵdomElementStart(2, "div", 2);
|
|
67
|
-
i0.ɵɵdomListener("click", function MoleculeModal_Conditional_0_Template_div_click_2_listener($event) { return $event.stopPropagation(); });
|
|
68
|
-
i0.ɵɵconditionalCreate(3, MoleculeModal_Conditional_0_Conditional_3_Template, 4, 4, "div", 3);
|
|
69
|
-
i0.ɵɵdomElementStart(4, "div");
|
|
70
|
-
i0.ɵɵprojection(5);
|
|
71
|
-
i0.ɵɵdomElementEnd();
|
|
72
|
-
i0.ɵɵconditionalCreate(6, MoleculeModal_Conditional_0_Conditional_6_Template, 2, 2, "div", 3);
|
|
73
|
-
i0.ɵɵdomElementEnd()();
|
|
65
|
+
function Modal_Conditional_7_Template(rf, ctx) { if (rf & 1) {
|
|
66
|
+
i0.ɵɵconditionalCreate(0, Modal_Conditional_7_Conditional_0_Template, 2, 4, "button", 9);
|
|
74
67
|
} if (rf & 2) {
|
|
75
68
|
const ctx_r1 = i0.ɵɵnextContext();
|
|
76
|
-
i0.ɵɵ
|
|
77
|
-
i0.ɵɵadvance();
|
|
78
|
-
i0.ɵɵstyleMap(ctx_r1.wrapperStyle);
|
|
79
|
-
i0.ɵɵclassMap(ctx_r1.wrapperClass);
|
|
80
|
-
i0.ɵɵadvance();
|
|
81
|
-
i0.ɵɵstyleMap(ctx_r1.style);
|
|
82
|
-
i0.ɵɵclassMap(ctx_r1.contentClasses);
|
|
83
|
-
i0.ɵɵattribute("aria-labelledby", ctx_r1.title ? "modal-title" : null)("data-testid", ctx_r1.testId);
|
|
84
|
-
i0.ɵɵadvance();
|
|
85
|
-
i0.ɵɵconditional(ctx_r1.title || ctx_r1.showCloseButton ? 3 : -1);
|
|
86
|
-
i0.ɵɵadvance();
|
|
87
|
-
i0.ɵɵclassMap(ctx_r1.bodyClass);
|
|
88
|
-
i0.ɵɵadvance(2);
|
|
89
|
-
i0.ɵɵconditional(ctx_r1.hasFooter ? 6 : -1);
|
|
69
|
+
i0.ɵɵconditional(ctx_r1.showCloseButton ? 0 : -1);
|
|
90
70
|
} }
|
|
71
|
+
/** Module-level open-modal stack (Escape/Tab act only for the topmost). */
|
|
72
|
+
const openModalStack = [];
|
|
73
|
+
/** Pushes a modal onto the stack (it becomes the topmost). */
|
|
74
|
+
const pushModalStack = (id) => {
|
|
75
|
+
if (!openModalStack.includes(id))
|
|
76
|
+
openModalStack.push(id);
|
|
77
|
+
};
|
|
78
|
+
/** Removes a modal from the stack. */
|
|
79
|
+
const popModalStack = (id) => {
|
|
80
|
+
const index = openModalStack.indexOf(id);
|
|
81
|
+
if (index !== -1)
|
|
82
|
+
openModalStack.splice(index, 1);
|
|
83
|
+
};
|
|
84
|
+
/** Whether the given modal is currently the topmost of the stack. */
|
|
85
|
+
const isTopOfModalStack = (id) => openModalStack.length > 0 && openModalStack[openModalStack.length - 1] === id;
|
|
86
|
+
let modalInstance = 0;
|
|
91
87
|
/**
|
|
92
|
-
*
|
|
93
|
-
* no dedicated ClassMap resolver option (it's a fixed token, not a
|
|
94
|
-
* `{ centered }`-parameterized one), so a top-anchored (non-centered) layout
|
|
95
|
-
* is expressed via the one inline-style exception the workspace styling rule
|
|
96
|
-
* allows for values ClassMap genuinely cannot express.
|
|
97
|
-
*
|
|
98
|
-
* A standalone function (rather than a class member) so it's unit-testable
|
|
99
|
-
* without constructing `MoleculeModal` — the class can't be `new`'d outside
|
|
100
|
-
* an Angular injection context (`sanitizer = inject(DomSanitizer)` runs at
|
|
101
|
-
* field-initializer time).
|
|
102
|
-
* @param centered - Whether the modal is vertically centered.
|
|
103
|
-
* @returns An inline style object, or `undefined` when centered.
|
|
104
|
-
*/
|
|
105
|
-
export function getModalWrapperStyle(centered) {
|
|
106
|
-
return centered ? undefined : { alignItems: 'flex-start' };
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Angular Modal UI component with UIClassMap-driven styling.
|
|
88
|
+
* Modal component.
|
|
110
89
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
90
|
+
* React's root is a FRAGMENT portaled into `document.body` (an overlay
|
|
91
|
+
* `<div>` and a centering wrapper `<div>`), so the host is unwrapped
|
|
92
|
+
* (`data-parity-unwrap`, `display: contents`) and both elements are moved
|
|
93
|
+
* into the body. Implements the WAI-ARIA APG modal dialog pattern (focus
|
|
94
|
+
* into the dialog on open, trapped Tab, focus restored on close, Escape for
|
|
95
|
+
* the topmost dialog only, reference-counted body scroll lock).
|
|
113
96
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
*/
|
|
117
|
-
export class MoleculeModal {
|
|
97
|
+
export class Modal {
|
|
98
|
+
/** Whether the dialog is open. */
|
|
118
99
|
open = false;
|
|
100
|
+
/** The dialog title. */
|
|
119
101
|
title;
|
|
102
|
+
/** Dialog width preset. */
|
|
120
103
|
size = 'md';
|
|
104
|
+
/** Whether the header/close button renders. */
|
|
121
105
|
showCloseButton = true;
|
|
122
|
-
|
|
106
|
+
/** Whether clicking the overlay closes the dialog. */
|
|
123
107
|
closeOnOverlayClick = true;
|
|
108
|
+
/** Whether Escape closes the dialog. */
|
|
124
109
|
closeOnEscape = true;
|
|
110
|
+
/** Footer content (node-valued prop). */
|
|
111
|
+
footer;
|
|
112
|
+
/** Whether the dialog is vertically centered. */
|
|
125
113
|
centered = true;
|
|
114
|
+
/** The close button's accessible label. */
|
|
115
|
+
closeLabel;
|
|
116
|
+
/** Whether body scroll is locked while open. */
|
|
126
117
|
preventScroll = true;
|
|
127
|
-
|
|
118
|
+
/** Extra classes for the dialog. */
|
|
128
119
|
className;
|
|
120
|
+
/** Inline style object for the dialog (React camelCase). */
|
|
129
121
|
style;
|
|
122
|
+
/** `data-testid` for the dialog. */
|
|
130
123
|
testId;
|
|
124
|
+
/** Fires when the dialog asks to close (React's `onClose`). */
|
|
131
125
|
close = new EventEmitter();
|
|
126
|
+
/** The overlay element (moved to `document.body`). */
|
|
127
|
+
overlay;
|
|
128
|
+
/** The centering wrapper (moved to `document.body`). */
|
|
129
|
+
wrapper;
|
|
130
|
+
/** The dialog element. */
|
|
131
|
+
dialog;
|
|
132
|
+
/** The footer wrapper (detached when unused). */
|
|
133
|
+
footerSlot;
|
|
134
|
+
/** The per-instance title id (the normalizer renumbers it). */
|
|
135
|
+
titleId = `mol-modal-title-${++modalInstance}`;
|
|
136
|
+
/** The instance's stack id. */
|
|
137
|
+
stackId = modalInstance;
|
|
138
|
+
host = inject(ElementRef);
|
|
132
139
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
|
|
136
|
-
get cm() {
|
|
137
|
-
return getClassMap();
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Computes the accessible close button label.
|
|
141
|
-
* @returns The localized aria-label for the close button.
|
|
140
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
141
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
142
|
+
* does not).
|
|
142
143
|
*/
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
i18n = useTranslation();
|
|
145
|
+
sync = createScrollLock();
|
|
146
|
+
lastOpen = false;
|
|
147
|
+
lastFooter = false;
|
|
148
|
+
footerParent = null;
|
|
149
|
+
previouslyFocused = null;
|
|
150
|
+
listeners = [];
|
|
151
|
+
locked = false;
|
|
152
|
+
moved = false;
|
|
147
153
|
/**
|
|
148
|
-
*
|
|
149
|
-
* @returns The
|
|
154
|
+
* The current class map.
|
|
155
|
+
* @returns The UIClassMap.
|
|
150
156
|
*/
|
|
151
|
-
|
|
152
|
-
return
|
|
157
|
+
cm() {
|
|
158
|
+
return getClassMap();
|
|
153
159
|
}
|
|
154
160
|
/**
|
|
155
|
-
*
|
|
156
|
-
* @returns
|
|
161
|
+
* The dialog class list.
|
|
162
|
+
* @returns The class string.
|
|
157
163
|
*/
|
|
158
|
-
|
|
159
|
-
return
|
|
164
|
+
dialogClasses() {
|
|
165
|
+
return this.cm().cn(this.cm().modal({ size: this.size }), this.className);
|
|
160
166
|
}
|
|
161
167
|
/**
|
|
162
|
-
*
|
|
163
|
-
* @returns The
|
|
168
|
+
* Serializes the dialog's inline style.
|
|
169
|
+
* @returns The style attribute text.
|
|
164
170
|
*/
|
|
165
|
-
|
|
166
|
-
return this.
|
|
171
|
+
dialogStyle() {
|
|
172
|
+
return styleText(this.style);
|
|
167
173
|
}
|
|
168
174
|
/**
|
|
169
|
-
*
|
|
170
|
-
* @returns The
|
|
175
|
+
* The wrapper's inline style (top-anchored when not centered).
|
|
176
|
+
* @returns The style attribute text.
|
|
171
177
|
*/
|
|
172
|
-
|
|
173
|
-
return this.
|
|
178
|
+
wrapperStyle() {
|
|
179
|
+
return styleText(this.centered ? undefined : { alignItems: 'flex-start' });
|
|
174
180
|
}
|
|
175
181
|
/**
|
|
176
|
-
*
|
|
177
|
-
* @returns The
|
|
182
|
+
* The close button's accessible label.
|
|
183
|
+
* @returns The label text.
|
|
178
184
|
*/
|
|
179
|
-
|
|
180
|
-
return this.
|
|
185
|
+
closeText() {
|
|
186
|
+
return this.closeLabel ?? this.i18n.t('ui.modal.close', undefined, { defaultValue: 'Close' });
|
|
181
187
|
}
|
|
182
188
|
/**
|
|
183
|
-
*
|
|
184
|
-
* @returns The
|
|
189
|
+
* The close button's X glyph.
|
|
190
|
+
* @returns The resolved icon.
|
|
185
191
|
*/
|
|
186
|
-
|
|
187
|
-
return this.cm.
|
|
192
|
+
closeIcon() {
|
|
193
|
+
return resolveIcon('x-mark', this.cm().iconMd);
|
|
188
194
|
}
|
|
189
195
|
/**
|
|
190
|
-
*
|
|
191
|
-
*
|
|
196
|
+
* Stops a click inside the dialog from reaching the overlay handler.
|
|
197
|
+
*
|
|
198
|
+
* @param event - The click event.
|
|
192
199
|
*/
|
|
193
|
-
|
|
194
|
-
|
|
200
|
+
stopPropagation(event) {
|
|
201
|
+
event.stopPropagation();
|
|
195
202
|
}
|
|
196
203
|
/**
|
|
197
|
-
*
|
|
198
|
-
*
|
|
204
|
+
* Closes when the click is on the wrapper itself (not bubbled content).
|
|
205
|
+
*
|
|
206
|
+
* @param event - The click event.
|
|
199
207
|
*/
|
|
200
|
-
|
|
201
|
-
|
|
208
|
+
handleOverlayClick(event) {
|
|
209
|
+
if (this.closeOnOverlayClick && event.target === event.currentTarget)
|
|
210
|
+
this.requestClose();
|
|
202
211
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
* @returns The sanitized SVG for the close icon.
|
|
207
|
-
*/
|
|
208
|
-
get closeIconSvg() {
|
|
209
|
-
return this.sanitizer.bypassSecurityTrustHtml(getIconSvg('x-mark', this.cm.iconMd));
|
|
212
|
+
/** Emits the close request (React's `onClose`). */
|
|
213
|
+
requestClose() {
|
|
214
|
+
this.close.emit();
|
|
210
215
|
}
|
|
211
216
|
/**
|
|
212
|
-
*
|
|
213
|
-
*
|
|
217
|
+
* Emits the close request from the close button — React's close button is
|
|
218
|
+
* `onClick={onClose}`, so the click event reaches the callback.
|
|
219
|
+
*
|
|
220
|
+
* @param event - The click event.
|
|
214
221
|
*/
|
|
215
|
-
|
|
216
|
-
|
|
222
|
+
requestCloseFromButton(event) {
|
|
223
|
+
this.close.emit(event);
|
|
217
224
|
}
|
|
218
225
|
/**
|
|
219
|
-
*
|
|
226
|
+
* Reads the view queries (they resolve only at view init), moves the portal
|
|
227
|
+
* content into `document.body` and applies the initial open state.
|
|
220
228
|
*/
|
|
221
|
-
|
|
222
|
-
this.
|
|
229
|
+
ngAfterViewInit() {
|
|
230
|
+
const overlay = this.overlay?.nativeElement;
|
|
231
|
+
const wrapper = this.wrapper?.nativeElement;
|
|
232
|
+
const dialog = this.dialog?.nativeElement;
|
|
233
|
+
this.footerParent = this.footerSlot?.nativeElement.parentElement ?? null;
|
|
234
|
+
if (dialog)
|
|
235
|
+
moveRestAttributes(this.host.nativeElement, dialog);
|
|
236
|
+
this.lastFooter = this.hasFooter();
|
|
237
|
+
this.syncFooter();
|
|
238
|
+
const open = !!this.open;
|
|
239
|
+
if (open) {
|
|
240
|
+
this.previouslyFocused = document.activeElement ?? null;
|
|
241
|
+
pushModalStack(this.stackId);
|
|
242
|
+
if (overlay && wrapper)
|
|
243
|
+
this.attachPortal();
|
|
244
|
+
if (dialog) {
|
|
245
|
+
const focusables = getFocusableElements(dialog);
|
|
246
|
+
(focusables[0] ?? dialog).focus();
|
|
247
|
+
}
|
|
248
|
+
this.addListeners();
|
|
249
|
+
}
|
|
250
|
+
else if (overlay && wrapper) {
|
|
251
|
+
// React renders nothing while closed.
|
|
252
|
+
this.detachPortal();
|
|
253
|
+
}
|
|
254
|
+
this.syncScrollLock();
|
|
255
|
+
this.lastOpen = open;
|
|
223
256
|
}
|
|
224
257
|
/**
|
|
225
|
-
*
|
|
226
|
-
* @param changes - The changed input properties.
|
|
258
|
+
* Reconciles the open state and the footer on later passes.
|
|
227
259
|
*/
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
this.
|
|
260
|
+
ngDoCheck() {
|
|
261
|
+
const open = !!this.open;
|
|
262
|
+
if (open !== this.lastOpen) {
|
|
263
|
+
this.lastOpen = open;
|
|
264
|
+
this.transition(open);
|
|
232
265
|
}
|
|
266
|
+
this.lastFooter = this.hasFooter();
|
|
267
|
+
this.syncFooter();
|
|
268
|
+
this.syncScrollLock();
|
|
233
269
|
}
|
|
234
|
-
/**
|
|
235
|
-
* Cleans up event listeners and body scroll on component destruction.
|
|
236
|
-
*/
|
|
270
|
+
/** Removes listeners, unlocks scroll and restores the portal nodes (unmount). */
|
|
237
271
|
ngOnDestroy() {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
272
|
+
this.removeListeners();
|
|
273
|
+
popModalStack(this.stackId);
|
|
274
|
+
if (this.locked) {
|
|
275
|
+
this.sync.unlock();
|
|
276
|
+
this.locked = false;
|
|
277
|
+
}
|
|
278
|
+
// The portal nodes must be children of the host again for Angular's own
|
|
279
|
+
// removal to succeed.
|
|
280
|
+
const host = this.host.nativeElement;
|
|
281
|
+
if (this.moved) {
|
|
282
|
+
const overlay = this.overlay?.nativeElement;
|
|
283
|
+
const wrapper = this.wrapper?.nativeElement;
|
|
284
|
+
if (overlay?.parentNode === document.body)
|
|
285
|
+
host.appendChild(overlay);
|
|
286
|
+
if (wrapper?.parentNode === document.body)
|
|
287
|
+
host.appendChild(wrapper);
|
|
288
|
+
this.moved = false;
|
|
241
289
|
}
|
|
242
290
|
}
|
|
243
291
|
/**
|
|
244
|
-
*
|
|
292
|
+
* Whether the footer slot carries nodes (read each pass so a later props
|
|
293
|
+
* step adding it still renders).
|
|
294
|
+
* @returns True when the footer wrapper should render.
|
|
245
295
|
*/
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
296
|
+
hasFooter() {
|
|
297
|
+
const slot = this.footerSlot?.nativeElement;
|
|
298
|
+
if (!slot)
|
|
299
|
+
return false;
|
|
300
|
+
for (const node of Array.from(slot.childNodes)) {
|
|
301
|
+
if (node.nodeType === 1)
|
|
302
|
+
return true;
|
|
303
|
+
if (node.nodeType === 3 && (node.textContent ?? '').trim())
|
|
304
|
+
return true;
|
|
249
305
|
}
|
|
250
|
-
|
|
251
|
-
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
/** Applies React's `{!!footer && <div className={dialogFooter}>…</div>}`. */
|
|
309
|
+
syncFooter() {
|
|
310
|
+
const slot = this.footerSlot?.nativeElement;
|
|
311
|
+
if (!slot)
|
|
312
|
+
return;
|
|
313
|
+
const shouldRender = this.lastFooter;
|
|
314
|
+
if (shouldRender && !slot.isConnected) {
|
|
315
|
+
;
|
|
316
|
+
(this.footerParent ?? this.dialog?.nativeElement ?? null)?.appendChild(slot);
|
|
317
|
+
}
|
|
318
|
+
else if (!shouldRender && slot.isConnected) {
|
|
319
|
+
slot.remove();
|
|
252
320
|
}
|
|
253
321
|
}
|
|
254
322
|
/**
|
|
255
|
-
*
|
|
323
|
+
* Applies an open/closed transition (React mounts/unmounts the portal and
|
|
324
|
+
* its effects).
|
|
325
|
+
*
|
|
326
|
+
* @param open - The new open state.
|
|
256
327
|
*/
|
|
257
|
-
|
|
258
|
-
if (
|
|
259
|
-
|
|
328
|
+
transition(open) {
|
|
329
|
+
if (open) {
|
|
330
|
+
this.previouslyFocused = document.activeElement ?? null;
|
|
331
|
+
pushModalStack(this.stackId);
|
|
332
|
+
this.attachPortal();
|
|
333
|
+
const dialog = this.dialog?.nativeElement;
|
|
334
|
+
if (dialog) {
|
|
335
|
+
const focusables = getFocusableElements(dialog);
|
|
336
|
+
(focusables[0] ?? dialog).focus();
|
|
337
|
+
}
|
|
338
|
+
this.addListeners();
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
popModalStack(this.stackId);
|
|
342
|
+
this.removeListeners();
|
|
343
|
+
this.detachPortal();
|
|
344
|
+
const toRestore = this.previouslyFocused;
|
|
345
|
+
if (toRestore && document.contains(toRestore))
|
|
346
|
+
toRestore.focus();
|
|
260
347
|
}
|
|
348
|
+
this.syncScrollLock();
|
|
261
349
|
}
|
|
262
|
-
/**
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
350
|
+
/** Re-inserts the portal nodes into `document.body` (in React's order). */
|
|
351
|
+
attachPortal() {
|
|
352
|
+
const overlay = this.overlay?.nativeElement;
|
|
353
|
+
const wrapper = this.wrapper?.nativeElement;
|
|
354
|
+
if (!overlay || !wrapper)
|
|
355
|
+
return;
|
|
356
|
+
document.body.appendChild(overlay);
|
|
357
|
+
document.body.appendChild(wrapper);
|
|
358
|
+
this.moved = true;
|
|
359
|
+
}
|
|
360
|
+
/** Removes the portal nodes from the document (React renders null). */
|
|
361
|
+
detachPortal() {
|
|
362
|
+
this.overlay?.nativeElement.remove();
|
|
363
|
+
this.wrapper?.nativeElement.remove();
|
|
364
|
+
this.moved = false;
|
|
365
|
+
}
|
|
366
|
+
/** Locks or unlocks body scroll for React's `open && preventScroll`. */
|
|
367
|
+
syncScrollLock() {
|
|
368
|
+
const shouldLock = !!this.open && this.preventScroll;
|
|
369
|
+
if (shouldLock && !this.locked) {
|
|
370
|
+
this.sync.lock();
|
|
371
|
+
this.locked = true;
|
|
269
372
|
}
|
|
373
|
+
else if (!shouldLock && this.locked) {
|
|
374
|
+
this.sync.unlock();
|
|
375
|
+
this.locked = false;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
/** Adds Escape and the Tab focus trap while open (React's effect). */
|
|
379
|
+
addListeners() {
|
|
380
|
+
this.removeListeners();
|
|
381
|
+
const onKeyDown = (event) => this.handleKeyDown(event);
|
|
382
|
+
document.addEventListener('keydown', onKeyDown);
|
|
383
|
+
this.listeners.push(() => document.removeEventListener('keydown', onKeyDown));
|
|
384
|
+
}
|
|
385
|
+
/** Removes the document listeners. */
|
|
386
|
+
removeListeners() {
|
|
387
|
+
for (const off of this.listeners)
|
|
388
|
+
off();
|
|
389
|
+
this.listeners = [];
|
|
270
390
|
}
|
|
271
391
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
392
|
+
* Escape closes the topmost dialog; Tab wraps inside it.
|
|
393
|
+
*
|
|
394
|
+
* @param event - The key event.
|
|
274
395
|
*/
|
|
275
|
-
|
|
276
|
-
if (
|
|
277
|
-
this.
|
|
396
|
+
handleKeyDown(event) {
|
|
397
|
+
if (event.key === 'Escape') {
|
|
398
|
+
if (this.closeOnEscape && isTopOfModalStack(this.stackId))
|
|
399
|
+
this.requestClose();
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (event.key !== 'Tab' || !isTopOfModalStack(this.stackId))
|
|
403
|
+
return;
|
|
404
|
+
const el = this.dialog?.nativeElement;
|
|
405
|
+
if (!el)
|
|
406
|
+
return;
|
|
407
|
+
const focusables = getFocusableElements(el);
|
|
408
|
+
if (focusables.length === 0) {
|
|
409
|
+
event.preventDefault();
|
|
410
|
+
el.focus();
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
const first = focusables[0];
|
|
414
|
+
const last = focusables[focusables.length - 1];
|
|
415
|
+
const active = document.activeElement;
|
|
416
|
+
if (event.shiftKey) {
|
|
417
|
+
if (active === first || !el.contains(active)) {
|
|
418
|
+
event.preventDefault();
|
|
419
|
+
last.focus();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
else if (active === last || !el.contains(active)) {
|
|
423
|
+
event.preventDefault();
|
|
424
|
+
first.focus();
|
|
278
425
|
}
|
|
279
426
|
}
|
|
280
|
-
static ɵfac = function
|
|
281
|
-
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type:
|
|
282
|
-
i0.ɵɵ
|
|
283
|
-
|
|
427
|
+
static ɵfac = function Modal_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Modal)(); };
|
|
428
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Modal, selectors: [["mol-modal"]], viewQuery: function Modal_Query(rf, ctx) { if (rf & 1) {
|
|
429
|
+
i0.ɵɵviewQuery(_c0, 5)(_c1, 5)(_c2, 5)(_c3, 5);
|
|
430
|
+
} if (rf & 2) {
|
|
431
|
+
let _t;
|
|
432
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.overlay = _t.first);
|
|
433
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.wrapper = _t.first);
|
|
434
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dialog = _t.first);
|
|
435
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.footerSlot = _t.first);
|
|
436
|
+
} }, hostAttrs: ["data-parity-unwrap", "", 2, "display", "contents"], inputs: { open: "open", title: "title", size: "size", showCloseButton: "showCloseButton", closeOnOverlayClick: "closeOnOverlayClick", closeOnEscape: "closeOnEscape", footer: "footer", centered: "centered", closeLabel: "closeLabel", preventScroll: "preventScroll", className: "className", style: "style", testId: "testId" }, outputs: { close: "close" }, ngContentSelectors: _c5, decls: 13, vars: 17, consts: [["overlay", ""], ["wrapper", ""], ["dialog", ""], ["footerSlot", ""], ["aria-hidden", "true"], [3, "click"], ["role", "dialog", "aria-modal", "true", "tabindex", "-1", 3, "click"], [3, "class"], [3, "id"], ["type", "button", "data-mol-id", "modal-close", 3, "class"], ["type", "button", "data-mol-id", "modal-close", 3, "click"], ["mol-icon", "", 3, "data"]], template: function Modal_Template(rf, ctx) { if (rf & 1) {
|
|
437
|
+
i0.ɵɵprojectionDef(_c4);
|
|
438
|
+
i0.ɵɵelement(0, "div", 4, 0);
|
|
439
|
+
i0.ɵɵelementStart(2, "div", 5, 1);
|
|
440
|
+
i0.ɵɵlistener("click", function Modal_Template_div_click_2_listener($event) { return ctx.handleOverlayClick($event); });
|
|
441
|
+
i0.ɵɵelementStart(4, "div", 6, 2);
|
|
442
|
+
i0.ɵɵlistener("click", function Modal_Template_div_click_4_listener($event) { return ctx.stopPropagation($event); });
|
|
443
|
+
i0.ɵɵconditionalCreate(6, Modal_Conditional_6_Template, 4, 7, "div", 7)(7, Modal_Conditional_7_Template, 1, 1);
|
|
444
|
+
i0.ɵɵelementStart(8, "div");
|
|
445
|
+
i0.ɵɵprojection(9);
|
|
446
|
+
i0.ɵɵelementEnd();
|
|
447
|
+
i0.ɵɵelementStart(10, "div", null, 3);
|
|
448
|
+
i0.ɵɵprojection(12, 1);
|
|
449
|
+
i0.ɵɵelementEnd()()();
|
|
284
450
|
} if (rf & 2) {
|
|
285
|
-
i0.ɵɵ
|
|
286
|
-
|
|
451
|
+
i0.ɵɵclassMap(ctx.cm().dialogOverlay);
|
|
452
|
+
i0.ɵɵadvance(2);
|
|
453
|
+
i0.ɵɵstyleMap(ctx.wrapperStyle());
|
|
454
|
+
i0.ɵɵclassMap(ctx.cm().dialogWrapper);
|
|
455
|
+
i0.ɵɵadvance(2);
|
|
456
|
+
i0.ɵɵstyleMap(ctx.dialogStyle());
|
|
457
|
+
i0.ɵɵclassMap(ctx.dialogClasses());
|
|
458
|
+
i0.ɵɵattribute("aria-labelledby", ctx.title ? ctx.titleId : null)("data-testid", ctx.testId);
|
|
459
|
+
i0.ɵɵadvance(2);
|
|
460
|
+
i0.ɵɵconditional(ctx.title ? 6 : 7);
|
|
461
|
+
i0.ɵɵadvance(2);
|
|
462
|
+
i0.ɵɵclassMap(ctx.cm().dialogBody);
|
|
463
|
+
i0.ɵɵadvance(2);
|
|
464
|
+
i0.ɵɵclassMap(ctx.cm().dialogFooter);
|
|
465
|
+
} }, dependencies: [MolIconSvg], encapsulation: 2 });
|
|
287
466
|
}
|
|
288
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(
|
|
467
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Modal, [{
|
|
289
468
|
type: Component,
|
|
290
469
|
args: [{
|
|
291
470
|
selector: 'mol-modal',
|
|
292
471
|
standalone: true,
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
472
|
+
imports: [MolIconSvg],
|
|
473
|
+
inputs: [
|
|
474
|
+
'open',
|
|
475
|
+
'title',
|
|
476
|
+
'size',
|
|
477
|
+
'showCloseButton',
|
|
478
|
+
'closeOnOverlayClick',
|
|
479
|
+
'closeOnEscape',
|
|
480
|
+
'footer',
|
|
481
|
+
'centered',
|
|
482
|
+
'closeLabel',
|
|
483
|
+
'preventScroll',
|
|
484
|
+
'className',
|
|
485
|
+
'style',
|
|
486
|
+
'testId',
|
|
487
|
+
],
|
|
488
|
+
outputs: ['close'],
|
|
489
|
+
host: {
|
|
490
|
+
'data-parity-unwrap': '',
|
|
491
|
+
style: 'display: contents',
|
|
492
|
+
},
|
|
493
|
+
template: `<div #overlay [class]="cm().dialogOverlay" aria-hidden="true"></div>
|
|
494
|
+
<div
|
|
495
|
+
#wrapper
|
|
496
|
+
[class]="cm().dialogWrapper"
|
|
497
|
+
[style]="wrapperStyle()"
|
|
498
|
+
(click)="handleOverlayClick($event)"
|
|
499
|
+
>
|
|
500
|
+
<div
|
|
501
|
+
#dialog
|
|
502
|
+
role="dialog"
|
|
503
|
+
aria-modal="true"
|
|
504
|
+
[attr.aria-labelledby]="title ? titleId : null"
|
|
505
|
+
tabindex="-1"
|
|
506
|
+
[class]="dialogClasses()"
|
|
507
|
+
[style]="dialogStyle()"
|
|
508
|
+
[attr.data-testid]="testId"
|
|
509
|
+
(click)="stopPropagation($event)"
|
|
510
|
+
>
|
|
511
|
+
@if (title) {
|
|
512
|
+
<div [class]="cm().dialogHeader">
|
|
513
|
+
<h2 [id]="titleId" [class]="cm().dialogTitle">{{ title }}</h2>
|
|
514
|
+
@if (showCloseButton) {
|
|
515
|
+
<button
|
|
516
|
+
type="button"
|
|
517
|
+
(click)="requestCloseFromButton($event)"
|
|
518
|
+
[class]="cm().dialogClose"
|
|
519
|
+
data-mol-id="modal-close"
|
|
520
|
+
[attr.aria-label]="closeText()"
|
|
521
|
+
>
|
|
522
|
+
<svg mol-icon [data]="closeIcon()" />
|
|
523
|
+
</button>
|
|
524
|
+
}
|
|
333
525
|
</div>
|
|
334
|
-
|
|
335
|
-
@if (
|
|
336
|
-
<
|
|
337
|
-
|
|
338
|
-
|
|
526
|
+
} @else {
|
|
527
|
+
@if (showCloseButton) {
|
|
528
|
+
<button
|
|
529
|
+
type="button"
|
|
530
|
+
(click)="requestCloseFromButton($event)"
|
|
531
|
+
[class]="cm().dialogCloseFloating"
|
|
532
|
+
data-mol-id="modal-close"
|
|
533
|
+
[attr.aria-label]="closeText()"
|
|
534
|
+
>
|
|
535
|
+
<svg mol-icon [data]="closeIcon()" />
|
|
536
|
+
</button>
|
|
339
537
|
}
|
|
538
|
+
}
|
|
539
|
+
<div [class]="cm().dialogBody"><ng-content></ng-content></div>
|
|
540
|
+
<div #footerSlot [class]="cm().dialogFooter">
|
|
541
|
+
<ng-content select="[slot=footer]"></ng-content>
|
|
340
542
|
</div>
|
|
341
543
|
</div>
|
|
342
|
-
|
|
343
|
-
`,
|
|
544
|
+
</div>`,
|
|
344
545
|
}]
|
|
345
|
-
}], null, {
|
|
346
|
-
type: Input
|
|
347
|
-
}], title: [{
|
|
348
|
-
type: Input
|
|
349
|
-
}], size: [{
|
|
350
|
-
type: Input
|
|
351
|
-
}], showCloseButton: [{
|
|
352
|
-
type: Input
|
|
353
|
-
}], closeLabel: [{
|
|
354
|
-
type: Input
|
|
355
|
-
}], closeOnOverlayClick: [{
|
|
356
|
-
type: Input
|
|
357
|
-
}], closeOnEscape: [{
|
|
358
|
-
type: Input
|
|
359
|
-
}], centered: [{
|
|
360
|
-
type: Input
|
|
361
|
-
}], preventScroll: [{
|
|
362
|
-
type: Input
|
|
363
|
-
}], hasFooter: [{
|
|
364
|
-
type: Input
|
|
365
|
-
}], className: [{
|
|
366
|
-
type: Input
|
|
367
|
-
}], style: [{
|
|
368
|
-
type: Input
|
|
369
|
-
}], testId: [{
|
|
370
|
-
type: Input
|
|
371
|
-
}], close: [{
|
|
546
|
+
}], null, { close: [{
|
|
372
547
|
type: Output
|
|
548
|
+
}], overlay: [{
|
|
549
|
+
type: ViewChild,
|
|
550
|
+
args: ['overlay']
|
|
551
|
+
}], wrapper: [{
|
|
552
|
+
type: ViewChild,
|
|
553
|
+
args: ['wrapper']
|
|
554
|
+
}], dialog: [{
|
|
555
|
+
type: ViewChild,
|
|
556
|
+
args: ['dialog']
|
|
557
|
+
}], footerSlot: [{
|
|
558
|
+
type: ViewChild,
|
|
559
|
+
args: ['footerSlot']
|
|
373
560
|
}] }); })();
|
|
374
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(
|
|
561
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Modal, { className: "Modal", filePath: "components/modal.component.ts", lineNumber: 136 }); })();
|
|
375
562
|
//# sourceMappingURL=modal.component.js.map
|