tailjng 0.0.55 → 0.0.57

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 (24) hide show
  1. package/cli/settings/components-list.js +8 -0
  2. package/cli/settings/header-generator.js +1 -1
  3. package/fesm2022/tailjng.mjs.map +1 -1
  4. package/lib/interfaces/crud/crud.interface.d.ts +5 -2
  5. package/lib/interfaces/crud/filter.interface.d.ts +4 -0
  6. package/package.json +1 -1
  7. package/src/lib/components/card/card-complete/complete-card.component.html +104 -0
  8. package/src/lib/components/card/card-complete/complete-card.component.scss +35 -0
  9. package/src/lib/components/card/card-complete/complete-card.component.ts +652 -0
  10. package/src/lib/components/coach-mark/coach-mark.component.html +36 -0
  11. package/src/lib/components/coach-mark/coach-mark.component.scss +20 -0
  12. package/src/lib/components/coach-mark/coach-mark.component.ts +45 -0
  13. package/src/lib/components/coach-mark/coach-mark.directive.ts +256 -0
  14. package/src/lib/components/filter/filter-complete/complete-filter.component.html +194 -178
  15. package/src/lib/components/filter/filter-complete/complete-filter.component.ts +11 -1
  16. package/src/lib/components/form/form-validation/validation-form.component.html +1 -1
  17. package/src/lib/components/input/input/input.component.html +1 -1
  18. package/src/lib/components/input/input-file/file-input.component.html +3 -3
  19. package/src/lib/components/input/input-textarea/textarea-input.component.html +23 -19
  20. package/src/lib/components/select/select-dropdown/dropdown-select.component.html +5 -4
  21. package/src/lib/components/select/select-dropdown/dropdown-select.component.ts +3 -0
  22. package/src/lib/components/select/select-multi-dropdown/multi-dropdown-select.component.html +2 -1
  23. package/src/lib/components/table/table-crud-complete/complete-crud-table.component.html +3 -1
  24. package/src/lib/components/table/table-crud-complete/complete-crud-table.component.ts +7 -1
