@ship-ui/core 0.14.2 → 0.14.6
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/fesm2022/ship-ui-core.mjs +38 -27
- package/fesm2022/ship-ui-core.mjs.map +1 -1
- package/index.d.ts +5 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef, Renderer2, ChangeDetectionStrategy, Component, input, computed, viewChild, effect, HostListener, NgModule,
|
|
2
|
+
import { inject, ElementRef, Renderer2, ChangeDetectionStrategy, Component, signal, DestroyRef, InjectionToken, input, computed, viewChild, effect, HostListener, NgModule, Injectable, model, output, ApplicationRef, createComponent, isSignal, OutputEmitterRef, contentChildren, afterNextRender, assertInInjectionContext, Injector, HostBinding, contentChild, TemplateRef, runInInjectionContext, Directive, ChangeDetectorRef, viewChildren, ViewContainerRef, EnvironmentInjector } from '@angular/core';
|
|
3
3
|
import { DatePipe, NgTemplateOutlet } from '@angular/common';
|
|
4
4
|
import { SIGNAL } from '@angular/core/primitives/signals';
|
|
5
5
|
|
|
@@ -34,13 +34,47 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
|
34
34
|
}]
|
|
35
35
|
}] });
|
|
36
36
|
|
|
37
|
+
function classMutationSignal() {
|
|
38
|
+
const element = inject(ElementRef).nativeElement;
|
|
39
|
+
if (!element)
|
|
40
|
+
return signal('');
|
|
41
|
+
const classListSignal = signal(element.className, ...(ngDevMode ? [{ debugName: "classListSignal" }] : []));
|
|
42
|
+
if (typeof MutationObserver === 'undefined')
|
|
43
|
+
return classListSignal.asReadonly();
|
|
44
|
+
const destroyRef = inject(DestroyRef);
|
|
45
|
+
const observer = new MutationObserver((mutations) => {
|
|
46
|
+
for (const mutation of mutations) {
|
|
47
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
|
48
|
+
const target = mutation.target;
|
|
49
|
+
classListSignal.set(target.className);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
observer.observe(element, { attributes: true });
|
|
54
|
+
destroyRef.onDestroy(() => observer.disconnect());
|
|
55
|
+
return classListSignal.asReadonly();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const SHIP_CONFIG = new InjectionToken('Ship UI Config');
|
|
59
|
+
|
|
60
|
+
const POSSIBLE_VARIANTS = ['simple', 'outlined', 'flat', 'raised'];
|
|
37
61
|
class ShipAlertComponent {
|
|
38
62
|
constructor() {
|
|
63
|
+
this.#shConfig = inject(SHIP_CONFIG, { optional: true });
|
|
64
|
+
this.variant = signal(this.#shConfig?.alertVariant ?? '', ...(ngDevMode ? [{ debugName: "variant" }] : []));
|
|
39
65
|
this._el = inject(ElementRef); // Used by alert container
|
|
40
66
|
this.alertService = input(null, ...(ngDevMode ? [{ debugName: "alertService" }] : []));
|
|
41
67
|
this.id = input(null, ...(ngDevMode ? [{ debugName: "id" }] : []));
|
|
42
|
-
this.
|
|
68
|
+
this.currentClasses = classMutationSignal();
|
|
69
|
+
this.activeClass = computed(() => {
|
|
70
|
+
const variant = this.variant();
|
|
71
|
+
if (!variant)
|
|
72
|
+
return this.currentClasses();
|
|
73
|
+
const hasVariant = POSSIBLE_VARIANTS.find((x) => this.currentClasses().includes(x));
|
|
74
|
+
return hasVariant ? this.currentClasses() : `${this.currentClasses()} ${variant}`;
|
|
75
|
+
}, ...(ngDevMode ? [{ debugName: "activeClass" }] : []));
|
|
43
76
|
}
|
|
77
|
+
#shConfig;
|
|
44
78
|
removeAlert() {
|
|
45
79
|
if (this.id() && this.alertService()) {
|
|
46
80
|
this.alertService()?.removeAlert(this.id());
|
|
@@ -55,7 +89,7 @@ class ShipAlertComponent {
|
|
|
55
89
|
</div>
|
|
56
90
|
|
|
57
91
|
<div class="icon">
|
|
58
|
-
@let _alertClasses =
|
|
92
|
+
@let _alertClasses = currentClasses();
|
|
59
93
|
|
|
60
94
|
@if (_alertClasses.includes('primary')) {
|
|
61
95
|
<sh-icon class="state-icon">info</sh-icon>
|
|
@@ -101,7 +135,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
|
101
135
|
</div>
|
|
102
136
|
|
|
103
137
|
<div class="icon">
|
|
104
|
-
@let _alertClasses =
|
|
138
|
+
@let _alertClasses = currentClasses();
|
|
105
139
|
|
|
106
140
|
@if (_alertClasses.includes('primary')) {
|
|
107
141
|
<sh-icon class="state-icon">info</sh-icon>
|
|
@@ -307,8 +341,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
|
307
341
|
}]
|
|
308
342
|
}] });
|
|
309
343
|
|
|
310
|
-
const SHIP_CONFIG = new InjectionToken('Ship UI Config');
|
|
311
|
-
|
|
312
344
|
const DEFAULT_OPTIONS$1 = {
|
|
313
345
|
class: 'default',
|
|
314
346
|
width: undefined,
|
|
@@ -574,27 +606,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
|
574
606
|
}]
|
|
575
607
|
}] });
|
|
576
608
|
|
|
577
|
-
function classMutationSignal() {
|
|
578
|
-
const element = inject(ElementRef).nativeElement;
|
|
579
|
-
if (!element)
|
|
580
|
-
return signal('');
|
|
581
|
-
const classListSignal = signal(element.className, ...(ngDevMode ? [{ debugName: "classListSignal" }] : []));
|
|
582
|
-
if (typeof MutationObserver === 'undefined')
|
|
583
|
-
return classListSignal.asReadonly();
|
|
584
|
-
const destroyRef = inject(DestroyRef);
|
|
585
|
-
const observer = new MutationObserver((mutations) => {
|
|
586
|
-
for (const mutation of mutations) {
|
|
587
|
-
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
|
588
|
-
const target = mutation.target;
|
|
589
|
-
classListSignal.set(target.className);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
observer.observe(element, { attributes: true });
|
|
594
|
-
destroyRef.onDestroy(() => observer.disconnect());
|
|
595
|
-
return classListSignal.asReadonly();
|
|
596
|
-
}
|
|
597
|
-
|
|
598
609
|
class ShipCheckboxComponent {
|
|
599
610
|
constructor() {
|
|
600
611
|
this.currentClassList = classMutationSignal();
|