@netwo/devkit 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/fesm2022/netwo-devkit-angular-forms.mjs +2125 -0
- package/fesm2022/netwo-devkit-angular-forms.mjs.map +1 -0
- package/fesm2022/netwo-devkit-angular.mjs +3782 -0
- package/fesm2022/netwo-devkit-angular.mjs.map +1 -0
- package/fesm2022/netwo-devkit.mjs +1910 -0
- package/fesm2022/netwo-devkit.mjs.map +1 -0
- package/package.json +45 -3
- package/types/netwo-devkit-angular-forms.d.ts +516 -0
- package/types/netwo-devkit-angular.d.ts +1670 -0
- package/types/netwo-devkit.d.ts +781 -0
- package/README.md +0 -3
|
@@ -0,0 +1,3782 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { numberAttribute, booleanAttribute, input, linkedSignal, HostBinding, Directive, signal, Injectable, inject, ElementRef, output, afterNextRender, untracked, DestroyRef, ContentChildren, contentChild, afterRenderEffect, model, Input, contentChildren, PLATFORM_ID, HostListener, NgZone, computed, assertInInjectionContext, Injector, runInInjectionContext, TemplateRef, ComponentRef, InjectionToken, Pipe, makeEnvironmentProviders, DEFAULT_CURRENCY_CODE, isDevMode, Optional, Inject, ErrorHandler, Service, effect, isSignal } from '@angular/core';
|
|
3
|
+
import { clamp, isNumber, isBoolean, getDeepest, observeResize, observeMutation, isNonEmpty, isNullable, isString, isError, isFn, isPromise, assertNonNullable, isNotNullable, isObject, num2digit, formatAddress, diff, groupBy, capitalize, formatFileSize, formatFrenchPhoneNumber, linkify, formatPhoneNumber, strictTitleCase, truncate, formatUserName, formatUserInitial, documentVisibilityState, subOfArr, resolveValueOrArr, toCamelCase, entries, wrapNullishComparer, deepEqualComparer, switchMapConcurrent, getCenteredSlice } from '@netwo/devkit';
|
|
4
|
+
import { createInjectionToken, createNoopInjectionToken } from 'ngxtension/create-injection-token';
|
|
5
|
+
import * as i1 from '@angular/router';
|
|
6
|
+
import { NavigationEnd, RouterLink, NavigationStart, NavigationError, UrlTree, RedirectCommand, Router, createUrlTreeFromSnapshot, ActivatedRoute, convertToParamMap } from '@angular/router';
|
|
7
|
+
import { provideComponentStore, ComponentStore } from '@ngrx/component-store';
|
|
8
|
+
import { map, filter, debounceTime, switchMap, take, tap, observeOn, asapScheduler, Subject, noop, Subscription, isObservable, firstValueFrom, from, catchError, EMPTY, ReplaySubject, combineLatest, scan, finalize, mergeMap, of, throwError, fromEvent, merge, startWith, distinctUntilChanged, timestamp, withLatestFrom, Observable, NEVER, skip, pipe, timer } from 'rxjs';
|
|
9
|
+
import { takeUntilDestroyed, outputToObservable, toObservable, toSignal } from '@angular/core/rxjs-interop';
|
|
10
|
+
import { isPlatformBrowser, CurrencyPipe as CurrencyPipe$1, I18nPluralPipe, DatePipe, DecimalPipe, LowerCasePipe, PercentPipe, UpperCasePipe } from '@angular/common';
|
|
11
|
+
import { assertInjector } from 'ngxtension/assert-injector';
|
|
12
|
+
import { DataSource } from '@angular/cdk/collections';
|
|
13
|
+
import { HttpResponse, HttpErrorResponse } from '@angular/common/http';
|
|
14
|
+
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
|
|
15
|
+
import { rxMethod } from '@ngrx/signals/rxjs-interop';
|
|
16
|
+
import { DateTime } from 'luxon';
|
|
17
|
+
import { signalStoreFeature, withState, withComputed, withProps, patchState, withMethods, getState, withFeature, withHooks, watchState } from '@ngrx/signals';
|
|
18
|
+
import { removeAllEntities } from '@ngrx/signals/entities';
|
|
19
|
+
|
|
20
|
+
function numberClampAttribute(min, max) {
|
|
21
|
+
return (value, fallbackValue) => {
|
|
22
|
+
const valueTransformed = numberAttribute(value, fallbackValue);
|
|
23
|
+
return clamp(valueTransformed, min, max);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const multiplicitySingle = { multiple: false, count: 1 };
|
|
27
|
+
function multiplicityAttribute(value) {
|
|
28
|
+
if (isNumber(value))
|
|
29
|
+
return fromNumber(value);
|
|
30
|
+
if (isBoolean(value))
|
|
31
|
+
return fromBoolean(value);
|
|
32
|
+
const possibleCount = numberAttribute(value);
|
|
33
|
+
if (!Number.isNaN(possibleCount))
|
|
34
|
+
return fromNumber(possibleCount);
|
|
35
|
+
if (booleanAttribute(value))
|
|
36
|
+
return fromBoolean(true);
|
|
37
|
+
return multiplicitySingle;
|
|
38
|
+
}
|
|
39
|
+
function fromNumber(value) {
|
|
40
|
+
const count = clamp(value, 1, Infinity);
|
|
41
|
+
const multiple = count > 1;
|
|
42
|
+
return { multiple, count };
|
|
43
|
+
}
|
|
44
|
+
function fromBoolean(multiple) {
|
|
45
|
+
const count = multiple ? Infinity : 1;
|
|
46
|
+
return { multiple, count };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const Color = [
|
|
50
|
+
'accent',
|
|
51
|
+
'error',
|
|
52
|
+
'success',
|
|
53
|
+
'info',
|
|
54
|
+
'warning',
|
|
55
|
+
'highlight',
|
|
56
|
+
'background',
|
|
57
|
+
'disable',
|
|
58
|
+
undefined,
|
|
59
|
+
];
|
|
60
|
+
const initialConf$d = {};
|
|
61
|
+
const [injectColorStateConf, provideColorStateConf] =
|
|
62
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf$d);
|
|
63
|
+
class ColorStateDirective {
|
|
64
|
+
constructor() {
|
|
65
|
+
this.conf = injectColorStateConf({
|
|
66
|
+
self: true,
|
|
67
|
+
optional: true,
|
|
68
|
+
});
|
|
69
|
+
this._color = input(this.conf?.defaultValue, { ...(ngDevMode ? { debugName: "_color" } : /* istanbul ignore next */ {}), alias: 'color' });
|
|
70
|
+
this.color = linkedSignal(() => this._color(), /* @ts-ignore */
|
|
71
|
+
...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
72
|
+
}
|
|
73
|
+
get colorClass() {
|
|
74
|
+
const color = this.color();
|
|
75
|
+
return color ? [`n-color-${color}`, 'n-colored'] : [];
|
|
76
|
+
}
|
|
77
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ColorStateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
78
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: ColorStateDirective, isStandalone: true, selector: "[color]", inputs: { _color: { classPropertyName: "_color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "this.colorClass" } }, ngImport: i0 }); }
|
|
79
|
+
}
|
|
80
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ColorStateDirective, decorators: [{
|
|
81
|
+
type: Directive,
|
|
82
|
+
args: [{
|
|
83
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
84
|
+
selector: '[color]',
|
|
85
|
+
}]
|
|
86
|
+
}], propDecorators: { _color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], colorClass: [{
|
|
87
|
+
type: HostBinding,
|
|
88
|
+
args: ['class']
|
|
89
|
+
}] } });
|
|
90
|
+
|
|
91
|
+
const Direction = ['ltr', 'rtl'];
|
|
92
|
+
const initialConf$c = {};
|
|
93
|
+
const [injectDirectionStateConf, provideDirectionStateConf] =
|
|
94
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf$c);
|
|
95
|
+
class DirectionStateDirective {
|
|
96
|
+
constructor() {
|
|
97
|
+
this.conf = injectDirectionStateConf({
|
|
98
|
+
self: true,
|
|
99
|
+
optional: true,
|
|
100
|
+
});
|
|
101
|
+
this._direction = input(this.conf?.defaultValue ?? 'ltr', { ...(ngDevMode ? { debugName: "_direction" } : /* istanbul ignore next */ {}),
|
|
102
|
+
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
103
|
+
alias: 'direction' });
|
|
104
|
+
this.direction = linkedSignal(() => this._direction(), /* @ts-ignore */
|
|
105
|
+
...(ngDevMode ? [{ debugName: "direction" }] : /* istanbul ignore next */ []));
|
|
106
|
+
}
|
|
107
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DirectionStateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
108
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: DirectionStateDirective, isStandalone: true, inputs: { _direction: { classPropertyName: "_direction", publicName: "direction", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.n-dir-ltr": "direction() === \"ltr\"", "class.n-dir-rtl": "direction() === \"rtl\"" } }, ngImport: i0 }); }
|
|
109
|
+
}
|
|
110
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DirectionStateDirective, decorators: [{
|
|
111
|
+
type: Directive,
|
|
112
|
+
args: [{
|
|
113
|
+
host: {
|
|
114
|
+
'[class.n-dir-ltr]': 'direction() === "ltr"',
|
|
115
|
+
'[class.n-dir-rtl]': 'direction() === "rtl"',
|
|
116
|
+
},
|
|
117
|
+
}]
|
|
118
|
+
}], propDecorators: { _direction: [{ type: i0.Input, args: [{ isSignal: true, alias: "direction", required: false }] }] } });
|
|
119
|
+
|
|
120
|
+
const initialConf$b = {};
|
|
121
|
+
const [injectDisabledStateConf, provideDisabledStateConf] =
|
|
122
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf$b);
|
|
123
|
+
class DisabledStateDirective {
|
|
124
|
+
constructor() {
|
|
125
|
+
this.conf = injectDisabledStateConf({
|
|
126
|
+
self: true,
|
|
127
|
+
optional: true,
|
|
128
|
+
});
|
|
129
|
+
this._disabled = input(this.conf?.defaultValue ?? false, { ...(ngDevMode ? { debugName: "_disabled" } : /* istanbul ignore next */ {}),
|
|
130
|
+
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
131
|
+
alias: 'disabled',
|
|
132
|
+
transform: booleanAttribute });
|
|
133
|
+
this.externals = signal([], /* @ts-ignore */
|
|
134
|
+
...(ngDevMode ? [{ debugName: "externals" }] : /* istanbul ignore next */ []));
|
|
135
|
+
this.disabled = linkedSignal(() => {
|
|
136
|
+
const externalValues = this.externals().reduce((res, item) => res || item(), false);
|
|
137
|
+
return this._disabled() || externalValues;
|
|
138
|
+
}, /* @ts-ignore */
|
|
139
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
140
|
+
}
|
|
141
|
+
register(value) {
|
|
142
|
+
this.externals.update((arr) => [...arr, value]);
|
|
143
|
+
return () => this.unregister(value);
|
|
144
|
+
}
|
|
145
|
+
unregister(value) {
|
|
146
|
+
this.externals.update((arr) => arr.filter((item) => item !== value));
|
|
147
|
+
}
|
|
148
|
+
clear() {
|
|
149
|
+
this.externals.set([]);
|
|
150
|
+
}
|
|
151
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DisabledStateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
152
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: DisabledStateDirective, isStandalone: true, inputs: { _disabled: { classPropertyName: "_disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.disabled": "disabled() ? true : null", "attr.aria-disabled": "disabled() ? true : null", "class.n-disabled": "disabled()", "class.disabled": "disabled()" } }, ngImport: i0 }); }
|
|
153
|
+
}
|
|
154
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DisabledStateDirective, decorators: [{
|
|
155
|
+
type: Directive,
|
|
156
|
+
args: [{
|
|
157
|
+
host: {
|
|
158
|
+
'[attr.disabled]': 'disabled() ? true : null',
|
|
159
|
+
'[attr.aria-disabled]': 'disabled() ? true : null',
|
|
160
|
+
'[class.n-disabled]': 'disabled()',
|
|
161
|
+
'[class.disabled]': 'disabled()',
|
|
162
|
+
},
|
|
163
|
+
}]
|
|
164
|
+
}], propDecorators: { _disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
165
|
+
|
|
166
|
+
const Hue = [10, 20, 40, 60, 80, 100, 120, undefined];
|
|
167
|
+
const initialConf$a = {};
|
|
168
|
+
const [injectHueStateConf, provideHueStateConf] =
|
|
169
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf$a);
|
|
170
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
171
|
+
class HueStateDirective {
|
|
172
|
+
constructor() {
|
|
173
|
+
this.conf = injectHueStateConf({
|
|
174
|
+
self: true,
|
|
175
|
+
optional: true,
|
|
176
|
+
});
|
|
177
|
+
this._hue = input(this.conf?.defaultValue, { ...(ngDevMode ? { debugName: "_hue" } : /* istanbul ignore next */ {}), alias: 'hue',
|
|
178
|
+
transform: numberAttribute });
|
|
179
|
+
this.hue = linkedSignal(() => this._hue(), /* @ts-ignore */
|
|
180
|
+
...(ngDevMode ? [{ debugName: "hue" }] : /* istanbul ignore next */ []));
|
|
181
|
+
}
|
|
182
|
+
get clazz() {
|
|
183
|
+
const hue = this.hue();
|
|
184
|
+
return hue ? [`n-hue-${hue}`] : [];
|
|
185
|
+
}
|
|
186
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: HueStateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
187
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: HueStateDirective, isStandalone: true, selector: "[hue]", inputs: { _hue: { classPropertyName: "_hue", publicName: "hue", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "this.clazz" } }, ngImport: i0 }); }
|
|
188
|
+
}
|
|
189
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: HueStateDirective, decorators: [{
|
|
190
|
+
type: Directive,
|
|
191
|
+
args: [{ selector: '[hue]' }]
|
|
192
|
+
}], propDecorators: { _hue: [{ type: i0.Input, args: [{ isSignal: true, alias: "hue", required: false }] }], clazz: [{
|
|
193
|
+
type: HostBinding,
|
|
194
|
+
args: ['class']
|
|
195
|
+
}] } });
|
|
196
|
+
|
|
197
|
+
const initialConf$9 = {};
|
|
198
|
+
const [injectInlineStateConf, provideInlineStateConf] =
|
|
199
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf$9);
|
|
200
|
+
class InlineStateDirective {
|
|
201
|
+
constructor() {
|
|
202
|
+
this.conf = injectInlineStateConf({
|
|
203
|
+
self: true,
|
|
204
|
+
optional: true,
|
|
205
|
+
});
|
|
206
|
+
this._inline = input(this.conf?.defaultValue ?? false, { ...(ngDevMode ? { debugName: "_inline" } : /* istanbul ignore next */ {}),
|
|
207
|
+
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
208
|
+
alias: 'inline',
|
|
209
|
+
transform: booleanAttribute });
|
|
210
|
+
this.inline = linkedSignal(() => this._inline(), /* @ts-ignore */
|
|
211
|
+
...(ngDevMode ? [{ debugName: "inline" }] : /* istanbul ignore next */ []));
|
|
212
|
+
}
|
|
213
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: InlineStateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
214
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: InlineStateDirective, isStandalone: true, inputs: { _inline: { classPropertyName: "_inline", publicName: "inline", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.n-inline": "inline()" } }, ngImport: i0 }); }
|
|
215
|
+
}
|
|
216
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: InlineStateDirective, decorators: [{
|
|
217
|
+
type: Directive,
|
|
218
|
+
args: [{
|
|
219
|
+
host: {
|
|
220
|
+
'[class.n-inline]': 'inline()',
|
|
221
|
+
},
|
|
222
|
+
}]
|
|
223
|
+
}], propDecorators: { _inline: [{ type: i0.Input, args: [{ isSignal: true, alias: "inline", required: false }] }] } });
|
|
224
|
+
|
|
225
|
+
const initialConf$8 = {};
|
|
226
|
+
const [injectInvalidStateConf, provideInvalidStateConf] =
|
|
227
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf$8);
|
|
228
|
+
class InvalidStateDirective {
|
|
229
|
+
constructor() {
|
|
230
|
+
this.conf = injectInvalidStateConf({
|
|
231
|
+
self: true,
|
|
232
|
+
optional: true,
|
|
233
|
+
});
|
|
234
|
+
this._invalid = input(this.conf?.defaultValue ?? false, { ...(ngDevMode ? { debugName: "_invalid" } : /* istanbul ignore next */ {}),
|
|
235
|
+
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
236
|
+
alias: 'inline',
|
|
237
|
+
transform: booleanAttribute });
|
|
238
|
+
this.invalid = linkedSignal(() => this._invalid(), /* @ts-ignore */
|
|
239
|
+
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
240
|
+
}
|
|
241
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: InvalidStateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
242
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: InvalidStateDirective, isStandalone: true, inputs: { _invalid: { classPropertyName: "_invalid", publicName: "inline", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.n-invalid": "invalid()" } }, ngImport: i0 }); }
|
|
243
|
+
}
|
|
244
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: InvalidStateDirective, decorators: [{
|
|
245
|
+
type: Directive,
|
|
246
|
+
args: [{
|
|
247
|
+
host: {
|
|
248
|
+
'[class.n-invalid]': 'invalid()',
|
|
249
|
+
},
|
|
250
|
+
}]
|
|
251
|
+
}], propDecorators: { _invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "inline", required: false }] }] } });
|
|
252
|
+
|
|
253
|
+
const initialConf$7 = {};
|
|
254
|
+
const [injectLoadingStateConf, provideLoadingStateConf] =
|
|
255
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf$7);
|
|
256
|
+
class LoadingStateDirective {
|
|
257
|
+
constructor() {
|
|
258
|
+
this.conf = injectLoadingStateConf({
|
|
259
|
+
self: true,
|
|
260
|
+
optional: true,
|
|
261
|
+
});
|
|
262
|
+
this._loading = input(this.conf?.defaultValue ?? false, { ...(ngDevMode ? { debugName: "_loading" } : /* istanbul ignore next */ {}),
|
|
263
|
+
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
264
|
+
alias: 'loading',
|
|
265
|
+
transform: booleanAttribute });
|
|
266
|
+
this.loading = linkedSignal(() => this._loading(), /* @ts-ignore */
|
|
267
|
+
...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
268
|
+
}
|
|
269
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: LoadingStateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
270
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: LoadingStateDirective, isStandalone: true, inputs: { _loading: { classPropertyName: "_loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.n-loading": "loading()" } }, ngImport: i0 }); }
|
|
271
|
+
}
|
|
272
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: LoadingStateDirective, decorators: [{
|
|
273
|
+
type: Directive,
|
|
274
|
+
args: [{
|
|
275
|
+
host: {
|
|
276
|
+
'[class.n-loading]': 'loading()',
|
|
277
|
+
},
|
|
278
|
+
}]
|
|
279
|
+
}], propDecorators: { _loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }] } });
|
|
280
|
+
|
|
281
|
+
const Orientation = ['horizontal', 'vertical'];
|
|
282
|
+
const initialConf$6 = {};
|
|
283
|
+
const [injectOrientationStateConf, provideOrientationStateConf] =
|
|
284
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf$6);
|
|
285
|
+
class OrientationStateDirective {
|
|
286
|
+
constructor() {
|
|
287
|
+
this.conf = injectOrientationStateConf({
|
|
288
|
+
self: true,
|
|
289
|
+
optional: true,
|
|
290
|
+
});
|
|
291
|
+
this._orientation = input(this.conf?.defaultValue ?? 'horizontal', { ...(ngDevMode ? { debugName: "_orientation" } : /* istanbul ignore next */ {}),
|
|
292
|
+
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
293
|
+
alias: 'orientation' });
|
|
294
|
+
this.orientation = linkedSignal(() => this._orientation(), /* @ts-ignore */
|
|
295
|
+
...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
296
|
+
}
|
|
297
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: OrientationStateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
298
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: OrientationStateDirective, isStandalone: true, inputs: { _orientation: { classPropertyName: "_orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.n-horizontal": "orientation() === \"horizontal\"", "class.n-vertical": "orientation() === \"vertical\"" } }, ngImport: i0 }); }
|
|
299
|
+
}
|
|
300
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: OrientationStateDirective, decorators: [{
|
|
301
|
+
type: Directive,
|
|
302
|
+
args: [{
|
|
303
|
+
host: {
|
|
304
|
+
'[class.n-horizontal]': 'orientation() === "horizontal"',
|
|
305
|
+
'[class.n-vertical]': 'orientation() === "vertical"',
|
|
306
|
+
},
|
|
307
|
+
}]
|
|
308
|
+
}], propDecorators: { _orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }] } });
|
|
309
|
+
|
|
310
|
+
const Radius = ['rounded', 'soft', 'circle', undefined];
|
|
311
|
+
const initialConf$5 = {};
|
|
312
|
+
const [injectRadiusStateConf, provideRadiusStateConf] =
|
|
313
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf$5);
|
|
314
|
+
class RadiusStateDirective {
|
|
315
|
+
constructor() {
|
|
316
|
+
this.conf = injectRadiusStateConf({
|
|
317
|
+
self: true,
|
|
318
|
+
optional: true,
|
|
319
|
+
});
|
|
320
|
+
this._radius = input(this.conf?.defaultValue, { ...(ngDevMode ? { debugName: "_radius" } : /* istanbul ignore next */ {}),
|
|
321
|
+
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
322
|
+
alias: 'radius' });
|
|
323
|
+
this.radius = linkedSignal(() => this._radius(), /* @ts-ignore */
|
|
324
|
+
...(ngDevMode ? [{ debugName: "radius" }] : /* istanbul ignore next */ []));
|
|
325
|
+
}
|
|
326
|
+
get radiusClass() {
|
|
327
|
+
const radius = this.radius();
|
|
328
|
+
return radius ? [`n-radius-${radius}`] : [];
|
|
329
|
+
}
|
|
330
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RadiusStateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
331
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: RadiusStateDirective, isStandalone: true, inputs: { _radius: { classPropertyName: "_radius", publicName: "radius", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "this.radiusClass" } }, ngImport: i0 }); }
|
|
332
|
+
}
|
|
333
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RadiusStateDirective, decorators: [{
|
|
334
|
+
type: Directive
|
|
335
|
+
}], propDecorators: { _radius: [{ type: i0.Input, args: [{ isSignal: true, alias: "radius", required: false }] }], radiusClass: [{
|
|
336
|
+
type: HostBinding,
|
|
337
|
+
args: ['class']
|
|
338
|
+
}] } });
|
|
339
|
+
|
|
340
|
+
const initialConf$4 = {};
|
|
341
|
+
const [injectReadonlyStateConf, provideReadonlyStateConf] =
|
|
342
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf$4);
|
|
343
|
+
class ReadonlyStateDirective {
|
|
344
|
+
constructor() {
|
|
345
|
+
this.conf = injectReadonlyStateConf({
|
|
346
|
+
self: true,
|
|
347
|
+
optional: true,
|
|
348
|
+
});
|
|
349
|
+
this._readonly = input(this.conf?.defaultValue ?? false, { ...(ngDevMode ? { debugName: "_readonly" } : /* istanbul ignore next */ {}),
|
|
350
|
+
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
351
|
+
alias: 'readonly',
|
|
352
|
+
transform: booleanAttribute });
|
|
353
|
+
this.readonly = linkedSignal(() => this._readonly(), /* @ts-ignore */
|
|
354
|
+
...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
|
|
355
|
+
}
|
|
356
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ReadonlyStateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
357
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: ReadonlyStateDirective, isStandalone: true, inputs: { _readonly: { classPropertyName: "_readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.n-readonly": "readonly()" } }, ngImport: i0 }); }
|
|
358
|
+
}
|
|
359
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ReadonlyStateDirective, decorators: [{
|
|
360
|
+
type: Directive,
|
|
361
|
+
args: [{
|
|
362
|
+
host: {
|
|
363
|
+
'[class.n-readonly]': 'readonly()',
|
|
364
|
+
},
|
|
365
|
+
}]
|
|
366
|
+
}], propDecorators: { _readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }] } });
|
|
367
|
+
|
|
368
|
+
const initialConf$3 = {};
|
|
369
|
+
const [injectRequiredStateConf, provideRequiredStateConf] =
|
|
370
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf$3);
|
|
371
|
+
class RequiredStateDirective {
|
|
372
|
+
constructor() {
|
|
373
|
+
this.conf = injectRequiredStateConf({
|
|
374
|
+
self: true,
|
|
375
|
+
optional: true,
|
|
376
|
+
});
|
|
377
|
+
this._required = input(this.conf?.defaultValue ?? false, { ...(ngDevMode ? { debugName: "_required" } : /* istanbul ignore next */ {}),
|
|
378
|
+
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
379
|
+
alias: 'required',
|
|
380
|
+
transform: booleanAttribute });
|
|
381
|
+
this.required = linkedSignal(() => this._required(), /* @ts-ignore */
|
|
382
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
383
|
+
}
|
|
384
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RequiredStateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
385
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: RequiredStateDirective, isStandalone: true, inputs: { _required: { classPropertyName: "_required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.n-required": "required()" } }, ngImport: i0 }); }
|
|
386
|
+
}
|
|
387
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RequiredStateDirective, decorators: [{
|
|
388
|
+
type: Directive,
|
|
389
|
+
args: [{
|
|
390
|
+
host: {
|
|
391
|
+
'[class.n-required]': 'required()',
|
|
392
|
+
},
|
|
393
|
+
}]
|
|
394
|
+
}], propDecorators: { _required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }] } });
|
|
395
|
+
|
|
396
|
+
const Size = ['small', 'medium', 'large', undefined];
|
|
397
|
+
const initialConf$2 = {};
|
|
398
|
+
const [injectSizeStateConf, provideSizeStateConf] =
|
|
399
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf$2);
|
|
400
|
+
class SizeStateDirective {
|
|
401
|
+
constructor() {
|
|
402
|
+
this.conf = injectSizeStateConf({
|
|
403
|
+
self: true,
|
|
404
|
+
optional: true,
|
|
405
|
+
});
|
|
406
|
+
this._size = input(this.conf?.defaultValue, { ...(ngDevMode ? { debugName: "_size" } : /* istanbul ignore next */ {}),
|
|
407
|
+
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
408
|
+
alias: 'size' });
|
|
409
|
+
this.size = linkedSignal(() => this._size(), /* @ts-ignore */
|
|
410
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
411
|
+
}
|
|
412
|
+
get sizeClass() {
|
|
413
|
+
const size = this.size();
|
|
414
|
+
return size ? [`n-size-${size}`] : [];
|
|
415
|
+
}
|
|
416
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SizeStateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
417
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: SizeStateDirective, isStandalone: true, inputs: { _size: { classPropertyName: "_size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "this.sizeClass" } }, ngImport: i0 }); }
|
|
418
|
+
}
|
|
419
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SizeStateDirective, decorators: [{
|
|
420
|
+
type: Directive
|
|
421
|
+
}], propDecorators: { _size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], sizeClass: [{
|
|
422
|
+
type: HostBinding,
|
|
423
|
+
args: ['class']
|
|
424
|
+
}] } });
|
|
425
|
+
|
|
426
|
+
function getDeepestRoute(route) {
|
|
427
|
+
return getDeepest(route, (route) => route.firstChild);
|
|
428
|
+
}
|
|
429
|
+
class MinimalRouterStateSerializer {
|
|
430
|
+
serialize(routerState) {
|
|
431
|
+
return {
|
|
432
|
+
root: this.serializeRoute(routerState.root),
|
|
433
|
+
url: routerState.url,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
serializeRoute(route) {
|
|
437
|
+
const children = route.children.map((c) => this.serializeRoute(c));
|
|
438
|
+
return {
|
|
439
|
+
params: route.params,
|
|
440
|
+
data: route.data,
|
|
441
|
+
url: route.url,
|
|
442
|
+
outlet: route.outlet,
|
|
443
|
+
title: route.title,
|
|
444
|
+
routeConfig: route.routeConfig
|
|
445
|
+
? {
|
|
446
|
+
path: route.routeConfig.path,
|
|
447
|
+
pathMatch: route.routeConfig.pathMatch,
|
|
448
|
+
redirectTo: route.routeConfig.redirectTo,
|
|
449
|
+
outlet: route.routeConfig.outlet,
|
|
450
|
+
title: typeof route.routeConfig.title === 'string'
|
|
451
|
+
? route.routeConfig.title
|
|
452
|
+
: undefined,
|
|
453
|
+
}
|
|
454
|
+
: null,
|
|
455
|
+
queryParams: route.queryParams,
|
|
456
|
+
fragment: route.fragment,
|
|
457
|
+
firstChild: children[0],
|
|
458
|
+
children,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MinimalRouterStateSerializer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
462
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MinimalRouterStateSerializer }); }
|
|
463
|
+
}
|
|
464
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MinimalRouterStateSerializer, decorators: [{
|
|
465
|
+
type: Injectable
|
|
466
|
+
}] });
|
|
467
|
+
|
|
468
|
+
function provideRouterStore() {
|
|
469
|
+
return [MinimalRouterStateSerializer, provideComponentStore(RouterStore)];
|
|
470
|
+
}
|
|
471
|
+
class RouterStore extends ComponentStore {
|
|
472
|
+
constructor(
|
|
473
|
+
// eslint-disable-next-line @angular-eslint/prefer-inject
|
|
474
|
+
router,
|
|
475
|
+
// eslint-disable-next-line @angular-eslint/prefer-inject
|
|
476
|
+
serializer) {
|
|
477
|
+
super({
|
|
478
|
+
routerState: serializer.serialize(router.routerState.snapshot),
|
|
479
|
+
});
|
|
480
|
+
this.router = router;
|
|
481
|
+
this.serializer = serializer;
|
|
482
|
+
this.routerState$ = this.select((state) => state.routerState);
|
|
483
|
+
this.rootRoute$ = this.select(this.routerState$, (routerState) => routerState.root);
|
|
484
|
+
this.currentRoute$ = this.select(this.rootRoute$, getDeepestRoute);
|
|
485
|
+
this.fragment$ = this.select(this.currentRoute$, (route) => route.fragment);
|
|
486
|
+
this.queryParams$ = this.select(this.currentRoute$, (route) => route.queryParams);
|
|
487
|
+
this.routeData$ = this.select(this.currentRoute$, (route) => route.data);
|
|
488
|
+
this.routeParams$ = this.select(this.currentRoute$, (route) => route.params);
|
|
489
|
+
this.title$ = this.select(this.currentRoute$, (route) => route.title);
|
|
490
|
+
this.url$ = this.select(this.routerState$, (routerState) => routerState.url);
|
|
491
|
+
this.updateRouterState = this.updater((state, routerState) => ({
|
|
492
|
+
...state,
|
|
493
|
+
routerState,
|
|
494
|
+
}));
|
|
495
|
+
}
|
|
496
|
+
ngrxOnStoreInit() {
|
|
497
|
+
this.updateRouterState(this.selectRouterEvents(NavigationEnd).pipe(map(() => this.serializer.serialize(this.router.routerState.snapshot))));
|
|
498
|
+
}
|
|
499
|
+
selectQueryParam(param) {
|
|
500
|
+
return this.select(this.queryParams$, (params) => params[param]);
|
|
501
|
+
}
|
|
502
|
+
selectRouteData(key) {
|
|
503
|
+
return this.select(this.routeData$, (data) => data[key]);
|
|
504
|
+
}
|
|
505
|
+
selectRouteParam(param) {
|
|
506
|
+
return this.select(this.routeParams$, (params) => params[param]);
|
|
507
|
+
}
|
|
508
|
+
selectRouterEvents(...acceptedEventTypes) {
|
|
509
|
+
return this.router.events.pipe(filter((event) => acceptedEventTypes.some((eventType) => event instanceof eventType)));
|
|
510
|
+
}
|
|
511
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RouterStore, deps: [{ token: i1.Router }, { token: MinimalRouterStateSerializer }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
512
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RouterStore }); }
|
|
513
|
+
}
|
|
514
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RouterStore, decorators: [{
|
|
515
|
+
type: Injectable
|
|
516
|
+
}], ctorParameters: () => [{ type: i1.Router }, { type: MinimalRouterStateSerializer }] });
|
|
517
|
+
|
|
518
|
+
const initialConf$1 = {
|
|
519
|
+
defaultValue: true,
|
|
520
|
+
threshold: 150,
|
|
521
|
+
};
|
|
522
|
+
const [injectNearTopConf, provideNearTopConf] =
|
|
523
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf$1);
|
|
524
|
+
class NearTopDirective {
|
|
525
|
+
constructor() {
|
|
526
|
+
this.elementRef = inject(ElementRef);
|
|
527
|
+
this.conf = injectNearTopConf();
|
|
528
|
+
this.threshold = this.conf.threshold ?? initialConf$1.threshold;
|
|
529
|
+
this.scrollContainer = this.elementRef.nativeElement;
|
|
530
|
+
this.topTouched = output();
|
|
531
|
+
this.isNearTop = signal(this.conf.defaultValue ?? initialConf$1.defaultValue, /* @ts-ignore */
|
|
532
|
+
...(ngDevMode ? [{ debugName: "isNearTop" }] : /* istanbul ignore next */ []));
|
|
533
|
+
afterNextRender(() => {
|
|
534
|
+
this.scrolled(false);
|
|
535
|
+
});
|
|
536
|
+
observeResize(this.scrollContainer)
|
|
537
|
+
.pipe(debounceTime(50), takeUntilDestroyed())
|
|
538
|
+
.subscribe(() => this.scrolled());
|
|
539
|
+
observeMutation(this.scrollContainer, { childList: true, subtree: true })
|
|
540
|
+
.pipe(debounceTime(50), takeUntilDestroyed())
|
|
541
|
+
.subscribe(() => this.scrolled());
|
|
542
|
+
}
|
|
543
|
+
scrolled(emitChange = true) {
|
|
544
|
+
const oldTouched = untracked(this.isNearTop);
|
|
545
|
+
const touched = this.updateNearTop();
|
|
546
|
+
this.isNearTop.set(touched);
|
|
547
|
+
if (emitChange && touched && !oldTouched) {
|
|
548
|
+
this.topTouched.emit();
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
updateNearTop() {
|
|
552
|
+
const position = this.scrollContainer.scrollTop;
|
|
553
|
+
return position <= this.threshold;
|
|
554
|
+
}
|
|
555
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NearTopDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
556
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: NearTopDirective, isStandalone: true, selector: "[nearTop]", outputs: { topTouched: "topTouched" }, host: { listeners: { "scroll": "scrolled()" } }, exportAs: ["nearTop"], ngImport: i0 }); }
|
|
557
|
+
}
|
|
558
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NearTopDirective, decorators: [{
|
|
559
|
+
type: Directive,
|
|
560
|
+
args: [{
|
|
561
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
562
|
+
selector: '[nearTop]',
|
|
563
|
+
exportAs: 'nearTop',
|
|
564
|
+
host: {
|
|
565
|
+
'(scroll)': 'scrolled()',
|
|
566
|
+
},
|
|
567
|
+
}]
|
|
568
|
+
}], ctorParameters: () => [], propDecorators: { topTouched: [{ type: i0.Output, args: ["topTouched"] }] } });
|
|
569
|
+
|
|
570
|
+
class AnchorToTopItemDirective {
|
|
571
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AnchorToTopItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
572
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: AnchorToTopItemDirective, isStandalone: true, selector: "[anchorToTopItem]", ngImport: i0 }); }
|
|
573
|
+
}
|
|
574
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AnchorToTopItemDirective, decorators: [{
|
|
575
|
+
type: Directive,
|
|
576
|
+
args: [{
|
|
577
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
578
|
+
selector: '[anchorToTopItem]',
|
|
579
|
+
}]
|
|
580
|
+
}] });
|
|
581
|
+
class AnchorToTopDirective {
|
|
582
|
+
constructor() {
|
|
583
|
+
this.nearTopDirective = inject(NearTopDirective, {
|
|
584
|
+
self: true,
|
|
585
|
+
});
|
|
586
|
+
this.destroyRef = inject(DestroyRef);
|
|
587
|
+
}
|
|
588
|
+
ngAfterViewInit() {
|
|
589
|
+
outputToObservable(this.nearTopDirective.topTouched)
|
|
590
|
+
.pipe(switchMap(() => {
|
|
591
|
+
const items = this.items.toArray();
|
|
592
|
+
const [firstItem] = items;
|
|
593
|
+
return this.items.changes.pipe(take(1), tap(() => {
|
|
594
|
+
const newItems = this.items.toArray();
|
|
595
|
+
const [newFirstItem] = newItems;
|
|
596
|
+
if (newFirstItem &&
|
|
597
|
+
firstItem !== newFirstItem &&
|
|
598
|
+
newItems.length > items.length) {
|
|
599
|
+
newFirstItem.nativeElement.scrollIntoView();
|
|
600
|
+
}
|
|
601
|
+
}));
|
|
602
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
603
|
+
.subscribe();
|
|
604
|
+
}
|
|
605
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AnchorToTopDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
606
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: AnchorToTopDirective, isStandalone: true, selector: "[anchorToTop]", queries: [{ propertyName: "items", predicate: AnchorToTopItemDirective, descendants: true, read: ElementRef }], exportAs: ["anchorToTop"], hostDirectives: [{ directive: NearTopDirective, outputs: ["topTouched", "topTouched"] }], ngImport: i0 }); }
|
|
607
|
+
}
|
|
608
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AnchorToTopDirective, decorators: [{
|
|
609
|
+
type: Directive,
|
|
610
|
+
args: [{
|
|
611
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
612
|
+
selector: '[anchorToTop]',
|
|
613
|
+
exportAs: 'anchorToTop',
|
|
614
|
+
hostDirectives: [{ directive: NearTopDirective, outputs: ['topTouched'] }],
|
|
615
|
+
}]
|
|
616
|
+
}], propDecorators: { items: [{
|
|
617
|
+
type: ContentChildren,
|
|
618
|
+
args: [AnchorToTopItemDirective, {
|
|
619
|
+
read: ElementRef,
|
|
620
|
+
descendants: true,
|
|
621
|
+
}]
|
|
622
|
+
}] } });
|
|
623
|
+
|
|
624
|
+
class ClampTargetDirective {
|
|
625
|
+
constructor() {
|
|
626
|
+
this.elementRef = inject(ElementRef);
|
|
627
|
+
}
|
|
628
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ClampTargetDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
629
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: ClampTargetDirective, isStandalone: true, selector: "[netwoClampTarget]", ngImport: i0 }); }
|
|
630
|
+
}
|
|
631
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ClampTargetDirective, decorators: [{
|
|
632
|
+
type: Directive,
|
|
633
|
+
args: [{
|
|
634
|
+
selector: '[netwoClampTarget]',
|
|
635
|
+
}]
|
|
636
|
+
}] });
|
|
637
|
+
class ClampObserverDirective {
|
|
638
|
+
constructor() {
|
|
639
|
+
this.host = inject(ElementRef);
|
|
640
|
+
this.destroyRef = inject(DestroyRef);
|
|
641
|
+
this.cssSelector = input(undefined, { ...(ngDevMode ? { debugName: "cssSelector" } : /* istanbul ignore next */ {}), alias: 'netwoClampObserver' });
|
|
642
|
+
this.observerDisabled = input(false, { ...(ngDevMode ? { debugName: "observerDisabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
643
|
+
this.target = contentChild(ClampTargetDirective, { ...(ngDevMode ? { debugName: "target" } : /* istanbul ignore next */ {}), descendants: true });
|
|
644
|
+
this.clamped = signal(false, /* @ts-ignore */
|
|
645
|
+
...(ngDevMode ? [{ debugName: "clamped" }] : /* istanbul ignore next */ []));
|
|
646
|
+
afterRenderEffect((oncleanup) => {
|
|
647
|
+
if (this.observerDisabled())
|
|
648
|
+
return;
|
|
649
|
+
const target = this.target();
|
|
650
|
+
const cssSelector = this.cssSelector();
|
|
651
|
+
if (!target && !cssSelector)
|
|
652
|
+
throw new Error('ClampObserver error: no clamp target found. Either provide a CSS selector or use the `clampTarget` directive.');
|
|
653
|
+
const parentEl = this.host.nativeElement;
|
|
654
|
+
const targetEl = target?.elementRef.nativeElement ??
|
|
655
|
+
parentEl.querySelector(isNonEmpty(cssSelector) ? cssSelector : '[class*="line-clamp-"]');
|
|
656
|
+
if (targetEl instanceof HTMLElement) {
|
|
657
|
+
const sub = observeResize(parentEl)
|
|
658
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
659
|
+
.subscribe(() => this.clamped.set(this.isClamped(targetEl)));
|
|
660
|
+
oncleanup(() => sub.unsubscribe());
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
isClamped(el) {
|
|
665
|
+
return el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth;
|
|
666
|
+
}
|
|
667
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ClampObserverDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
668
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "22.0.6", type: ClampObserverDirective, isStandalone: true, selector: "[netwoClampObserver]", inputs: { cssSelector: { classPropertyName: "cssSelector", publicName: "netwoClampObserver", isSignal: true, isRequired: false, transformFunction: null }, observerDisabled: { classPropertyName: "observerDisabled", publicName: "observerDisabled", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "target", first: true, predicate: ClampTargetDirective, descendants: true, isSignal: true }], exportAs: ["netwoClampObserver"], ngImport: i0 }); }
|
|
669
|
+
}
|
|
670
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ClampObserverDirective, decorators: [{
|
|
671
|
+
type: Directive,
|
|
672
|
+
args: [{
|
|
673
|
+
selector: '[netwoClampObserver]',
|
|
674
|
+
exportAs: 'netwoClampObserver',
|
|
675
|
+
}]
|
|
676
|
+
}], ctorParameters: () => [], propDecorators: { cssSelector: [{ type: i0.Input, args: [{ isSignal: true, alias: "netwoClampObserver", required: false }] }], observerDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "observerDisabled", required: false }] }], target: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ClampTargetDirective), { ...{ descendants: true }, isSignal: true }] }] } });
|
|
677
|
+
|
|
678
|
+
class ErrorDirective {
|
|
679
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ErrorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
680
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: ErrorDirective, isStandalone: true, selector: "netwo-error,[netwoError]", ngImport: i0 }); }
|
|
681
|
+
}
|
|
682
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ErrorDirective, decorators: [{
|
|
683
|
+
type: Directive,
|
|
684
|
+
args: [{
|
|
685
|
+
selector: 'netwo-error,[netwoError]',
|
|
686
|
+
}]
|
|
687
|
+
}] });
|
|
688
|
+
|
|
689
|
+
class HideIfEmptyDirective {
|
|
690
|
+
constructor() {
|
|
691
|
+
this.destroyRef = inject(DestroyRef);
|
|
692
|
+
this.elementRef = inject(ElementRef);
|
|
693
|
+
this.selector = model(undefined, { ...(ngDevMode ? { debugName: "selector" } : /* istanbul ignore next */ {}), alias: 'netwoHideIfEmpty' });
|
|
694
|
+
this.hasContent = signal(false, /* @ts-ignore */
|
|
695
|
+
...(ngDevMode ? [{ debugName: "hasContent" }] : /* istanbul ignore next */ []));
|
|
696
|
+
afterNextRender(() => {
|
|
697
|
+
const selector = this.selector();
|
|
698
|
+
const el = selector
|
|
699
|
+
? this.elementRef.nativeElement.querySelector(selector)
|
|
700
|
+
: this.elementRef.nativeElement;
|
|
701
|
+
if (!el)
|
|
702
|
+
return;
|
|
703
|
+
const observer = new MutationObserver(() => {
|
|
704
|
+
this.toggleDisplay(el);
|
|
705
|
+
});
|
|
706
|
+
observer.observe(el, {
|
|
707
|
+
childList: true,
|
|
708
|
+
subtree: true,
|
|
709
|
+
characterData: true,
|
|
710
|
+
attributes: true,
|
|
711
|
+
attributeFilter: ['style', 'class', 'hidden'],
|
|
712
|
+
});
|
|
713
|
+
this.toggleDisplay(el);
|
|
714
|
+
this.destroyRef.onDestroy(() => observer.disconnect());
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
toggleDisplay(el) {
|
|
718
|
+
const hasContent = Array.from(el.childNodes).some((node) => isVisibleText(node) || isVisibleElement(node));
|
|
719
|
+
this.hasContent.set(hasContent);
|
|
720
|
+
}
|
|
721
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: HideIfEmptyDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
722
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: HideIfEmptyDirective, isStandalone: true, selector: "[netwoHideIfEmpty]", inputs: { selector: { classPropertyName: "selector", publicName: "netwoHideIfEmpty", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selector: "netwoHideIfEmptyChange" }, host: { properties: { "style.display": "hasContent() ? null : \"none\"" } }, ngImport: i0 }); }
|
|
723
|
+
}
|
|
724
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: HideIfEmptyDirective, decorators: [{
|
|
725
|
+
type: Directive,
|
|
726
|
+
args: [{
|
|
727
|
+
selector: '[netwoHideIfEmpty]',
|
|
728
|
+
host: {
|
|
729
|
+
'[style.display]': 'hasContent() ? null : "none"',
|
|
730
|
+
},
|
|
731
|
+
}]
|
|
732
|
+
}], ctorParameters: () => [], propDecorators: { selector: [{ type: i0.Input, args: [{ isSignal: true, alias: "netwoHideIfEmpty", required: false }] }, { type: i0.Output, args: ["netwoHideIfEmptyChange"] }] } });
|
|
733
|
+
function isVisibleText(node) {
|
|
734
|
+
return node.nodeType === Node.TEXT_NODE && !!node.textContent?.trim().length;
|
|
735
|
+
}
|
|
736
|
+
function isElement(node) {
|
|
737
|
+
return node.nodeType === Node.ELEMENT_NODE;
|
|
738
|
+
}
|
|
739
|
+
function isVisibleElement(node) {
|
|
740
|
+
if (!isElement(node))
|
|
741
|
+
return false;
|
|
742
|
+
const { display, visibility } = getComputedStyle(node);
|
|
743
|
+
return (display !== 'none' &&
|
|
744
|
+
visibility !== 'hidden' &&
|
|
745
|
+
!node.hasAttribute('hidden'));
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
class HintDirective {
|
|
749
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: HintDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
750
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: HintDirective, isStandalone: true, selector: "netwo-hint,[netwoHint]", ngImport: i0 }); }
|
|
751
|
+
}
|
|
752
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: HintDirective, decorators: [{
|
|
753
|
+
type: Directive,
|
|
754
|
+
args: [{
|
|
755
|
+
selector: 'netwo-hint,[netwoHint]',
|
|
756
|
+
}]
|
|
757
|
+
}] });
|
|
758
|
+
|
|
759
|
+
class LabelDirective {
|
|
760
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: LabelDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
761
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: LabelDirective, isStandalone: true, selector: "netwo-label,[netwoLabel]", ngImport: i0 }); }
|
|
762
|
+
}
|
|
763
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: LabelDirective, decorators: [{
|
|
764
|
+
type: Directive,
|
|
765
|
+
args: [{
|
|
766
|
+
selector: 'netwo-label,[netwoLabel]',
|
|
767
|
+
}]
|
|
768
|
+
}] });
|
|
769
|
+
|
|
770
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
771
|
+
class LetDirective {
|
|
772
|
+
constructor() {
|
|
773
|
+
this.context = {
|
|
774
|
+
netwoLet: null,
|
|
775
|
+
$implicit: null,
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
set value(value) {
|
|
779
|
+
this.context.$implicit = this.context.netwoLet = value;
|
|
780
|
+
}
|
|
781
|
+
get value() {
|
|
782
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
783
|
+
return this.context.netwoLet;
|
|
784
|
+
}
|
|
785
|
+
static ngTemplateContextGuard(_dir, _ctx) {
|
|
786
|
+
return true;
|
|
787
|
+
}
|
|
788
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: LetDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
789
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: LetDirective, isStandalone: true, selector: "[netwoLet]", inputs: { value: ["netwoLet", "value"] }, exportAs: ["netwoLet"], ngImport: i0 }); }
|
|
790
|
+
}
|
|
791
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: LetDirective, decorators: [{
|
|
792
|
+
type: Directive,
|
|
793
|
+
args: [{
|
|
794
|
+
selector: '[netwoLet]',
|
|
795
|
+
exportAs: 'netwoLet',
|
|
796
|
+
}]
|
|
797
|
+
}], propDecorators: { value: [{
|
|
798
|
+
type: Input,
|
|
799
|
+
args: ['netwoLet']
|
|
800
|
+
}] } });
|
|
801
|
+
|
|
802
|
+
const initialConf = {
|
|
803
|
+
defaultValue: true,
|
|
804
|
+
threshold: 150,
|
|
805
|
+
};
|
|
806
|
+
const [injectNearBottomConf, provideNearBottomConf] =
|
|
807
|
+
/* @__PURE__ */ createInjectionToken(() => initialConf);
|
|
808
|
+
class NearBottomDirective {
|
|
809
|
+
constructor() {
|
|
810
|
+
this.elementRef = inject(ElementRef);
|
|
811
|
+
this.conf = injectNearBottomConf();
|
|
812
|
+
this.threshold = this.conf.threshold ?? initialConf.threshold;
|
|
813
|
+
this.scrollContainer = this.elementRef.nativeElement;
|
|
814
|
+
this.bottomTouched = output();
|
|
815
|
+
this.isNearBottom = signal(this.conf.defaultValue ?? initialConf.defaultValue, /* @ts-ignore */
|
|
816
|
+
...(ngDevMode ? [{ debugName: "isNearBottom" }] : /* istanbul ignore next */ []));
|
|
817
|
+
afterNextRender(() => {
|
|
818
|
+
this.scrolled(false);
|
|
819
|
+
});
|
|
820
|
+
observeResize(this.scrollContainer)
|
|
821
|
+
.pipe(debounceTime(50), takeUntilDestroyed())
|
|
822
|
+
.subscribe(() => this.scrolled());
|
|
823
|
+
observeMutation(this.scrollContainer, { childList: true, subtree: true })
|
|
824
|
+
.pipe(debounceTime(50), takeUntilDestroyed())
|
|
825
|
+
.subscribe(() => this.scrolled());
|
|
826
|
+
}
|
|
827
|
+
scrolled(emitChange = true) {
|
|
828
|
+
const oldTouched = untracked(this.isNearBottom);
|
|
829
|
+
const touched = this.updateNearBottom();
|
|
830
|
+
this.isNearBottom.set(touched);
|
|
831
|
+
if (emitChange && touched && !oldTouched) {
|
|
832
|
+
this.bottomTouched.emit();
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
updateNearBottom() {
|
|
836
|
+
const position = this.scrollContainer.scrollTop + this.scrollContainer.offsetHeight;
|
|
837
|
+
const height = this.scrollContainer.scrollHeight;
|
|
838
|
+
return position >= height - this.threshold;
|
|
839
|
+
}
|
|
840
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NearBottomDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
841
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: NearBottomDirective, isStandalone: true, selector: "[nearBottom]", outputs: { bottomTouched: "bottomTouched" }, host: { listeners: { "scroll": "scrolled()" } }, exportAs: ["nearBottom"], ngImport: i0 }); }
|
|
842
|
+
}
|
|
843
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NearBottomDirective, decorators: [{
|
|
844
|
+
type: Directive,
|
|
845
|
+
args: [{
|
|
846
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
847
|
+
selector: '[nearBottom]',
|
|
848
|
+
exportAs: 'nearBottom',
|
|
849
|
+
host: {
|
|
850
|
+
'(scroll)': 'scrolled()',
|
|
851
|
+
},
|
|
852
|
+
}]
|
|
853
|
+
}], ctorParameters: () => [], propDecorators: { bottomTouched: [{ type: i0.Output, args: ["bottomTouched"] }] } });
|
|
854
|
+
|
|
855
|
+
class PreventDefaultDirective {
|
|
856
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PreventDefaultDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
857
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: PreventDefaultDirective, isStandalone: true, selector: "[preventDefault]", host: { listeners: { "click": "$event.preventDefault()" } }, ngImport: i0 }); }
|
|
858
|
+
}
|
|
859
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PreventDefaultDirective, decorators: [{
|
|
860
|
+
type: Directive,
|
|
861
|
+
args: [{
|
|
862
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
863
|
+
selector: '[preventDefault]',
|
|
864
|
+
host: { '(click)': '$event.preventDefault()' },
|
|
865
|
+
}]
|
|
866
|
+
}] });
|
|
867
|
+
|
|
868
|
+
function patchRouterLinkDisabled(disabled) {
|
|
869
|
+
const routerLink = inject(RouterLink, { self: true });
|
|
870
|
+
const onClickOrigin = routerLink.onClick.bind(routerLink);
|
|
871
|
+
routerLink.onClick = (button, ctrlKey, shiftKey, altKey, metaKey) => {
|
|
872
|
+
if (disabled() && !(ctrlKey || metaKey))
|
|
873
|
+
return false;
|
|
874
|
+
return onClickOrigin(button, ctrlKey, shiftKey, altKey, metaKey);
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
class RouterLinkDisabledDirective {
|
|
878
|
+
constructor() {
|
|
879
|
+
// do not replace with DisabledStateDirective to avoid the use of multiple host directives
|
|
880
|
+
this.disabled = input.required({ ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute,
|
|
881
|
+
alias: 'routerLinkDisabled' });
|
|
882
|
+
patchRouterLinkDisabled(this.disabled);
|
|
883
|
+
}
|
|
884
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RouterLinkDisabledDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
885
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: RouterLinkDisabledDirective, isStandalone: true, selector: "[routerLinkDisabled]", inputs: { disabled: { classPropertyName: "disabled", publicName: "routerLinkDisabled", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 }); }
|
|
886
|
+
}
|
|
887
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RouterLinkDisabledDirective, decorators: [{
|
|
888
|
+
type: Directive,
|
|
889
|
+
args: [{
|
|
890
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
891
|
+
selector: '[routerLinkDisabled]',
|
|
892
|
+
}]
|
|
893
|
+
}], ctorParameters: () => [], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "routerLinkDisabled", required: true }] }] } });
|
|
894
|
+
|
|
895
|
+
class ScrollToBottomItemDirective {
|
|
896
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ScrollToBottomItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
897
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: ScrollToBottomItemDirective, isStandalone: true, selector: "[scrollToBottomItem]", ngImport: i0 }); }
|
|
898
|
+
}
|
|
899
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ScrollToBottomItemDirective, decorators: [{
|
|
900
|
+
type: Directive,
|
|
901
|
+
args: [{
|
|
902
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
903
|
+
selector: '[scrollToBottomItem]',
|
|
904
|
+
}]
|
|
905
|
+
}] });
|
|
906
|
+
class ScrollToBottomDirective {
|
|
907
|
+
constructor() {
|
|
908
|
+
this.nearBottomDirective = inject(NearBottomDirective, {
|
|
909
|
+
self: true,
|
|
910
|
+
});
|
|
911
|
+
this.autoScrollToBottom = input(false, { ...(ngDevMode ? { debugName: "autoScrollToBottom" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
912
|
+
this.items = contentChildren(ScrollToBottomItemDirective, { ...(ngDevMode ? { debugName: "items" } : /* istanbul ignore next */ {}), descendants: true });
|
|
913
|
+
let initialized = false;
|
|
914
|
+
afterRenderEffect((oncleanup) => {
|
|
915
|
+
const items = this.items();
|
|
916
|
+
if (!items.length) {
|
|
917
|
+
initialized = false;
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
const timeoutId = setTimeout(() => {
|
|
921
|
+
if (initialized) {
|
|
922
|
+
this.onItemElementsChanged();
|
|
923
|
+
}
|
|
924
|
+
else if (untracked(this.autoScrollToBottom)) {
|
|
925
|
+
this.scrollToBottom('auto');
|
|
926
|
+
initialized = true;
|
|
927
|
+
}
|
|
928
|
+
});
|
|
929
|
+
oncleanup(() => clearInterval(timeoutId));
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
onItemElementsChanged() {
|
|
933
|
+
if (untracked(this.nearBottomDirective.isNearBottom)) {
|
|
934
|
+
this.scrollToBottom('smooth');
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
scrollToBottom(behavior) {
|
|
938
|
+
this.nearBottomDirective.scrollContainer.scroll({
|
|
939
|
+
top: this.nearBottomDirective.scrollContainer.scrollHeight,
|
|
940
|
+
left: 0,
|
|
941
|
+
behavior,
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ScrollToBottomDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
945
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "22.0.6", type: ScrollToBottomDirective, isStandalone: true, selector: "[scrollToBottom]", inputs: { autoScrollToBottom: { classPropertyName: "autoScrollToBottom", publicName: "autoScrollToBottom", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "items", predicate: ScrollToBottomItemDirective, descendants: true, isSignal: true }], exportAs: ["scrollToBottom"], hostDirectives: [{ directive: NearBottomDirective, outputs: ["bottomTouched", "bottomTouched"] }], ngImport: i0 }); }
|
|
946
|
+
}
|
|
947
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ScrollToBottomDirective, decorators: [{
|
|
948
|
+
type: Directive,
|
|
949
|
+
args: [{
|
|
950
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
951
|
+
selector: '[scrollToBottom]',
|
|
952
|
+
exportAs: 'scrollToBottom',
|
|
953
|
+
hostDirectives: [
|
|
954
|
+
{ directive: NearBottomDirective, outputs: ['bottomTouched'] },
|
|
955
|
+
],
|
|
956
|
+
}]
|
|
957
|
+
}], ctorParameters: () => [], propDecorators: { autoScrollToBottom: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoScrollToBottom", required: false }] }], items: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => ScrollToBottomItemDirective), { ...{
|
|
958
|
+
descendants: true,
|
|
959
|
+
}, isSignal: true }] }] } });
|
|
960
|
+
|
|
961
|
+
class StopPropagationDirective {
|
|
962
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StopPropagationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
963
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: StopPropagationDirective, isStandalone: true, selector: "[stopPropagation]", host: { listeners: { "click": "$event.stopPropagation()" } }, ngImport: i0 }); }
|
|
964
|
+
}
|
|
965
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StopPropagationDirective, decorators: [{
|
|
966
|
+
type: Directive,
|
|
967
|
+
args: [{
|
|
968
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
969
|
+
selector: '[stopPropagation]',
|
|
970
|
+
host: { '(click)': '$event.stopPropagation()' },
|
|
971
|
+
}]
|
|
972
|
+
}] });
|
|
973
|
+
|
|
974
|
+
class SubtitleDirective {
|
|
975
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SubtitleDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
976
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SubtitleDirective, isStandalone: true, selector: "netwo-subtitle,[netwoSubtitle]", ngImport: i0 }); }
|
|
977
|
+
}
|
|
978
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SubtitleDirective, decorators: [{
|
|
979
|
+
type: Directive,
|
|
980
|
+
args: [{
|
|
981
|
+
selector: 'netwo-subtitle,[netwoSubtitle]',
|
|
982
|
+
}]
|
|
983
|
+
}] });
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Force typings for the context of NgTemplate
|
|
987
|
+
*
|
|
988
|
+
* Example:
|
|
989
|
+
*
|
|
990
|
+
* ``` items.component.ts
|
|
991
|
+
* itemCtx: ImplicitContext<string, {
|
|
992
|
+
* arg1: number;
|
|
993
|
+
* arg2: boolean;
|
|
994
|
+
* }>;
|
|
995
|
+
* ```
|
|
996
|
+
*
|
|
997
|
+
* ``` items.component.html
|
|
998
|
+
* <ng-template let-item let-arg1="arg1" let-arg2="arg2" [templateCtx]="itemCtx"
|
|
999
|
+
* ```
|
|
1000
|
+
*
|
|
1001
|
+
* item will be typed as string, arg1 is number and arg2 is boolean
|
|
1002
|
+
*/
|
|
1003
|
+
class TemplateContextDirective {
|
|
1004
|
+
constructor() {
|
|
1005
|
+
this.templateCtx = input.required(/* @ts-ignore */
|
|
1006
|
+
...(ngDevMode ? [{ debugName: "templateCtx" }] : /* istanbul ignore next */ []));
|
|
1007
|
+
}
|
|
1008
|
+
static ngTemplateContextGuard(_dir, _ctx) {
|
|
1009
|
+
return true;
|
|
1010
|
+
}
|
|
1011
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TemplateContextDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1012
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: TemplateContextDirective, isStandalone: true, selector: "[templateCtx]", inputs: { templateCtx: { classPropertyName: "templateCtx", publicName: "templateCtx", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 }); }
|
|
1013
|
+
}
|
|
1014
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TemplateContextDirective, decorators: [{
|
|
1015
|
+
type: Directive,
|
|
1016
|
+
args: [{
|
|
1017
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
1018
|
+
selector: '[templateCtx]',
|
|
1019
|
+
}]
|
|
1020
|
+
}], propDecorators: { templateCtx: [{ type: i0.Input, args: [{ isSignal: true, alias: "templateCtx", required: true }] }] } });
|
|
1021
|
+
|
|
1022
|
+
class TitleDirective {
|
|
1023
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TitleDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1024
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: TitleDirective, isStandalone: true, selector: "netwo-title,[netwoTitle]", ngImport: i0 }); }
|
|
1025
|
+
}
|
|
1026
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TitleDirective, decorators: [{
|
|
1027
|
+
type: Directive,
|
|
1028
|
+
args: [{
|
|
1029
|
+
selector: 'netwo-title,[netwoTitle]',
|
|
1030
|
+
}]
|
|
1031
|
+
}] });
|
|
1032
|
+
|
|
1033
|
+
// Define a factory function to conditionally provide the Window object based on the platform
|
|
1034
|
+
function windowFactory(platformId) {
|
|
1035
|
+
// Check if the application is running in a browser
|
|
1036
|
+
if (isPlatformBrowser(platformId)) {
|
|
1037
|
+
// If running in a browser, return the native window object
|
|
1038
|
+
return window;
|
|
1039
|
+
}
|
|
1040
|
+
// If not running in a browser, throw an error
|
|
1041
|
+
throw new Error('Window is not available');
|
|
1042
|
+
}
|
|
1043
|
+
// Create injection token utilities with the windowFactory function
|
|
1044
|
+
const [injectWindow] = /* @__PURE__ */ createInjectionToken(windowFactory, {
|
|
1045
|
+
deps: [PLATFORM_ID],
|
|
1046
|
+
isRoot: true,
|
|
1047
|
+
});
|
|
1048
|
+
|
|
1049
|
+
const anchorTarget = [
|
|
1050
|
+
'_self',
|
|
1051
|
+
'_blank',
|
|
1052
|
+
'_parent',
|
|
1053
|
+
'_top',
|
|
1054
|
+
'_unfencedTop',
|
|
1055
|
+
];
|
|
1056
|
+
class WindowOpenDirective {
|
|
1057
|
+
constructor() {
|
|
1058
|
+
this.window = injectWindow();
|
|
1059
|
+
this.url = input.required({ ...(ngDevMode ? { debugName: "url" } : /* istanbul ignore next */ {}), alias: 'netwoWindowOpen' });
|
|
1060
|
+
this.target = input('_blank', /* @ts-ignore */
|
|
1061
|
+
...(ngDevMode ? [{ debugName: "target" }] : /* istanbul ignore next */ []));
|
|
1062
|
+
}
|
|
1063
|
+
onClick() {
|
|
1064
|
+
this.window.open(this.url(), this.target());
|
|
1065
|
+
}
|
|
1066
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowOpenDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1067
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: WindowOpenDirective, isStandalone: true, selector: "[netwoWindowOpen]", inputs: { url: { classPropertyName: "url", publicName: "netwoWindowOpen", isSignal: true, isRequired: true, transformFunction: null }, target: { classPropertyName: "target", publicName: "target", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "onClick()" } }, ngImport: i0 }); }
|
|
1068
|
+
}
|
|
1069
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowOpenDirective, decorators: [{
|
|
1070
|
+
type: Directive,
|
|
1071
|
+
args: [{
|
|
1072
|
+
selector: '[netwoWindowOpen]',
|
|
1073
|
+
}]
|
|
1074
|
+
}], propDecorators: { url: [{ type: i0.Input, args: [{ isSignal: true, alias: "netwoWindowOpen", required: true }] }], target: [{ type: i0.Input, args: [{ isSignal: true, alias: "target", required: false }] }], onClick: [{
|
|
1075
|
+
type: HostListener,
|
|
1076
|
+
args: ['click']
|
|
1077
|
+
}] } });
|
|
1078
|
+
|
|
1079
|
+
function getDefaultDigitsInfo(value) {
|
|
1080
|
+
const hasCents = value % 1 !== 0;
|
|
1081
|
+
const digits = hasCents ? '1.2-2' : '1.0-0';
|
|
1082
|
+
return digits;
|
|
1083
|
+
}
|
|
1084
|
+
function formatCurrency(value, options) {
|
|
1085
|
+
return assertInjector(formatCurrency, options?.injector, () => {
|
|
1086
|
+
const currencyPipe = inject(CurrencyPipe$1);
|
|
1087
|
+
const currency = currencyPipe.transform(value, undefined, undefined, options?.digitsInfo ?? getDefaultDigitsInfo(value));
|
|
1088
|
+
if (options?.noIndicator) {
|
|
1089
|
+
const zeroValue = currencyPipe.transform(0, undefined, undefined, '1.0-0');
|
|
1090
|
+
const indicator = zeroValue?.slice(1) ?? '';
|
|
1091
|
+
return currency?.replace(indicator, '');
|
|
1092
|
+
}
|
|
1093
|
+
return currency ?? undefined;
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
let monthWord = undefined;
|
|
1098
|
+
function getMonthWord() {
|
|
1099
|
+
if (isNullable(monthWord)) {
|
|
1100
|
+
monthWord = new Intl.NumberFormat(navigator.language, {
|
|
1101
|
+
style: 'unit',
|
|
1102
|
+
unit: 'month',
|
|
1103
|
+
unitDisplay: 'long',
|
|
1104
|
+
})
|
|
1105
|
+
.formatToParts()
|
|
1106
|
+
.find((item) => item.type === 'unit')?.value;
|
|
1107
|
+
}
|
|
1108
|
+
return monthWord ?? '';
|
|
1109
|
+
}
|
|
1110
|
+
function formatMonthlyCurrency(value, options) {
|
|
1111
|
+
const { periodicity = 1, ...currencyOptions } = options ?? {};
|
|
1112
|
+
const fmtValue = formatCurrency(value, {
|
|
1113
|
+
...currencyOptions,
|
|
1114
|
+
noIndicator: false,
|
|
1115
|
+
});
|
|
1116
|
+
return `${fmtValue}/${periodicity > 1 ? periodicity : ''}${getMonthWord()}`;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
function createUnitFormatter({ coerce, fallback, rules, }) {
|
|
1120
|
+
let rulesValue;
|
|
1121
|
+
return function formatUnit(rawValue, options) {
|
|
1122
|
+
return assertInjector(formatUnit, options?.injector, () => {
|
|
1123
|
+
const resolve = resolverFn();
|
|
1124
|
+
const value = coerce?.(rawValue) ?? rawValue;
|
|
1125
|
+
rulesValue ??= rules();
|
|
1126
|
+
for (const rule of rulesValue) {
|
|
1127
|
+
const unit = rule.convert(value);
|
|
1128
|
+
if (rule.matches(unit)) {
|
|
1129
|
+
const fmtValue = rule.format(unit);
|
|
1130
|
+
return resolve(unit, fmtValue);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
return fallback(rawValue, value);
|
|
1134
|
+
});
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
function resolverFn() {
|
|
1138
|
+
const pluralPipe = inject(I18nPluralPipe);
|
|
1139
|
+
return (unit, fmtValue) => isString(fmtValue) ? fmtValue : pluralPipe.transform(unit, fmtValue);
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
class EnterZoneScheduler {
|
|
1143
|
+
constructor(ngZone, scheduler) {
|
|
1144
|
+
this.ngZone = ngZone;
|
|
1145
|
+
this.scheduler = scheduler;
|
|
1146
|
+
}
|
|
1147
|
+
schedule(...args) {
|
|
1148
|
+
return this.ngZone.run(() => this.scheduler.schedule.apply(this.scheduler, args));
|
|
1149
|
+
}
|
|
1150
|
+
now() {
|
|
1151
|
+
return this.scheduler.now();
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
class LeaveZoneScheduler {
|
|
1155
|
+
constructor(ngZone, scheduler) {
|
|
1156
|
+
this.ngZone = ngZone;
|
|
1157
|
+
this.scheduler = scheduler;
|
|
1158
|
+
}
|
|
1159
|
+
schedule(...args) {
|
|
1160
|
+
return this.ngZone.runOutsideAngular(() => this.scheduler.schedule.apply(this.scheduler, args));
|
|
1161
|
+
}
|
|
1162
|
+
now() {
|
|
1163
|
+
return this.scheduler.now();
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
function enterZone(ngZone) {
|
|
1167
|
+
return (source) => source.pipe(observeOn(new EnterZoneScheduler(ngZone, asapScheduler)));
|
|
1168
|
+
}
|
|
1169
|
+
function leaveZone(ngZone) {
|
|
1170
|
+
return (source) => source.pipe(observeOn(new LeaveZoneScheduler(ngZone, asapScheduler)));
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
function broadcastChannel(name, guard) {
|
|
1174
|
+
const destroyRef = inject(DestroyRef);
|
|
1175
|
+
const ngZone = inject(NgZone);
|
|
1176
|
+
const channel = new BroadcastChannel(name);
|
|
1177
|
+
const closed = signal(false, /* @ts-ignore */
|
|
1178
|
+
...(ngDevMode ? [{ debugName: "closed" }] : /* istanbul ignore next */ []));
|
|
1179
|
+
const events$ = new Subject();
|
|
1180
|
+
const messages$ = events$.pipe(map((msg) => msg.data), enterZone(ngZone));
|
|
1181
|
+
channel.onmessage = (evt) => {
|
|
1182
|
+
if (!isMessageEvent(evt, guard)) {
|
|
1183
|
+
console.error(`[BroadcastChannel:${name}:Listen] Received an invalid message:`, evt.data);
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1186
|
+
events$.next(evt);
|
|
1187
|
+
};
|
|
1188
|
+
const close = () => {
|
|
1189
|
+
channel.onmessage = null;
|
|
1190
|
+
channel.close();
|
|
1191
|
+
events$.complete();
|
|
1192
|
+
closed.set(true);
|
|
1193
|
+
};
|
|
1194
|
+
const listen = (fn) => {
|
|
1195
|
+
if (untracked(closed)) {
|
|
1196
|
+
console.warn(`[BroadcastChannel:${name}:Listen] Channel is closed.`);
|
|
1197
|
+
return noop;
|
|
1198
|
+
}
|
|
1199
|
+
const sub = messages$.subscribe((data) => fn(data));
|
|
1200
|
+
const unlisten = () => sub.unsubscribe();
|
|
1201
|
+
const unregister = destroyRef.onDestroy(unlisten);
|
|
1202
|
+
return () => {
|
|
1203
|
+
unlisten();
|
|
1204
|
+
unregister();
|
|
1205
|
+
};
|
|
1206
|
+
};
|
|
1207
|
+
const publish = (evt) => {
|
|
1208
|
+
if (untracked(closed)) {
|
|
1209
|
+
console.error(`[BroadcastChannel:${name}:Publish] Channel is closed.`);
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1212
|
+
channel.postMessage(evt);
|
|
1213
|
+
};
|
|
1214
|
+
destroyRef.onDestroy(close);
|
|
1215
|
+
return {
|
|
1216
|
+
close,
|
|
1217
|
+
closed: closed.asReadonly(),
|
|
1218
|
+
listen,
|
|
1219
|
+
messages$,
|
|
1220
|
+
publish,
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
function isMessageEvent(evt, guard) {
|
|
1224
|
+
return guard(evt.data);
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
class ScrollDataSource extends DataSource {
|
|
1228
|
+
constructor(ref, injector) {
|
|
1229
|
+
super();
|
|
1230
|
+
this.ref = ref;
|
|
1231
|
+
this.injector = injector;
|
|
1232
|
+
this._subscription = Subscription.EMPTY;
|
|
1233
|
+
this.data$ = toObservable(computed(() => this.ref.value().data), { injector: this.injector });
|
|
1234
|
+
}
|
|
1235
|
+
connect(collectionViewer) {
|
|
1236
|
+
this._subscription = collectionViewer.viewChange
|
|
1237
|
+
.pipe(takeUntilDestroyed(this.injector.get(DestroyRef)))
|
|
1238
|
+
.subscribe(({ start, end }) => this.ref.loadPagesInRange(start, end));
|
|
1239
|
+
return this.data$;
|
|
1240
|
+
}
|
|
1241
|
+
disconnect(_collectionViewer) {
|
|
1242
|
+
this._subscription.unsubscribe();
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
function isChunkError(src) {
|
|
1247
|
+
if (isError(src.error)) {
|
|
1248
|
+
const message = [src.error.name, src.error.message].join('\n');
|
|
1249
|
+
return /ChunkLoadError|Loading chunk \d+ failed|chunk[-\w]*\.js|dynamically imported module|Importing a module script failed/i.test(message);
|
|
1250
|
+
}
|
|
1251
|
+
return false;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
1255
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1256
|
+
function makeInjectionRunnable(fn, injector) {
|
|
1257
|
+
if (!injector)
|
|
1258
|
+
assertInInjectionContext(makeInjectionRunnable);
|
|
1259
|
+
injector = injector ?? inject(Injector);
|
|
1260
|
+
return (...args) => runInInjectionContext(injector, () => fn(...args));
|
|
1261
|
+
}
|
|
1262
|
+
function makeNonReactive(fn) {
|
|
1263
|
+
return (...args) => untracked(() => fn(...args));
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
function isTemplateRef(obj) {
|
|
1267
|
+
return obj instanceof TemplateRef;
|
|
1268
|
+
}
|
|
1269
|
+
function isComponentRef(obj) {
|
|
1270
|
+
return obj instanceof ComponentRef;
|
|
1271
|
+
}
|
|
1272
|
+
function isFunctionConstructor(value) {
|
|
1273
|
+
return (
|
|
1274
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1275
|
+
isFn(value) && !!value.prototype && value.prototype.constructor === value);
|
|
1276
|
+
}
|
|
1277
|
+
function isHttpResponse(error) {
|
|
1278
|
+
return error instanceof HttpResponse;
|
|
1279
|
+
}
|
|
1280
|
+
function isHttpErrorResponse(error) {
|
|
1281
|
+
return error instanceof HttpErrorResponse;
|
|
1282
|
+
}
|
|
1283
|
+
function isInjector(
|
|
1284
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1285
|
+
value) {
|
|
1286
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
|
|
1287
|
+
return value && typeof value.get === 'function';
|
|
1288
|
+
}
|
|
1289
|
+
function isResourceRef(
|
|
1290
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1291
|
+
value) {
|
|
1292
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
|
|
1293
|
+
return value && typeof value.hasValue === 'function';
|
|
1294
|
+
}
|
|
1295
|
+
function isNavigationStart(value) {
|
|
1296
|
+
return value instanceof NavigationStart;
|
|
1297
|
+
}
|
|
1298
|
+
function isNavigationEnd(value) {
|
|
1299
|
+
return value instanceof NavigationEnd;
|
|
1300
|
+
}
|
|
1301
|
+
function isNavigationError(value) {
|
|
1302
|
+
return value instanceof NavigationError;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1306
|
+
function createInjectDict(dict) {
|
|
1307
|
+
const injectFn = (selector) => {
|
|
1308
|
+
const injector = inject(Injector);
|
|
1309
|
+
return computed(() => runInInjectionContext(injector, () => buildInjectedDict(selector(), dict)));
|
|
1310
|
+
};
|
|
1311
|
+
const provideFn = () => Object.values(dict);
|
|
1312
|
+
return [injectFn, provideFn];
|
|
1313
|
+
}
|
|
1314
|
+
function buildInjectedDict(target, dict) {
|
|
1315
|
+
assertInInjectionContext(buildInjectedDict);
|
|
1316
|
+
return Object.entries(dict).reduce((res, [key, token]) => {
|
|
1317
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
1318
|
+
const injectFn = makeNonReactive(() => inject(token));
|
|
1319
|
+
return {
|
|
1320
|
+
...res,
|
|
1321
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1322
|
+
[key]: key === target ? injectFn() : undefined,
|
|
1323
|
+
};
|
|
1324
|
+
}, {});
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
function getCurrentInjector() {
|
|
1328
|
+
try {
|
|
1329
|
+
return inject(Injector);
|
|
1330
|
+
}
|
|
1331
|
+
catch {
|
|
1332
|
+
return undefined;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
function safeResourceValue(input, defaultValue) {
|
|
1337
|
+
return computed(() => input.hasValue() ? (input.value() ?? defaultValue) : defaultValue);
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
const OverlayPosition = [
|
|
1341
|
+
'bottom-center',
|
|
1342
|
+
'bottom-end',
|
|
1343
|
+
'bottom-start',
|
|
1344
|
+
'end-bottom',
|
|
1345
|
+
'end-center',
|
|
1346
|
+
'end-top',
|
|
1347
|
+
'start-bottom',
|
|
1348
|
+
'start-center',
|
|
1349
|
+
'start-top',
|
|
1350
|
+
'top-center',
|
|
1351
|
+
'top-end',
|
|
1352
|
+
'top-start',
|
|
1353
|
+
];
|
|
1354
|
+
const BOTTOM_CENTER_POSITION = {
|
|
1355
|
+
originX: 'center',
|
|
1356
|
+
originY: 'bottom',
|
|
1357
|
+
overlayX: 'center',
|
|
1358
|
+
overlayY: 'top',
|
|
1359
|
+
offsetY: 8,
|
|
1360
|
+
};
|
|
1361
|
+
const BOTTOM_END_POSITION = {
|
|
1362
|
+
originX: 'end',
|
|
1363
|
+
originY: 'bottom',
|
|
1364
|
+
overlayX: 'end',
|
|
1365
|
+
overlayY: 'top',
|
|
1366
|
+
offsetY: 8,
|
|
1367
|
+
};
|
|
1368
|
+
const BOTTOM_START_POSITION = {
|
|
1369
|
+
originX: 'start',
|
|
1370
|
+
originY: 'bottom',
|
|
1371
|
+
overlayX: 'start',
|
|
1372
|
+
overlayY: 'top',
|
|
1373
|
+
offsetY: 8,
|
|
1374
|
+
};
|
|
1375
|
+
const END_BOTTOM_POSITION = {
|
|
1376
|
+
originX: 'end',
|
|
1377
|
+
originY: 'bottom',
|
|
1378
|
+
overlayX: 'start',
|
|
1379
|
+
overlayY: 'bottom',
|
|
1380
|
+
offsetX: 8,
|
|
1381
|
+
};
|
|
1382
|
+
const END_CENTER_POSITION = {
|
|
1383
|
+
originX: 'end',
|
|
1384
|
+
originY: 'center',
|
|
1385
|
+
overlayX: 'start',
|
|
1386
|
+
overlayY: 'center',
|
|
1387
|
+
offsetX: 8,
|
|
1388
|
+
};
|
|
1389
|
+
const END_TOP_POSITION = {
|
|
1390
|
+
originX: 'end',
|
|
1391
|
+
originY: 'top',
|
|
1392
|
+
overlayX: 'start',
|
|
1393
|
+
overlayY: 'top',
|
|
1394
|
+
offsetX: 8,
|
|
1395
|
+
};
|
|
1396
|
+
const START_BOTTOM_POSITION = {
|
|
1397
|
+
originX: 'start',
|
|
1398
|
+
originY: 'bottom',
|
|
1399
|
+
overlayX: 'end',
|
|
1400
|
+
overlayY: 'bottom',
|
|
1401
|
+
offsetX: -8,
|
|
1402
|
+
};
|
|
1403
|
+
const START_CENTER_POSITION = {
|
|
1404
|
+
originX: 'start',
|
|
1405
|
+
originY: 'center',
|
|
1406
|
+
overlayX: 'end',
|
|
1407
|
+
overlayY: 'center',
|
|
1408
|
+
offsetX: -8,
|
|
1409
|
+
};
|
|
1410
|
+
const START_TOP_POSITION = {
|
|
1411
|
+
originX: 'start',
|
|
1412
|
+
originY: 'top',
|
|
1413
|
+
overlayX: 'end',
|
|
1414
|
+
overlayY: 'top',
|
|
1415
|
+
offsetX: -8,
|
|
1416
|
+
};
|
|
1417
|
+
const TOP_CENTER_POSITION = {
|
|
1418
|
+
originX: 'center',
|
|
1419
|
+
originY: 'top',
|
|
1420
|
+
overlayX: 'center',
|
|
1421
|
+
overlayY: 'bottom',
|
|
1422
|
+
offsetY: -8,
|
|
1423
|
+
};
|
|
1424
|
+
const TOP_END_POSITION = {
|
|
1425
|
+
originX: 'end',
|
|
1426
|
+
originY: 'top',
|
|
1427
|
+
overlayX: 'end',
|
|
1428
|
+
overlayY: 'bottom',
|
|
1429
|
+
offsetY: -8,
|
|
1430
|
+
};
|
|
1431
|
+
const TOP_START_POSITION = {
|
|
1432
|
+
originX: 'start',
|
|
1433
|
+
originY: 'top',
|
|
1434
|
+
overlayX: 'start',
|
|
1435
|
+
overlayY: 'bottom',
|
|
1436
|
+
offsetY: -8,
|
|
1437
|
+
};
|
|
1438
|
+
const OVERLAY_POSITIONS = {
|
|
1439
|
+
'bottom-center': [BOTTOM_CENTER_POSITION, TOP_CENTER_POSITION],
|
|
1440
|
+
'bottom-end': [BOTTOM_END_POSITION, TOP_END_POSITION],
|
|
1441
|
+
'bottom-start': [BOTTOM_START_POSITION, TOP_START_POSITION],
|
|
1442
|
+
'end-bottom': [END_BOTTOM_POSITION, START_BOTTOM_POSITION],
|
|
1443
|
+
'end-center': [END_CENTER_POSITION, START_CENTER_POSITION],
|
|
1444
|
+
'end-top': [END_TOP_POSITION, START_TOP_POSITION],
|
|
1445
|
+
'start-bottom': [START_BOTTOM_POSITION, END_BOTTOM_POSITION],
|
|
1446
|
+
'start-center': [START_CENTER_POSITION, END_CENTER_POSITION],
|
|
1447
|
+
'start-top': [START_TOP_POSITION, END_TOP_POSITION],
|
|
1448
|
+
'top-center': [TOP_CENTER_POSITION, BOTTOM_CENTER_POSITION],
|
|
1449
|
+
'top-end': [TOP_END_POSITION, BOTTOM_END_POSITION],
|
|
1450
|
+
'top-start': [TOP_START_POSITION, BOTTOM_START_POSITION],
|
|
1451
|
+
};
|
|
1452
|
+
|
|
1453
|
+
function provideExistingOrFallback(clazz) {
|
|
1454
|
+
const INTERNAL = new InjectionToken('');
|
|
1455
|
+
return [
|
|
1456
|
+
{ provide: INTERNAL, useClass: clazz },
|
|
1457
|
+
{
|
|
1458
|
+
provide: clazz,
|
|
1459
|
+
useFactory: () =>
|
|
1460
|
+
// select token in the parent injectors
|
|
1461
|
+
inject(clazz, { skipSelf: true, optional: true }) ??
|
|
1462
|
+
// otherwise use internal token in self injector
|
|
1463
|
+
inject(INTERNAL, { self: true }),
|
|
1464
|
+
},
|
|
1465
|
+
];
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
function data(...items) {
|
|
1469
|
+
return Object.assign({}, ...items);
|
|
1470
|
+
}
|
|
1471
|
+
function resolveData(...items) {
|
|
1472
|
+
return Object.assign({}, ...items);
|
|
1473
|
+
}
|
|
1474
|
+
function dataEntry(key, value) {
|
|
1475
|
+
return { [key]: value };
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
const IsUrlSubset = {
|
|
1479
|
+
matrixParams: 'subset',
|
|
1480
|
+
queryParams: 'ignored',
|
|
1481
|
+
paths: 'subset',
|
|
1482
|
+
fragment: 'ignored',
|
|
1483
|
+
};
|
|
1484
|
+
const IsUrlExact = {
|
|
1485
|
+
matrixParams: 'exact',
|
|
1486
|
+
queryParams: 'ignored',
|
|
1487
|
+
paths: 'exact',
|
|
1488
|
+
fragment: 'ignored',
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
function resolveAsync(value) {
|
|
1492
|
+
if (isObservable(value))
|
|
1493
|
+
return firstValueFrom(value);
|
|
1494
|
+
if (isPromise(value))
|
|
1495
|
+
return value;
|
|
1496
|
+
return Promise.resolve(value);
|
|
1497
|
+
}
|
|
1498
|
+
function composeGuards(...firstGroup) {
|
|
1499
|
+
const groups = [firstGroup];
|
|
1500
|
+
const composedGuard = (async (...args) => {
|
|
1501
|
+
const injector = inject(Injector);
|
|
1502
|
+
for (const group of groups) {
|
|
1503
|
+
const promises = group.map((guard) => {
|
|
1504
|
+
const fn = runInInjectionContext(injector, () =>
|
|
1505
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any
|
|
1506
|
+
guard(...args));
|
|
1507
|
+
return resolveAsync(fn);
|
|
1508
|
+
});
|
|
1509
|
+
const results = await Promise.all(promises);
|
|
1510
|
+
const redirect = results.find((item) => item instanceof UrlTree || item instanceof RedirectCommand);
|
|
1511
|
+
if (redirect)
|
|
1512
|
+
return redirect;
|
|
1513
|
+
if (results.some((r) => r === false))
|
|
1514
|
+
return false;
|
|
1515
|
+
}
|
|
1516
|
+
return true;
|
|
1517
|
+
});
|
|
1518
|
+
composedGuard.then = (...group) => {
|
|
1519
|
+
groups.push(group);
|
|
1520
|
+
return composedGuard;
|
|
1521
|
+
};
|
|
1522
|
+
return composedGuard;
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
function useScreenSize(injector) {
|
|
1526
|
+
if (!injector)
|
|
1527
|
+
assertInInjectionContext(useScreenSize);
|
|
1528
|
+
injector ??= inject(Injector);
|
|
1529
|
+
const breakpointObserver = injector.get(BreakpointObserver);
|
|
1530
|
+
const state = toSignal(breakpointObserver.observe([
|
|
1531
|
+
Breakpoints.XSmall,
|
|
1532
|
+
Breakpoints.Small,
|
|
1533
|
+
Breakpoints.Medium,
|
|
1534
|
+
Breakpoints.Large,
|
|
1535
|
+
Breakpoints.XLarge,
|
|
1536
|
+
]), {
|
|
1537
|
+
initialValue: { breakpoints: {}, matches: false },
|
|
1538
|
+
injector,
|
|
1539
|
+
});
|
|
1540
|
+
return computed(({ breakpoints } = state()) => ({
|
|
1541
|
+
match: getBreakpointMatch(breakpoints),
|
|
1542
|
+
breakpoints: {
|
|
1543
|
+
[Breakpoints.XSmall]: breakpoints[Breakpoints.XSmall] ?? false,
|
|
1544
|
+
[Breakpoints.Small]: breakpoints[Breakpoints.Small] ?? false,
|
|
1545
|
+
[Breakpoints.Medium]: breakpoints[Breakpoints.Medium] ?? false,
|
|
1546
|
+
[Breakpoints.Large]: breakpoints[Breakpoints.Large] ?? false,
|
|
1547
|
+
[Breakpoints.XLarge]: breakpoints[Breakpoints.XLarge] ?? false,
|
|
1548
|
+
},
|
|
1549
|
+
}));
|
|
1550
|
+
}
|
|
1551
|
+
function getBreakpointMatch(breakpoints) {
|
|
1552
|
+
const match = Object.entries(breakpoints).find(([_, value]) => value)?.[0];
|
|
1553
|
+
assertNonNullable(match, 'match');
|
|
1554
|
+
return match;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
let taskId = 0;
|
|
1558
|
+
// Main function for defining a task effect
|
|
1559
|
+
function taskEffect(conf) {
|
|
1560
|
+
// Be sure to execute method in a valid context injection
|
|
1561
|
+
if (!conf.injector) {
|
|
1562
|
+
assertInInjectionContext(taskEffect);
|
|
1563
|
+
}
|
|
1564
|
+
const { complete, error, finalize: finalize$1, injector: sourceInjector = inject(Injector), operator = switchMap, start, success, task, } = conf;
|
|
1565
|
+
const globalLoading = signal(false, /* @ts-ignore */
|
|
1566
|
+
...(ngDevMode ? [{ debugName: "globalLoading" }] : /* istanbul ignore next */ []));
|
|
1567
|
+
// Streams to track task origins and events
|
|
1568
|
+
const origin$ = new Subject();
|
|
1569
|
+
const event$ = new Subject();
|
|
1570
|
+
// Map to store pending task origins grouped by taskId
|
|
1571
|
+
const pendingOrigins = new Map();
|
|
1572
|
+
// Add a new origin to the pendingOrigins map
|
|
1573
|
+
const collectOrigin = (origin) => {
|
|
1574
|
+
if (!pendingOrigins.has(origin.taskId)) {
|
|
1575
|
+
pendingOrigins.set(origin.taskId, new Set());
|
|
1576
|
+
}
|
|
1577
|
+
pendingOrigins.get(origin.taskId)?.add(origin);
|
|
1578
|
+
};
|
|
1579
|
+
// Remove an origin from the pendingOrigins map
|
|
1580
|
+
const uncollectOrigin = (origin) => {
|
|
1581
|
+
const orgins = pendingOrigins.get(origin.taskId);
|
|
1582
|
+
orgins?.delete(origin);
|
|
1583
|
+
if (orgins?.size === 0) {
|
|
1584
|
+
pendingOrigins.delete(origin.taskId);
|
|
1585
|
+
}
|
|
1586
|
+
};
|
|
1587
|
+
// Cancel all pending origins for a given taskId and remove them from the queue
|
|
1588
|
+
const flushPendingOrigins = (taskId) => {
|
|
1589
|
+
pendingOrigins.get(taskId)?.forEach((origin) => event$.next({
|
|
1590
|
+
cancel: {},
|
|
1591
|
+
origin,
|
|
1592
|
+
type: 'cancel',
|
|
1593
|
+
}));
|
|
1594
|
+
pendingOrigins.delete(taskId);
|
|
1595
|
+
if (pendingOrigins.size === 0) {
|
|
1596
|
+
globalLoading.set(false);
|
|
1597
|
+
}
|
|
1598
|
+
};
|
|
1599
|
+
rxMethod(operator((origin, index) => {
|
|
1600
|
+
globalLoading.set(true);
|
|
1601
|
+
start?.(origin.input);
|
|
1602
|
+
// Used to detect if the task emitted any value before completing
|
|
1603
|
+
const result = new Array();
|
|
1604
|
+
return from(task(origin.input, index)).pipe(tap({
|
|
1605
|
+
next: (value) => {
|
|
1606
|
+
// Store success value
|
|
1607
|
+
result.push(value);
|
|
1608
|
+
success?.(value, origin.input);
|
|
1609
|
+
},
|
|
1610
|
+
error: (err) => {
|
|
1611
|
+
flushPendingOrigins(origin.taskId);
|
|
1612
|
+
event$.next({
|
|
1613
|
+
error: { err },
|
|
1614
|
+
origin,
|
|
1615
|
+
type: 'error',
|
|
1616
|
+
});
|
|
1617
|
+
error?.(err, origin.input);
|
|
1618
|
+
finalize$1?.(origin.input);
|
|
1619
|
+
},
|
|
1620
|
+
complete: () => {
|
|
1621
|
+
flushPendingOrigins(origin.taskId);
|
|
1622
|
+
event$.next({
|
|
1623
|
+
complete: { result },
|
|
1624
|
+
origin,
|
|
1625
|
+
type: 'complete',
|
|
1626
|
+
});
|
|
1627
|
+
complete?.(result, origin.input);
|
|
1628
|
+
finalize$1?.(origin.input);
|
|
1629
|
+
},
|
|
1630
|
+
subscribe: () => {
|
|
1631
|
+
// When subscribing, mark the origin as "in progress"
|
|
1632
|
+
// (remove from pending set to avoid premature cancel)
|
|
1633
|
+
uncollectOrigin(origin);
|
|
1634
|
+
},
|
|
1635
|
+
unsubscribe: () => {
|
|
1636
|
+
// If unsubscribed before completion, mark origin as pending
|
|
1637
|
+
// (it may be flushed/cancelled later)
|
|
1638
|
+
collectOrigin(origin);
|
|
1639
|
+
},
|
|
1640
|
+
}), catchError(() => EMPTY));
|
|
1641
|
+
}), { injector: sourceInjector })(origin$.pipe(tap(collectOrigin)), {
|
|
1642
|
+
injector: sourceInjector,
|
|
1643
|
+
});
|
|
1644
|
+
sourceInjector.get(DestroyRef).onDestroy(() => {
|
|
1645
|
+
origin$.complete();
|
|
1646
|
+
event$.complete();
|
|
1647
|
+
pendingOrigins.clear();
|
|
1648
|
+
});
|
|
1649
|
+
function createCallerFn() {
|
|
1650
|
+
return (input, callerConf) => {
|
|
1651
|
+
const currentTaskId = taskId++;
|
|
1652
|
+
const taskLoading = signal(false, /* @ts-ignore */
|
|
1653
|
+
...(ngDevMode ? [{ debugName: "taskLoading" }] : /* istanbul ignore next */ []));
|
|
1654
|
+
// Emits when the input stream has completed (signal used to trigger report evaluation)
|
|
1655
|
+
const inputCompleted$ = new Subject();
|
|
1656
|
+
// Holds the final result of the task (last emission is replayed to new subscribers)
|
|
1657
|
+
const report$ = new ReplaySubject(1);
|
|
1658
|
+
const instanceInjector = callerConf?.injector ?? getCurrentInjector() ?? sourceInjector;
|
|
1659
|
+
const destroyRef = instanceInjector.get(DestroyRef);
|
|
1660
|
+
const sub = combineLatest([
|
|
1661
|
+
// Buffers all inputs that were sent for this taskId
|
|
1662
|
+
origin$.pipe(scan((arr, value) => [...arr, value], new Array())),
|
|
1663
|
+
// Buffers all task events (complete, error, cancel, etc.)
|
|
1664
|
+
event$.pipe(filter((event) => event.origin.taskId === currentTaskId), scan((arr, value) => [...arr, value], new Array())),
|
|
1665
|
+
inputCompleted$,
|
|
1666
|
+
])
|
|
1667
|
+
.pipe(takeUntilDestroyed(destroyRef))
|
|
1668
|
+
.subscribe(([origins, events]) => {
|
|
1669
|
+
// Report is only emitted when every input has a corresponding event
|
|
1670
|
+
if (origins.length === events.length) {
|
|
1671
|
+
report$.next(createReport(events));
|
|
1672
|
+
report$.complete();
|
|
1673
|
+
sub.unsubscribe();
|
|
1674
|
+
}
|
|
1675
|
+
});
|
|
1676
|
+
const emitOrigin = (value) => {
|
|
1677
|
+
taskLoading.set(true);
|
|
1678
|
+
origin$.next(createOrigin(value, currentTaskId));
|
|
1679
|
+
};
|
|
1680
|
+
if (isObservable(input)) {
|
|
1681
|
+
sub.add(input
|
|
1682
|
+
.pipe(tap({
|
|
1683
|
+
next: (value) => emitOrigin(value),
|
|
1684
|
+
error: (err) => report$.error(err),
|
|
1685
|
+
finalize: () => inputCompleted$.next(),
|
|
1686
|
+
}), takeUntilDestroyed(destroyRef))
|
|
1687
|
+
.subscribe());
|
|
1688
|
+
}
|
|
1689
|
+
else {
|
|
1690
|
+
emitOrigin(input);
|
|
1691
|
+
inputCompleted$.next();
|
|
1692
|
+
}
|
|
1693
|
+
sub.add(report$.pipe(finalize(() => taskLoading.set(false))).subscribe());
|
|
1694
|
+
const cancel = () => {
|
|
1695
|
+
inputCompleted$.complete();
|
|
1696
|
+
report$.complete();
|
|
1697
|
+
sub.unsubscribe();
|
|
1698
|
+
};
|
|
1699
|
+
destroyRef.onDestroy(cancel);
|
|
1700
|
+
return {
|
|
1701
|
+
loading: taskLoading,
|
|
1702
|
+
afterTask$: report$.pipe(mapTaskSuccess()),
|
|
1703
|
+
afterFirstTask$: report$.pipe(mapTaskFirstSuccess()),
|
|
1704
|
+
report$: report$.asObservable(),
|
|
1705
|
+
cancel,
|
|
1706
|
+
};
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
// function to create a reference to a task
|
|
1710
|
+
const callerFn = createCallerFn();
|
|
1711
|
+
callerFn.loading = globalLoading;
|
|
1712
|
+
return callerFn;
|
|
1713
|
+
}
|
|
1714
|
+
class TaskError extends Error {
|
|
1715
|
+
constructor(message, causes) {
|
|
1716
|
+
super(message);
|
|
1717
|
+
this.causes = causes;
|
|
1718
|
+
this.name = 'TaskError';
|
|
1719
|
+
this.cause = causes[0];
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
function mapTaskSuccess() {
|
|
1723
|
+
return mergeMap((report) => {
|
|
1724
|
+
if (report.success) {
|
|
1725
|
+
const successValue = report.events.flatMap((event) => event.complete?.result ?? []);
|
|
1726
|
+
return of(successValue);
|
|
1727
|
+
}
|
|
1728
|
+
if (report.failed) {
|
|
1729
|
+
const causes = report.events
|
|
1730
|
+
.map((event) => event.error?.err)
|
|
1731
|
+
.filter(isNotNullable);
|
|
1732
|
+
return throwError(() => new TaskError('TaskEffect failed', causes));
|
|
1733
|
+
}
|
|
1734
|
+
return EMPTY;
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
function mapTaskFirstSuccess() {
|
|
1738
|
+
return mergeMap((report) => {
|
|
1739
|
+
if (report.success) {
|
|
1740
|
+
const successValue = report.events.flatMap((event) => event.complete?.result ?? []);
|
|
1741
|
+
return of(successValue[0]);
|
|
1742
|
+
}
|
|
1743
|
+
if (report.failed) {
|
|
1744
|
+
const events = report.events.filter((event) => event.error);
|
|
1745
|
+
return throwError(() => events[0]?.error?.err);
|
|
1746
|
+
}
|
|
1747
|
+
return EMPTY;
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1750
|
+
function createOrigin(input, taskId) {
|
|
1751
|
+
return { input, taskId };
|
|
1752
|
+
}
|
|
1753
|
+
function createReport(events) {
|
|
1754
|
+
const failed = events.some((item) => item.type === 'error');
|
|
1755
|
+
const completed = events.some((item) => item.type === 'complete');
|
|
1756
|
+
const cancelled = events.every((item) => item.type === 'cancel');
|
|
1757
|
+
return {
|
|
1758
|
+
events,
|
|
1759
|
+
failed,
|
|
1760
|
+
completed,
|
|
1761
|
+
cancelled,
|
|
1762
|
+
success: completed && !failed,
|
|
1763
|
+
};
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
class TimeUtils {
|
|
1767
|
+
constructor(hours, minutes) {
|
|
1768
|
+
this.hours = hours;
|
|
1769
|
+
this.minutes = minutes;
|
|
1770
|
+
this.hours = Math.max(Math.min(this.hours, 23), 0);
|
|
1771
|
+
this.minutes = Math.max(Math.min(this.minutes, 59), 0);
|
|
1772
|
+
}
|
|
1773
|
+
static of(input) {
|
|
1774
|
+
if (isString(input)) {
|
|
1775
|
+
const [hours, minutes] = input.split(':');
|
|
1776
|
+
return new TimeUtils(Number(hours), Number(minutes));
|
|
1777
|
+
}
|
|
1778
|
+
if (input instanceof Date) {
|
|
1779
|
+
input = DateTime.fromJSDate(input);
|
|
1780
|
+
}
|
|
1781
|
+
if (isObject(input) && 'hours' in input && 'minutes' in input) {
|
|
1782
|
+
return new TimeUtils(input.hours, input.minutes);
|
|
1783
|
+
}
|
|
1784
|
+
return new TimeUtils(input.hour, input.minute);
|
|
1785
|
+
}
|
|
1786
|
+
into() {
|
|
1787
|
+
return {
|
|
1788
|
+
hours: this.hours,
|
|
1789
|
+
minutes: this.minutes,
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1792
|
+
intoRaw() {
|
|
1793
|
+
return [this.hours, this.minutes]
|
|
1794
|
+
.map((num) => num2digit(num))
|
|
1795
|
+
.join(':');
|
|
1796
|
+
}
|
|
1797
|
+
intoDateTime(date) {
|
|
1798
|
+
const base = date ? DateTime.fromJSDate(date) : DateTime.now();
|
|
1799
|
+
return base.set({
|
|
1800
|
+
hour: this.hours,
|
|
1801
|
+
minute: this.minutes,
|
|
1802
|
+
second: 0,
|
|
1803
|
+
millisecond: 0,
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
isAfter(target) {
|
|
1807
|
+
const d1 = this.intoDateTime();
|
|
1808
|
+
const d2 = target.intoDateTime();
|
|
1809
|
+
return d1 > d2;
|
|
1810
|
+
}
|
|
1811
|
+
isAfterOrEq(target) {
|
|
1812
|
+
return this.isAfter(target) || this.isSame(target);
|
|
1813
|
+
}
|
|
1814
|
+
isBefore(target) {
|
|
1815
|
+
const d1 = this.intoDateTime();
|
|
1816
|
+
const d2 = target.intoDateTime();
|
|
1817
|
+
return d1 < d2;
|
|
1818
|
+
}
|
|
1819
|
+
isBeforeOrEq(target) {
|
|
1820
|
+
return this.isBefore(target) || this.isSame(target);
|
|
1821
|
+
}
|
|
1822
|
+
isSame(target) {
|
|
1823
|
+
const d1 = this.intoDateTime();
|
|
1824
|
+
const d2 = target.intoDateTime();
|
|
1825
|
+
return d1.equals(d2);
|
|
1826
|
+
}
|
|
1827
|
+
add(target) {
|
|
1828
|
+
const d1 = this.intoDateTime();
|
|
1829
|
+
const d2 = target.into();
|
|
1830
|
+
return TimeUtils.of(d1.plus({ hours: d2.hours, minutes: d2.minutes }));
|
|
1831
|
+
}
|
|
1832
|
+
subtract(target) {
|
|
1833
|
+
const d1 = this.intoDateTime();
|
|
1834
|
+
const d2 = target.into();
|
|
1835
|
+
return TimeUtils.of(d1.minus({ hours: d2.hours, minutes: d2.minutes }));
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
function triggerFileDownload(file, options = {}) {
|
|
1840
|
+
return assertInjector(triggerFileDownload, options.injector, () => {
|
|
1841
|
+
const window = injectWindow();
|
|
1842
|
+
const { target = '_self' } = options;
|
|
1843
|
+
const link = window.document.createElement('a');
|
|
1844
|
+
const url = window.URL.createObjectURL(file);
|
|
1845
|
+
try {
|
|
1846
|
+
link.href = url;
|
|
1847
|
+
link.setAttribute('target', target);
|
|
1848
|
+
link.setAttribute('download', file.name);
|
|
1849
|
+
window.document.body.appendChild(link);
|
|
1850
|
+
link.click();
|
|
1851
|
+
}
|
|
1852
|
+
finally {
|
|
1853
|
+
window.URL.revokeObjectURL(url);
|
|
1854
|
+
link.parentNode?.removeChild(link);
|
|
1855
|
+
}
|
|
1856
|
+
});
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
const skipForFragmentAndQueryChange = {
|
|
1860
|
+
onViewTransitionCreated: ({ transition, to }) => {
|
|
1861
|
+
const router = inject(Router);
|
|
1862
|
+
const toTree = createUrlTreeFromSnapshot(to, []);
|
|
1863
|
+
// Skip the transition if the only thing changing is the fragment and queryParams
|
|
1864
|
+
if (router.isActive(toTree, IsUrlExact)) {
|
|
1865
|
+
transition.skipTransition();
|
|
1866
|
+
}
|
|
1867
|
+
},
|
|
1868
|
+
};
|
|
1869
|
+
|
|
1870
|
+
let _appInjector = null;
|
|
1871
|
+
function getRootInjector() {
|
|
1872
|
+
if (!_appInjector) {
|
|
1873
|
+
throw new Error('App injector has not been set. Call setRootInjector() from the application bootstrap.');
|
|
1874
|
+
}
|
|
1875
|
+
return _appInjector;
|
|
1876
|
+
}
|
|
1877
|
+
function setRootInjector(injector) {
|
|
1878
|
+
_appInjector = injector;
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
class AddressPipe {
|
|
1882
|
+
transform(customer) {
|
|
1883
|
+
return formatAddress(customer);
|
|
1884
|
+
}
|
|
1885
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AddressPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1886
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: AddressPipe, isStandalone: true, name: "address" }); }
|
|
1887
|
+
}
|
|
1888
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AddressPipe, decorators: [{
|
|
1889
|
+
type: Pipe,
|
|
1890
|
+
args: [{ name: 'address' }]
|
|
1891
|
+
}] });
|
|
1892
|
+
|
|
1893
|
+
class DiffOfArrPipe {
|
|
1894
|
+
transform(arr1, arr2, comparer) {
|
|
1895
|
+
return diff(arr1, arr2, comparer);
|
|
1896
|
+
}
|
|
1897
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DiffOfArrPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1898
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: DiffOfArrPipe, isStandalone: true, name: "diffOfArr" }); }
|
|
1899
|
+
}
|
|
1900
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DiffOfArrPipe, decorators: [{
|
|
1901
|
+
type: Pipe,
|
|
1902
|
+
args: [{ name: 'diffOfArr' }]
|
|
1903
|
+
}] });
|
|
1904
|
+
|
|
1905
|
+
class FilterOfArrPipe {
|
|
1906
|
+
transform(items, predicate, ...args) {
|
|
1907
|
+
return items.filter((item) => predicate(item, ...args));
|
|
1908
|
+
}
|
|
1909
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: FilterOfArrPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1910
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: FilterOfArrPipe, isStandalone: true, name: "filterOfArr" }); }
|
|
1911
|
+
}
|
|
1912
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: FilterOfArrPipe, decorators: [{
|
|
1913
|
+
type: Pipe,
|
|
1914
|
+
args: [{ name: 'filterOfArr' }]
|
|
1915
|
+
}] });
|
|
1916
|
+
|
|
1917
|
+
class GroupByOfArrPipe {
|
|
1918
|
+
transform(items, keyGetter) {
|
|
1919
|
+
return groupBy(items, keyGetter);
|
|
1920
|
+
}
|
|
1921
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GroupByOfArrPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1922
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: GroupByOfArrPipe, isStandalone: true, name: "groupByOfArr" }); }
|
|
1923
|
+
}
|
|
1924
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GroupByOfArrPipe, decorators: [{
|
|
1925
|
+
type: Pipe,
|
|
1926
|
+
args: [{ name: 'groupByOfArr' }]
|
|
1927
|
+
}] });
|
|
1928
|
+
|
|
1929
|
+
class JoinOfArrPipe {
|
|
1930
|
+
transform(items, separator) {
|
|
1931
|
+
return items.join(separator);
|
|
1932
|
+
}
|
|
1933
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JoinOfArrPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1934
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: JoinOfArrPipe, isStandalone: true, name: "joinOfArr" }); }
|
|
1935
|
+
}
|
|
1936
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: JoinOfArrPipe, decorators: [{
|
|
1937
|
+
type: Pipe,
|
|
1938
|
+
args: [{ name: 'joinOfArr' }]
|
|
1939
|
+
}] });
|
|
1940
|
+
|
|
1941
|
+
class MapOfArrPipe {
|
|
1942
|
+
transform(items, callbackfn) {
|
|
1943
|
+
return items.map((item, index, array) => callbackfn(item, index, array));
|
|
1944
|
+
}
|
|
1945
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MapOfArrPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1946
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: MapOfArrPipe, isStandalone: true, name: "mapOfArr" }); }
|
|
1947
|
+
}
|
|
1948
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MapOfArrPipe, decorators: [{
|
|
1949
|
+
type: Pipe,
|
|
1950
|
+
args: [{ name: 'mapOfArr' }]
|
|
1951
|
+
}] });
|
|
1952
|
+
|
|
1953
|
+
class PluckOfArrPipe {
|
|
1954
|
+
transform(items, key) {
|
|
1955
|
+
return items.map((item) => item[key]);
|
|
1956
|
+
}
|
|
1957
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PluckOfArrPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1958
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: PluckOfArrPipe, isStandalone: true, name: "pluckOfArr" }); }
|
|
1959
|
+
}
|
|
1960
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PluckOfArrPipe, decorators: [{
|
|
1961
|
+
type: Pipe,
|
|
1962
|
+
args: [{ name: 'pluckOfArr' }]
|
|
1963
|
+
}] });
|
|
1964
|
+
|
|
1965
|
+
class SortOfArrPipe {
|
|
1966
|
+
transform(items, sortfn) {
|
|
1967
|
+
return [...items].sort((a, b) => sortfn(a, b));
|
|
1968
|
+
}
|
|
1969
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SortOfArrPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1970
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: SortOfArrPipe, isStandalone: true, name: "sortOfArr" }); }
|
|
1971
|
+
}
|
|
1972
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SortOfArrPipe, decorators: [{
|
|
1973
|
+
type: Pipe,
|
|
1974
|
+
args: [{ name: 'sortOfArr' }]
|
|
1975
|
+
}] });
|
|
1976
|
+
|
|
1977
|
+
class CapitalizePipe {
|
|
1978
|
+
transform(value) {
|
|
1979
|
+
return value && capitalize(value);
|
|
1980
|
+
}
|
|
1981
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CapitalizePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1982
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: CapitalizePipe, isStandalone: true, name: "capitalize" }); }
|
|
1983
|
+
}
|
|
1984
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CapitalizePipe, decorators: [{
|
|
1985
|
+
type: Pipe,
|
|
1986
|
+
args: [{ name: 'capitalize' }]
|
|
1987
|
+
}] });
|
|
1988
|
+
|
|
1989
|
+
class CurrencyPipe {
|
|
1990
|
+
constructor() {
|
|
1991
|
+
this.injector = inject(Injector);
|
|
1992
|
+
}
|
|
1993
|
+
transform(value, options) {
|
|
1994
|
+
return isNotNullable(value)
|
|
1995
|
+
? formatCurrency(value, {
|
|
1996
|
+
injector: this.injector,
|
|
1997
|
+
...options,
|
|
1998
|
+
})
|
|
1999
|
+
: undefined;
|
|
2000
|
+
}
|
|
2001
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CurrencyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2002
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: CurrencyPipe, isStandalone: true, name: "currency" }); }
|
|
2003
|
+
}
|
|
2004
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CurrencyPipe, decorators: [{
|
|
2005
|
+
type: Pipe,
|
|
2006
|
+
args: [{ name: 'currency' }]
|
|
2007
|
+
}] });
|
|
2008
|
+
|
|
2009
|
+
class FileSizePipe {
|
|
2010
|
+
transform(value) {
|
|
2011
|
+
return formatFileSize(value);
|
|
2012
|
+
}
|
|
2013
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: FileSizePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2014
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: FileSizePipe, isStandalone: true, name: "fileSize" }); }
|
|
2015
|
+
}
|
|
2016
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: FileSizePipe, decorators: [{
|
|
2017
|
+
type: Pipe,
|
|
2018
|
+
args: [{ name: 'fileSize' }]
|
|
2019
|
+
}] });
|
|
2020
|
+
|
|
2021
|
+
class FrenchPhoneNumberPipe {
|
|
2022
|
+
transform(value) {
|
|
2023
|
+
return formatFrenchPhoneNumber(value);
|
|
2024
|
+
}
|
|
2025
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: FrenchPhoneNumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2026
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: FrenchPhoneNumberPipe, isStandalone: true, name: "frenchPhoneNumber" }); }
|
|
2027
|
+
}
|
|
2028
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: FrenchPhoneNumberPipe, decorators: [{
|
|
2029
|
+
type: Pipe,
|
|
2030
|
+
args: [{ name: 'frenchPhoneNumber' }]
|
|
2031
|
+
}] });
|
|
2032
|
+
|
|
2033
|
+
function keyIn(value, key) {
|
|
2034
|
+
return key in value;
|
|
2035
|
+
}
|
|
2036
|
+
class KeyInPipe {
|
|
2037
|
+
transform(value, key) {
|
|
2038
|
+
return keyIn(value, key);
|
|
2039
|
+
}
|
|
2040
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: KeyInPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2041
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: KeyInPipe, isStandalone: true, name: "keyIn" }); }
|
|
2042
|
+
}
|
|
2043
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: KeyInPipe, decorators: [{
|
|
2044
|
+
type: Pipe,
|
|
2045
|
+
args: [{ name: 'keyIn' }]
|
|
2046
|
+
}] });
|
|
2047
|
+
|
|
2048
|
+
class LinkifyPipe {
|
|
2049
|
+
transform(value, options = {}) {
|
|
2050
|
+
return linkify(value, options);
|
|
2051
|
+
}
|
|
2052
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: LinkifyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2053
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: LinkifyPipe, isStandalone: true, name: "linkify" }); }
|
|
2054
|
+
}
|
|
2055
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: LinkifyPipe, decorators: [{
|
|
2056
|
+
type: Pipe,
|
|
2057
|
+
args: [{ name: 'linkify' }]
|
|
2058
|
+
}] });
|
|
2059
|
+
|
|
2060
|
+
/**
|
|
2061
|
+
* Maps object to an arbitrary result through a mapper function
|
|
2062
|
+
*
|
|
2063
|
+
* Example
|
|
2064
|
+
* ```
|
|
2065
|
+
* {{ object | map: toTile }}
|
|
2066
|
+
* ```
|
|
2067
|
+
*/
|
|
2068
|
+
class MapPipe {
|
|
2069
|
+
/**
|
|
2070
|
+
* @param value an item to transform
|
|
2071
|
+
* @param mapper a mapping function
|
|
2072
|
+
* @param args arbitrary number of additional arguments
|
|
2073
|
+
*/
|
|
2074
|
+
transform(value, mapper, ...args) {
|
|
2075
|
+
return mapper(value, ...args);
|
|
2076
|
+
}
|
|
2077
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MapPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2078
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: MapPipe, isStandalone: true, name: "map" }); }
|
|
2079
|
+
}
|
|
2080
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MapPipe, decorators: [{
|
|
2081
|
+
type: Pipe,
|
|
2082
|
+
args: [{ name: 'map' }]
|
|
2083
|
+
}] });
|
|
2084
|
+
|
|
2085
|
+
class MonthlyCurrencyPipe {
|
|
2086
|
+
constructor() {
|
|
2087
|
+
this.injector = inject(Injector);
|
|
2088
|
+
}
|
|
2089
|
+
transform(value, options) {
|
|
2090
|
+
return isNotNullable(value)
|
|
2091
|
+
? formatMonthlyCurrency(value, {
|
|
2092
|
+
injector: this.injector,
|
|
2093
|
+
...options,
|
|
2094
|
+
})
|
|
2095
|
+
: undefined;
|
|
2096
|
+
}
|
|
2097
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MonthlyCurrencyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2098
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: MonthlyCurrencyPipe, isStandalone: true, name: "monthlyCurrency" }); }
|
|
2099
|
+
}
|
|
2100
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MonthlyCurrencyPipe, decorators: [{
|
|
2101
|
+
type: Pipe,
|
|
2102
|
+
args: [{ name: 'monthlyCurrency' }]
|
|
2103
|
+
}] });
|
|
2104
|
+
|
|
2105
|
+
class PhoneNumberPipe {
|
|
2106
|
+
transform(value) {
|
|
2107
|
+
return formatPhoneNumber(value);
|
|
2108
|
+
}
|
|
2109
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PhoneNumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2110
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: PhoneNumberPipe, isStandalone: true, name: "phoneNumber" }); }
|
|
2111
|
+
}
|
|
2112
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PhoneNumberPipe, decorators: [{
|
|
2113
|
+
type: Pipe,
|
|
2114
|
+
args: [{ name: 'phoneNumber' }]
|
|
2115
|
+
}] });
|
|
2116
|
+
|
|
2117
|
+
class StrictTitleCasePipe {
|
|
2118
|
+
transform(value) {
|
|
2119
|
+
return value && strictTitleCase(value);
|
|
2120
|
+
}
|
|
2121
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StrictTitleCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2122
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: StrictTitleCasePipe, isStandalone: true, name: "strictTitleCase" }); }
|
|
2123
|
+
}
|
|
2124
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StrictTitleCasePipe, decorators: [{
|
|
2125
|
+
type: Pipe,
|
|
2126
|
+
args: [{ name: 'strictTitleCase' }]
|
|
2127
|
+
}] });
|
|
2128
|
+
|
|
2129
|
+
class TruncatePipe {
|
|
2130
|
+
transform(value, length) {
|
|
2131
|
+
return truncate(value, length);
|
|
2132
|
+
}
|
|
2133
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TruncatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2134
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: TruncatePipe, isStandalone: true, name: "truncate" }); }
|
|
2135
|
+
}
|
|
2136
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TruncatePipe, decorators: [{
|
|
2137
|
+
type: Pipe,
|
|
2138
|
+
args: [{ name: 'truncate' }]
|
|
2139
|
+
}] });
|
|
2140
|
+
|
|
2141
|
+
class UserFullnamePipe {
|
|
2142
|
+
transform(value) {
|
|
2143
|
+
return formatUserName(value);
|
|
2144
|
+
}
|
|
2145
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: UserFullnamePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2146
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: UserFullnamePipe, isStandalone: true, name: "userFullname" }); }
|
|
2147
|
+
}
|
|
2148
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: UserFullnamePipe, decorators: [{
|
|
2149
|
+
type: Pipe,
|
|
2150
|
+
args: [{ name: 'userFullname' }]
|
|
2151
|
+
}] });
|
|
2152
|
+
|
|
2153
|
+
class UserInitialPipe {
|
|
2154
|
+
transform(value) {
|
|
2155
|
+
return formatUserInitial(value);
|
|
2156
|
+
}
|
|
2157
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: UserInitialPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2158
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: UserInitialPipe, isStandalone: true, name: "userInitial" }); }
|
|
2159
|
+
}
|
|
2160
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: UserInitialPipe, decorators: [{
|
|
2161
|
+
type: Pipe,
|
|
2162
|
+
args: [{ name: 'userInitial' }]
|
|
2163
|
+
}] });
|
|
2164
|
+
|
|
2165
|
+
const angularPipes = [
|
|
2166
|
+
CurrencyPipe$1,
|
|
2167
|
+
DatePipe,
|
|
2168
|
+
DecimalPipe,
|
|
2169
|
+
I18nPluralPipe,
|
|
2170
|
+
LowerCasePipe,
|
|
2171
|
+
PercentPipe,
|
|
2172
|
+
UpperCasePipe,
|
|
2173
|
+
];
|
|
2174
|
+
function provideDevKitAngular(conf) {
|
|
2175
|
+
return makeEnvironmentProviders([
|
|
2176
|
+
{
|
|
2177
|
+
provide: DEFAULT_CURRENCY_CODE,
|
|
2178
|
+
useValue: conf?.currencyCode ?? 'EUR',
|
|
2179
|
+
},
|
|
2180
|
+
angularPipes,
|
|
2181
|
+
]);
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
const [injectDeploymentStage, _provideDeploymentStage] =
|
|
2185
|
+
/* @__PURE__ */ createNoopInjectionToken('Deployment Stage');
|
|
2186
|
+
function provideDeploymentStage(stage, providers) {
|
|
2187
|
+
return {
|
|
2188
|
+
stage,
|
|
2189
|
+
providers: [_provideDeploymentStage(stage), ...providers],
|
|
2190
|
+
};
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
function documentVisibilityStateFactory() {
|
|
2194
|
+
const document = inject(Document);
|
|
2195
|
+
return toSignal(documentVisibilityState(document), { requireSync: true });
|
|
2196
|
+
}
|
|
2197
|
+
const [injectDocumentVisibilityState] =
|
|
2198
|
+
/* @__PURE__ */ createInjectionToken(documentVisibilityStateFactory, {
|
|
2199
|
+
isRoot: true,
|
|
2200
|
+
});
|
|
2201
|
+
|
|
2202
|
+
const [injectAppVersion, provideAppVersion] =
|
|
2203
|
+
/* @__PURE__ */ createInjectionToken(() => '0.0.0');
|
|
2204
|
+
|
|
2205
|
+
function windowFocusState(window) {
|
|
2206
|
+
const focus$ = fromEvent(window, 'focus').pipe(map(() => 'focus'));
|
|
2207
|
+
const blur$ = fromEvent(window, 'blur').pipe(map(() => 'blur'));
|
|
2208
|
+
const initialState = window.document.hasFocus()
|
|
2209
|
+
? 'focus'
|
|
2210
|
+
: 'blur';
|
|
2211
|
+
return merge(focus$, blur$).pipe(startWith(initialState), distinctUntilChanged());
|
|
2212
|
+
}
|
|
2213
|
+
function lostFocusDuration(window) {
|
|
2214
|
+
const focusState$ = windowFocusState(window);
|
|
2215
|
+
const blur$ = focusState$.pipe(filter((state) => state === 'blur'));
|
|
2216
|
+
const focus$ = focusState$.pipe(filter((state) => state === 'focus'));
|
|
2217
|
+
const blurTs$ = blur$.pipe(timestamp(), map((evt) => evt.timestamp));
|
|
2218
|
+
const focusTs$ = focus$.pipe(timestamp(), map((evt) => evt.timestamp));
|
|
2219
|
+
return focusTs$.pipe(withLatestFrom(blurTs$), subOfArr());
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
function windowFocusStateFactory() {
|
|
2223
|
+
const window = injectWindow();
|
|
2224
|
+
return toSignal(windowFocusState(window), { requireSync: true });
|
|
2225
|
+
}
|
|
2226
|
+
const [injectWindowFocusState] = /* @__PURE__ */ createInjectionToken(windowFocusStateFactory, { isRoot: true });
|
|
2227
|
+
|
|
2228
|
+
function fromNextRender(injector) {
|
|
2229
|
+
if (!injector)
|
|
2230
|
+
assertInInjectionContext(fromNextRender);
|
|
2231
|
+
injector ??= inject(Injector);
|
|
2232
|
+
return new Observable((subscriber) => {
|
|
2233
|
+
afterNextRender(() => {
|
|
2234
|
+
subscriber.next();
|
|
2235
|
+
subscriber.complete();
|
|
2236
|
+
}, { injector });
|
|
2237
|
+
});
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
function useRxMethod(fn, config) {
|
|
2241
|
+
const { injector, operator = switchMap } = config ?? {};
|
|
2242
|
+
const result = rxMethod(operator(fn), {
|
|
2243
|
+
injector,
|
|
2244
|
+
});
|
|
2245
|
+
result.invoke = (input) => from(fn(input));
|
|
2246
|
+
return result;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
class ReplayQueryListObservable extends Observable {
|
|
2250
|
+
constructor(input) {
|
|
2251
|
+
super((subscriber) => input.changes
|
|
2252
|
+
.pipe(map(() => input.toArray()), startWith(input.toArray()))
|
|
2253
|
+
.subscribe(subscriber));
|
|
2254
|
+
}
|
|
2255
|
+
static of(input) {
|
|
2256
|
+
return new ReplayQueryListObservable(input);
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
/* eslint-disable no-console */
|
|
2261
|
+
// LogPrinter class to handle printing and observing log messages
|
|
2262
|
+
class LogPrinter {
|
|
2263
|
+
constructor(level,
|
|
2264
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2265
|
+
_print) {
|
|
2266
|
+
this.level = level;
|
|
2267
|
+
this._print = _print;
|
|
2268
|
+
this._message$ = new Subject();
|
|
2269
|
+
this.message$ = this._message$.asObservable();
|
|
2270
|
+
}
|
|
2271
|
+
// Destroy method to complete the message observable
|
|
2272
|
+
destroy() {
|
|
2273
|
+
this._message$.complete();
|
|
2274
|
+
}
|
|
2275
|
+
// Print method to print the message, decorate it, and emit to observers
|
|
2276
|
+
print(message, logger) {
|
|
2277
|
+
message = this.decorate(message, logger);
|
|
2278
|
+
this._print(message);
|
|
2279
|
+
this._message$.next(message);
|
|
2280
|
+
}
|
|
2281
|
+
// Decorate method to add a prefix to the log message
|
|
2282
|
+
decorate(message, logger) {
|
|
2283
|
+
return `[${logger.prefixName}] ${message}`;
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
// Injection token for logger prefix name
|
|
2287
|
+
const LOGGER_PREFIX_NAME = /* @__PURE__ */ new InjectionToken('@netwo/devkit: Logger Prefix Name');
|
|
2288
|
+
class Logger {
|
|
2289
|
+
constructor(
|
|
2290
|
+
// eslint-disable-next-line @angular-eslint/prefer-inject
|
|
2291
|
+
prefixName) {
|
|
2292
|
+
this.prefixName = prefixName;
|
|
2293
|
+
// Log printers for different levels
|
|
2294
|
+
this.infoPrinter = new LogPrinter('info', console.info);
|
|
2295
|
+
this.debugPrinter = new LogPrinter('debug', console.debug);
|
|
2296
|
+
this.tracePrinter = new LogPrinter('trace', console.trace);
|
|
2297
|
+
this.warnPrinter = new LogPrinter('warn', console.warn);
|
|
2298
|
+
this.errorPrinter = new LogPrinter('error', console.error);
|
|
2299
|
+
// Array of log printers
|
|
2300
|
+
this.printers = [
|
|
2301
|
+
this.infoPrinter,
|
|
2302
|
+
this.debugPrinter,
|
|
2303
|
+
this.tracePrinter,
|
|
2304
|
+
this.warnPrinter,
|
|
2305
|
+
this.errorPrinter,
|
|
2306
|
+
];
|
|
2307
|
+
// Observable stream of log messages
|
|
2308
|
+
this.log$ = merge(...this.printers.map(({ message$, level }) => message$.pipe(map((message) => ({
|
|
2309
|
+
level,
|
|
2310
|
+
message,
|
|
2311
|
+
})))));
|
|
2312
|
+
this.prefixName = this.prefixName ?? this.toPrefixName(Logger);
|
|
2313
|
+
}
|
|
2314
|
+
ngOnDestroy() {
|
|
2315
|
+
this.printers.forEach((printer) => printer.destroy());
|
|
2316
|
+
}
|
|
2317
|
+
// Method to create a new logger instance for a specific source
|
|
2318
|
+
forSource(source) {
|
|
2319
|
+
return new Logger(this.toPrefixName(source));
|
|
2320
|
+
}
|
|
2321
|
+
// Log methods for different levels
|
|
2322
|
+
info(message) {
|
|
2323
|
+
this.infoPrinter.print(message, this);
|
|
2324
|
+
}
|
|
2325
|
+
debug(message) {
|
|
2326
|
+
if (isDevMode()) {
|
|
2327
|
+
this.debugPrinter.print(message, this);
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
trace(message) {
|
|
2331
|
+
if (isDevMode()) {
|
|
2332
|
+
this.tracePrinter.print(message, this);
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
warn(message) {
|
|
2336
|
+
this.warnPrinter.print(message, this);
|
|
2337
|
+
}
|
|
2338
|
+
error(message) {
|
|
2339
|
+
this.errorPrinter.print(message, this);
|
|
2340
|
+
}
|
|
2341
|
+
// Helper method to generate a prefix name based on the input
|
|
2342
|
+
toPrefixName(input) {
|
|
2343
|
+
return isString(input) ? input : input.name;
|
|
2344
|
+
}
|
|
2345
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: Logger, deps: [{ token: LOGGER_PREFIX_NAME, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2346
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: Logger, providedIn: 'root' }); }
|
|
2347
|
+
}
|
|
2348
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: Logger, decorators: [{
|
|
2349
|
+
type: Injectable,
|
|
2350
|
+
args: [{ providedIn: 'root' }]
|
|
2351
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2352
|
+
type: Optional
|
|
2353
|
+
}, {
|
|
2354
|
+
type: Inject,
|
|
2355
|
+
args: [LOGGER_PREFIX_NAME]
|
|
2356
|
+
}] }] });
|
|
2357
|
+
|
|
2358
|
+
// Function to check if an object is of type PrintSelectOptions
|
|
2359
|
+
function isPrintSelectOption(obj) {
|
|
2360
|
+
return isObject(obj) && 'sectionId' in obj;
|
|
2361
|
+
}
|
|
2362
|
+
// Function to check if an object is of type PrintContentOptions
|
|
2363
|
+
function isPrintContentOption(obj) {
|
|
2364
|
+
return isObject(obj) && 'contents' in obj;
|
|
2365
|
+
}
|
|
2366
|
+
/**
|
|
2367
|
+
* This service provides functionality to print specific sections or custom content with various print options.
|
|
2368
|
+
* Usage examples:
|
|
2369
|
+
*
|
|
2370
|
+
* // Example 1: Print a specific section with additional options
|
|
2371
|
+
* const printSelectOptions: PrintSelectOptions = {
|
|
2372
|
+
* sectionId: 'someTagId',
|
|
2373
|
+
* title: 'Print Example',
|
|
2374
|
+
* style: { h1: { 'font-family': 'Arial', 'font-size': '16px' } },
|
|
2375
|
+
* cssList: ['custom-styles.css'],
|
|
2376
|
+
* delay: 500,
|
|
2377
|
+
* openNewTab: false,
|
|
2378
|
+
* previewOnly: false,
|
|
2379
|
+
* useExistingCss: false,
|
|
2380
|
+
* };
|
|
2381
|
+
* printer.print(printSelectOptions);
|
|
2382
|
+
*
|
|
2383
|
+
* // Example 2: Print custom content with additional options
|
|
2384
|
+
* const printContentOptions: PrintContentOptions = {
|
|
2385
|
+
* contents: '<div><h1>Hello, Print!</h1></div>',
|
|
2386
|
+
* title: 'Print Example',
|
|
2387
|
+
* style: { h1: { 'font-family': 'Arial', 'font-size': '16px' } },
|
|
2388
|
+
* cssList: ['custom-styles.css'],
|
|
2389
|
+
* delay: 0,
|
|
2390
|
+
* openNewTab: false,
|
|
2391
|
+
* previewOnly: false,
|
|
2392
|
+
* useExistingCss: false,
|
|
2393
|
+
* };
|
|
2394
|
+
* printer.print(printContentOptions);
|
|
2395
|
+
*/
|
|
2396
|
+
class Printer {
|
|
2397
|
+
constructor() {
|
|
2398
|
+
this.window = injectWindow();
|
|
2399
|
+
this.errorHandler = inject(ErrorHandler);
|
|
2400
|
+
}
|
|
2401
|
+
// Initiate the print process based on the provided options
|
|
2402
|
+
print(options) {
|
|
2403
|
+
let printContents = '';
|
|
2404
|
+
// Check if the print options are for selecting a print section
|
|
2405
|
+
if (isPrintSelectOption(options)) {
|
|
2406
|
+
const contents = this.getHtmlContents(options.sectionId);
|
|
2407
|
+
if (!contents) {
|
|
2408
|
+
const error = new Error(`Print section with id ${options.sectionId} not found.`);
|
|
2409
|
+
// Handle error if the print section is not found
|
|
2410
|
+
this.errorHandler.handleError(error);
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
printContents = contents;
|
|
2414
|
+
}
|
|
2415
|
+
// Check if the print options are for printing specific content
|
|
2416
|
+
if (isPrintContentOption(options)) {
|
|
2417
|
+
printContents = options.contents;
|
|
2418
|
+
}
|
|
2419
|
+
// Extract additional options
|
|
2420
|
+
const { title = '', style = {}, cssList = [], delay = 0, openNewTab = false, previewOnly = false, useExistingCss = false, } = options;
|
|
2421
|
+
// Get base tag from the window document
|
|
2422
|
+
const baseTag = this.getElementTag('base');
|
|
2423
|
+
let styles = '';
|
|
2424
|
+
let links = '';
|
|
2425
|
+
if (useExistingCss) {
|
|
2426
|
+
// Get styles and links from the window document
|
|
2427
|
+
styles = this.getElementTag('style');
|
|
2428
|
+
links = this.getElementTag('link');
|
|
2429
|
+
}
|
|
2430
|
+
// Get style sheet file content
|
|
2431
|
+
const styleSheetFile = this.getStyleSheetFile(cssList);
|
|
2432
|
+
// Get style values
|
|
2433
|
+
const styleValues = this.getStyleValues(style);
|
|
2434
|
+
// Configure popup window
|
|
2435
|
+
let popOut = '';
|
|
2436
|
+
if (!openNewTab) {
|
|
2437
|
+
popOut = 'top=0,left=0,height=auto,width=auto';
|
|
2438
|
+
}
|
|
2439
|
+
// Open a new window or tab for printing
|
|
2440
|
+
const popupWin = this.window.open('', '_blank', popOut);
|
|
2441
|
+
// Assert that the popup window is not null
|
|
2442
|
+
assertNonNullable(popupWin, 'Popup');
|
|
2443
|
+
// Open the popup window document
|
|
2444
|
+
popupWin.document.open();
|
|
2445
|
+
// Write HTML content to the popup window
|
|
2446
|
+
popupWin.document.write(`
|
|
2447
|
+
<html>
|
|
2448
|
+
<head>
|
|
2449
|
+
<title>${title}</title>
|
|
2450
|
+
${baseTag}
|
|
2451
|
+
${styleValues}
|
|
2452
|
+
${styleSheetFile}
|
|
2453
|
+
${styles}
|
|
2454
|
+
${links}
|
|
2455
|
+
</head>
|
|
2456
|
+
<body>
|
|
2457
|
+
${printContents}
|
|
2458
|
+
<script defer>
|
|
2459
|
+
function triggerPrint(event) {
|
|
2460
|
+
window.removeEventListener('load', triggerPrint, false);
|
|
2461
|
+
${previewOnly
|
|
2462
|
+
? ''
|
|
2463
|
+
: `setTimeout(function() {
|
|
2464
|
+
closeWindow(window.print());
|
|
2465
|
+
}, ${delay});`}
|
|
2466
|
+
}
|
|
2467
|
+
function closeWindow(){
|
|
2468
|
+
window.close();
|
|
2469
|
+
}
|
|
2470
|
+
window.addEventListener('load', triggerPrint, false);
|
|
2471
|
+
</script>
|
|
2472
|
+
</body>
|
|
2473
|
+
</html>
|
|
2474
|
+
`);
|
|
2475
|
+
// Close the popup window document
|
|
2476
|
+
popupWin.document.close();
|
|
2477
|
+
}
|
|
2478
|
+
printAsyncHtmlElement(options) {
|
|
2479
|
+
return new Promise((resolve, reject) => {
|
|
2480
|
+
const { nativeElement, renderer, ...printOpts } = options;
|
|
2481
|
+
// Hide the rendered component
|
|
2482
|
+
renderer.setStyle(nativeElement, 'display', 'none');
|
|
2483
|
+
// Destroy the rendered component in the current document
|
|
2484
|
+
const destroy = () => renderer.removeChild(nativeElement.parentElement, nativeElement);
|
|
2485
|
+
const observer = new MutationObserver((mutationsList) => {
|
|
2486
|
+
const nodes = mutationsList.reduce((acc, cur) => [...acc, ...Array.from(cur.addedNodes)], []);
|
|
2487
|
+
if (nodes.length) {
|
|
2488
|
+
// Cancel the timeout
|
|
2489
|
+
clearTimeout(timeoutId);
|
|
2490
|
+
// Stop to observe
|
|
2491
|
+
observer.disconnect();
|
|
2492
|
+
// Show the rendered component
|
|
2493
|
+
renderer.removeStyle(nativeElement, 'display');
|
|
2494
|
+
// Print the target contents
|
|
2495
|
+
this.print({
|
|
2496
|
+
contents: nativeElement.outerHTML,
|
|
2497
|
+
...printOpts,
|
|
2498
|
+
});
|
|
2499
|
+
// Trigger destroy
|
|
2500
|
+
destroy();
|
|
2501
|
+
resolve();
|
|
2502
|
+
}
|
|
2503
|
+
});
|
|
2504
|
+
// Start to observe dom
|
|
2505
|
+
observer.observe(nativeElement, {
|
|
2506
|
+
attributes: true,
|
|
2507
|
+
childList: true,
|
|
2508
|
+
subtree: true,
|
|
2509
|
+
});
|
|
2510
|
+
// Start countdown to prevent leak
|
|
2511
|
+
const timeoutId = setTimeout(() => {
|
|
2512
|
+
// Stop to observe
|
|
2513
|
+
observer.disconnect();
|
|
2514
|
+
// Trigger destroy
|
|
2515
|
+
destroy();
|
|
2516
|
+
reject(new Error());
|
|
2517
|
+
}, 1000);
|
|
2518
|
+
});
|
|
2519
|
+
}
|
|
2520
|
+
// Helper method to get the outerHTML of elements with a specific tag
|
|
2521
|
+
getElementTag(tag) {
|
|
2522
|
+
const html = [];
|
|
2523
|
+
const elements = this.window.document.getElementsByTagName(tag);
|
|
2524
|
+
for (let i = 0; i < elements.length; i++) {
|
|
2525
|
+
const element = elements.item(i);
|
|
2526
|
+
assertNonNullable(element, `Tag at index ${i}`);
|
|
2527
|
+
html.push(element.outerHTML);
|
|
2528
|
+
}
|
|
2529
|
+
return html.join('\r\n');
|
|
2530
|
+
}
|
|
2531
|
+
// Helper method to get HTML contents based on the section ID
|
|
2532
|
+
getHtmlContents(printSectionId) {
|
|
2533
|
+
const printContents = this.window.document.getElementById(printSectionId);
|
|
2534
|
+
if (!printContents)
|
|
2535
|
+
return null;
|
|
2536
|
+
// Update defaults for input, select, textarea, and canvas elements
|
|
2537
|
+
const inputEls = printContents.getElementsByTagName('input');
|
|
2538
|
+
const selectEls = printContents.getElementsByTagName('select');
|
|
2539
|
+
const textAreaEls = printContents.getElementsByTagName('textarea');
|
|
2540
|
+
const canvasEls = printContents.getElementsByTagName('canvas');
|
|
2541
|
+
this.updateInputDefaults(inputEls);
|
|
2542
|
+
this.updateSelectDefaults(selectEls);
|
|
2543
|
+
this.updateTextAreaDefaults(textAreaEls);
|
|
2544
|
+
this.updateCanvasToImage(canvasEls);
|
|
2545
|
+
// Return innerHTML of the print section
|
|
2546
|
+
return printContents.innerHTML;
|
|
2547
|
+
}
|
|
2548
|
+
// Helper method to get the content of style sheets
|
|
2549
|
+
getStyleSheetFile(cssList) {
|
|
2550
|
+
return cssList.reduce((acc, cssFileName) => acc + `<link rel="stylesheet" type="text/css" href="${cssFileName}">`, '');
|
|
2551
|
+
}
|
|
2552
|
+
// Helper method to get style values based on the provided styles object
|
|
2553
|
+
getStyleValues(printStyle) {
|
|
2554
|
+
const styles = new Array();
|
|
2555
|
+
for (const key in printStyle) {
|
|
2556
|
+
if (key in printStyle) {
|
|
2557
|
+
styles.push((key + JSON.stringify(printStyle[key])).replace(/['"]+/g, ''));
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
return `<style> ${styles.join(' ').replace(/,/g, ';')} </style>`;
|
|
2561
|
+
}
|
|
2562
|
+
// Helper method to update defaults for input elements
|
|
2563
|
+
updateInputDefaults(elements) {
|
|
2564
|
+
for (let i = 0; i < elements.length; i++) {
|
|
2565
|
+
const element = elements.item(i);
|
|
2566
|
+
assertNonNullable(element, `Input at index ${i}`);
|
|
2567
|
+
element.defaultValue = element.value;
|
|
2568
|
+
if (element.checked)
|
|
2569
|
+
element.defaultChecked = true;
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
// Helper method to update defaults for select elements
|
|
2573
|
+
updateSelectDefaults(elements) {
|
|
2574
|
+
for (let i = 0; i < elements.length; i++) {
|
|
2575
|
+
const element = elements.item(i);
|
|
2576
|
+
assertNonNullable(element, `Select at index ${i}`);
|
|
2577
|
+
const selectedIdx = element.selectedIndex;
|
|
2578
|
+
const selectedOption = element.options[selectedIdx];
|
|
2579
|
+
assertNonNullable(selectedOption, `SelectOption at index ${i}`);
|
|
2580
|
+
selectedOption.defaultSelected = true;
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
// Helper method to update defaults for textarea elements
|
|
2584
|
+
updateTextAreaDefaults(elements) {
|
|
2585
|
+
for (let i = 0; i < elements.length; i++) {
|
|
2586
|
+
const element = elements.item(i);
|
|
2587
|
+
assertNonNullable(element, `TextArea at index ${i}`);
|
|
2588
|
+
element.defaultValue = element.value;
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
// Helper method to update canvas elements to images
|
|
2592
|
+
updateCanvasToImage(elements) {
|
|
2593
|
+
for (let i = 0; i < elements.length; i++) {
|
|
2594
|
+
const element = elements.item(i);
|
|
2595
|
+
assertNonNullable(element, `Canvas at index ${i}`);
|
|
2596
|
+
const img = this.canvasToImageHtml(element);
|
|
2597
|
+
element.insertAdjacentHTML('afterend', img);
|
|
2598
|
+
element.remove();
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
// Helper method to convert canvas elements to image HTML
|
|
2602
|
+
canvasToImageHtml(element) {
|
|
2603
|
+
const dataUrl = element.toDataURL();
|
|
2604
|
+
return `<img src="${dataUrl}" style="max-width: 100%;">`;
|
|
2605
|
+
}
|
|
2606
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: Printer, deps: [], target: i0.ɵɵFactoryTarget.Service }); }
|
|
2607
|
+
static { this.ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.6", ngImport: i0, type: Printer }); }
|
|
2608
|
+
}
|
|
2609
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: Printer, decorators: [{
|
|
2610
|
+
type: Service
|
|
2611
|
+
}] });
|
|
2612
|
+
|
|
2613
|
+
class StorageService {
|
|
2614
|
+
constructor() {
|
|
2615
|
+
this.logger = inject(Logger).forSource(`StorageService`);
|
|
2616
|
+
this.window = injectWindow();
|
|
2617
|
+
this.sessionStorage = {
|
|
2618
|
+
type: 'session',
|
|
2619
|
+
storage: this.window.sessionStorage,
|
|
2620
|
+
};
|
|
2621
|
+
this.localStorage = {
|
|
2622
|
+
type: 'local',
|
|
2623
|
+
storage: this.window.localStorage,
|
|
2624
|
+
};
|
|
2625
|
+
}
|
|
2626
|
+
/**
|
|
2627
|
+
* Stores a key/value pair in storage according to session parameter.
|
|
2628
|
+
* @param key the key of value to store.
|
|
2629
|
+
* @param value the value to store.
|
|
2630
|
+
* @param target indicates where to store key/value pair.
|
|
2631
|
+
*/
|
|
2632
|
+
store(key, value, target = 'session') {
|
|
2633
|
+
const storages = this.getTargetedStorages(target);
|
|
2634
|
+
storages.forEach(({ type, storage }) => {
|
|
2635
|
+
const strValue = JSON.stringify(value);
|
|
2636
|
+
this.logger.debug(`Storing ("${key}", ${strValue}) in ${type} storage.`);
|
|
2637
|
+
storage.setItem(key, strValue);
|
|
2638
|
+
});
|
|
2639
|
+
}
|
|
2640
|
+
/**
|
|
2641
|
+
* Get value corresponding to given key from storage.
|
|
2642
|
+
* @param key the key of value to retrieve.
|
|
2643
|
+
* @param target boolean which indicates from where to retrieve the value corresponding to given key.
|
|
2644
|
+
* @returns an option containing the value corresponding to given key or none if no value was found.
|
|
2645
|
+
*/
|
|
2646
|
+
get(key, target = 'session') {
|
|
2647
|
+
const storages = this.getTargetedStorages(target);
|
|
2648
|
+
return storages.reduce((value, { type, storage }) => {
|
|
2649
|
+
if (isNotNullable(value)) {
|
|
2650
|
+
return value;
|
|
2651
|
+
}
|
|
2652
|
+
const json = storage.getItem(key);
|
|
2653
|
+
if (json) {
|
|
2654
|
+
try {
|
|
2655
|
+
const value = JSON.parse(json);
|
|
2656
|
+
return value;
|
|
2657
|
+
}
|
|
2658
|
+
catch (_ignore) {
|
|
2659
|
+
this.logger.error(`Malformed value stored for ${key} in ${type} storage.`);
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
return undefined;
|
|
2663
|
+
}, undefined);
|
|
2664
|
+
}
|
|
2665
|
+
/**
|
|
2666
|
+
* Indicated if there is an entry corresponding to given key in storage.
|
|
2667
|
+
* @param key the key to look for.
|
|
2668
|
+
* @param target indicates which storage to clear. Default is true.
|
|
2669
|
+
* @returns true if there is an entry corresponding to given key, false else.
|
|
2670
|
+
*/
|
|
2671
|
+
hasKey(key, target = 'session') {
|
|
2672
|
+
return !!this.get(key, target);
|
|
2673
|
+
}
|
|
2674
|
+
/**
|
|
2675
|
+
* Remove entry from storage.
|
|
2676
|
+
* @param key the key corresponding to te entry to remove.
|
|
2677
|
+
* @param target indicates from where to remove the entry corresponding to given key.
|
|
2678
|
+
*/
|
|
2679
|
+
remove(key, target = 'session') {
|
|
2680
|
+
const storages = this.getTargetedStorages(target);
|
|
2681
|
+
storages.forEach(({ type, storage }) => {
|
|
2682
|
+
this.logger.debug(`Removing "${key}" from ${type} storage.`);
|
|
2683
|
+
storage.removeItem(key);
|
|
2684
|
+
});
|
|
2685
|
+
}
|
|
2686
|
+
/**
|
|
2687
|
+
* Clear the storage.
|
|
2688
|
+
* @param target indicates which storage to clear. Default is true.
|
|
2689
|
+
*/
|
|
2690
|
+
clear(target = 'session') {
|
|
2691
|
+
const storages = this.getTargetedStorages(target);
|
|
2692
|
+
storages.forEach(({ type, storage }) => {
|
|
2693
|
+
this.logger.debug(`Clearing ${type} storage`);
|
|
2694
|
+
storage.clear();
|
|
2695
|
+
});
|
|
2696
|
+
}
|
|
2697
|
+
getTargetedStorages(target) {
|
|
2698
|
+
const storages = new Array();
|
|
2699
|
+
if (target === 'all') {
|
|
2700
|
+
storages.push(this.sessionStorage);
|
|
2701
|
+
storages.push(this.localStorage);
|
|
2702
|
+
}
|
|
2703
|
+
else {
|
|
2704
|
+
const targets = resolveValueOrArr(target);
|
|
2705
|
+
if (targets.includes('session')) {
|
|
2706
|
+
storages.push(this.sessionStorage);
|
|
2707
|
+
}
|
|
2708
|
+
if (targets.includes('local')) {
|
|
2709
|
+
storages.push(this.localStorage);
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
return storages.filter((s) => this.isSupported(s));
|
|
2713
|
+
}
|
|
2714
|
+
isSupported({ type, storage }) {
|
|
2715
|
+
if (typeof storage !== 'undefined') {
|
|
2716
|
+
return true;
|
|
2717
|
+
}
|
|
2718
|
+
this.logger.warn(`Storage ${type} not supported`);
|
|
2719
|
+
return false;
|
|
2720
|
+
}
|
|
2721
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StorageService, deps: [], target: i0.ɵɵFactoryTarget.Service }); }
|
|
2722
|
+
static { this.ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.6", ngImport: i0, type: StorageService }); }
|
|
2723
|
+
}
|
|
2724
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StorageService, decorators: [{
|
|
2725
|
+
type: Service
|
|
2726
|
+
}] });
|
|
2727
|
+
|
|
2728
|
+
function getDefaultSelectId() {
|
|
2729
|
+
return (def) => def.id;
|
|
2730
|
+
}
|
|
2731
|
+
const VIEW_RESOLVER_CONF = /* @__PURE__ */ new InjectionToken('@netwo/devkit: View Resolver Conf');
|
|
2732
|
+
/**
|
|
2733
|
+
* Used to provide view resolver conf.
|
|
2734
|
+
*
|
|
2735
|
+
* @example
|
|
2736
|
+
*
|
|
2737
|
+
* export interface CustomViewDef extends ViewDef<CustomRenderComponent> {
|
|
2738
|
+
* readonly customId: string;
|
|
2739
|
+
* }
|
|
2740
|
+
*
|
|
2741
|
+
* const CUSTOM_VIEW_DEF = new InjectionToken<CustomViewDef[]>('Custom View Def');
|
|
2742
|
+
*
|
|
2743
|
+
* @Component({
|
|
2744
|
+
* // ...
|
|
2745
|
+
* viewProviders: [
|
|
2746
|
+
* provideViewResolverConf({
|
|
2747
|
+
* token: CUSTOM_VIEW_DEF,
|
|
2748
|
+
* selectId: (def: CustomViewDef) => def.customId
|
|
2749
|
+
* }),
|
|
2750
|
+
* ],
|
|
2751
|
+
* })
|
|
2752
|
+
* export class CustomContainerComponent {
|
|
2753
|
+
* constructor(private readonly viewResolver: ViewResolver<CustomViewDef>) {}
|
|
2754
|
+
*
|
|
2755
|
+
* // ...
|
|
2756
|
+
* }
|
|
2757
|
+
*/
|
|
2758
|
+
function provideViewResolver(conf) {
|
|
2759
|
+
const viewResolverConf = {
|
|
2760
|
+
provide: VIEW_RESOLVER_CONF,
|
|
2761
|
+
useValue: conf,
|
|
2762
|
+
};
|
|
2763
|
+
return [viewResolverConf, ViewResolver];
|
|
2764
|
+
}
|
|
2765
|
+
function buildViewResolver(conf) {
|
|
2766
|
+
const injectFn = () => inject(ViewResolver);
|
|
2767
|
+
const provideFn = () => provideViewResolver(conf);
|
|
2768
|
+
return [injectFn, provideFn];
|
|
2769
|
+
}
|
|
2770
|
+
/**
|
|
2771
|
+
* View Resolver to register a list of definitions and render a component depending of a selected id
|
|
2772
|
+
*
|
|
2773
|
+
* @example
|
|
2774
|
+
*
|
|
2775
|
+
* export class CustomContainerComponent implements OnInit {
|
|
2776
|
+
* @Input() customInput: any;
|
|
2777
|
+
*
|
|
2778
|
+
* @ViewChild('container', {
|
|
2779
|
+
* read: ViewContainerRef,
|
|
2780
|
+
* static: true,
|
|
2781
|
+
* })
|
|
2782
|
+
* private readonly container: ViewContainerRef;
|
|
2783
|
+
*
|
|
2784
|
+
* constructor(
|
|
2785
|
+
* private readonly viewResolver: ViewResolver<CustomViewDef>
|
|
2786
|
+
* ) {}
|
|
2787
|
+
*
|
|
2788
|
+
* ngOnInit() {
|
|
2789
|
+
* const instance = this.viewResolver.render('customId', {
|
|
2790
|
+
* container: this.container,
|
|
2791
|
+
* })
|
|
2792
|
+
* instance.customInput = this.customInput
|
|
2793
|
+
* }
|
|
2794
|
+
*/
|
|
2795
|
+
class ViewResolver {
|
|
2796
|
+
constructor() {
|
|
2797
|
+
this.injector = inject(Injector);
|
|
2798
|
+
this.conf = inject(VIEW_RESOLVER_CONF);
|
|
2799
|
+
this.selectId = this.conf.selectId ?? getDefaultSelectId();
|
|
2800
|
+
this.defs = this.getDefs(this.injector, this.conf.token);
|
|
2801
|
+
this.registeredDefs = [];
|
|
2802
|
+
}
|
|
2803
|
+
get ids() {
|
|
2804
|
+
return this.defs.map((def) => this.selectId(def));
|
|
2805
|
+
}
|
|
2806
|
+
/**
|
|
2807
|
+
* Add a non injectable definition
|
|
2808
|
+
*/
|
|
2809
|
+
register(def) {
|
|
2810
|
+
this.defs.push(def);
|
|
2811
|
+
this.registeredDefs.push(def);
|
|
2812
|
+
}
|
|
2813
|
+
/**
|
|
2814
|
+
* true if the definition exist for le given id, otherwise false
|
|
2815
|
+
*/
|
|
2816
|
+
has(id, options) {
|
|
2817
|
+
return !!this.find(id, options);
|
|
2818
|
+
}
|
|
2819
|
+
/**
|
|
2820
|
+
* Find the definitions for the given id
|
|
2821
|
+
*/
|
|
2822
|
+
find(id, options) {
|
|
2823
|
+
const { injector } = options ?? {};
|
|
2824
|
+
// only if there'are view definitions
|
|
2825
|
+
const localDefs = injector && this.getDefs(injector, this.conf.token);
|
|
2826
|
+
const defs = (localDefs && [...localDefs, ...this.registeredDefs]) ?? this.defs;
|
|
2827
|
+
// found the first view definition
|
|
2828
|
+
return defs.find((def) => this.selectId(def) === id);
|
|
2829
|
+
}
|
|
2830
|
+
render(idOrDef, options) {
|
|
2831
|
+
const { container, injector, createOptions } = options;
|
|
2832
|
+
// clear view
|
|
2833
|
+
container.clear();
|
|
2834
|
+
// find the correct def
|
|
2835
|
+
let def;
|
|
2836
|
+
if (isString(idOrDef)) {
|
|
2837
|
+
const innerDef = this.find(idOrDef, { injector });
|
|
2838
|
+
if (!innerDef)
|
|
2839
|
+
throw new Error(`no def found for id [${idOrDef}]`);
|
|
2840
|
+
def = innerDef;
|
|
2841
|
+
}
|
|
2842
|
+
else {
|
|
2843
|
+
def = idOrDef;
|
|
2844
|
+
}
|
|
2845
|
+
// render the component in the container
|
|
2846
|
+
return container.createComponent(def.component, createOptions);
|
|
2847
|
+
}
|
|
2848
|
+
getDefs(injector, token) {
|
|
2849
|
+
try {
|
|
2850
|
+
return injector.get(token, []);
|
|
2851
|
+
}
|
|
2852
|
+
catch (_ignore) {
|
|
2853
|
+
return [];
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ViewResolver, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2857
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ViewResolver }); }
|
|
2858
|
+
}
|
|
2859
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ViewResolver, decorators: [{
|
|
2860
|
+
type: Injectable
|
|
2861
|
+
}] });
|
|
2862
|
+
|
|
2863
|
+
function getWithCallStatusKeys(collection) {
|
|
2864
|
+
const capitalizedProp = collection && capitalize(collection);
|
|
2865
|
+
return {
|
|
2866
|
+
callStatusKey: collection ? `${collection}CallStatus` : 'callStatus',
|
|
2867
|
+
errorKey: collection ? `${collection}Error` : 'error',
|
|
2868
|
+
loadedKey: collection ? `is${capitalizedProp}Loaded` : 'isLoaded',
|
|
2869
|
+
loadingKey: collection ? `is${capitalizedProp}Loading` : 'isLoading',
|
|
2870
|
+
setErrorKey: collection ? `_set${capitalizedProp}Error` : '_setError',
|
|
2871
|
+
setLoadedKey: collection ? `_set${capitalizedProp}Loaded` : '_setLoaded',
|
|
2872
|
+
setLoadingKey: collection ? `_set${capitalizedProp}Loading` : '_setLoading',
|
|
2873
|
+
};
|
|
2874
|
+
}
|
|
2875
|
+
function withCallStatus(config) {
|
|
2876
|
+
const { collection, initialValue = 'idle' } = config ?? {};
|
|
2877
|
+
const { callStatusKey, errorKey, loadedKey, loadingKey, setErrorKey, setLoadedKey, setLoadingKey, } = getWithCallStatusKeys(collection);
|
|
2878
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
2879
|
+
return signalStoreFeature(withState(() => ({ [callStatusKey]: initialValue })), withComputed((store) => {
|
|
2880
|
+
const callStatus = store[callStatusKey];
|
|
2881
|
+
return {
|
|
2882
|
+
[loadingKey]: computed(() => callStatus() === 'loading'),
|
|
2883
|
+
[loadedKey]: computed(() => callStatus() === 'loaded'),
|
|
2884
|
+
[errorKey]: computed(() => {
|
|
2885
|
+
const status = callStatus();
|
|
2886
|
+
return typeof status === 'object' ? status.error : null;
|
|
2887
|
+
}),
|
|
2888
|
+
};
|
|
2889
|
+
}), withProps((store) => ({
|
|
2890
|
+
[setLoadingKey]: () => {
|
|
2891
|
+
patchState(store, { [callStatusKey]: 'loading' });
|
|
2892
|
+
},
|
|
2893
|
+
[setLoadedKey]: () => {
|
|
2894
|
+
patchState(store, { [callStatusKey]: 'loaded' });
|
|
2895
|
+
},
|
|
2896
|
+
[setErrorKey]: (error) => {
|
|
2897
|
+
patchState(store, { [callStatusKey]: { error } });
|
|
2898
|
+
},
|
|
2899
|
+
})));
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2902
|
+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
|
|
2903
|
+
const DEFAULT_PAGE_SIZE = 10;
|
|
2904
|
+
function withPaginatedResource(optionsOrFactory, factory = optionsOrFactory) {
|
|
2905
|
+
const options = typeof optionsOrFactory === 'function' ? {} : optionsOrFactory;
|
|
2906
|
+
return createPaginatedResourceFeature(factory, options);
|
|
2907
|
+
}
|
|
2908
|
+
function createPaginatedResourceFeature(factory, options) {
|
|
2909
|
+
const namespace = 'namespace' in options ? options.namespace : undefined;
|
|
2910
|
+
const keyPrefix = namespace ? toCamelCase(namespace) : '';
|
|
2911
|
+
const methodPrefix = namespace ? capitalize(keyPrefix) : '';
|
|
2912
|
+
const pageKey = namespace ? `${keyPrefix}Page` : 'page';
|
|
2913
|
+
const pageSizeKey = namespace ? `${keyPrefix}PageSize` : 'pageSize';
|
|
2914
|
+
const searchKey = namespace ? `${keyPrefix}Search` : 'search';
|
|
2915
|
+
const sortKey = namespace ? `${keyPrefix}Sort` : 'sort';
|
|
2916
|
+
const filtersKey = namespace ? `${keyPrefix}Filters` : 'filters';
|
|
2917
|
+
const initialFilters = (options.initialFilters ?? {});
|
|
2918
|
+
return signalStoreFeature(withState(namespacedRecord(namespace, {
|
|
2919
|
+
page: 1,
|
|
2920
|
+
pageSize: options.pageSize ?? DEFAULT_PAGE_SIZE,
|
|
2921
|
+
search: '',
|
|
2922
|
+
sort: undefined,
|
|
2923
|
+
filters: initialFilters,
|
|
2924
|
+
})), withMethods((store) => ({
|
|
2925
|
+
[`set${methodPrefix}Page`](page) {
|
|
2926
|
+
patchState(store, { [pageKey]: page });
|
|
2927
|
+
},
|
|
2928
|
+
[`set${methodPrefix}PageSize`](pageSize) {
|
|
2929
|
+
patchState(store, { [pageSizeKey]: pageSize, [pageKey]: 1 });
|
|
2930
|
+
},
|
|
2931
|
+
[`set${methodPrefix}Search`](search) {
|
|
2932
|
+
patchState(store, { [searchKey]: search, [pageKey]: 1 });
|
|
2933
|
+
},
|
|
2934
|
+
[`set${methodPrefix}Sort`](sort) {
|
|
2935
|
+
patchState(store, { [sortKey]: sort, [pageKey]: 1 });
|
|
2936
|
+
},
|
|
2937
|
+
[`set${methodPrefix}Filter`](key, value) {
|
|
2938
|
+
const filters = getState(store)[filtersKey];
|
|
2939
|
+
patchState(store, {
|
|
2940
|
+
[filtersKey]: { ...filters, [key]: value },
|
|
2941
|
+
[pageKey]: 1,
|
|
2942
|
+
});
|
|
2943
|
+
},
|
|
2944
|
+
[`clear${methodPrefix}Filters`]() {
|
|
2945
|
+
patchState(store, { [filtersKey]: initialFilters, [pageKey]: 1 });
|
|
2946
|
+
},
|
|
2947
|
+
[`clear${methodPrefix}SearchAndFilters`]() {
|
|
2948
|
+
patchState(store, {
|
|
2949
|
+
[filtersKey]: initialFilters,
|
|
2950
|
+
[searchKey]: '',
|
|
2951
|
+
[pageKey]: 1,
|
|
2952
|
+
});
|
|
2953
|
+
},
|
|
2954
|
+
})), withFeature((store) => withProps(() => {
|
|
2955
|
+
const filters = computed(() => getState(store)[filtersKey] ?? initialFilters, /* @ts-ignore */
|
|
2956
|
+
...(ngDevMode ? [{ debugName: "filters" }] : /* istanbul ignore next */ []));
|
|
2957
|
+
const sort = computed(() => getState(store)[sortKey], /* @ts-ignore */
|
|
2958
|
+
...(ngDevMode ? [{ debugName: "sort" }] : /* istanbul ignore next */ []));
|
|
2959
|
+
const activeFilterCount = computed(() => countActiveFilters(filters(), initialFilters), /* @ts-ignore */
|
|
2960
|
+
...(ngDevMode ? [{ debugName: "activeFilterCount" }] : /* istanbul ignore next */ []));
|
|
2961
|
+
const hasFilters = computed(() => activeFilterCount() > 0, /* @ts-ignore */
|
|
2962
|
+
...(ngDevMode ? [{ debugName: "hasFilters" }] : /* istanbul ignore next */ []));
|
|
2963
|
+
const hasSearchOrFilters = computed(() => {
|
|
2964
|
+
const state = getState(store);
|
|
2965
|
+
const search = state[searchKey];
|
|
2966
|
+
return (isString(search) && search.trim().length > 0) || hasFilters();
|
|
2967
|
+
}, /* @ts-ignore */
|
|
2968
|
+
...(ngDevMode ? [{ debugName: "hasSearchOrFilters" }] : /* istanbul ignore next */ []));
|
|
2969
|
+
const params = computed(() => {
|
|
2970
|
+
const state = getState(store);
|
|
2971
|
+
return {
|
|
2972
|
+
page: state[pageKey],
|
|
2973
|
+
pageSize: state[pageSizeKey],
|
|
2974
|
+
search: state[searchKey],
|
|
2975
|
+
sort: sort(),
|
|
2976
|
+
...filters(),
|
|
2977
|
+
};
|
|
2978
|
+
}, /* @ts-ignore */
|
|
2979
|
+
...(ngDevMode ? [{ debugName: "params" }] : /* istanbul ignore next */ []));
|
|
2980
|
+
const resource = factory(params);
|
|
2981
|
+
const resourceValue = safeResourceValue(resource);
|
|
2982
|
+
const resourceResultWithParams = computed(() => {
|
|
2983
|
+
const value = resourceValue();
|
|
2984
|
+
return value ? { ...value, ...untracked(() => params()) } : undefined;
|
|
2985
|
+
}, /* @ts-ignore */
|
|
2986
|
+
...(ngDevMode ? [{ debugName: "resourceResultWithParams" }] : /* istanbul ignore next */ []));
|
|
2987
|
+
const paginatedResult = linkedSignal({ ...(ngDevMode ? { debugName: "paginatedResult" } : /* istanbul ignore next */ {}), source: resourceResultWithParams,
|
|
2988
|
+
computation: (value, previous) => value ?? previous?.value });
|
|
2989
|
+
const items = computed(() => (paginatedResult()?.items ??
|
|
2990
|
+
[]), /* @ts-ignore */
|
|
2991
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
2992
|
+
const total = computed(() => paginatedResult()?.total ?? 0, /* @ts-ignore */
|
|
2993
|
+
...(ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []));
|
|
2994
|
+
const isPagedInitialLoading = computed(() => resource.status() === 'idle' ||
|
|
2995
|
+
(resource.isLoading() && paginatedResult() === undefined), /* @ts-ignore */
|
|
2996
|
+
...(ngDevMode ? [{ debugName: "isPagedInitialLoading" }] : /* istanbul ignore next */ []));
|
|
2997
|
+
const isPagedRefreshingEmptySearch = computed(() => resource.isLoading() &&
|
|
2998
|
+
items().length === 0 &&
|
|
2999
|
+
paginatedResult()?.search !== params().search, /* @ts-ignore */
|
|
3000
|
+
...(ngDevMode ? [{ debugName: "isPagedRefreshingEmptySearch" }] : /* istanbul ignore next */ []));
|
|
3001
|
+
return namespacedRecord(namespace, {
|
|
3002
|
+
activeFilterCount,
|
|
3003
|
+
hasFilters,
|
|
3004
|
+
hasPagedError: computed(() => resource.error() !== undefined),
|
|
3005
|
+
hasSearchOrFilters,
|
|
3006
|
+
isLoading: computed(() => isPagedInitialLoading() || isPagedRefreshingEmptySearch()),
|
|
3007
|
+
isPagedInitialLoading,
|
|
3008
|
+
isPagedLoading: computed(() => resource.isLoading()),
|
|
3009
|
+
isPagedRefreshing: computed(() => resource.isLoading() && paginatedResult() !== undefined),
|
|
3010
|
+
isPagedRefreshingEmptySearch,
|
|
3011
|
+
pagedItems: items,
|
|
3012
|
+
pagedResource: resource,
|
|
3013
|
+
pagedResult: paginatedResult,
|
|
3014
|
+
pagedTotal: total,
|
|
3015
|
+
});
|
|
3016
|
+
})));
|
|
3017
|
+
}
|
|
3018
|
+
function countActiveFilters(filters, initialFilters) {
|
|
3019
|
+
return Object.keys(initialFilters).filter((key) => isFilterActive(filters[key], initialFilters[key])).length;
|
|
3020
|
+
}
|
|
3021
|
+
function isFilterActive(currentValue, initialValue) {
|
|
3022
|
+
if (Array.isArray(currentValue) || Array.isArray(initialValue)) {
|
|
3023
|
+
return !areFilterArraysEqual(toFilterArray(currentValue), toFilterArray(initialValue));
|
|
3024
|
+
}
|
|
3025
|
+
return currentValue !== initialValue;
|
|
3026
|
+
}
|
|
3027
|
+
function toFilterArray(value) {
|
|
3028
|
+
if (Array.isArray(value))
|
|
3029
|
+
return value;
|
|
3030
|
+
if (value === undefined || typeof value === 'boolean')
|
|
3031
|
+
return [];
|
|
3032
|
+
return [value];
|
|
3033
|
+
}
|
|
3034
|
+
function areFilterArraysEqual(left, right) {
|
|
3035
|
+
if (left.length !== right.length)
|
|
3036
|
+
return false;
|
|
3037
|
+
const sortedLeft = [...left].map(String).sort();
|
|
3038
|
+
const sortedRight = [...right].map(String).sort();
|
|
3039
|
+
return sortedLeft.every((value, index) => value === sortedRight[index]);
|
|
3040
|
+
}
|
|
3041
|
+
function namespacedRecord(namespace, value) {
|
|
3042
|
+
if (!namespace)
|
|
3043
|
+
return value;
|
|
3044
|
+
const prefix = toCamelCase(namespace);
|
|
3045
|
+
const title = capitalize(prefix);
|
|
3046
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => {
|
|
3047
|
+
const prefixedKey = key.startsWith('is')
|
|
3048
|
+
? `is${title}${key.slice(2)}`
|
|
3049
|
+
: key.startsWith('has')
|
|
3050
|
+
? `has${title}${key.slice(3)}`
|
|
3051
|
+
: `${prefix}${capitalize(key)}`;
|
|
3052
|
+
return [prefixedKey, item];
|
|
3053
|
+
}));
|
|
3054
|
+
}
|
|
3055
|
+
|
|
3056
|
+
function withCumulativePaginatedResource(options, factory) {
|
|
3057
|
+
const prefix = (options.namespace ? toCamelCase(options.namespace) : '');
|
|
3058
|
+
const title = capitalize(prefix);
|
|
3059
|
+
return signalStoreFeature(withPaginatedResource({
|
|
3060
|
+
initialFilters: options.initialFilters ?? {},
|
|
3061
|
+
namespace: options.namespace ?? '',
|
|
3062
|
+
pageSize: options.pageSize,
|
|
3063
|
+
}, factory), withFeature((store) => withProps(() => {
|
|
3064
|
+
const paginatedStore = store;
|
|
3065
|
+
const page = paginatedStore[prefix ? `${prefix}Page` : 'page'];
|
|
3066
|
+
const pageSize = paginatedStore[prefix ? `${prefix}PageSize` : 'pageSize'];
|
|
3067
|
+
const pagedResource = paginatedStore[prefix ? `${prefix}PagedResource` : 'pagedResource'];
|
|
3068
|
+
const pagedResult = paginatedStore[prefix ? `${prefix}PagedResult` : 'pagedResult'];
|
|
3069
|
+
const pagedTotal = paginatedStore[prefix ? `${prefix}PagedTotal` : 'pagedTotal'];
|
|
3070
|
+
const hasPagedError = paginatedStore[`has${title}PagedError`];
|
|
3071
|
+
const isPagedLoading = paginatedStore[`is${title}PagedLoading`];
|
|
3072
|
+
const setPage = paginatedStore[`set${title}Page`];
|
|
3073
|
+
const pageCache = linkedSignal({ ...(ngDevMode ? { debugName: "pageCache" } : /* istanbul ignore next */ {}), source: pagedResult,
|
|
3074
|
+
computation: (result, previous) => {
|
|
3075
|
+
if (!result)
|
|
3076
|
+
return previous?.value ?? { pages: new Map() };
|
|
3077
|
+
if (result.page === 1)
|
|
3078
|
+
return { pages: new Map([[1, result.items]]) };
|
|
3079
|
+
const pages = new Map(previous?.value.pages ?? []);
|
|
3080
|
+
pages.set(result.page, result.items);
|
|
3081
|
+
return { pages };
|
|
3082
|
+
} });
|
|
3083
|
+
const visiblePage = linkedSignal({ ...(ngDevMode ? { debugName: "visiblePage" } : /* istanbul ignore next */ {}), source: pagedResult,
|
|
3084
|
+
computation: (result, previous) => result?.page === 1 ? 1 : (previous?.value ?? 1) });
|
|
3085
|
+
const loadedPageCount = computed(() => contiguousPageCount(pageCache().pages), /* @ts-ignore */
|
|
3086
|
+
...(ngDevMode ? [{ debugName: "loadedPageCount" }] : /* istanbul ignore next */ []));
|
|
3087
|
+
const items = computed(() => flattenPages(pageCache().pages, visiblePage(), options.selectId), /* @ts-ignore */
|
|
3088
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
3089
|
+
const hasNextPage = computed(() => visiblePage() < loadedPageCount() ||
|
|
3090
|
+
loadedPageCount() < Math.ceil(pagedTotal() / pageSize()), /* @ts-ignore */
|
|
3091
|
+
...(ngDevMode ? [{ debugName: "hasNextPage" }] : /* istanbul ignore next */ []));
|
|
3092
|
+
const nextPageItemCount = computed(() => hasNextPage()
|
|
3093
|
+
? Math.min(pageSize(), Math.max(0, pagedTotal() - items().length))
|
|
3094
|
+
: 0, /* @ts-ignore */
|
|
3095
|
+
...(ngDevMode ? [{ debugName: "nextPageItemCount" }] : /* istanbul ignore next */ []));
|
|
3096
|
+
const loadNextPage = () => {
|
|
3097
|
+
if (isPagedLoading() || !hasNextPage())
|
|
3098
|
+
return;
|
|
3099
|
+
if (hasPagedError()) {
|
|
3100
|
+
pagedResource.reload();
|
|
3101
|
+
return;
|
|
3102
|
+
}
|
|
3103
|
+
const nextPage = visiblePage() + 1;
|
|
3104
|
+
visiblePage.set(nextPage);
|
|
3105
|
+
if (nextPage > loadedPageCount())
|
|
3106
|
+
setPage(loadedPageCount() + 1);
|
|
3107
|
+
};
|
|
3108
|
+
const resetPagination = () => {
|
|
3109
|
+
visiblePage.set(1);
|
|
3110
|
+
if (page() === 1)
|
|
3111
|
+
pagedResource.reload();
|
|
3112
|
+
else
|
|
3113
|
+
setPage(1);
|
|
3114
|
+
};
|
|
3115
|
+
const retryPage = () => {
|
|
3116
|
+
if (hasPagedError() && !isPagedLoading())
|
|
3117
|
+
pagedResource.reload();
|
|
3118
|
+
};
|
|
3119
|
+
return {
|
|
3120
|
+
[prefix ? `${prefix}Items` : 'items']: items,
|
|
3121
|
+
[prefix ? `${prefix}NextPageItemCount` : 'nextPageItemCount']: nextPageItemCount,
|
|
3122
|
+
[`has${title}NextPage`]: hasNextPage,
|
|
3123
|
+
[`loadNext${title}Page`]: loadNextPage,
|
|
3124
|
+
[`reset${title}Pagination`]: resetPagination,
|
|
3125
|
+
[`reset${title}VisiblePage`]: () => visiblePage.set(1),
|
|
3126
|
+
[`retry${title}Page`]: retryPage,
|
|
3127
|
+
};
|
|
3128
|
+
})));
|
|
3129
|
+
}
|
|
3130
|
+
function contiguousPageCount(pages) {
|
|
3131
|
+
let count = 0;
|
|
3132
|
+
while (pages.has(count + 1))
|
|
3133
|
+
count += 1;
|
|
3134
|
+
return count;
|
|
3135
|
+
}
|
|
3136
|
+
function flattenPages(pages, pageCount, selectId) {
|
|
3137
|
+
const items = [];
|
|
3138
|
+
const ids = new Set();
|
|
3139
|
+
for (let page = 1; page <= pageCount; page += 1) {
|
|
3140
|
+
const pageItems = pages.get(page);
|
|
3141
|
+
if (!pageItems)
|
|
3142
|
+
break;
|
|
3143
|
+
for (const item of pageItems) {
|
|
3144
|
+
const id = selectId(item);
|
|
3145
|
+
if (ids.has(id))
|
|
3146
|
+
continue;
|
|
3147
|
+
ids.add(id);
|
|
3148
|
+
items.push(item);
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
return items;
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
function withInvalidationRevision(options = {}) {
|
|
3155
|
+
const prefix = (options.namespace ? toCamelCase(options.namespace) : '');
|
|
3156
|
+
const title = capitalize(prefix);
|
|
3157
|
+
const revisionKey = (prefix ? `${prefix}Revision` : 'revision');
|
|
3158
|
+
const invalidateKey = (options.namespace ? `invalidate${title}` : 'invalidate');
|
|
3159
|
+
return signalStoreFeature(withState({
|
|
3160
|
+
[revisionKey]: 0,
|
|
3161
|
+
}), withMethods((store) => {
|
|
3162
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
3163
|
+
const revision = store[revisionKey];
|
|
3164
|
+
return {
|
|
3165
|
+
[invalidateKey]() {
|
|
3166
|
+
patchState(store, {
|
|
3167
|
+
[revisionKey]: revision() + 1,
|
|
3168
|
+
});
|
|
3169
|
+
},
|
|
3170
|
+
};
|
|
3171
|
+
}));
|
|
3172
|
+
}
|
|
3173
|
+
|
|
3174
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
3175
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3176
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3177
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
3178
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
3179
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
3180
|
+
const UNSTABLE_FLAG = /* @__PURE__ */ Symbol('unstable flag');
|
|
3181
|
+
function pageResourceConfig(config) {
|
|
3182
|
+
return config;
|
|
3183
|
+
}
|
|
3184
|
+
function withPageResources(sourcesObj) {
|
|
3185
|
+
return withProps(() => ({
|
|
3186
|
+
...makePageResources(sourcesObj),
|
|
3187
|
+
}));
|
|
3188
|
+
}
|
|
3189
|
+
function makePageResources(sourcesObj) {
|
|
3190
|
+
const injector = inject(Injector);
|
|
3191
|
+
const resourceRefs = toResourceRefs(sourcesObj);
|
|
3192
|
+
const sourcesArr = Object.values(resourceRefs);
|
|
3193
|
+
const pageErrors = computed(() => sourcesArr.map((item) => item.error()).filter(isNotNullable), /* @ts-ignore */
|
|
3194
|
+
...(ngDevMode ? [{ debugName: "pageErrors" }] : /* istanbul ignore next */ []));
|
|
3195
|
+
const isPageError = reduceWith('or', sourcesArr, (item) => {
|
|
3196
|
+
const reloading = matchReloading(item);
|
|
3197
|
+
const hasError = !!item.error();
|
|
3198
|
+
return !reloading && hasError;
|
|
3199
|
+
});
|
|
3200
|
+
const isPageInitializing = reduceWith('or', sourcesArr, (item) => {
|
|
3201
|
+
const idle = matchIdle(item);
|
|
3202
|
+
const loading = matchLoading(item);
|
|
3203
|
+
const reloading = matchReloading(item);
|
|
3204
|
+
const hasError = !!item.error();
|
|
3205
|
+
return idle || loading || (reloading && hasError);
|
|
3206
|
+
});
|
|
3207
|
+
const isPageStable = reduceWith('and', sourcesArr, (item) => {
|
|
3208
|
+
const local = matchLocal(item);
|
|
3209
|
+
const resolved = matchResolved(item);
|
|
3210
|
+
const reloading = matchReloading(item);
|
|
3211
|
+
const noError = !item.error();
|
|
3212
|
+
return (local || resolved || reloading) && noError;
|
|
3213
|
+
});
|
|
3214
|
+
const pageStatus = computed(() => mapToStatus({
|
|
3215
|
+
isError: isPageError(),
|
|
3216
|
+
isInitializing: isPageInitializing(),
|
|
3217
|
+
isStable: isPageStable(),
|
|
3218
|
+
}), /* @ts-ignore */
|
|
3219
|
+
...(ngDevMode ? [{ debugName: "pageStatus" }] : /* istanbul ignore next */ []));
|
|
3220
|
+
return {
|
|
3221
|
+
...makeResources(sourcesObj, isPageStable),
|
|
3222
|
+
pageErrors,
|
|
3223
|
+
firstPageError: computed(() => pageErrors()[0]),
|
|
3224
|
+
isPageError,
|
|
3225
|
+
isPageInitializing,
|
|
3226
|
+
isPageStable,
|
|
3227
|
+
pageStatus,
|
|
3228
|
+
pageResources: {
|
|
3229
|
+
every: makeResourcesState('and', sourcesArr),
|
|
3230
|
+
some: makeResourcesState('or', sourcesArr),
|
|
3231
|
+
...resourceRefs,
|
|
3232
|
+
},
|
|
3233
|
+
reloadPage() {
|
|
3234
|
+
sourcesArr.forEach((ref) => ref.reload());
|
|
3235
|
+
},
|
|
3236
|
+
awaitPageReady(errorCtor = Error) {
|
|
3237
|
+
return new Promise((resolve, reject) => {
|
|
3238
|
+
const ref = effect(() => {
|
|
3239
|
+
if (isPageError()) {
|
|
3240
|
+
ref.destroy();
|
|
3241
|
+
reject(new errorCtor());
|
|
3242
|
+
}
|
|
3243
|
+
else if (isPageStable()) {
|
|
3244
|
+
ref.destroy();
|
|
3245
|
+
resolve(true);
|
|
3246
|
+
}
|
|
3247
|
+
}, { ...(ngDevMode ? { debugName: "ref" } : /* istanbul ignore next */ {}), injector });
|
|
3248
|
+
});
|
|
3249
|
+
},
|
|
3250
|
+
};
|
|
3251
|
+
}
|
|
3252
|
+
function makeResources(source, isStable) {
|
|
3253
|
+
return Object.fromEntries(entries(source).map(([key, input]) => [key, stableSignal(input, isStable)]));
|
|
3254
|
+
}
|
|
3255
|
+
function stableSignal(input, isStable) {
|
|
3256
|
+
const value = isPageResourceConfig(input)
|
|
3257
|
+
? safeResourceValue(input.resource, input.defaultValue)
|
|
3258
|
+
: safeResourceValue(input);
|
|
3259
|
+
const transformedValue = isPageResourceConfig(input) && input.transform
|
|
3260
|
+
? computed(() => input.transform(value()))
|
|
3261
|
+
: value;
|
|
3262
|
+
return stableValueSignal(transformedValue, isStable);
|
|
3263
|
+
}
|
|
3264
|
+
function stableValueSignal(value, isStable) {
|
|
3265
|
+
return linkedSignal({
|
|
3266
|
+
source: () => {
|
|
3267
|
+
if (!isStable())
|
|
3268
|
+
return UNSTABLE_FLAG;
|
|
3269
|
+
return value();
|
|
3270
|
+
},
|
|
3271
|
+
computation: (source, prev) => source === UNSTABLE_FLAG ? (prev?.value ?? value()) : source,
|
|
3272
|
+
}).asReadonly();
|
|
3273
|
+
}
|
|
3274
|
+
function toResourceRefs(sourcesObj) {
|
|
3275
|
+
return Object.fromEntries(entries(sourcesObj).map(([key, input]) => [key, resourceRefOf(input)]));
|
|
3276
|
+
}
|
|
3277
|
+
function resourceRefOf(input) {
|
|
3278
|
+
return isPageResourceConfig(input) ? input.resource : input;
|
|
3279
|
+
}
|
|
3280
|
+
function isPageResourceConfig(input) {
|
|
3281
|
+
return isObject(input) && 'resource' in input;
|
|
3282
|
+
}
|
|
3283
|
+
function makeResourcesState(operator, resources) {
|
|
3284
|
+
return {
|
|
3285
|
+
isError: reduceWith(operator, resources, matchError),
|
|
3286
|
+
isIdle: reduceWith(operator, resources, matchIdle),
|
|
3287
|
+
isLoading: reduceWith(operator, resources, matchLoading),
|
|
3288
|
+
isLocal: reduceWith(operator, resources, matchLocal),
|
|
3289
|
+
isReloading: reduceWith(operator, resources, matchReloading),
|
|
3290
|
+
isResolved: reduceWith(operator, resources, matchResolved),
|
|
3291
|
+
};
|
|
3292
|
+
}
|
|
3293
|
+
function reduceWith(operator, resources, predicate) {
|
|
3294
|
+
return computed(() => resources
|
|
3295
|
+
.map((item) => predicate(item))
|
|
3296
|
+
.reduce((res, value) => operation[operator](res, value), operator === 'and'));
|
|
3297
|
+
}
|
|
3298
|
+
function mapToStatus(state) {
|
|
3299
|
+
if (state.isError)
|
|
3300
|
+
return 'error';
|
|
3301
|
+
if (state.isInitializing)
|
|
3302
|
+
return 'initializing';
|
|
3303
|
+
if (state.isStable)
|
|
3304
|
+
return 'stable';
|
|
3305
|
+
return 'error'; // fallback case
|
|
3306
|
+
}
|
|
3307
|
+
const operation = {
|
|
3308
|
+
and: (a, b) => a && b, // Conjunction
|
|
3309
|
+
or: (a, b) => a || b, // Disjunction
|
|
3310
|
+
};
|
|
3311
|
+
function matchStatuses(...statuses) {
|
|
3312
|
+
return (item) => statuses.includes(item.status());
|
|
3313
|
+
}
|
|
3314
|
+
const matchError = /* @__PURE__ */ matchStatuses('error');
|
|
3315
|
+
const matchIdle = /* @__PURE__ */ matchStatuses('idle');
|
|
3316
|
+
const matchLoading = /* @__PURE__ */ matchStatuses('loading');
|
|
3317
|
+
const matchLocal = /* @__PURE__ */ matchStatuses('local');
|
|
3318
|
+
const matchReloading = /* @__PURE__ */ matchStatuses('reloading');
|
|
3319
|
+
const matchResolved = /* @__PURE__ */ matchStatuses('resolved');
|
|
3320
|
+
|
|
3321
|
+
function withResetState(...configs) {
|
|
3322
|
+
return signalStoreFeature(withProps((store) => {
|
|
3323
|
+
const initialState = getState(store);
|
|
3324
|
+
return {
|
|
3325
|
+
resetState() {
|
|
3326
|
+
patchState(store, initialState);
|
|
3327
|
+
for (const config of configs) {
|
|
3328
|
+
patchState(store, removeAllEntities(config));
|
|
3329
|
+
}
|
|
3330
|
+
},
|
|
3331
|
+
};
|
|
3332
|
+
}));
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3335
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3336
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3337
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
3338
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3339
|
+
function withRouteParams(mapper) {
|
|
3340
|
+
return withProps(() => {
|
|
3341
|
+
const activatedRoute = inject(ActivatedRoute);
|
|
3342
|
+
const paramsSignal = toSignal(activatedRoute.params);
|
|
3343
|
+
const queryParamsSignal = toSignal(activatedRoute.queryParams);
|
|
3344
|
+
const dataSignal = toSignal(activatedRoute.data);
|
|
3345
|
+
const params = computed(() => mapper({
|
|
3346
|
+
paramMap: createParamMapWithRequired(paramsSignal() ?? {}),
|
|
3347
|
+
queryParamMap: createParamMapWithRequired(queryParamsSignal() ?? {}),
|
|
3348
|
+
data: dataSignal(),
|
|
3349
|
+
}), /* @ts-ignore */
|
|
3350
|
+
...(ngDevMode ? [{ debugName: "params" }] : /* istanbul ignore next */ []));
|
|
3351
|
+
const computedParams = {};
|
|
3352
|
+
Object.keys(params()).forEach((key) => {
|
|
3353
|
+
computedParams[key] = computed(() => params()[key]);
|
|
3354
|
+
});
|
|
3355
|
+
return computedParams;
|
|
3356
|
+
});
|
|
3357
|
+
}
|
|
3358
|
+
function createParamMapWithRequired(params) {
|
|
3359
|
+
const paramMap = convertToParamMap(params);
|
|
3360
|
+
const requiredProxy = new Proxy(paramMap, {
|
|
3361
|
+
get(target, prop) {
|
|
3362
|
+
if (prop === 'get') {
|
|
3363
|
+
return (name) => {
|
|
3364
|
+
const value = target.get(name);
|
|
3365
|
+
assertNonNullable(value, `Route params ${name} is required`);
|
|
3366
|
+
return value;
|
|
3367
|
+
};
|
|
3368
|
+
}
|
|
3369
|
+
return Reflect.get(target, prop);
|
|
3370
|
+
},
|
|
3371
|
+
});
|
|
3372
|
+
paramMap.required = requiredProxy;
|
|
3373
|
+
return paramMap;
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3376
|
+
// Function to enable state synchronization with storage
|
|
3377
|
+
function withStorageSync(configOrKey) {
|
|
3378
|
+
const { autoSync = true, key, parse = JSON.parse, select = (state) => state, storage: storageFactory = () => localStorage, stringify = JSON.stringify, } = isString(configOrKey) ? { key: configOrKey } : configOrKey;
|
|
3379
|
+
const storage = storageFactory();
|
|
3380
|
+
return signalStoreFeature(withMethods((store) => ({
|
|
3381
|
+
clearStorage() {
|
|
3382
|
+
storage.removeItem(key);
|
|
3383
|
+
},
|
|
3384
|
+
readFromStorage() {
|
|
3385
|
+
const stateStr = storage.getItem(key);
|
|
3386
|
+
if (stateStr) {
|
|
3387
|
+
patchState(store, parse(stateStr));
|
|
3388
|
+
}
|
|
3389
|
+
},
|
|
3390
|
+
writeToStorage() {
|
|
3391
|
+
const slicedState = select(getState(store));
|
|
3392
|
+
storage.setItem(key, stringify(slicedState));
|
|
3393
|
+
},
|
|
3394
|
+
})), withHooks({
|
|
3395
|
+
onInit(store) {
|
|
3396
|
+
if (autoSync) {
|
|
3397
|
+
store.readFromStorage();
|
|
3398
|
+
watchState(store, () => store.writeToStorage());
|
|
3399
|
+
}
|
|
3400
|
+
},
|
|
3401
|
+
}));
|
|
3402
|
+
}
|
|
3403
|
+
|
|
3404
|
+
class LoaderResourceImpl {
|
|
3405
|
+
createOperator() {
|
|
3406
|
+
return (project) => switchMap((wrapped) => {
|
|
3407
|
+
this.state.update((state) => ({
|
|
3408
|
+
...state,
|
|
3409
|
+
error: undefined,
|
|
3410
|
+
nextParams: wrapped.params,
|
|
3411
|
+
status: wrapped.reload > 0 ? 'reloading' : 'loading',
|
|
3412
|
+
}));
|
|
3413
|
+
const error = (error) => {
|
|
3414
|
+
this.state.update((state) => ({
|
|
3415
|
+
...state,
|
|
3416
|
+
error,
|
|
3417
|
+
status: 'error',
|
|
3418
|
+
}));
|
|
3419
|
+
};
|
|
3420
|
+
let hasResult = false;
|
|
3421
|
+
return project(wrapped).pipe(tap({
|
|
3422
|
+
next: (result) => {
|
|
3423
|
+
hasResult = true;
|
|
3424
|
+
this.state.update((state) => ({
|
|
3425
|
+
...state,
|
|
3426
|
+
nextParams: undefined,
|
|
3427
|
+
params: wrapped.params,
|
|
3428
|
+
result,
|
|
3429
|
+
status: 'resolved',
|
|
3430
|
+
}));
|
|
3431
|
+
},
|
|
3432
|
+
error,
|
|
3433
|
+
complete: () => {
|
|
3434
|
+
if (!hasResult) {
|
|
3435
|
+
error();
|
|
3436
|
+
}
|
|
3437
|
+
},
|
|
3438
|
+
}), catchError(() => NEVER));
|
|
3439
|
+
});
|
|
3440
|
+
}
|
|
3441
|
+
constructor(srcParams, stream, config) {
|
|
3442
|
+
this.srcParams = srcParams;
|
|
3443
|
+
this.stream = stream;
|
|
3444
|
+
this.config = config;
|
|
3445
|
+
this.loadSub = undefined;
|
|
3446
|
+
this.destroyed = false;
|
|
3447
|
+
this.initialState = {
|
|
3448
|
+
error: undefined,
|
|
3449
|
+
nextParams: undefined,
|
|
3450
|
+
params: untracked(this.srcParams),
|
|
3451
|
+
result: this.config.defaultValue,
|
|
3452
|
+
status: 'idle',
|
|
3453
|
+
};
|
|
3454
|
+
this.state = signal(this.initialState, /* @ts-ignore */
|
|
3455
|
+
...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
3456
|
+
this.status = computed(() => this.state().status, /* @ts-ignore */
|
|
3457
|
+
...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
|
|
3458
|
+
this.error = computed(() => this.state().error, /* @ts-ignore */
|
|
3459
|
+
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
3460
|
+
this.isError = computed((status = this.status()) => status === 'error', /* @ts-ignore */
|
|
3461
|
+
...(ngDevMode ? [{ debugName: "isError" }] : /* istanbul ignore next */ []));
|
|
3462
|
+
this.isIdle = computed((status = this.status()) => status === 'idle', /* @ts-ignore */
|
|
3463
|
+
...(ngDevMode ? [{ debugName: "isIdle" }] : /* istanbul ignore next */ []));
|
|
3464
|
+
this.isResolved = computed((status = this.status()) => status === 'resolved', /* @ts-ignore */
|
|
3465
|
+
...(ngDevMode ? [{ debugName: "isResolved" }] : /* istanbul ignore next */ []));
|
|
3466
|
+
this.isLoading = computed((status = this.status()) => status === 'loading' || status === 'reloading', /* @ts-ignore */
|
|
3467
|
+
...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
|
|
3468
|
+
this.value = linkedSignal({ ...(ngDevMode ? { debugName: "value" } : /* istanbul ignore next */ {}), computation: (source) => source.result,
|
|
3469
|
+
equal: this.config.compareResult,
|
|
3470
|
+
source: this.state });
|
|
3471
|
+
this.params = linkedSignal({ ...(ngDevMode ? { debugName: "params" } : /* istanbul ignore next */ {}), source: this.state,
|
|
3472
|
+
computation: (source) => source.nextParams ?? source.params });
|
|
3473
|
+
this.nextParams = computed(this.srcParams, { ...(ngDevMode ? { debugName: "nextParams" } : /* istanbul ignore next */ {}), equal: this.compareParams.bind(this) });
|
|
3474
|
+
this.externalParams = linkedSignal({ ...(ngDevMode ? { debugName: "externalParams" } : /* istanbul ignore next */ {}), source: this.nextParams,
|
|
3475
|
+
computation: (source) => ({ reload: 0, params: source }) });
|
|
3476
|
+
this.snapshot = computed(() => {
|
|
3477
|
+
const status = this.status();
|
|
3478
|
+
if (status === 'error') {
|
|
3479
|
+
const error = this.error();
|
|
3480
|
+
assertNonNullable(error, 'error');
|
|
3481
|
+
return { status: 'error', error };
|
|
3482
|
+
}
|
|
3483
|
+
else {
|
|
3484
|
+
return { status, value: this.value() };
|
|
3485
|
+
}
|
|
3486
|
+
}, /* @ts-ignore */
|
|
3487
|
+
...(ngDevMode ? [{ debugName: "snapshot" }] : /* istanbul ignore next */ []));
|
|
3488
|
+
this.abort$ = new Subject();
|
|
3489
|
+
this.value.set = this.set.bind(this);
|
|
3490
|
+
this.value.update = this.update.bind(this);
|
|
3491
|
+
this.params.set = this.setParams.bind(this);
|
|
3492
|
+
this.params.update = this.updateParams.bind(this);
|
|
3493
|
+
const { injector, lazy } = config;
|
|
3494
|
+
this.loadSub = toObservable(this.externalParams)
|
|
3495
|
+
.pipe(lazy ? skip(1) : tap(), this.createOperator()((wrapped) => {
|
|
3496
|
+
const controller = new AbortController();
|
|
3497
|
+
let shouldAbort = true;
|
|
3498
|
+
return from(stream(wrapped.params, controller.signal)).pipe(tap({
|
|
3499
|
+
complete: () => {
|
|
3500
|
+
shouldAbort = false;
|
|
3501
|
+
},
|
|
3502
|
+
finalize: () => {
|
|
3503
|
+
if (shouldAbort)
|
|
3504
|
+
controller.abort();
|
|
3505
|
+
},
|
|
3506
|
+
}));
|
|
3507
|
+
}))
|
|
3508
|
+
.subscribe();
|
|
3509
|
+
injector.get(DestroyRef).onDestroy(() => this.destroy());
|
|
3510
|
+
}
|
|
3511
|
+
hasValue() {
|
|
3512
|
+
return isNotNullable(this.value());
|
|
3513
|
+
}
|
|
3514
|
+
asReadonly() {
|
|
3515
|
+
return this;
|
|
3516
|
+
}
|
|
3517
|
+
destroy() {
|
|
3518
|
+
this.destroyed = true;
|
|
3519
|
+
this.abort$.next();
|
|
3520
|
+
this.abort$.complete();
|
|
3521
|
+
this.loadSub?.unsubscribe();
|
|
3522
|
+
this.loadSub = undefined;
|
|
3523
|
+
}
|
|
3524
|
+
set(value) {
|
|
3525
|
+
if (this.destroyed) {
|
|
3526
|
+
return;
|
|
3527
|
+
}
|
|
3528
|
+
this.abort$.next();
|
|
3529
|
+
this.state.update((state) => ({
|
|
3530
|
+
...state,
|
|
3531
|
+
error: undefined,
|
|
3532
|
+
result: value,
|
|
3533
|
+
status: 'local',
|
|
3534
|
+
}));
|
|
3535
|
+
}
|
|
3536
|
+
update(updater) {
|
|
3537
|
+
this.set(updater(untracked(this.value)));
|
|
3538
|
+
}
|
|
3539
|
+
setParams(params) {
|
|
3540
|
+
this.srcParams.set(params);
|
|
3541
|
+
}
|
|
3542
|
+
updateParams(updater) {
|
|
3543
|
+
this.setParams(updater(untracked(this.srcParams)));
|
|
3544
|
+
}
|
|
3545
|
+
reload() {
|
|
3546
|
+
if (untracked(this.isIdle) || untracked(this.isLoading)) {
|
|
3547
|
+
return false;
|
|
3548
|
+
}
|
|
3549
|
+
this.externalParams.update(({ reload, params }) => ({
|
|
3550
|
+
reload: reload + 1,
|
|
3551
|
+
params,
|
|
3552
|
+
}));
|
|
3553
|
+
return true;
|
|
3554
|
+
}
|
|
3555
|
+
reset() {
|
|
3556
|
+
this.abort$.next();
|
|
3557
|
+
this.state.set(this.initialState);
|
|
3558
|
+
}
|
|
3559
|
+
compareParams(prev, next) {
|
|
3560
|
+
return !this.isIdle() && this.config.compareParams(prev, next);
|
|
3561
|
+
}
|
|
3562
|
+
}
|
|
3563
|
+
function loaderResource({ compareParams = deepEqualComparer(), compareResult, defaultValue, injector = inject(Injector), lazy = false, stream, params, }) {
|
|
3564
|
+
return new LoaderResourceImpl(linkedSignal(params), stream, {
|
|
3565
|
+
compareParams,
|
|
3566
|
+
compareResult: compareResult && wrapNullishComparer(compareResult),
|
|
3567
|
+
defaultValue,
|
|
3568
|
+
injector,
|
|
3569
|
+
lazy,
|
|
3570
|
+
});
|
|
3571
|
+
}
|
|
3572
|
+
|
|
3573
|
+
function pagedResource({ compareParams = deepEqualComparer(), compareResult, defaultPageSize = 10, defaultValue = pagedResult([]), params, injector = inject(Injector), lazy = false, stream, }) {
|
|
3574
|
+
const pagedParamsSrc = pagedParams(params, defaultPageSize);
|
|
3575
|
+
return new LoaderResourceImpl(pagedParamsSrc, stream, {
|
|
3576
|
+
compareParams: pagedParamsComparer(compareParams),
|
|
3577
|
+
compareResult: compareResult && pagedResultComparer(compareResult),
|
|
3578
|
+
defaultValue,
|
|
3579
|
+
injector,
|
|
3580
|
+
lazy,
|
|
3581
|
+
});
|
|
3582
|
+
}
|
|
3583
|
+
const sortComparer =
|
|
3584
|
+
/* @__PURE__ */ wrapNullishComparer((s1, s2) => s1.active === s2.active && s1.direction === s2.direction);
|
|
3585
|
+
function pagedParamsComparer(comparer) {
|
|
3586
|
+
return (a, b) => {
|
|
3587
|
+
const isSameParams = comparer(a.params, b.params);
|
|
3588
|
+
const isSamePageIndex = a.pageIndex === b.pageIndex;
|
|
3589
|
+
const isSamePageSize = a.pageSize === b.pageSize;
|
|
3590
|
+
const isSameSearch = a.search === b.search;
|
|
3591
|
+
const isSameSort = sortComparer(a.sort, b.sort);
|
|
3592
|
+
return [
|
|
3593
|
+
isSameParams,
|
|
3594
|
+
isSamePageIndex,
|
|
3595
|
+
isSamePageSize,
|
|
3596
|
+
isSameSearch,
|
|
3597
|
+
isSameSort,
|
|
3598
|
+
].every(Boolean);
|
|
3599
|
+
};
|
|
3600
|
+
}
|
|
3601
|
+
function pagedResultComparer(comparer) {
|
|
3602
|
+
return (a, b) => {
|
|
3603
|
+
const isSameData = comparer(a.data, b.data);
|
|
3604
|
+
const isSameTotal = a.total === b.total;
|
|
3605
|
+
return [isSameData, isSameTotal].every(Boolean);
|
|
3606
|
+
};
|
|
3607
|
+
}
|
|
3608
|
+
function pagedParams(params, pageSize) {
|
|
3609
|
+
if (!params) {
|
|
3610
|
+
return signal({
|
|
3611
|
+
params: {},
|
|
3612
|
+
pageIndex: 0,
|
|
3613
|
+
pageSize,
|
|
3614
|
+
});
|
|
3615
|
+
}
|
|
3616
|
+
return linkedSignal({
|
|
3617
|
+
source: params,
|
|
3618
|
+
computation: (source, prev) => ({
|
|
3619
|
+
pageSize,
|
|
3620
|
+
...prev?.value,
|
|
3621
|
+
pageIndex: 0,
|
|
3622
|
+
params: source,
|
|
3623
|
+
}),
|
|
3624
|
+
});
|
|
3625
|
+
}
|
|
3626
|
+
function pagedResult(data) {
|
|
3627
|
+
return { data, total: data.length };
|
|
3628
|
+
}
|
|
3629
|
+
|
|
3630
|
+
class ScrollResourceImpl extends LoaderResourceImpl {
|
|
3631
|
+
createOperator() {
|
|
3632
|
+
return (project) => pipe(switchMapConcurrent((wrapped) => {
|
|
3633
|
+
this.state.update((state) => ({
|
|
3634
|
+
...state,
|
|
3635
|
+
status: 'loading',
|
|
3636
|
+
}));
|
|
3637
|
+
return timer(this.config.loadDelay).pipe(switchMap(() => project(wrapped)), tap({
|
|
3638
|
+
next: (result) => {
|
|
3639
|
+
this.state.update((state) => ({
|
|
3640
|
+
...state,
|
|
3641
|
+
result: this.handleResult(result, wrapped.params),
|
|
3642
|
+
}));
|
|
3643
|
+
},
|
|
3644
|
+
error: () => this.loadedPages.delete(wrapped.params.pageIndex),
|
|
3645
|
+
unsubscribe: () => this.loadedPages.delete(wrapped.params.pageIndex),
|
|
3646
|
+
subscribe: () => this.loadedPages.add(wrapped.params.pageIndex),
|
|
3647
|
+
}));
|
|
3648
|
+
}, {
|
|
3649
|
+
abort$: () => this.abort$.asObservable(),
|
|
3650
|
+
concurrent: this.config.maxParallelLoad,
|
|
3651
|
+
onEmpty: () => this.state.update((state) => ({
|
|
3652
|
+
...state,
|
|
3653
|
+
status: 'resolved',
|
|
3654
|
+
})),
|
|
3655
|
+
}), catchError(() => NEVER));
|
|
3656
|
+
}
|
|
3657
|
+
constructor(srcParams, stream, config) {
|
|
3658
|
+
super(srcParams, stream, config);
|
|
3659
|
+
this.srcParams = srcParams;
|
|
3660
|
+
this.stream = stream;
|
|
3661
|
+
this.config = config;
|
|
3662
|
+
this.loadedPages = new Set();
|
|
3663
|
+
}
|
|
3664
|
+
isPageLoaded(pageIndex) {
|
|
3665
|
+
return this.loadedPages.has(pageIndex);
|
|
3666
|
+
}
|
|
3667
|
+
loadPagesInRange(startOffset, endOffset) {
|
|
3668
|
+
const startPage = this.getPageIndex(startOffset, 'down');
|
|
3669
|
+
const endPage = endOffset
|
|
3670
|
+
? this.getPageIndex(endOffset - 1, 'down')
|
|
3671
|
+
: startPage;
|
|
3672
|
+
for (let i = startPage; i <= endPage; i++) {
|
|
3673
|
+
this.loadPage(i);
|
|
3674
|
+
}
|
|
3675
|
+
}
|
|
3676
|
+
loadPage(pageIndex) {
|
|
3677
|
+
this.updateParams((params) => ({ ...params, pageIndex }));
|
|
3678
|
+
}
|
|
3679
|
+
reload(currentIndex) {
|
|
3680
|
+
this.abort$.next();
|
|
3681
|
+
const loadedPages = Array.from(this.loadedPages);
|
|
3682
|
+
currentIndex ??= loadedPages.length - 1;
|
|
3683
|
+
const pagesToLoad = getCenteredSlice(loadedPages, currentIndex, this.config.maxParallelLoad);
|
|
3684
|
+
for (const pageIndex of pagesToLoad) {
|
|
3685
|
+
this.loadedPages.delete(pageIndex);
|
|
3686
|
+
this.loadPage(pageIndex);
|
|
3687
|
+
}
|
|
3688
|
+
return true;
|
|
3689
|
+
}
|
|
3690
|
+
reset() {
|
|
3691
|
+
this.loadedPages.clear();
|
|
3692
|
+
super.reset();
|
|
3693
|
+
}
|
|
3694
|
+
compareParams(prev, next) {
|
|
3695
|
+
const isEqual = super.compareParams(prev, {
|
|
3696
|
+
...next,
|
|
3697
|
+
pageIndex: prev.pageIndex,
|
|
3698
|
+
});
|
|
3699
|
+
if (!isEqual) {
|
|
3700
|
+
this.reset();
|
|
3701
|
+
}
|
|
3702
|
+
if (this.loadedPages.has(next.pageIndex)) {
|
|
3703
|
+
return true;
|
|
3704
|
+
}
|
|
3705
|
+
return false;
|
|
3706
|
+
}
|
|
3707
|
+
getPageIndex(offset, round) {
|
|
3708
|
+
const pageIndex = offset / this.params().pageSize;
|
|
3709
|
+
switch (round) {
|
|
3710
|
+
case 'up':
|
|
3711
|
+
return Math.ceil(pageIndex);
|
|
3712
|
+
case 'down':
|
|
3713
|
+
return Math.floor(pageIndex);
|
|
3714
|
+
default:
|
|
3715
|
+
return Math.round(pageIndex);
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3718
|
+
handleResult(result, params) {
|
|
3719
|
+
const { result: prevResult } = this.state();
|
|
3720
|
+
const { pageIndex, pageSize } = params;
|
|
3721
|
+
const head = prevResult.data.slice(0, pageIndex * pageSize);
|
|
3722
|
+
const tail = prevResult.data.slice((pageIndex + 1) * pageSize);
|
|
3723
|
+
const allPages = [...head, ...result.data, ...tail];
|
|
3724
|
+
allPages.length = result.total;
|
|
3725
|
+
const nextResult = {
|
|
3726
|
+
total: result.total,
|
|
3727
|
+
data: allPages,
|
|
3728
|
+
};
|
|
3729
|
+
return nextResult;
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
function scrollResource({ compareParams = deepEqualComparer(), compareResult, defaultPageSize = 10, defaultValue = pagedResult([]), injector = inject(Injector), lazy = false, loadDelay = 100, maxParallelLoad = 3, params, stream, }) {
|
|
3733
|
+
const pagedParamsSrc = pagedParams(params, defaultPageSize);
|
|
3734
|
+
return new ScrollResourceImpl(pagedParamsSrc, stream, {
|
|
3735
|
+
compareParams: pagedParamsComparer(compareParams),
|
|
3736
|
+
compareResult: compareResult && pagedResultComparer(compareResult),
|
|
3737
|
+
defaultValue,
|
|
3738
|
+
injector,
|
|
3739
|
+
lazy,
|
|
3740
|
+
loadDelay,
|
|
3741
|
+
maxParallelLoad,
|
|
3742
|
+
});
|
|
3743
|
+
}
|
|
3744
|
+
|
|
3745
|
+
function sliceSignal(initial, options) {
|
|
3746
|
+
return _sliceSignal(signal(initial, options));
|
|
3747
|
+
}
|
|
3748
|
+
function _sliceSignal(source) {
|
|
3749
|
+
for (const [key, value] of entries(untracked(source))) {
|
|
3750
|
+
const property = isObject(value)
|
|
3751
|
+
? _sliceSignal(createLinkedSlice(source, key))
|
|
3752
|
+
: createLinkedSlice(source, key);
|
|
3753
|
+
Object.defineProperty(source, key, {
|
|
3754
|
+
get: () => property,
|
|
3755
|
+
enumerable: true,
|
|
3756
|
+
configurable: true,
|
|
3757
|
+
});
|
|
3758
|
+
}
|
|
3759
|
+
return source;
|
|
3760
|
+
}
|
|
3761
|
+
function createLinkedSlice(source, key) {
|
|
3762
|
+
const slice = linkedSignal(() => source()[key], /* @ts-ignore */
|
|
3763
|
+
...(ngDevMode ? [{ debugName: "slice" }] : /* istanbul ignore next */ []));
|
|
3764
|
+
slice.set = (newValue) => {
|
|
3765
|
+
source.update((prev) => ({ ...prev, [key]: newValue }));
|
|
3766
|
+
};
|
|
3767
|
+
slice.update = (fn) => {
|
|
3768
|
+
source.update((prev) => ({ ...prev, [key]: fn(prev[key]) }));
|
|
3769
|
+
};
|
|
3770
|
+
return slice;
|
|
3771
|
+
}
|
|
3772
|
+
|
|
3773
|
+
function resolveValueOrSignal(valueOrSignal) {
|
|
3774
|
+
return isSignal(valueOrSignal) ? valueOrSignal : signal(valueOrSignal);
|
|
3775
|
+
}
|
|
3776
|
+
|
|
3777
|
+
/**
|
|
3778
|
+
* Generated bundle index. Do not edit.
|
|
3779
|
+
*/
|
|
3780
|
+
|
|
3781
|
+
export { AddressPipe, AnchorToTopDirective, AnchorToTopItemDirective, BOTTOM_CENTER_POSITION, BOTTOM_END_POSITION, BOTTOM_START_POSITION, CapitalizePipe, ClampObserverDirective, ClampTargetDirective, Color, ColorStateDirective, CurrencyPipe, DiffOfArrPipe, Direction, DirectionStateDirective, DisabledStateDirective, END_BOTTOM_POSITION, END_CENTER_POSITION, END_TOP_POSITION, ErrorDirective, FileSizePipe, FilterOfArrPipe, FrenchPhoneNumberPipe, GroupByOfArrPipe, HideIfEmptyDirective, HintDirective, Hue, HueStateDirective, InlineStateDirective, InvalidStateDirective, IsUrlExact, IsUrlSubset, JoinOfArrPipe, KeyInPipe, LabelDirective, LetDirective, LinkifyPipe, LoaderResourceImpl, LoadingStateDirective, LogPrinter, Logger, MapOfArrPipe, MapPipe, MinimalRouterStateSerializer, MonthlyCurrencyPipe, NearBottomDirective, NearTopDirective, OVERLAY_POSITIONS, Orientation, OrientationStateDirective, OverlayPosition, PhoneNumberPipe, PluckOfArrPipe, PreventDefaultDirective, Printer, Radius, RadiusStateDirective, ReadonlyStateDirective, ReplayQueryListObservable, RequiredStateDirective, RouterLinkDisabledDirective, RouterStore, START_BOTTOM_POSITION, START_CENTER_POSITION, START_TOP_POSITION, ScrollDataSource, ScrollToBottomDirective, ScrollToBottomItemDirective, Size, SizeStateDirective, SortOfArrPipe, StopPropagationDirective, StorageService, StrictTitleCasePipe, SubtitleDirective, TOP_CENTER_POSITION, TOP_END_POSITION, TOP_START_POSITION, TaskError, TemplateContextDirective, TimeUtils, TitleDirective, TruncatePipe, UserFullnamePipe, UserInitialPipe, ViewResolver, WindowOpenDirective, anchorTarget, broadcastChannel, buildViewResolver, composeGuards, createInjectDict, createUnitFormatter, data, dataEntry, enterZone, formatCurrency, formatMonthlyCurrency, fromNextRender, getCurrentInjector, getDeepestRoute, getRootInjector, injectAppVersion, injectColorStateConf, injectDeploymentStage, injectDirectionStateConf, injectDisabledStateConf, injectDocumentVisibilityState, injectHueStateConf, injectInlineStateConf, injectInvalidStateConf, injectLoadingStateConf, injectNearBottomConf, injectNearTopConf, injectOrientationStateConf, injectRadiusStateConf, injectReadonlyStateConf, injectRequiredStateConf, injectSizeStateConf, injectWindow, injectWindowFocusState, isChunkError, isComponentRef, isFunctionConstructor, isHttpErrorResponse, isHttpResponse, isInjector, isNavigationEnd, isNavigationError, isNavigationStart, isResourceRef, isTemplateRef, keyIn, leaveZone, loaderResource, lostFocusDuration, makeInjectionRunnable, makeNonReactive, multiplicityAttribute, multiplicitySingle, numberClampAttribute, pageResourceConfig, pagedParams, pagedParamsComparer, pagedResource, pagedResult, pagedResultComparer, patchRouterLinkDisabled, provideAppVersion, provideColorStateConf, provideDeploymentStage, provideDevKitAngular, provideDirectionStateConf, provideDisabledStateConf, provideExistingOrFallback, provideHueStateConf, provideInlineStateConf, provideInvalidStateConf, provideLoadingStateConf, provideNearBottomConf, provideNearTopConf, provideOrientationStateConf, provideRadiusStateConf, provideReadonlyStateConf, provideRequiredStateConf, provideRouterStore, provideSizeStateConf, resolveData, resolveValueOrSignal, safeResourceValue, scrollResource, setRootInjector, skipForFragmentAndQueryChange, sliceSignal, taskEffect, triggerFileDownload, useRxMethod, useScreenSize, windowFactory, windowFocusState, withCallStatus, withCumulativePaginatedResource, withInvalidationRevision, withPageResources, withPaginatedResource, withResetState, withRouteParams, withStorageSync };
|
|
3782
|
+
//# sourceMappingURL=netwo-devkit-angular.mjs.map
|