@molecule/app-ui-angular 1.4.2 → 1.5.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 +987 -1015
- package/dist/components/alert.component.d.ts +11 -16
- package/dist/components/alert.component.d.ts.map +1 -1
- package/dist/components/alert.component.js +22 -51
- package/dist/components/alert.component.js.map +1 -1
- package/dist/components/auth-guard.component.d.ts +36 -28
- package/dist/components/auth-guard.component.d.ts.map +1 -1
- package/dist/components/auth-guard.component.js +59 -67
- package/dist/components/auth-guard.component.js.map +1 -1
- package/dist/components/avatar.component.d.ts +13 -10
- package/dist/components/avatar.component.d.ts.map +1 -1
- package/dist/components/avatar.component.js +27 -25
- package/dist/components/avatar.component.js.map +1 -1
- package/dist/components/button.component.d.ts +26 -30
- package/dist/components/button.component.d.ts.map +1 -1
- package/dist/components/button.component.js +41 -75
- package/dist/components/button.component.js.map +1 -1
- package/dist/components/checkbox.component.d.ts +5 -4
- package/dist/components/checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox.component.js +14 -9
- package/dist/components/checkbox.component.js.map +1 -1
- package/dist/components/confirm-button.component.d.ts +11 -28
- package/dist/components/confirm-button.component.d.ts.map +1 -1
- package/dist/components/confirm-button.component.js +31 -63
- package/dist/components/confirm-button.component.js.map +1 -1
- package/dist/components/confirm-dialog.component.d.ts +28 -17
- package/dist/components/confirm-dialog.component.d.ts.map +1 -1
- package/dist/components/confirm-dialog.component.js +98 -69
- package/dist/components/confirm-dialog.component.js.map +1 -1
- package/dist/components/dropdown.component.d.ts +29 -16
- package/dist/components/dropdown.component.d.ts.map +1 -1
- package/dist/components/dropdown.component.js +143 -105
- package/dist/components/dropdown.component.js.map +1 -1
- package/dist/components/empty-state.component.d.ts +10 -15
- package/dist/components/empty-state.component.d.ts.map +1 -1
- package/dist/components/empty-state.component.js +23 -27
- package/dist/components/empty-state.component.js.map +1 -1
- package/dist/components/form-field.component.d.ts +26 -11
- package/dist/components/form-field.component.d.ts.map +1 -1
- package/dist/components/form-field.component.js +86 -25
- package/dist/components/form-field.component.js.map +1 -1
- package/dist/components/input.component.d.ts +20 -23
- package/dist/components/input.component.d.ts.map +1 -1
- package/dist/components/input.component.js +45 -54
- package/dist/components/input.component.js.map +1 -1
- package/dist/components/language-picker.component.d.ts +15 -18
- package/dist/components/language-picker.component.d.ts.map +1 -1
- package/dist/components/language-picker.component.js +25 -35
- package/dist/components/language-picker.component.js.map +1 -1
- package/dist/components/load-error-banner.component.d.ts +14 -26
- package/dist/components/load-error-banner.component.d.ts.map +1 -1
- package/dist/components/load-error-banner.component.js +28 -62
- package/dist/components/load-error-banner.component.js.map +1 -1
- package/dist/components/modal.component.d.ts +38 -21
- package/dist/components/modal.component.d.ts.map +1 -1
- package/dist/components/modal.component.js +55 -78
- package/dist/components/modal.component.js.map +1 -1
- package/dist/components/molecule/button.component.d.ts +13 -2
- package/dist/components/molecule/button.component.d.ts.map +1 -1
- package/dist/components/molecule/button.component.js +45 -15
- package/dist/components/molecule/button.component.js.map +1 -1
- package/dist/components/molecule/toast.component.d.ts +2 -1
- package/dist/components/molecule/toast.component.d.ts.map +1 -1
- package/dist/components/molecule/toast.component.js +9 -7
- package/dist/components/molecule/toast.component.js.map +1 -1
- package/dist/components/molecule/tooltip.component.d.ts +4 -2
- package/dist/components/molecule/tooltip.component.d.ts.map +1 -1
- package/dist/components/molecule/tooltip.component.js +19 -14
- package/dist/components/molecule/tooltip.component.js.map +1 -1
- package/dist/components/optimistic-toggle-button.component.d.ts +13 -25
- package/dist/components/optimistic-toggle-button.component.d.ts.map +1 -1
- package/dist/components/optimistic-toggle-button.component.js +33 -63
- package/dist/components/optimistic-toggle-button.component.js.map +1 -1
- package/dist/components/page-header.component.d.ts +8 -13
- package/dist/components/page-header.component.d.ts.map +1 -1
- package/dist/components/page-header.component.js +16 -24
- package/dist/components/page-header.component.js.map +1 -1
- package/dist/components/page-shell.component.d.ts +8 -14
- package/dist/components/page-shell.component.d.ts.map +1 -1
- package/dist/components/page-shell.component.js +18 -28
- package/dist/components/page-shell.component.js.map +1 -1
- package/dist/components/panel-close.component.d.ts +14 -8
- package/dist/components/panel-close.component.d.ts.map +1 -1
- package/dist/components/panel-close.component.js +28 -17
- package/dist/components/panel-close.component.js.map +1 -1
- package/dist/components/prompt-dialog.component.d.ts +32 -10
- package/dist/components/prompt-dialog.component.d.ts.map +1 -1
- package/dist/components/prompt-dialog.component.js +110 -73
- package/dist/components/prompt-dialog.component.js.map +1 -1
- package/dist/components/responsive-app-shell.component.d.ts +46 -41
- package/dist/components/responsive-app-shell.component.d.ts.map +1 -1
- package/dist/components/responsive-app-shell.component.js +138 -147
- package/dist/components/responsive-app-shell.component.js.map +1 -1
- package/dist/components/sidebar-user-card.component.d.ts +8 -12
- package/dist/components/sidebar-user-card.component.d.ts.map +1 -1
- package/dist/components/sidebar-user-card.component.js +19 -35
- package/dist/components/sidebar-user-card.component.js.map +1 -1
- package/dist/components/switch.component.d.ts +13 -8
- package/dist/components/switch.component.d.ts.map +1 -1
- package/dist/components/switch.component.js +29 -20
- package/dist/components/switch.component.js.map +1 -1
- package/dist/components/table.component.d.ts +22 -14
- package/dist/components/table.component.d.ts.map +1 -1
- package/dist/components/table.component.js +34 -32
- package/dist/components/table.component.js.map +1 -1
- package/dist/components/toast.component.d.ts +34 -30
- package/dist/components/toast.component.d.ts.map +1 -1
- package/dist/components/toast.component.js +74 -84
- package/dist/components/toast.component.js.map +1 -1
- package/dist/components/tooltip.component.d.ts +27 -11
- package/dist/components/tooltip.component.d.ts.map +1 -1
- package/dist/components/tooltip.component.js +62 -47
- package/dist/components/tooltip.component.js.map +1 -1
- package/dist/components/user-menu-popover.component.d.ts +18 -12
- package/dist/components/user-menu-popover.component.d.ts.map +1 -1
- package/dist/components/user-menu-popover.component.js +52 -77
- package/dist/components/user-menu-popover.component.js.map +1 -1
- package/dist/components/user-menu.component.d.ts +8 -11
- package/dist/components/user-menu.component.d.ts.map +1 -1
- package/dist/components/user-menu.component.js +19 -27
- package/dist/components/user-menu.component.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/utilities/dom-context.d.ts +62 -15
- package/dist/utilities/dom-context.d.ts.map +1 -1
- package/dist/utilities/dom-context.js +79 -34
- package/dist/utilities/dom-context.js.map +1 -1
- package/dist/utilities/form-field-context.d.ts +2 -0
- package/dist/utilities/form-field-context.d.ts.map +1 -1
- package/dist/utilities/form-field-context.js +4 -2
- package/dist/utilities/form-field-context.js.map +1 -1
- package/dist/utilities/node-value.d.ts +8 -0
- package/dist/utilities/node-value.d.ts.map +1 -1
- package/dist/utilities/node-value.js +10 -0
- package/dist/utilities/node-value.js.map +1 -1
- package/dist/utilities/rest-attrs.d.ts +2 -2
- package/dist/utilities/rest-attrs.js +1 -1
- package/package.json +3 -3
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
|
-
import { Component,
|
|
8
|
-
import { useTranslation } from '@molecule/app-angular';
|
|
7
|
+
import { Component, signal, ViewChild } from '@angular/core';
|
|
8
|
+
import { MolPlacement, placeContent, setElementPresent, usePlacement, useTranslation, } from '@molecule/app-angular';
|
|
9
9
|
import { getClassMap } from '@molecule/app-ui';
|
|
10
10
|
import { asTemplate, isGiven, nodeText } from '../utilities/node-value.js';
|
|
11
11
|
import { Alert } from './alert.component.js';
|
|
12
|
-
import { hasNodes, SlotWrapper } from './button.component.js';
|
|
13
12
|
import { MolTemplateOutlet } from './template-outlet.directive.js';
|
|
14
13
|
import * as i0 from "@angular/core";
|
|
14
|
+
import * as i1 from "@molecule/app-angular";
|
|
15
15
|
const _c0 = ["detailSlot"];
|
|
16
16
|
const _c1 = ["retrySlot"];
|
|
17
17
|
const _c2 = ["retryLabelSlot"];
|
|
@@ -76,13 +76,13 @@ export class LoadErrorBanner {
|
|
|
76
76
|
* does not).
|
|
77
77
|
*/
|
|
78
78
|
i18n = useTranslation();
|
|
79
|
-
|
|
80
|
-
hasDetail = false;
|
|
81
|
-
/** Whether the projected retry label exists (a signal: it is read after view init). */
|
|
79
|
+
/** Whether the projected retry label exists (a signal the placement function sets). */
|
|
82
80
|
hasRetryLabel = signal(false, /* @ts-ignore */
|
|
83
81
|
...(ngDevMode ? [{ debugName: "hasRetryLabel" }] : /* istanbul ignore next */ []));
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
/** Reconciles the detail/retry wrappers and the projected retry label. */
|
|
83
|
+
constructor() {
|
|
84
|
+
usePlacement((hasContent) => this.reconcile(hasContent));
|
|
85
|
+
}
|
|
86
86
|
/**
|
|
87
87
|
* The current class map.
|
|
88
88
|
* @returns The UIClassMap.
|
|
@@ -127,38 +127,29 @@ export class LoadErrorBanner {
|
|
|
127
127
|
.finally(() => this.pending.set(false));
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
|
-
*
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.retryParent = this.retrySlot?.nativeElement.parentElement ?? null;
|
|
135
|
-
this.hasDetail = this.detailPresent();
|
|
136
|
-
this.hasRetryLabel.set(hasNodes(this.retryLabelSlot?.nativeElement));
|
|
137
|
-
this.sync.sync(this.retryLabelSlot?.nativeElement, false, this.retryLabelSlot?.nativeElement.parentElement ?? undefined);
|
|
138
|
-
this.ngDoCheck();
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Re-reconciles the conditional wrappers on later passes.
|
|
130
|
+
* Applies React's detail/retry conditions and moves the projected retry
|
|
131
|
+
* label onto the retry button.
|
|
132
|
+
*
|
|
133
|
+
* @param hasContent - Reads whether a slot has content.
|
|
142
134
|
*/
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this.
|
|
135
|
+
reconcile(hasContent) {
|
|
136
|
+
const retryLabelSlot = this.retryLabelSlot?.nativeElement;
|
|
137
|
+
this.hasRetryLabel.set(hasContent(retryLabelSlot));
|
|
138
|
+
setElementPresent(retryLabelSlot, false);
|
|
139
|
+
setElementPresent(this.detailSlot?.nativeElement, this.detailPresent(hasContent));
|
|
146
140
|
// React renders the retry row exactly when `onRetry` is given.
|
|
147
|
-
|
|
141
|
+
setElementPresent(this.retrySlot?.nativeElement, !!this.onRetry);
|
|
148
142
|
this.showRetryLabel();
|
|
149
143
|
}
|
|
150
144
|
/**
|
|
151
145
|
* Whether React would render the detail paragraph (a given node value or
|
|
152
146
|
* projected slot content).
|
|
147
|
+
*
|
|
148
|
+
* @param hasContent - Reads whether a slot has content.
|
|
153
149
|
* @returns True when the detail renders.
|
|
154
150
|
*/
|
|
155
|
-
detailPresent() {
|
|
156
|
-
return isGiven(this.detail) ||
|
|
157
|
-
}
|
|
158
|
-
/** Restores the retry-label capture span on unmount. */
|
|
159
|
-
ngOnDestroy() {
|
|
160
|
-
this.visibleNodes = [];
|
|
161
|
-
this.visibleFrom = null;
|
|
151
|
+
detailPresent(hasContent) {
|
|
152
|
+
return isGiven(this.detail) || hasContent(this.detailSlot?.nativeElement);
|
|
162
153
|
}
|
|
163
154
|
/** Moves the projected retry label onto the retry button (React: no wrapper). */
|
|
164
155
|
showRetryLabel() {
|
|
@@ -167,36 +158,10 @@ export class LoadErrorBanner {
|
|
|
167
158
|
if (!host || !span)
|
|
168
159
|
return;
|
|
169
160
|
if (!this.hasRetryLabel()) {
|
|
170
|
-
|
|
161
|
+
placeContent(span, null);
|
|
171
162
|
return;
|
|
172
163
|
}
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
visibleNodes = [];
|
|
176
|
-
visibleFrom = null;
|
|
177
|
-
/**
|
|
178
|
-
* Shows one capture span's children inside a target element, parking any
|
|
179
|
-
* previously shown nodes back in their span.
|
|
180
|
-
*
|
|
181
|
-
* @param target - The element to show the nodes in.
|
|
182
|
-
* @param span - The capture span (null parks everything).
|
|
183
|
-
*/
|
|
184
|
-
showNodes(target, span) {
|
|
185
|
-
if (span === this.visibleFrom)
|
|
186
|
-
return;
|
|
187
|
-
for (const node of this.visibleNodes) {
|
|
188
|
-
if (node.parentNode === target)
|
|
189
|
-
this.visibleFrom?.appendChild(node);
|
|
190
|
-
}
|
|
191
|
-
this.visibleNodes = [];
|
|
192
|
-
this.visibleFrom = null;
|
|
193
|
-
if (!span)
|
|
194
|
-
return;
|
|
195
|
-
const nodes = Array.from(span.childNodes);
|
|
196
|
-
for (const node of nodes)
|
|
197
|
-
target.appendChild(node);
|
|
198
|
-
this.visibleNodes = nodes;
|
|
199
|
-
this.visibleFrom = span;
|
|
164
|
+
placeContent(span, host);
|
|
200
165
|
}
|
|
201
166
|
static ɵfac = function LoadErrorBanner_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || LoadErrorBanner)(); };
|
|
202
167
|
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LoadErrorBanner, selectors: [["div", "mol-load-error-banner", ""]], viewQuery: function LoadErrorBanner_Query(rf, ctx) { if (rf & 1) {
|
|
@@ -208,7 +173,7 @@ export class LoadErrorBanner {
|
|
|
208
173
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.retryLabelSlot = _t.first);
|
|
209
174
|
} }, hostVars: 2, hostBindings: function LoadErrorBanner_HostBindings(rf, ctx) { if (rf & 2) {
|
|
210
175
|
i0.ɵɵclassMap(ctx.className);
|
|
211
|
-
} }, inputs: { message: "message", detail: "detail", retryLabel: "retryLabel", retryMolId: "retryMolId", onRetry: "onRetry" }, ngContentSelectors: _c4, decls: 20, vars: 21, consts: [["detailSlot", ""], ["retrySlot", ""], ["retryLabelSlot", ""], ["mol-alert", "", 3, "status", "live"], [3, "molTemplateOutlet"], ["type", "button", 3, "click", "disabled"]], template: function LoadErrorBanner_Template(rf, ctx) { if (rf & 1) {
|
|
176
|
+
} }, inputs: { message: "message", detail: "detail", retryLabel: "retryLabel", retryMolId: "retryMolId", onRetry: "onRetry" }, features: [i0.ɵɵHostDirectivesFeature([i1.MolPlacement])], ngContentSelectors: _c4, decls: 20, vars: 21, consts: [["detailSlot", ""], ["retrySlot", ""], ["retryLabelSlot", ""], ["mol-alert", "", 3, "status", "live"], [3, "molTemplateOutlet"], ["type", "button", 3, "click", "disabled"]], template: function LoadErrorBanner_Template(rf, ctx) { if (rf & 1) {
|
|
212
177
|
i0.ɵɵprojectionDef(_c3);
|
|
213
178
|
i0.ɵɵelementStart(0, "div", 3)(1, "div")(2, "p");
|
|
214
179
|
i0.ɵɵelementContainer(3, 4);
|
|
@@ -259,6 +224,7 @@ export class LoadErrorBanner {
|
|
|
259
224
|
args: [{
|
|
260
225
|
selector: 'div[mol-load-error-banner]',
|
|
261
226
|
standalone: true,
|
|
227
|
+
hostDirectives: [MolPlacement],
|
|
262
228
|
imports: [Alert, MolTemplateOutlet],
|
|
263
229
|
inputs: ['message', 'detail', 'retryLabel', 'retryMolId', 'onRetry'],
|
|
264
230
|
host: {
|
|
@@ -296,7 +262,7 @@ export class LoadErrorBanner {
|
|
|
296
262
|
</div>
|
|
297
263
|
</div>`,
|
|
298
264
|
}]
|
|
299
|
-
}],
|
|
265
|
+
}], () => [], { detailSlot: [{
|
|
300
266
|
type: ViewChild,
|
|
301
267
|
args: ['detailSlot']
|
|
302
268
|
}], retrySlot: [{
|
|
@@ -306,5 +272,5 @@ export class LoadErrorBanner {
|
|
|
306
272
|
type: ViewChild,
|
|
307
273
|
args: ['retryLabelSlot']
|
|
308
274
|
}] }); })();
|
|
309
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(LoadErrorBanner, { className: "LoadErrorBanner", filePath: "components/load-error-banner.component.ts", lineNumber:
|
|
275
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(LoadErrorBanner, { className: "LoadErrorBanner", filePath: "components/load-error-banner.component.ts", lineNumber: 95 }); })();
|
|
310
276
|
//# sourceMappingURL=load-error-banner.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-error-banner.component.js","sourceRoot":"","sources":["../../src/components/load-error-banner.component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"load-error-banner.component.js","sourceRoot":"","sources":["../../src/components/load-error-banner.component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAmB,MAAM,EAAoB,SAAS,EAAE,MAAM,eAAe,CAAA;AAE/F,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,iBAAiB,EAEjB,YAAY,EACZ,cAAc,GACf,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;;;;;;;;;;IA8DtD,2BACC;IAAA,YACH;;;IAFgB,wEAA4C;IACzD,cACH;IADG,kEACH;;;IACE,YACF;;;IADE,mDACF;;AA5CV;;;;;;;;GAQG;AA0CH,MAAM,OAAO,eAAe;IAC1B,iDAAiD;IACjD,OAAO,CAAkC;IACzC,2DAA2D;IAC3D,MAAM,CAAiC;IACvC,6CAA6C;IAC7C,UAAU,CAAqC;IAC/C,uEAAuE;IACvE,UAAU,GAAwC,kBAAkB,CAAA;IACpE,iFAAiF;IACjF,OAAO,CAAkC;IACzC,6DAA6D;IAC7D,SAAS,CAAoC;IAE7C,2DAA2D;IAClD,UAAU,GAAG,UAAU,CAAA;IAChC,gDAAgD;IACvC,QAAQ,GAAG,QAAQ,CAAA;IAC5B,4CAA4C;IACnC,OAAO,GAAG,OAAO,CAAA;IAE1B,oCAAoC;IAC3B,OAAO,GAAG,MAAM,CAAC,KAAK;gFAAC,CAAA;IAEhC,2EAA2E;IAClD,UAAU,CAAmC;IACtE,yEAAyE;IACjD,SAAS,CAA6B;IAC9D,qCAAqC;IACR,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;mBAAC,gBAAgB;;kFA7BhB,eAAe"}
|
|
@@ -8,15 +8,30 @@ import type { ModalSize, MouseEventHandler, UIClassMap } from '@molecule/app-ui'
|
|
|
8
8
|
import type { HasElement } from '../utilities/element.js';
|
|
9
9
|
import type { ResolvedIcon } from '../utilities/render-icon.js';
|
|
10
10
|
import * as i0 from "@angular/core";
|
|
11
|
+
import * as i1 from "@molecule/app-angular";
|
|
11
12
|
/**
|
|
12
13
|
* Modal component.
|
|
13
14
|
*
|
|
14
15
|
* React's root is a FRAGMENT portaled into `document.body` (an overlay
|
|
15
|
-
* `<div>` and a centering wrapper `<div>`), so the host
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* `<div>` and a centering wrapper `<div>`), so the host element leaves the
|
|
17
|
+
* page and both elements are moved into the body while open: the rendered
|
|
18
|
+
* tree is React's, with no wrapper at the component's place. Implements the
|
|
19
|
+
* WAI-ARIA APG modal dialog pattern (focus
|
|
18
20
|
* into the dialog on open, trapped Tab, focus restored on close, Escape for
|
|
19
21
|
* the topmost dialog only, reference-counted body scroll lock).
|
|
22
|
+
*
|
|
23
|
+
* Projected content is created with the consumer's view, so a closed modal's body and footer exist
|
|
24
|
+
* while hidden: their components, effects and fetches run. React mounts them only while shown, and
|
|
25
|
+
* again each time they show. Write content with state as `*molLazy` (`MolLazy` from
|
|
26
|
+
* `@molecule/app-angular`): it is created when it shows and destroyed when it hides, as React's is.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```html
|
|
30
|
+
* <mol-modal [open]="open" title="Edit profile" (close)="open = false">
|
|
31
|
+
* <form *molLazy>…</form>
|
|
32
|
+
* <div slot="footer" *molLazy><button mol-button (click)="save()">Save</button></div>
|
|
33
|
+
* </mol-modal>
|
|
34
|
+
* ```
|
|
20
35
|
*/
|
|
21
36
|
export declare class Modal implements AfterViewInit, AfterViewChecked, DoCheck, OnDestroy, HasElement<HTMLDivElement> {
|
|
22
37
|
/** Whether the dialog is open. */
|
|
@@ -49,7 +64,11 @@ export declare class Modal implements AfterViewInit, AfterViewChecked, DoCheck,
|
|
|
49
64
|
automationId?: string;
|
|
50
65
|
/** A `data-mol-id` given as a plain rest attribute (React's `rootProps` precedence). */
|
|
51
66
|
dataMolId?: string;
|
|
52
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* A caller's double-click handler on the dialog (React spreads rest onto it).
|
|
69
|
+
*
|
|
70
|
+
* @deprecated Bind `(dblclick)` on the tag: what a caller binds there lands on the dialog.
|
|
71
|
+
*/
|
|
53
72
|
onDoubleClick?: MouseEventHandler;
|
|
54
73
|
/** Fires when the dialog asks to close (React's `onClose`). */
|
|
55
74
|
readonly close: EventEmitter<MouseEvent | undefined>;
|
|
@@ -73,6 +92,8 @@ export declare class Modal implements AfterViewInit, AfterViewChecked, DoCheck,
|
|
|
73
92
|
private readonly inner;
|
|
74
93
|
/** The element a caller's ref receives: the dialog, or `null` while closed. */
|
|
75
94
|
readonly element: import("@angular/core").Signal<HTMLDivElement | null>;
|
|
95
|
+
/** Applies React's `{!!footer && <div className={dialogFooter}>…</div>}`. */
|
|
96
|
+
constructor();
|
|
76
97
|
/**
|
|
77
98
|
* Reactive translation, read in the injection context. Its `t` reads the
|
|
78
99
|
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
@@ -82,11 +103,9 @@ export declare class Modal implements AfterViewInit, AfterViewChecked, DoCheck,
|
|
|
82
103
|
private readonly sync;
|
|
83
104
|
private lastOpen;
|
|
84
105
|
private lastFooter;
|
|
85
|
-
private footerParent;
|
|
86
106
|
private previouslyFocused;
|
|
87
107
|
private listeners;
|
|
88
108
|
private locked;
|
|
89
|
-
private moved;
|
|
90
109
|
/** The `data-mol-id` a caller bound on the host (React spreads it onto the dialog). */
|
|
91
110
|
private externalMolId;
|
|
92
111
|
/**
|
|
@@ -148,29 +167,27 @@ export declare class Modal implements AfterViewInit, AfterViewChecked, DoCheck,
|
|
|
148
167
|
*/
|
|
149
168
|
ngAfterViewInit(): void;
|
|
150
169
|
/**
|
|
151
|
-
* Reconciles the open state
|
|
170
|
+
* Reconciles the open state on later passes.
|
|
152
171
|
*/
|
|
153
172
|
ngDoCheck(): void;
|
|
154
173
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* {@link
|
|
159
|
-
* first value while the host accumulates the new one. Modal spreads those
|
|
160
|
-
* attributes straight onto the dialog (it merges `aria-describedby` with
|
|
161
|
-
* nothing), so it re-moves that attribute too.
|
|
174
|
+
* Follows a `data-mol-id` the caller binds on the tag on every pass: React
|
|
175
|
+
* merges it with `automationId` on the dialog. Every other attribute, class,
|
|
176
|
+
* style and listener on the tag reaches the dialog through
|
|
177
|
+
* {@link setHostRoot}.
|
|
162
178
|
*/
|
|
163
179
|
ngAfterViewChecked(): void;
|
|
164
180
|
/** Removes listeners, unlocks scroll and restores the portal nodes (unmount). */
|
|
165
181
|
ngOnDestroy(): void;
|
|
166
182
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
183
|
+
* Applies React's `{!!footer && <div className={dialogFooter}>…</div>}`, and
|
|
184
|
+
* takes the host out of the page: everything React renders lives in the
|
|
185
|
+
* `document.body` portal, nothing at the component's place. What the caller
|
|
186
|
+
* binds on the tag lands on the dialog, React's `{...rest}` target.
|
|
187
|
+
*
|
|
188
|
+
* @param hasContent - Reads whether a slot has content.
|
|
170
189
|
*/
|
|
171
|
-
private
|
|
172
|
-
/** Applies React's `{!!footer && <div className={dialogFooter}>…</div>}`. */
|
|
173
|
-
private syncFooter;
|
|
190
|
+
private reconcileFooter;
|
|
174
191
|
/**
|
|
175
192
|
* Applies an open/closed transition (React mounts/unmounts the portal and
|
|
176
193
|
* its effects).
|
|
@@ -202,6 +219,6 @@ export declare class Modal implements AfterViewInit, AfterViewChecked, DoCheck,
|
|
|
202
219
|
*/
|
|
203
220
|
private handleKeyDown;
|
|
204
221
|
static ɵfac: i0.ɵɵFactoryDeclaration<Modal, never>;
|
|
205
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<Modal, "mol-modal", never, { "open": { "alias": "open"; "required": false; }; "title": { "alias": "title"; "required": false; }; "size": { "alias": "size"; "required": false; }; "showCloseButton": { "alias": "showCloseButton"; "required": false; }; "closeOnOverlayClick": { "alias": "closeOnOverlayClick"; "required": false; }; "closeOnEscape": { "alias": "closeOnEscape"; "required": false; }; "footer": { "alias": "footer"; "required": false; }; "centered": { "alias": "centered"; "required": false; }; "closeLabel": { "alias": "closeLabel"; "required": false; }; "preventScroll": { "alias": "preventScroll"; "required": false; }; "className": { "alias": "className"; "required": false; }; "style": { "alias": "style"; "required": false; }; "testId": { "alias": "testId"; "required": false; }; "automationId": { "alias": "automationId"; "required": false; }; "dataMolId": { "alias": "data-mol-id"; "required": false; }; "onDoubleClick": { "alias": "onDoubleClick"; "required": false; }; }, { "close": "close"; }, never, ["*", "[slot=footer]"], true,
|
|
222
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<Modal, "mol-modal", never, { "open": { "alias": "open"; "required": false; }; "title": { "alias": "title"; "required": false; }; "size": { "alias": "size"; "required": false; }; "showCloseButton": { "alias": "showCloseButton"; "required": false; }; "closeOnOverlayClick": { "alias": "closeOnOverlayClick"; "required": false; }; "closeOnEscape": { "alias": "closeOnEscape"; "required": false; }; "footer": { "alias": "footer"; "required": false; }; "centered": { "alias": "centered"; "required": false; }; "closeLabel": { "alias": "closeLabel"; "required": false; }; "preventScroll": { "alias": "preventScroll"; "required": false; }; "className": { "alias": "className"; "required": false; }; "style": { "alias": "style"; "required": false; }; "testId": { "alias": "testId"; "required": false; }; "automationId": { "alias": "automationId"; "required": false; }; "dataMolId": { "alias": "data-mol-id"; "required": false; }; "onDoubleClick": { "alias": "onDoubleClick"; "required": false; }; }, { "close": "close"; }, never, ["*", "[slot=footer]"], true, [{ directive: typeof i1.MolPlacement; inputs: {}; outputs: {}; }]>;
|
|
206
223
|
}
|
|
207
224
|
//# sourceMappingURL=modal.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.component.d.ts","sourceRoot":"","sources":["../../src/components/modal.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAElB,KAAK,OAAO,EACZ,UAAU,EAEV,YAAY,EAGZ,KAAK,SAAS,EAIf,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"modal.component.d.ts","sourceRoot":"","sources":["../../src/components/modal.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAElB,KAAK,OAAO,EACZ,UAAU,EAEV,YAAY,EAGZ,KAAK,SAAS,EAIf,MAAM,eAAe,CAAA;AAWtB,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGhF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;;;AAyB/D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBA+Ea,KACX,YAAW,aAAa,EAAE,gBAAgB,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,cAAc,CAAC;IAE1F,kCAAkC;IAClC,IAAI,UAAQ;IACZ,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2BAA2B;IAC3B,IAAI,EAAE,SAAS,CAAO;IACtB,+CAA+C;IAC/C,eAAe,UAAO;IACtB,sDAAsD;IACtD,mBAAmB,UAAO;IAC1B,wCAAwC;IACxC,aAAa,UAAO;IACpB,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,iDAAiD;IACjD,QAAQ,UAAO;IACf,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gDAAgD;IAChD,aAAa,UAAO;IACpB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*/
|
|
6
6
|
import { afterNextRender, Component, ElementRef, EnvironmentInjector, EventEmitter, inject, Injector, Output, signal, ViewChild, } from '@angular/core';
|
|
7
|
-
import { useTranslation } from '@molecule/app-angular';
|
|
7
|
+
import { MolPlacement, placeElement, setElementPresent, setHostRoot, usePlacement, useTranslation, } from '@molecule/app-angular';
|
|
8
8
|
import { getClassMap } from '@molecule/app-ui';
|
|
9
9
|
import { createScrollLock, getFocusableElements } from '../utilities/focus.js';
|
|
10
10
|
import { MolIconSvg, resolveIcon } from '../utilities/render-icon.js';
|
|
11
|
-
import { adoptHostDataMolId
|
|
11
|
+
import { adoptHostDataMolId } from '../utilities/rest-attrs.js';
|
|
12
12
|
import { styleText } from '../utilities/style.js';
|
|
13
13
|
import * as i0 from "@angular/core";
|
|
14
|
+
import * as i1 from "@molecule/app-angular";
|
|
14
15
|
const _c0 = ["overlay"];
|
|
15
16
|
const _c1 = ["wrapper"];
|
|
16
17
|
const _c2 = ["dialog"];
|
|
@@ -88,11 +89,25 @@ let modalInstance = 0;
|
|
|
88
89
|
* Modal component.
|
|
89
90
|
*
|
|
90
91
|
* React's root is a FRAGMENT portaled into `document.body` (an overlay
|
|
91
|
-
* `<div>` and a centering wrapper `<div>`), so the host
|
|
92
|
-
*
|
|
93
|
-
*
|
|
92
|
+
* `<div>` and a centering wrapper `<div>`), so the host element leaves the
|
|
93
|
+
* page and both elements are moved into the body while open: the rendered
|
|
94
|
+
* tree is React's, with no wrapper at the component's place. Implements the
|
|
95
|
+
* WAI-ARIA APG modal dialog pattern (focus
|
|
94
96
|
* into the dialog on open, trapped Tab, focus restored on close, Escape for
|
|
95
97
|
* the topmost dialog only, reference-counted body scroll lock).
|
|
98
|
+
*
|
|
99
|
+
* Projected content is created with the consumer's view, so a closed modal's body and footer exist
|
|
100
|
+
* while hidden: their components, effects and fetches run. React mounts them only while shown, and
|
|
101
|
+
* again each time they show. Write content with state as `*molLazy` (`MolLazy` from
|
|
102
|
+
* `@molecule/app-angular`): it is created when it shows and destroyed when it hides, as React's is.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```html
|
|
106
|
+
* <mol-modal [open]="open" title="Edit profile" (close)="open = false">
|
|
107
|
+
* <form *molLazy>…</form>
|
|
108
|
+
* <div slot="footer" *molLazy><button mol-button (click)="save()">Save</button></div>
|
|
109
|
+
* </mol-modal>
|
|
110
|
+
* ```
|
|
96
111
|
*/
|
|
97
112
|
export class Modal {
|
|
98
113
|
/** Whether the dialog is open. */
|
|
@@ -125,7 +140,11 @@ export class Modal {
|
|
|
125
140
|
automationId;
|
|
126
141
|
/** A `data-mol-id` given as a plain rest attribute (React's `rootProps` precedence). */
|
|
127
142
|
dataMolId;
|
|
128
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* A caller's double-click handler on the dialog (React spreads rest onto it).
|
|
145
|
+
*
|
|
146
|
+
* @deprecated Bind `(dblclick)` on the tag: what a caller binds there lands on the dialog.
|
|
147
|
+
*/
|
|
129
148
|
onDoubleClick;
|
|
130
149
|
/** Fires when the dialog asks to close (React's `onClose`). */
|
|
131
150
|
close = new EventEmitter();
|
|
@@ -150,6 +169,10 @@ export class Modal {
|
|
|
150
169
|
...(ngDevMode ? [{ debugName: "inner" }] : /* istanbul ignore next */ []));
|
|
151
170
|
/** The element a caller's ref receives: the dialog, or `null` while closed. */
|
|
152
171
|
element = this.inner.asReadonly();
|
|
172
|
+
/** Applies React's `{!!footer && <div className={dialogFooter}>…</div>}`. */
|
|
173
|
+
constructor() {
|
|
174
|
+
usePlacement((hasContent) => this.reconcileFooter(hasContent));
|
|
175
|
+
}
|
|
153
176
|
/**
|
|
154
177
|
* Reactive translation, read in the injection context. Its `t` reads the
|
|
155
178
|
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
@@ -159,11 +182,9 @@ export class Modal {
|
|
|
159
182
|
sync = createScrollLock();
|
|
160
183
|
lastOpen = false;
|
|
161
184
|
lastFooter = false;
|
|
162
|
-
footerParent = null;
|
|
163
185
|
previouslyFocused = null;
|
|
164
186
|
listeners = [];
|
|
165
187
|
locked = false;
|
|
166
|
-
moved = false;
|
|
167
188
|
/** The `data-mol-id` a caller bound on the host (React spreads it onto the dialog). */
|
|
168
189
|
externalMolId;
|
|
169
190
|
/**
|
|
@@ -252,15 +273,11 @@ export class Modal {
|
|
|
252
273
|
const overlay = this.overlay?.nativeElement;
|
|
253
274
|
const wrapper = this.wrapper?.nativeElement;
|
|
254
275
|
const dialog = this.dialog?.nativeElement;
|
|
255
|
-
this.footerParent = this.footerSlot?.nativeElement.parentElement ?? null;
|
|
256
276
|
if (dialog) {
|
|
257
277
|
adoptHostDataMolId(this.host.nativeElement, dialog, (id) => {
|
|
258
278
|
this.externalMolId = id;
|
|
259
279
|
}, () => this.molId());
|
|
260
|
-
moveRestAttributes(this.host.nativeElement, dialog);
|
|
261
280
|
}
|
|
262
|
-
this.lastFooter = this.hasFooter();
|
|
263
|
-
this.syncFooter();
|
|
264
281
|
const open = !!this.open;
|
|
265
282
|
if (open) {
|
|
266
283
|
this.previouslyFocused = document.activeElement ?? null;
|
|
@@ -278,7 +295,7 @@ export class Modal {
|
|
|
278
295
|
this.lastOpen = open;
|
|
279
296
|
}
|
|
280
297
|
/**
|
|
281
|
-
* Reconciles the open state
|
|
298
|
+
* Reconciles the open state on later passes.
|
|
282
299
|
*/
|
|
283
300
|
ngDoCheck() {
|
|
284
301
|
const open = !!this.open;
|
|
@@ -286,26 +303,18 @@ export class Modal {
|
|
|
286
303
|
this.lastOpen = open;
|
|
287
304
|
this.transition(open);
|
|
288
305
|
}
|
|
289
|
-
this.lastFooter = this.hasFooter();
|
|
290
|
-
this.syncFooter();
|
|
291
306
|
this.syncScrollLock();
|
|
292
307
|
}
|
|
293
308
|
/**
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
* {@link
|
|
298
|
-
* first value while the host accumulates the new one. Modal spreads those
|
|
299
|
-
* attributes straight onto the dialog (it merges `aria-describedby` with
|
|
300
|
-
* nothing), so it re-moves that attribute too.
|
|
309
|
+
* Follows a `data-mol-id` the caller binds on the tag on every pass: React
|
|
310
|
+
* merges it with `automationId` on the dialog. Every other attribute, class,
|
|
311
|
+
* style and listener on the tag reaches the dialog through
|
|
312
|
+
* {@link setHostRoot}.
|
|
301
313
|
*/
|
|
302
314
|
ngAfterViewChecked() {
|
|
303
315
|
adoptHostDataMolId(this.host.nativeElement, this.dialog?.nativeElement, (id) => {
|
|
304
316
|
this.externalMolId = id;
|
|
305
317
|
}, () => this.molId());
|
|
306
|
-
reapplyRestAttributes(this.host.nativeElement, this.dialog?.nativeElement, {
|
|
307
|
-
includeDescribedBy: true,
|
|
308
|
-
});
|
|
309
318
|
}
|
|
310
319
|
/** Removes listeners, unlocks scroll and restores the portal nodes (unmount). */
|
|
311
320
|
ngOnDestroy() {
|
|
@@ -325,49 +334,20 @@ export class Modal {
|
|
|
325
334
|
this.sync.unlock();
|
|
326
335
|
this.locked = false;
|
|
327
336
|
}
|
|
328
|
-
// The portal nodes must be children of the host again for Angular's own
|
|
329
|
-
// removal to succeed.
|
|
330
|
-
const host = this.host.nativeElement;
|
|
331
|
-
if (this.moved) {
|
|
332
|
-
const overlay = this.overlay?.nativeElement;
|
|
333
|
-
const wrapper = this.wrapper?.nativeElement;
|
|
334
|
-
if (overlay?.parentNode === document.body)
|
|
335
|
-
host.appendChild(overlay);
|
|
336
|
-
if (wrapper?.parentNode === document.body)
|
|
337
|
-
host.appendChild(wrapper);
|
|
338
|
-
this.moved = false;
|
|
339
|
-
}
|
|
340
337
|
}
|
|
341
338
|
/**
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
339
|
+
* Applies React's `{!!footer && <div className={dialogFooter}>…</div>}`, and
|
|
340
|
+
* takes the host out of the page: everything React renders lives in the
|
|
341
|
+
* `document.body` portal, nothing at the component's place. What the caller
|
|
342
|
+
* binds on the tag lands on the dialog, React's `{...rest}` target.
|
|
343
|
+
*
|
|
344
|
+
* @param hasContent - Reads whether a slot has content.
|
|
345
345
|
*/
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
if (node.nodeType === 1)
|
|
352
|
-
return true;
|
|
353
|
-
if (node.nodeType === 3 && (node.textContent ?? '').trim())
|
|
354
|
-
return true;
|
|
355
|
-
}
|
|
356
|
-
return false;
|
|
357
|
-
}
|
|
358
|
-
/** Applies React's `{!!footer && <div className={dialogFooter}>…</div>}`. */
|
|
359
|
-
syncFooter() {
|
|
360
|
-
const slot = this.footerSlot?.nativeElement;
|
|
361
|
-
if (!slot)
|
|
362
|
-
return;
|
|
363
|
-
const shouldRender = this.lastFooter;
|
|
364
|
-
if (shouldRender && !slot.isConnected) {
|
|
365
|
-
;
|
|
366
|
-
(this.footerParent ?? this.dialog?.nativeElement ?? null)?.appendChild(slot);
|
|
367
|
-
}
|
|
368
|
-
else if (!shouldRender && slot.isConnected) {
|
|
369
|
-
slot.remove();
|
|
370
|
-
}
|
|
346
|
+
reconcileFooter(hasContent) {
|
|
347
|
+
this.lastFooter = hasContent(this.footerSlot?.nativeElement);
|
|
348
|
+
setElementPresent(this.footerSlot?.nativeElement, this.lastFooter);
|
|
349
|
+
setElementPresent(this.host.nativeElement, false);
|
|
350
|
+
setHostRoot(this.host.nativeElement, this.dialog?.nativeElement, { except: ['data-mol-id'] });
|
|
371
351
|
}
|
|
372
352
|
/**
|
|
373
353
|
* Applies an open/closed transition (React mounts/unmounts the portal and
|
|
@@ -419,17 +399,17 @@ export class Modal {
|
|
|
419
399
|
const wrapper = this.wrapper?.nativeElement;
|
|
420
400
|
if (!overlay || !wrapper)
|
|
421
401
|
return;
|
|
422
|
-
document.body
|
|
423
|
-
document.body
|
|
402
|
+
placeElement(overlay, document.body);
|
|
403
|
+
placeElement(wrapper, document.body);
|
|
424
404
|
this.inner.set(this.dialog?.nativeElement ?? null);
|
|
425
|
-
this.moved = true;
|
|
426
405
|
}
|
|
427
406
|
/** Removes the portal nodes from the document (React renders null). */
|
|
428
407
|
detachPortal() {
|
|
429
|
-
this.overlay?.nativeElement
|
|
430
|
-
this.
|
|
408
|
+
placeElement(this.overlay?.nativeElement, null);
|
|
409
|
+
setElementPresent(this.overlay?.nativeElement, false);
|
|
410
|
+
placeElement(this.wrapper?.nativeElement, null);
|
|
411
|
+
setElementPresent(this.wrapper?.nativeElement, false);
|
|
431
412
|
this.inner.set(null);
|
|
432
|
-
this.moved = false;
|
|
433
413
|
}
|
|
434
414
|
/** Locks or unlocks body scroll for React's `open && preventScroll`. */
|
|
435
415
|
syncScrollLock() {
|
|
@@ -501,7 +481,7 @@ export class Modal {
|
|
|
501
481
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.wrapper = _t.first);
|
|
502
482
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dialog = _t.first);
|
|
503
483
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.footerSlot = _t.first);
|
|
504
|
-
} },
|
|
484
|
+
} }, 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", automationId: "automationId", dataMolId: [0, "data-mol-id", "dataMolId"], onDoubleClick: "onDoubleClick" }, outputs: { close: "close" }, features: [i0.ɵɵHostDirectivesFeature([i1.MolPlacement])], ngContentSelectors: _c5, decls: 13, vars: 18, consts: [["overlay", ""], ["wrapper", ""], ["dialog", ""], ["footerSlot", ""], ["aria-hidden", "true"], ["role", "presentation", 3, "click"], ["role", "dialog", "aria-modal", "true", "tabindex", "-1", 3, "dblclick"], [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) {
|
|
505
485
|
i0.ɵɵprojectionDef(_c4);
|
|
506
486
|
i0.ɵɵelement(0, "div", 4, 0);
|
|
507
487
|
i0.ɵɵelementStart(2, "div", 5, 1);
|
|
@@ -537,6 +517,7 @@ export class Modal {
|
|
|
537
517
|
args: [{
|
|
538
518
|
selector: 'mol-modal',
|
|
539
519
|
standalone: true,
|
|
520
|
+
hostDirectives: [MolPlacement],
|
|
540
521
|
imports: [MolIconSvg],
|
|
541
522
|
inputs: [
|
|
542
523
|
'open',
|
|
@@ -557,10 +538,6 @@ export class Modal {
|
|
|
557
538
|
'onDoubleClick',
|
|
558
539
|
],
|
|
559
540
|
outputs: ['close'],
|
|
560
|
-
host: {
|
|
561
|
-
'data-parity-unwrap': '',
|
|
562
|
-
style: 'display: contents',
|
|
563
|
-
},
|
|
564
541
|
template: `<div #overlay [class]="cm().dialogOverlay" aria-hidden="true"></div>
|
|
565
542
|
<div
|
|
566
543
|
#wrapper
|
|
@@ -616,7 +593,7 @@ export class Modal {
|
|
|
616
593
|
</div>
|
|
617
594
|
</div>`,
|
|
618
595
|
}]
|
|
619
|
-
}],
|
|
596
|
+
}], () => [], { close: [{
|
|
620
597
|
type: Output
|
|
621
598
|
}], overlay: [{
|
|
622
599
|
type: ViewChild,
|
|
@@ -631,5 +608,5 @@ export class Modal {
|
|
|
631
608
|
type: ViewChild,
|
|
632
609
|
args: ['footerSlot']
|
|
633
610
|
}] }); })();
|
|
634
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Modal, { className: "Modal", filePath: "components/modal.component.ts", lineNumber:
|
|
611
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Modal, { className: "Modal", filePath: "components/modal.component.ts", lineNumber: 166 }); })();
|
|
635
612
|
//# sourceMappingURL=modal.component.js.map
|