@ethlete/core 2.4.2 → 2.5.0
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.
- package/esm2022/lib/directives/animated-overlay/animated-overlay.directive.mjs +24 -3
- package/esm2022/lib/utils/active-selection-model.utils.mjs +82 -0
- package/esm2022/lib/utils/public-api.mjs +2 -1
- package/esm2022/lib/utils/selection-model.utils.mjs +4 -4
- package/fesm2022/ethlete-core.mjs +119 -18
- package/fesm2022/ethlete-core.mjs.map +1 -1
- package/lib/directives/animated-overlay/animated-overlay.directive.d.ts +5 -0
- package/lib/utils/active-selection-model.utils.d.ts +14 -0
- package/lib/utils/public-api.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { inject, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, HostBinding, InjectionToken, assertInInjectionContext, DestroyRef, ElementRef, isDevMode, Directive, Injectable, Inject, Optional, NgZone, EventEmitter, Output, Injector, ViewContainerRef, Pipe, QueryList } from '@angular/core';
|
|
3
3
|
import { DomSanitizer, Meta, Title } from '@angular/platform-browser';
|
|
4
|
-
import {
|
|
4
|
+
import { Subject, BehaviorSubject, takeUntil, switchMap, of, tap, Observable, combineLatest, startWith, map, distinctUntilChanged, shareReplay, skip, take, debounceTime, merge, fromEvent, filter, pairwise, finalize } from 'rxjs';
|
|
5
|
+
import { END, HOME, PAGE_DOWN, PAGE_UP, UP_ARROW, DOWN_ARROW } from '@angular/cdk/keycodes';
|
|
5
6
|
import { coerceCssPixelValue, coerceElement, coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
|
|
6
7
|
import { supportsScrollBehavior } from '@angular/cdk/platform';
|
|
7
8
|
import { Overlay } from '@angular/cdk/overlay';
|
|
@@ -88,6 +89,96 @@ const Memo = (config = {}) => (_, __, descriptor) => {
|
|
|
88
89
|
return descriptor;
|
|
89
90
|
};
|
|
90
91
|
|
|
92
|
+
const createDestroy = () => {
|
|
93
|
+
assertInInjectionContext(createDestroy);
|
|
94
|
+
const destroy$ = new Subject();
|
|
95
|
+
const ref = inject(DestroyRef);
|
|
96
|
+
ref.onDestroy(() => {
|
|
97
|
+
destroy$.next(true);
|
|
98
|
+
destroy$.complete();
|
|
99
|
+
});
|
|
100
|
+
return destroy$.asObservable();
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
class ActiveSelectionModel {
|
|
104
|
+
get selectionModel$() {
|
|
105
|
+
return this._selectionModel$.asObservable();
|
|
106
|
+
}
|
|
107
|
+
get selectionModel() {
|
|
108
|
+
return this._selectionModel$.value;
|
|
109
|
+
}
|
|
110
|
+
get activeOption$() {
|
|
111
|
+
return this._activeOption$.asObservable();
|
|
112
|
+
}
|
|
113
|
+
get activeOption() {
|
|
114
|
+
return this._activeOption$.value;
|
|
115
|
+
}
|
|
116
|
+
constructor() {
|
|
117
|
+
this._destroy$ = createDestroy();
|
|
118
|
+
this._selectionModel$ = new BehaviorSubject(null);
|
|
119
|
+
this._activeOption$ = new BehaviorSubject(null);
|
|
120
|
+
this._selectionModel$
|
|
121
|
+
.pipe(takeUntil(this._destroy$), switchMap((model) => model?.filteredOptions$ ?? of([])), tap(() => this._resetActiveOptions()))
|
|
122
|
+
.subscribe();
|
|
123
|
+
}
|
|
124
|
+
setSelectionModel(selectionModel) {
|
|
125
|
+
this._selectionModel$.next(selectionModel);
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
evaluateKeyboardEvent(event) {
|
|
129
|
+
const keyCode = event.keyCode;
|
|
130
|
+
const activeOption = this.activeOption;
|
|
131
|
+
if (!this.selectionModel || !activeOption)
|
|
132
|
+
return;
|
|
133
|
+
const currentIndex = this.selectionModel?.getOptionIndex(activeOption);
|
|
134
|
+
if (currentIndex === null)
|
|
135
|
+
return;
|
|
136
|
+
let newActiveOption = undefined;
|
|
137
|
+
switch (keyCode) {
|
|
138
|
+
case DOWN_ARROW:
|
|
139
|
+
{
|
|
140
|
+
newActiveOption = this.selectionModel?.getOptionByOffset(1, currentIndex);
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
case UP_ARROW:
|
|
144
|
+
{
|
|
145
|
+
newActiveOption = this.selectionModel?.getOptionByOffset(-1, currentIndex);
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
case PAGE_UP:
|
|
149
|
+
{
|
|
150
|
+
newActiveOption = this.selectionModel?.getOptionByOffset(-10, currentIndex);
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
case PAGE_DOWN:
|
|
154
|
+
{
|
|
155
|
+
newActiveOption = this.selectionModel?.getOptionByOffset(10, currentIndex);
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
case HOME:
|
|
159
|
+
{
|
|
160
|
+
newActiveOption = this.selectionModel?.getFirstOption();
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case END:
|
|
164
|
+
{
|
|
165
|
+
newActiveOption = this.selectionModel?.getLastOption();
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
if (newActiveOption !== undefined) {
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
}
|
|
172
|
+
if (newActiveOption !== activeOption && newActiveOption !== undefined) {
|
|
173
|
+
this._activeOption$.next(newActiveOption);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
_resetActiveOptions() {
|
|
177
|
+
const firstOption = this.selectionModel?.getFirstOption();
|
|
178
|
+
this._activeOption$.next(firstOption ?? null);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
91
182
|
const nextFrame = (cb) => {
|
|
92
183
|
requestAnimationFrame(() => {
|
|
93
184
|
requestAnimationFrame(cb);
|
|
@@ -330,17 +421,6 @@ const getDomain = () => {
|
|
|
330
421
|
return hostname;
|
|
331
422
|
};
|
|
332
423
|
|
|
333
|
-
const createDestroy = () => {
|
|
334
|
-
assertInInjectionContext(createDestroy);
|
|
335
|
-
const destroy$ = new Subject();
|
|
336
|
-
const ref = inject(DestroyRef);
|
|
337
|
-
ref.onDestroy(() => {
|
|
338
|
-
destroy$.next(true);
|
|
339
|
-
destroy$.complete();
|
|
340
|
-
});
|
|
341
|
-
return destroy$.asObservable();
|
|
342
|
-
};
|
|
343
|
-
|
|
344
424
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
345
425
|
/* eslint-disable no-var */
|
|
346
426
|
/**
|
|
@@ -908,13 +988,13 @@ class SelectionModel {
|
|
|
908
988
|
}
|
|
909
989
|
return this.getOptionByIndex(newIndex);
|
|
910
990
|
}
|
|
911
|
-
getFirstOption(options = this.
|
|
991
|
+
getFirstOption(options = this.getFilteredOptions()) {
|
|
912
992
|
return this.getOptionByIndex(0, options);
|
|
913
993
|
}
|
|
914
|
-
getLastOption(options = this.
|
|
994
|
+
getLastOption(options = this.getFilteredOptions()) {
|
|
915
995
|
return this.getOptionByIndex(options.length - 1, options);
|
|
916
996
|
}
|
|
917
|
-
getOptionIndex(option, options = this.
|
|
997
|
+
getOptionIndex(option, options = this.getFilteredOptions()) {
|
|
918
998
|
const key = this.getKey(option);
|
|
919
999
|
const index = options.findIndex((o) => this.getKey(o) === key);
|
|
920
1000
|
return index === -1 ? null : index;
|
|
@@ -2028,6 +2108,8 @@ class AnimatedOverlayDirective {
|
|
|
2028
2108
|
this._beforeClosed = null;
|
|
2029
2109
|
this._afterClosed = null;
|
|
2030
2110
|
this._isMounted$ = new BehaviorSubject(false);
|
|
2111
|
+
this._isMounting$ = new BehaviorSubject(false);
|
|
2112
|
+
this._isUnmounting$ = new BehaviorSubject(false);
|
|
2031
2113
|
/**
|
|
2032
2114
|
* The placement of the animated overlay.
|
|
2033
2115
|
* @default 'auto'
|
|
@@ -2051,6 +2133,15 @@ class AnimatedOverlayDirective {
|
|
|
2051
2133
|
get isMounted$() {
|
|
2052
2134
|
return this._isMounted$.asObservable();
|
|
2053
2135
|
}
|
|
2136
|
+
get isMounting() {
|
|
2137
|
+
return this._isMounting$.value;
|
|
2138
|
+
}
|
|
2139
|
+
get isMounting$() {
|
|
2140
|
+
return this._isMounting$.asObservable();
|
|
2141
|
+
}
|
|
2142
|
+
get isUnmounting() {
|
|
2143
|
+
return this._isUnmounting$.value;
|
|
2144
|
+
}
|
|
2054
2145
|
get portal() {
|
|
2055
2146
|
return this._portal;
|
|
2056
2147
|
}
|
|
@@ -2064,12 +2155,13 @@ class AnimatedOverlayDirective {
|
|
|
2064
2155
|
return this._popper;
|
|
2065
2156
|
}
|
|
2066
2157
|
mount(config) {
|
|
2067
|
-
if (this.isMounted) {
|
|
2158
|
+
if (this.isMounted || this.isMounting) {
|
|
2068
2159
|
if (isDevMode()) {
|
|
2069
|
-
console.warn('AnimatedOverlayDirective:
|
|
2160
|
+
console.warn('AnimatedOverlayDirective: The component is already mounted or mounting. Please unmount the component before mounting again.');
|
|
2070
2161
|
}
|
|
2071
2162
|
return;
|
|
2072
2163
|
}
|
|
2164
|
+
this._isMounting$.next(true);
|
|
2073
2165
|
const { component, providers, data, mirrorWidth } = config;
|
|
2074
2166
|
this._beforeOpened?.next();
|
|
2075
2167
|
const injector = Injector.create({
|
|
@@ -2150,14 +2242,22 @@ class AnimatedOverlayDirective {
|
|
|
2150
2242
|
}), take(1), takeUntil(this._destroy$))
|
|
2151
2243
|
.subscribe();
|
|
2152
2244
|
this._isMounted$.next(true);
|
|
2245
|
+
this._isMounting$.next(false);
|
|
2153
2246
|
});
|
|
2154
2247
|
});
|
|
2155
2248
|
return this._componentRef.instance;
|
|
2156
2249
|
}
|
|
2157
2250
|
unmount() {
|
|
2251
|
+
if (!this.isMounted || this.isUnmounting) {
|
|
2252
|
+
if (isDevMode()) {
|
|
2253
|
+
console.warn('AnimatedOverlayDirective: The component is not mounted or is already unmounting. Please call `mount` before calling `unmount` again.');
|
|
2254
|
+
}
|
|
2255
|
+
return;
|
|
2256
|
+
}
|
|
2158
2257
|
if (!this._componentRef) {
|
|
2159
2258
|
return;
|
|
2160
2259
|
}
|
|
2260
|
+
this._isUnmounting$.next(true);
|
|
2161
2261
|
this._beforeClosed?.next();
|
|
2162
2262
|
this._componentRef.instance._animatedLifecycle?.leave();
|
|
2163
2263
|
this._componentRef.instance._animatedLifecycle?.state$
|
|
@@ -2202,6 +2302,7 @@ class AnimatedOverlayDirective {
|
|
|
2202
2302
|
this._componentRef = null;
|
|
2203
2303
|
}
|
|
2204
2304
|
this._isMounted$.next(false);
|
|
2305
|
+
this._isUnmounting$.next(false);
|
|
2205
2306
|
this._afterClosed?.next();
|
|
2206
2307
|
}
|
|
2207
2308
|
_reposition() {
|
|
@@ -3444,5 +3545,5 @@ const Validators = {
|
|
|
3444
3545
|
* Generated bundle index. Do not edit.
|
|
3445
3546
|
*/
|
|
3446
3547
|
|
|
3447
|
-
export { ANIMATABLE_TOKEN, ANIMATED_LIFECYCLE_TOKEN, AnimatableDirective, AnimatedLifecycleDirective, AnimatedOverlayDirective, BehaviorSubjectWithSubscriberCount, ClickObserverFactory, ClickObserverService, ClickOutsideDirective, ContentObserverService, CursorDragScrollDirective, DEFAULT_VIEWPORT_CONFIG, DELAYABLE_TOKEN, DelayableDirective, ET_PROPERTY_REMOVED, FocusVisibleService, IS_ACTIVE_ELEMENT, IS_ARRAY_NOT_EMPTY, IS_EMAIL, IsActiveElementDirective, IsArrayNotEmpty, IsEmail, LetContext, LetDirective, MUST_MATCH, Memo, MustMatch, MutationObserverFactory, NormalizeGameResultTypePipe, NormalizeMatchParticipantsPipe, NormalizeMatchScorePipe, NormalizeMatchStatePipe, NormalizeMatchTypePipe, OBSERVE_SCROLL_STATE, ObserveContentDirective, ObserveResizeDirective, ObserveScrollStateDirective, RepeatDirective, ResizeObserverFactory, ResizeObserverService, RouterStateService, RuntimeError, SCROLL_OBSERVER_FIRST_ELEMENT_CLASS, SCROLL_OBSERVER_IGNORE_TARGET_CLASS, SCROLL_OBSERVER_LAST_ELEMENT_CLASS, SEO_DIRECTIVE_TOKEN, ScrollObserverFirstElementDirective, ScrollObserverIgnoreTargetDirective, ScrollObserverLastElementDirective, SelectionModel, SeoDirective, SmartBlockScrollStrategy, StructuredDataComponent, ToArrayPipe, TypedQueryList, VIEWPORT_CONFIG, Validators, ViewportService, clamp, clone, createDestroy, createFlipAnimation, createFlipAnimationGroup, createMediaQueryObservable, createReactiveBindings, deleteCookie, elementCanScroll, equal, forceReflow, formatRuntimeError, fromNextFrame, getCookie, getDomain, getGroupMatchPoints, getGroupMatchScore, getKnockoutMatchScore, getMatchScoreSubLine, hasCookie, isElementVisible, isGroupMatch, isKnockoutMatch, mergeSeoConfig, nextFrame, normalizeGameResultType, normalizeMatchParticipant, normalizeMatchParticipants, normalizeMatchScore, normalizeMatchState, normalizeMatchType, provideViewportConfig, routerDisableScrollTop, scrollToElement, setCookie, toArray, toArrayTrackByFn };
|
|
3548
|
+
export { ANIMATABLE_TOKEN, ANIMATED_LIFECYCLE_TOKEN, ActiveSelectionModel, AnimatableDirective, AnimatedLifecycleDirective, AnimatedOverlayDirective, BehaviorSubjectWithSubscriberCount, ClickObserverFactory, ClickObserverService, ClickOutsideDirective, ContentObserverService, CursorDragScrollDirective, DEFAULT_VIEWPORT_CONFIG, DELAYABLE_TOKEN, DelayableDirective, ET_PROPERTY_REMOVED, FocusVisibleService, IS_ACTIVE_ELEMENT, IS_ARRAY_NOT_EMPTY, IS_EMAIL, IsActiveElementDirective, IsArrayNotEmpty, IsEmail, LetContext, LetDirective, MUST_MATCH, Memo, MustMatch, MutationObserverFactory, NormalizeGameResultTypePipe, NormalizeMatchParticipantsPipe, NormalizeMatchScorePipe, NormalizeMatchStatePipe, NormalizeMatchTypePipe, OBSERVE_SCROLL_STATE, ObserveContentDirective, ObserveResizeDirective, ObserveScrollStateDirective, RepeatDirective, ResizeObserverFactory, ResizeObserverService, RouterStateService, RuntimeError, SCROLL_OBSERVER_FIRST_ELEMENT_CLASS, SCROLL_OBSERVER_IGNORE_TARGET_CLASS, SCROLL_OBSERVER_LAST_ELEMENT_CLASS, SEO_DIRECTIVE_TOKEN, ScrollObserverFirstElementDirective, ScrollObserverIgnoreTargetDirective, ScrollObserverLastElementDirective, SelectionModel, SeoDirective, SmartBlockScrollStrategy, StructuredDataComponent, ToArrayPipe, TypedQueryList, VIEWPORT_CONFIG, Validators, ViewportService, clamp, clone, createDestroy, createFlipAnimation, createFlipAnimationGroup, createMediaQueryObservable, createReactiveBindings, deleteCookie, elementCanScroll, equal, forceReflow, formatRuntimeError, fromNextFrame, getCookie, getDomain, getGroupMatchPoints, getGroupMatchScore, getKnockoutMatchScore, getMatchScoreSubLine, hasCookie, isElementVisible, isGroupMatch, isKnockoutMatch, mergeSeoConfig, nextFrame, normalizeGameResultType, normalizeMatchParticipant, normalizeMatchParticipants, normalizeMatchScore, normalizeMatchState, normalizeMatchType, provideViewportConfig, routerDisableScrollTop, scrollToElement, setCookie, toArray, toArrayTrackByFn };
|
|
3448
3549
|
//# sourceMappingURL=ethlete-core.mjs.map
|