@ngrdt/core 0.0.98 → 0.0.99
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/fesm2022/ngrdt-core.mjs +264 -73
- package/fesm2022/ngrdt-core.mjs.map +1 -1
- package/package.json +6 -6
- package/{index.d.ts → types/ngrdt-core.d.ts} +184 -44
package/fesm2022/ngrdt-core.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, ElementRef, Directive, Injectable, DestroyRef, ViewContainerRef, input, effect, signal, computed, LOCALE_ID, Pipe, booleanAttribute, untracked, linkedSignal, afterNextRender, isSignal } from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, ElementRef, Directive, Injectable, DestroyRef, ViewContainerRef, input, effect, makeEnvironmentProviders, provideAppInitializer, signal, computed, LOCALE_ID, Pipe, booleanAttribute, untracked, linkedSignal, afterNextRender, isSignal } from '@angular/core';
|
|
3
3
|
import { DOCUMENT } from '@angular/common';
|
|
4
|
-
import { of, concat, filter, map, catchError, defer, from } from 'rxjs';
|
|
4
|
+
import { of, concat, filter, map, catchError, defer, from, tap } from 'rxjs';
|
|
5
5
|
import { cs, enUS } from 'date-fns/locale';
|
|
6
6
|
import { formatDate } from 'date-fns';
|
|
7
7
|
import { toObservable } from '@angular/core/rxjs-interop';
|
|
@@ -34,10 +34,10 @@ class RdtAutoFocusOnInitDirective {
|
|
|
34
34
|
this.elementRef.nativeElement.focus();
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
38
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
37
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtAutoFocusOnInitDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
38
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.2", type: RdtAutoFocusOnInitDirective, isStandalone: true, selector: "[rdtAutofocusOnInit]", ngImport: i0 });
|
|
39
39
|
}
|
|
40
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
40
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtAutoFocusOnInitDirective, decorators: [{
|
|
41
41
|
type: Directive,
|
|
42
42
|
args: [{
|
|
43
43
|
selector: '[rdtAutofocusOnInit]',
|
|
@@ -58,10 +58,10 @@ class RdtAutofocusableDirective {
|
|
|
58
58
|
The component must then implement RdtAutofocusable.`);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
62
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
61
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtAutofocusableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
62
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.2", type: RdtAutofocusableDirective, isStandalone: true, selector: "[rdtAutofocusable]", ngImport: i0 });
|
|
63
63
|
}
|
|
64
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
64
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtAutofocusableDirective, decorators: [{
|
|
65
65
|
type: Directive,
|
|
66
66
|
args: [{
|
|
67
67
|
selector: '[rdtAutofocusable]',
|
|
@@ -72,8 +72,17 @@ function getRdtAutofocusable(src) {
|
|
|
72
72
|
return (Array.from(src).find((dir) => dir.component?.autofocus())?.component ?? null);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Your component should implement RdtGuarded and call rdtUseGuard(this) in its constructor instead.
|
|
77
|
+
*/
|
|
75
78
|
const RDT_GUARDED_COMPONENT = new InjectionToken('');
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated Your component should implement RdtGuardedContainer and assign readonly guardRegistry = rdtUseGuardContainer(this).
|
|
81
|
+
*/
|
|
76
82
|
const RDT_CONTAINER = new InjectionToken('');
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated
|
|
85
|
+
*/
|
|
77
86
|
function canTransition$(from, to) {
|
|
78
87
|
if (to === from) {
|
|
79
88
|
return of(true);
|
|
@@ -121,6 +130,9 @@ function rdtGetResult$(inputFactory) {
|
|
|
121
130
|
}));
|
|
122
131
|
}
|
|
123
132
|
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated
|
|
135
|
+
*/
|
|
124
136
|
class RdtComponentGuardStoreService {
|
|
125
137
|
guards = new Set();
|
|
126
138
|
registerGuard(guard) {
|
|
@@ -144,16 +156,19 @@ class RdtComponentGuardStoreService {
|
|
|
144
156
|
}
|
|
145
157
|
}));
|
|
146
158
|
}
|
|
147
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
148
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
159
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtComponentGuardStoreService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
160
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtComponentGuardStoreService, providedIn: 'root' });
|
|
149
161
|
}
|
|
150
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtComponentGuardStoreService, decorators: [{
|
|
151
163
|
type: Injectable,
|
|
152
164
|
args: [{
|
|
153
165
|
providedIn: 'root',
|
|
154
166
|
}]
|
|
155
167
|
}] });
|
|
156
168
|
|
|
169
|
+
/**
|
|
170
|
+
* @deprecated Your component should implement RdtGuarded and call rdtUseGuard(this) in its constructor instead.
|
|
171
|
+
*/
|
|
157
172
|
class RdtChildDirective {
|
|
158
173
|
guardStore = inject(RdtComponentGuardStoreService);
|
|
159
174
|
destroyRef = inject(DestroyRef);
|
|
@@ -227,10 +242,10 @@ class RdtChildDirective {
|
|
|
227
242
|
return this.container.getParentByClass(parentClass);
|
|
228
243
|
}
|
|
229
244
|
}
|
|
230
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
231
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
245
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtChildDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
246
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.2", type: RdtChildDirective, isStandalone: true, selector: "[rdtChild]", ngImport: i0 });
|
|
232
247
|
}
|
|
233
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
248
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtChildDirective, decorators: [{
|
|
234
249
|
type: Directive,
|
|
235
250
|
args: [{
|
|
236
251
|
selector: '[rdtChild]',
|
|
@@ -238,6 +253,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImpor
|
|
|
238
253
|
}]
|
|
239
254
|
}] });
|
|
240
255
|
|
|
256
|
+
/**
|
|
257
|
+
* @deprecated Your component should implement RdtGuarded and call rdtUseGuard(this) in its constructor instead.
|
|
258
|
+
*/
|
|
241
259
|
class RdtContainerDirective extends RdtChildDirective {
|
|
242
260
|
rdtChildren = new Set();
|
|
243
261
|
registerChild(child) {
|
|
@@ -298,8 +316,8 @@ class RdtContainerDirective extends RdtChildDirective {
|
|
|
298
316
|
}
|
|
299
317
|
});
|
|
300
318
|
}
|
|
301
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
302
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
319
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtContainerDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
320
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.2", type: RdtContainerDirective, isStandalone: true, selector: "[rdtContainer]", providers: [
|
|
303
321
|
{
|
|
304
322
|
provide: RdtChildDirective,
|
|
305
323
|
useExisting: RdtContainerDirective,
|
|
@@ -310,7 +328,7 @@ class RdtContainerDirective extends RdtChildDirective {
|
|
|
310
328
|
},
|
|
311
329
|
], usesInheritance: true, ngImport: i0 });
|
|
312
330
|
}
|
|
313
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
331
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtContainerDirective, decorators: [{
|
|
314
332
|
type: Directive,
|
|
315
333
|
args: [{
|
|
316
334
|
selector: '[rdtContainer]',
|
|
@@ -330,7 +348,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImpor
|
|
|
330
348
|
|
|
331
349
|
class RdtComponentOutletDirective {
|
|
332
350
|
_viewContainerRef = inject(ViewContainerRef);
|
|
333
|
-
inputs = input({});
|
|
351
|
+
inputs = input({}, ...(ngDevMode ? [{ debugName: "inputs" }] : []));
|
|
334
352
|
get instance() {
|
|
335
353
|
return this._componentRef?.instance;
|
|
336
354
|
}
|
|
@@ -344,7 +362,7 @@ class RdtComponentOutletDirective {
|
|
|
344
362
|
* that are no longer referenced.
|
|
345
363
|
*/
|
|
346
364
|
_inputsUsed = new Map();
|
|
347
|
-
inputsEffect = effect(() => this.onInputsChanged());
|
|
365
|
+
inputsEffect = effect(() => this.onInputsChanged(), ...(ngDevMode ? [{ debugName: "inputsEffect" }] : []));
|
|
348
366
|
disabledEffect = effect(() => {
|
|
349
367
|
const inputs = this.inputs();
|
|
350
368
|
const disabledValue = inputs?.disabled ?? inputs?.rdtDisabled;
|
|
@@ -352,7 +370,7 @@ class RdtComponentOutletDirective {
|
|
|
352
370
|
const instance = this._componentRef.instance;
|
|
353
371
|
instance?.setDisabledState?.(disabledValue);
|
|
354
372
|
}
|
|
355
|
-
});
|
|
373
|
+
}, ...(ngDevMode ? [{ debugName: "disabledEffect" }] : []));
|
|
356
374
|
initComponentRef() {
|
|
357
375
|
const injector = this._viewContainerRef.injector;
|
|
358
376
|
this._componentRef = this._viewContainerRef.createComponent(this.componentClass, {
|
|
@@ -406,15 +424,194 @@ class RdtComponentOutletDirective {
|
|
|
406
424
|
// Fallback: if metadata isn't available, optimistically try setInput.
|
|
407
425
|
return true;
|
|
408
426
|
}
|
|
409
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
410
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "
|
|
427
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtComponentOutletDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
428
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.2", type: RdtComponentOutletDirective, isStandalone: true, inputs: { inputs: { classPropertyName: "inputs", publicName: "inputs", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
411
429
|
}
|
|
412
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
430
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtComponentOutletDirective, decorators: [{
|
|
413
431
|
type: Directive
|
|
414
|
-
}] });
|
|
432
|
+
}], propDecorators: { inputs: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputs", required: false }] }] } });
|
|
415
433
|
|
|
416
434
|
const RDT_DIALOG_SERVICE_PROVIDER = new InjectionToken('RDT_DIALOG_SERVICE_PROVIDER');
|
|
417
435
|
|
|
436
|
+
class RdtGuardBlockerResolver {
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
class RdtGuardRegistry {
|
|
440
|
+
entries = new Map();
|
|
441
|
+
resolver = inject(RdtGuardBlockerResolver, { optional: true });
|
|
442
|
+
register(guard, childRegistry) {
|
|
443
|
+
this.entries.set(guard, { guard, childRegistry });
|
|
444
|
+
}
|
|
445
|
+
unregister(guard) {
|
|
446
|
+
this.entries.delete(guard);
|
|
447
|
+
}
|
|
448
|
+
hasLeaveBlockers() {
|
|
449
|
+
return this.collectLeaveBlockers().length > 0;
|
|
450
|
+
}
|
|
451
|
+
hasEnterBlockers() {
|
|
452
|
+
return this.collectEnterBlockers().length > 0;
|
|
453
|
+
}
|
|
454
|
+
collectLeaveBlockers() {
|
|
455
|
+
const blockers = [];
|
|
456
|
+
for (const entry of this.entries.values()) {
|
|
457
|
+
const selfBlocked = entry.guard.canLeave
|
|
458
|
+
? !entry.guard.canLeave()
|
|
459
|
+
: false;
|
|
460
|
+
const children = this.getChildRegistries(entry).flatMap((r) => r.collectLeaveBlockers());
|
|
461
|
+
if (selfBlocked || children.length) {
|
|
462
|
+
blockers.push({
|
|
463
|
+
guard: entry.guard,
|
|
464
|
+
kind: 'leave',
|
|
465
|
+
meta: selfBlocked ? entry.guard.getLeaveGuardMeta?.() : undefined,
|
|
466
|
+
children,
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return blockers;
|
|
471
|
+
}
|
|
472
|
+
collectEnterBlockers() {
|
|
473
|
+
const blockers = [];
|
|
474
|
+
for (const entry of this.entries.values()) {
|
|
475
|
+
const selfBlocked = entry.guard.canEnter
|
|
476
|
+
? !entry.guard.canEnter()
|
|
477
|
+
: false;
|
|
478
|
+
const children = this.getChildRegistries(entry).flatMap((r) => r.collectEnterBlockers());
|
|
479
|
+
if (selfBlocked || children.length) {
|
|
480
|
+
blockers.push({
|
|
481
|
+
guard: entry.guard,
|
|
482
|
+
kind: 'enter',
|
|
483
|
+
meta: selfBlocked ? entry.guard.getEnterGuardMeta?.() : undefined,
|
|
484
|
+
children,
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
return blockers;
|
|
489
|
+
}
|
|
490
|
+
getChildRegistries(entry) {
|
|
491
|
+
const guard = entry.guard;
|
|
492
|
+
return (guard.getActiveChildRegistries?.() ??
|
|
493
|
+
(entry.childRegistry ? [entry.childRegistry] : []));
|
|
494
|
+
}
|
|
495
|
+
canLeaveAll() {
|
|
496
|
+
return this.resolveBlockers(this.collectLeaveBlockers());
|
|
497
|
+
}
|
|
498
|
+
canEnterAll() {
|
|
499
|
+
return this.resolveBlockers(this.collectEnterBlockers());
|
|
500
|
+
}
|
|
501
|
+
canSwitch(destinationRegistry) {
|
|
502
|
+
const blockers = [
|
|
503
|
+
...this.collectLeaveBlockers(),
|
|
504
|
+
...(destinationRegistry?.collectEnterBlockers() ?? []),
|
|
505
|
+
];
|
|
506
|
+
return this.resolveBlockers(blockers);
|
|
507
|
+
}
|
|
508
|
+
resolveBlockers(blockers) {
|
|
509
|
+
if (!blockers.length)
|
|
510
|
+
return of(true);
|
|
511
|
+
if (!this.resolver) {
|
|
512
|
+
throw new Error('RdtGuardBlockerResolver is not provided. Call provideRdtGuardBlockerResolver() in your application providers.');
|
|
513
|
+
}
|
|
514
|
+
return this.resolver.resolve(blockers).pipe(tap((allowed) => {
|
|
515
|
+
if (allowed)
|
|
516
|
+
this.notifyForced(blockers);
|
|
517
|
+
else
|
|
518
|
+
this.notifyPrevented(blockers);
|
|
519
|
+
}));
|
|
520
|
+
}
|
|
521
|
+
notifyPrevented(blockers) {
|
|
522
|
+
for (const blocker of blockers) {
|
|
523
|
+
if (blocker.kind === 'leave')
|
|
524
|
+
blocker.guard.onLeavePrevented?.();
|
|
525
|
+
else
|
|
526
|
+
blocker.guard.onEnterPrevented?.();
|
|
527
|
+
this.notifyPrevented(blocker.children);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
notifyForced(blockers) {
|
|
531
|
+
for (const blocker of blockers) {
|
|
532
|
+
if (blocker.kind === 'leave')
|
|
533
|
+
blocker.guard.onLeaveForced?.();
|
|
534
|
+
else
|
|
535
|
+
blocker.guard.onEnterForced?.();
|
|
536
|
+
this.notifyForced(blocker.children);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtGuardRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
540
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtGuardRegistry });
|
|
541
|
+
}
|
|
542
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtGuardRegistry, decorators: [{
|
|
543
|
+
type: Injectable
|
|
544
|
+
}] });
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Flattens a blocker tree into leaf blockers (those with no children).
|
|
548
|
+
* Useful in blocker resolvers to get the actual component-level blockers
|
|
549
|
+
* without the intermediate container blockers.
|
|
550
|
+
*/
|
|
551
|
+
function rdtFlattenBlockers(blockers) {
|
|
552
|
+
const result = [];
|
|
553
|
+
for (const blocker of blockers) {
|
|
554
|
+
if (blocker.children.length) {
|
|
555
|
+
result.push(...rdtFlattenBlockers(blocker.children));
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
result.push(blocker);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return result;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Provides the root-level RdtGuardRegistry, the global RdtGuardBlockerResolver,
|
|
566
|
+
* and a `beforeunload` listener that prevents closing the browser tab when there are leave blockers.
|
|
567
|
+
*/
|
|
568
|
+
function provideRdtGuardBlockerResolver(resolver) {
|
|
569
|
+
return makeEnvironmentProviders([
|
|
570
|
+
RdtGuardRegistry,
|
|
571
|
+
{ provide: RdtGuardBlockerResolver, useClass: resolver },
|
|
572
|
+
provideAppInitializer(() => {
|
|
573
|
+
const registry = inject(RdtGuardRegistry);
|
|
574
|
+
const destroyRef = inject(DestroyRef);
|
|
575
|
+
const listener = (e) => {
|
|
576
|
+
if (registry.hasLeaveBlockers()) {
|
|
577
|
+
e.preventDefault();
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
window.addEventListener('beforeunload', listener);
|
|
581
|
+
destroyRef.onDestroy(() => window.removeEventListener('beforeunload', listener));
|
|
582
|
+
}),
|
|
583
|
+
]);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Call in the constructor of a guarded leaf component.
|
|
588
|
+
* Registers the component with the nearest ancestor RdtGuardRegistry.
|
|
589
|
+
*/
|
|
590
|
+
function rdtUseGuard(component) {
|
|
591
|
+
const registry = inject(RdtGuardRegistry, { optional: true, skipSelf: true });
|
|
592
|
+
if (registry) {
|
|
593
|
+
registry.register(component);
|
|
594
|
+
inject(DestroyRef).onDestroy(() => registry.unregister(component));
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Call in the constructor of a container component.
|
|
599
|
+
* Returns the container's own RdtGuardRegistry (for querying children)
|
|
600
|
+
* and registers the container with its parent's registry, linking the child registry.
|
|
601
|
+
*/
|
|
602
|
+
function rdtUseGuardContainer(component) {
|
|
603
|
+
const registry = inject(RdtGuardRegistry);
|
|
604
|
+
const parentRegistry = inject(RdtGuardRegistry, {
|
|
605
|
+
optional: true,
|
|
606
|
+
skipSelf: true,
|
|
607
|
+
});
|
|
608
|
+
if (parentRegistry) {
|
|
609
|
+
parentRegistry.register(component, registry);
|
|
610
|
+
inject(DestroyRef).onDestroy(() => parentRegistry.unregister(component));
|
|
611
|
+
}
|
|
612
|
+
return registry;
|
|
613
|
+
}
|
|
614
|
+
|
|
418
615
|
const csRdtDictionary = {
|
|
419
616
|
RDT_YES: 'Ano',
|
|
420
617
|
RDT_NO: 'Ne',
|
|
@@ -456,6 +653,7 @@ const csRdtDictionary = {
|
|
|
456
653
|
RDT_GOV_DATE_NEXT_MONTH: 'Další měsíc',
|
|
457
654
|
RDT_GOV_DATE_PREV_YEAR: 'Předchozí rok',
|
|
458
655
|
RDT_GOV_DATE_NEXT_YEAR: 'Další rok',
|
|
656
|
+
RDT_FORM_UNSAVED_CHANGES: 'Ve formuláři máte neuložené změny. Opravdu chcete odejít?',
|
|
459
657
|
};
|
|
460
658
|
|
|
461
659
|
const enUsRdtDictionary = {
|
|
@@ -499,6 +697,7 @@ const enUsRdtDictionary = {
|
|
|
499
697
|
RDT_GOV_DATE_NEXT_MONTH: 'Next month',
|
|
500
698
|
RDT_GOV_DATE_PREV_YEAR: 'Previous year',
|
|
501
699
|
RDT_GOV_DATE_NEXT_YEAR: 'Next year',
|
|
700
|
+
RDT_FORM_UNSAVED_CHANGES: 'You have unsaved changes. Are you sure you want to leave?',
|
|
502
701
|
};
|
|
503
702
|
|
|
504
703
|
class RdtLocaleFormat {
|
|
@@ -532,8 +731,7 @@ const enUsRdtLocaleFormat = new RdtLocaleFormat({
|
|
|
532
731
|
formatLocale: 'en-US',
|
|
533
732
|
});
|
|
534
733
|
|
|
535
|
-
/*
|
|
536
|
-
| 'RDT_YES' // Ano
|
|
734
|
+
/* | 'RDT_YES' // Ano
|
|
537
735
|
| 'RDT_NO' // Ne
|
|
538
736
|
| 'RDT_SELECT_DEFAULT_PLACEHOLDER' //Vyberte
|
|
539
737
|
| 'RDT_SELECT_LOADING' //Načítání
|
|
@@ -571,8 +769,9 @@ const enUsRdtLocaleFormat = new RdtLocaleFormat({
|
|
|
571
769
|
| 'RDT_GOV_DATE_PREV_MONTH' //Předchozí měsíc
|
|
572
770
|
| 'RDT_GOV_DATE_NEXT_MONTH' //Další měsíc
|
|
573
771
|
| 'RDT_GOV_DATE_PREV_YEAR' //Předchozí rok
|
|
574
|
-
| 'RDT_GOV_DATE_NEXT_YEAR'
|
|
575
|
-
|
|
772
|
+
| 'RDT_GOV_DATE_NEXT_YEAR' //Další rok
|
|
773
|
+
| 'RDT_FORM_UNSAVED_CHANGES'; // Ve formuláři máte neuložené změny. Opravdu chcete odejít?
|
|
774
|
+
*/
|
|
576
775
|
|
|
577
776
|
const RDT_DEFAULT_LOCALE_STORE = {
|
|
578
777
|
'cs-CZ': {
|
|
@@ -592,15 +791,15 @@ const RDT_LOCALE_STORE_PROVIDER = new InjectionToken('RDT_LOCALE_STORE_PROVIDER'
|
|
|
592
791
|
// This locale is necessary and must always be present.
|
|
593
792
|
const DEFAULT_LOCALE = 'cs-CZ';
|
|
594
793
|
class RdtTranslateService {
|
|
595
|
-
_localeStore = signal(inject(RDT_LOCALE_STORE_PROVIDER));
|
|
596
|
-
availableLocales = computed(() => Object.keys(this._localeStore()));
|
|
597
|
-
_localeCode = signal(this.getNearestLocaleCode(inject(LOCALE_ID)));
|
|
794
|
+
_localeStore = signal(inject(RDT_LOCALE_STORE_PROVIDER), ...(ngDevMode ? [{ debugName: "_localeStore" }] : []));
|
|
795
|
+
availableLocales = computed(() => Object.keys(this._localeStore()), ...(ngDevMode ? [{ debugName: "availableLocales" }] : []));
|
|
796
|
+
_localeCode = signal(this.getNearestLocaleCode(inject(LOCALE_ID)), ...(ngDevMode ? [{ debugName: "_localeCode" }] : []));
|
|
598
797
|
currentLocaleCode = this._localeCode.asReadonly();
|
|
599
|
-
currentLanguage = computed(() => this._localeCode().split('-')[0]);
|
|
798
|
+
currentLanguage = computed(() => this._localeCode().split('-')[0], ...(ngDevMode ? [{ debugName: "currentLanguage" }] : []));
|
|
600
799
|
currentLocale = computed(() => this._localeStore()[this._localeCode()] ??
|
|
601
|
-
this._localeStore()[DEFAULT_LOCALE]);
|
|
602
|
-
currentFormat = computed(() => this.currentLocale().format);
|
|
603
|
-
currentDictionary = computed(() => this.currentLocale().dictionary);
|
|
800
|
+
this._localeStore()[DEFAULT_LOCALE], ...(ngDevMode ? [{ debugName: "currentLocale" }] : []));
|
|
801
|
+
currentFormat = computed(() => this.currentLocale().format, ...(ngDevMode ? [{ debugName: "currentFormat" }] : []));
|
|
802
|
+
currentDictionary = computed(() => this.currentLocale().dictionary, ...(ngDevMode ? [{ debugName: "currentDictionary" }] : []));
|
|
604
803
|
currentLocaleChange$ = toObservable(this.currentLocale);
|
|
605
804
|
constructor() {
|
|
606
805
|
if (!this._localeStore()[DEFAULT_LOCALE]) {
|
|
@@ -697,10 +896,10 @@ class RdtTranslateService {
|
|
|
697
896
|
console.warn(`Locale '${locale}' not found, falling back to default locale '${DEFAULT_LOCALE}'.`);
|
|
698
897
|
return DEFAULT_LOCALE;
|
|
699
898
|
}
|
|
700
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
701
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
899
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtTranslateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
900
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtTranslateService, providedIn: 'root' });
|
|
702
901
|
}
|
|
703
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
902
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtTranslateService, decorators: [{
|
|
704
903
|
type: Injectable,
|
|
705
904
|
args: [{
|
|
706
905
|
providedIn: 'root',
|
|
@@ -719,10 +918,10 @@ class RdtFormatPipe {
|
|
|
719
918
|
return this.translateService.formatNumber(key);
|
|
720
919
|
}
|
|
721
920
|
}
|
|
722
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
723
|
-
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "
|
|
921
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtFormatPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
922
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.2", ngImport: i0, type: RdtFormatPipe, isStandalone: true, name: "rdtFormat", pure: false });
|
|
724
923
|
}
|
|
725
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
924
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtFormatPipe, decorators: [{
|
|
726
925
|
type: Pipe,
|
|
727
926
|
args: [{
|
|
728
927
|
name: 'rdtFormat',
|
|
@@ -744,10 +943,10 @@ class RdtTranslatePipe {
|
|
|
744
943
|
}));
|
|
745
944
|
return this.translateService.instant(key, strParams);
|
|
746
945
|
}
|
|
747
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
748
|
-
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "
|
|
946
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtTranslatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
947
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.2", ngImport: i0, type: RdtTranslatePipe, isStandalone: true, name: "rdtTranslate", pure: false });
|
|
749
948
|
}
|
|
750
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
949
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtTranslatePipe, decorators: [{
|
|
751
950
|
type: Pipe,
|
|
752
951
|
args: [{
|
|
753
952
|
name: 'rdtTranslate',
|
|
@@ -764,41 +963,33 @@ class RdtInteractiveElementComponent {
|
|
|
764
963
|
destroyRef = inject(DestroyRef);
|
|
765
964
|
// Input for the disabled state
|
|
766
965
|
// Used only from outside using disabled="true" construct.
|
|
767
|
-
disabledInput = input(false, {
|
|
768
|
-
|
|
769
|
-
transform: booleanAttribute,
|
|
770
|
-
});
|
|
966
|
+
disabledInput = input(false, { ...(ngDevMode ? { debugName: "disabledInput" } : {}), alias: 'rdtDisabled',
|
|
967
|
+
transform: booleanAttribute });
|
|
771
968
|
// Map to track disabled state keys
|
|
772
|
-
disabledMap = signal({});
|
|
969
|
+
disabledMap = signal({}, ...(ngDevMode ? [{ debugName: "disabledMap" }] : []));
|
|
773
970
|
// Computed disabled state
|
|
774
|
-
disabled = computed(() => this.disabledInput() || RdtObjectUtils.someValuesTrue(this.disabledMap()));
|
|
971
|
+
disabled = computed(() => this.disabledInput() || RdtObjectUtils.someValuesTrue(this.disabledMap()), ...(ngDevMode ? [{ debugName: "disabled" }] : []));
|
|
775
972
|
// In case component is focused and disabled
|
|
776
973
|
disabledEffect = effect(() => {
|
|
777
974
|
if (untracked(this.focused) && this.disabled()) {
|
|
778
975
|
this.focused.set(false);
|
|
779
976
|
}
|
|
780
|
-
});
|
|
781
|
-
loadingInput = input(false, {
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
});
|
|
785
|
-
loadingMap = signal({});
|
|
786
|
-
loading = computed(() => this.loadingInput() || RdtObjectUtils.someValuesTrue(this.loadingMap()));
|
|
977
|
+
}, ...(ngDevMode ? [{ debugName: "disabledEffect" }] : []));
|
|
978
|
+
loadingInput = input(false, { ...(ngDevMode ? { debugName: "loadingInput" } : {}), alias: 'loading',
|
|
979
|
+
transform: booleanAttribute });
|
|
980
|
+
loadingMap = signal({}, ...(ngDevMode ? [{ debugName: "loadingMap" }] : []));
|
|
981
|
+
loading = computed(() => this.loadingInput() || RdtObjectUtils.someValuesTrue(this.loadingMap()), ...(ngDevMode ? [{ debugName: "loading" }] : []));
|
|
787
982
|
get uid() {
|
|
788
983
|
return this._uid;
|
|
789
984
|
}
|
|
790
985
|
_uid = (Math.random() + 1).toString(36).substring(7);
|
|
791
|
-
idInput = input(this._uid, {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
})
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
transform: booleanAttribute,
|
|
799
|
-
});
|
|
800
|
-
autofocus = linkedSignal(() => this.autofocusInput());
|
|
801
|
-
focused = signal(false);
|
|
986
|
+
idInput = input(this._uid, { ...(ngDevMode ? { debugName: "idInput" } : {}), alias: 'id',
|
|
987
|
+
transform: (value) => value || this._uid });
|
|
988
|
+
id = linkedSignal(() => this.idInput(), ...(ngDevMode ? [{ debugName: "id" }] : []));
|
|
989
|
+
autofocusInput = input(false, { ...(ngDevMode ? { debugName: "autofocusInput" } : {}), alias: 'autofocus',
|
|
990
|
+
transform: booleanAttribute });
|
|
991
|
+
autofocus = linkedSignal(() => this.autofocusInput(), ...(ngDevMode ? [{ debugName: "autofocus" }] : []));
|
|
992
|
+
focused = signal(false, ...(ngDevMode ? [{ debugName: "focused" }] : []));
|
|
802
993
|
autofocusEffect = afterNextRender({
|
|
803
994
|
read: () => {
|
|
804
995
|
rdtGetResult$(this.canFocus.bind(this))
|
|
@@ -836,15 +1027,15 @@ class RdtInteractiveElementComponent {
|
|
|
836
1027
|
onBlur() {
|
|
837
1028
|
this.focused.set(false);
|
|
838
1029
|
}
|
|
839
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
840
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "
|
|
1030
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtInteractiveElementComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1031
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.2", type: RdtInteractiveElementComponent, isStandalone: true, inputs: { disabledInput: { classPropertyName: "disabledInput", publicName: "rdtDisabled", isSignal: true, isRequired: false, transformFunction: null }, loadingInput: { classPropertyName: "loadingInput", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, idInput: { classPropertyName: "idInput", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, autofocusInput: { classPropertyName: "autofocusInput", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
841
1032
|
}
|
|
842
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1033
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: RdtInteractiveElementComponent, decorators: [{
|
|
843
1034
|
type: Directive,
|
|
844
1035
|
args: [{
|
|
845
1036
|
standalone: true,
|
|
846
1037
|
}]
|
|
847
|
-
}] });
|
|
1038
|
+
}], propDecorators: { disabledInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "rdtDisabled", required: false }] }], loadingInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], idInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], autofocusInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }] } });
|
|
848
1039
|
|
|
849
1040
|
function rdtCreateLinkedState(params) {
|
|
850
1041
|
const state = {};
|
|
@@ -866,5 +1057,5 @@ const RDT_NOTIFICATION_SERVICE_PROVIDER = new InjectionToken('RDT_NOTIFICATION_S
|
|
|
866
1057
|
* Generated bundle index. Do not edit.
|
|
867
1058
|
*/
|
|
868
1059
|
|
|
869
|
-
export { RDT_AUTOFOCUSABLE_COMPONENT, RDT_CONTAINER, RDT_DEFAULT_DISABLED_KEY, RDT_DEFAULT_LOADING_KEY, RDT_DEFAULT_LOCALE_STORE, RDT_DIALOG_SERVICE_PROVIDER, RDT_GUARDED_COMPONENT, RDT_LOCALE_STORE_PROVIDER, RDT_NOTIFICATION_SERVICE_PROVIDER, RdtAutoFocusOnInitDirective, RdtAutofocusableDirective, RdtChildDirective, RdtComponentGuardStoreService, RdtComponentOutletDirective, RdtContainerDirective, RdtFormatPipe, RdtInteractiveElementComponent, RdtLocaleFormat, RdtTranslatePipe, RdtTranslateService, canTransition$, csRdtDictionary, csRdtLocaleFormat, enUsRdtDictionary, enUsRdtLocaleFormat, getRdtAutofocusable, rdtCreateLinkedState, rdtGetAllResultsTrue$, rdtGetResult
|
|
1060
|
+
export { RDT_AUTOFOCUSABLE_COMPONENT, RDT_CONTAINER, RDT_DEFAULT_DISABLED_KEY, RDT_DEFAULT_LOADING_KEY, RDT_DEFAULT_LOCALE_STORE, RDT_DIALOG_SERVICE_PROVIDER, RDT_GUARDED_COMPONENT, RDT_LOCALE_STORE_PROVIDER, RDT_NOTIFICATION_SERVICE_PROVIDER, RdtAutoFocusOnInitDirective, RdtAutofocusableDirective, RdtChildDirective, RdtComponentGuardStoreService, RdtComponentOutletDirective, RdtContainerDirective, RdtFormatPipe, RdtGuardBlockerResolver, RdtGuardRegistry, RdtInteractiveElementComponent, RdtLocaleFormat, RdtTranslatePipe, RdtTranslateService, canTransition$, csRdtDictionary, csRdtLocaleFormat, enUsRdtDictionary, enUsRdtLocaleFormat, getRdtAutofocusable, provideRdtGuardBlockerResolver, rdtCreateLinkedState, rdtFlattenBlockers, rdtGetAllResultsTrue$, rdtGetResult$, rdtUseGuard, rdtUseGuardContainer };
|
|
870
1061
|
//# sourceMappingURL=ngrdt-core.mjs.map
|