@skyux/core 14.0.0-alpha.7 → 14.0.0-alpha.9

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,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { NgModule, Injectable, inject, RendererFactory2, NgZone, DOCUMENT, EventEmitter, Output, Input, Directive, ElementRef, input, output, signal, effect, ChangeDetectionStrategy, Component, provideEnvironmentInitializer, DestroyRef, EnvironmentInjector, createEnvironmentInjector, createComponent, ChangeDetectorRef, ViewContainerRef, ViewChild, InjectionToken, Optional, Inject, ApplicationRef, afterNextRender, Injector, Pipe, HostBinding, Renderer2, HostListener } from '@angular/core';
2
+ import { NgModule, Injectable, inject, RendererFactory2, NgZone, DOCUMENT, EventEmitter, Output, Input, Directive, effect, ElementRef, input, output, signal, DestroyRef, ChangeDetectionStrategy, Component, provideEnvironmentInitializer, EnvironmentInjector, createEnvironmentInjector, createComponent, ChangeDetectorRef, ViewContainerRef, ViewChild, InjectionToken, Optional, Inject, ApplicationRef, afterNextRender, Injector, Pipe, HostBinding, Renderer2, HostListener } from '@angular/core';
3
3
  import { Subject, Subscription, ReplaySubject, fromEvent, of, Observable, filter, map, distinctUntilChanged, shareReplay, observeOn, animationFrameScheduler, takeUntil as takeUntil$1, BehaviorSubject, combineLatestWith, switchMap, concat, debounceTime as debounceTime$1 } from 'rxjs';
4
4
  import { takeUntil, debounceTime, take } from 'rxjs/operators';
5
5
  import { ViewportRuler } from '@angular/cdk/overlay';
@@ -1054,80 +1054,112 @@ function _skyAnimationsDisabled() {
1054
1054
  return inject(DOCUMENT).body.classList.contains(SKY_ANIMATIONS_DISABLED_CLASS_NAME);
1055
1055
  }
1056
1056
 
1057
+ /**
1058
+ * Mimics a CSS motion end event (`animationend`/`transitionend`) when
1059
+ * CSS motion is disabled.
1060
+ *
1061
+ * Registers an effect that watches the provided trigger signal and, after the
1062
+ * first change, emits on a microtask when the host element is visible. This
1063
+ * preserves async timing that callers expect from real motion end events.
1064
+ */
1065
+ function mimicCssMotionEvent(elementRef, destroyRef, triggerSignal, output) {
1066
+ const el = elementRef.nativeElement;
1067
+ let destroyed = false;
1068
+ let initialized = false;
1069
+ destroyRef.onDestroy(() => {
1070
+ destroyed = true;
1071
+ });
1072
+ effect(() => {
1073
+ triggerSignal();
1074
+ // CSS animation/transition events do not fire when the element is `display: none`.
1075
+ if (initialized && getComputedStyle(el).display !== 'none') {
1076
+ // Defer the emit to a microtask so it fires after the current
1077
+ // change detection pass, matching real transition timing.
1078
+ queueMicrotask(() => {
1079
+ if (!destroyed) {
1080
+ output.emit();
1081
+ }
1082
+ });
1083
+ }
1084
+ initialized = true;
1085
+ });
1086
+ }
1087
+
1057
1088
  /**
1058
1089
  * @internal
1059
1090
  *
1060
1091
  * Listens for CSS `transitionend` events on the host element and emits
1061
1092
  * a `transitionEnd` output when the tracked CSS property finishes
1062
1093
  * transitioning. When animations are globally disabled, the output
1063
- * emits synchronously whenever the `transitionTrigger` input changes.
1094
+ * emits via a microtask whenever the `transitionTrigger` input changes.
1064
1095
  *
1065
- * Consumers **must** call `cssPropertyToTrack()` to specify which CSS
1066
- * property to monitor before any transition occurs on the host element.
1096
+ * The CSS property to monitor can be set via the `transitionPropertyToTrack`
1097
+ * input (for template usage) or by calling `setPropertyToTrack()`
1098
+ * (for `hostDirectives` usage).
1067
1099
  */