@@ -0,0 +1,45 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { Component, Input, TemplateRef } from '@angular/core';
3
+
4
+ type CoachPosition =
5
+ | 'top'
6
+ | 'top-left'
7
+ | 'top-right'
8
+ | 'bottom'
9
+ | 'bottom-left'
10
+ | 'bottom-right'
11
+ | 'left'
12
+ | 'left-top'
13
+ | 'left-bottom'
14
+ | 'right'
15
+ | 'right-top'
16
+ | 'right-bottom';
17
+
18
+ @Component({
19
+ selector: 'JCoachMarkOverlay',
20
+ imports: [CommonModule],
21
+ templateUrl: './coach-mark.component.html',
22
+ styleUrl: './coach-mark.component.scss'
23
+ })
24
+ export class JCoachMarkComponent {
25
+ @Input() title = '';
26
+ @Input() description = '';
27
+ @Input() contentTemplate?: TemplateRef<unknown>;
28
+
29
+ @Input() spotlight = true;
30
+
31
+ @Input() cardTop = 0;
32
+ @Input() cardLeft = 0;
33
+
34
+ @Input() targetTop = 0;
35
+ @Input() targetLeft = 0;
36
+ @Input() targetWidth = 0;
37
+ @Input() targetHeight = 0;
38
+ @Input() targetRadius = '12px';
39
+
40
+ @Input() position: CoachPosition = 'bottom';
41
+
42
+ @Input() width = '300px';
43
+ @Input() maxWidth = '340px';
44
+ @Input() zIndex = 99999;
45
+ }
@@ -0,0 +1,256 @@
1
+ import {
2
+ ApplicationRef,
3
+ ComponentRef,
4
+ Directive,
5
+ ElementRef,
6
+ EnvironmentInjector,
7
+ HostListener,
8
+ Input,
9
+ OnDestroy,
10
+ TemplateRef,
11
+ createComponent
12
+ } from '@angular/core';
13
+
14
+ import { JCoachMarkComponent } from './coach-mark.component';
15
+
16
+ type CoachTrigger = 'hover' | 'click';
17
+ type CoachPosition =
18
+ | 'top'
19
+ | 'top-left'
20
+ | 'top-right'
21
+ | 'bottom'
22
+ | 'bottom-left'
23
+ | 'bottom-right'
24
+ | 'left'
25
+ | 'left-top'
26
+ | 'left-bottom'
27
+ | 'right'
28
+ | 'right-top'
29
+ | 'right-bottom';
30
+
31
+ @Directive({
32
+ selector: '[jCoachMark]',
33
+ standalone: true
34
+ })
35
+ export class JCoachMarkDirective implements OnDestroy {
36
+ @Input() coachTitle = '';
37
+ @Input() coachDescription = '';
38
+ @Input() coachContent?: TemplateRef<unknown>;
39
+
40
+ @Input() coachTrigger: CoachTrigger = 'click';
41
+ @Input() coachPosition: CoachPosition = 'bottom';
42
+
43
+ @Input() coachSpotlight = true;
44
+ @Input() coachDisabled = false;
45
+
46
+ @Input() coachWidth = '300px';
47
+ @Input() coachMaxWidth = '340px';
48
+ @Input() coachOffset = 12;
49
+ @Input() coachRadius = '12px';
50
+
51
+ private overlayRef?: ComponentRef<JCoachMarkComponent>;
52
+ private isOpen = false;
53
+
54
+ private scrollHandler = () => this.updatePosition();
55
+ private resizeHandler = () => this.updatePosition();
56
+
57
+ constructor(
58
+ private elementRef: ElementRef<HTMLElement>,
59
+ private appRef: ApplicationRef,
60
+ private injector: EnvironmentInjector
61
+ ) { }
62
+
63
+ @HostListener('mouseenter')
64
+ onMouseEnter() {
65
+ if (this.coachTrigger === 'hover') this.open();
66
+ }
67
+
68
+ @HostListener('mouseleave')
69
+ onMouseLeave() {
70
+ if (this.coachTrigger === 'hover') this.close();
71
+ }
72
+
73
+ @HostListener('click', ['$event'])
74
+ onClick(event: MouseEvent) {
75
+ if (this.coachTrigger !== 'click') return;
76
+
77
+ event.stopPropagation();
78
+
79
+ this.isOpen ? this.close() : this.open();
80
+
81
+ setTimeout(() => {
82
+ document.addEventListener('click', this.documentClickHandler);
83
+ });
84
+ }
85
+
86
+ private documentClickHandler = (event: MouseEvent) => {
87
+ const host = this.elementRef.nativeElement;
88
+
89
+ if (!host.contains(event.target as Node)) {
90
+ this.close();
91
+ }
92
+ };
93
+
94
+ private open() {
95
+ if (this.coachDisabled) return;
96
+ if (this.overlayRef) return;
97
+
98
+ this.overlayRef = createComponent(JCoachMarkComponent, {
99
+ environmentInjector: this.injector
100
+ });
101
+
102
+ this.overlayRef.instance.title = this.coachTitle;
103
+ this.overlayRef.instance.description = this.coachDescription;
104
+ this.overlayRef.instance.contentTemplate = this.coachContent;
105
+
106
+ this.overlayRef.instance.spotlight = this.coachSpotlight;
107
+ this.overlayRef.instance.position = this.coachPosition;
108
+
109
+ this.overlayRef.instance.width = this.coachWidth;
110
+ this.overlayRef.instance.maxWidth = this.coachMaxWidth;
111
+ this.overlayRef.instance.targetRadius = this.coachRadius;
112
+
113
+ this.appRef.attachView(this.overlayRef.hostView);
114
+
115
+ document.body.appendChild(
116
+ this.overlayRef.location.nativeElement
117
+ );
118
+
119
+ this.isOpen = true;
120
+
121
+ requestAnimationFrame(() => this.updatePosition());
122
+
123
+ window.addEventListener('scroll', this.scrollHandler, true);
124
+ window.addEventListener('resize', this.resizeHandler);
125
+ }
126
+
127
+ private updatePosition() {
128
+ if (!this.overlayRef) return;
129
+
130
+ const host = this.elementRef.nativeElement;
131
+ const rect = host.getBoundingClientRect();
132
+
133
+ const cardElement = this.overlayRef.location.nativeElement
134
+ .querySelector('.j-coach-card') as HTMLElement;
135
+
136
+ if (!cardElement) return;
137
+
138
+ const cardRect = cardElement.getBoundingClientRect();
139
+
140
+ let cardTop = 0;
141
+ let cardLeft = 0;
142
+
143
+ const position = this.coachPosition;
144
+
145
+ const alignCenterX = rect.left + rect.width / 2 - cardRect.width / 2;
146
+ const alignLeft = rect.left;
147
+ const alignRight = rect.right - cardRect.width;
148
+
149
+ const alignCenterY = rect.top + rect.height / 2 - cardRect.height / 2;
150
+ const alignTop = rect.top;
151
+ const alignBottom = rect.bottom - cardRect.height;
152
+
153
+ switch (position) {
154
+ case 'top':
155
+ cardTop = rect.top - cardRect.height - this.coachOffset;
156
+ cardLeft = alignCenterX;
157
+ break;
158
+
159
+ case 'top-left':
160
+ cardTop = rect.top - cardRect.height - this.coachOffset;
161
+ cardLeft = alignLeft;
162
+ break;
163
+
164
+ case 'top-right':
165
+ cardTop = rect.top - cardRect.height - this.coachOffset;
166
+ cardLeft = alignRight;
167
+ break;
168
+
169
+ case 'bottom':
170
+ cardTop = rect.bottom + this.coachOffset;
171
+ cardLeft = alignCenterX;
172
+ break;
173
+
174
+ case 'bottom-left':
175
+ cardTop = rect.bottom + this.coachOffset;
176
+ cardLeft = alignLeft;
177
+ break;
178
+
179
+ case 'bottom-right':
180
+ cardTop = rect.bottom + this.coachOffset;
181
+ cardLeft = alignRight;
182
+ break;
183
+
184
+ case 'left':
185
+ cardTop = alignCenterY;
186
+ cardLeft = rect.left - cardRect.width - this.coachOffset;
187
+ break;
188
+
189
+ case 'left-top':
190
+ cardTop = alignTop;
191
+ cardLeft = rect.left - cardRect.width - this.coachOffset;
192
+ break;
193
+
194
+ case 'left-bottom':
195
+ cardTop = alignBottom;
196
+ cardLeft = rect.left - cardRect.width - this.coachOffset;
197
+ break;
198
+
199
+ case 'right':
200
+ cardTop = alignCenterY;
201
+ cardLeft = rect.right + this.coachOffset;
202
+ break;
203
+
204
+ case 'right-top':
205
+ cardTop = alignTop;
206
+ cardLeft = rect.right + this.coachOffset;
207
+ break;
208
+
209
+ case 'right-bottom':
210
+ cardTop = alignBottom;
211
+ cardLeft = rect.right + this.coachOffset;
212
+ break;
213
+ }
214
+
215
+ const margin = 10;
216
+
217
+ cardLeft = Math.max(margin, cardLeft);
218
+ cardTop = Math.max(margin, cardTop);
219
+
220
+ if (cardLeft + cardRect.width > window.innerWidth - margin) {
221
+ cardLeft = window.innerWidth - cardRect.width - margin;
222
+ }
223
+
224
+ if (cardTop + cardRect.height > window.innerHeight - margin) {
225
+ cardTop = window.innerHeight - cardRect.height - margin;
226
+ }
227
+
228
+ this.overlayRef.instance.targetTop = rect.top;
229
+ this.overlayRef.instance.targetLeft = rect.left;
230
+ this.overlayRef.instance.targetWidth = rect.width;
231
+ this.overlayRef.instance.targetHeight = rect.height;
232
+
233
+ this.overlayRef.instance.cardTop = cardTop;
234
+ this.overlayRef.instance.cardLeft = cardLeft;
235
+
236
+ this.overlayRef.changeDetectorRef.detectChanges();
237
+ }
238
+
239
+ private close() {
240
+ this.isOpen = false;
241
+
242
+ document.removeEventListener('click', this.documentClickHandler);
243
+ window.removeEventListener('scroll', this.scrollHandler, true);
244
+ window.removeEventListener('resize', this.resizeHandler);
245
+
246
+ if (!this.overlayRef) return;
247
+
248
+ this.appRef.detachView(this.overlayRef.hostView);
249
+ this.overlayRef.destroy();
250
+ this.overlayRef = undefined;
251
+ }
252
+
253
+ ngOnDestroy() {
254
+ this.close();
255
+ }
256
+ }