ngx-semantic 2.0.7-beta.1 → 2.0.7-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,721 @@
1
+ import { style, animate, keyframes, AnimationBuilder } from '@angular/animations';
2
+ import { __decorate } from 'tslib';
3
+ import * as i0 from '@angular/core';
4
+ import { inject, ElementRef, Renderer2, NgZone, ChangeDetectorRef, EventEmitter, Output, Input, ChangeDetectionStrategy, ViewEncapsulation, Component, NgModule } from '@angular/core';
5
+ import { ClassUtils, InputBoolean } from 'ngx-semantic/core/util';
6
+
7
+ /**
8
+ * Helpers for Semantic UI–style transition names and durations.
9
+ * @see https://semantic-ui.com/modules/transition.html
10
+ */
11
+ function durationToCss(d) {
12
+ if (typeof d === 'number') {
13
+ return Number.isFinite(d) ? `${d}ms` : '500ms';
14
+ }
15
+ const s = String(d).trim();
16
+ if (!s) {
17
+ return '500ms';
18
+ }
19
+ if (/^\d+(\.\d+)?(ms|s)$/i.test(s)) {
20
+ return s;
21
+ }
22
+ if (/^\d+(\.\d+)?$/.test(s)) {
23
+ return `${s}ms`;
24
+ }
25
+ return s;
26
+ }
27
+ function parseTransitionName(raw) {
28
+ const s = raw.trim().toLowerCase().replace(/\s+/g, ' ');
29
+ let explicitDirection = null;
30
+ let base = s;
31
+ if (base.endsWith(' in')) {
32
+ explicitDirection = 'in';
33
+ base = base.slice(0, -3).trim();
34
+ }
35
+ else if (base.endsWith(' out')) {
36
+ explicitDirection = 'out';
37
+ base = base.slice(0, -4).trim();
38
+ }
39
+ return { baseName: base, explicitDirection };
40
+ }
41
+ /**
42
+ * Resolves whether the next run should play an inward or outward transition.
43
+ */
44
+ function resolveTransitionDirection(explicitFromName, mode, targetVisible) {
45
+ if (explicitFromName === 'in' || explicitFromName === 'out') {
46
+ return explicitFromName;
47
+ }
48
+ if (mode === 'in') {
49
+ return 'in';
50
+ }
51
+ if (mode === 'out') {
52
+ return 'out';
53
+ }
54
+ return targetVisible ? 'in' : 'out';
55
+ }
56
+ const STATIC_NAMES = new Set([
57
+ 'jiggle',
58
+ 'flash',
59
+ 'shake',
60
+ 'pulse',
61
+ 'tada',
62
+ 'bounce',
63
+ 'glow'
64
+ ]);
65
+ function isStaticTransitionName(baseName) {
66
+ return STATIC_NAMES.has(baseName);
67
+ }
68
+
69
+ /**
70
+ * Angular animation metadata approximating Semantic UI transition behaviors.
71
+ * @see https://semantic-ui.com/modules/transition.html
72
+ */
73
+ const EASE = 'cubic-bezier(0.4, 0, 0.2, 1)';
74
+ const MOTIONS = {
75
+ scale: {
76
+ enter: d => [
77
+ style({ opacity: 0, transform: 'scale(0)', offset: 0 }),
78
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'scale(1)' }))
79
+ ],
80
+ leave: d => [
81
+ style({ opacity: 1, transform: 'scale(1)', offset: 0 }),
82
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'scale(0)' }))
83
+ ]
84
+ },
85
+ zoom: {
86
+ enter: d => [
87
+ style({ opacity: 0, transform: 'scale(0.35)', offset: 0 }),
88
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'scale(1)' }))
89
+ ],
90
+ leave: d => [
91
+ style({ opacity: 1, transform: 'scale(1)', offset: 0 }),
92
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'scale(0.35)' }))
93
+ ]
94
+ },
95
+ fade: {
96
+ enter: d => [
97
+ style({ opacity: 0, offset: 0 }),
98
+ animate(`${d} ${EASE}`, style({ opacity: 1 }))
99
+ ],
100
+ leave: d => [
101
+ style({ opacity: 1, offset: 0 }),
102
+ animate(`${d} ${EASE}`, style({ opacity: 0 }))
103
+ ]
104
+ },
105
+ 'fade up': {
106
+ enter: d => [
107
+ style({ opacity: 0, transform: 'translateY(0.75rem)', offset: 0 }),
108
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
109
+ ],
110
+ leave: d => [
111
+ style({ opacity: 1, transform: 'none', offset: 0 }),
112
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateY(0.75rem)' }))
113
+ ]
114
+ },
115
+ 'fade down': {
116
+ enter: d => [
117
+ style({ opacity: 0, transform: 'translateY(-0.75rem)', offset: 0 }),
118
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
119
+ ],
120
+ leave: d => [
121
+ style({ opacity: 1, transform: 'none', offset: 0 }),
122
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateY(-0.75rem)' }))
123
+ ]
124
+ },
125
+ 'fade left': {
126
+ enter: d => [
127
+ style({ opacity: 0, transform: 'translateX(0.75rem)', offset: 0 }),
128
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
129
+ ],
130
+ leave: d => [
131
+ style({ opacity: 1, transform: 'none', offset: 0 }),
132
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateX(0.75rem)' }))
133
+ ]
134
+ },
135
+ 'fade right': {
136
+ enter: d => [
137
+ style({ opacity: 0, transform: 'translateX(-0.75rem)', offset: 0 }),
138
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
139
+ ],
140
+ leave: d => [
141
+ style({ opacity: 1, transform: 'none', offset: 0 }),
142
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateX(-0.75rem)' }))
143
+ ]
144
+ },
145
+ 'horizontal flip': {
146
+ enter: d => [
147
+ style({
148
+ opacity: 0,
149
+ transform: 'perspective(600px) rotateY(-90deg)',
150
+ offset: 0
151
+ }),
152
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'perspective(600px) rotateY(0deg)' }))
153
+ ],
154
+ leave: d => [
155
+ style({
156
+ opacity: 1,
157
+ transform: 'perspective(600px) rotateY(0deg)',
158
+ offset: 0
159
+ }),
160
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'perspective(600px) rotateY(90deg)' }))
161
+ ]
162
+ },
163
+ 'vertical flip': {
164
+ enter: d => [
165
+ style({
166
+ opacity: 0,
167
+ transform: 'perspective(600px) rotateX(-90deg)',
168
+ offset: 0
169
+ }),
170
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'perspective(600px) rotateX(0deg)' }))
171
+ ],
172
+ leave: d => [
173
+ style({
174
+ opacity: 1,
175
+ transform: 'perspective(600px) rotateX(0deg)',
176
+ offset: 0
177
+ }),
178
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'perspective(600px) rotateX(90deg)' }))
179
+ ]
180
+ },
181
+ drop: {
182
+ enter: d => [
183
+ style({ opacity: 0, transform: 'translateY(-120%)', offset: 0 }),
184
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
185
+ ],
186
+ leave: d => [
187
+ style({ opacity: 1, transform: 'none', offset: 0 }),
188
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateY(-120%)' }))
189
+ ]
190
+ },
191
+ 'fly left': {
192
+ enter: d => [
193
+ style({ opacity: 0, transform: 'translateX(120%)', offset: 0 }),
194
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
195
+ ],
196
+ leave: d => [
197
+ style({ opacity: 1, transform: 'none', offset: 0 }),
198
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateX(-120%)' }))
199
+ ]
200
+ },
201
+ 'fly right': {
202
+ enter: d => [
203
+ style({ opacity: 0, transform: 'translateX(-120%)', offset: 0 }),
204
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
205
+ ],
206
+ leave: d => [
207
+ style({ opacity: 1, transform: 'none', offset: 0 }),
208
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateX(120%)' }))
209
+ ]
210
+ },
211
+ 'fly up': {
212
+ enter: d => [
213
+ style({ opacity: 0, transform: 'translateY(120%)', offset: 0 }),
214
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
215
+ ],
216
+ leave: d => [
217
+ style({ opacity: 1, transform: 'none', offset: 0 }),
218
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateY(-120%)' }))
219
+ ]
220
+ },
221
+ 'fly down': {
222
+ enter: d => [
223
+ style({ opacity: 0, transform: 'translateY(-120%)', offset: 0 }),
224
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
225
+ ],
226
+ leave: d => [
227
+ style({ opacity: 1, transform: 'none', offset: 0 }),
228
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateY(120%)' }))
229
+ ]
230
+ },
231
+ 'swing left': {
232
+ enter: d => [
233
+ style({ opacity: 0, transform: 'rotate(-12deg)', transformOrigin: 'top center', offset: 0 }),
234
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
235
+ ],
236
+ leave: d => [
237
+ style({ opacity: 1, transform: 'none', offset: 0 }),
238
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'rotate(12deg)', transformOrigin: 'top center' }))
239
+ ]
240
+ },
241
+ 'swing right': {
242
+ enter: d => [
243
+ style({ opacity: 0, transform: 'rotate(12deg)', transformOrigin: 'top center', offset: 0 }),
244
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
245
+ ],
246
+ leave: d => [
247
+ style({ opacity: 1, transform: 'none', offset: 0 }),
248
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'rotate(-12deg)', transformOrigin: 'top center' }))
249
+ ]
250
+ },
251
+ 'swing up': {
252
+ enter: d => [
253
+ style({ opacity: 0, transform: 'rotate(-10deg)', transformOrigin: 'bottom center', offset: 0 }),
254
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
255
+ ],
256
+ leave: d => [
257
+ style({ opacity: 1, transform: 'none', offset: 0 }),
258
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'rotate(10deg)', transformOrigin: 'bottom center' }))
259
+ ]
260
+ },
261
+ 'swing down': {
262
+ enter: d => [
263
+ style({ opacity: 0, transform: 'rotate(10deg)', transformOrigin: 'top center', offset: 0 }),
264
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
265
+ ],
266
+ leave: d => [
267
+ style({ opacity: 1, transform: 'none', offset: 0 }),
268
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'rotate(-10deg)', transformOrigin: 'top center' }))
269
+ ]
270
+ },
271
+ browse: {
272
+ enter: d => [
273
+ style({ opacity: 0, transform: 'translateX(-1rem) skewX(-6deg)', offset: 0 }),
274
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
275
+ ],
276
+ leave: d => [
277
+ style({ opacity: 1, transform: 'none', offset: 0 }),
278
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateX(1rem) skewX(6deg)' }))
279
+ ]
280
+ },
281
+ 'browse right': {
282
+ enter: d => [
283
+ style({ opacity: 0, transform: 'translateX(1rem) skewX(6deg)', offset: 0 }),
284
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
285
+ ],
286
+ leave: d => [
287
+ style({ opacity: 1, transform: 'none', offset: 0 }),
288
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateX(-1rem) skewX(-6deg)' }))
289
+ ]
290
+ },
291
+ 'slide down': {
292
+ enter: d => [
293
+ style({ opacity: 0, transform: 'translateY(-100%)', offset: 0 }),
294
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
295
+ ],
296
+ leave: d => [
297
+ style({ opacity: 1, transform: 'none', offset: 0 }),
298
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateY(-100%)' }))
299
+ ]
300
+ },
301
+ 'slide up': {
302
+ enter: d => [
303
+ style({ opacity: 0, transform: 'translateY(100%)', offset: 0 }),
304
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
305
+ ],
306
+ leave: d => [
307
+ style({ opacity: 1, transform: 'none', offset: 0 }),
308
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateY(100%)' }))
309
+ ]
310
+ },
311
+ 'slide left': {
312
+ enter: d => [
313
+ style({ opacity: 0, transform: 'translateX(100%)', offset: 0 }),
314
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
315
+ ],
316
+ leave: d => [
317
+ style({ opacity: 1, transform: 'none', offset: 0 }),
318
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateX(-100%)' }))
319
+ ]
320
+ },
321
+ 'slide right': {
322
+ enter: d => [
323
+ style({ opacity: 0, transform: 'translateX(-100%)', offset: 0 }),
324
+ animate(`${d} ${EASE}`, style({ opacity: 1, transform: 'none' }))
325
+ ],
326
+ leave: d => [
327
+ style({ opacity: 1, transform: 'none', offset: 0 }),
328
+ animate(`${d} ${EASE}`, style({ opacity: 0, transform: 'translateX(100%)' }))
329
+ ]
330
+ }
331
+ };
332
+ const DEFAULT_MOTION = MOTIONS.fade;
333
+ function getMotionForVisibility(baseName) {
334
+ if (isStaticTransitionName(baseName)) {
335
+ return DEFAULT_MOTION;
336
+ }
337
+ return MOTIONS[baseName] ?? DEFAULT_MOTION;
338
+ }
339
+ function buildEnterSteps(baseName, durationCss) {
340
+ return getMotionForVisibility(baseName).enter(durationCss);
341
+ }
342
+ function buildLeaveSteps(baseName, durationCss) {
343
+ return getMotionForVisibility(baseName).leave(durationCss);
344
+ }
345
+ function buildStaticSteps(baseName, durationCss) {
346
+ if (!isStaticTransitionName(baseName)) {
347
+ return null;
348
+ }
349
+ switch (baseName) {
350
+ case 'pulse':
351
+ return [
352
+ style({ transform: 'scale(1)', offset: 0 }),
353
+ animate(`${durationCss} ${EASE}`, keyframes([
354
+ style({ transform: 'scale(1)', offset: 0 }),
355
+ style({ transform: 'scale(1.06)', offset: 0.5 }),
356
+ style({ transform: 'scale(1)', offset: 1 })
357
+ ]))
358
+ ];
359
+ case 'shake':
360
+ return [
361
+ animate(`${durationCss} ${EASE}`, keyframes([
362
+ style({ transform: 'translateX(0)', offset: 0 }),
363
+ style({ transform: 'translateX(-0.5rem)', offset: 0.2 }),
364
+ style({ transform: 'translateX(0.5rem)', offset: 0.4 }),
365
+ style({ transform: 'translateX(-0.35rem)', offset: 0.6 }),
366
+ style({ transform: 'translateX(0.35rem)', offset: 0.8 }),
367
+ style({ transform: 'translateX(0)', offset: 1 })
368
+ ]))
369
+ ];
370
+ case 'jiggle':
371
+ return [
372
+ animate(`${durationCss} ${EASE}`, keyframes([
373
+ style({ transform: 'rotate(0deg)', offset: 0 }),
374
+ style({ transform: 'rotate(-2.5deg)', offset: 0.25 }),
375
+ style({ transform: 'rotate(2.5deg)', offset: 0.5 }),
376
+ style({ transform: 'rotate(-1.5deg)', offset: 0.75 }),
377
+ style({ transform: 'rotate(0deg)', offset: 1 })
378
+ ]))
379
+ ];
380
+ case 'flash':
381
+ return [
382
+ animate(`${durationCss} linear`, keyframes([
383
+ style({ opacity: 1, offset: 0 }),
384
+ style({ opacity: 0.2, offset: 0.5 }),
385
+ style({ opacity: 1, offset: 1 })
386
+ ]))
387
+ ];
388
+ case 'tada':
389
+ return [
390
+ animate(`${durationCss} ${EASE}`, keyframes([
391
+ style({ transform: 'scale(1) rotate(0deg)', offset: 0 }),
392
+ style({ transform: 'scale(0.92) rotate(-2deg)', offset: 0.1 }),
393
+ style({ transform: 'scale(1.08) rotate(2deg)', offset: 0.3 }),
394
+ style({ transform: 'scale(1.02) rotate(-1deg)', offset: 0.5 }),
395
+ style({ transform: 'scale(1) rotate(0deg)', offset: 1 })
396
+ ]))
397
+ ];
398
+ case 'bounce':
399
+ return [
400
+ animate(`${durationCss} ${EASE}`, keyframes([
401
+ style({ transform: 'translateY(0)', offset: 0 }),
402
+ style({ transform: 'translateY(-0.6rem)', offset: 0.35 }),
403
+ style({ transform: 'translateY(0)', offset: 0.55 }),
404
+ style({ transform: 'translateY(-0.25rem)', offset: 0.7 }),
405
+ style({ transform: 'translateY(0)', offset: 0.85 }),
406
+ style({ transform: 'translateY(0)', offset: 1 })
407
+ ]))
408
+ ];
409
+ case 'glow':
410
+ return [
411
+ animate(`${durationCss} ${EASE}`, keyframes([
412
+ style({ boxShadow: '0 0 0 0 rgba(100, 180, 255, 0)', offset: 0 }),
413
+ style({ boxShadow: '0 0 1.25rem 0.25rem rgba(100, 180, 255, 0.45)', offset: 0.5 }),
414
+ style({ boxShadow: '0 0 0 0 rgba(100, 180, 255, 0)', offset: 1 })
415
+ ]))
416
+ ];
417
+ default:
418
+ return null;
419
+ }
420
+ }
421
+ function listRegisteredMotionKeys() {
422
+ return Object.keys(MOTIONS);
423
+ }
424
+
425
+ class SuiTransitionComponent {
426
+ constructor() {
427
+ this.builder = inject(AnimationBuilder);
428
+ this.el = inject((ElementRef));
429
+ this.renderer = inject(Renderer2);
430
+ this.zone = inject(NgZone);
431
+ this.cdr = inject(ChangeDetectorRef);
432
+ /** Semantic animation name, e.g. `fade up`, `horizontal flip`, `pulse`. Optional ` in` / ` out` suffix. */
433
+ this.suiAnimation = 'fade';
434
+ /** Duration in ms or CSS time string (e.g. `500`, `500ms`, `0.5s`). */
435
+ this.suiDuration = 500;
436
+ /** When not forced by the animation string, controls automatic in vs out (default mirrors Semantic `auto`). */
437
+ this.suiDirection = 'auto';
438
+ /** Whether the host is shown (after transitions complete). Two-way bindable. */
439
+ this.suiVisible = true;
440
+ /** Increment to replay the current **static** animation (`pulse`, `shake`, …). */
441
+ this.suiPlay = 0;
442
+ /** Disables animations; visibility updates apply immediately. */
443
+ this.suiDisabled = false;
444
+ this.suiVisibleChange = new EventEmitter();
445
+ /** Fires when a transition begins (visibility or static). */
446
+ this.suiAnimationStart = new EventEmitter();
447
+ /** Fires when a transition finishes. */
448
+ this.suiAnimationComplete = new EventEmitter();
449
+ /** After an inward transition that ends visible. */
450
+ this.suiOnShow = new EventEmitter();
451
+ /** After an outward transition that ends hidden. */
452
+ this.suiOnHide = new EventEmitter();
453
+ /** Mirrors Semantic UI state classes. */
454
+ this.animating = false;
455
+ /** Final hidden state (opacity/visibility), not necessarily DOM removal. */
456
+ this.hidden = false;
457
+ this.hostClassList = '';
458
+ this.player = null;
459
+ this.initialized = false;
460
+ this.lastVisible = true;
461
+ this.lastPlay = 0;
462
+ }
463
+ ngOnChanges(changes) {
464
+ if (changes['suiPlay']) {
465
+ if (changes['suiPlay'].firstChange) {
466
+ this.lastPlay = this.suiPlay;
467
+ }
468
+ else if (this.suiPlay !== this.lastPlay) {
469
+ this.lastPlay = this.suiPlay;
470
+ this.runStaticAnimation();
471
+ }
472
+ }
473
+ if (changes['suiVisible']) {
474
+ const cur = this.suiVisible;
475
+ if (!this.initialized) {
476
+ this.initialized = true;
477
+ this.lastVisible = cur;
478
+ this.applyImmediateVisibility(cur);
479
+ this.syncHostClasses();
480
+ return;
481
+ }
482
+ if (cur !== this.lastVisible) {
483
+ this.lastVisible = cur;
484
+ this.runVisibilityTransition(cur);
485
+ }
486
+ }
487
+ if (changes['suiAnimation'] ||
488
+ changes['suiDuration'] ||
489
+ changes['suiDirection'] ||
490
+ changes['suiDisabled']) {
491
+ this.syncHostClasses();
492
+ }
493
+ }
494
+ ngOnDestroy() {
495
+ this.destroyPlayer();
496
+ }
497
+ /** Show with the current animation settings. */
498
+ show() {
499
+ this.setVisible(true);
500
+ }
501
+ /** Hide with the current animation settings. */
502
+ hide() {
503
+ this.setVisible(false);
504
+ }
505
+ /** Toggle visibility. */
506
+ toggle() {
507
+ this.setVisible(!this.suiVisible);
508
+ }
509
+ /** Stop the active animation (Semantic `stop` / `stop all` style: clears current player). */
510
+ stop() {
511
+ this.destroyPlayer();
512
+ this.animating = false;
513
+ this.syncHostClasses();
514
+ this.cdr.markForCheck();
515
+ }
516
+ /** Run a static attention animation if `suiAnimation` is static; no-op otherwise. */
517
+ playStatic() {
518
+ this.runStaticAnimation();
519
+ }
520
+ setVisible(value) {
521
+ if (this.suiVisible === value) {
522
+ return;
523
+ }
524
+ this.suiVisible = value;
525
+ this.suiVisibleChange.emit(value);
526
+ if (!this.initialized) {
527
+ this.initialized = true;
528
+ this.lastVisible = value;
529
+ this.applyImmediateVisibility(value);
530
+ this.syncHostClasses();
531
+ this.cdr.markForCheck();
532
+ return;
533
+ }
534
+ this.lastVisible = value;
535
+ this.runVisibilityTransition(value);
536
+ this.cdr.markForCheck();
537
+ }
538
+ runVisibilityTransition(targetVisible) {
539
+ if (this.suiDisabled) {
540
+ this.suiAnimationStart.emit();
541
+ this.applyImmediateVisibility(targetVisible);
542
+ this.emitVisibilityCallbacks(targetVisible);
543
+ this.cdr.markForCheck();
544
+ return;
545
+ }
546
+ const { baseName, explicitDirection } = parseTransitionName(this.suiAnimation);
547
+ const direction = resolveTransitionDirection(explicitDirection, this.suiDirection, targetVisible);
548
+ const motionBase = isStaticTransitionName(baseName) ? 'fade' : baseName;
549
+ const durationCss = durationToCss(this.suiDuration);
550
+ const steps = direction === 'in'
551
+ ? buildEnterSteps(motionBase, durationCss)
552
+ : buildLeaveSteps(motionBase, durationCss);
553
+ this.playSteps(steps, targetVisible);
554
+ }
555
+ runStaticAnimation() {
556
+ const { baseName } = parseTransitionName(this.suiAnimation);
557
+ if (!isStaticTransitionName(baseName) || this.suiDisabled) {
558
+ return;
559
+ }
560
+ const steps = buildStaticSteps(baseName, durationToCss(this.suiDuration));
561
+ if (!steps) {
562
+ return;
563
+ }
564
+ this.playSteps(steps, true, true);
565
+ }
566
+ playSteps(steps, endingVisible, isStatic = false) {
567
+ this.destroyPlayer();
568
+ this.animating = true;
569
+ this.suiAnimationStart.emit();
570
+ this.syncHostClasses();
571
+ this.cdr.markForCheck();
572
+ const factory = this.builder.build(steps);
573
+ const player = factory.create(this.el.nativeElement);
574
+ this.player = player;
575
+ player.onDone(() => {
576
+ this.zone.run(() => {
577
+ this.player = null;
578
+ this.animating = false;
579
+ if (endingVisible) {
580
+ this.applyVisibleEndState();
581
+ this.hidden = false;
582
+ }
583
+ else {
584
+ this.applyHiddenEndState();
585
+ this.hidden = true;
586
+ }
587
+ this.suiAnimationComplete.emit();
588
+ if (!isStatic) {
589
+ if (endingVisible) {
590
+ this.suiOnShow.emit();
591
+ }
592
+ else {
593
+ this.suiOnHide.emit();
594
+ }
595
+ }
596
+ this.syncHostClasses();
597
+ this.cdr.markForCheck();
598
+ });
599
+ });
600
+ player.play();
601
+ }
602
+ emitVisibilityCallbacks(targetVisible) {
603
+ this.suiAnimationComplete.emit();
604
+ if (targetVisible) {
605
+ this.suiOnShow.emit();
606
+ }
607
+ else {
608
+ this.suiOnHide.emit();
609
+ }
610
+ }
611
+ applyImmediateVisibility(visible) {
612
+ this.destroyPlayer();
613
+ this.animating = false;
614
+ if (visible) {
615
+ this.applyVisibleEndState();
616
+ this.hidden = false;
617
+ }
618
+ else {
619
+ this.applyHiddenEndState();
620
+ this.hidden = true;
621
+ }
622
+ this.syncHostClasses();
623
+ }
624
+ applyVisibleEndState() {
625
+ const el = this.el.nativeElement;
626
+ this.renderer.setStyle(el, 'opacity', '1');
627
+ this.renderer.setStyle(el, 'visibility', 'visible');
628
+ this.renderer.removeStyle(el, 'transform');
629
+ this.renderer.removeStyle(el, 'transform-origin');
630
+ this.renderer.removeStyle(el, 'box-shadow');
631
+ }
632
+ applyHiddenEndState() {
633
+ const el = this.el.nativeElement;
634
+ this.renderer.setStyle(el, 'opacity', '0');
635
+ this.renderer.setStyle(el, 'visibility', 'hidden');
636
+ this.renderer.removeStyle(el, 'transform');
637
+ this.renderer.removeStyle(el, 'transform-origin');
638
+ }
639
+ destroyPlayer() {
640
+ if (this.player) {
641
+ this.player.destroy();
642
+ this.player = null;
643
+ }
644
+ }
645
+ syncHostClasses() {
646
+ const { baseName } = parseTransitionName(this.suiAnimation);
647
+ const tokens = ClassUtils.combineToClass([
648
+ 'transition',
649
+ ...baseName.split(' '),
650
+ ClassUtils.getPropClass(this.animating, 'animating'),
651
+ ClassUtils.getPropClass(this.suiDisabled, 'disabled'),
652
+ ClassUtils.getPropClass(!this.hidden, 'visible'),
653
+ ClassUtils.getPropClass(this.hidden, 'hidden')
654
+ ]);
655
+ this.hostClassList = ClassUtils.removeExcessWhitespace(tokens);
656
+ }
657
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: SuiTransitionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
658
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.7", type: SuiTransitionComponent, isStandalone: true, selector: "sui-transition", inputs: { suiAnimation: "suiAnimation", suiDuration: "suiDuration", suiDirection: "suiDirection", suiVisible: "suiVisible", suiPlay: "suiPlay", suiDisabled: "suiDisabled" }, outputs: { suiVisibleChange: "suiVisibleChange", suiAnimationStart: "suiAnimationStart", suiAnimationComplete: "suiAnimationComplete", suiOnShow: "suiOnShow", suiOnHide: "suiOnHide" }, host: { properties: { "class": "hostClassList" } }, exportAs: ["suiTransition"], usesOnChanges: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
659
+ }
660
+ __decorate([
661
+ InputBoolean()
662
+ ], SuiTransitionComponent.prototype, "suiVisible", void 0);
663
+ __decorate([
664
+ InputBoolean()
665
+ ], SuiTransitionComponent.prototype, "suiDisabled", void 0);
666
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: SuiTransitionComponent, decorators: [{
667
+ type: Component,
668
+ args: [{
669
+ standalone: true,
670
+ selector: 'sui-transition',
671
+ exportAs: 'suiTransition',
672
+ encapsulation: ViewEncapsulation.None,
673
+ changeDetection: ChangeDetectionStrategy.OnPush,
674
+ template: '<ng-content></ng-content>',
675
+ host: {
676
+ '[class]': 'hostClassList'
677
+ }
678
+ }]
679
+ }], propDecorators: { suiAnimation: [{
680
+ type: Input
681
+ }], suiDuration: [{
682
+ type: Input
683
+ }], suiDirection: [{
684
+ type: Input
685
+ }], suiVisible: [{
686
+ type: Input
687
+ }], suiPlay: [{
688
+ type: Input
689
+ }], suiDisabled: [{
690
+ type: Input
691
+ }], suiVisibleChange: [{
692
+ type: Output
693
+ }], suiAnimationStart: [{
694
+ type: Output
695
+ }], suiAnimationComplete: [{
696
+ type: Output
697
+ }], suiOnShow: [{
698
+ type: Output
699
+ }], suiOnHide: [{
700
+ type: Output
701
+ }] } });
702
+
703
+ class SuiTransitionModule {
704
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: SuiTransitionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
705
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.7", ngImport: i0, type: SuiTransitionModule, imports: [SuiTransitionComponent], exports: [SuiTransitionComponent] }); }
706
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: SuiTransitionModule }); }
707
+ }
708
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: SuiTransitionModule, decorators: [{
709
+ type: NgModule,
710
+ args: [{
711
+ imports: [SuiTransitionComponent],
712
+ exports: [SuiTransitionComponent]
713
+ }]
714
+ }] });
715
+
716
+ /**
717
+ * Generated bundle index. Do not edit.
718
+ */
719
+
720
+ export { SuiTransitionComponent, SuiTransitionModule, buildEnterSteps, buildLeaveSteps, buildStaticSteps, durationToCss, getMotionForVisibility, isStaticTransitionName, listRegisteredMotionKeys, parseTransitionName, resolveTransitionDirection };
721
+ //# sourceMappingURL=ngx-semantic-modules-transition.mjs.map