1068
- class _SkyAnimationTransitionHandlerDirective {
1100
+ class _SkyTransitionEndHandlerDirective {
1069
1101
  #elementRef;
1070
- #propertyName;
1102
+ #propertyNameOverride;
1071
1103
  constructor() {
1072
1104
  this.#elementRef = inject((ElementRef));
1073
1105
  /**
1074
1106
  * Drives the CSS transition on the host element. When the value
1075
1107
  * changes and animations are enabled, a CSS transition runs and
1076
1108
  * `transitionEnd` emits on completion. When animations are
1077
- * disabled, `transitionEnd` emits synchronously instead.
1109
+ * disabled, `transitionEnd` emits via a microtask instead.
1078
1110
  */
1079
1111
  this.transitionTrigger = input.required(...(ngDevMode ? [{ debugName: "transitionTrigger" }] : []));
1112
+ /**
1113
+ * The CSS property name to monitor for `transitionend` events
1114
+ * (e.g. `'opacity'`, `'transform'`). Can be set declaratively in
1115
+ * templates.
1116
+ */
1117
+ this.transitionPropertyToTrack = input(...(ngDevMode ? [undefined, { debugName: "transitionPropertyToTrack" }] : []));
1080
1118
  /**
1081
1119
  * Emits when the tracked CSS property's `transitionend` event fires
1082
- * on the host element, or synchronously when animations are disabled.
1120
+ * on the host element, or via a microtask when animations are disabled.
1083
1121
  */
1084
1122
  this.transitionEnd = output();
1085
- this.#propertyName = signal(undefined, ...(ngDevMode ? [{ debugName: "#propertyName" }] : []));
1123
+ this.#propertyNameOverride = signal(undefined, ...(ngDevMode ? [{ debugName: "#propertyNameOverride" }] : []));
1086
1124
  if (_skyAnimationsDisabled()) {
1087
- let initialized = false;
1088
- effect(() => {
1089
- this.transitionTrigger();
1090
- if (initialized) {
1091
- this.transitionEnd.emit();
1092
- }
1093
- initialized = true;
1094
- });
1125
+ mimicCssMotionEvent(this.#elementRef, inject(DestroyRef), this.transitionTrigger, this.transitionEnd);
1095
1126
  }
1096
1127
  }
1097
1128
  /**
1098
1129
  * Sets the CSS property name to monitor for `transitionend` events
1099
- * (e.g. `'opacity'`, `'max-height'`). This must be called before a
1100
- * transition occurs; otherwise an error is thrown when the host
1101
- * element's `transitionend` event fires.
1130
+ * programmatically. Use this when applying the directive via
1131
+ * `hostDirectives`.
1102
1132
  */
1103
- cssPropertyToTrack(propertyName) {
1104
- this.#propertyName.set(propertyName);
1133
+ setPropertyToTrack(propertyName) {
1134
+ this.#propertyNameOverride.set(propertyName);
1105
1135
  }
1106
1136
  onTransitionEnd(evt) {
1107
1137
  if (evt.target !== this.#elementRef.nativeElement) {
1108
1138
  return;
1109
1139
  }
1110
- if (!this.#propertyName()) {
1111
- throw new Error(`SkyAnimationTransitionHandler: No CSS property specified for transition tracking on element ` +
1140
+ const propertyName = this.transitionPropertyToTrack() ?? this.#propertyNameOverride();
1141
+ if (!propertyName) {
1142
+ throw new Error(`SkyTransitionEndHandler: No CSS property specified for transition tracking on element ` +
1112
1143
  `'<${this.#elementRef.nativeElement.tagName.toLowerCase()}>'. ` +
1113
- `Call 'cssPropertyToTrack()' with a valid CSS property name before a transition occurs.`);
1144
+ `Set the 'transitionPropertyToTrack' input or call 'setPropertyToTrack()' with a valid CSS property name before a transition occurs.`);
1114
1145
  }
1115
- if (evt.propertyName === this.#propertyName()) {
1146
+ if (evt.propertyName === propertyName) {
1116
1147
  this.transitionEnd.emit();
1117
1148
  evt.stopPropagation();
1118
1149
  }
1119
1150
  }
1120
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: _SkyAnimationTransitionHandlerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1121
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.0", type: _SkyAnimationTransitionHandlerDirective, isStandalone: true, inputs: { transitionTrigger: { classPropertyName: "transitionTrigger", publicName: "transitionTrigger", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { transitionEnd: "transitionEnd" }, host: { listeners: { "transitionend": "onTransitionEnd($event)" } }, ngImport: i0 }); }
1151
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: _SkyTransitionEndHandlerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1152
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.0", type: _SkyTransitionEndHandlerDirective, isStandalone: true, selector: "[skyTransitionEndHandler]", inputs: { transitionTrigger: { classPropertyName: "transitionTrigger", publicName: "transitionTrigger", isSignal: true, isRequired: true, transformFunction: null }, transitionPropertyToTrack: { classPropertyName: "transitionPropertyToTrack", publicName: "transitionPropertyToTrack", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { transitionEnd: "transitionEnd" }, host: { listeners: { "transitionend": "onTransitionEnd($event)" } }, ngImport: i0 }); }
1122
1153
  }
1123
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: _SkyAnimationTransitionHandlerDirective, decorators: [{
1154
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: _SkyTransitionEndHandlerDirective, decorators: [{
1124
1155
  type: Directive,
1125
1156
  args: [{
1157
+ selector: '[skyTransitionEndHandler]',
1126
1158
  host: {
1127
1159
  '(transitionend)': 'onTransitionEnd($event)',
1128
1160
  },
1129
1161
  }]
1130
- }], ctorParameters: () => [], propDecorators: { transitionTrigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "transitionTrigger", required: true }] }], transitionEnd: [{ type: i0.Output, args: ["transitionEnd"] }] } });
1162
+ }], ctorParameters: () => [], propDecorators: { transitionTrigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "transitionTrigger", required: true }] }], transitionPropertyToTrack: [{ type: i0.Input, args: [{ isSignal: true, alias: "transitionPropertyToTrack", required: false }] }], transitionEnd: [{ type: i0.Output, args: ["transitionEnd"] }] } });
1131
1163
 
