@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.
Files changed (115) hide show
  1. package/README.md +50 -77
  2. package/assets/css/animations.css +207 -0
  3. package/assets/css/base.css +76 -0
  4. package/assets/css/tailwind.css +53 -0
  5. package/assets/css/themes/gray.css +73 -0
  6. package/assets/css/themes/green.css +75 -0
  7. package/assets/css/themes/hospital.css +79 -0
  8. package/assets/css/themes/neutral.css +73 -0
  9. package/assets/css/themes/orange.css +73 -0
  10. package/assets/css/themes/slate.css +73 -0
  11. package/assets/css/themes/stone.css +73 -0
  12. package/assets/css/themes/violet.css +73 -0
  13. package/assets/css/themes/zinc.css +73 -0
  14. package/assets/images/avatar.svg +6 -0
  15. package/assets/images/logo.svg +6 -0
  16. package/fesm2022/shival99-z-ui-components-z-accordion.mjs +148 -0
  17. package/fesm2022/shival99-z-ui-components-z-accordion.mjs.map +1 -0
  18. package/fesm2022/shival99-z-ui-components-z-breadcrumb.mjs +74 -0
  19. package/fesm2022/shival99-z-ui-components-z-breadcrumb.mjs.map +1 -0
  20. package/fesm2022/shival99-z-ui-components-z-button.mjs +155 -0
  21. package/fesm2022/shival99-z-ui-components-z-button.mjs.map +1 -0
  22. package/fesm2022/shival99-z-ui-components-z-calendar.mjs +2335 -0
  23. package/fesm2022/shival99-z-ui-components-z-calendar.mjs.map +1 -0
  24. package/fesm2022/shival99-z-ui-components-z-checkbox.mjs +240 -0
  25. package/fesm2022/shival99-z-ui-components-z-checkbox.mjs.map +1 -0
  26. package/fesm2022/shival99-z-ui-components-z-code.mjs +139 -0
  27. package/fesm2022/shival99-z-ui-components-z-code.mjs.map +1 -0
  28. package/fesm2022/shival99-z-ui-components-z-drawer.mjs +664 -0
  29. package/fesm2022/shival99-z-ui-components-z-drawer.mjs.map +1 -0
  30. package/fesm2022/shival99-z-ui-components-z-dropdown-menu.mjs +55 -0
  31. package/fesm2022/shival99-z-ui-components-z-dropdown-menu.mjs.map +1 -0
  32. package/fesm2022/shival99-z-ui-components-z-editor.mjs +411 -0
  33. package/fesm2022/shival99-z-ui-components-z-editor.mjs.map +1 -0
  34. package/fesm2022/shival99-z-ui-components-z-filter.mjs +794 -0
  35. package/fesm2022/shival99-z-ui-components-z-filter.mjs.map +1 -0
  36. package/fesm2022/shival99-z-ui-components-z-icon.mjs +451 -0
  37. package/fesm2022/shival99-z-ui-components-z-icon.mjs.map +1 -0
  38. package/fesm2022/shival99-z-ui-components-z-input.mjs +804 -0
  39. package/fesm2022/shival99-z-ui-components-z-input.mjs.map +1 -0
  40. package/fesm2022/shival99-z-ui-components-z-loading.mjs +105 -0
  41. package/fesm2022/shival99-z-ui-components-z-loading.mjs.map +1 -0
  42. package/fesm2022/shival99-z-ui-components-z-menu.mjs +351 -0
  43. package/fesm2022/shival99-z-ui-components-z-menu.mjs.map +1 -0
  44. package/fesm2022/shival99-z-ui-components-z-modal.mjs +722 -0
  45. package/fesm2022/shival99-z-ui-components-z-modal.mjs.map +1 -0
  46. package/fesm2022/shival99-z-ui-components-z-pagination.mjs +131 -0
  47. package/fesm2022/shival99-z-ui-components-z-pagination.mjs.map +1 -0
  48. package/fesm2022/shival99-z-ui-components-z-popover.mjs +917 -0
  49. package/fesm2022/shival99-z-ui-components-z-popover.mjs.map +1 -0
  50. package/fesm2022/shival99-z-ui-components-z-radio.mjs +154 -0
  51. package/fesm2022/shival99-z-ui-components-z-radio.mjs.map +1 -0
  52. package/fesm2022/shival99-z-ui-components-z-select.mjs +998 -0
  53. package/fesm2022/shival99-z-ui-components-z-select.mjs.map +1 -0
  54. package/fesm2022/shival99-z-ui-components-z-skeleton.mjs +139 -0
  55. package/fesm2022/shival99-z-ui-components-z-skeleton.mjs.map +1 -0
  56. package/fesm2022/shival99-z-ui-components-z-switch.mjs +127 -0
  57. package/fesm2022/shival99-z-ui-components-z-switch.mjs.map +1 -0
  58. package/fesm2022/shival99-z-ui-components-z-table.mjs +2628 -0
  59. package/fesm2022/shival99-z-ui-components-z-table.mjs.map +1 -0
  60. package/fesm2022/shival99-z-ui-components-z-tabs.mjs +259 -0
  61. package/fesm2022/shival99-z-ui-components-z-tabs.mjs.map +1 -0
  62. package/fesm2022/shival99-z-ui-components-z-timeline.mjs +335 -0
  63. package/fesm2022/shival99-z-ui-components-z-timeline.mjs.map +1 -0
  64. package/fesm2022/shival99-z-ui-components-z-toast.mjs +93 -0
  65. package/fesm2022/shival99-z-ui-components-z-toast.mjs.map +1 -0
  66. package/fesm2022/shival99-z-ui-components-z-tooltip.mjs +660 -0
  67. package/fesm2022/shival99-z-ui-components-z-tooltip.mjs.map +1 -0
  68. package/fesm2022/shival99-z-ui-components-z-upload.mjs +504 -0
  69. package/fesm2022/shival99-z-ui-components-z-upload.mjs.map +1 -0
  70. package/fesm2022/shival99-z-ui-i18n.mjs +258 -0
  71. package/fesm2022/shival99-z-ui-i18n.mjs.map +1 -0
  72. package/fesm2022/shival99-z-ui-pipes.mjs +116 -0
  73. package/fesm2022/shival99-z-ui-pipes.mjs.map +1 -0
  74. package/fesm2022/shival99-z-ui-providers.mjs +203 -0
  75. package/fesm2022/shival99-z-ui-providers.mjs.map +1 -0
  76. package/fesm2022/shival99-z-ui-services.mjs +919 -0
  77. package/fesm2022/shival99-z-ui-services.mjs.map +1 -0
  78. package/fesm2022/shival99-z-ui-utils.mjs +591 -0
  79. package/fesm2022/shival99-z-ui-utils.mjs.map +1 -0
  80. package/fesm2022/z-ui.mjs +3 -19924
  81. package/fesm2022/z-ui.mjs.map +1 -1
  82. package/package.json +132 -4
  83. package/types/shival99-z-ui-components-z-accordion.d.ts +55 -0
  84. package/types/shival99-z-ui-components-z-breadcrumb.d.ts +36 -0
  85. package/types/shival99-z-ui-components-z-button.d.ts +41 -0
  86. package/types/shival99-z-ui-components-z-calendar.d.ts +300 -0
  87. package/types/shival99-z-ui-components-z-checkbox.d.ts +84 -0
  88. package/types/shival99-z-ui-components-z-code.d.ts +35 -0
  89. package/types/shival99-z-ui-components-z-drawer.d.ts +232 -0
  90. package/types/shival99-z-ui-components-z-dropdown-menu.d.ts +50 -0
  91. package/types/shival99-z-ui-components-z-editor.d.ts +115 -0
  92. package/types/shival99-z-ui-components-z-filter.d.ts +268 -0
  93. package/types/shival99-z-ui-components-z-icon.d.ts +291 -0
  94. package/types/shival99-z-ui-components-z-input.d.ts +188 -0
  95. package/types/shival99-z-ui-components-z-loading.d.ts +46 -0
  96. package/types/shival99-z-ui-components-z-menu.d.ts +116 -0
  97. package/types/shival99-z-ui-components-z-modal.d.ts +270 -0
  98. package/types/shival99-z-ui-components-z-pagination.d.ts +52 -0
  99. package/types/shival99-z-ui-components-z-popover.d.ts +134 -0
  100. package/types/shival99-z-ui-components-z-radio.d.ts +63 -0
  101. package/types/shival99-z-ui-components-z-select.d.ts +268 -0
  102. package/types/shival99-z-ui-components-z-skeleton.d.ts +55 -0
  103. package/types/shival99-z-ui-components-z-switch.d.ts +48 -0
  104. package/types/shival99-z-ui-components-z-table.d.ts +482 -0
  105. package/types/shival99-z-ui-components-z-tabs.d.ts +75 -0
  106. package/types/shival99-z-ui-components-z-timeline.d.ts +98 -0
  107. package/types/shival99-z-ui-components-z-toast.d.ts +61 -0
  108. package/types/shival99-z-ui-components-z-tooltip.d.ts +85 -0
  109. package/types/shival99-z-ui-components-z-upload.d.ts +136 -0
  110. package/types/shival99-z-ui-i18n.d.ts +50 -0
  111. package/types/shival99-z-ui-pipes.d.ts +36 -0
  112. package/types/shival99-z-ui-providers.d.ts +132 -0
  113. package/types/shival99-z-ui-services.d.ts +364 -0
  114. package/types/shival99-z-ui-utils.d.ts +145 -0
  115. package/types/z-ui.d.ts +3 -4977
