@vsn-ux/ngx-gaia 0.14.3 → 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.
@@ -10,11 +10,11 @@ import { NgTemplateOutlet } from '@angular/common';
10
10
  import { ComponentPortal } from '@angular/cdk/portal';
11
11
  import { Subject, takeUntil, map, merge, filter, Observable, isObservable, timer } from 'rxjs';
12
12
  import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
13
+ import * as i1$3 from '@angular/cdk/a11y';
14
+ import { FocusMonitor, CdkTrapFocus } from '@angular/cdk/a11y';
13
15
  import * as i1$2 from '@angular/cdk/menu';
14
16
  import { CdkMenu, CdkMenuItem, CdkMenuTrigger, MENU_SCROLL_STRATEGY } from '@angular/cdk/menu';
15
17
  import { Router, ResolveStart } from '@angular/router';
16
- import * as i1$3 from '@angular/cdk/a11y';
17
- import { CdkTrapFocus } from '@angular/cdk/a11y';
18
18
  import * as i1$4 from '@angular/cdk/scrolling';
19
19
  import { CdkScrollable } from '@angular/cdk/scrolling';
20
20
  import * as i1$5 from '@angular/cdk/listbox';
@@ -1864,7 +1864,6 @@ class GaDatepickerInputDirective {
1864
1864
  updateValue(value, { updateView, emitToNgModel, } = {}) {
1865
1865
  this.value.set(value);
1866
1866
  this.lastValueValid.set(true);
1867
- this.lastDateChangeEmittedValue.set(value);
1868
1867
  if (updateView) {
1869
1868
  this.formatValue();
1870
1869
  }
@@ -1874,11 +1873,37 @@ class GaDatepickerInputDirective {
1874
1873
  this.onNgTouchedFn?.();
1875
1874
  this.dateInput.emit(value);
1876
1875
  this.dateChange.emit(value);
1876
+ // The dedupe baseline must only advance when dateChange is actually
1877
+ // emitted, so the next blur can detect a real change.
1878
+ this.lastDateChangeEmittedValue.set(value);
1877
1879
  }
1878
1880
  }
1879
1881
  // ControlValueAccessor implementation
1880
1882
  writeValue(value) {
1883
+ // A form write-back echoing the value we already hold (e.g. the
1884
+ // synchronous/async round-trip triggered by `onInput` -> `onNgChangeFn`)
1885
+ // must NOT advance the dedupe baseline, otherwise a manually typed date
1886
+ // would be neutralized before `onBlur` can emit `dateChange`.
1887
+ // A genuine programmatic seed brings a new value and must advance the
1888
+ // baseline so blurring without an edit does not spuriously emit.
1889
+ const isEcho = this.valuesEqual(value, this.value());
1881
1890
  this.updateValue(value, { updateView: !this.focused });
1891
+ if (!isEcho) {
1892
+ this.lastDateChangeEmittedValue.set(value);
1893
+ }
1894
+ }
1895
+ valuesEqual(a, b) {
1896
+ if (a === b) {
1897
+ return true;
1898
+ }
1899
+ const structA = this.valueAdapter.toStruct(a);
1900
+ const structB = this.valueAdapter.toStruct(b);
1901
+ // Two unparseable (e.g. raw string) values are only equal when identical,
1902
+ // already handled above; treat them as distinct here.
1903
+ if (!structA && !structB) {
1904
+ return false;
1905
+ }
1906
+ return compareStructs(structA, structB) === 0;
1882
1907
  }
1883
1908
  registerOnChange(fn) {
1884
1909
  this.onNgChangeFn = fn;
@@ -2507,6 +2532,7 @@ class GaTooltipDirective {
2507
2532
  elementRef = inject(ElementRef);
2508
2533
  overlay = inject(Overlay);
2509
2534
  ngZone = inject(NgZone);
2535
+ focusMonitor = inject(FocusMonitor);
2510
2536
  destroyed$ = new Subject();
2511
2537
  _content = null;
2512
2538
  tooltipInstanceDestroyed$ = null;
@@ -2587,9 +2613,28 @@ class GaTooltipDirective {
2587
2613
  get placement() {
2588
2614
  return this._placement;
2589
2615
  }
2616
+ constructor() {
2617
+ // Only treat keyboard focus as a tooltip trigger. Pointer-originated focus
2618
+ // (e.g. clicking a button) is left to the hover lifecycle, so the tooltip
2619
+ // dismisses on mouse leave even though the element keeps focus.
2620
+ this.focusMonitor
2621
+ .monitor(this.elementRef)
2622
+ .pipe(takeUntil(this.destroyed$))
2623
+ .subscribe((origin) => {
2624
+ this.ngZone.run(() => {
2625
+ if (origin === 'keyboard') {
2626
+ this.handleFocusIn();
2627
+ }
2628
+ else if (!origin) {
2629
+ this.handleFocusOut();
2630
+ }
2631
+ });
2632
+ });
2633
+ }
2590
2634
  ngOnDestroy() {
2591
2635
  this.clearShowTimeout();
2592
2636
  this.isAnimatingOut = false;
2637
+ this.focusMonitor.stopMonitoring(this.elementRef);
2593
2638
  this.destroyed$.next();
2594
2639
  this.destroyed$.complete();
2595
2640
  this.overlayRef?.detach();
@@ -2850,7 +2895,7 @@ class GaTooltipDirective {
2850
2895
  }
2851
2896
  }
2852
2897
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: GaTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2853
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.0", type: GaTooltipDirective, isStandalone: true, selector: "[gaTooltip]", inputs: { content: { classPropertyName: "content", publicName: "gaTooltip", isSignal: false, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "gaTooltipDisabled", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, controlMode: { classPropertyName: "controlMode", publicName: "gaTooltipControlMode", isSignal: false, isRequired: false, transformFunction: null }, showControlMode: { classPropertyName: "showControlMode", publicName: "gaTooltipShowControlMode", isSignal: false, isRequired: false, transformFunction: null }, hideControlMode: { classPropertyName: "hideControlMode", publicName: "gaTooltipHideControlMode", isSignal: false, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "gaTooltipOffsetSize", isSignal: false, isRequired: false, transformFunction: numberAttribute }, showDelay: { classPropertyName: "showDelay", publicName: "gaTooltipShowDelay", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "gaTooltipPlacement", isSignal: false, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "handleMouseClick()", "mouseenter": "handleMouseEnter()", "mouseleave": "handleMouseLeave()", "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.aria-describedby": "ariaDescribedBy()" } }, exportAs: ["gaTooltip"], ngImport: i0 });
2898
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.0", type: GaTooltipDirective, isStandalone: true, selector: "[gaTooltip]", inputs: { content: { classPropertyName: "content", publicName: "gaTooltip", isSignal: false, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "gaTooltipDisabled", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, controlMode: { classPropertyName: "controlMode", publicName: "gaTooltipControlMode", isSignal: false, isRequired: false, transformFunction: null }, showControlMode: { classPropertyName: "showControlMode", publicName: "gaTooltipShowControlMode", isSignal: false, isRequired: false, transformFunction: null }, hideControlMode: { classPropertyName: "hideControlMode", publicName: "gaTooltipHideControlMode", isSignal: false, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "gaTooltipOffsetSize", isSignal: false, isRequired: false, transformFunction: numberAttribute }, showDelay: { classPropertyName: "showDelay", publicName: "gaTooltipShowDelay", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "gaTooltipPlacement", isSignal: false, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "handleMouseClick()", "mouseenter": "handleMouseEnter()", "mouseleave": "handleMouseLeave()" }, properties: { "attr.aria-describedby": "ariaDescribedBy()" } }, exportAs: ["gaTooltip"], ngImport: i0 });
2854
2899
  }
2855
2900
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: GaTooltipDirective, decorators: [{
2856
2901
  type: Directive,
@@ -2862,11 +2907,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
2862
2907
  '(click)': 'handleMouseClick()',
2863
2908
  '(mouseenter)': 'handleMouseEnter()',
2864
2909
  '(mouseleave)': 'handleMouseLeave()',
2865
- '(focusin)': 'handleFocusIn()',
2866
- '(focusout)': 'handleFocusOut()',
2867
2910
  },
2868
2911
  }]
2869
- }], propDecorators: { content: [{
2912
+ }], ctorParameters: () => [], propDecorators: { content: [{
2870
2913
  type: Input,
2871
2914
  args: ['gaTooltip']
2872
2915
  }], disabled: [{