@ngrdt/core 0.0.2 → 0.0.4

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.
Files changed (44) hide show
  1. package/esm2022/index.mjs +4 -0
  2. package/esm2022/lib/rdt-autofocus/index.mjs +4 -0
  3. package/esm2022/lib/rdt-autofocus/models.mjs +3 -0
  4. package/esm2022/lib/rdt-autofocus/rdt-autofocusable.directive.mjs +27 -0
  5. package/esm2022/lib/rdt-autofocus/utils.mjs +9 -0
  6. package/esm2022/lib/rdt-component-guard/directives/rdt-child.directive.mjs +88 -0
  7. package/esm2022/lib/rdt-component-guard/directives/rdt-container.directive.mjs +95 -0
  8. package/esm2022/lib/rdt-component-guard/index.mjs +5 -0
  9. package/esm2022/lib/rdt-component-guard/models.mjs +25 -0
  10. package/esm2022/lib/rdt-component-guard/services/rdt-component-guard-store.service.mjs +36 -0
  11. package/esm2022/lib/utils/index.mjs +2 -0
  12. package/esm2022/lib/utils/rdt-boolean-result.mjs +25 -0
  13. package/esm2022/ngrdt-core.mjs +5 -0
  14. package/fesm2022/ngrdt-core.mjs +299 -0
  15. package/fesm2022/ngrdt-core.mjs.map +1 -0
  16. package/lib/rdt-autofocus/models.d.ts +8 -0
  17. package/lib/rdt-autofocus/rdt-autofocusable.directive.d.ts +8 -0
  18. package/lib/rdt-autofocus/utils.d.ts +3 -0
  19. package/lib/rdt-component-guard/directives/rdt-child.directive.d.ts +22 -0
  20. package/lib/rdt-component-guard/directives/rdt-container.directive.d.ts +18 -0
  21. package/{src/lib/rdt-component-guard/index.ts → lib/rdt-component-guard/index.d.ts} +1 -0
  22. package/lib/rdt-component-guard/models.d.ts +22 -0
  23. package/lib/rdt-component-guard/services/rdt-component-guard-store.service.d.ts +11 -0
  24. package/lib/utils/rdt-boolean-result.d.ts +4 -0
  25. package/package.json +20 -4
  26. package/eslint.config.js +0 -44
  27. package/jest.config.ts +0 -21
  28. package/ng-package.json +0 -7
  29. package/project.json +0 -36
  30. package/src/lib/rdt-autofocus/models.ts +0 -12
  31. package/src/lib/rdt-autofocus/rdt-autofocusable.directive.ts +0 -22
  32. package/src/lib/rdt-autofocus/utils.ts +0 -13
  33. package/src/lib/rdt-component-guard/directives/rdt-child.directive.ts +0 -103
  34. package/src/lib/rdt-component-guard/directives/rdt-container.directive.ts +0 -90
  35. package/src/lib/rdt-component-guard/models.ts +0 -47
  36. package/src/lib/utils/rdt-boolean-result.ts +0 -38
  37. package/src/test-setup.ts +0 -8
  38. package/tsconfig.json +0 -28
  39. package/tsconfig.lib.json +0 -17
  40. package/tsconfig.lib.prod.json +0 -9
  41. package/tsconfig.spec.json +0 -16
  42. /package/{src/index.ts → index.d.ts} +0 -0
  43. /package/{src/lib/rdt-autofocus/index.ts → lib/rdt-autofocus/index.d.ts} +0 -0
  44. /package/{src/lib/utils/index.ts → lib/utils/index.d.ts} +0 -0