@@ -0,0 +1,660 @@
1
+ import { Overlay, OverlayPositionBuilder } from '@angular/cdk/overlay';
2
+ import { ComponentPortal } from '@angular/cdk/portal';
3
+ import { NgTemplateOutlet, DOCUMENT, isPlatformBrowser } from '@angular/common';
4
+ import * as i0 from '@angular/core';
5
+ import { signal, computed, ChangeDetectionStrategy, Component, input, output, inject, ElementRef, Renderer2, DestroyRef, PLATFORM_ID, Directive } from '@angular/core';
6
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
7
+ import { zMergeClasses, zTransform } from '@shival99/z-ui/utils';
8
+ import { Subject, switchMap, of, timer, map, filter } from 'rxjs';
9
+ import { ZSafeHtmlPipe } from '@shival99/z-ui/pipes';
10
+ import { cva } from 'class-variance-authority';
11
+
12
+ const zTooltipVariants = cva(['z-tooltip relative z-[9999] rounded-[5px] shadow-md', 'z-animate-in z-fade-in z-duration-150'], {
13
+ variants: {
14
+ zType: {
15
+ default: 'bg-foreground text-background border border-foreground',
16
+ dark: 'bg-slate-900 text-white border border-slate-700',
17
+ light: 'bg-white text-slate-900 border border-slate-200',
18
+ primary: 'bg-primary text-primary-foreground border border-primary',
19
+ success: 'bg-green-600 text-white border border-green-600',
20
+ warning: 'bg-amber-500 text-white border border-amber-500',
21
+ error: 'bg-red-600 text-white border border-red-600',
22
+ info: 'bg-blue-600 text-white border border-blue-600',
23
+ },
24
+ zSize: {
25
+ sm: 'text-[10px]',
26
+ default: 'text-xs',
27
+ lg: 'text-sm',
28
+ },
29
+ zPosition: {
30
+ top: 'z-slide-in-from-bottom-2',
31
+ 'top-left': 'z-slide-in-from-bottom-2',
32
+ 'top-right': 'z-slide-in-from-bottom-2',
33
+ bottom: 'z-slide-in-from-top-2',
34
+ 'bottom-left': 'z-slide-in-from-top-2',
35
+ 'bottom-right': 'z-slide-in-from-top-2',
36
+ left: 'z-slide-in-from-right-2',
37
+ 'left-top': 'z-slide-in-from-right-2',
38
+ 'left-bottom': 'z-slide-in-from-right-2',
39
+ right: 'z-slide-in-from-left-2',
40
+ 'right-top': 'z-slide-in-from-left-2',
41
+ 'right-bottom': 'z-slide-in-from-left-2',
42
+ },
43
+ },
44
+ defaultVariants: {
45
+ zType: 'default',
46
+ zSize: 'default',
47
+ zPosition: 'top',
48
+ },
49
+ });
50
+ const zTooltipContentVariants = cva('relative z-10 rounded-[4px] font-medium p-1.5 break-words leading-[1.7]', {
51
+ variants: {
52
+ zType: {
53
+ default: 'bg-foreground',
54
+ dark: 'bg-slate-900',
55
+ light: 'bg-white',
56
+ primary: 'bg-primary',
57
+ success: 'bg-green-600',
58
+ warning: 'bg-amber-500',
59
+ error: 'bg-red-600',
60
+ info: 'bg-blue-600',
61
+ },
62
+ },
63
+ defaultVariants: {
64
+ zType: 'default',
65
+ },
66
+ });
67
+ const zTooltipArrowVariants = cva('absolute z-0 size-2.5 rotate-45 rounded-[2px]', {
68
+ variants: {
69
+ position: {
70
+ top: '-bottom-1 left-1/2 -translate-x-1/2 border-r border-b',
71
+ 'top-left': '-bottom-1 left-3 border-r border-b',
72
+ 'top-right': '-bottom-1 right-3 border-r border-b',
73
+ bottom: '-top-1 left-1/2 -translate-x-1/2 border-l border-t',
74
+ 'bottom-left': '-top-1 left-3 border-l border-t',
75
+ 'bottom-right': '-top-1 right-3 border-l border-t',
76
+ left: 'top-1/2 -translate-y-1/2 -right-1 border-t border-r',
77
+ 'left-top': 'top-2 -right-1 border-t border-r',
78
+ 'left-bottom': 'bottom-2 -right-1 border-t border-r',
79
+ right: 'top-1/2 -translate-y-1/2 -left-1 border-b border-l',
80
+ 'right-top': 'top-2 -left-1 border-b border-l',
81
+ 'right-bottom': 'bottom-2 -left-1 border-b border-l',
82
+ },
83
+ zType: {
84
+ default: 'bg-foreground border-foreground',
85
+ dark: 'bg-slate-900 border-slate-700',
86
+ light: 'bg-white border-slate-200',
87
+ primary: 'bg-primary border-primary',
88
+ success: 'bg-green-600 border-green-600',
89
+ warning: 'bg-amber-500 border-amber-500',
90
+ error: 'bg-red-600 border-red-600',
91
+ info: 'bg-blue-600 border-blue-600',
92
+ },
93
+ },
94
+ defaultVariants: {
95
+ position: 'top',
96
+ zType: 'default',
97
+ },
98
+ });
99
+ const zTooltipExitVariants = cva('z-animate-out z-fade-out', {
100
+ variants: {
101
+ zPosition: {
102
+ top: 'z-slide-out-to-bottom-2',
103
+ 'top-left': 'z-slide-out-to-bottom-2',
104
+ 'top-right': 'z-slide-out-to-bottom-2',
105
+ bottom: 'z-slide-out-to-top-2',
106
+ 'bottom-left': 'z-slide-out-to-top-2',
107
+ 'bottom-right': 'z-slide-out-to-top-2',
108
+ left: 'z-slide-out-to-right-2',
109
+ 'left-top': 'z-slide-out-to-right-2',
110
+ 'left-bottom': 'z-slide-out-to-right-2',
111
+ right: 'z-slide-out-to-left-2',
112
+ 'right-top': 'z-slide-out-to-left-2',
113
+ 'right-bottom': 'z-slide-out-to-left-2',
114
+ },
115
+ },
116
+ defaultVariants: {
117
+ zPosition: 'top',
118
+ },
119
+ });
120
+
121
+ class ZTooltipContentComponent {
122
+ content = signal('', ...(ngDevMode ? [{ debugName: "content" }] : []));
123
+ position = signal('top', ...(ngDevMode ? [{ debugName: "position" }] : []));
124
+ tooltipType = signal('default', ...(ngDevMode ? [{ debugName: "tooltipType" }] : []));
125
+ tooltipSize = signal('default', ...(ngDevMode ? [{ debugName: "tooltipSize" }] : []));
126
+ tooltipClass = signal('', ...(ngDevMode ? [{ debugName: "tooltipClass" }] : []));
127
+ showArrow = signal(true, ...(ngDevMode ? [{ debugName: "showArrow" }] : []));
128
+ maxWidth = signal('250px', ...(ngDevMode ? [{ debugName: "maxWidth" }] : []));
129
+ state = signal('open', ...(ngDevMode ? [{ debugName: "state" }] : []));
130
+ arrowOffset = signal(0, ...(ngDevMode ? [{ debugName: "arrowOffset" }] : []));
131
+ classes = computed(() => {
132
+ const baseClasses = zTooltipVariants({
133
+ zType: this.tooltipType(),
134
+ zSize: this.tooltipSize(),
135
+ zPosition: this.position(),
136
+ });
137
+ const exitClasses = this.state() === 'closed' ? this._getExitAnimationClasses() : '';
138
+ return zMergeClasses(baseClasses, exitClasses, this.tooltipClass());
139
+ }, ...(ngDevMode ? [{ debugName: "classes" }] : []));
140
+ _getExitAnimationClasses() {
141
+ return zTooltipExitVariants({ zPosition: this.position() });
142
+ }
143
+ contentClasses = computed(() => zMergeClasses(zTooltipContentVariants({ zType: this.tooltipType() })), ...(ngDevMode ? [{ debugName: "contentClasses" }] : []));
144
+ arrowClasses = computed(() => zMergeClasses(zTooltipArrowVariants({
145
+ position: this.position(),
146
+ zType: this.tooltipType(),
147
+ })), ...(ngDevMode ? [{ debugName: "arrowClasses" }] : []));
148
+ arrowStyle = computed(() => {
149
+ const pos = this.position();
150
+ const offset = this.arrowOffset();
151
+ const isCornerPosition = pos.includes('-');
152
+ if (isCornerPosition) {
153
+ return {};
154
+ }
155
+ if (offset === 0) {
156
+ return {};
157
+ }
158
+ if (pos === 'top' || pos === 'bottom') {
159
+ return {
160
+ left: `calc(50% + ${offset}px)`,
161
+ };
162
+ }
163
+ if (pos === 'left' || pos === 'right') {
164
+ return {
165
+ top: `calc(50% + ${offset}px)`,
166
+ };
167
+ }
168
+ return {};
169
+ }, ...(ngDevMode ? [{ debugName: "arrowStyle" }] : []));
170
+ isTemplateContent = computed(() => {
171
+ const c = this.content();
172
+ return c && typeof c !== 'string';
173
+ }, ...(ngDevMode ? [{ debugName: "isTemplateContent" }] : []));
174
+ isHtmlContent = computed(() => {
175
+ const c = this.content();
176
+ return typeof c === 'string' && c.includes('<');
177
+ }, ...(ngDevMode ? [{ debugName: "isHtmlContent" }] : []));
178
+ setProps(config) {
179
+ this.content.set(config.content);
180
+ this.position.set(config.position);
181
+ if (config.type) {
182
+ this.tooltipType.set(config.type);
183
+ }
184
+ if (config.size) {
185
+ this.tooltipSize.set(config.size);
186
+ }
187
+ if (config.customClass) {
188
+ this.tooltipClass.set(config.customClass);
189
+ }
190
+ if (config.arrow !== undefined) {
191
+ this.showArrow.set(config.arrow);
192
+ }
193
+ if (config.maxWidth) {
194
+ this.maxWidth.set(config.maxWidth);
195
+ }
196
+ }
197
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZTooltipContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
198
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.6", type: ZTooltipContentComponent, isStandalone: true, selector: "z-tooltip-content", host: { attributes: { "role": "tooltip" }, properties: { "class": "classes()", "style.maxWidth": "maxWidth()", "attr.data-state": "state()", "attr.data-position": "position()" } }, ngImport: i0, template: `
199
+ <!-- Arrow layer - rotated square, partial border -->
200
+ @if (showArrow()) {
201
+ <div [class]="arrowClasses()" [style]="arrowStyle()"></div>
202
+ }
203
+
204
+ <!-- Content layer - covers arrow base -->
205
+ <div [class]="contentClasses()">
206
+ @if (isTemplateContent()) {
207
+ <ng-container [ngTemplateOutlet]="$any(content())" />
208
+ } @else if (isHtmlContent()) {
209
+ <span [innerHTML]="$any(content()) | zSafeHtml"></span>
210
+ } @else {
211
+ {{ content() }}
212
+ }
213
+ </div>
214
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: ZSafeHtmlPipe, name: "zSafeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
215
+ }
216
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZTooltipContentComponent, decorators: [{
217
+ type: Component,
218
+ args: [{
219
+ selector: 'z-tooltip-content',
220
+ imports: [NgTemplateOutlet, ZSafeHtmlPipe],
221
+ standalone: true,
222
+ template: `
223
+ <!-- Arrow layer - rotated square, partial border -->
224
+ @if (showArrow()) {
225
+ <div [class]="arrowClasses()" [style]="arrowStyle()"></div>
226
+ }
227
+
228
+ <!-- Content layer - covers arrow base -->
229
+ <div [class]="contentClasses()">
230
+ @if (isTemplateContent()) {
231
+ <ng-container [ngTemplateOutlet]="$any(content())" />
232
+ } @else if (isHtmlContent()) {
233
+ <span [innerHTML]="$any(content()) | zSafeHtml"></span>
234
+ } @else {
235
+ {{ content() }}
236
+ }
237
+ </div>
238
+ `,
239
+ changeDetection: ChangeDetectionStrategy.OnPush,
240
+ host: {
241
+ '[class]': 'classes()',
242
+ '[style.maxWidth]': 'maxWidth()',
243
+ '[attr.data-state]': 'state()',
244
+ '[attr.data-position]': 'position()',
245
+ role: 'tooltip',
246
+ },
247
+ }]
248
+ }] });
249
+
250
+ function createTooltipPosition(position, offset) {
251
+ const positions = {
252
+ top: {
253
+ originX: 'center',
254
+ originY: 'top',
255
+ overlayX: 'center',
256
+ overlayY: 'bottom',
257
+ offsetY: -offset,
258
+ },
259
+ 'top-left': {
260
+ originX: 'start',
261
+ originY: 'top',
262
+ overlayX: 'start',
263
+ overlayY: 'bottom',
264
+ offsetY: -offset,
265
+ },
266
+ 'top-right': {
267
+ originX: 'end',
268
+ originY: 'top',
269
+ overlayX: 'end',
270
+ overlayY: 'bottom',
271
+ offsetY: -offset,
272
+ },
273
+ bottom: {
274
+ originX: 'center',
275
+ originY: 'bottom',
276
+ overlayX: 'center',
277
+ overlayY: 'top',
278
+ offsetY: offset,
279
+ },
280
+ 'bottom-left': {
281
+ originX: 'start',
282
+ originY: 'bottom',
283
+ overlayX: 'start',
284
+ overlayY: 'top',
285
+ offsetY: offset,
286
+ },
287
+ 'bottom-right': {
288
+ originX: 'end',
289
+ originY: 'bottom',
290
+ overlayX: 'end',
291
+ overlayY: 'top',
292
+ offsetY: offset,
293
+ },
294
+ left: {
295
+ originX: 'start',
296
+ originY: 'center',
297
+ overlayX: 'end',
298
+ overlayY: 'center',
299
+ offsetX: -offset,
300
+ },
301
+ 'left-top': {
302
+ originX: 'start',
303
+ originY: 'top',
304
+ overlayX: 'end',
305
+ overlayY: 'top',
306
+ offsetX: -offset,
307
+ },
308
+ 'left-bottom': {
309
+ originX: 'start',
310
+ originY: 'bottom',
311
+ overlayX: 'end',
312
+ overlayY: 'bottom',
313
+ offsetX: -offset,
314
+ },
315
+ right: {
316
+ originX: 'end',
317
+ originY: 'center',
318
+ overlayX: 'start',
319
+ overlayY: 'center',
320
+ offsetX: offset,
321
+ },
322
+ 'right-top': {
323
+ originX: 'end',
324
+ originY: 'top',
325
+ overlayX: 'start',
326
+ overlayY: 'top',
327
+ offsetX: offset,
328
+ },
329
+ 'right-bottom': {
330
+ originX: 'end',
331
+ originY: 'bottom',
332
+ overlayX: 'start',
333
+ overlayY: 'bottom',
334
+ offsetX: offset,
335
+ },
336
+ };
337
+ return positions[position];
338
+ }
339
+ function getTooltipFallbackPositions(position, offset) {
340
+ const fallbackOrder = {
341
+ top: ['top', 'bottom', 'top-left', 'top-right', 'bottom-left', 'bottom-right'],
342
+ 'top-left': ['top-left', 'bottom-left', 'top', 'bottom', 'top-right', 'bottom-right'],
343
+ 'top-right': ['top-right', 'bottom-right', 'top', 'bottom', 'top-left', 'bottom-left'],
344
+ bottom: ['bottom', 'top', 'bottom-left', 'bottom-right', 'top-left', 'top-right'],
345
+ 'bottom-left': ['bottom-left', 'top-left', 'bottom', 'top', 'bottom-right', 'top-right'],
346
+ 'bottom-right': ['bottom-right', 'top-right', 'bottom', 'top', 'bottom-left', 'top-left'],
347
+ left: ['left', 'right', 'left-top', 'left-bottom', 'right-top', 'right-bottom'],
348
+ 'left-top': ['left-top', 'right-top', 'left', 'right', 'left-bottom', 'right-bottom'],
349
+ 'left-bottom': ['left-bottom', 'right-bottom', 'left', 'right', 'left-top', 'right-top'],
350
+ right: ['right', 'left', 'right-top', 'right-bottom', 'left-top', 'left-bottom'],
351
+ 'right-top': ['right-top', 'left-top', 'right', 'left', 'right-bottom', 'left-bottom'],
352
+ 'right-bottom': ['right-bottom', 'left-bottom', 'right', 'left', 'right-top', 'left-top'],
353
+ };
354
+ const orderedPositions = fallbackOrder[position] ?? [position];
355
+ return orderedPositions.map(pos => createTooltipPosition(pos, offset));
356
+ }
357
+ function getActualPosition(change) {
358
+ const { originX, originY, overlayX, overlayY } = change.connectionPair;
359
+ if (overlayY === 'bottom' && originY === 'top') {
360
+ if (originX === 'start' && overlayX === 'start') {
361
+ return 'top-left';
362
+ }
363
+ if (originX === 'end' && overlayX === 'end') {
364
+ return 'top-right';
365
+ }
366
+ return 'top';
367
+ }
368
+ if (overlayY === 'top' && originY === 'bottom') {
369
+ if (originX === 'start' && overlayX === 'start') {
370
+ return 'bottom-left';
371
+ }
372
+ if (originX === 'end' && overlayX === 'end') {
373
+ return 'bottom-right';
374
+ }
375
+ return 'bottom';
376
+ }
377
+ if (overlayX === 'end' && originX === 'start') {
378
+ if (originY === 'top' && overlayY === 'top') {
379
+ return 'left-top';
380
+ }
381
+ if (originY === 'bottom' && overlayY === 'bottom') {
382
+ return 'left-bottom';
383
+ }
384
+ return 'left';
385
+ }
386
+ if (overlayX === 'start' && originX === 'end') {
387
+ if (originY === 'top' && overlayY === 'top') {
388
+ return 'right-top';
389
+ }
390
+ if (originY === 'bottom' && overlayY === 'bottom') {
391
+ return 'right-bottom';
392
+ }
393
+ return 'right';
394
+ }
395
+ return 'top';
396
+ }
397
+
398
+ const Z_TOOLTIP_ANIMATION_DURATION = 150;
399
+
400
+ class ZTooltipDirective {
401
+ zContent = input('', ...(ngDevMode ? [{ debugName: "zContent" }] : []));
402
+ zPosition = input('top', ...(ngDevMode ? [{ debugName: "zPosition" }] : []));
403
+ zTrigger = input('hover', ...(ngDevMode ? [{ debugName: "zTrigger" }] : []));
404
+ zType = input('default', { ...(ngDevMode ? { debugName: "zType" } : {}), alias: 'zTooltipType' });
405
+ zSize = input('default', { ...(ngDevMode ? { debugName: "zSize" } : {}), alias: 'zTooltipSize' });
406
+ zClass = input('', ...(ngDevMode ? [{ debugName: "zClass" }] : []));
407
+ zShowDelay = input(100, ...(ngDevMode ? [{ debugName: "zShowDelay" }] : []));
408
+ zHideDelay = input(0, ...(ngDevMode ? [{ debugName: "zHideDelay" }] : []));
409
+ zArrow = input(true, { ...(ngDevMode ? { debugName: "zArrow" } : {}), transform: zTransform });
410
+ zDisabled = input(false, { ...(ngDevMode ? { debugName: "zDisabled" } : {}), transform: zTransform });
411
+ zOffset = input(8, ...(ngDevMode ? [{ debugName: "zOffset" }] : []));
412
+ zAutoDetect = input(true, { ...(ngDevMode ? { debugName: "zAutoDetect" } : {}), transform: zTransform });
413
+ zTriggerElement = input(null, ...(ngDevMode ? [{ debugName: "zTriggerElement" }] : []));
414
+ zAlwaysShow = input(false, { ...(ngDevMode ? { debugName: "zAlwaysShow" } : {}), transform: zTransform });
415
+ zMaxWidth = input('250px', ...(ngDevMode ? [{ debugName: "zMaxWidth" }] : []));
416
+ zShow = output();
417
+ zHide = output();
418
+ _overlay = inject(Overlay);
419
+ _overlayPositionBuilder = inject(OverlayPositionBuilder);
420
+ _elementRef = inject((ElementRef));
421
+ _renderer = inject(Renderer2);
422
+ _destroyRef = inject(DestroyRef);
423
+ _platformId = inject(PLATFORM_ID);
424
+ _document = inject(DOCUMENT);
425
+ _overlayRef = null;
426
+ _componentRef = null;
427
+ _delaySubject = new Subject();
428
+ _listenerCleanups = [];
429
+ _positionSubscription = null;
430
+ _isVisible = signal(false, ...(ngDevMode ? [{ debugName: "_isVisible" }] : []));
431
+ ngOnInit() {
432
+ if (!isPlatformBrowser(this._platformId)) {
433
+ return;
434
+ }
435
+ this._setupDelayMechanism();
436
+ this._setupTriggers();
437
+ }
438
+ ngOnDestroy() {
439
+ this._delaySubject.complete();
440
+ this._cleanupListeners();
441
+ this._disposeOverlay();
442
+ }
443
+ show() {
444
+ if (this.zDisabled() || !this.zContent()) {
445
+ return;
446
+ }
447
+ if (!this.zAlwaysShow() && this.zAutoDetect() && !this._isTextTruncated()) {
448
+ return;
449
+ }
450
+ if (this._isVisible()) {
451
+ this._delay(true, 0);
452
+ return;
453
+ }
454
+ this._delay(true, this.zShowDelay());
455
+ }
456
+ _isTextTruncated() {
457
+ const el = this._elementRef.nativeElement;
458
+ if (el.scrollWidth > el.clientWidth) {
459
+ return true;
460
+ }
461
+ if (el.scrollHeight > el.clientHeight) {
462
+ return true;
463
+ }
464
+ const styles = getComputedStyle(el);
465
+ const lineClamp = styles.getPropertyValue('-webkit-line-clamp');
466
+ if (lineClamp && lineClamp !== 'none') {
467
+ const range = this._document.createRange();
468
+ range.selectNodeContents(el);
469
+ const rangeHeight = range.getBoundingClientRect().height;
470
+ const elHeight = el.getBoundingClientRect().height;
471
+ const paddingTop = parseFloat(styles.paddingTop) || 0;
472
+ const paddingBottom = parseFloat(styles.paddingBottom) || 0;
473
+ const contentHeight = elHeight - paddingTop - paddingBottom;
474
+ if (rangeHeight > contentHeight + 1) {
475
+ return true;
476
+ }
477
+ }
478
+ return false;
479
+ }
480
+ hide() {
481
+ this._delay(false, this.zHideDelay());
482
+ }
483
+ toggle() {
484
+ if (this._isVisible()) {
485
+ this.hide();
486
+ return;
487
+ }
488
+ this.show();
489
+ }
490
+ _createOverlay() {
491
+ const anchorElement = this.zTriggerElement() || this._elementRef;
492
+ const positionStrategy = this._overlayPositionBuilder
493
+ .flexibleConnectedTo(anchorElement)
494
+ .withPositions(getTooltipFallbackPositions(this.zPosition(), this.zOffset()))
495
+ .withFlexibleDimensions(false)
496
+ .withPush(true);
497
+ return this._overlay.create({
498
+ positionStrategy,
499
+ scrollStrategy: this._overlay.scrollStrategies.reposition(),
500
+ });
501
+ }
502
+ _disposeOverlay() {
503
+ this._positionSubscription?.unsubscribe();
504
+ this._positionSubscription = null;
505
+ this._overlayRef?.dispose();
506
+ this._overlayRef = null;
507
+ this._componentRef = null;
508
+ }
509
+ _setupDelayMechanism() {
510
+ this._delaySubject
511
+ .pipe(switchMap(config => (config.delay <= 0 ? of(config) : timer(config.delay).pipe(map(() => config)))), takeUntilDestroyed(this._destroyRef))
512
+ .subscribe(config => {
513
+ if (config.show) {
514
+ this._showTooltip();
515
+ return;
516
+ }
517
+ this._hideTooltip();
518
+ });
519
+ }
520
+ _setupTriggers() {
521
+ this._cleanupListeners();
522
+ const trigger = this.zTrigger();
523
+ const triggerEl = this.zTriggerElement() || this._elementRef.nativeElement;
524
+ if (trigger === 'hover') {
525
+ this._listenerCleanups.push(this._renderer.listen(triggerEl, 'mouseenter', () => this.show()), this._renderer.listen(triggerEl, 'mouseleave', () => this.hide()), this._renderer.listen(triggerEl, 'focus', () => this.show()), this._renderer.listen(triggerEl, 'blur', () => this.hide()));
526
+ return;
527
+ }
528
+ if (trigger === 'click') {
529
+ this._listenerCleanups.push(this._renderer.listen(triggerEl, 'click', () => {
530
+ if (this._isVisible()) {
531
+ this._delay(false, 0);
532
+ return;
533
+ }
534
+ this._delay(true, this.zShowDelay());
535
+ }));
536
+ }
537
+ this._listenerCleanups.push(this._renderer.listen(this._document.defaultView, 'scroll', () => this._delay(false, 0), {
538
+ passive: true,
539
+ capture: true,
540
+ }));
541
+ }
542
+ _setupOutsideClick() {
543
+ if (!this._overlayRef) {
544
+ return;
545
+ }
546
+ this._overlayRef
547
+ .outsidePointerEvents()
548
+ .pipe(filter(() => this.zTrigger() === 'click'), filter(event => !this._elementRef.nativeElement.contains(event.target)), takeUntilDestroyed(this._destroyRef))
549
+ .subscribe(() => this._delay(false, 0));
550
+ }
551
+ _delay(show, delay) {
552
+ this._delaySubject.next({ show, delay });
553
+ }
554
+ _showTooltip() {
555
+ const content = this.zContent();
556
+ if (!content || this._componentRef) {
557
+ return;
558
+ }
559
+ if (!this._overlayRef) {
560
+ this._overlayRef = this._createOverlay();
561
+ this._setupOutsideClick();
562
+ }
563
+ const anchorElement = this.zTriggerElement() || this._elementRef;
564
+ const positionStrategy = this._overlayPositionBuilder
565
+ .flexibleConnectedTo(anchorElement)
566
+ .withPositions(getTooltipFallbackPositions(this.zPosition(), this.zOffset()))
567
+ .withFlexibleDimensions(false)
568
+ .withPush(true);
569
+ this._overlayRef.updatePositionStrategy(positionStrategy);
570
+ const portal = new ComponentPortal(ZTooltipContentComponent);
571
+ this._componentRef = this._overlayRef.attach(portal);
572
+ this._componentRef.instance.setProps({
573
+ content,
574
+ position: this.zPosition(),
575
+ type: this.zType(),
576
+ size: this.zSize(),
577
+ customClass: this.zClass(),
578
+ arrow: this.zArrow(),
579
+ maxWidth: this.zMaxWidth(),
580
+ });
581
+ this._positionSubscription = positionStrategy.positionChanges.subscribe(change => {
582
+ const actualPosition = getActualPosition(change);
583
+ this._componentRef?.instance.position.set(actualPosition);
584
+ this._calculateArrowOffset(actualPosition);
585
+ });
586
+ if (this.zTrigger() === 'hover') {
587
+ this._setupTooltipHover();
588
+ }
589
+ this._isVisible.set(true);
590
+ this.zShow.emit();
591
+ }
592
+ _setupTooltipHover() {
593
+ const overlayElement = this._overlayRef?.overlayElement;
594
+ if (!overlayElement) {
595
+ return;
596
+ }
597
+ this._listenerCleanups.push(this._renderer.listen(overlayElement, 'mouseenter', () => {
598
+ this._delay(true, 0);
599
+ }), this._renderer.listen(overlayElement, 'mouseleave', () => {
600
+ this._delay(false, this.zHideDelay());
601
+ }));
602
+ }
603
+ _hideTooltip() {
604
+ if (!this._componentRef) {
605
+ return;
606
+ }
607
+ this._componentRef.instance.state.set('closed');
608
+ setTimeout(() => {
609
+ this._disposeOverlay();
610
+ this._isVisible.set(false);
611
+ this.zHide.emit();
612
+ }, Z_TOOLTIP_ANIMATION_DURATION);
613
+ }
614
+ _cleanupListeners() {
615
+ this._listenerCleanups.forEach(cleanup => cleanup());
616
+ this._listenerCleanups = [];
617
+ }
618
+ _calculateArrowOffset(position) {
619
+ if (!this._overlayRef || !this._componentRef) {
620
+ return;
621
+ }
622
+ const triggerRect = this._elementRef.nativeElement.getBoundingClientRect();
623
+ const tooltipRect = this._overlayRef.overlayElement.getBoundingClientRect();
624
+ let offset = 0;
625
+ if (position === 'top' || position === 'bottom') {
626
+ const triggerCenterX = triggerRect.left + triggerRect.width / 2;
627
+ const tooltipCenterX = tooltipRect.left + tooltipRect.width / 2;
628
+ offset = triggerCenterX - tooltipCenterX;
629
+ }
630
+ if (position === 'left' || position === 'right') {
631
+ const triggerCenterY = triggerRect.top + triggerRect.height / 2;
632
+ const tooltipCenterY = tooltipRect.top + tooltipRect.height / 2;
633
+ offset = triggerCenterY - tooltipCenterY;
634
+ }
635
+ const maxOffset = position === 'top' || position === 'bottom' ? tooltipRect.width / 2 - 12 : tooltipRect.height / 2 - 12;
636
+ offset = Math.max(-maxOffset, Math.min(maxOffset, offset));
637
+ if (Math.abs(offset) > 1) {
638
+ this._componentRef.instance.arrowOffset.set(offset);
639
+ return;
640
+ }
641
+ this._componentRef.instance.arrowOffset.set(0);
642
+ }
643
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
644
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.6", type: ZTooltipDirective, isStandalone: true, selector: "[z-tooltip], [zTooltip]", inputs: { zContent: { classPropertyName: "zContent", publicName: "zContent", isSignal: true, isRequired: false, transformFunction: null }, zPosition: { classPropertyName: "zPosition", publicName: "zPosition", isSignal: true, isRequired: false, transformFunction: null }, zTrigger: { classPropertyName: "zTrigger", publicName: "zTrigger", isSignal: true, isRequired: false, transformFunction: null }, zType: { classPropertyName: "zType", publicName: "zTooltipType", isSignal: true, isRequired: false, transformFunction: null }, zSize: { classPropertyName: "zSize", publicName: "zTooltipSize", isSignal: true, isRequired: false, transformFunction: null }, zClass: { classPropertyName: "zClass", publicName: "zClass", isSignal: true, isRequired: false, transformFunction: null }, zShowDelay: { classPropertyName: "zShowDelay", publicName: "zShowDelay", isSignal: true, isRequired: false, transformFunction: null }, zHideDelay: { classPropertyName: "zHideDelay", publicName: "zHideDelay", isSignal: true, isRequired: false, transformFunction: null }, zArrow: { classPropertyName: "zArrow", publicName: "zArrow", isSignal: true, isRequired: false, transformFunction: null }, zDisabled: { classPropertyName: "zDisabled", publicName: "zDisabled", isSignal: true, isRequired: false, transformFunction: null }, zOffset: { classPropertyName: "zOffset", publicName: "zOffset", isSignal: true, isRequired: false, transformFunction: null }, zAutoDetect: { classPropertyName: "zAutoDetect", publicName: "zAutoDetect", isSignal: true, isRequired: false, transformFunction: null }, zTriggerElement: { classPropertyName: "zTriggerElement", publicName: "zTriggerElement", isSignal: true, isRequired: false, transformFunction: null }, zAlwaysShow: { classPropertyName: "zAlwaysShow", publicName: "zAlwaysShow", isSignal: true, isRequired: false, transformFunction: null }, zMaxWidth: { classPropertyName: "zMaxWidth", publicName: "zMaxWidth", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { zShow: "zShow", zHide: "zHide" }, exportAs: ["zTooltip"], ngImport: i0 });
645
+ }
646
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZTooltipDirective, decorators: [{
647
+ type: Directive,
648
+ args: [{
649
+ selector: '[z-tooltip], [zTooltip]',
650
+ standalone: true,
651
+ exportAs: 'zTooltip',
652
+ }]
653
+ }], propDecorators: { zContent: [{ type: i0.Input, args: [{ isSignal: true, alias: "zContent", required: false }] }], zPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPosition", required: false }] }], zTrigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTrigger", required: false }] }], zType: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTooltipType", required: false }] }], zSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTooltipSize", required: false }] }], zClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "zClass", required: false }] }], zShowDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShowDelay", required: false }] }], zHideDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "zHideDelay", required: false }] }], zArrow: [{ type: i0.Input, args: [{ isSignal: true, alias: "zArrow", required: false }] }], zDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDisabled", required: false }] }], zOffset: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOffset", required: false }] }], zAutoDetect: [{ type: i0.Input, args: [{ isSignal: true, alias: "zAutoDetect", required: false }] }], zTriggerElement: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTriggerElement", required: false }] }], zAlwaysShow: [{ type: i0.Input, args: [{ isSignal: true, alias: "zAlwaysShow", required: false }] }], zMaxWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "zMaxWidth", required: false }] }], zShow: [{ type: i0.Output, args: ["zShow"] }], zHide: [{ type: i0.Output, args: ["zHide"] }] } });
654
+
655
+ /**
656
+ * Generated bundle index. Do not edit.
657
+ */
658
+
659
+ export { ZTooltipDirective, zTooltipVariants };
660
+ //# sourceMappingURL=shival99-z-ui-components-z-tooltip.mjs.map