@shival99/z-ui 0.0.1 → 1.0.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/assets/css/animations.css +207 -0
- package/assets/css/base.css +76 -0
- package/assets/css/tailwind.css +53 -0
- package/assets/css/themes/gray.css +73 -0
- package/assets/css/themes/green.css +75 -0
- package/assets/css/themes/hospital.css +79 -0
- package/assets/css/themes/neutral.css +73 -0
- package/assets/css/themes/orange.css +73 -0
- package/assets/css/themes/slate.css +73 -0
- package/assets/css/themes/stone.css +73 -0
- package/assets/css/themes/violet.css +73 -0
- package/assets/css/themes/zinc.css +73 -0
- package/assets/images/avatar.svg +6 -0
- package/assets/images/logo.svg +6 -0
- package/fesm2022/shival99-z-ui-components-z-accordion.mjs +148 -0
- package/fesm2022/shival99-z-ui-components-z-accordion.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-breadcrumb.mjs +74 -0
- package/fesm2022/shival99-z-ui-components-z-breadcrumb.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-button.mjs +155 -0
- package/fesm2022/shival99-z-ui-components-z-button.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-calendar.mjs +2335 -0
- package/fesm2022/shival99-z-ui-components-z-calendar.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-checkbox.mjs +240 -0
- package/fesm2022/shival99-z-ui-components-z-checkbox.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-code.mjs +139 -0
- package/fesm2022/shival99-z-ui-components-z-code.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-drawer.mjs +664 -0
- package/fesm2022/shival99-z-ui-components-z-drawer.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-dropdown-menu.mjs +55 -0
- package/fesm2022/shival99-z-ui-components-z-dropdown-menu.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-editor.mjs +411 -0
- package/fesm2022/shival99-z-ui-components-z-editor.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-filter.mjs +794 -0
- package/fesm2022/shival99-z-ui-components-z-filter.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-icon.mjs +451 -0
- package/fesm2022/shival99-z-ui-components-z-icon.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-input.mjs +804 -0
- package/fesm2022/shival99-z-ui-components-z-input.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-loading.mjs +105 -0
- package/fesm2022/shival99-z-ui-components-z-loading.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-menu.mjs +351 -0
- package/fesm2022/shival99-z-ui-components-z-menu.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-modal.mjs +722 -0
- package/fesm2022/shival99-z-ui-components-z-modal.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-pagination.mjs +131 -0
- package/fesm2022/shival99-z-ui-components-z-pagination.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-popover.mjs +917 -0
- package/fesm2022/shival99-z-ui-components-z-popover.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-radio.mjs +154 -0
- package/fesm2022/shival99-z-ui-components-z-radio.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-select.mjs +998 -0
- package/fesm2022/shival99-z-ui-components-z-select.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-skeleton.mjs +139 -0
- package/fesm2022/shival99-z-ui-components-z-skeleton.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-switch.mjs +127 -0
- package/fesm2022/shival99-z-ui-components-z-switch.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-table.mjs +2628 -0
- package/fesm2022/shival99-z-ui-components-z-table.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-tabs.mjs +259 -0
- package/fesm2022/shival99-z-ui-components-z-tabs.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-timeline.mjs +335 -0
- package/fesm2022/shival99-z-ui-components-z-timeline.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-toast.mjs +93 -0
- package/fesm2022/shival99-z-ui-components-z-toast.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-tooltip.mjs +660 -0
- package/fesm2022/shival99-z-ui-components-z-tooltip.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-upload.mjs +504 -0
- package/fesm2022/shival99-z-ui-components-z-upload.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-i18n.mjs +258 -0
- package/fesm2022/shival99-z-ui-i18n.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-pipes.mjs +116 -0
- package/fesm2022/shival99-z-ui-pipes.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-providers.mjs +203 -0
- package/fesm2022/shival99-z-ui-providers.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-services.mjs +919 -0
- package/fesm2022/shival99-z-ui-services.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-utils.mjs +591 -0
- package/fesm2022/shival99-z-ui-utils.mjs.map +1 -0
- package/fesm2022/z-ui.mjs +3 -19924
- package/fesm2022/z-ui.mjs.map +1 -1
- package/package.json +129 -1
- package/types/shival99-z-ui-components-z-accordion.d.ts +55 -0
- package/types/shival99-z-ui-components-z-breadcrumb.d.ts +36 -0
- package/types/shival99-z-ui-components-z-button.d.ts +41 -0
- package/types/shival99-z-ui-components-z-calendar.d.ts +300 -0
- package/types/shival99-z-ui-components-z-checkbox.d.ts +84 -0
- package/types/shival99-z-ui-components-z-code.d.ts +35 -0
- package/types/shival99-z-ui-components-z-drawer.d.ts +232 -0
- package/types/shival99-z-ui-components-z-dropdown-menu.d.ts +50 -0
- package/types/shival99-z-ui-components-z-editor.d.ts +115 -0
- package/types/shival99-z-ui-components-z-filter.d.ts +268 -0
- package/types/shival99-z-ui-components-z-icon.d.ts +291 -0
- package/types/shival99-z-ui-components-z-input.d.ts +188 -0
- package/types/shival99-z-ui-components-z-loading.d.ts +46 -0
- package/types/shival99-z-ui-components-z-menu.d.ts +116 -0
- package/types/shival99-z-ui-components-z-modal.d.ts +270 -0
- package/types/shival99-z-ui-components-z-pagination.d.ts +52 -0
- package/types/shival99-z-ui-components-z-popover.d.ts +134 -0
- package/types/shival99-z-ui-components-z-radio.d.ts +63 -0
- package/types/shival99-z-ui-components-z-select.d.ts +268 -0
- package/types/shival99-z-ui-components-z-skeleton.d.ts +55 -0
- package/types/shival99-z-ui-components-z-switch.d.ts +48 -0
- package/types/shival99-z-ui-components-z-table.d.ts +482 -0
- package/types/shival99-z-ui-components-z-tabs.d.ts +75 -0
- package/types/shival99-z-ui-components-z-timeline.d.ts +98 -0
- package/types/shival99-z-ui-components-z-toast.d.ts +61 -0
- package/types/shival99-z-ui-components-z-tooltip.d.ts +85 -0
- package/types/shival99-z-ui-components-z-upload.d.ts +136 -0
- package/types/shival99-z-ui-i18n.d.ts +50 -0
- package/types/shival99-z-ui-pipes.d.ts +36 -0
- package/types/shival99-z-ui-providers.d.ts +132 -0
- package/types/shival99-z-ui-services.d.ts +364 -0
- package/types/shival99-z-ui-utils.d.ts +145 -0
- package/types/z-ui.d.ts +3 -4977
|
@@ -0,0 +1,722 @@
|
|
|
1
|
+
import { Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
|
|
2
|
+
import * as i1 from '@angular/cdk/portal';
|
|
3
|
+
import { BasePortalOutlet, CdkPortalOutlet, TemplatePortal, PortalModule, ComponentPortal } from '@angular/cdk/portal';
|
|
4
|
+
import { isPlatformBrowser, NgTemplateOutlet } from '@angular/common';
|
|
5
|
+
import * as i0 from '@angular/core';
|
|
6
|
+
import { inject, TemplateRef, Directive, InjectionToken, output, input, model, contentChild, viewChild, PLATFORM_ID, ElementRef, ViewContainerRef, ChangeDetectorRef, signal, computed, effect, ChangeDetectionStrategy, Component, EventEmitter, Inject, Injector, Injectable } from '@angular/core';
|
|
7
|
+
import { zDetectBrowser, zMergeClasses } from '@shival99/z-ui/utils';
|
|
8
|
+
import { cva } from 'class-variance-authority';
|
|
9
|
+
import { ZContentTypePipe, ZSafeHtmlPipe } from '@shival99/z-ui/pipes';
|
|
10
|
+
import { ZButtonComponent } from '@shival99/z-ui/components/z-button';
|
|
11
|
+
import { ZIconComponent } from '@shival99/z-ui/components/z-icon';
|
|
12
|
+
import { ZSkeletonComponent } from '@shival99/z-ui/components/z-skeleton';
|
|
13
|
+
import { __decorate, __param, __metadata } from 'tslib';
|
|
14
|
+
import { Subject, takeUntil, fromEvent, filter } from 'rxjs';
|
|
15
|
+
|
|
16
|
+
class ZModalContentDirective {
|
|
17
|
+
templateRef = inject((TemplateRef));
|
|
18
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZModalContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
19
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.6", type: ZModalContentDirective, isStandalone: true, selector: "[z-modal-content], [zModalContent]", ngImport: i0 });
|
|
20
|
+
}
|
|
21
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZModalContentDirective, decorators: [{
|
|
22
|
+
type: Directive,
|
|
23
|
+
args: [{
|
|
24
|
+
selector: '[z-modal-content], [zModalContent]',
|
|
25
|
+
standalone: true,
|
|
26
|
+
}]
|
|
27
|
+
}] });
|
|
28
|
+
|
|
29
|
+
class ZModalFooterDirective {
|
|
30
|
+
templateRef = inject((TemplateRef));
|
|
31
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZModalFooterDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
32
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.6", type: ZModalFooterDirective, isStandalone: true, selector: "[z-modal-footer], [zModalFooter]", ngImport: i0 });
|
|
33
|
+
}
|
|
34
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZModalFooterDirective, decorators: [{
|
|
35
|
+
type: Directive,
|
|
36
|
+
args: [{
|
|
37
|
+
selector: '[z-modal-footer], [zModalFooter]',
|
|
38
|
+
standalone: true,
|
|
39
|
+
}]
|
|
40
|
+
}] });
|
|
41
|
+
|
|
42
|
+
class ZModalHeaderDirective {
|
|
43
|
+
templateRef = inject((TemplateRef));
|
|
44
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZModalHeaderDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
45
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.6", type: ZModalHeaderDirective, isStandalone: true, selector: "[z-modal-header], [zModalHeader]", ngImport: i0 });
|
|
46
|
+
}
|
|
47
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZModalHeaderDirective, decorators: [{
|
|
48
|
+
type: Directive,
|
|
49
|
+
args: [{
|
|
50
|
+
selector: '[z-modal-header], [zModalHeader]',
|
|
51
|
+
standalone: true,
|
|
52
|
+
}]
|
|
53
|
+
}] });
|
|
54
|
+
|
|
55
|
+
const Z_MODAL_DATA = new InjectionToken('Z_MODAL_DATA');
|
|
56
|
+
const Z_MODAL_ANIMATION_DURATION = 200;
|
|
57
|
+
var ZModalTriggerAction;
|
|
58
|
+
(function (ZModalTriggerAction) {
|
|
59
|
+
ZModalTriggerAction["CANCEL"] = "cancel";
|
|
60
|
+
ZModalTriggerAction["OK"] = "ok";
|
|
61
|
+
})(ZModalTriggerAction || (ZModalTriggerAction = {}));
|
|
62
|
+
const noopFun = () => { };
|
|
63
|
+
/**
|
|
64
|
+
* Configuration options for z-modal component.
|
|
65
|
+
*
|
|
66
|
+
* @template T - The type of the content component
|
|
67
|
+
* @template U - The type of the data passed to the modal
|
|
68
|
+
*/
|
|
69
|
+
class ZModalOptions {
|
|
70
|
+
/** Icon for the cancel button */
|
|
71
|
+
zCancelIcon;
|
|
72
|
+
/** Text for the cancel button. Set to null to hide the button */
|
|
73
|
+
zCancelText;
|
|
74
|
+
/** Whether the modal is closable (shows close button) */
|
|
75
|
+
zClosable;
|
|
76
|
+
/** Confirm type for preset styling (show, info, warning, danger) */
|
|
77
|
+
zConfirmType;
|
|
78
|
+
/** Icon for the confirm modal */
|
|
79
|
+
zConfirmIcon;
|
|
80
|
+
/** Modal content - can be a component, template, or string */
|
|
81
|
+
zContent;
|
|
82
|
+
/** Custom CSS classes for the modal */
|
|
83
|
+
class;
|
|
84
|
+
/** Data to be passed to the content component via Z_MODAL_DATA token */
|
|
85
|
+
zData;
|
|
86
|
+
/**
|
|
87
|
+
* Observable for deferred data loading before showing modal content.
|
|
88
|
+
* Modal will show a loading spinner until the Observable completes.
|
|
89
|
+
* The resolved data will be available via Z_MODAL_DATA.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* this.modalService.create({
|
|
94
|
+
* zDefer: this.userService.getUser(userId),
|
|
95
|
+
* zContent: UserFormComponent,
|
|
96
|
+
* });
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
zDefer;
|
|
100
|
+
/** Description text shown below the title */
|
|
101
|
+
zDescription;
|
|
102
|
+
/** Whether to hide the default footer */
|
|
103
|
+
zHideFooter;
|
|
104
|
+
/**
|
|
105
|
+
* WritableSignal to control loading state of the OK button.
|
|
106
|
+
* Use this when submitting forms or calling APIs.
|
|
107
|
+
*
|
|
108
|
+
* @example Using with confirm modal (delete action)
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const modalRef = this.modalService.danger({
|
|
111
|
+
* zTitle: 'Delete Item',
|
|
112
|
+
* zContent: 'Are you sure you want to delete this item?',
|
|
113
|
+
* zOkText: 'Delete',
|
|
114
|
+
* zOnOk: () => {
|
|
115
|
+
* modalRef.setLoading(true);
|
|
116
|
+
* this.api.delete(itemId).subscribe({
|
|
117
|
+
* next: () => {
|
|
118
|
+
* modalRef.setLoading(false);
|
|
119
|
+
* modalRef.close();
|
|
120
|
+
* },
|
|
121
|
+
* error: () => modalRef.setLoading(false),
|
|
122
|
+
* });
|
|
123
|
+
* return false; // Prevent auto-close
|
|
124
|
+
* },
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
zLoading;
|
|
129
|
+
/** Whether clicking mask closes the modal */
|
|
130
|
+
zMaskClosable;
|
|
131
|
+
/** Whether OK button has destructive (red) style */
|
|
132
|
+
zOkDestructive;
|
|
133
|
+
/** Whether OK button is disabled */
|
|
134
|
+
zOkDisabled;
|
|
135
|
+
/** Overlay style: 'dark' (black overlay) or 'blur' (backdrop blur) */
|
|
136
|
+
zOverlay;
|
|
137
|
+
/** Icon for the OK button */
|
|
138
|
+
zOkIcon;
|
|
139
|
+
/** Text for the OK button. Set to null to hide the button */
|
|
140
|
+
zOkText;
|
|
141
|
+
/** Callback or EventEmitter when cancel is clicked */
|
|
142
|
+
zOnCancel = noopFun;
|
|
143
|
+
/** Callback or EventEmitter when OK is clicked */
|
|
144
|
+
zOnOk = noopFun;
|
|
145
|
+
/** Modal title - supports string, HTML string, or TemplateRef */
|
|
146
|
+
zTitle;
|
|
147
|
+
/** ViewContainerRef for the modal portal */
|
|
148
|
+
zViewContainerRef;
|
|
149
|
+
/** Modal width (e.g., '425px', '80%') */
|
|
150
|
+
zWidth;
|
|
151
|
+
/** WritableSignal to control content loading state (shows skeleton when true) */
|
|
152
|
+
zContentLoading;
|
|
153
|
+
/** Number of skeleton rows to show when content is loading */
|
|
154
|
+
zSkeletonRows;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const getOverlayType = () => {
|
|
158
|
+
const browser = zDetectBrowser();
|
|
159
|
+
return browser.name === 'Chrome' ? 'dark' : 'blur';
|
|
160
|
+
};
|
|
161
|
+
const Z_MODAL_CONFIRM_CONFIG = {
|
|
162
|
+
show: {
|
|
163
|
+
icon: 'lucideMessageCircleQuestion',
|
|
164
|
+
colors: {
|
|
165
|
+
ring: 'bg-gray-500/10',
|
|
166
|
+
bg: 'bg-gray-500/15',
|
|
167
|
+
icon: 'text-gray-600!',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
info: {
|
|
171
|
+
icon: 'lucideInfo',
|
|
172
|
+
colors: {
|
|
173
|
+
ring: 'bg-blue-500/10',
|
|
174
|
+
bg: 'bg-blue-500/15',
|
|
175
|
+
icon: 'text-blue-500!',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
warning: {
|
|
179
|
+
icon: 'lucideTriangleAlert',
|
|
180
|
+
colors: {
|
|
181
|
+
ring: 'bg-amber-500/10',
|
|
182
|
+
bg: 'bg-amber-500/15',
|
|
183
|
+
icon: 'text-amber-500!',
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
danger: {
|
|
187
|
+
icon: 'lucideX',
|
|
188
|
+
okDestructive: true,
|
|
189
|
+
colors: {
|
|
190
|
+
ring: 'bg-red-500/10',
|
|
191
|
+
bg: 'bg-red-500/15',
|
|
192
|
+
icon: 'text-red-500!',
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const zModalVariants = cva([
|
|
198
|
+
'fixed left-[50%] top-[50%] z-50 flex flex-col w-full translate-x-[-50%]',
|
|
199
|
+
'translate-y-[-50%] border bg-background py-4 shadow-lg rounded-lg',
|
|
200
|
+
'max-w-[calc(100%-2rem)] overflow-hidden',
|
|
201
|
+
'max-h-[80dvh]',
|
|
202
|
+
].join(' '));
|
|
203
|
+
|
|
204
|
+
class ZModalComponent extends BasePortalOutlet {
|
|
205
|
+
zOk = output();
|
|
206
|
+
zCancel = output();
|
|
207
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : []));
|
|
208
|
+
zVisible = model(false, ...(ngDevMode ? [{ debugName: "zVisible" }] : []));
|
|
209
|
+
zTitle = input(...(ngDevMode ? [undefined, { debugName: "zTitle" }] : []));
|
|
210
|
+
zDescription = input(...(ngDevMode ? [undefined, { debugName: "zDescription" }] : []));
|
|
211
|
+
zWidth = input('500px', ...(ngDevMode ? [{ debugName: "zWidth" }] : []));
|
|
212
|
+
zClosable = input(true, ...(ngDevMode ? [{ debugName: "zClosable" }] : []));
|
|
213
|
+
zMaskClosable = input(true, ...(ngDevMode ? [{ debugName: "zMaskClosable" }] : []));
|
|
214
|
+
zHideFooter = input(false, ...(ngDevMode ? [{ debugName: "zHideFooter" }] : []));
|
|
215
|
+
zOkText = input('OK', ...(ngDevMode ? [{ debugName: "zOkText" }] : []));
|
|
216
|
+
zCancelText = input('Cancel', ...(ngDevMode ? [{ debugName: "zCancelText" }] : []));
|
|
217
|
+
zOkDestructive = input(false, ...(ngDevMode ? [{ debugName: "zOkDestructive" }] : []));
|
|
218
|
+
zOkDisabled = input(false, ...(ngDevMode ? [{ debugName: "zOkDisabled" }] : []));
|
|
219
|
+
zLoading = input(false, ...(ngDevMode ? [{ debugName: "zLoading" }] : []));
|
|
220
|
+
zContentLoading = input(false, ...(ngDevMode ? [{ debugName: "zContentLoading" }] : []));
|
|
221
|
+
zSkeletonRows = input(3, ...(ngDevMode ? [{ debugName: "zSkeletonRows" }] : []));
|
|
222
|
+
zOverlay = input(getOverlayType(), ...(ngDevMode ? [{ debugName: "zOverlay" }] : []));
|
|
223
|
+
customHeader = contentChild(ZModalHeaderDirective, ...(ngDevMode ? [{ debugName: "customHeader" }] : []));
|
|
224
|
+
customContent = contentChild(ZModalContentDirective, ...(ngDevMode ? [{ debugName: "customContent" }] : []));
|
|
225
|
+
customFooter = contentChild(ZModalFooterDirective, ...(ngDevMode ? [{ debugName: "customFooter" }] : []));
|
|
226
|
+
modalRef;
|
|
227
|
+
portalOutlet = viewChild(CdkPortalOutlet, ...(ngDevMode ? [{ debugName: "portalOutlet" }] : []));
|
|
228
|
+
dummyTemplateRef = viewChild('dummyTemplate', ...(ngDevMode ? [{ debugName: "dummyTemplateRef" }] : []));
|
|
229
|
+
mainContentRef = viewChild('mainContent', ...(ngDevMode ? [{ debugName: "mainContentRef" }] : []));
|
|
230
|
+
config = inject((ZModalOptions), { optional: true }) || new ZModalOptions();
|
|
231
|
+
_platformId = inject(PLATFORM_ID);
|
|
232
|
+
_host = inject((ElementRef));
|
|
233
|
+
_overlay = inject(Overlay);
|
|
234
|
+
_viewContainerRef = inject(ViewContainerRef);
|
|
235
|
+
_cdr = inject(ChangeDetectorRef);
|
|
236
|
+
_templateOverlayRef = null;
|
|
237
|
+
_originalParent = null;
|
|
238
|
+
_originalNextSibling = null;
|
|
239
|
+
_backdropSubscription = null;
|
|
240
|
+
isLeaving = signal(false, ...(ngDevMode ? [{ debugName: "isLeaving" }] : []));
|
|
241
|
+
hasScrollableContent = signal(false, ...(ngDevMode ? [{ debugName: "hasScrollableContent" }] : []));
|
|
242
|
+
isScrolledFromTop = signal(false, ...(ngDevMode ? [{ debugName: "isScrolledFromTop" }] : []));
|
|
243
|
+
isScrolledToBottom = signal(false, ...(ngDevMode ? [{ debugName: "isScrolledToBottom" }] : []));
|
|
244
|
+
isServiceMode = computed(() => !!this.modalRef, ...(ngDevMode ? [{ debugName: "isServiceMode" }] : []));
|
|
245
|
+
isTemplateMode = computed(() => !this.isServiceMode(), ...(ngDevMode ? [{ debugName: "isTemplateMode" }] : []));
|
|
246
|
+
isConfirmMode = computed(() => !!this.config.zConfirmType, ...(ngDevMode ? [{ debugName: "isConfirmMode" }] : []));
|
|
247
|
+
shouldRenderContent = computed(() => this.zVisible() || this.isLeaving(), ...(ngDevMode ? [{ debugName: "shouldRenderContent" }] : []));
|
|
248
|
+
isStringContent = computed(() => typeof this.config.zContent === 'string' && !this.isConfirmMode(), ...(ngDevMode ? [{ debugName: "isStringContent" }] : []));
|
|
249
|
+
shouldShowShadow = computed(() => true, ...(ngDevMode ? [{ debugName: "shouldShowShadow" }] : []));
|
|
250
|
+
_lastScrollHeight = 0;
|
|
251
|
+
ngAfterViewChecked() {
|
|
252
|
+
this._checkScrollState();
|
|
253
|
+
}
|
|
254
|
+
_checkScrollState() {
|
|
255
|
+
const scrollbar = this.mainContentRef();
|
|
256
|
+
if (!scrollbar) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const viewport = scrollbar.nativeElement.querySelector('.ng-scroll-viewport');
|
|
260
|
+
if (!viewport) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (viewport.scrollHeight === this._lastScrollHeight) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
this._lastScrollHeight = viewport.scrollHeight;
|
|
267
|
+
const hasVerticalScroll = viewport.scrollHeight > viewport.clientHeight;
|
|
268
|
+
this.hasScrollableContent.set(hasVerticalScroll);
|
|
269
|
+
}
|
|
270
|
+
onContentScroll(event) {
|
|
271
|
+
const target = event.target;
|
|
272
|
+
if (!target) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const { scrollTop } = target;
|
|
276
|
+
const { scrollHeight } = target;
|
|
277
|
+
const { clientHeight } = target;
|
|
278
|
+
this.isScrolledFromTop.set(scrollTop > 0);
|
|
279
|
+
this.isScrolledToBottom.set(scrollTop + clientHeight >= scrollHeight - 1);
|
|
280
|
+
}
|
|
281
|
+
confirmIconColors = computed(() => {
|
|
282
|
+
const type = this.config.zConfirmType ?? 'show';
|
|
283
|
+
return Z_MODAL_CONFIRM_CONFIG[type].colors;
|
|
284
|
+
}, ...(ngDevMode ? [{ debugName: "confirmIconColors" }] : []));
|
|
285
|
+
effectiveTitle = computed(() => (this.isServiceMode() ? this.config.zTitle : this.zTitle()), ...(ngDevMode ? [{ debugName: "effectiveTitle" }] : []));
|
|
286
|
+
effectiveDescription = computed(() => this.isServiceMode() ? this.config.zDescription : this.zDescription(), ...(ngDevMode ? [{ debugName: "effectiveDescription" }] : []));
|
|
287
|
+
effectiveClosable = computed(() => this.isServiceMode() ? (this.config.zClosable ?? true) : this.zClosable(), ...(ngDevMode ? [{ debugName: "effectiveClosable" }] : []));
|
|
288
|
+
effectiveHideFooter = computed(() => this.isServiceMode() ? this.config.zHideFooter : this.zHideFooter(), ...(ngDevMode ? [{ debugName: "effectiveHideFooter" }] : []));
|
|
289
|
+
effectiveOkText = computed(() => (this.isServiceMode() ? this.config.zOkText : this.zOkText()), ...(ngDevMode ? [{ debugName: "effectiveOkText" }] : []));
|
|
290
|
+
effectiveCancelText = computed(() => this.isServiceMode() ? this.config.zCancelText : this.zCancelText(), ...(ngDevMode ? [{ debugName: "effectiveCancelText" }] : []));
|
|
291
|
+
effectiveOkDestructive = computed(() => this.isServiceMode() ? this.config.zOkDestructive : this.zOkDestructive(), ...(ngDevMode ? [{ debugName: "effectiveOkDestructive" }] : []));
|
|
292
|
+
effectiveTypeOk = computed(() => {
|
|
293
|
+
if (!this.isServiceMode()) {
|
|
294
|
+
return 'default';
|
|
295
|
+
}
|
|
296
|
+
const typeMap = {
|
|
297
|
+
show: 'default',
|
|
298
|
+
info: 'info',
|
|
299
|
+
warning: 'warning',
|
|
300
|
+
danger: 'error',
|
|
301
|
+
};
|
|
302
|
+
const confirmType = this.config.zConfirmType;
|
|
303
|
+
return confirmType ? (typeMap[confirmType] ?? 'default') : 'default';
|
|
304
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveTypeOk" }] : []));
|
|
305
|
+
effectiveOkDisabled = computed(() => this.isServiceMode() ? this.config.zOkDisabled : this.zOkDisabled(), ...(ngDevMode ? [{ debugName: "effectiveOkDisabled" }] : []));
|
|
306
|
+
effectiveLoading = computed(() => {
|
|
307
|
+
if (this.isServiceMode()) {
|
|
308
|
+
return this.modalRef?.loading() || (this.config.zLoading?.() ?? false);
|
|
309
|
+
}
|
|
310
|
+
return this.zLoading();
|
|
311
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveLoading" }] : []));
|
|
312
|
+
effectiveContentLoading = computed(() => {
|
|
313
|
+
if (this.isServiceMode()) {
|
|
314
|
+
return this.config.zContentLoading?.() ?? false;
|
|
315
|
+
}
|
|
316
|
+
return this.zContentLoading();
|
|
317
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveContentLoading" }] : []));
|
|
318
|
+
effectiveSkeletonRows = computed(() => {
|
|
319
|
+
if (this.isServiceMode()) {
|
|
320
|
+
return this.config.zSkeletonRows ?? 3;
|
|
321
|
+
}
|
|
322
|
+
return this.zSkeletonRows();
|
|
323
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveSkeletonRows" }] : []));
|
|
324
|
+
effectiveWidth = computed(() => {
|
|
325
|
+
if (this.isServiceMode()) {
|
|
326
|
+
return this.zWidth() || this.config.zWidth || null;
|
|
327
|
+
}
|
|
328
|
+
return this.shouldRenderContent() ? this.zWidth() : null;
|
|
329
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveWidth" }] : []));
|
|
330
|
+
isDeferLoading = computed(() => {
|
|
331
|
+
if (!this.isServiceMode()) {
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
return !!this.config.zDefer && !this.portalOutlet()?.hasAttached();
|
|
335
|
+
}, ...(ngDevMode ? [{ debugName: "isDeferLoading" }] : []));
|
|
336
|
+
classes = computed(() => zMergeClasses(zModalVariants(), this.isServiceMode() ? this.config.class : this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : []));
|
|
337
|
+
hostClasses = computed(() => {
|
|
338
|
+
const baseClasses = this.classes();
|
|
339
|
+
if (this.isServiceMode()) {
|
|
340
|
+
return `${baseClasses} z-modal-service-mode`.trim();
|
|
341
|
+
}
|
|
342
|
+
if (this.shouldRenderContent()) {
|
|
343
|
+
return `${baseClasses} z-modal-template-mode`.trim();
|
|
344
|
+
}
|
|
345
|
+
return 'z-modal-template-host';
|
|
346
|
+
}, ...(ngDevMode ? [{ debugName: "hostClasses" }] : []));
|
|
347
|
+
constructor() {
|
|
348
|
+
super();
|
|
349
|
+
effect(() => {
|
|
350
|
+
const visible = this.zVisible();
|
|
351
|
+
if (visible && this.isTemplateMode() && !this._templateOverlayRef) {
|
|
352
|
+
this._openTemplateOverlay();
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (!visible && this.isTemplateMode() && this._templateOverlayRef && !this.isLeaving()) {
|
|
356
|
+
this._closeWithAnimation();
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
ngOnDestroy() {
|
|
361
|
+
this._disposeTemplateOverlay();
|
|
362
|
+
}
|
|
363
|
+
getNativeElement() {
|
|
364
|
+
return this._host.nativeElement;
|
|
365
|
+
}
|
|
366
|
+
attachComponentPortal(portal) {
|
|
367
|
+
this._cdr.detectChanges();
|
|
368
|
+
const outlet = this.portalOutlet();
|
|
369
|
+
if (outlet?.hasAttached()) {
|
|
370
|
+
throw new Error('Attempting to attach modal content after content is already attached');
|
|
371
|
+
}
|
|
372
|
+
return outlet?.attachComponentPortal(portal);
|
|
373
|
+
}
|
|
374
|
+
attachTemplatePortal(portal) {
|
|
375
|
+
const outlet = this.portalOutlet();
|
|
376
|
+
if (outlet?.hasAttached()) {
|
|
377
|
+
throw new Error('Attempting to attach modal content after content is already attached');
|
|
378
|
+
}
|
|
379
|
+
return outlet?.attachTemplatePortal(portal);
|
|
380
|
+
}
|
|
381
|
+
onOkClick() {
|
|
382
|
+
if (this.effectiveLoading()) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
this.zOk.emit();
|
|
386
|
+
}
|
|
387
|
+
onCloseClick() {
|
|
388
|
+
this.zCancel.emit();
|
|
389
|
+
if (this.isTemplateMode() && !this.effectiveLoading()) {
|
|
390
|
+
this._closeWithAnimation();
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
onBackdropClick() {
|
|
394
|
+
if (this.zMaskClosable() && !this.effectiveLoading()) {
|
|
395
|
+
this._closeWithAnimation();
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
open() {
|
|
399
|
+
this.isLeaving.set(false);
|
|
400
|
+
this.zVisible.set(true);
|
|
401
|
+
}
|
|
402
|
+
close() {
|
|
403
|
+
this._closeWithAnimation();
|
|
404
|
+
}
|
|
405
|
+
_createOverlay() {
|
|
406
|
+
if (!isPlatformBrowser(this._platformId)) {
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
const overlayType = getOverlayType();
|
|
410
|
+
const backdropClass = overlayType === 'blur' ? 'z-modal-backdrop-blur' : 'z-modal-backdrop-dark';
|
|
411
|
+
const overlayConfig = new OverlayConfig({
|
|
412
|
+
hasBackdrop: true,
|
|
413
|
+
backdropClass,
|
|
414
|
+
positionStrategy: this._overlay.position().global(),
|
|
415
|
+
scrollStrategy: this._overlay.scrollStrategies.block(),
|
|
416
|
+
});
|
|
417
|
+
return this._overlay.create(overlayConfig);
|
|
418
|
+
}
|
|
419
|
+
_openTemplateOverlay() {
|
|
420
|
+
if (this._templateOverlayRef) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
const dummyRef = this.dummyTemplateRef();
|
|
424
|
+
if (!dummyRef) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
this._templateOverlayRef = this._createOverlay();
|
|
428
|
+
if (!this._templateOverlayRef) {
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
const hostElement = this._host.nativeElement;
|
|
432
|
+
this._originalParent = hostElement.parentElement;
|
|
433
|
+
this._originalNextSibling = hostElement.nextSibling;
|
|
434
|
+
const portal = new TemplatePortal(dummyRef, this._viewContainerRef);
|
|
435
|
+
this._templateOverlayRef.attach(portal);
|
|
436
|
+
const overlayPane = this._templateOverlayRef.overlayElement;
|
|
437
|
+
overlayPane.style.position = 'static';
|
|
438
|
+
overlayPane.appendChild(hostElement);
|
|
439
|
+
this._backdropSubscription = this._templateOverlayRef.backdropClick().subscribe(() => {
|
|
440
|
+
this.onBackdropClick();
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
_closeWithAnimation() {
|
|
444
|
+
if (this.isLeaving()) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
this.isLeaving.set(true);
|
|
448
|
+
this.zVisible.set(false);
|
|
449
|
+
const hostElement = this._host.nativeElement;
|
|
450
|
+
const { backdropElement } = this._templateOverlayRef ?? {};
|
|
451
|
+
if (backdropElement) {
|
|
452
|
+
backdropElement.classList.add('z-backdrop-leaving');
|
|
453
|
+
}
|
|
454
|
+
hostElement.classList.add('modal-leave');
|
|
455
|
+
setTimeout(() => {
|
|
456
|
+
this.isLeaving.set(false);
|
|
457
|
+
this._disposeTemplateOverlay();
|
|
458
|
+
}, Z_MODAL_ANIMATION_DURATION);
|
|
459
|
+
}
|
|
460
|
+
_disposeTemplateOverlay() {
|
|
461
|
+
const hostElement = this._host.nativeElement;
|
|
462
|
+
if (this._originalParent && this._originalNextSibling) {
|
|
463
|
+
this._originalParent.insertBefore(hostElement, this._originalNextSibling);
|
|
464
|
+
}
|
|
465
|
+
if (this._originalParent && !this._originalNextSibling) {
|
|
466
|
+
this._originalParent.appendChild(hostElement);
|
|
467
|
+
}
|
|
468
|
+
hostElement.classList.remove('modal-leave');
|
|
469
|
+
if (this._templateOverlayRef) {
|
|
470
|
+
this._templateOverlayRef.dispose();
|
|
471
|
+
this._templateOverlayRef = null;
|
|
472
|
+
}
|
|
473
|
+
this._originalParent = null;
|
|
474
|
+
this._originalNextSibling = null;
|
|
475
|
+
if (this._backdropSubscription) {
|
|
476
|
+
this._backdropSubscription.unsubscribe();
|
|
477
|
+
this._backdropSubscription = null;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZModalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
481
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.6", type: ZModalComponent, isStandalone: true, selector: "z-modal", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, zVisible: { classPropertyName: "zVisible", publicName: "zVisible", isSignal: true, isRequired: false, transformFunction: null }, zTitle: { classPropertyName: "zTitle", publicName: "zTitle", isSignal: true, isRequired: false, transformFunction: null }, zDescription: { classPropertyName: "zDescription", publicName: "zDescription", isSignal: true, isRequired: false, transformFunction: null }, zWidth: { classPropertyName: "zWidth", publicName: "zWidth", isSignal: true, isRequired: false, transformFunction: null }, zClosable: { classPropertyName: "zClosable", publicName: "zClosable", isSignal: true, isRequired: false, transformFunction: null }, zMaskClosable: { classPropertyName: "zMaskClosable", publicName: "zMaskClosable", isSignal: true, isRequired: false, transformFunction: null }, zHideFooter: { classPropertyName: "zHideFooter", publicName: "zHideFooter", isSignal: true, isRequired: false, transformFunction: null }, zOkText: { classPropertyName: "zOkText", publicName: "zOkText", isSignal: true, isRequired: false, transformFunction: null }, zCancelText: { classPropertyName: "zCancelText", publicName: "zCancelText", isSignal: true, isRequired: false, transformFunction: null }, zOkDestructive: { classPropertyName: "zOkDestructive", publicName: "zOkDestructive", isSignal: true, isRequired: false, transformFunction: null }, zOkDisabled: { classPropertyName: "zOkDisabled", publicName: "zOkDisabled", isSignal: true, isRequired: false, transformFunction: null }, zLoading: { classPropertyName: "zLoading", publicName: "zLoading", isSignal: true, isRequired: false, transformFunction: null }, zContentLoading: { classPropertyName: "zContentLoading", publicName: "zContentLoading", isSignal: true, isRequired: false, transformFunction: null }, zSkeletonRows: { classPropertyName: "zSkeletonRows", publicName: "zSkeletonRows", isSignal: true, isRequired: false, transformFunction: null }, zOverlay: { classPropertyName: "zOverlay", publicName: "zOverlay", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { zOk: "zOk", zCancel: "zCancel", zVisible: "zVisibleChange" }, host: { properties: { "class": "hostClasses()", "style.width": "effectiveWidth()" } }, queries: [{ propertyName: "customHeader", first: true, predicate: ZModalHeaderDirective, descendants: true, isSignal: true }, { propertyName: "customContent", first: true, predicate: ZModalContentDirective, descendants: true, isSignal: true }, { propertyName: "customFooter", first: true, predicate: ZModalFooterDirective, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "portalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true, isSignal: true }, { propertyName: "dummyTemplateRef", first: true, predicate: ["dummyTemplate"], descendants: true, isSignal: true }, { propertyName: "mainContentRef", first: true, predicate: ["mainContent"], descendants: true, isSignal: true }], exportAs: ["zModal"], usesInheritance: true, ngImport: i0, template: "<!-- Dummy template to trigger CDK backdrop creation -->\n<ng-template #dummyTemplate />\n\n<!-- Template mode content (rendered in host element, which is moved to overlay) -->\n@if (isTemplateMode() && shouldRenderContent()) {\n @defer (when !effectiveContentLoading()) {\n @if (customHeader(); as headerDir) {\n <header [class.z-modal-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex items-start justify-between px-4\">\n <ng-container *ngTemplateOutlet=\"headerDir.templateRef\" />\n </div>\n </header>\n } @else if (effectiveTitle()) {\n <header [class.z-modal-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex w-full items-start justify-between overflow-hidden px-4\">\n <div class=\"min-w-0 flex-1 overflow-hidden pr-2\">\n @if (effectiveTitle(); as title) {\n @switch (title | zContentType) {\n @case ('template') {\n <ng-container *ngTemplateOutlet=\"$any(title)\" />\n }\n @case ('html') {\n <h4\n data-testid=\"z-modal-title\"\n class=\"m-0 truncate text-base leading-snug font-semibold\"\n z-tooltip\n [zContent]=\"title\"\n [innerHTML]=\"$any(title) | zSafeHtml\"></h4>\n }\n @default {\n <h4\n data-testid=\"z-modal-title\"\n class=\"m-0 truncate text-base leading-snug font-semibold\"\n z-tooltip\n [zContent]=\"title\">\n {{ title }}\n </h4>\n }\n }\n }\n @if (effectiveDescription(); as description) {\n @switch (description | zContentType) {\n @case ('template') {\n <ng-container *ngTemplateOutlet=\"$any(description)\" />\n }\n @case ('html') {\n <p\n data-testid=\"z-modal-description\"\n class=\"text-muted-foreground m-0 mt-1 text-sm\"\n [innerHTML]=\"$any(description) | zSafeHtml\"></p>\n }\n @default {\n <p data-testid=\"z-modal-description\" class=\"text-muted-foreground m-0 mt-1 text-sm\">\n {{ description }}\n </p>\n }\n }\n }\n </div>\n @if (effectiveClosable()) {\n <button\n type=\"button\"\n data-testid=\"z-modal-close-header-button\"\n z-button\n zType=\"subtle\"\n zSize=\"xs\"\n [zWave]=\"false\"\n (click)=\"onCloseClick()\">\n <z-icon zType=\"lucideX\" />\n </button>\n }\n </div>\n </header>\n } @else if (effectiveClosable()) {\n <header [class.z-modal-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex justify-end px-4\">\n <button\n type=\"button\"\n data-testid=\"z-modal-close-header-button\"\n z-button\n zType=\"subtle\"\n zSize=\"xs\"\n [zWave]=\"false\"\n (click)=\"onCloseClick()\">\n <z-icon zType=\"lucideX\" />\n </button>\n </div>\n </header>\n }\n\n <ng-scrollbar class=\"z-modal-scrollbar flex-1\" #mainContent track=\"vertical\" (scroll)=\"onContentScroll($event)\">\n <main class=\"flex min-h-0 flex-col gap-4 px-4 py-4\">\n @if (customContent(); as contentDir) {\n <ng-container *ngTemplateOutlet=\"contentDir.templateRef\" />\n } @else {\n <ng-content />\n }\n </main>\n </ng-scrollbar>\n\n @if (customFooter(); as footerDir) {\n <footer [class.z-modal-footer-shadow]=\"shouldShowShadow()\">\n <div class=\"flex flex-row justify-end gap-2 px-4\">\n <ng-container *ngTemplateOutlet=\"footerDir.templateRef\" />\n </div>\n </footer>\n } @else if (!effectiveHideFooter()) {\n <footer [class.z-modal-footer-shadow]=\"shouldShowShadow()\">\n <div class=\"flex flex-row justify-end gap-2 px-4\">\n @if (effectiveCancelText() !== null) {\n <button type=\"button\" data-testid=\"z-modal-cancel-button\" z-button zType=\"outline\" (click)=\"onCloseClick()\">\n {{ effectiveCancelText() ?? 'Cancel' }}\n </button>\n }\n\n @if (effectiveOkText() !== null) {\n <button\n type=\"button\"\n data-testid=\"z-modal-ok-button\"\n z-button\n [zType]=\"effectiveOkDestructive() ? 'destructive' : 'default'\"\n [disabled]=\"effectiveOkDisabled() || effectiveLoading()\"\n [zLoading]=\"effectiveLoading()\"\n (click)=\"onOkClick()\">\n {{ effectiveOkText() ?? 'OK' }}\n </button>\n }\n </div>\n </footer>\n }\n } @placeholder {\n <div class=\"flex h-[200px] flex-col gap-4 px-4\">\n <z-skeleton [zRows]=\"effectiveSkeletonRows()\" />\n </div>\n }\n}\n\n<!-- Service mode content -->\n@if (isServiceMode()) {\n <!-- Confirm Modal Layout (no skeleton) -->\n @if (isConfirmMode()) {\n <div class=\"flex flex-col items-center px-4 pt-2 text-center\">\n @if (config.zConfirmIcon) {\n <div class=\"relative mb-4 flex size-20 items-center justify-center\">\n <div class=\"absolute inset-0 rounded-full\" [class]=\"confirmIconColors().ring\"></div>\n <div class=\"relative flex size-14 items-center justify-center rounded-full\" [class]=\"confirmIconColors().bg\">\n <z-icon [zType]=\"config.zConfirmIcon\" zSize=\"30\" [zStrokeWidth]=\"2.6\" [class]=\"confirmIconColors().icon\" />\n </div>\n </div>\n }\n\n <!-- Title centered -->\n @if (effectiveTitle(); as title) {\n @switch (title | zContentType) {\n @case ('template') {\n <ng-container *ngTemplateOutlet=\"$any(title)\" />\n }\n @case ('html') {\n <h4\n data-testid=\"z-modal-title\"\n class=\"m-0 text-lg leading-snug font-semibold\"\n [innerHTML]=\"$any(title) | zSafeHtml\"></h4>\n }\n @default {\n <h4 data-testid=\"z-modal-title\" class=\"m-0 text-lg leading-snug font-semibold\">\n {{ title }}\n </h4>\n }\n }\n }\n\n <!-- Description centered -->\n @if (config.zContent; as content) {\n <p\n data-testid=\"z-modal-description\"\n class=\"text-muted-foreground m-0 mt-2 text-sm\"\n [innerHTML]=\"$any(content) | zSafeHtml\"></p>\n }\n </div>\n\n <!-- Footer centered -->\n @if (!effectiveHideFooter()) {\n <footer class=\"mt-4 flex flex-row justify-center gap-3 pb-2\">\n @if (effectiveCancelText() !== null) {\n <button type=\"button\" data-testid=\"z-modal-cancel-button\" z-button zType=\"outline\" (click)=\"onCloseClick()\">\n {{ effectiveCancelText() ?? 'Cancel' }}\n </button>\n }\n\n @if (effectiveOkText() !== null) {\n <button\n type=\"button\"\n data-testid=\"z-modal-ok-button\"\n z-button\n [zType]=\"effectiveTypeOk()\"\n [disabled]=\"effectiveOkDisabled() || effectiveLoading()\"\n [zLoading]=\"effectiveLoading()\"\n (click)=\"onOkClick()\">\n {{ effectiveOkText() ?? 'OK' }}\n </button>\n }\n </footer>\n }\n } @else {\n <!-- Normal Modal Layout with defer -->\n @defer (when !effectiveContentLoading()) {\n @if (effectiveTitle()) {\n <header [class.z-modal-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex w-full items-start justify-between overflow-hidden px-4\">\n <div class=\"min-w-0 flex-1 overflow-hidden pr-2\">\n @if (effectiveTitle(); as title) {\n @switch (title | zContentType) {\n @case ('template') {\n <ng-container *ngTemplateOutlet=\"$any(title)\" />\n }\n @case ('html') {\n <h4\n data-testid=\"z-modal-title\"\n class=\"m-0 truncate text-base leading-snug font-semibold\"\n z-tooltip\n [zContent]=\"title\"\n [innerHTML]=\"$any(title) | zSafeHtml\"></h4>\n }\n @default {\n <h4\n data-testid=\"z-modal-title\"\n class=\"m-0 truncate text-base leading-snug font-semibold\"\n z-tooltip\n [zContent]=\"title\">\n {{ title }}\n </h4>\n }\n }\n }\n </div>\n @if (effectiveClosable()) {\n <button\n type=\"button\"\n data-testid=\"z-modal-close-header-button\"\n z-button\n zType=\"subtle\"\n zSize=\"xs\"\n [zWave]=\"false\"\n (click)=\"onCloseClick()\">\n <z-icon zType=\"lucideX\" />\n </button>\n }\n </div>\n </header>\n } @else if (effectiveClosable()) {\n <header [class.z-modal-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex justify-end px-4\">\n <button\n type=\"button\"\n data-testid=\"z-modal-close-header-button\"\n z-button\n zType=\"subtle\"\n zSize=\"xs\"\n [zWave]=\"false\"\n (click)=\"onCloseClick()\">\n <z-icon zType=\"lucideX\" />\n </button>\n </div>\n </header>\n }\n\n <ng-scrollbar class=\"z-modal-scrollbar flex-1\" #mainContent track=\"vertical\" (scroll)=\"onContentScroll($event)\">\n <main class=\"flex min-h-0 flex-col gap-4 px-4 py-4\">\n <ng-template cdkPortalOutlet />\n\n @if (isStringContent()) {\n <div data-testid=\"z-modal-content\" [innerHTML]=\"$any(config.zContent) | zSafeHtml\"></div>\n }\n </main>\n </ng-scrollbar>\n\n @if (!effectiveHideFooter()) {\n <footer [class.z-modal-footer-shadow]=\"shouldShowShadow()\">\n <div class=\"flex flex-row justify-end gap-2 px-4\">\n @if (effectiveCancelText() !== null) {\n <button\n type=\"button\"\n data-testid=\"z-modal-cancel-button\"\n z-button\n zType=\"outline\"\n (click)=\"onCloseClick()\">\n @if (config.zCancelIcon) {\n <z-icon [zType]=\"config.zCancelIcon\" />\n }\n {{ effectiveCancelText() ?? 'Cancel' }}\n </button>\n }\n\n @if (effectiveOkText() !== null) {\n <button\n type=\"button\"\n data-testid=\"z-modal-ok-button\"\n z-button\n [zType]=\"effectiveOkDestructive() ? 'destructive' : 'default'\"\n [disabled]=\"effectiveOkDisabled() || effectiveLoading()\"\n [zLoading]=\"effectiveLoading()\"\n (click)=\"onOkClick()\">\n @if (config.zOkIcon && !effectiveLoading()) {\n <z-icon [zType]=\"config.zOkIcon\" />\n }\n {{ effectiveOkText() ?? 'OK' }}\n </button>\n }\n </div>\n </footer>\n }\n } @placeholder {\n <div class=\"flex h-[200px] flex-col gap-4 px-4\">\n <z-skeleton [zRows]=\"effectiveSkeletonRows()\" />\n </div>\n }\n }\n}\n", styles: [":host.z-modal-service-mode,:host.z-modal-template-mode{--z-enter-opacity: 0;--z-enter-translate-y: -8px;--z-enter-scale: .95;animation:z-enter .18s cubic-bezier(.32,.72,0,1) forwards}:host.z-modal-service-mode.modal-leave,:host.z-modal-template-mode.modal-leave{--z-exit-opacity: 0;--z-exit-translate-y: -8px;--z-exit-scale: .95;animation:z-exit .15s cubic-bezier(.32,.72,0,1) forwards}:host.z-modal-template-host{display:contents}::ng-deep .z-modal-backdrop-dark{background-color:#0009;animation:z-backdrop-enter .15s ease-out forwards}::ng-deep .z-modal-backdrop-blur{background-color:#0000000d;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);animation:z-backdrop-enter .15s ease-out forwards}::ng-deep .z-modal-backdrop-dark.z-backdrop-leaving,::ng-deep .z-modal-backdrop-blur.z-backdrop-leaving{animation:z-backdrop-exit .12s ease-in forwards}.z-modal-header-shadow{padding-bottom:16px;box-shadow:0 2px 8px -2px #0000001a}.z-modal-footer-shadow{padding-top:16px;box-shadow:0 -2px 8px -2px #0000001a}:host main{overscroll-behavior:contain}:host header,:host footer{transition:box-shadow .2s ease-out,padding .2s ease-out}.z-modal-scrollbar{--scrollbar-padding: 2px}\n"], dependencies: [{ kind: "ngmodule", type: PortalModule }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: ZButtonComponent, selector: "z-button, button[z-button], a[z-button]", inputs: ["class", "zType", "zSize", "zShape", "zLabel", "zLoading", "zDisabled", "zTypeIcon", "zSizeIcon", "zStrokeWidthIcon", "zWave"], exportAs: ["zButton"] }, { kind: "component", type: ZIconComponent, selector: "z-icon, [z-icon]", inputs: ["class", "zType", "zSize", "zStrokeWidth", "zSvg"] }, { kind: "component", type: ZSkeletonComponent, selector: "z-skeleton", inputs: ["zType", "zSize", "zWidth", "zHeight", "zRows", "zGap", "zAnimated", "zRadius", "zClass"] }, { kind: "pipe", type: ZContentTypePipe, name: "zContentType" }, { kind: "pipe", type: ZSafeHtmlPipe, name: "zSafeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, deferBlockDependencies: [() => [NgTemplateOutlet,
|
|
482
|
+
ZButtonComponent,
|
|
483
|
+
ZIconComponent, import('@shival99/z-ui/components/z-tooltip').then(m => m.ZTooltipDirective), import('ngx-scrollbar').then(m => m.NgScrollbar), ZContentTypePipe,
|
|
484
|
+
ZSafeHtmlPipe], () => [i1.CdkPortalOutlet, NgTemplateOutlet,
|
|
485
|
+
ZButtonComponent,
|
|
486
|
+
ZIconComponent, import('@shival99/z-ui/components/z-tooltip').then(m => m.ZTooltipDirective), import('ngx-scrollbar').then(m => m.NgScrollbar), ZContentTypePipe,
|
|
487
|
+
ZSafeHtmlPipe]] });
|
|
488
|
+
}
|
|
489
|
+
i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "21.0.6", ngImport: i0, type: ZModalComponent, resolveDeferredDeps: () => [import('@shival99/z-ui/components/z-tooltip').then(m => m.ZTooltipDirective), import('ngx-scrollbar').then(m => m.NgScrollbar)], resolveMetadata: (ZTooltipDirective, NgScrollbar) => ({ decorators: [{
|
|
490
|
+
type: Component,
|
|
491
|
+
args: [{ selector: 'z-modal', imports: [
|
|
492
|
+
PortalModule,
|
|
493
|
+
NgTemplateOutlet,
|
|
494
|
+
ZButtonComponent,
|
|
495
|
+
ZIconComponent,
|
|
496
|
+
ZContentTypePipe,
|
|
497
|
+
ZTooltipDirective,
|
|
498
|
+
ZSkeletonComponent,
|
|
499
|
+
NgScrollbar,
|
|
500
|
+
ZSafeHtmlPipe,
|
|
501
|
+
], standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
502
|
+
'[class]': 'hostClasses()',
|
|
503
|
+
'[style.width]': 'effectiveWidth()',
|
|
504
|
+
}, exportAs: 'zModal', template: "<!-- Dummy template to trigger CDK backdrop creation -->\n<ng-template #dummyTemplate />\n\n<!-- Template mode content (rendered in host element, which is moved to overlay) -->\n@if (isTemplateMode() && shouldRenderContent()) {\n @defer (when !effectiveContentLoading()) {\n @if (customHeader(); as headerDir) {\n <header [class.z-modal-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex items-start justify-between px-4\">\n <ng-container *ngTemplateOutlet=\"headerDir.templateRef\" />\n </div>\n </header>\n } @else if (effectiveTitle()) {\n <header [class.z-modal-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex w-full items-start justify-between overflow-hidden px-4\">\n <div class=\"min-w-0 flex-1 overflow-hidden pr-2\">\n @if (effectiveTitle(); as title) {\n @switch (title | zContentType) {\n @case ('template') {\n <ng-container *ngTemplateOutlet=\"$any(title)\" />\n }\n @case ('html') {\n <h4\n data-testid=\"z-modal-title\"\n class=\"m-0 truncate text-base leading-snug font-semibold\"\n z-tooltip\n [zContent]=\"title\"\n [innerHTML]=\"$any(title) | zSafeHtml\"></h4>\n }\n @default {\n <h4\n data-testid=\"z-modal-title\"\n class=\"m-0 truncate text-base leading-snug font-semibold\"\n z-tooltip\n [zContent]=\"title\">\n {{ title }}\n </h4>\n }\n }\n }\n @if (effectiveDescription(); as description) {\n @switch (description | zContentType) {\n @case ('template') {\n <ng-container *ngTemplateOutlet=\"$any(description)\" />\n }\n @case ('html') {\n <p\n data-testid=\"z-modal-description\"\n class=\"text-muted-foreground m-0 mt-1 text-sm\"\n [innerHTML]=\"$any(description) | zSafeHtml\"></p>\n }\n @default {\n <p data-testid=\"z-modal-description\" class=\"text-muted-foreground m-0 mt-1 text-sm\">\n {{ description }}\n </p>\n }\n }\n }\n </div>\n @if (effectiveClosable()) {\n <button\n type=\"button\"\n data-testid=\"z-modal-close-header-button\"\n z-button\n zType=\"subtle\"\n zSize=\"xs\"\n [zWave]=\"false\"\n (click)=\"onCloseClick()\">\n <z-icon zType=\"lucideX\" />\n </button>\n }\n </div>\n </header>\n } @else if (effectiveClosable()) {\n <header [class.z-modal-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex justify-end px-4\">\n <button\n type=\"button\"\n data-testid=\"z-modal-close-header-button\"\n z-button\n zType=\"subtle\"\n zSize=\"xs\"\n [zWave]=\"false\"\n (click)=\"onCloseClick()\">\n <z-icon zType=\"lucideX\" />\n </button>\n </div>\n </header>\n }\n\n <ng-scrollbar class=\"z-modal-scrollbar flex-1\" #mainContent track=\"vertical\" (scroll)=\"onContentScroll($event)\">\n <main class=\"flex min-h-0 flex-col gap-4 px-4 py-4\">\n @if (customContent(); as contentDir) {\n <ng-container *ngTemplateOutlet=\"contentDir.templateRef\" />\n } @else {\n <ng-content />\n }\n </main>\n </ng-scrollbar>\n\n @if (customFooter(); as footerDir) {\n <footer [class.z-modal-footer-shadow]=\"shouldShowShadow()\">\n <div class=\"flex flex-row justify-end gap-2 px-4\">\n <ng-container *ngTemplateOutlet=\"footerDir.templateRef\" />\n </div>\n </footer>\n } @else if (!effectiveHideFooter()) {\n <footer [class.z-modal-footer-shadow]=\"shouldShowShadow()\">\n <div class=\"flex flex-row justify-end gap-2 px-4\">\n @if (effectiveCancelText() !== null) {\n <button type=\"button\" data-testid=\"z-modal-cancel-button\" z-button zType=\"outline\" (click)=\"onCloseClick()\">\n {{ effectiveCancelText() ?? 'Cancel' }}\n </button>\n }\n\n @if (effectiveOkText() !== null) {\n <button\n type=\"button\"\n data-testid=\"z-modal-ok-button\"\n z-button\n [zType]=\"effectiveOkDestructive() ? 'destructive' : 'default'\"\n [disabled]=\"effectiveOkDisabled() || effectiveLoading()\"\n [zLoading]=\"effectiveLoading()\"\n (click)=\"onOkClick()\">\n {{ effectiveOkText() ?? 'OK' }}\n </button>\n }\n </div>\n </footer>\n }\n } @placeholder {\n <div class=\"flex h-[200px] flex-col gap-4 px-4\">\n <z-skeleton [zRows]=\"effectiveSkeletonRows()\" />\n </div>\n }\n}\n\n<!-- Service mode content -->\n@if (isServiceMode()) {\n <!-- Confirm Modal Layout (no skeleton) -->\n @if (isConfirmMode()) {\n <div class=\"flex flex-col items-center px-4 pt-2 text-center\">\n @if (config.zConfirmIcon) {\n <div class=\"relative mb-4 flex size-20 items-center justify-center\">\n <div class=\"absolute inset-0 rounded-full\" [class]=\"confirmIconColors().ring\"></div>\n <div class=\"relative flex size-14 items-center justify-center rounded-full\" [class]=\"confirmIconColors().bg\">\n <z-icon [zType]=\"config.zConfirmIcon\" zSize=\"30\" [zStrokeWidth]=\"2.6\" [class]=\"confirmIconColors().icon\" />\n </div>\n </div>\n }\n\n <!-- Title centered -->\n @if (effectiveTitle(); as title) {\n @switch (title | zContentType) {\n @case ('template') {\n <ng-container *ngTemplateOutlet=\"$any(title)\" />\n }\n @case ('html') {\n <h4\n data-testid=\"z-modal-title\"\n class=\"m-0 text-lg leading-snug font-semibold\"\n [innerHTML]=\"$any(title) | zSafeHtml\"></h4>\n }\n @default {\n <h4 data-testid=\"z-modal-title\" class=\"m-0 text-lg leading-snug font-semibold\">\n {{ title }}\n </h4>\n }\n }\n }\n\n <!-- Description centered -->\n @if (config.zContent; as content) {\n <p\n data-testid=\"z-modal-description\"\n class=\"text-muted-foreground m-0 mt-2 text-sm\"\n [innerHTML]=\"$any(content) | zSafeHtml\"></p>\n }\n </div>\n\n <!-- Footer centered -->\n @if (!effectiveHideFooter()) {\n <footer class=\"mt-4 flex flex-row justify-center gap-3 pb-2\">\n @if (effectiveCancelText() !== null) {\n <button type=\"button\" data-testid=\"z-modal-cancel-button\" z-button zType=\"outline\" (click)=\"onCloseClick()\">\n {{ effectiveCancelText() ?? 'Cancel' }}\n </button>\n }\n\n @if (effectiveOkText() !== null) {\n <button\n type=\"button\"\n data-testid=\"z-modal-ok-button\"\n z-button\n [zType]=\"effectiveTypeOk()\"\n [disabled]=\"effectiveOkDisabled() || effectiveLoading()\"\n [zLoading]=\"effectiveLoading()\"\n (click)=\"onOkClick()\">\n {{ effectiveOkText() ?? 'OK' }}\n </button>\n }\n </footer>\n }\n } @else {\n <!-- Normal Modal Layout with defer -->\n @defer (when !effectiveContentLoading()) {\n @if (effectiveTitle()) {\n <header [class.z-modal-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex w-full items-start justify-between overflow-hidden px-4\">\n <div class=\"min-w-0 flex-1 overflow-hidden pr-2\">\n @if (effectiveTitle(); as title) {\n @switch (title | zContentType) {\n @case ('template') {\n <ng-container *ngTemplateOutlet=\"$any(title)\" />\n }\n @case ('html') {\n <h4\n data-testid=\"z-modal-title\"\n class=\"m-0 truncate text-base leading-snug font-semibold\"\n z-tooltip\n [zContent]=\"title\"\n [innerHTML]=\"$any(title) | zSafeHtml\"></h4>\n }\n @default {\n <h4\n data-testid=\"z-modal-title\"\n class=\"m-0 truncate text-base leading-snug font-semibold\"\n z-tooltip\n [zContent]=\"title\">\n {{ title }}\n </h4>\n }\n }\n }\n </div>\n @if (effectiveClosable()) {\n <button\n type=\"button\"\n data-testid=\"z-modal-close-header-button\"\n z-button\n zType=\"subtle\"\n zSize=\"xs\"\n [zWave]=\"false\"\n (click)=\"onCloseClick()\">\n <z-icon zType=\"lucideX\" />\n </button>\n }\n </div>\n </header>\n } @else if (effectiveClosable()) {\n <header [class.z-modal-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex justify-end px-4\">\n <button\n type=\"button\"\n data-testid=\"z-modal-close-header-button\"\n z-button\n zType=\"subtle\"\n zSize=\"xs\"\n [zWave]=\"false\"\n (click)=\"onCloseClick()\">\n <z-icon zType=\"lucideX\" />\n </button>\n </div>\n </header>\n }\n\n <ng-scrollbar class=\"z-modal-scrollbar flex-1\" #mainContent track=\"vertical\" (scroll)=\"onContentScroll($event)\">\n <main class=\"flex min-h-0 flex-col gap-4 px-4 py-4\">\n <ng-template cdkPortalOutlet />\n\n @if (isStringContent()) {\n <div data-testid=\"z-modal-content\" [innerHTML]=\"$any(config.zContent) | zSafeHtml\"></div>\n }\n </main>\n </ng-scrollbar>\n\n @if (!effectiveHideFooter()) {\n <footer [class.z-modal-footer-shadow]=\"shouldShowShadow()\">\n <div class=\"flex flex-row justify-end gap-2 px-4\">\n @if (effectiveCancelText() !== null) {\n <button\n type=\"button\"\n data-testid=\"z-modal-cancel-button\"\n z-button\n zType=\"outline\"\n (click)=\"onCloseClick()\">\n @if (config.zCancelIcon) {\n <z-icon [zType]=\"config.zCancelIcon\" />\n }\n {{ effectiveCancelText() ?? 'Cancel' }}\n </button>\n }\n\n @if (effectiveOkText() !== null) {\n <button\n type=\"button\"\n data-testid=\"z-modal-ok-button\"\n z-button\n [zType]=\"effectiveOkDestructive() ? 'destructive' : 'default'\"\n [disabled]=\"effectiveOkDisabled() || effectiveLoading()\"\n [zLoading]=\"effectiveLoading()\"\n (click)=\"onOkClick()\">\n @if (config.zOkIcon && !effectiveLoading()) {\n <z-icon [zType]=\"config.zOkIcon\" />\n }\n {{ effectiveOkText() ?? 'OK' }}\n </button>\n }\n </div>\n </footer>\n }\n } @placeholder {\n <div class=\"flex h-[200px] flex-col gap-4 px-4\">\n <z-skeleton [zRows]=\"effectiveSkeletonRows()\" />\n </div>\n }\n }\n}\n", styles: [":host.z-modal-service-mode,:host.z-modal-template-mode{--z-enter-opacity: 0;--z-enter-translate-y: -8px;--z-enter-scale: .95;animation:z-enter .18s cubic-bezier(.32,.72,0,1) forwards}:host.z-modal-service-mode.modal-leave,:host.z-modal-template-mode.modal-leave{--z-exit-opacity: 0;--z-exit-translate-y: -8px;--z-exit-scale: .95;animation:z-exit .15s cubic-bezier(.32,.72,0,1) forwards}:host.z-modal-template-host{display:contents}::ng-deep .z-modal-backdrop-dark{background-color:#0009;animation:z-backdrop-enter .15s ease-out forwards}::ng-deep .z-modal-backdrop-blur{background-color:#0000000d;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);animation:z-backdrop-enter .15s ease-out forwards}::ng-deep .z-modal-backdrop-dark.z-backdrop-leaving,::ng-deep .z-modal-backdrop-blur.z-backdrop-leaving{animation:z-backdrop-exit .12s ease-in forwards}.z-modal-header-shadow{padding-bottom:16px;box-shadow:0 2px 8px -2px #0000001a}.z-modal-footer-shadow{padding-top:16px;box-shadow:0 -2px 8px -2px #0000001a}:host main{overscroll-behavior:contain}:host header,:host footer{transition:box-shadow .2s ease-out,padding .2s ease-out}.z-modal-scrollbar{--scrollbar-padding: 2px}\n"] }]
|
|
505
|
+
}], ctorParameters: () => [], propDecorators: { zOk: [{ type: i0.Output, args: ["zOk"] }], zCancel: [{ type: i0.Output, args: ["zCancel"] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], zVisible: [{ type: i0.Input, args: [{ isSignal: true, alias: "zVisible", required: false }] }, { type: i0.Output, args: ["zVisibleChange"] }], zTitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTitle", required: false }] }], zDescription: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDescription", required: false }] }], zWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "zWidth", required: false }] }], zClosable: [{ type: i0.Input, args: [{ isSignal: true, alias: "zClosable", required: false }] }], zMaskClosable: [{ type: i0.Input, args: [{ isSignal: true, alias: "zMaskClosable", required: false }] }], zHideFooter: [{ type: i0.Input, args: [{ isSignal: true, alias: "zHideFooter", required: false }] }], zOkText: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOkText", required: false }] }], zCancelText: [{ type: i0.Input, args: [{ isSignal: true, alias: "zCancelText", required: false }] }], zOkDestructive: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOkDestructive", required: false }] }], zOkDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOkDisabled", required: false }] }], zLoading: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLoading", required: false }] }], zContentLoading: [{ type: i0.Input, args: [{ isSignal: true, alias: "zContentLoading", required: false }] }], zSkeletonRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "zSkeletonRows", required: false }] }], zOverlay: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOverlay", required: false }] }], customHeader: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ZModalHeaderDirective), { isSignal: true }] }], customContent: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ZModalContentDirective), { isSignal: true }] }], customFooter: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ZModalFooterDirective), { isSignal: true }] }], portalOutlet: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CdkPortalOutlet), { isSignal: true }] }], dummyTemplateRef: [{ type: i0.ViewChild, args: ['dummyTemplate', { isSignal: true }] }], mainContentRef: [{ type: i0.ViewChild, args: ['mainContent', { isSignal: true }] }] } }) });
|
|
506
|
+
|
|
507
|
+
let ZModalRef = class ZModalRef {
|
|
508
|
+
_overlayRef;
|
|
509
|
+
_config;
|
|
510
|
+
_containerInstance;
|
|
511
|
+
_platformId;
|
|
512
|
+
_destroy$ = new Subject();
|
|
513
|
+
_isClosing = false;
|
|
514
|
+
_result;
|
|
515
|
+
componentInstance = null;
|
|
516
|
+
loading = signal(false, ...(ngDevMode ? [{ debugName: "loading" }] : []));
|
|
517
|
+
constructor(_overlayRef, _config, _containerInstance, _platformId) {
|
|
518
|
+
this._overlayRef = _overlayRef;
|
|
519
|
+
this._config = _config;
|
|
520
|
+
this._containerInstance = _containerInstance;
|
|
521
|
+
this._platformId = _platformId;
|
|
522
|
+
this._containerInstance.zCancel.subscribe(() => this._trigger(ZModalTriggerAction.CANCEL));
|
|
523
|
+
this._containerInstance.zOk.subscribe(() => this._trigger(ZModalTriggerAction.OK));
|
|
524
|
+
if ((this._config.zMaskClosable ?? true) && isPlatformBrowser(this._platformId)) {
|
|
525
|
+
this._overlayRef
|
|
526
|
+
.outsidePointerEvents()
|
|
527
|
+
.pipe(takeUntil(this._destroy$))
|
|
528
|
+
.subscribe(() => {
|
|
529
|
+
if (!this.loading()) {
|
|
530
|
+
this.close();
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
if (isPlatformBrowser(this._platformId)) {
|
|
535
|
+
fromEvent(document, 'keydown')
|
|
536
|
+
.pipe(filter(event => event.key === 'Escape'), takeUntil(this._destroy$))
|
|
537
|
+
.subscribe(() => {
|
|
538
|
+
if (!this.loading()) {
|
|
539
|
+
this.close();
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
setLoading(value) {
|
|
545
|
+
this.loading.set(value);
|
|
546
|
+
}
|
|
547
|
+
close(result) {
|
|
548
|
+
if (this._isClosing) {
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
this._isClosing = true;
|
|
552
|
+
this._result = result;
|
|
553
|
+
if (isPlatformBrowser(this._platformId)) {
|
|
554
|
+
const hostElement = this._containerInstance.getNativeElement();
|
|
555
|
+
hostElement.classList.add('modal-leave');
|
|
556
|
+
const { backdropElement } = this._overlayRef;
|
|
557
|
+
if (backdropElement) {
|
|
558
|
+
backdropElement.classList.add('z-backdrop-leaving');
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
setTimeout(() => {
|
|
562
|
+
if (this._overlayRef) {
|
|
563
|
+
if (this._overlayRef.hasAttached()) {
|
|
564
|
+
this._overlayRef.detachBackdrop();
|
|
565
|
+
}
|
|
566
|
+
this._overlayRef.dispose();
|
|
567
|
+
}
|
|
568
|
+
if (!this._destroy$.closed) {
|
|
569
|
+
this._destroy$.next();
|
|
570
|
+
this._destroy$.complete();
|
|
571
|
+
}
|
|
572
|
+
}, Z_MODAL_ANIMATION_DURATION);
|
|
573
|
+
}
|
|
574
|
+
_trigger(action) {
|
|
575
|
+
if (this.loading()) {
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
const trigger = {
|
|
579
|
+
ok: this._config.zOnOk,
|
|
580
|
+
cancel: this._config.zOnCancel,
|
|
581
|
+
}[action];
|
|
582
|
+
if (trigger instanceof EventEmitter) {
|
|
583
|
+
trigger.emit(this._getContentComponent());
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
if (typeof trigger === 'function') {
|
|
587
|
+
const result = trigger(this._getContentComponent(), this);
|
|
588
|
+
this._closeWithResult(result);
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
this.close();
|
|
592
|
+
}
|
|
593
|
+
_getContentComponent() {
|
|
594
|
+
return this.componentInstance;
|
|
595
|
+
}
|
|
596
|
+
_closeWithResult(result) {
|
|
597
|
+
if (result !== false) {
|
|
598
|
+
this.close(result);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
ZModalRef = __decorate([
|
|
603
|
+
__param(3, Inject(PLATFORM_ID)),
|
|
604
|
+
__metadata("design:paramtypes", [OverlayRef,
|
|
605
|
+
ZModalOptions,
|
|
606
|
+
ZModalComponent, Object])
|
|
607
|
+
], ZModalRef);
|
|
608
|
+
|
|
609
|
+
class ZModalService {
|
|
610
|
+
_overlay = inject(Overlay);
|
|
611
|
+
_injector = inject(Injector);
|
|
612
|
+
_platformId = inject(PLATFORM_ID);
|
|
613
|
+
create(config) {
|
|
614
|
+
return this._open(config.zContent, config);
|
|
615
|
+
}
|
|
616
|
+
show(options) {
|
|
617
|
+
return this._confirmModal('show', options);
|
|
618
|
+
}
|
|
619
|
+
info(options) {
|
|
620
|
+
return this._confirmModal('info', options);
|
|
621
|
+
}
|
|
622
|
+
warning(options) {
|
|
623
|
+
return this._confirmModal('warning', options);
|
|
624
|
+
}
|
|
625
|
+
danger(options) {
|
|
626
|
+
return this._confirmModal('danger', options);
|
|
627
|
+
}
|
|
628
|
+
_confirmModal(type, options) {
|
|
629
|
+
const typeConfig = Z_MODAL_CONFIRM_CONFIG[type];
|
|
630
|
+
const config = {
|
|
631
|
+
zTitle: options.zTitle,
|
|
632
|
+
zContent: options.zContent,
|
|
633
|
+
zOkText: options.zOkText ?? 'OK',
|
|
634
|
+
zCancelText: options.zCancelText ?? 'Cancel',
|
|
635
|
+
zOkDestructive: typeConfig.okDestructive,
|
|
636
|
+
zConfirmIcon: options.zIcon ?? typeConfig.icon,
|
|
637
|
+
zMaskClosable: options.zMaskClosable ?? true,
|
|
638
|
+
zWidth: options.zWidth ?? '500px',
|
|
639
|
+
zConfirmType: type,
|
|
640
|
+
zData: options.zData,
|
|
641
|
+
zOnOk: () => options.zOnOk?.(),
|
|
642
|
+
zOnCancel: () => {
|
|
643
|
+
options.zOnCancel?.();
|
|
644
|
+
},
|
|
645
|
+
};
|
|
646
|
+
return this.create(config);
|
|
647
|
+
}
|
|
648
|
+
_open(componentOrTemplateRef, config) {
|
|
649
|
+
const overlayRef = this._createOverlay(config);
|
|
650
|
+
if (!overlayRef) {
|
|
651
|
+
return new ZModalRef(undefined, config, undefined, this._platformId);
|
|
652
|
+
}
|
|
653
|
+
const modalContainer = this._attachModalContainer(overlayRef, config);
|
|
654
|
+
const modalRef = this._attachModalContent(componentOrTemplateRef, modalContainer, overlayRef, config);
|
|
655
|
+
return modalRef;
|
|
656
|
+
}
|
|
657
|
+
_createOverlay(config) {
|
|
658
|
+
if (!isPlatformBrowser(this._platformId)) {
|
|
659
|
+
return undefined;
|
|
660
|
+
}
|
|
661
|
+
const overlayType = config.zOverlay ?? getOverlayType();
|
|
662
|
+
const backdropClass = overlayType === 'blur' ? 'z-modal-backdrop-blur' : 'z-modal-backdrop-dark';
|
|
663
|
+
const overlayConfig = new OverlayConfig({
|
|
664
|
+
hasBackdrop: true,
|
|
665
|
+
backdropClass,
|
|
666
|
+
positionStrategy: this._overlay.position().global(),
|
|
667
|
+
});
|
|
668
|
+
return this._overlay.create(overlayConfig);
|
|
669
|
+
}
|
|
670
|
+
_attachModalContainer(overlayRef, config) {
|
|
671
|
+
const injector = Injector.create({
|
|
672
|
+
parent: this._injector,
|
|
673
|
+
providers: [
|
|
674
|
+
{ provide: OverlayRef, useValue: overlayRef },
|
|
675
|
+
{ provide: ZModalOptions, useValue: config },
|
|
676
|
+
],
|
|
677
|
+
});
|
|
678
|
+
const containerPortal = new ComponentPortal(ZModalComponent, config.zViewContainerRef, injector);
|
|
679
|
+
const containerRef = overlayRef.attach(containerPortal);
|
|
680
|
+
return containerRef.instance;
|
|
681
|
+
}
|
|
682
|
+
_attachModalContent(componentOrTemplateRef, modalContainer, overlayRef, config) {
|
|
683
|
+
const modalRef = new ZModalRef(overlayRef, config, modalContainer, this._platformId);
|
|
684
|
+
modalContainer.modalRef = modalRef;
|
|
685
|
+
if (componentOrTemplateRef instanceof TemplateRef) {
|
|
686
|
+
modalContainer.attachTemplatePortal(new TemplatePortal(componentOrTemplateRef, null, { modalRef }));
|
|
687
|
+
return modalRef;
|
|
688
|
+
}
|
|
689
|
+
if (typeof componentOrTemplateRef !== 'string') {
|
|
690
|
+
const injector = this._createInjector(modalRef, config);
|
|
691
|
+
const contentRef = modalContainer.attachComponentPortal(new ComponentPortal(componentOrTemplateRef, config.zViewContainerRef, injector));
|
|
692
|
+
if (contentRef) {
|
|
693
|
+
modalRef.componentInstance = contentRef.instance;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
return modalRef;
|
|
697
|
+
}
|
|
698
|
+
_createInjector(modalRef, config) {
|
|
699
|
+
return Injector.create({
|
|
700
|
+
parent: this._injector,
|
|
701
|
+
providers: [
|
|
702
|
+
{ provide: ZModalRef, useValue: modalRef },
|
|
703
|
+
{ provide: Z_MODAL_DATA, useValue: config.zData },
|
|
704
|
+
],
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZModalService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
708
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZModalService, providedIn: 'root' });
|
|
709
|
+
}
|
|
710
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZModalService, decorators: [{
|
|
711
|
+
type: Injectable,
|
|
712
|
+
args: [{
|
|
713
|
+
providedIn: 'root',
|
|
714
|
+
}]
|
|
715
|
+
}] });
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Generated bundle index. Do not edit.
|
|
719
|
+
*/
|
|
720
|
+
|
|
721
|
+
export { ZModalComponent, ZModalContentDirective, ZModalFooterDirective, ZModalHeaderDirective, ZModalRef, ZModalService, Z_MODAL_DATA, zModalVariants };
|
|
722
|
+
//# sourceMappingURL=shival99-z-ui-components-z-modal.mjs.map
|