@@ -0,0 +1,299 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, inject, Directive, Injectable, DestroyRef } from '@angular/core';
3
+ import { of, concat, filter, map, catchError, defer } from 'rxjs';
4
+ import { fromPromise } from 'rxjs/internal/observable/innerFrom';
5
+
6
+ const RDT_AUTOFOCUSABLE_COMPONENT = new InjectionToken('');
7
+
8
+ class RdtAutofocusableDirective {
9
+ component = inject(RDT_AUTOFOCUSABLE_COMPONENT, {
10
+ host: true,
11
+ optional: true,
12
+ self: true,
13
+ });
14
+ ngOnInit() {
15
+ if (!this.component) {
16
+ throw new Error(`
17
+ RdtAutofocusableDirective usage:
18
+ Apply directive directly on component and provide the same component as RDT_AUTOFOCUSABLE_COMPONENT.
19
+ The component must then implement RdtAutocusable.`);
20
+ }
21
+ }
22
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: RdtAutofocusableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
23
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.7", type: RdtAutofocusableDirective, selector: "[rdtAutofocusable]", ngImport: i0 });
24
+ }
25
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: RdtAutofocusableDirective, decorators: [{
26
+ type: Directive,
27
+ args: [{
28
+ selector: '[rdtAutofocusable]',
29
+ }]
30
+ }] });
31
+
32
+ function getRdtAutofocusable(src) {
33
+ const withPrios = Array.from(src).map((dir) => ({
34
+ cmp: dir.component,
35
+ prio: dir.component?.rdtGetAutofocusPriority?.() ?? 0,
36
+ }));
37
+ withPrios.sort((a, b) => b.prio - a.prio);
38
+ return withPrios[0]?.cmp;
39
+ }
40
+
41
+ const RDT_GUARDED_COMPONENT = new InjectionToken('');
42
+ const RDT_CONTAINER = new InjectionToken('');
43
+ function canTransition$(from, to) {
44
+ console.log('canTransition$', from, to);
45
+ if (to === from) {
46
+ return of(true);
47
+ }
48
+ const canLeave$ = from ? from.checkCanLeave$() : of(true);
49
+ return canLeave$;
50
+ /*
51
+ const canEnter$ = to ? to.checkCanEnter$() : of(true);
52
+
53
+ return canLeave$.pipe(
54
+ switchMap((res) => {
55
+ if (res) {
56
+ return canEnter$;
57
+ } else {
58
+ return of(res);
59
+ }
60
+ })
61
+ );*/
62
+ }
63
+
64
+ function rdtGetAllResultsTrue$(inputFactories) {
65
+ const can$ = inputFactories.map((fn) => rdtGetResult$(fn));
66
+ const last = Symbol('last');
67
+ return concat(...can$, of(last)).pipe(filter((res) => res === last), map(() => true), catchError(() => of(false)));
68
+ }
69
+ function rdtGetResult$(inputFactory) {
70
+ return defer(() => {
71
+ const input = inputFactory();
72
+ if (typeof input === 'boolean') {
73
+ return of(input);
74
+ }
75
+ if (input instanceof Promise) {
76
+ return fromPromise(input);
77
+ }
78
+ return input;
79
+ }).pipe(map((res) => {
80
+ if (res) {
81
+ return res;
82
+ }
83
+ throw res;
84
+ }));
85
+ }
86
+
87
+ class RdtComponentGuardStoreService {
88
+ guards = new Set();
89
+ registerGuard(guard) {
90
+ this.guards.add(guard);
91
+ }
92
+ removeGuard(guard) {
93
+ this.guards.delete(guard);
94
+ }
95
+ getGuards() {
96
+ return Array.from(this.guards);
97
+ }
98
+ checkCanLeaveGlobal$() {
99
+ return rdtGetAllResultsTrue$(this.getGuards().map((ch) => () => {
100
+ // @ts-ignore
101
+ if (typeof ch.checkCanLeave$ === 'function') {
102
+ // @ts-ignore
103
+ return ch.checkCanLeave$();
104
+ }
105
+ else {
106
+ return ch.canLeaveView();
107
+ }
108
+ }));
109
+ }
110
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: RdtComponentGuardStoreService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
111
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: RdtComponentGuardStoreService, providedIn: 'root' });
112
+ }
113
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: RdtComponentGuardStoreService, decorators: [{
114
+ type: Injectable,
115
+ args: [{
116
+ providedIn: 'root',
117
+ }]
118
+ }] });
119
+
120
+ class RdtChildDirective {
121
+ guardStore = inject(RdtComponentGuardStoreService);
122
+ destroyRef = inject(DestroyRef);
123
+ container = inject(RDT_CONTAINER, {
124
+ optional: true,
125
+ skipSelf: true,
126
+ });
127
+ guardedComponent = inject(RDT_GUARDED_COMPONENT, {
128
+ optional: true,
129
+ self: true,
130
+ host: true,
131
+ });
132
+ ngOnInit() {
133
+ if (!this.guardedComponent) {
134
+ throw new Error(`
135
+ RdtChildDirective usage:
136
+ Apply directive directly on component and provide the same component as RDT_GUARDED_COMPONENT.
137
+ The component can then implement RdtCanLeaveView or RdtCanEnterView.
138
+ This applies to both Child and Container directives.
139
+ `);
140
+ }
141
+ if (!this.container) {
142
+ this.guardStore.registerGuard(this);
143
+ }
144
+ else {
145
+ this.container?.registerChild(this);
146
+ }
147
+ }
148
+ ngOnDestroy() {
149
+ this.guardStore.removeGuard(this);
150
+ this.container?.removeChild(this);
151
+ }
152
+ isActive() {
153
+ const comp = this.guardedComponent;
154
+ return comp?.rdtIsActive?.() ?? true;
155
+ }
156
+ canEnterView() {
157
+ const comp = this.guardedComponent;
158
+ if (typeof comp?.rdtCanEnterView === 'function') {
159
+ return comp.rdtCanEnterView();
160
+ }
161
+ else {
162
+ return true;
163
+ }
164
+ }
165
+ canLeaveView() {
166
+ const comp = this.guardedComponent;
167
+ if (typeof comp?.rdtCanLeaveView === 'function') {
168
+ return comp.rdtCanLeaveView();
169
+ }
170
+ else {
171
+ return true;
172
+ }
173
+ }
174
+ onViewWillEnter() {
175
+ const comp = this.guardedComponent;
176
+ comp?.rdtOnViewWillEnter();
177
+ }
178
+ onViewWillLeave() {
179
+ const comp = this.guardedComponent;
180
+ comp?.rdtOnViewWillLeave();
181
+ }
182
+ getParentByClass(parentClass) {
183
+ if (!this.container) {
184
+ return null;
185
+ }
186
+ else if (this.container instanceof parentClass) {
187
+ return this.container;
188
+ }
189
+ else {
190
+ return this.container.getParentByClass(parentClass);
191
+ }
192
+ }
193
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: RdtChildDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
194
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.7", type: RdtChildDirective, isStandalone: true, selector: "[rdtChild]", ngImport: i0 });
195
+ }
196
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: RdtChildDirective, decorators: [{
197
+ type: Directive,
198
+ args: [{
199
+ selector: '[rdtChild]',
200
+ standalone: true,
201
+ }]
202
+ }] });
203
+
204
+ class RdtContainerDirective extends RdtChildDirective {
205
+ rdtChildren = new Set();
206
+ registerChild(child) {
207
+ this.rdtChildren.add(child);
208
+ }
209
+ removeChild(child) {
210
+ this.rdtChildren.delete(child);
211
+ }
212
+ checkCanLeave$() {
213
+ return rdtGetAllResultsTrue$([this, ...this.getActiveChildren()].map((ch) => () => ch.canLeaveView()));
214
+ }
215
+ /* TODO
216
+ checkCanEnter$() {
217
+ return getCan$(
218
+ [this, ...this.getActiveChildren()].map((ch) => () => ch.canEnterView())
219
+ );
220
+ }
221
+ */
222
+ onViewWillEnter() {
223
+ super.onViewWillEnter();
224
+ this.rdtChildren.forEach((ch) => ch.onViewWillEnter());
225
+ }
226
+ onViewWillLeave() {
227
+ super.onViewWillLeave();
228
+ this.rdtChildren.forEach((ch) => ch.onViewWillLeave());
229
+ }
230
+ getChildrenRecursive(filter) {
231
+ const res = [];
232
+ this._getChildrenRecursive(res, filter);
233
+ return res;
234
+ }
235
+ getActiveChildren() {
236
+ return this.getChildrenRecursive((ch) => ch.isActive());
237
+ }
238
+ getChildrenByClass(childClass) {
239
+ const res = [];
240
+ this._getChildrenByClassRecursive(childClass, res);
241
+ return res;
242
+ }
243
+ _getChildrenRecursive(res, filter) {
244
+ const children = Array.from(this.rdtChildren);
245
+ const filteredChildren = filter ? children.filter(filter) : children;
246
+ res.push(...filteredChildren);
247
+ filteredChildren.forEach((child) => {
248
+ if (child instanceof RdtContainerDirective) {
249
+ child._getChildrenRecursive(res, filter);
250
+ }
251
+ });
252
+ }
253
+ _getChildrenByClassRecursive(childClass, res) {
254
+ this.rdtChildren.forEach((child) => {
255
+ const comp = child.guardedComponent;
256
+ if (comp instanceof childClass) {
257
+ res.push(comp);
258
+ }
259
+ else if (child instanceof RdtContainerDirective) {
260
+ child._getChildrenByClassRecursive(childClass, res);
261
+ }
262
+ });
263
+ }
264
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: RdtContainerDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
265
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.7", type: RdtContainerDirective, isStandalone: true, selector: "[rdtContainer]", providers: [
266
+ {
267
+ provide: RdtChildDirective,
268
+ useExisting: RdtContainerDirective,
269
+ },
270
+ {
271
+ provide: RDT_CONTAINER,
272
+ useExisting: RdtContainerDirective,
273
+ },
274
+ ], usesInheritance: true, ngImport: i0 });
275
+ }
276
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: RdtContainerDirective, decorators: [{
277
+ type: Directive,
278
+ args: [{
279
+ selector: '[rdtContainer]',
280
+ standalone: true,
281
+ providers: [
282
+ {
283
+ provide: RdtChildDirective,
284
+ useExisting: RdtContainerDirective,
285
+ },
286
+ {
287
+ provide: RDT_CONTAINER,
288
+ useExisting: RdtContainerDirective,
289
+ },
290
+ ],
291
+ }]
292
+ }] });
293
+
294
+ /**
295
+ * Generated bundle index. Do not edit.
296
+ */
297
+
298
+ export { RDT_AUTOFOCUSABLE_COMPONENT, RDT_CONTAINER, RDT_GUARDED_COMPONENT, RdtAutofocusableDirective, RdtChildDirective, RdtComponentGuardStoreService, RdtContainerDirective, canTransition$, getRdtAutofocusable, rdtGetAllResultsTrue$, rdtGetResult$ };
299
+ //# sourceMappingURL=ngrdt-core.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngrdt-core.mjs","sources":["../../../../@ngrdt/core/src/lib/rdt-autofocus/models.ts","../../../../@ngrdt/core/src/lib/rdt-autofocus/rdt-autofocusable.directive.ts","../../../../@ngrdt/core/src/lib/rdt-autofocus/utils.ts","../../../../@ngrdt/core/src/lib/rdt-component-guard/models.ts","../../../../@ngrdt/core/src/lib/utils/rdt-boolean-result.ts","../../../../@ngrdt/core/src/lib/rdt-component-guard/services/rdt-component-guard-store.service.ts","../../../../@ngrdt/core/src/lib/rdt-component-guard/directives/rdt-child.directive.ts","../../../../@ngrdt/core/src/lib/rdt-component-guard/directives/rdt-container.directive.ts","../../../../@ngrdt/core/src/ngrdt-core.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { RdtBooleanResult } from '../utils';\n\nexport interface RdtAutocusable {\n rdtFocus(): void;\n rdtCanFocus(): RdtBooleanResult;\n rdtGetAutofocusPriority?(): number;\n}\n\nexport const RDT_AUTOFOCUSABLE_COMPONENT = new InjectionToken<RdtAutocusable>(\n ''\n);\n","import { Directive, inject, OnInit } from '@angular/core';\nimport { RDT_AUTOFOCUSABLE_COMPONENT } from './models';\n\n@Directive({\n selector: '[rdtAutofocusable]',\n})\nexport class RdtAutofocusableDirective implements OnInit {\n readonly component = inject(RDT_AUTOFOCUSABLE_COMPONENT, {\n host: true,\n optional: true,\n self: true,\n });\n\n ngOnInit() {\n if (!this.component) {\n throw new Error(`\n RdtAutofocusableDirective usage:\n Apply directive directly on component and provide the same component as RDT_AUTOFOCUSABLE_COMPONENT.\n The component must then implement RdtAutocusable.`);\n }\n }\n}\n","import { RdtAutocusable } from './models';\nimport { RdtAutofocusableDirective } from './rdt-autofocusable.directive';\n\nexport function getRdtAutofocusable(\n src: Iterable<RdtAutofocusableDirective>\n): RdtAutocusable | null {\n const withPrios = Array.from(src).map((dir) => ({\n cmp: dir.component,\n prio: dir.component?.rdtGetAutofocusPriority?.() ?? 0,\n }));\n withPrios.sort((a, b) => b.prio - a.prio);\n return withPrios[0]?.cmp;\n}\n","import { InjectionToken } from '@angular/core';\nimport { Nullable } from '@ngrdt/utils';\nimport { of } from 'rxjs';\nimport { RdtBooleanResult } from '../utils';\nimport { RdtContainerDirective } from './directives/rdt-container.directive';\n\nexport interface RdtIsActive {\n rdtIsActive(): boolean;\n}\n\nexport interface RdtCanLeaveView {\n rdtCanLeaveView(): RdtBooleanResult;\n}\n\nexport interface RdtCanEnterView {\n rdtCanEnterView(): RdtBooleanResult;\n}\n\nexport interface RdtOnViewWillLeave {\n rdtOnViewWillLeave(): void;\n}\n\nexport interface RdtOnViewWillEnter {\n rdtOnViewWillEnter(): void;\n}\n\nexport const RDT_GUARDED_COMPONENT = new InjectionToken<\n | RdtCanLeaveView\n | RdtCanEnterView\n | RdtOnViewWillEnter\n | RdtOnViewWillLeave\n | RdtIsActive\n>('');\n\nexport const RDT_CONTAINER = new InjectionToken<RdtContainerDirective>('');\n\nexport function canTransition$(\n from: Nullable<RdtContainerDirective>,\n to: Nullable<RdtContainerDirective>\n) {\n console.log('canTransition$', from, to);\n if (to === from) {\n return of(true);\n }\n const canLeave$ = from ? from.checkCanLeave$() : of(true);\n return canLeave$;\n /*\n const canEnter$ = to ? to.checkCanEnter$() : of(true);\n\n return canLeave$.pipe(\n switchMap((res) => {\n if (res) {\n return canEnter$;\n } else {\n return of(res);\n }\n })\n );*/\n}\n","import { catchError, concat, defer, filter, map, Observable, of } from 'rxjs';\nimport { fromPromise } from 'rxjs/internal/observable/innerFrom';\n\nexport type RdtBooleanResult = Observable<boolean> | Promise<boolean> | boolean;\n\nexport function rdtGetAllResultsTrue$(\n inputFactories: (() => RdtBooleanResult)[]\n) {\n const can$ = inputFactories.map((fn) => rdtGetResult$(fn));\n const last = Symbol('last');\n\n return concat(...can$, of(last)).pipe(\n filter((res) => res === last),\n map(() => true),\n catchError(() => of(false))\n );\n}\n\nexport function rdtGetResult$(inputFactory: () => RdtBooleanResult) {\n return defer(() => {\n const input = inputFactory();\n\n if (typeof input === 'boolean') {\n return of(input);\n }\n if (input instanceof Promise) {\n return fromPromise(input);\n }\n return input;\n }).pipe(\n map((res) => {\n if (res) {\n return res;\n }\n throw res;\n })\n );\n}\n","import { Injectable } from '@angular/core';\nimport { rdtGetAllResultsTrue$ } from '../../utils';\nimport { RdtChildDirective } from '../directives/rdt-child.directive';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RdtComponentGuardStoreService {\n private readonly guards = new Set<RdtChildDirective>();\n\n registerGuard(guard: RdtChildDirective) {\n this.guards.add(guard);\n }\n\n removeGuard(guard: RdtChildDirective) {\n this.guards.delete(guard);\n }\n\n getGuards() {\n return Array.from(this.guards);\n }\n\n checkCanLeaveGlobal$() {\n return rdtGetAllResultsTrue$(\n this.getGuards().map((ch) => () => {\n // @ts-ignore\n if (typeof ch.checkCanLeave$ === 'function') {\n // @ts-ignore\n return ch.checkCanLeave$();\n } else {\n return ch.canLeaveView();\n }\n })\n );\n }\n}\n","import {\n DestroyRef,\n Directive,\n inject,\n OnDestroy,\n OnInit,\n Type,\n} from '@angular/core';\nimport { RdtBooleanResult } from '../../utils';\nimport {\n RDT_CONTAINER,\n RDT_GUARDED_COMPONENT,\n RdtCanEnterView,\n RdtCanLeaveView,\n RdtIsActive,\n RdtOnViewWillEnter,\n RdtOnViewWillLeave,\n} from '../models';\nimport { RdtComponentGuardStoreService } from '../services/rdt-component-guard-store.service';\nimport { RdtContainerDirective } from './rdt-container.directive';\n\n@Directive({\n selector: '[rdtChild]',\n standalone: true,\n})\nexport class RdtChildDirective implements OnInit, OnDestroy {\n readonly guardStore = inject(RdtComponentGuardStoreService);\n readonly destroyRef = inject(DestroyRef);\n readonly container = inject(RDT_CONTAINER, {\n optional: true,\n skipSelf: true,\n });\n readonly guardedComponent = inject(RDT_GUARDED_COMPONENT, {\n optional: true,\n self: true,\n host: true,\n });\n\n ngOnInit() {\n if (!this.guardedComponent) {\n throw new Error(`\n RdtChildDirective usage:\n Apply directive directly on component and provide the same component as RDT_GUARDED_COMPONENT.\n The component can then implement RdtCanLeaveView or RdtCanEnterView.\n This applies to both Child and Container directives.\n `);\n }\n if (!this.container) {\n this.guardStore.registerGuard(this);\n } else {\n this.container?.registerChild(this);\n }\n }\n\n ngOnDestroy() {\n this.guardStore.removeGuard(this);\n this.container?.removeChild(this);\n }\n\n isActive() {\n const comp = this.guardedComponent as RdtIsActive | undefined;\n return comp?.rdtIsActive?.() ?? true;\n }\n\n canEnterView(): RdtBooleanResult {\n const comp = this.guardedComponent as RdtCanEnterView | undefined;\n if (typeof comp?.rdtCanEnterView === 'function') {\n return comp.rdtCanEnterView();\n } else {\n return true;\n }\n }\n\n canLeaveView(): RdtBooleanResult {\n const comp = this.guardedComponent as RdtCanLeaveView | undefined;\n if (typeof comp?.rdtCanLeaveView === 'function') {\n return comp.rdtCanLeaveView();\n } else {\n return true;\n }\n }\n\n onViewWillEnter(): void {\n const comp = this.guardedComponent as RdtOnViewWillEnter | undefined;\n comp?.rdtOnViewWillEnter();\n }\n\n onViewWillLeave(): void {\n const comp = this.guardedComponent as RdtOnViewWillLeave | undefined;\n comp?.rdtOnViewWillLeave();\n }\n\n getParentByClass<T extends RdtContainerDirective>(\n parentClass: Type<T>\n ): T | null {\n if (!this.container) {\n return null;\n } else if (this.container instanceof parentClass) {\n return this.container;\n } else {\n return this.container.getParentByClass(parentClass);\n }\n }\n}\n","import { Directive, Type } from '@angular/core';\nimport { rdtGetAllResultsTrue$ } from '../../utils';\nimport { RDT_CONTAINER } from '../models';\nimport { RdtChildDirective } from './rdt-child.directive';\n\n@Directive({\n selector: '[rdtContainer]',\n standalone: true,\n providers: [\n {\n provide: RdtChildDirective,\n useExisting: RdtContainerDirective,\n },\n {\n provide: RDT_CONTAINER,\n useExisting: RdtContainerDirective,\n },\n ],\n})\nexport class RdtContainerDirective extends RdtChildDirective {\n readonly rdtChildren: Set<RdtChildDirective> = new Set<RdtChildDirective>();\n\n registerChild(child: RdtChildDirective) {\n this.rdtChildren.add(child);\n }\n\n removeChild(child: RdtChildDirective) {\n this.rdtChildren.delete(child);\n }\n\n checkCanLeave$() {\n return rdtGetAllResultsTrue$(\n [this, ...this.getActiveChildren()].map((ch) => () => ch.canLeaveView())\n );\n }\n\n /* TODO\n checkCanEnter$() {\n return getCan$(\n [this, ...this.getActiveChildren()].map((ch) => () => ch.canEnterView())\n );\n }\n */\n\n override onViewWillEnter() {\n super.onViewWillEnter();\n this.rdtChildren.forEach((ch) => ch.onViewWillEnter());\n }\n\n override onViewWillLeave() {\n super.onViewWillLeave();\n this.rdtChildren.forEach((ch) => ch.onViewWillLeave());\n }\n\n getChildrenRecursive(filter?: (ch: RdtChildDirective) => boolean) {\n const res: RdtChildDirective[] = [];\n this._getChildrenRecursive(res, filter);\n return res;\n }\n\n protected getActiveChildren() {\n return this.getChildrenRecursive((ch) => ch.isActive());\n }\n\n getChildrenByClass<T>(childClass: Type<T>) {\n const res: T[] = [];\n this._getChildrenByClassRecursive(childClass, res);\n return res;\n }\n\n private _getChildrenRecursive(\n res: RdtChildDirective[],\n filter?: (ch: RdtChildDirective) => boolean\n ) {\n const children = Array.from(this.rdtChildren);\n const filteredChildren = filter ? children.filter(filter) : children;\n res.push(...filteredChildren);\n filteredChildren.forEach((child) => {\n if (child instanceof RdtContainerDirective) {\n child._getChildrenRecursive(res, filter);\n }\n });\n }\n\n private _getChildrenByClassRecursive<T>(childClass: Type<T>, res: T[]) {\n this.rdtChildren.forEach((child) => {\n const comp = (child as RdtChildDirective).guardedComponent;\n if (comp instanceof childClass) {\n res.push(comp);\n } else if (child instanceof RdtContainerDirective) {\n child._getChildrenByClassRecursive(childClass, res);\n }\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MASa,2BAA2B,GAAG,IAAI,cAAc,CAC3D,EAAE;;MCJS,yBAAyB,CAAA;AAC3B,IAAA,SAAS,GAAG,MAAM,CAAC,2BAA2B,EAAE;AACvD,QAAA,IAAI,EAAE,IAAI;AACV,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,IAAI,EAAE,IAAI;AACX,KAAA,CAAC,CAAC;IAEH,QAAQ,GAAA;AACN,QAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,CAAA;;;AAGoC,yDAAA,CAAA,CAAC,CAAC;SACvD;KACF;uGAdU,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;2FAAzB,yBAAyB,EAAA,QAAA,EAAA,oBAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAAzB,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAHrC,SAAS;AAAC,YAAA,IAAA,EAAA,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,4BAAA,OAAO,EAAE,iBAAiB;AAC1B,4BAAA,WAAW,EAAuB,qBAAA;AACnC,yBAAA;AACD,wBAAA;AACE,4BAAA,OAAO,EAAE,aAAa;AACtB,4BAAA,WAAW,EAAuB,qBAAA;AACnC,yBAAA;AACF,qBAAA;AACF,iBAAA,CAAA;;;AClBD;;AAEG;;;;"}
@@ -0,0 +1,8 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { RdtBooleanResult } from '../utils';
3
+ export interface RdtAutocusable {
4
+ rdtFocus(): void;
5
+ rdtCanFocus(): RdtBooleanResult;
6
+ rdtGetAutofocusPriority?(): number;
7
+ }
8
+ export declare const RDT_AUTOFOCUSABLE_COMPONENT: InjectionToken<RdtAutocusable>;
@@ -0,0 +1,8 @@
1
+ import { OnInit } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class RdtAutofocusableDirective implements OnInit {
4
+ readonly component: import("./models").RdtAutocusable | null;
5
+ ngOnInit(): void;
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<RdtAutofocusableDirective, never>;
7
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RdtAutofocusableDirective, "[rdtAutofocusable]", never, {}, {}, never, never, false, never>;
8
+ }
@@ -0,0 +1,3 @@
1
+ import { RdtAutocusable } from './models';
2
+ import { RdtAutofocusableDirective } from './rdt-autofocusable.directive';
3
+ export declare function getRdtAutofocusable(src: Iterable<RdtAutofocusableDirective>): RdtAutocusable | null;
@@ -0,0 +1,22 @@
1
+ import { DestroyRef, OnDestroy, OnInit, Type } from '@angular/core';
2
+ import { RdtBooleanResult } from '../../utils';
3
+ import { RdtCanEnterView, RdtCanLeaveView, RdtIsActive, RdtOnViewWillEnter, RdtOnViewWillLeave } from '../models';
4
+ import { RdtComponentGuardStoreService } from '../services/rdt-component-guard-store.service';
5
+ import { RdtContainerDirective } from './rdt-container.directive';
6
+ import * as i0 from "@angular/core";
7
+ export declare class RdtChildDirective implements OnInit, OnDestroy {
8
+ readonly guardStore: RdtComponentGuardStoreService;
9
+ readonly destroyRef: DestroyRef;
10
+ readonly container: RdtContainerDirective | null;
11
+ readonly guardedComponent: RdtIsActive | RdtCanLeaveView | RdtCanEnterView | RdtOnViewWillEnter | RdtOnViewWillLeave | null;
12
+ ngOnInit(): void;
13
+ ngOnDestroy(): void;
14
+ isActive(): boolean;
15
+ canEnterView(): RdtBooleanResult;
16
+ canLeaveView(): RdtBooleanResult;
17
+ onViewWillEnter(): void;
18
+ onViewWillLeave(): void;
19
+ getParentByClass<T extends RdtContainerDirective>(parentClass: Type<T>): T | null;
20
+ static ɵfac: i0.ɵɵFactoryDeclaration<RdtChildDirective, never>;
21
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RdtChildDirective, "[rdtChild]", never, {}, {}, never, never, true, never>;
22
+ }
@@ -0,0 +1,18 @@
1
+ import { Type } from '@angular/core';
2
+ import { RdtChildDirective } from './rdt-child.directive';
3
+ import * as i0 from "@angular/core";
4
+ export declare class RdtContainerDirective extends RdtChildDirective {
5
+ readonly rdtChildren: Set<RdtChildDirective>;
6
+ registerChild(child: RdtChildDirective): void;
7
+ removeChild(child: RdtChildDirective): void;
8
+ checkCanLeave$(): import("rxjs").Observable<boolean>;
9
+ onViewWillEnter(): void;
10
+ onViewWillLeave(): void;
11
+ getChildrenRecursive(filter?: (ch: RdtChildDirective) => boolean): RdtChildDirective[];
12
+ protected getActiveChildren(): RdtChildDirective[];
13
+ getChildrenByClass<T>(childClass: Type<T>): T[];
14
+ private _getChildrenRecursive;
15
+ private _getChildrenByClassRecursive;
16
+ static ɵfac: i0.ɵɵFactoryDeclaration<RdtContainerDirective, never>;
17
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RdtContainerDirective, "[rdtContainer]", never, {}, {}, never, never, true, never>;
18
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './directives/rdt-child.directive';
2
2
  export * from './directives/rdt-container.directive';
3
3
  export * from './models';
4
+ export * from './services/rdt-component-guard-store.service';
@@ -0,0 +1,22 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { Nullable } from '@ngrdt/utils';
3
+ import { RdtBooleanResult } from '../utils';
4
+ import { RdtContainerDirective } from './directives/rdt-container.directive';
5
+ export interface RdtIsActive {
6
+ rdtIsActive(): boolean;
7
+ }
8
+ export interface RdtCanLeaveView {
9
+ rdtCanLeaveView(): RdtBooleanResult;
10
+ }
11
+ export interface RdtCanEnterView {
12
+ rdtCanEnterView(): RdtBooleanResult;
13
+ }
14
+ export interface RdtOnViewWillLeave {
15
+ rdtOnViewWillLeave(): void;
16
+ }
17
+ export interface RdtOnViewWillEnter {
18
+ rdtOnViewWillEnter(): void;
19
+ }
20
+ export declare const RDT_GUARDED_COMPONENT: InjectionToken<RdtIsActive | RdtCanLeaveView | RdtCanEnterView | RdtOnViewWillEnter | RdtOnViewWillLeave>;
21
+ export declare const RDT_CONTAINER: InjectionToken<RdtContainerDirective>;
22
+ export declare function canTransition$(from: Nullable<RdtContainerDirective>, to: Nullable<RdtContainerDirective>): import("rxjs").Observable<boolean>;
@@ -0,0 +1,11 @@
1
+ import { RdtChildDirective } from '../directives/rdt-child.directive';
2
+ import * as i0 from "@angular/core";
3
+ export declare class RdtComponentGuardStoreService {
4
+ private readonly guards;
5
+ registerGuard(guard: RdtChildDirective): void;
6
+ removeGuard(guard: RdtChildDirective): void;
7
+ getGuards(): RdtChildDirective[];
8
+ checkCanLeaveGlobal$(): import("rxjs").Observable<boolean>;
9
+ static ɵfac: i0.ɵɵFactoryDeclaration<RdtComponentGuardStoreService, never>;
10
+ static ɵprov: i0.ɵɵInjectableDeclaration<RdtComponentGuardStoreService>;
11
+ }
@@ -0,0 +1,4 @@
1
+ import { Observable } from 'rxjs';
2
+ export type RdtBooleanResult = Observable<boolean> | Promise<boolean> | boolean;
3
+ export declare function rdtGetAllResultsTrue$(inputFactories: (() => RdtBooleanResult)[]): Observable<boolean>;
4
+ export declare function rdtGetResult$(inputFactory: () => RdtBooleanResult): Observable<true>;
package/package.json CHANGED
@@ -1,10 +1,26 @@
1
1
  {
2
2
  "name": "@ngrdt/core",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "peerDependencies": {
5
5
  "@angular/core": "^18.2.0",
6
6
  "rxjs": "~7.8.0",
7
- "@ngrdt/utils": "0.0.6"
7
+ "@ngrdt/utils": "0.0.7"
8
8
  },
9
- "sideEffects": false
10
- }
9
+ "sideEffects": false,
10
+ "module": "fesm2022/ngrdt-core.mjs",
11
+ "typings": "index.d.ts",
12
+ "exports": {
13
+ "./package.json": {
14
+ "default": "./package.json"
15
+ },
16
+ ".": {
17
+ "types": "./index.d.ts",
18
+ "esm2022": "./esm2022/ngrdt-core.mjs",
19
+ "esm": "./esm2022/ngrdt-core.mjs",
20
+ "default": "./fesm2022/ngrdt-core.mjs"
21
+ }
22
+ },
23
+ "dependencies": {
24
+ "tslib": "^2.3.0"
25
+ }
26
+ }
package/eslint.config.js DELETED
@@ -1,44 +0,0 @@
1
- const nx = require('@nx/eslint-plugin');
2
- const baseConfig = require('../../eslint.config.js');
3
-
4
- module.exports = [
5
- ...baseConfig,
6
- {
7
- files: ['**/*.json'],
8
- rules: {
9
- '@nx/dependency-checks': [
10
- 'error',
11
- { ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'] },
12
- ],
13
- },
14
- languageOptions: { parser: require('jsonc-eslint-parser') },
15
- },
16
- ...nx.configs['flat/angular'],
17
- ...nx.configs['flat/angular-template'],
18
- {
19
- files: ['**/*.ts'],
20
- rules: {
21
- '@angular-eslint/directive-selector': [
22
- 'error',
23
- {
24
- type: 'attribute',
25
- prefix: 'lib',
26
- style: 'camelCase',
27
- },
28
- ],
29
- '@angular-eslint/component-selector': [
30
- 'error',
31
- {
32
- type: 'element',
33
- prefix: 'lib',
34
- style: 'kebab-case',
35
- },
36
- ],
37
- },
38
- },
39
- {
40
- files: ['**/*.html'],
41
- // Override or add rules here
42
- rules: {},
43
- },
44
- ];
package/jest.config.ts DELETED
@@ -1,21 +0,0 @@
1
- export default {
2
- displayName: '@ngrdt/core',
3
- preset: '../../jest.preset.js',
4
- setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
5
- coverageDirectory: '../../coverage/@ngrdt/core',
6
- transform: {
7
- '^.+\\.(ts|mjs|js|html)$': [
8
- 'jest-preset-angular',
9
- {
10
- tsconfig: '<rootDir>/tsconfig.spec.json',
11
- stringifyContentPathRegex: '\\.(html|svg)$',
12
- },
13
- ],
14
- },
15
- transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
16
- snapshotSerializers: [
17
- 'jest-preset-angular/build/serializers/no-ng-attributes',
18
- 'jest-preset-angular/build/serializers/ng-snapshot',
19
- 'jest-preset-angular/build/serializers/html-comment',
20
- ],
21
- };
package/ng-package.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../dist/@ngrdt/core",
4
- "lib": {
5
- "entryFile": "src/index.ts"
6
- }
7
- }
package/project.json DELETED
@@ -1,36 +0,0 @@
1
- {
2
- "name": "@ngrdt/core",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "@ngrdt/core/src",
5
- "prefix": "lib",
6
- "projectType": "library",
7
- "tags": [],
8
- "targets": {
9
- "build": {
10
- "executor": "@nx/angular:package",
11
- "outputs": ["{workspaceRoot}/dist/{projectRoot}"],
12
- "options": {
13
- "project": "@ngrdt/core/ng-package.json"
14
- },
15
- "configurations": {
16
- "production": {
17
- "tsConfig": "@ngrdt/core/tsconfig.lib.prod.json"
18
- },
19
- "development": {
20
- "tsConfig": "@ngrdt/core/tsconfig.lib.json"
21
- }
22
- },
23
- "defaultConfiguration": "production"
24
- },
25
- "test": {
26
- "executor": "@nx/jest:jest",
27
- "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
28
- "options": {
29
- "jestConfig": "@ngrdt/core/jest.config.ts"
30
- }
31
- },
32
- "lint": {
33
- "executor": "@nx/eslint:lint"
34
- }
35
- }
36
- }
@@ -1,12 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- import { RdtBooleanResult } from '../utils';
3
-
4
- export interface RdtAutocusable {
5
- rdtFocus(): void;
6
- rdtCanFocus(): RdtBooleanResult;
7
- rdtGetAutofocusPriority?(): number;
8
- }
9
-
10
- export const RDT_AUTOFOCUSABLE_COMPONENT = new InjectionToken<RdtAutocusable>(
11
- ''
12
- );
@@ -1,22 +0,0 @@
1
- import { Directive, inject, OnInit } from '@angular/core';
2
- import { RDT_AUTOFOCUSABLE_COMPONENT } from './models';
3
-
4
- @Directive({
5
- selector: '[rdtAutofocusable]',
6
- })
7
- export class RdtAutofocusableDirective implements OnInit {
8
- readonly component = inject(RDT_AUTOFOCUSABLE_COMPONENT, {
9
- host: true,
10
- optional: true,
11
- self: true,
12
- });
13
-
14
- ngOnInit() {
15
- if (!this.component) {
16
- throw new Error(`
17
- RdtAutofocusableDirective usage:
18
- Apply directive directly on component and provide the same component as RDT_AUTOFOCUSABLE_COMPONENT.
19
- The component must then implement RdtAutocusable.`);
20
- }
21
- }
22
- }
@@ -1,13 +0,0 @@
1
- import { RdtAutocusable } from './models';
2
- import { RdtAutofocusableDirective } from './rdt-autofocusable.directive';
3
-
4
- export function getRdtAutofocusable(
5
- src: Iterable<RdtAutofocusableDirective>
6
- ): RdtAutocusable | null {
7
- const withPrios = Array.from(src).map((dir) => ({
8
- cmp: dir.component,
9
- prio: dir.component?.rdtGetAutofocusPriority?.() ?? 0,
10
- }));
11
- withPrios.sort((a, b) => b.prio - a.prio);
12
- return withPrios[0]?.cmp;
13
- }