@shival99/z-ui 1.0.1 → 1.0.3
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 +50 -77
- 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 +132 -4
- 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,664 @@
|
|
|
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 { ZSkeletonComponent } from '@shival99/z-ui/components/z-skeleton';
|
|
8
|
+
import { zDetectBrowser, zMergeClasses } from '@shival99/z-ui/utils';
|
|
9
|
+
import { cva } from 'class-variance-authority';
|
|
10
|
+
import { __decorate, __param, __metadata } from 'tslib';
|
|
11
|
+
import { Subject, takeUntil, fromEvent, filter } from 'rxjs';
|
|
12
|
+
|
|
13
|
+
class ZDrawerContentDirective {
|
|
14
|
+
templateRef = inject((TemplateRef));
|
|
15
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZDrawerContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
16
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.6", type: ZDrawerContentDirective, isStandalone: true, selector: "[z-drawer-content], [zDrawerContent]", ngImport: i0 });
|
|
17
|
+
}
|
|
18
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZDrawerContentDirective, decorators: [{
|
|
19
|
+
type: Directive,
|
|
20
|
+
args: [{
|
|
21
|
+
selector: '[z-drawer-content], [zDrawerContent]',
|
|
22
|
+
standalone: true,
|
|
23
|
+
}]
|
|
24
|
+
}] });
|
|
25
|
+
|
|
26
|
+
class ZDrawerFooterDirective {
|
|
27
|
+
templateRef = inject((TemplateRef));
|
|
28
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZDrawerFooterDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
29
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.6", type: ZDrawerFooterDirective, isStandalone: true, selector: "[z-drawer-footer], [zDrawerFooter]", ngImport: i0 });
|
|
30
|
+
}
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZDrawerFooterDirective, decorators: [{
|
|
32
|
+
type: Directive,
|
|
33
|
+
args: [{
|
|
34
|
+
selector: '[z-drawer-footer], [zDrawerFooter]',
|
|
35
|
+
standalone: true,
|
|
36
|
+
}]
|
|
37
|
+
}] });
|
|
38
|
+
|
|
39
|
+
class ZDrawerHeaderDirective {
|
|
40
|
+
templateRef = inject((TemplateRef));
|
|
41
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZDrawerHeaderDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
42
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.6", type: ZDrawerHeaderDirective, isStandalone: true, selector: "[z-drawer-header], [zDrawerHeader]", ngImport: i0 });
|
|
43
|
+
}
|
|
44
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZDrawerHeaderDirective, decorators: [{
|
|
45
|
+
type: Directive,
|
|
46
|
+
args: [{
|
|
47
|
+
selector: '[z-drawer-header], [zDrawerHeader]',
|
|
48
|
+
standalone: true,
|
|
49
|
+
}]
|
|
50
|
+
}] });
|
|
51
|
+
|
|
52
|
+
const Z_DRAWER_DATA = new InjectionToken('Z_DRAWER_DATA');
|
|
53
|
+
const Z_DRAWER_ANIMATION_DURATION = 250;
|
|
54
|
+
var ZDrawerTriggerAction;
|
|
55
|
+
(function (ZDrawerTriggerAction) {
|
|
56
|
+
ZDrawerTriggerAction["CANCEL"] = "cancel";
|
|
57
|
+
ZDrawerTriggerAction["OK"] = "ok";
|
|
58
|
+
})(ZDrawerTriggerAction || (ZDrawerTriggerAction = {}));
|
|
59
|
+
const noopFun = () => { };
|
|
60
|
+
/**
|
|
61
|
+
* Configuration options for z-drawer component.
|
|
62
|
+
*
|
|
63
|
+
* @template T - The type of the content component
|
|
64
|
+
* @template U - The type of the data passed to the drawer
|
|
65
|
+
*/
|
|
66
|
+
class ZDrawerOptions {
|
|
67
|
+
/** Icon for the cancel button */
|
|
68
|
+
zCancelIcon;
|
|
69
|
+
/** Text for the cancel button. Set to null to hide the button */
|
|
70
|
+
zCancelText;
|
|
71
|
+
/** Whether the drawer is closable (shows close button) */
|
|
72
|
+
zClosable;
|
|
73
|
+
/** Drawer content - can be a component, template, or string */
|
|
74
|
+
zContent;
|
|
75
|
+
/** Custom CSS classes for the drawer */
|
|
76
|
+
class;
|
|
77
|
+
/** Data to be passed to the content component via Z_DRAWER_DATA token */
|
|
78
|
+
zData;
|
|
79
|
+
/**
|
|
80
|
+
* Observable for deferred data loading before showing drawer content.
|
|
81
|
+
* Drawer will show a loading spinner until the Observable completes.
|
|
82
|
+
* The resolved data will be available via Z_DRAWER_DATA.
|
|
83
|
+
*/
|
|
84
|
+
zDefer;
|
|
85
|
+
/** Description text shown below the title */
|
|
86
|
+
zDescription;
|
|
87
|
+
/** Whether to hide the default footer */
|
|
88
|
+
zHideFooter;
|
|
89
|
+
/**
|
|
90
|
+
* WritableSignal to control loading state of the OK button.
|
|
91
|
+
* Use this when submitting forms or calling APIs.
|
|
92
|
+
*/
|
|
93
|
+
zLoading;
|
|
94
|
+
/** Whether clicking mask closes the drawer */
|
|
95
|
+
zMaskClosable;
|
|
96
|
+
/** Whether OK button has destructive (red) style */
|
|
97
|
+
zOkDestructive;
|
|
98
|
+
/** Whether OK button is disabled */
|
|
99
|
+
zOkDisabled;
|
|
100
|
+
/** Overlay style: 'dark' (black overlay) or 'blur' (backdrop blur) */
|
|
101
|
+
zOverlay;
|
|
102
|
+
/** Icon for the OK button */
|
|
103
|
+
zOkIcon;
|
|
104
|
+
/** Text for the OK button. Set to null to hide the button */
|
|
105
|
+
zOkText;
|
|
106
|
+
/** Callback or EventEmitter when cancel is clicked */
|
|
107
|
+
zOnCancel = noopFun;
|
|
108
|
+
/** Callback or EventEmitter when OK is clicked */
|
|
109
|
+
zOnOk = noopFun;
|
|
110
|
+
/** Drawer title - supports string, HTML string, or TemplateRef */
|
|
111
|
+
zTitle;
|
|
112
|
+
/** ViewContainerRef for the drawer portal */
|
|
113
|
+
zViewContainerRef;
|
|
114
|
+
/** Drawer width for left/right placement (e.g., '400px', '80%') */
|
|
115
|
+
zWidth;
|
|
116
|
+
/** Drawer height for top/bottom placement (e.g., '400px', '50%') */
|
|
117
|
+
zHeight;
|
|
118
|
+
/** Placement of the drawer: 'left', 'right', 'top', 'bottom' */
|
|
119
|
+
zPlacement;
|
|
120
|
+
/** Force shadow on header/footer regardless of scroll state */
|
|
121
|
+
zShadow;
|
|
122
|
+
/** Shape of the drawer: 'rounded' (with border-radius) or 'square' (no border-radius) */
|
|
123
|
+
zShape;
|
|
124
|
+
/** WritableSignal to control content loading state (shows skeleton when true) */
|
|
125
|
+
zContentLoading;
|
|
126
|
+
/** Number of skeleton rows to show when content is loading (default: 5 for left/right, 3 for top/bottom) */
|
|
127
|
+
zSkeletonRows;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const getOverlayType = () => {
|
|
131
|
+
const browser = zDetectBrowser();
|
|
132
|
+
return browser.name === 'Chrome' ? 'dark' : 'blur';
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const zDrawerVariants = cva(['fixed z-50 flex flex-col bg-background overflow-hidden'].join(' '), {
|
|
136
|
+
variants: {
|
|
137
|
+
placement: {
|
|
138
|
+
left: 'left-0 top-0 h-full max-w-[90vw] border-r shadow-[3px_0_10px_rgba(0,0,0,0.08)]',
|
|
139
|
+
right: 'right-0 top-0 h-full max-w-[90vw] border-l shadow-[-3px_0_10px_rgba(0,0,0,0.08)]',
|
|
140
|
+
top: 'top-0 left-0 w-full max-h-[90vh] border-b shadow-[0_3px_10px_rgba(0,0,0,0.08)]',
|
|
141
|
+
bottom: 'bottom-0 left-0 w-full max-h-[90vh] border-t shadow-[0_-3px_10px_rgba(0,0,0,0.08)]',
|
|
142
|
+
},
|
|
143
|
+
shape: {
|
|
144
|
+
rounded: '',
|
|
145
|
+
square: '',
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
compoundVariants: [
|
|
149
|
+
{ placement: 'left', shape: 'rounded', class: 'rounded-r-lg' },
|
|
150
|
+
{ placement: 'right', shape: 'rounded', class: 'rounded-l-lg' },
|
|
151
|
+
{ placement: 'top', shape: 'rounded', class: 'rounded-b-lg' },
|
|
152
|
+
{ placement: 'bottom', shape: 'rounded', class: 'rounded-t-lg' },
|
|
153
|
+
],
|
|
154
|
+
defaultVariants: {
|
|
155
|
+
placement: 'right',
|
|
156
|
+
shape: 'rounded',
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
class ZDrawerComponent extends BasePortalOutlet {
|
|
161
|
+
zOnOk = output();
|
|
162
|
+
zOnCancel = output();
|
|
163
|
+
class = input('', ...(ngDevMode ? [{ debugName: "class" }] : []));
|
|
164
|
+
zVisible = model(false, ...(ngDevMode ? [{ debugName: "zVisible" }] : []));
|
|
165
|
+
zTitle = input(...(ngDevMode ? [undefined, { debugName: "zTitle" }] : []));
|
|
166
|
+
zDescription = input(...(ngDevMode ? [undefined, { debugName: "zDescription" }] : []));
|
|
167
|
+
zWidth = input('400px', ...(ngDevMode ? [{ debugName: "zWidth" }] : []));
|
|
168
|
+
zHeight = input('400px', ...(ngDevMode ? [{ debugName: "zHeight" }] : []));
|
|
169
|
+
zPlacement = input('right', ...(ngDevMode ? [{ debugName: "zPlacement" }] : []));
|
|
170
|
+
zClosable = input(true, ...(ngDevMode ? [{ debugName: "zClosable" }] : []));
|
|
171
|
+
zMaskClosable = input(true, ...(ngDevMode ? [{ debugName: "zMaskClosable" }] : []));
|
|
172
|
+
zHideFooter = input(false, ...(ngDevMode ? [{ debugName: "zHideFooter" }] : []));
|
|
173
|
+
zOkText = input('OK', ...(ngDevMode ? [{ debugName: "zOkText" }] : []));
|
|
174
|
+
zCancelText = input('Cancel', ...(ngDevMode ? [{ debugName: "zCancelText" }] : []));
|
|
175
|
+
zOkDestructive = input(false, ...(ngDevMode ? [{ debugName: "zOkDestructive" }] : []));
|
|
176
|
+
zOkDisabled = input(false, ...(ngDevMode ? [{ debugName: "zOkDisabled" }] : []));
|
|
177
|
+
zLoading = input(false, ...(ngDevMode ? [{ debugName: "zLoading" }] : []));
|
|
178
|
+
zOverlay = input(getOverlayType(), ...(ngDevMode ? [{ debugName: "zOverlay" }] : []));
|
|
179
|
+
zShadow = input(false, ...(ngDevMode ? [{ debugName: "zShadow" }] : []));
|
|
180
|
+
zShape = input('rounded', ...(ngDevMode ? [{ debugName: "zShape" }] : []));
|
|
181
|
+
zContentLoading = input(false, ...(ngDevMode ? [{ debugName: "zContentLoading" }] : []));
|
|
182
|
+
zSkeletonRows = input(null, ...(ngDevMode ? [{ debugName: "zSkeletonRows" }] : []));
|
|
183
|
+
customHeader = contentChild(ZDrawerHeaderDirective, ...(ngDevMode ? [{ debugName: "customHeader" }] : []));
|
|
184
|
+
customContent = contentChild(ZDrawerContentDirective, ...(ngDevMode ? [{ debugName: "customContent" }] : []));
|
|
185
|
+
customFooter = contentChild(ZDrawerFooterDirective, ...(ngDevMode ? [{ debugName: "customFooter" }] : []));
|
|
186
|
+
drawerRef;
|
|
187
|
+
portalOutlet = viewChild(CdkPortalOutlet, ...(ngDevMode ? [{ debugName: "portalOutlet" }] : []));
|
|
188
|
+
dummyTemplateRef = viewChild('dummyTemplate', ...(ngDevMode ? [{ debugName: "dummyTemplateRef" }] : []));
|
|
189
|
+
mainContentRef = viewChild('mainContent', ...(ngDevMode ? [{ debugName: "mainContentRef" }] : []));
|
|
190
|
+
config = inject((ZDrawerOptions), { optional: true }) || new ZDrawerOptions();
|
|
191
|
+
_platformId = inject(PLATFORM_ID);
|
|
192
|
+
_host = inject((ElementRef));
|
|
193
|
+
_overlay = inject(Overlay);
|
|
194
|
+
_viewContainerRef = inject(ViewContainerRef);
|
|
195
|
+
_cdr = inject(ChangeDetectorRef);
|
|
196
|
+
_templateOverlayRef = null;
|
|
197
|
+
_originalParent = null;
|
|
198
|
+
_originalNextSibling = null;
|
|
199
|
+
_backdropSubscription = null;
|
|
200
|
+
isLeaving = signal(false, ...(ngDevMode ? [{ debugName: "isLeaving" }] : []));
|
|
201
|
+
hasScrollableContent = signal(false, ...(ngDevMode ? [{ debugName: "hasScrollableContent" }] : []));
|
|
202
|
+
isScrolledFromTop = signal(false, ...(ngDevMode ? [{ debugName: "isScrolledFromTop" }] : []));
|
|
203
|
+
isScrolledToBottom = signal(false, ...(ngDevMode ? [{ debugName: "isScrolledToBottom" }] : []));
|
|
204
|
+
isServiceMode = computed(() => !!this.drawerRef, ...(ngDevMode ? [{ debugName: "isServiceMode" }] : []));
|
|
205
|
+
isTemplateMode = computed(() => !this.isServiceMode(), ...(ngDevMode ? [{ debugName: "isTemplateMode" }] : []));
|
|
206
|
+
shouldRenderContent = computed(() => this.zVisible() || this.isLeaving(), ...(ngDevMode ? [{ debugName: "shouldRenderContent" }] : []));
|
|
207
|
+
isStringContent = computed(() => typeof this.config.zContent === 'string', ...(ngDevMode ? [{ debugName: "isStringContent" }] : []));
|
|
208
|
+
shouldShowShadow = computed(() => true, ...(ngDevMode ? [{ debugName: "shouldShowShadow" }] : []));
|
|
209
|
+
_lastScrollHeight = 0;
|
|
210
|
+
ngAfterViewChecked() {
|
|
211
|
+
this._checkScrollState();
|
|
212
|
+
}
|
|
213
|
+
_checkScrollState() {
|
|
214
|
+
const scrollbar = this.mainContentRef();
|
|
215
|
+
if (!scrollbar) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const viewport = scrollbar.nativeElement.querySelector('.ng-scroll-viewport');
|
|
219
|
+
if (!viewport) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (viewport.scrollHeight === this._lastScrollHeight) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
this._lastScrollHeight = viewport.scrollHeight;
|
|
226
|
+
const hasVerticalScroll = viewport.scrollHeight > viewport.clientHeight;
|
|
227
|
+
this.hasScrollableContent.set(hasVerticalScroll);
|
|
228
|
+
}
|
|
229
|
+
onContentScroll(event) {
|
|
230
|
+
const target = event.target;
|
|
231
|
+
if (!target) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const { scrollTop } = target;
|
|
235
|
+
const { scrollHeight } = target;
|
|
236
|
+
const { clientHeight } = target;
|
|
237
|
+
this.isScrolledFromTop.set(scrollTop > 0);
|
|
238
|
+
this.isScrolledToBottom.set(scrollTop + clientHeight >= scrollHeight - 1);
|
|
239
|
+
}
|
|
240
|
+
effectiveTitle = computed(() => (this.isServiceMode() ? this.config.zTitle : this.zTitle()), ...(ngDevMode ? [{ debugName: "effectiveTitle" }] : []));
|
|
241
|
+
effectiveDescription = computed(() => this.isServiceMode() ? this.config.zDescription : this.zDescription(), ...(ngDevMode ? [{ debugName: "effectiveDescription" }] : []));
|
|
242
|
+
effectiveClosable = computed(() => this.isServiceMode() ? (this.config.zClosable ?? true) : this.zClosable(), ...(ngDevMode ? [{ debugName: "effectiveClosable" }] : []));
|
|
243
|
+
effectiveHideFooter = computed(() => this.isServiceMode() ? this.config.zHideFooter : this.zHideFooter(), ...(ngDevMode ? [{ debugName: "effectiveHideFooter" }] : []));
|
|
244
|
+
effectiveOkText = computed(() => (this.isServiceMode() ? this.config.zOkText : this.zOkText()), ...(ngDevMode ? [{ debugName: "effectiveOkText" }] : []));
|
|
245
|
+
effectiveCancelText = computed(() => this.isServiceMode() ? this.config.zCancelText : this.zCancelText(), ...(ngDevMode ? [{ debugName: "effectiveCancelText" }] : []));
|
|
246
|
+
effectiveOkDestructive = computed(() => this.isServiceMode() ? this.config.zOkDestructive : this.zOkDestructive(), ...(ngDevMode ? [{ debugName: "effectiveOkDestructive" }] : []));
|
|
247
|
+
effectiveOkDisabled = computed(() => this.isServiceMode() ? this.config.zOkDisabled : this.zOkDisabled(), ...(ngDevMode ? [{ debugName: "effectiveOkDisabled" }] : []));
|
|
248
|
+
effectiveLoading = computed(() => {
|
|
249
|
+
if (this.isServiceMode()) {
|
|
250
|
+
return this.drawerRef?.loading() || (this.config.zLoading?.() ?? false);
|
|
251
|
+
}
|
|
252
|
+
return this.zLoading();
|
|
253
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveLoading" }] : []));
|
|
254
|
+
effectiveContentLoading = computed(() => {
|
|
255
|
+
if (this.isServiceMode()) {
|
|
256
|
+
return this.config.zContentLoading?.() ?? false;
|
|
257
|
+
}
|
|
258
|
+
return this.zContentLoading();
|
|
259
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveContentLoading" }] : []));
|
|
260
|
+
effectiveSkeletonRows = computed(() => {
|
|
261
|
+
if (this.isServiceMode() && this.config.zSkeletonRows != null) {
|
|
262
|
+
return this.config.zSkeletonRows;
|
|
263
|
+
}
|
|
264
|
+
if (this.zSkeletonRows() != null) {
|
|
265
|
+
return this.zSkeletonRows();
|
|
266
|
+
}
|
|
267
|
+
const placement = this.effectivePlacement();
|
|
268
|
+
return placement === 'left' || placement === 'right' ? 6 : 3;
|
|
269
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveSkeletonRows" }] : []));
|
|
270
|
+
effectivePlacement = computed(() => {
|
|
271
|
+
if (this.isServiceMode()) {
|
|
272
|
+
return this.config.zPlacement ?? 'right';
|
|
273
|
+
}
|
|
274
|
+
return this.zPlacement();
|
|
275
|
+
}, ...(ngDevMode ? [{ debugName: "effectivePlacement" }] : []));
|
|
276
|
+
effectiveShadow = computed(() => {
|
|
277
|
+
if (this.isServiceMode()) {
|
|
278
|
+
return this.config.zShadow ?? false;
|
|
279
|
+
}
|
|
280
|
+
return this.zShadow();
|
|
281
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveShadow" }] : []));
|
|
282
|
+
effectiveShape = computed(() => {
|
|
283
|
+
if (this.isServiceMode()) {
|
|
284
|
+
return this.config.zShape ?? 'rounded';
|
|
285
|
+
}
|
|
286
|
+
return this.zShape();
|
|
287
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveShape" }] : []));
|
|
288
|
+
effectiveWidth = computed(() => {
|
|
289
|
+
const placement = this.effectivePlacement();
|
|
290
|
+
if (placement === 'top' || placement === 'bottom') {
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
if (this.isServiceMode()) {
|
|
294
|
+
return this.zWidth() || this.config.zWidth || null;
|
|
295
|
+
}
|
|
296
|
+
return this.shouldRenderContent() ? this.zWidth() : null;
|
|
297
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveWidth" }] : []));
|
|
298
|
+
effectiveHeight = computed(() => {
|
|
299
|
+
const placement = this.effectivePlacement();
|
|
300
|
+
if (placement === 'left' || placement === 'right') {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
if (this.isServiceMode()) {
|
|
304
|
+
return this.zHeight() || this.config.zHeight || null;
|
|
305
|
+
}
|
|
306
|
+
return this.shouldRenderContent() ? this.zHeight() : null;
|
|
307
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveHeight" }] : []));
|
|
308
|
+
isDeferLoading = computed(() => {
|
|
309
|
+
if (!this.isServiceMode()) {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
return !!this.config.zDefer && !this.portalOutlet()?.hasAttached();
|
|
313
|
+
}, ...(ngDevMode ? [{ debugName: "isDeferLoading" }] : []));
|
|
314
|
+
classes = computed(() => zMergeClasses(zDrawerVariants({ placement: this.effectivePlacement(), shape: this.effectiveShape() }), this.isServiceMode() ? this.config.class : this.class()), ...(ngDevMode ? [{ debugName: "classes" }] : []));
|
|
315
|
+
hostClasses = computed(() => {
|
|
316
|
+
const baseClasses = this.classes();
|
|
317
|
+
if (this.isServiceMode()) {
|
|
318
|
+
return `${baseClasses} z-drawer-service-mode`.trim();
|
|
319
|
+
}
|
|
320
|
+
if (this.shouldRenderContent()) {
|
|
321
|
+
return `${baseClasses} z-drawer-template-mode`.trim();
|
|
322
|
+
}
|
|
323
|
+
return 'z-drawer-template-host';
|
|
324
|
+
}, ...(ngDevMode ? [{ debugName: "hostClasses" }] : []));
|
|
325
|
+
constructor() {
|
|
326
|
+
super();
|
|
327
|
+
effect(() => {
|
|
328
|
+
const visible = this.zVisible();
|
|
329
|
+
if (visible && this.isTemplateMode() && !this._templateOverlayRef) {
|
|
330
|
+
this._openTemplateOverlay();
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (!visible && this.isTemplateMode() && this._templateOverlayRef && !this.isLeaving()) {
|
|
334
|
+
this._closeWithAnimation();
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
ngOnDestroy() {
|
|
339
|
+
this._disposeTemplateOverlay();
|
|
340
|
+
}
|
|
341
|
+
getNativeElement() {
|
|
342
|
+
return this._host.nativeElement;
|
|
343
|
+
}
|
|
344
|
+
attachComponentPortal(portal) {
|
|
345
|
+
this._cdr.detectChanges();
|
|
346
|
+
const outlet = this.portalOutlet();
|
|
347
|
+
if (outlet?.hasAttached()) {
|
|
348
|
+
throw new Error('Attempting to attach drawer content after content is already attached');
|
|
349
|
+
}
|
|
350
|
+
return outlet?.attachComponentPortal(portal);
|
|
351
|
+
}
|
|
352
|
+
attachTemplatePortal(portal) {
|
|
353
|
+
const outlet = this.portalOutlet();
|
|
354
|
+
if (outlet?.hasAttached()) {
|
|
355
|
+
throw new Error('Attempting to attach drawer content after content is already attached');
|
|
356
|
+
}
|
|
357
|
+
return outlet?.attachTemplatePortal(portal);
|
|
358
|
+
}
|
|
359
|
+
onOkClick() {
|
|
360
|
+
if (this.effectiveLoading()) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
this.zOnOk.emit();
|
|
364
|
+
}
|
|
365
|
+
onCloseClick() {
|
|
366
|
+
this.zOnCancel.emit();
|
|
367
|
+
if (this.isTemplateMode() && !this.effectiveLoading()) {
|
|
368
|
+
this._closeWithAnimation();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
onBackdropClick() {
|
|
372
|
+
if (this.zMaskClosable() && !this.effectiveLoading()) {
|
|
373
|
+
this._closeWithAnimation();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
open() {
|
|
377
|
+
this.isLeaving.set(false);
|
|
378
|
+
this.zVisible.set(true);
|
|
379
|
+
}
|
|
380
|
+
close() {
|
|
381
|
+
this._closeWithAnimation();
|
|
382
|
+
}
|
|
383
|
+
_createOverlay() {
|
|
384
|
+
if (!isPlatformBrowser(this._platformId)) {
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
const overlayType = this.zOverlay();
|
|
388
|
+
const backdropClass = overlayType === 'blur' ? 'z-drawer-backdrop-blur' : 'z-drawer-backdrop-dark';
|
|
389
|
+
const overlayConfig = new OverlayConfig({
|
|
390
|
+
hasBackdrop: true,
|
|
391
|
+
backdropClass,
|
|
392
|
+
positionStrategy: this._overlay.position().global(),
|
|
393
|
+
scrollStrategy: this._overlay.scrollStrategies.block(),
|
|
394
|
+
});
|
|
395
|
+
return this._overlay.create(overlayConfig);
|
|
396
|
+
}
|
|
397
|
+
_openTemplateOverlay() {
|
|
398
|
+
if (this._templateOverlayRef) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
const dummyRef = this.dummyTemplateRef();
|
|
402
|
+
if (!dummyRef) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
this._templateOverlayRef = this._createOverlay();
|
|
406
|
+
if (!this._templateOverlayRef) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
const hostElement = this._host.nativeElement;
|
|
410
|
+
this._originalParent = hostElement.parentElement;
|
|
411
|
+
this._originalNextSibling = hostElement.nextSibling;
|
|
412
|
+
const portal = new TemplatePortal(dummyRef, this._viewContainerRef);
|
|
413
|
+
this._templateOverlayRef.attach(portal);
|
|
414
|
+
const overlayPane = this._templateOverlayRef.overlayElement;
|
|
415
|
+
overlayPane.style.position = 'static';
|
|
416
|
+
overlayPane.appendChild(hostElement);
|
|
417
|
+
this._backdropSubscription = this._templateOverlayRef.backdropClick().subscribe(() => {
|
|
418
|
+
this.onBackdropClick();
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
_closeWithAnimation() {
|
|
422
|
+
if (this.isLeaving()) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
this.isLeaving.set(true);
|
|
426
|
+
this.zVisible.set(false);
|
|
427
|
+
const hostElement = this._host.nativeElement;
|
|
428
|
+
const { backdropElement } = this._templateOverlayRef ?? {};
|
|
429
|
+
if (backdropElement) {
|
|
430
|
+
backdropElement.classList.add('z-backdrop-leaving');
|
|
431
|
+
}
|
|
432
|
+
hostElement.classList.add('drawer-leave');
|
|
433
|
+
setTimeout(() => {
|
|
434
|
+
this.isLeaving.set(false);
|
|
435
|
+
this._disposeTemplateOverlay();
|
|
436
|
+
}, Z_DRAWER_ANIMATION_DURATION);
|
|
437
|
+
}
|
|
438
|
+
_disposeTemplateOverlay() {
|
|
439
|
+
const hostElement = this._host.nativeElement;
|
|
440
|
+
if (this._originalParent && this._originalNextSibling) {
|
|
441
|
+
this._originalParent.insertBefore(hostElement, this._originalNextSibling);
|
|
442
|
+
}
|
|
443
|
+
if (this._originalParent && !this._originalNextSibling) {
|
|
444
|
+
this._originalParent.appendChild(hostElement);
|
|
445
|
+
}
|
|
446
|
+
hostElement.classList.remove('drawer-leave');
|
|
447
|
+
if (this._templateOverlayRef) {
|
|
448
|
+
this._templateOverlayRef.dispose();
|
|
449
|
+
this._templateOverlayRef = null;
|
|
450
|
+
}
|
|
451
|
+
this._originalParent = null;
|
|
452
|
+
this._originalNextSibling = null;
|
|
453
|
+
if (this._backdropSubscription) {
|
|
454
|
+
this._backdropSubscription.unsubscribe();
|
|
455
|
+
this._backdropSubscription = null;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZDrawerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
459
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.6", type: ZDrawerComponent, isStandalone: true, selector: "z-drawer", 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 }, zHeight: { classPropertyName: "zHeight", publicName: "zHeight", isSignal: true, isRequired: false, transformFunction: null }, zPlacement: { classPropertyName: "zPlacement", publicName: "zPlacement", 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 }, zOverlay: { classPropertyName: "zOverlay", publicName: "zOverlay", isSignal: true, isRequired: false, transformFunction: null }, zShadow: { classPropertyName: "zShadow", publicName: "zShadow", isSignal: true, isRequired: false, transformFunction: null }, zShape: { classPropertyName: "zShape", publicName: "zShape", 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 } }, outputs: { zOnOk: "zOnOk", zOnCancel: "zOnCancel", zVisible: "zVisibleChange" }, host: { properties: { "class": "hostClasses()", "style.width": "effectiveWidth()", "style.height": "effectiveHeight()", "attr.data-placement": "effectivePlacement()" } }, queries: [{ propertyName: "customHeader", first: true, predicate: ZDrawerHeaderDirective, descendants: true, isSignal: true }, { propertyName: "customContent", first: true, predicate: ZDrawerContentDirective, descendants: true, isSignal: true }, { propertyName: "customFooter", first: true, predicate: ZDrawerFooterDirective, 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: ["zDrawer"], 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-drawer-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-drawer-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-drawer-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-drawer-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-drawer-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-drawer-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-drawer-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-drawer-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex justify-end px-4\">\n <button\n type=\"button\"\n data-testid=\"z-drawer-close-header-button\"\n z-button\n zType=\"subtle\"\n zSize=\"xs\"\n class=\"-mt-1 -mr-2 shrink-0\"\n [zWave]=\"false\"\n (click)=\"onCloseClick()\">\n <z-icon zType=\"lucideX\" />\n </button>\n </div>\n </header>\n }\n\n <ng-scrollbar class=\"z-drawer-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-drawer-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-drawer-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-drawer-cancel-button\"\n z-button\n zType=\"outline\"\n (click)=\"onCloseClick()\">\n {{ effectiveCancelText() ?? 'Cancel' }}\n </button>\n }\n\n @if (effectiveOkText() !== null) {\n <button\n type=\"button\"\n data-testid=\"z-drawer-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 flex-1 flex-col gap-4 p-4\">\n <z-skeleton [zRows]=\"effectiveSkeletonRows()\" />\n </div>\n }\n}\n\n<!-- Service mode content -->\n@if (isServiceMode()) {\n @defer (when !effectiveContentLoading()) {\n @if (effectiveTitle()) {\n <header [class.z-drawer-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-drawer-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-drawer-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-drawer-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-drawer-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex justify-end px-4\">\n <button\n type=\"button\"\n data-testid=\"z-drawer-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-drawer-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-drawer-content\" [innerHTML]=\"$any(config.zContent) | zSafeHtml\"></div>\n }\n </main>\n </ng-scrollbar>\n\n @if (!effectiveHideFooter()) {\n <footer [class.z-drawer-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-drawer-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-drawer-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 flex-1 flex-col gap-4 p-4\">\n <z-skeleton [zRows]=\"effectiveSkeletonRows()\" />\n </div>\n }\n}\n", styles: [":host.z-drawer-service-mode[data-placement=left],:host.z-drawer-template-mode[data-placement=left]{--z-enter-translate-x: -100%;animation:z-enter .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=left].drawer-leave,:host.z-drawer-template-mode[data-placement=left].drawer-leave{--z-exit-translate-x: -100%;animation:z-exit .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=right],:host.z-drawer-template-mode[data-placement=right]{--z-enter-translate-x: 100%;animation:z-enter .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=right].drawer-leave,:host.z-drawer-template-mode[data-placement=right].drawer-leave{--z-exit-translate-x: 100%;animation:z-exit .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=top],:host.z-drawer-template-mode[data-placement=top]{--z-enter-translate-y: -100%;animation:z-enter .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=top].drawer-leave,:host.z-drawer-template-mode[data-placement=top].drawer-leave{--z-exit-translate-y: -100%;animation:z-exit .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=bottom],:host.z-drawer-template-mode[data-placement=bottom]{--z-enter-translate-y: 100%;animation:z-enter .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=bottom].drawer-leave,:host.z-drawer-template-mode[data-placement=bottom].drawer-leave{--z-exit-translate-y: 100%;animation:z-exit .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-template-host{display:contents}::ng-deep .z-drawer-backdrop-dark{background-color:#0009}::ng-deep .z-drawer-backdrop-blur{background-color:#0000000d;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.z-drawer-header-shadow{box-shadow:0 2px 8px -2px #0000001a}.z-drawer-footer-shadow{box-shadow:0 -2px 8px -2px #0000001a}:host header{padding-top:16px;padding-bottom:16px}:host footer{padding-top:16px;padding-bottom:16px}:host main{overscroll-behavior:contain}:host header,:host footer{transition:box-shadow .2s ease-out}.z-drawer-scrollbar{--scrollbar-padding: 2px}\n"], dependencies: [{ kind: "ngmodule", type: PortalModule }, { kind: "component", type: ZSkeletonComponent, selector: "z-skeleton", inputs: ["zType", "zSize", "zWidth", "zHeight", "zRows", "zGap", "zAnimated", "zRadius", "zClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, deferBlockDependencies: [() => [NgTemplateOutlet, import('@shival99/z-ui/components/z-button').then(m => m.ZButtonComponent), import('@shival99/z-ui/components/z-icon').then(m => m.ZIconComponent), import('@shival99/z-ui/components/z-tooltip').then(m => m.ZTooltipDirective), import('ngx-scrollbar').then(m => m.NgScrollbar), import('@shival99/z-ui/pipes').then(m => m.ZContentTypePipe), import('@shival99/z-ui/pipes').then(m => m.ZSafeHtmlPipe)], () => [i1.CdkPortalOutlet, NgTemplateOutlet, import('@shival99/z-ui/components/z-button').then(m => m.ZButtonComponent), import('@shival99/z-ui/components/z-icon').then(m => m.ZIconComponent), import('@shival99/z-ui/components/z-tooltip').then(m => m.ZTooltipDirective), import('ngx-scrollbar').then(m => m.NgScrollbar), import('@shival99/z-ui/pipes').then(m => m.ZContentTypePipe), import('@shival99/z-ui/pipes').then(m => m.ZSafeHtmlPipe)]] });
|
|
460
|
+
}
|
|
461
|
+
i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "21.0.6", ngImport: i0, type: ZDrawerComponent, resolveDeferredDeps: () => [import('@shival99/z-ui/components/z-button').then(m => m.ZButtonComponent), import('@shival99/z-ui/components/z-icon').then(m => m.ZIconComponent), import('@shival99/z-ui/components/z-tooltip').then(m => m.ZTooltipDirective), import('ngx-scrollbar').then(m => m.NgScrollbar), import('@shival99/z-ui/pipes').then(m => m.ZContentTypePipe), import('@shival99/z-ui/pipes').then(m => m.ZSafeHtmlPipe)], resolveMetadata: (ZButtonComponent, ZIconComponent, ZTooltipDirective, NgScrollbar, ZContentTypePipe, ZSafeHtmlPipe) => ({ decorators: [{
|
|
462
|
+
type: Component,
|
|
463
|
+
args: [{ selector: 'z-drawer', imports: [
|
|
464
|
+
PortalModule,
|
|
465
|
+
NgTemplateOutlet,
|
|
466
|
+
ZButtonComponent,
|
|
467
|
+
ZIconComponent,
|
|
468
|
+
ZContentTypePipe,
|
|
469
|
+
ZTooltipDirective,
|
|
470
|
+
ZSkeletonComponent,
|
|
471
|
+
NgScrollbar,
|
|
472
|
+
ZSafeHtmlPipe,
|
|
473
|
+
], standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
474
|
+
'[class]': 'hostClasses()',
|
|
475
|
+
'[style.width]': 'effectiveWidth()',
|
|
476
|
+
'[style.height]': 'effectiveHeight()',
|
|
477
|
+
'[attr.data-placement]': 'effectivePlacement()',
|
|
478
|
+
}, exportAs: 'zDrawer', 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-drawer-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-drawer-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-drawer-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-drawer-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-drawer-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-drawer-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-drawer-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-drawer-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex justify-end px-4\">\n <button\n type=\"button\"\n data-testid=\"z-drawer-close-header-button\"\n z-button\n zType=\"subtle\"\n zSize=\"xs\"\n class=\"-mt-1 -mr-2 shrink-0\"\n [zWave]=\"false\"\n (click)=\"onCloseClick()\">\n <z-icon zType=\"lucideX\" />\n </button>\n </div>\n </header>\n }\n\n <ng-scrollbar class=\"z-drawer-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-drawer-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-drawer-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-drawer-cancel-button\"\n z-button\n zType=\"outline\"\n (click)=\"onCloseClick()\">\n {{ effectiveCancelText() ?? 'Cancel' }}\n </button>\n }\n\n @if (effectiveOkText() !== null) {\n <button\n type=\"button\"\n data-testid=\"z-drawer-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 flex-1 flex-col gap-4 p-4\">\n <z-skeleton [zRows]=\"effectiveSkeletonRows()\" />\n </div>\n }\n}\n\n<!-- Service mode content -->\n@if (isServiceMode()) {\n @defer (when !effectiveContentLoading()) {\n @if (effectiveTitle()) {\n <header [class.z-drawer-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-drawer-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-drawer-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-drawer-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-drawer-header-shadow]=\"shouldShowShadow()\">\n <div class=\"flex justify-end px-4\">\n <button\n type=\"button\"\n data-testid=\"z-drawer-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-drawer-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-drawer-content\" [innerHTML]=\"$any(config.zContent) | zSafeHtml\"></div>\n }\n </main>\n </ng-scrollbar>\n\n @if (!effectiveHideFooter()) {\n <footer [class.z-drawer-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-drawer-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-drawer-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 flex-1 flex-col gap-4 p-4\">\n <z-skeleton [zRows]=\"effectiveSkeletonRows()\" />\n </div>\n }\n}\n", styles: [":host.z-drawer-service-mode[data-placement=left],:host.z-drawer-template-mode[data-placement=left]{--z-enter-translate-x: -100%;animation:z-enter .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=left].drawer-leave,:host.z-drawer-template-mode[data-placement=left].drawer-leave{--z-exit-translate-x: -100%;animation:z-exit .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=right],:host.z-drawer-template-mode[data-placement=right]{--z-enter-translate-x: 100%;animation:z-enter .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=right].drawer-leave,:host.z-drawer-template-mode[data-placement=right].drawer-leave{--z-exit-translate-x: 100%;animation:z-exit .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=top],:host.z-drawer-template-mode[data-placement=top]{--z-enter-translate-y: -100%;animation:z-enter .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=top].drawer-leave,:host.z-drawer-template-mode[data-placement=top].drawer-leave{--z-exit-translate-y: -100%;animation:z-exit .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=bottom],:host.z-drawer-template-mode[data-placement=bottom]{--z-enter-translate-y: 100%;animation:z-enter .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-service-mode[data-placement=bottom].drawer-leave,:host.z-drawer-template-mode[data-placement=bottom].drawer-leave{--z-exit-translate-y: 100%;animation:z-exit .25s cubic-bezier(.16,1,.3,1) forwards}:host.z-drawer-template-host{display:contents}::ng-deep .z-drawer-backdrop-dark{background-color:#0009}::ng-deep .z-drawer-backdrop-blur{background-color:#0000000d;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.z-drawer-header-shadow{box-shadow:0 2px 8px -2px #0000001a}.z-drawer-footer-shadow{box-shadow:0 -2px 8px -2px #0000001a}:host header{padding-top:16px;padding-bottom:16px}:host footer{padding-top:16px;padding-bottom:16px}:host main{overscroll-behavior:contain}:host header,:host footer{transition:box-shadow .2s ease-out}.z-drawer-scrollbar{--scrollbar-padding: 2px}\n"] }]
|
|
479
|
+
}], ctorParameters: () => [], propDecorators: { zOnOk: [{ type: i0.Output, args: ["zOnOk"] }], zOnCancel: [{ type: i0.Output, args: ["zOnCancel"] }], 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 }] }], zHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "zHeight", required: false }] }], zPlacement: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPlacement", 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 }] }], zOverlay: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOverlay", required: false }] }], zShadow: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShadow", required: false }] }], zShape: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShape", required: false }] }], zContentLoading: [{ type: i0.Input, args: [{ isSignal: true, alias: "zContentLoading", required: false }] }], zSkeletonRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "zSkeletonRows", required: false }] }], customHeader: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ZDrawerHeaderDirective), { isSignal: true }] }], customContent: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ZDrawerContentDirective), { isSignal: true }] }], customFooter: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ZDrawerFooterDirective), { 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 }] }] } }) });
|
|
480
|
+
|
|
481
|
+
let ZDrawerRef = class ZDrawerRef {
|
|
482
|
+
_overlayRef;
|
|
483
|
+
_config;
|
|
484
|
+
_containerInstance;
|
|
485
|
+
_platformId;
|
|
486
|
+
_destroy$ = new Subject();
|
|
487
|
+
_isClosing = false;
|
|
488
|
+
_result;
|
|
489
|
+
componentInstance = null;
|
|
490
|
+
loading = signal(false, ...(ngDevMode ? [{ debugName: "loading" }] : []));
|
|
491
|
+
constructor(_overlayRef, _config, _containerInstance, _platformId) {
|
|
492
|
+
this._overlayRef = _overlayRef;
|
|
493
|
+
this._config = _config;
|
|
494
|
+
this._containerInstance = _containerInstance;
|
|
495
|
+
this._platformId = _platformId;
|
|
496
|
+
this._containerInstance.zOnCancel.subscribe(() => this._trigger(ZDrawerTriggerAction.CANCEL));
|
|
497
|
+
this._containerInstance.zOnOk.subscribe(() => this._trigger(ZDrawerTriggerAction.OK));
|
|
498
|
+
if ((this._config.zMaskClosable ?? true) && isPlatformBrowser(this._platformId)) {
|
|
499
|
+
this._overlayRef
|
|
500
|
+
.outsidePointerEvents()
|
|
501
|
+
.pipe(takeUntil(this._destroy$))
|
|
502
|
+
.subscribe(() => {
|
|
503
|
+
if (!this.loading()) {
|
|
504
|
+
this.close();
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
if (isPlatformBrowser(this._platformId)) {
|
|
509
|
+
fromEvent(document, 'keydown')
|
|
510
|
+
.pipe(filter(event => event.key === 'Escape'), takeUntil(this._destroy$))
|
|
511
|
+
.subscribe(() => {
|
|
512
|
+
if (!this.loading()) {
|
|
513
|
+
this.close();
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
setLoading(value) {
|
|
519
|
+
this.loading.set(value);
|
|
520
|
+
}
|
|
521
|
+
close(result) {
|
|
522
|
+
if (this._isClosing) {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
this._isClosing = true;
|
|
526
|
+
this._result = result;
|
|
527
|
+
if (isPlatformBrowser(this._platformId)) {
|
|
528
|
+
const hostElement = this._containerInstance.getNativeElement();
|
|
529
|
+
hostElement.classList.add('drawer-leave');
|
|
530
|
+
const { backdropElement } = this._overlayRef;
|
|
531
|
+
if (backdropElement) {
|
|
532
|
+
backdropElement.classList.add('z-backdrop-leaving');
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
setTimeout(() => {
|
|
536
|
+
if (this._overlayRef) {
|
|
537
|
+
if (this._overlayRef.hasAttached()) {
|
|
538
|
+
this._overlayRef.detachBackdrop();
|
|
539
|
+
}
|
|
540
|
+
this._overlayRef.dispose();
|
|
541
|
+
}
|
|
542
|
+
if (!this._destroy$.closed) {
|
|
543
|
+
this._destroy$.next();
|
|
544
|
+
this._destroy$.complete();
|
|
545
|
+
}
|
|
546
|
+
}, Z_DRAWER_ANIMATION_DURATION);
|
|
547
|
+
}
|
|
548
|
+
_trigger(action) {
|
|
549
|
+
if (this.loading()) {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
const trigger = {
|
|
553
|
+
ok: this._config.zOnOk,
|
|
554
|
+
cancel: this._config.zOnCancel,
|
|
555
|
+
}[action];
|
|
556
|
+
if (trigger instanceof EventEmitter) {
|
|
557
|
+
trigger.emit(this._getContentComponent());
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
if (typeof trigger === 'function') {
|
|
561
|
+
const result = trigger(this._getContentComponent(), this);
|
|
562
|
+
this._closeWithResult(result);
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
this.close();
|
|
566
|
+
}
|
|
567
|
+
_getContentComponent() {
|
|
568
|
+
return this.componentInstance;
|
|
569
|
+
}
|
|
570
|
+
_closeWithResult(result) {
|
|
571
|
+
if (result !== false) {
|
|
572
|
+
this.close(result);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
ZDrawerRef = __decorate([
|
|
577
|
+
__param(3, Inject(PLATFORM_ID)),
|
|
578
|
+
__metadata("design:paramtypes", [OverlayRef,
|
|
579
|
+
ZDrawerOptions,
|
|
580
|
+
ZDrawerComponent, Object])
|
|
581
|
+
], ZDrawerRef);
|
|
582
|
+
|
|
583
|
+
class ZDrawerService {
|
|
584
|
+
_overlay = inject(Overlay);
|
|
585
|
+
_injector = inject(Injector);
|
|
586
|
+
_platformId = inject(PLATFORM_ID);
|
|
587
|
+
create(config) {
|
|
588
|
+
return this._open(config.zContent, config);
|
|
589
|
+
}
|
|
590
|
+
_open(componentOrTemplateRef, config) {
|
|
591
|
+
const overlayRef = this._createOverlay(config);
|
|
592
|
+
if (!overlayRef) {
|
|
593
|
+
return new ZDrawerRef(undefined, config, undefined, this._platformId);
|
|
594
|
+
}
|
|
595
|
+
const drawerContainer = this._attachDrawerContainer(overlayRef, config);
|
|
596
|
+
const drawerRef = this._attachDrawerContent(componentOrTemplateRef, drawerContainer, overlayRef, config);
|
|
597
|
+
return drawerRef;
|
|
598
|
+
}
|
|
599
|
+
_createOverlay(config) {
|
|
600
|
+
if (!isPlatformBrowser(this._platformId)) {
|
|
601
|
+
return undefined;
|
|
602
|
+
}
|
|
603
|
+
const overlayType = config.zOverlay ?? getOverlayType();
|
|
604
|
+
const backdropClass = overlayType === 'blur' ? 'z-drawer-backdrop-blur' : 'z-drawer-backdrop-dark';
|
|
605
|
+
const overlayConfig = new OverlayConfig({
|
|
606
|
+
hasBackdrop: true,
|
|
607
|
+
backdropClass,
|
|
608
|
+
positionStrategy: this._overlay.position().global(),
|
|
609
|
+
});
|
|
610
|
+
return this._overlay.create(overlayConfig);
|
|
611
|
+
}
|
|
612
|
+
_attachDrawerContainer(overlayRef, config) {
|
|
613
|
+
const injector = Injector.create({
|
|
614
|
+
parent: this._injector,
|
|
615
|
+
providers: [
|
|
616
|
+
{ provide: OverlayRef, useValue: overlayRef },
|
|
617
|
+
{ provide: ZDrawerOptions, useValue: config },
|
|
618
|
+
],
|
|
619
|
+
});
|
|
620
|
+
const containerPortal = new ComponentPortal(ZDrawerComponent, config.zViewContainerRef, injector);
|
|
621
|
+
const containerRef = overlayRef.attach(containerPortal);
|
|
622
|
+
return containerRef.instance;
|
|
623
|
+
}
|
|
624
|
+
_attachDrawerContent(componentOrTemplateRef, drawerContainer, overlayRef, config) {
|
|
625
|
+
const drawerRef = new ZDrawerRef(overlayRef, config, drawerContainer, this._platformId);
|
|
626
|
+
drawerContainer.drawerRef = drawerRef;
|
|
627
|
+
if (componentOrTemplateRef instanceof TemplateRef) {
|
|
628
|
+
drawerContainer.attachTemplatePortal(new TemplatePortal(componentOrTemplateRef, null, { drawerRef }));
|
|
629
|
+
return drawerRef;
|
|
630
|
+
}
|
|
631
|
+
if (typeof componentOrTemplateRef !== 'string') {
|
|
632
|
+
const injector = this._createInjector(drawerRef, config);
|
|
633
|
+
const contentRef = drawerContainer.attachComponentPortal(new ComponentPortal(componentOrTemplateRef, config.zViewContainerRef, injector));
|
|
634
|
+
if (contentRef) {
|
|
635
|
+
drawerRef.componentInstance = contentRef.instance;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return drawerRef;
|
|
639
|
+
}
|
|
640
|
+
_createInjector(drawerRef, config) {
|
|
641
|
+
return Injector.create({
|
|
642
|
+
parent: this._injector,
|
|
643
|
+
providers: [
|
|
644
|
+
{ provide: ZDrawerRef, useValue: drawerRef },
|
|
645
|
+
{ provide: Z_DRAWER_DATA, useValue: config.zData },
|
|
646
|
+
],
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZDrawerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
650
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZDrawerService, providedIn: 'root' });
|
|
651
|
+
}
|
|
652
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZDrawerService, decorators: [{
|
|
653
|
+
type: Injectable,
|
|
654
|
+
args: [{
|
|
655
|
+
providedIn: 'root',
|
|
656
|
+
}]
|
|
657
|
+
}] });
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Generated bundle index. Do not edit.
|
|
661
|
+
*/
|
|
662
|
+
|
|
663
|
+
export { ZDrawerComponent, ZDrawerContentDirective, ZDrawerFooterDirective, ZDrawerHeaderDirective, ZDrawerRef, ZDrawerService, Z_DRAWER_DATA, zDrawerVariants };
|
|
664
|
+
//# sourceMappingURL=shival99-z-ui-components-z-drawer.mjs.map
|