1132
1164
  /**
1133
1165
  * @internal
@@ -1138,10 +1170,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
1138
1170
  class _SkyAnimationSlideComponent {
1139
1171
  constructor() {
1140
1172
  this.opened = input.required(...(ngDevMode ? [{ debugName: "opened" }] : []));
1141
- inject(_SkyAnimationTransitionHandlerDirective).cssPropertyToTrack('visibility');
1173
+ inject(_SkyTransitionEndHandlerDirective).setPropertyToTrack('visibility');
1142
1174
  }
1143
1175
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: _SkyAnimationSlideComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1144
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.0", type: _SkyAnimationSlideComponent, isStandalone: true, selector: "sky-animation-slide", inputs: { opened: { classPropertyName: "opened", publicName: "opened", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "class.sky-animation-slide-in": "!opened()", "class.sky-animation-slide-out": "opened()" } }, hostDirectives: [{ directive: _SkyAnimationTransitionHandlerDirective, inputs: ["transitionTrigger", "opened"], outputs: ["transitionEnd", "transitionEnd"] }], ngImport: i0, template: '<div class="sky-animation-slide-content"><ng-content /></div>', isInline: true, styles: [":host{display:grid;grid-template-rows:0fr;overflow:hidden;transition-property:grid-template-rows,visibility;transition-duration:var(--sky-transition-time-short);transition-timing-function:ease-in}:host.sky-animation-slide-in{grid-template-rows:0fr;visibility:hidden}:host.sky-animation-slide-out{grid-template-rows:1fr;visibility:visible}:host>.sky-animation-slide-content{min-height:0;overflow:hidden}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1176
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.0", type: _SkyAnimationSlideComponent, isStandalone: true, selector: "sky-animation-slide", inputs: { opened: { classPropertyName: "opened", publicName: "opened", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "class.sky-animation-slide-in": "!opened()", "class.sky-animation-slide-out": "opened()" } }, hostDirectives: [{ directive: _SkyTransitionEndHandlerDirective, inputs: ["transitionTrigger", "opened"], outputs: ["transitionEnd", "transitionEnd"] }], ngImport: i0, template: '<div class="sky-animation-slide-content"><ng-content /></div>', isInline: true, styles: [":host{display:grid;grid-template-rows:0fr;overflow:hidden;transition-property:grid-template-rows,visibility;transition-duration:var(--sky-transition-time-short);transition-timing-function:ease-in}:host.sky-animation-slide-in{grid-template-rows:0fr;visibility:hidden}:host.sky-animation-slide-out{grid-template-rows:1fr;visibility:visible}:host>.sky-animation-slide-content{min-height:0;overflow:hidden}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1145
1177
  }
1146
1178
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: _SkyAnimationSlideComponent, decorators: [{
1147
1179
  type: Component,
@@ -1150,7 +1182,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
1150
1182
  '[class.sky-animation-slide-out]': 'opened()',
1151
1183
  }, hostDirectives: [
1152
1184
  {
1153
- directive: _SkyAnimationTransitionHandlerDirective,
1185
+ directive: _SkyTransitionEndHandlerDirective,
1154
1186
  inputs: ['transitionTrigger: opened'],
1155
1187
  outputs: ['transitionEnd'],
1156
1188
  },
@@ -4872,11 +4904,11 @@ class Version {
4872
4904
  /**
4873
4905
  * Represents the version of @skyux/core.
4874
4906
  */
