@ship-ui/core 0.14.1 → 0.14.5
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.
|
@@ -1,5 +1,6 @@
|
|
|
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, input, computed, viewChild, effect, HostListener, NgModule, Injectable, InjectionToken, model, output, ApplicationRef, createComponent, isSignal, OutputEmitterRef, contentChildren, afterNextRender, assertInInjectionContext, Injector, HostBinding, contentChild, TemplateRef, runInInjectionContext, Directive, ChangeDetectorRef, viewChildren, ViewContainerRef, EnvironmentInjector } from '@angular/core';
|
|
3
|
+
import { SHIP_CONFIG as SHIP_CONFIG$1 } from 'ship-ui';
|
|
3
4
|
import { DatePipe, NgTemplateOutlet } from '@angular/common';
|
|
4
5
|
import { SIGNAL } from '@angular/core/primitives/signals';
|
|
5
6
|
|
|
@@ -34,13 +35,45 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
|
34
35
|
}]
|
|
35
36
|
}] });
|
|
36
37
|
|
|
38
|
+
function classMutationSignal() {
|
|
39
|
+
const element = inject(ElementRef).nativeElement;
|
|
40
|
+
if (!element)
|
|
41
|
+
return signal('');
|
|
42
|
+
const classListSignal = signal(element.className, ...(ngDevMode ? [{ debugName: "classListSignal" }] : []));
|
|
43
|
+
if (typeof MutationObserver === 'undefined')
|
|
44
|
+
return classListSignal.asReadonly();
|
|
45
|
+
const destroyRef = inject(DestroyRef);
|
|
46
|
+
const observer = new MutationObserver((mutations) => {
|
|
47
|
+
for (const mutation of mutations) {
|
|
48
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
|
49
|
+
const target = mutation.target;
|
|
50
|
+
classListSignal.set(target.className);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
observer.observe(element, { attributes: true });
|
|
55
|
+
destroyRef.onDestroy(() => observer.disconnect());
|
|
56
|
+
return classListSignal.asReadonly();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const POSSIBLE_VARIANTS = ['simple', 'outlined', 'flat', 'raised'];
|
|
37
60
|
class ShipAlertComponent {
|
|
38
61
|
constructor() {
|
|
62
|
+
this.#shConfig = inject(SHIP_CONFIG$1, { optional: true });
|
|
63
|
+
this.variant = signal(this.#shConfig?.alertVariant ?? '', ...(ngDevMode ? [{ debugName: "variant" }] : []));
|
|
39
64
|
this._el = inject(ElementRef); // Used by alert container
|
|
40
65
|
this.alertService = input(null, ...(ngDevMode ? [{ debugName: "alertService" }] : []));
|
|
41
66
|
this.id = input(null, ...(ngDevMode ? [{ debugName: "id" }] : []));
|
|
42
|
-
this.
|
|
67
|
+
this.currentClasses = classMutationSignal();
|
|
68
|
+
this.activeClass = computed(() => {
|
|
69
|
+
const variant = this.variant();
|
|
70
|
+
if (!variant)
|
|
71
|
+
return this.currentClasses();
|
|
72
|
+
const hasVariant = POSSIBLE_VARIANTS.find((x) => this.currentClasses().includes(x));
|
|
73
|
+
return hasVariant ? this.currentClasses() : `${this.currentClasses()} ${variant}`;
|
|
74
|
+
}, ...(ngDevMode ? [{ debugName: "activeClass" }] : []));
|
|
43
75
|
}
|
|
76
|
+
#shConfig;
|
|
44
77
|
removeAlert() {
|
|
45
78
|
if (this.id() && this.alertService()) {
|
|
46
79
|
this.alertService()?.removeAlert(this.id());
|
|
@@ -55,7 +88,7 @@ class ShipAlertComponent {
|
|
|
55
88
|
</div>
|
|
56
89
|
|
|
57
90
|
<div class="icon">
|
|
58
|
-
@let _alertClasses =
|
|
91
|
+
@let _alertClasses = currentClasses();
|
|
59
92
|
|
|
60
93
|
@if (_alertClasses.includes('primary')) {
|
|
61
94
|
<sh-icon class="state-icon">info</sh-icon>
|
|
@@ -101,7 +134,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
|
101
134
|
</div>
|
|
102
135
|
|
|
103
136
|
<div class="icon">
|
|
104
|
-
@let _alertClasses =
|
|
137
|
+
@let _alertClasses = currentClasses();
|
|
105
138
|
|
|
106
139
|
@if (_alertClasses.includes('primary')) {
|
|
107
140
|
<sh-icon class="state-icon">info</sh-icon>
|
|
@@ -575,10 +608,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
|
575
608
|
}] });
|
|
576
609
|
|
|
577
610
|
class ShipCheckboxComponent {
|
|
578
|
-
|
|
611
|
+
constructor() {
|
|
612
|
+
this.currentClassList = classMutationSignal();
|
|
613
|
+
this.showClasses = computed(() => {
|
|
614
|
+
const classArr = this.currentClassList().split(' ');
|
|
615
|
+
return classArr.includes('active') ? classArr : '';
|
|
616
|
+
}, ...(ngDevMode ? [{ debugName: "showClasses" }] : []));
|
|
617
|
+
}
|
|
579
618
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: ShipCheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
580
619
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.6", type: ShipCheckboxComponent, isStandalone: true, selector: "sh-checkbox", ngImport: i0, template: `
|
|
581
|
-
<div class="box">
|
|
620
|
+
<div class="box sh-sheet" [class]="showClasses()">
|
|
582
621
|
<sh-icon class="inherit default-indicator">check-bold</sh-icon>
|
|
583
622
|
<sh-icon class="inherit indeterminate-indicator">minus-bold</sh-icon>
|
|
584
623
|
</div>
|
|
@@ -592,7 +631,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
|
592
631
|
selector: 'sh-checkbox',
|
|
593
632
|
imports: [ShipIconComponent],
|
|
594
633
|
template: `
|
|
595
|
-
<div class="box">
|
|
634
|
+
<div class="box sh-sheet" [class]="showClasses()">
|
|
596
635
|
<sh-icon class="inherit default-indicator">check-bold</sh-icon>
|
|
597
636
|
<sh-icon class="inherit indeterminate-indicator">minus-bold</sh-icon>
|
|
598
637
|
</div>
|
|
@@ -1261,24 +1300,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
|
1261
1300
|
args: ['click']
|
|
1262
1301
|
}] } });
|
|
1263
1302
|
|
|
1264
|
-
function classMutationSignal(element) {
|
|
1265
|
-
const classListSignal = signal(element.className, ...(ngDevMode ? [{ debugName: "classListSignal" }] : []));
|
|
1266
|
-
if (typeof MutationObserver === 'undefined')
|
|
1267
|
-
return classListSignal.asReadonly();
|
|
1268
|
-
const destroyRef = inject(DestroyRef);
|
|
1269
|
-
const observer = new MutationObserver((mutations) => {
|
|
1270
|
-
for (const mutation of mutations) {
|
|
1271
|
-
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
|
1272
|
-
const target = mutation.target;
|
|
1273
|
-
classListSignal.set(target.className);
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
});
|
|
1277
|
-
observer.observe(element, { attributes: true });
|
|
1278
|
-
destroyRef.onDestroy(() => observer.disconnect());
|
|
1279
|
-
return classListSignal.asReadonly();
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
1303
|
function contentProjectionSignal(hostElement, querySelector) {
|
|
1283
1304
|
const projectedElementsSignal = signal([], ...(ngDevMode ? [{ debugName: "projectedElementsSignal" }] : []));
|
|
1284
1305
|
const destroyRef = inject(DestroyRef);
|
|
@@ -1312,7 +1333,6 @@ function contentProjectionSignal(hostElement, querySelector) {
|
|
|
1312
1333
|
|
|
1313
1334
|
class ShipDatepickerComponent {
|
|
1314
1335
|
constructor() {
|
|
1315
|
-
this.#selfRef = inject(ElementRef);
|
|
1316
1336
|
this.#INIT_DATE = this.#getUTCDate(new Date());
|
|
1317
1337
|
this.date = model(null, ...(ngDevMode ? [{ debugName: "date" }] : []));
|
|
1318
1338
|
this.endDate = model(null, ...(ngDevMode ? [{ debugName: "endDate" }] : []));
|
|
@@ -1332,7 +1352,7 @@ class ShipDatepickerComponent {
|
|
|
1332
1352
|
const weekdayLabels = this.weekdayLabels();
|
|
1333
1353
|
return weekdayLabels.slice(startOfWeek).concat(weekdayLabels.slice(0, startOfWeek));
|
|
1334
1354
|
}, ...(ngDevMode ? [{ debugName: "weekdays" }] : []));
|
|
1335
|
-
this.currentClasses = classMutationSignal(
|
|
1355
|
+
this.currentClasses = classMutationSignal();
|
|
1336
1356
|
this.someEffect = effect(() => {
|
|
1337
1357
|
const _ = this.currentClasses();
|
|
1338
1358
|
this.#findSelectedAndCalc();
|
|
@@ -1343,7 +1363,6 @@ class ShipDatepickerComponent {
|
|
|
1343
1363
|
this.#setDateAsCurrent();
|
|
1344
1364
|
}, ...(ngDevMode ? [{ debugName: "#newDateEffect" }] : []));
|
|
1345
1365
|
}
|
|
1346
|
-
#selfRef;
|
|
1347
1366
|
#INIT_DATE;
|
|
1348
1367
|
getLastVisibleMonth() {
|
|
1349
1368
|
const lastMonthOffset = this.monthsToShow() - 1;
|
|
@@ -1660,7 +1679,7 @@ class ShipDatepickerInputComponent {
|
|
|
1660
1679
|
}, ...(ngDevMode ? [{ debugName: "_maskedDate" }] : []));
|
|
1661
1680
|
this.internalDate = signal(this.#INIT_DATE, ...(ngDevMode ? [{ debugName: "internalDate" }] : []));
|
|
1662
1681
|
this.isOpen = model(false, ...(ngDevMode ? [{ debugName: "isOpen" }] : []));
|
|
1663
|
-
this.currentClass = classMutationSignal(
|
|
1682
|
+
this.currentClass = classMutationSignal();
|
|
1664
1683
|
this.#inputObserver = contentProjectionSignal(this.#elementRef.nativeElement, '#input-wrap input');
|
|
1665
1684
|
this.#inputRefEffect = effect(() => {
|
|
1666
1685
|
const inputs = this.#inputObserver();
|