cmat 0.0.80 → 0.0.82

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 (35) hide show
  1. package/fesm2022/cmat-components-carousel.mjs +34 -9
  2. package/fesm2022/cmat-components-carousel.mjs.map +1 -1
  3. package/fesm2022/cmat-components-drawer.mjs +49 -14
  4. package/fesm2022/cmat-components-drawer.mjs.map +1 -1
  5. package/fesm2022/cmat-components-material-datetimepicker.mjs +49 -27
  6. package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
  7. package/fesm2022/cmat-components-navigation.mjs +161 -182
  8. package/fesm2022/cmat-components-navigation.mjs.map +1 -1
  9. package/fesm2022/cmat-components-opt-input.mjs +73 -63
  10. package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
  11. package/fesm2022/cmat-components-popover.mjs +25 -14
  12. package/fesm2022/cmat-components-popover.mjs.map +1 -1
  13. package/fesm2022/cmat-components-select-search.mjs +9 -19
  14. package/fesm2022/cmat-components-select-search.mjs.map +1 -1
  15. package/fesm2022/cmat-components-speed-dial.mjs +45 -5
  16. package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
  17. package/fesm2022/cmat-components-toast.mjs +69 -18
  18. package/fesm2022/cmat-components-toast.mjs.map +1 -1
  19. package/fesm2022/cmat-components-treetable.mjs.map +1 -1
  20. package/fesm2022/cmat-directives-arrow-cursor.mjs +66 -43
  21. package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
  22. package/fesm2022/cmat.mjs +571 -387
  23. package/fesm2022/cmat.mjs.map +1 -1
  24. package/package.json +1 -1
  25. package/types/cmat-components-carousel.d.ts +16 -9
  26. package/types/cmat-components-drawer.d.ts +6 -0
  27. package/types/cmat-components-material-datetimepicker.d.ts +10 -7
  28. package/types/cmat-components-navigation.d.ts +25 -20
  29. package/types/cmat-components-opt-input.d.ts +11 -8
  30. package/types/cmat-components-popover.d.ts +3 -3
  31. package/types/cmat-components-select-search.d.ts +1 -1
  32. package/types/cmat-components-speed-dial.d.ts +5 -1
  33. package/types/cmat-components-toast.d.ts +12 -2
  34. package/types/cmat-directives-arrow-cursor.d.ts +9 -4
  35. package/types/cmat.d.ts +85 -42
@@ -1,8 +1,9 @@
1
1
  import { NgStyle, NgClass } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { EventEmitter, inject, ElementRef, HostListener, Input, HostBinding, Output, ChangeDetectionStrategy, ViewEncapsulation, Component, Injectable, signal, Directive, ViewChild, InjectionToken, Injector, ViewContainerRef, DOCUMENT, afterNextRender, forwardRef, ContentChild } from '@angular/core';
3
+ import { EventEmitter, inject, ElementRef, HostListener, Input, HostBinding, Output, ChangeDetectionStrategy, ViewEncapsulation, Component, Injectable, signal, Directive, DestroyRef, ViewChild, InjectionToken, Injector, ViewContainerRef, DOCUMENT, afterNextRender, forwardRef, ContentChild } from '@angular/core';
4
4
  import { DatetimeAdapter, CMAT_DATETIME_FORMATS } from 'cmat/components/adapter';
5
5
  import { coerceNumberProperty, coerceBooleanProperty, coerceStringArray } from '@angular/cdk/coercion';
6
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
6
7
  import * as i1 from '@angular/material/button';
7
8
  import { MatButtonModule } from '@angular/material/button';
8
9
  import { Subject, Subscription, merge, of } from 'rxjs';
@@ -135,15 +136,15 @@ class CmatDatetimepickerClockComponent {
135
136
  this.activeDate = this._activeDate || this._adapter.today();
136
137
  this._init();
137
138
  }
139
+ ngOnDestroy() {
140
+ this._removeDocumentListeners();
141
+ }
138
142
  handleMousemove(event) {
139
143
  event.preventDefault();
140
144
  this._setTime(event);
141
145
  }