4875
- const VERSION = new Version('14.0.0-alpha.7');
4907
+ const VERSION = new Version('14.0.0-alpha.9');
4876
4908
 
4877
4909
  /**
4878
4910
  * Generated bundle index. Do not edit.
4879
4911
  */
4880
4912
 
4881
- export { NumericOptions, SKY_BREAKPOINTS, SKY_BREAKPOINT_OBSERVER, SKY_HELP_GLOBAL_OPTIONS, SKY_LOG_LEVEL, SKY_STACKING_CONTEXT, SkyAffixAutoFitContext, SkyAffixModule, SkyAffixService, SkyAffixer, SkyAppFormat, SkyAppTitleService, SkyAppWindowRef, SkyContainerBreakpointObserver, SkyContentInfoProvider, SkyCoreAdapterModule, SkyCoreAdapterService, SkyDefaultInputProvider, SkyDockItem, SkyDockLocation, SkyDockModule, SkyDockService, SkyDynamicComponentLegacyService, SkyDynamicComponentLocation, SkyDynamicComponentModule, SkyDynamicComponentService, SkyFileReaderService, SkyHelpService, SkyIdModule, SkyIdService, SkyLayoutHostDirective, SkyLayoutHostService, SkyLiveAnnouncerService, SkyLogLevel, SkyLogModule, SkyLogService, SkyMediaBreakpointObserver, SkyMediaBreakpoints, SkyMediaQueryModule, SkyMediaQueryService, SkyMutationObserverService, SkyNumericModule, SkyNumericPipe, SkyNumericService, SkyOverlayInstance, SkyOverlayLegacyService, SkyOverlayModule, SkyOverlayService, SkyPercentPipe, SkyPercentPipeModule, SkyResizeObserverMediaQueryService, SkyResizeObserverService, SkyResponsiveHostDirective, SkyScreenReaderLabelDirective, SkyScrollShadowDirective, SkyScrollableHostService, SkyTrimModule, SkyUIConfigService, SkyViewkeeper, SkyViewkeeperHostOptions, SkyViewkeeperModule, SkyViewkeeperService, VERSION, _SkyAnimationSlideComponent, _SkyAnimationTransitionHandlerDirective, provideNoopSkyAnimations, provideSkyBreakpointObserver, SkyAffixDirective as λ1, SkyIdDirective as λ2, SkyViewkeeperDirective as λ3, SkyTrimDirective as λ4 };
4913
+ export { NumericOptions, SKY_BREAKPOINTS, SKY_BREAKPOINT_OBSERVER, SKY_HELP_GLOBAL_OPTIONS, SKY_LOG_LEVEL, SKY_STACKING_CONTEXT, SkyAffixAutoFitContext, SkyAffixModule, SkyAffixService, SkyAffixer, SkyAppFormat, SkyAppTitleService, SkyAppWindowRef, SkyContainerBreakpointObserver, SkyContentInfoProvider, SkyCoreAdapterModule, SkyCoreAdapterService, SkyDefaultInputProvider, SkyDockItem, SkyDockLocation, SkyDockModule, SkyDockService, SkyDynamicComponentLegacyService, SkyDynamicComponentLocation, SkyDynamicComponentModule, SkyDynamicComponentService, SkyFileReaderService, SkyHelpService, SkyIdModule, SkyIdService, SkyLayoutHostDirective, SkyLayoutHostService, SkyLiveAnnouncerService, SkyLogLevel, SkyLogModule, SkyLogService, SkyMediaBreakpointObserver, SkyMediaBreakpoints, SkyMediaQueryModule, SkyMediaQueryService, SkyMutationObserverService, SkyNumericModule, SkyNumericPipe, SkyNumericService, SkyOverlayInstance, SkyOverlayLegacyService, SkyOverlayModule, SkyOverlayService, SkyPercentPipe, SkyPercentPipeModule, SkyResizeObserverMediaQueryService, SkyResizeObserverService, SkyResponsiveHostDirective, SkyScreenReaderLabelDirective, SkyScrollShadowDirective, SkyScrollableHostService, SkyTrimModule, SkyUIConfigService, SkyViewkeeper, SkyViewkeeperHostOptions, SkyViewkeeperModule, SkyViewkeeperService, VERSION, _SkyAnimationSlideComponent, _SkyTransitionEndHandlerDirective, provideNoopSkyAnimations, provideSkyBreakpointObserver, SkyAffixDirective as λ1, SkyIdDirective as λ2, SkyViewkeeperDirective as λ3, SkyTrimDirective as λ4 };
4882
4914
  //# sourceMappingURL=skyux-core.mjs.map