@ship-ui/core 0.14.1 → 0.14.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.
@@ -574,11 +574,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
574
574
  }]
575
575
  }] });
576
576
 
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
+
577
598
  class ShipCheckboxComponent {
578
- #selfRef = inject(ElementRef);
599
+ constructor() {
600
+ this.currentClassList = classMutationSignal();
601
+ this.showClasses = computed(() => {
602
+ const classArr = this.currentClassList().split(' ');
603
+ return classArr.includes('active') ? classArr : '';
604
+ }, ...(ngDevMode ? [{ debugName: "showClasses" }] : []));
605
+ }
579
606
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: ShipCheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
580
607
  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">
608
+ <div class="box sh-sheet" [class]="showClasses()">
582
609
  <sh-icon class="inherit default-indicator">check-bold</sh-icon>
583
610
  <sh-icon class="inherit indeterminate-indicator">minus-bold</sh-icon>
584
611
  </div>
@@ -592,7 +619,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
592
619
  selector: 'sh-checkbox',
593
620
  imports: [ShipIconComponent],
594
621
  template: `
595
- <div class="box">
622
+ <div class="box sh-sheet" [class]="showClasses()">
596
623
  <sh-icon class="inherit default-indicator">check-bold</sh-icon>
597
624
  <sh-icon class="inherit indeterminate-indicator">minus-bold</sh-icon>
598
625
  </div>
@@ -1261,24 +1288,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
1261
1288
  args: ['click']
1262
1289
  }] } });
1263
1290
 
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
1291
  function contentProjectionSignal(hostElement, querySelector) {
1283
1292
  const projectedElementsSignal = signal([], ...(ngDevMode ? [{ debugName: "projectedElementsSignal" }] : []));
1284
1293
  const destroyRef = inject(DestroyRef);
@@ -1312,7 +1321,6 @@ function contentProjectionSignal(hostElement, querySelector) {
1312
1321
 
1313
1322
  class ShipDatepickerComponent {
1314
1323
  constructor() {
1315
- this.#selfRef = inject(ElementRef);
1316
1324
  this.#INIT_DATE = this.#getUTCDate(new Date());
1317
1325
  this.date = model(null, ...(ngDevMode ? [{ debugName: "date" }] : []));
1318
1326
  this.endDate = model(null, ...(ngDevMode ? [{ debugName: "endDate" }] : []));
@@ -1332,7 +1340,7 @@ class ShipDatepickerComponent {
1332
1340
  const weekdayLabels = this.weekdayLabels();
1333
1341
  return weekdayLabels.slice(startOfWeek).concat(weekdayLabels.slice(0, startOfWeek));
1334
1342
  }, ...(ngDevMode ? [{ debugName: "weekdays" }] : []));
1335
- this.currentClasses = classMutationSignal(this.#selfRef.nativeElement);
1343
+ this.currentClasses = classMutationSignal();
1336
1344
  this.someEffect = effect(() => {
1337
1345
  const _ = this.currentClasses();
1338
1346
  this.#findSelectedAndCalc();
@@ -1343,7 +1351,6 @@ class ShipDatepickerComponent {
1343
1351
  this.#setDateAsCurrent();
1344
1352
  }, ...(ngDevMode ? [{ debugName: "#newDateEffect" }] : []));
1345
1353
  }
1346
- #selfRef;
1347
1354
  #INIT_DATE;
1348
1355
  getLastVisibleMonth() {
1349
1356
  const lastMonthOffset = this.monthsToShow() - 1;
@@ -1660,7 +1667,7 @@ class ShipDatepickerInputComponent {
1660
1667
  }, ...(ngDevMode ? [{ debugName: "_maskedDate" }] : []));
1661
1668
  this.internalDate = signal(this.#INIT_DATE, ...(ngDevMode ? [{ debugName: "internalDate" }] : []));
1662
1669
  this.isOpen = model(false, ...(ngDevMode ? [{ debugName: "isOpen" }] : []));
1663
- this.currentClass = classMutationSignal(this.#elementRef.nativeElement);
1670
+ this.currentClass = classMutationSignal();
1664
1671
  this.#inputObserver = contentProjectionSignal(this.#elementRef.nativeElement, '#input-wrap input');
1665
1672
  this.#inputRefEffect = effect(() => {
1666
1673
  const inputs = this.#inputObserver();