142
146
  handleMouseup() {
143
- document.removeEventListener('mousemove', this._mouseMoveListener);
144
- document.removeEventListener('touchmove', this._mouseMoveListener);
145
- document.removeEventListener('mouseup', this._mouseUpListener);
146
- document.removeEventListener('touchend', this._mouseUpListener);
147
+ this._removeDocumentListeners();
147
148
  if (this._timeChanged) {
148
149
  this.selectedChange.emit(this.activeDate);
149
150
  if (!this.hourView) {
@@ -151,6 +152,12 @@ class CmatDatetimepickerClockComponent {
151
152
  }
152
153
  }
153
154
  }
155
+ _removeDocumentListeners() {
156
+ document.removeEventListener('mousemove', this._mouseMoveListener);
157
+ document.removeEventListener('touchmove', this._mouseMoveListener);
158
+ document.removeEventListener('mouseup', this._mouseUpListener);
159
+ document.removeEventListener('touchend', this._mouseUpListener);
160
+ }
154
161
  _init() {
155
162
  this.hours.length = 0;
156
163
  this.minutes.length = 0;
@@ -211,8 +218,8 @@ class CmatDatetimepickerClockComponent {
211
218
  const triggerRect = trigger.getBoundingClientRect();
212
219
  const width = trigger.offsetWidth;
213
220
  const height = trigger.offsetHeight;
214
- const pageX = event.pageX !== undefined ? event.pageX : event.touches[0].pageX;
215
- const pageY = event.pageY !== undefined ? event.pageY : event.touches[0].pageY;
221
+ const pageX = event instanceof MouseEvent ? event.pageX : event.touches[0].pageX;
222
+ const pageY = event instanceof MouseEvent ? event.pageY : event.touches[0].pageY;
216
223
  const x = (width / 2) - (pageX - triggerRect.left - window.scrollX);
217
224
  const y = (height / 2) - (pageY - triggerRect.top - window.scrollY);
218
225
  let radian = Math.atan2(-x, y);
@@ -848,9 +855,12 @@ class CmatDatetimepickerTimeComponent {
848
855
  this.intlVersion = signal(0, ...(ngDevMode ? [{ debugName: "intlVersion" }] : /* istanbul ignore next */ []));
849
856
  this.datetimepickerIntl = inject(CmatDatetimepickerIntl);
850
857
  this._adapter = inject(DatetimeAdapter);
858
+ this._destroyRef = inject(DestroyRef);
851
859
  this._twelvehour = false;
852
860
  this._clockView = 'hour';
853
- this.datetimepickerIntlChangesSubscription = this.datetimepickerIntl.changes.subscribe(() => {
861
+ this.datetimepickerIntl.changes
862
+ .pipe(takeUntilDestroyed(this._destroyRef))
863
+ .subscribe(() => {
854
864
  this.intlVersion.update(value => value + 1);
855
865
  });
856
866
  }
@@ -858,7 +868,7 @@ class CmatDatetimepickerTimeComponent {
858
868
  return this._clockView === 'hour';
859
869
  }
860
870
  get isMinuteView() {
861
- return this._clockView === 'hour';
871
+ return this._clockView === 'minute';
862
872
  }
863
873
  get hour() {
864
874
  if (!this.activeDate) {
@@ -1021,11 +1031,6 @@ class CmatDatetimepickerTimeComponent {
1021
1031
  handleCancel() {
1022
1032
  this.userSelection.emit();
1023
1033
  }
1024
- ngOnDestroy() {
1025
- if (this.datetimepickerIntlChangesSubscription) {
1026
- this.datetimepickerIntlChangesSubscription.unsubscribe();
1027
- }
1028
- }
1029
1034
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: CmatDatetimepickerTimeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1030
1035
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: CmatDatetimepickerTimeComponent, isStandalone: true, selector: "cmat-datetimepicker-time", inputs: { dateFilter: "dateFilter", interval: "interval", AMPM: "AMPM", twelvehour: "twelvehour", activeDate: "activeDate", selected: "selected", minDate: "minDate", maxDate: "maxDate", clockView: "clockView" }, outputs: { selectedChange: "selectedChange", activeDateChange: "activeDateChange", userSelection: "userSelection", ampmChange: "ampmChange", clockViewChange: "clockViewChange" }, host: { properties: { "class": "this.class" } }, viewQueries: [{ propertyName: "hourInputElement", first: true, predicate: ["hourInput"], descendants: true, read: (ElementRef) }, { propertyName: "hourInputDirective", first: true, predicate: ["hourInput"], descendants: true, read: CmatDatetimepickerTimeInputDirective }, { propertyName: "minuteInputElement", first: true, predicate: ["minuteInput"], descendants: true, read: (ElementRef) }, { propertyName: "minuteInputDirective", first: true, predicate: ["minuteInput"], descendants: true, read: CmatDatetimepickerTimeInputDirective }], exportAs: ["cmatDatetimepickerTime"], usesOnChanges: true, ngImport: i0, template: "<div class=\"cmat-datetimepicker-time-input-wrapper\" [attr.data-refresh]=\"intlVersion()\">\r\n <div class=\"cmat-datetimepicker-time-input-inner\">\r\n <input #hourInput=\"cmatDatetimepickerTimeInput\" class=\"cmat-datetimepicker-time-input\"\r\n type=\"text\" inputmode=\"numeric\"\r\n maxlength=\"2\" [class.cmat-datetimepicker-time-input-active]=\"clockView === 'hour'\" [class.cmat-datetimepicker-time-input-warning]=\"!hourInput.valid\" [timeMin]=\"twelvehour ? 1 : 0\" [timeMax]=\"twelvehour ? 12 : 23\"\r\n [timeValue]=\"hour\" (timeValueChanged)=\"handleHourInputChange($event)\" (focus)=\"handleFocus('hour')\" />\r\n\r\n <div class=\"cmat-datetimepicker-time-seperator\">:</div>\r\n\r\n <input #minuteInput=\"cmatDatetimepickerTimeInput\" class=\"cmat-datetimepicker-time-input\"\r\n type=\"text\" inputmode=\"numeric\"\r\n maxlength=\"2\" [class.cmat-datetimepicker-time-input-active]=\"clockView === 'minute'\" [class.cmat-datetimepicker-time-input-warning]=\"!minuteInput.valid\" [timeMin]=\"0\" [timeMax]=\"59\" [timeValue]=\"minute\"\r\n [timeInterval]=\"interval\" (timeValueChanged)=\"handleMinuteInputChange($event)\" (focus)=\"handleFocus('minute')\" />\r\n\r\n @if (twelvehour) {\r\n <div class=\"cmat-datetimepicker-time-ampm\">\r\n <button matButton type=\"button\" class=\"cmat-datetimepicker-time-am\"\r\n aria-label=\"AM\" [class.cmat-datetimepicker-time-ampm-active]=\"AMPM === 'AM'\"\r\n (keydown)=\"$event.stopPropagation()\" (click)=\"ampmChange.emit('AM')\">AM</button>\r\n <button matButton type=\"button\" class=\"cmat-datetimepicker-time-pm\"\r\n aria-label=\"PM\" [class.cmat-datetimepicker-time-ampm-active]=\"AMPM === 'PM'\"\r\n (keydown)=\"$event.stopPropagation()\" (click)=\"ampmChange.emit('PM')\">PM</button>\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n\r\n <cmat-datetimepicker-clock [dateFilter]=\"dateFilter\" [interval]=\"interval\"\r\n [maxDate]=\"maxDate\" [minDate]=\"minDate\" [selected]=\"selected\" [startView]=\"clockView\" [twelvehour]=\"twelvehour\"\r\n (selectedChange)=\"timeSelected($event)\" (activeDateChange)=\"onActiveDateChange($event)\">\r\n </cmat-datetimepicker-clock>\r\n\r\n <div class=\"cmat-datetimepicker-time-button-wrapper flex flex-row gap-4\">\r\n <button class=\"cmat=datetimepicker-time-cancel-button\" matButton=\"outlined\" type=\"button\" (click)=\"handleCancel()\">\r\n {{ datetimepickerIntl.cancelLabel }}\r\n </button>\r\n <button class=\"cmat-datetimepicker-time-ok-button\" matButton=\"filled\" type=\"button\" color=\"primary\" [disabled]=\"minuteInputDirective?.invalid || hourInputDirective?.invalid\"\r\n (click)=\"handleOk()\">\r\n {{ datetimepickerIntl.okLabel }}\r\n </button>\r\n </div>\r\n", styles: [".cmat-datetimepicker-time{display:block;outline:none;-webkit-user-select:none;user-select:none}.cmat-datetimepicker-time-input-wrapper{padding:8px 0;text-align:center}.cmat-datetimepicker-time-input-inner{display:inline-flex;height:56px;align-items:center}.cmat-datetimepicker-time-input{width:72px;font-size:36px;text-align:center;border-radius:8px;border:2px solid transparent;appearance:none;outline:none;height:100%}.cmat-datetimepicker-time-seperator{display:inline-flex;justify-content:center;width:24px;font-size:36px;height:100%}.cmat-datetimepicker-time-ampm{display:inline-flex;flex-direction:column;margin-left:12px;height:100%}[dir=rtl] .cmat-datetimepicker-time-ampm{margin-left:auto;margin-right:12px}.cmat-datetimepicker-time-am.mat-mdc-button,.cmat-datetimepicker-time-pm.mat-mdc-button{flex:1;width:40px;min-width:auto;padding:0;line-height:normal;border-width:1px;border-style:solid;min-height:0}.cmat-datetimepicker-time-am.mat-mdc-button{border-radius:8px 8px 0 0!important}.cmat-datetimepicker-time-pm.mat-mdc-button{border-radius:0 0 8px 8px!important;border-top:none}.cmat-datetimepicker-time-button-wrapper{display:flex;justify-content:flex-end;padding-top:8px}\n"], dependencies: [{ kind: "directive", type: CmatDatetimepickerTimeInputDirective, selector: "input.cmat-datetimepicker-time-input", inputs: ["timeInterval", "timeMin", "timeMax", "timeValue"], outputs: ["timeValueChanged"], exportAs: ["cmatDatetimepickerTimeInput"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i1.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: CmatDatetimepickerClockComponent, selector: "cmat-datetimepicker-clock", inputs: ["dateFilter", "interval", "twelvehour", "activeDate", "selected", "minDate", "maxDate", "startView"], outputs: ["userSelection", "selectedChange", "activeDateChange"], exportAs: ["cmatDatetimepickerClock"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
1031
1036
  }
@@ -1210,6 +1215,7 @@ class CmatDatetimepickerCalendarComponent {
1210
1215
  this._intl = inject(CmatDatetimepickerIntl);
1211
1216
  this._adapter = inject(DatetimeAdapter, { optional: true });
1212
1217
  this._dateFormats = inject(CMAT_DATETIME_FORMATS, { optional: true });
1218
+ this._destroyRef = inject(DestroyRef);
1213
1219
  this._type = 'date';
1214
1220
  this._timeInput = false;
1215
1221
  this._calendarAnimationListener = this.calendarStateDone.bind(this);
@@ -1217,14 +1223,14 @@ class CmatDatetimepickerCalendarComponent {
1217
1223
  (!this.dateFilter || this.dateFilter(date, CmatDatetimepickerFilterType.DATE)) &&
1218
1224
  (!this.minDate || this._adapter.compareDate(date, this.minDate) >= 0) &&
1219
1225
  (!this.maxDate || this._adapter.compareDate(date, this.maxDate) <= 0);
1220
- const _intl = this._intl;
1221
1226
  if (!this._adapter) {
1222
1227
  throw createMissingDateImplError('CDatetimeAdapter');
1223
1228
  }
1224
1229
  if (!this._dateFormats) {
1225
1230
  throw createMissingDateImplError('CMAT_DATETIME_FORMATS');
1226
1231
  }
1227
- this._intlChanges = _intl.changes
1232
+ this._intl.changes
1233
+ .pipe(takeUntilDestroyed(this._destroyRef))
1228
1234
  .subscribe(() => this.intlVersion.update(value => value + 1));
1229
1235
  this._elementRef.nativeElement.addEventListener('animationend', this._calendarAnimationListener);
1230
1236
  }
@@ -1418,7 +1424,6 @@ class CmatDatetimepickerCalendarComponent {
1418
1424
  }
1419
1425
  ngOnDestroy() {
1420
1426
  this._elementRef.nativeElement.removeEventListener('animationend', this._calendarAnimationListener);
1421
- this._intlChanges.unsubscribe();
1422
1427
  }
1423
1428
  dateSelected(date) {
1424
1429
  if (this.type === 'date') {
@@ -1869,6 +1874,7 @@ class CmatDatetimepickerComponent {
1869
1874
  this._focusedElementBeforeOpen = null;
1870
1875
  this._backdropHarnessClass = `${this.id}-backdrop`;
1871
1876
  this._inputStateChanges = Subscription.EMPTY;
1877
+ this._closeAnimationTimeoutId = null;
1872
1878
  this._multiYearSelector = false;
1873
1879
  this._twelvehour = false;
1874
1880
  this._opened = false;
@@ -2023,7 +2029,16 @@ class CmatDatetimepickerComponent {
2023
2029
  if (this._componentRef) {
2024
2030
  const { instance, location } = this._componentRef;
2025
2031
  instance.startExitAnimation();
2032
+ this._closeAnimationTimeoutId = window.setTimeout(() => {
2033
+ this._closeAnimationTimeoutId = null;
2034
+ this._focusedElementBeforeOpen = null;
2035
+ this._destroyOverlay();
2036
+ }, 500);
2026
2037
  instance.animationDone.pipe(take(1)).subscribe(() => {
2038
+ if (this._closeAnimationTimeoutId !== null) {
2039
+ clearTimeout(this._closeAnimationTimeoutId);
2040
+ this._closeAnimationTimeoutId = null;
2041
+ }
2027
2042
  const activeElement = this._document.activeElement;
2028
2043
  if (canRestoreFocus &&
2029
2044
  (!activeElement ||
@@ -2232,6 +2247,7 @@ class CmatDatetimepickerInputDirective {
2232
2247
  this._formField = inject(MatFormField, { optional: true });
2233
2248
  this._datepickerSubscription = Subscription.EMPTY;
2234
2249
  this._localeSubscription = Subscription.EMPTY;
2250
+ this._valueChangeTimeoutId = null;
2235
2251
  this._lastValueValid = false;
2236
2252
  // eslint-disable-next-line @typescript-eslint/no-empty-function
2237
2253
  this._onTouched = () => { };
@@ -2287,7 +2303,11 @@ class CmatDatetimepickerInputDirective {
2287
2303
  const oldDate = this.value;
2288
2304
  this._value = value;
2289
2305
  this._formatValue(value);
2290
- setTimeout(() => {
2306
+ if (this._valueChangeTimeoutId !== null) {
2307
+ clearTimeout(this._valueChangeTimeoutId);
2308
+ }
2309
+ this._valueChangeTimeoutId = window.setTimeout(() => {
2310
+ this._valueChangeTimeoutId = null;
2291
2311
  if (!this._dateAdapter.sameDatetime(oldDate, value)) {
2292
2312
  this.valueChange.emit(value);
2293
2313
  }
@@ -2332,6 +2352,10 @@ class CmatDatetimepickerInputDirective {
2332
2352
  }
2333
2353
  }
2334
2354
  ngOnDestroy() {
2355
+ if (this._valueChangeTimeoutId !== null) {
2356
+ clearTimeout(this._valueChangeTimeoutId);
2357
+ this._valueChangeTimeoutId = null;
2358
+ }
2335
2359
  this._datepickerSubscription.unsubscribe();
2336
2360
  this._localeSubscription.unsubscribe();
2337
2361
  this.valueChange.complete();
@@ -2499,7 +2523,7 @@ class CmatDatetimepickerToggleComponent {
2499
2523
  this.class = 'cmat-datetimepicker-toggle';
2500
2524
  this.refreshVersion = signal(0, ...(ngDevMode ? [{ debugName: "refreshVersion" }] : /* istanbul ignore next */ []));
2501
2525
  this.intl = inject(CmatDatetimepickerIntl);
2502
- this._stateChanges = Subscription.EMPTY;
2526
+ this._destroyRef = inject(DestroyRef);
2503
2527
  }
2504
2528
  get disabled() {
2505
2529
  return this._disabled === undefined ? this.datetimepicker.disabled : !!this._disabled;
@@ -2512,9 +2536,6 @@ class CmatDatetimepickerToggleComponent {
2512
2536
  this._watchStateChanges();
2513
2537
  }
2514
2538
  }
2515
- ngOnDestroy() {
2516
- this._stateChanges.unsubscribe();
2517
- }
2518
2539
  ngAfterContentInit() {
2519
2540
  this._watchStateChanges();
2520
2541
  }
@@ -2525,11 +2546,12 @@ class CmatDatetimepickerToggleComponent {
2525
2546
  }
2526
2547
  }
2527
2548
  _watchStateChanges() {
2528
- const datepickerDisabled = this.datetimepicker ? this.datetimepicker.disabledChange : of();
2529
- const inputDisabled = this.datetimepicker?.datetimepickerInput ?
2530
- this.datetimepicker.datetimepickerInput.disabledChange : of();
2531
- this._stateChanges.unsubscribe();
2532
- this._stateChanges = merge([this.intl.changes, datepickerDisabled, inputDisabled])
2549
+ const datepickerDisabled = this.datetimepicker?.disabledChange ? this.datetimepicker.disabledChange : of(false);
2550
+ const inputDisabled = this.datetimepicker?.datetimepickerInput?.disabledChange
2551
+ ? this.datetimepicker.datetimepickerInput.disabledChange
2552
+ : of(false);
2553
+ merge(this.intl.changes, datepickerDisabled, inputDisabled)
2554
+ .pipe(takeUntilDestroyed(this._destroyRef))
2533
2555
  .subscribe(() => this.refreshVersion.update(value => value + 1));
2534
2556
  }
2535
2557
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: CmatDatetimepickerToggleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }