xt-components 0.5.0 → 0.5.5
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/xt-components.mjs +218 -50
- package/fesm2022/xt-components.mjs.map +1 -1
- package/index.d.ts +117 -39
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { signal, computed, InjectionToken, inject, Injectable, input, model, output, viewChild, Component } from '@angular/core';
|
|
3
3
|
import { xtTypeManager, ManagedDataHandler, isPrimitive } from 'xt-type';
|
|
4
4
|
import { loadRemoteModule } from '@angular-architects/native-federation';
|
|
5
5
|
import { NgComponentOutlet, CommonModule } from '@angular/common';
|
|
6
6
|
import * as i1 from '@angular/forms';
|
|
7
7
|
import { ReactiveFormsModule, FormControl, FormGroup, FormBuilder, FormArray } from '@angular/forms';
|
|
8
|
+
import { from } from 'rxjs';
|
|
8
9
|
|
|
9
10
|
class XtBaseContext {
|
|
10
11
|
/**
|
|
@@ -16,6 +17,11 @@ class XtBaseContext {
|
|
|
16
17
|
*/
|
|
17
18
|
constructor(displayMode, subName, parentGroup, parentContext) {
|
|
18
19
|
this.displayMode = 'FULL_VIEW';
|
|
20
|
+
/**
|
|
21
|
+
* Keeps track of all the possible actions for this context
|
|
22
|
+
* @protected
|
|
23
|
+
*/
|
|
24
|
+
this.listActions = signal(null, ...(ngDevMode ? [{ debugName: "listActions" }] : []));
|
|
19
25
|
this.displayValue = computed(() => {
|
|
20
26
|
if (this.nonFormValue !== undefined) {
|
|
21
27
|
return this.nonFormValue();
|
|
@@ -28,6 +34,13 @@ class XtBaseContext {
|
|
|
28
34
|
this.parentFormGroup = parentGroup;
|
|
29
35
|
this.parentContext = parentContext;
|
|
30
36
|
this.subName = subName;
|
|
37
|
+
if ((parentGroup != null) && (subName != null)) {
|
|
38
|
+
const subControl = parentGroup.get(subName);
|
|
39
|
+
// If it's a form group, then it should be set as localFormGroup
|
|
40
|
+
if (subControl?.controls != null) {
|
|
41
|
+
this.localFormGroup = subControl;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
31
44
|
}
|
|
32
45
|
setDisplayValue(newValue, type, updateParent = true) {
|
|
33
46
|
if (newValue !== undefined) {
|
|
@@ -172,9 +185,9 @@ class XtBaseContext {
|
|
|
172
185
|
}
|
|
173
186
|
else {
|
|
174
187
|
let subValue = null;
|
|
175
|
-
let
|
|
188
|
+
let currentGroup = this.formGroup();
|
|
176
189
|
// Recalculate parentGroup and formControlName and value if needed.
|
|
177
|
-
if (
|
|
190
|
+
if (currentGroup == null) {
|
|
178
191
|
let curValue = this.nonFormValue;
|
|
179
192
|
if (curValue != null) {
|
|
180
193
|
if (curValue() != null) {
|
|
@@ -185,7 +198,7 @@ class XtBaseContext {
|
|
|
185
198
|
subValue = signal(null);
|
|
186
199
|
}
|
|
187
200
|
}
|
|
188
|
-
const ret = new XtBaseContext(this.displayMode, subName,
|
|
201
|
+
const ret = new XtBaseContext(this.displayMode, subName, currentGroup, this);
|
|
189
202
|
if (subValue != null)
|
|
190
203
|
ret.nonFormValue = subValue;
|
|
191
204
|
if (subType != null) {
|
|
@@ -234,6 +247,7 @@ class XtPluginRegistry {
|
|
|
234
247
|
this.pluginRegistry = new Map();
|
|
235
248
|
this.componentRegistry = new Map();
|
|
236
249
|
this.componentByTypeCache = new Map();
|
|
250
|
+
this.actionByTypeRegistry = new Map();
|
|
237
251
|
this.listComponents = signal(new Array(), ...(ngDevMode ? [{ debugName: "listComponents" }] : []));
|
|
238
252
|
this.listPlugins = signal(new Array(), ...(ngDevMode ? [{ debugName: "listPlugins" }] : []));
|
|
239
253
|
}
|
|
@@ -266,6 +280,11 @@ class XtPluginRegistry {
|
|
|
266
280
|
if (updated)
|
|
267
281
|
this.componentByTypeCache.clear(); // Force recalculation of type
|
|
268
282
|
}
|
|
283
|
+
if (info.actionHandlers != null) {
|
|
284
|
+
for (const handler of info.actionHandlers) {
|
|
285
|
+
this.registerActionHandler(handler);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
269
288
|
this.listPlugins.update((array) => {
|
|
270
289
|
let found = false;
|
|
271
290
|
for (let i = 0; i < array.length; i++) {
|
|
@@ -364,6 +383,36 @@ class XtPluginRegistry {
|
|
|
364
383
|
}
|
|
365
384
|
return ret;
|
|
366
385
|
}
|
|
386
|
+
registerActionHandler(handlerInfo) {
|
|
387
|
+
for (const type of handlerInfo.types) {
|
|
388
|
+
const handlers = handlerInfo.actions;
|
|
389
|
+
for (const actionName of Object.keys(handlers)) {
|
|
390
|
+
let exist = this.actionByTypeRegistry.get(type);
|
|
391
|
+
if (exist == null) {
|
|
392
|
+
exist = new Map();
|
|
393
|
+
this.actionByTypeRegistry.set(type, exist);
|
|
394
|
+
}
|
|
395
|
+
exist.set(actionName, handlers[actionName]);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
findActionInfo(type, actionName) {
|
|
400
|
+
const handlers = this.actionByTypeRegistry.get(type);
|
|
401
|
+
if (handlers != null) {
|
|
402
|
+
return handlers.get(actionName);
|
|
403
|
+
}
|
|
404
|
+
return undefined;
|
|
405
|
+
}
|
|
406
|
+
listActionInfos(type) {
|
|
407
|
+
const handlers = this.actionByTypeRegistry.get(type);
|
|
408
|
+
if (handlers != null) {
|
|
409
|
+
return Array.from(handlers.entries()).map(([name, info]) => {
|
|
410
|
+
return { name: name, info: info };
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
else
|
|
414
|
+
return [];
|
|
415
|
+
}
|
|
367
416
|
}
|
|
368
417
|
|
|
369
418
|
/**
|
|
@@ -404,6 +453,20 @@ class XtRegistryResolver {
|
|
|
404
453
|
}
|
|
405
454
|
}
|
|
406
455
|
|
|
456
|
+
class XtAction {
|
|
457
|
+
constructor(name, info, enabled) {
|
|
458
|
+
this.enabled = signal(false, ...(ngDevMode ? [{ debugName: "enabled" }] : []));
|
|
459
|
+
this.name = name;
|
|
460
|
+
this.info = info;
|
|
461
|
+
if (enabled != null) {
|
|
462
|
+
this.enabled.set(enabled);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* An all in one helper class, enabling manipulation of the context, with data and type associated with it.
|
|
469
|
+
*/
|
|
407
470
|
class XtResolverService {
|
|
408
471
|
constructor() {
|
|
409
472
|
this.pluginRegistry = inject(XT_REGISTRY_TOKEN);
|
|
@@ -438,7 +501,7 @@ class XtResolverService {
|
|
|
438
501
|
return ret;
|
|
439
502
|
}
|
|
440
503
|
findTypeHandlerOf(baseContext, subName, value) {
|
|
441
|
-
const ret = this.typeResolver.findTypeHandler(baseContext.valueType, subName, value);
|
|
504
|
+
const ret = this.typeResolver.findTypeHandler(baseContext.valueType, false, subName, value);
|
|
442
505
|
return ret;
|
|
443
506
|
}
|
|
444
507
|
listSubNamesOf(baseContext, value) {
|
|
@@ -462,6 +525,54 @@ class XtResolverService {
|
|
|
462
525
|
}
|
|
463
526
|
}
|
|
464
527
|
}
|
|
528
|
+
/**
|
|
529
|
+
* Calculates all the possible actions for a given context
|
|
530
|
+
* @param context
|
|
531
|
+
* @param onlyVisible
|
|
532
|
+
*/
|
|
533
|
+
possibleActions(context, onlyVisible = true) {
|
|
534
|
+
const existingActions = context.listActions();
|
|
535
|
+
if (existingActions != null) {
|
|
536
|
+
return existingActions;
|
|
537
|
+
}
|
|
538
|
+
if (context.valueType != null) {
|
|
539
|
+
const actionInfos = this.pluginRegistry.listActionInfos(context.valueType);
|
|
540
|
+
const actions = actionInfos.map((info) => {
|
|
541
|
+
const ret = new XtAction(info.name, info.info, true);
|
|
542
|
+
return ret;
|
|
543
|
+
});
|
|
544
|
+
context.listActions.set(actions);
|
|
545
|
+
return actions;
|
|
546
|
+
}
|
|
547
|
+
return [];
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Finds the possible action with the given name for the current type, and runs it in the current value.
|
|
551
|
+
* If the action is not possible in this context, try a parent context
|
|
552
|
+
* @param actionName
|
|
553
|
+
*/
|
|
554
|
+
async runAction(context, actionName, storeMgr) {
|
|
555
|
+
let handler = null;
|
|
556
|
+
for (const action of this.possibleActions(context, false)) {
|
|
557
|
+
if (action.name == actionName) {
|
|
558
|
+
const handlerClass = action.info.handlerClass;
|
|
559
|
+
handler = new handlerClass();
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (handler != null) {
|
|
564
|
+
return handler.runAction(context, actionName, this, storeMgr);
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
// Couldn't find the handler, let's see if we can have that up the context chain
|
|
568
|
+
if (context.parentContext != null) {
|
|
569
|
+
return this.runAction(context.parentContext, actionName); // Run the parent without any store indication, as it most probably is different
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
return Promise.reject("Cannot find action " + actionName + " for context " + this.toString());
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
465
576
|
handlerDefinedFor(newType, handlers) {
|
|
466
577
|
for (const handler of handlers ?? []) {
|
|
467
578
|
if (handler.typesHandled.includes(newType)) {
|
|
@@ -503,10 +614,53 @@ class XtResolverService {
|
|
|
503
614
|
return module;
|
|
504
615
|
});
|
|
505
616
|
}
|
|
506
|
-
|
|
507
|
-
|
|
617
|
+
/**
|
|
618
|
+
* Based on the type & value of the element, find which property is on its type and returns it's value
|
|
619
|
+
* @param context
|
|
620
|
+
* @param subPropertyType
|
|
621
|
+
* @param value
|
|
622
|
+
*/
|
|
623
|
+
findSubPropertyWithType(context, subPropertyType, value) {
|
|
624
|
+
const subKeys = this.typeResolver.findSubPropertiesWithType(context.valueType, subPropertyType);
|
|
625
|
+
if ((subKeys != null) && (subKeys.length == 1)) {
|
|
626
|
+
return value[subKeys[0]];
|
|
627
|
+
}
|
|
628
|
+
else if (subKeys.length > 1) {
|
|
629
|
+
// Let's pickup the first
|
|
630
|
+
return value[subKeys[0]];
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
return undefined;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Creates a duplicate of an object, using our knowledge on its type given by the context
|
|
638
|
+
* @param context
|
|
639
|
+
* @param value
|
|
640
|
+
*/
|
|
641
|
+
safeDuplicate(context, value) {
|
|
642
|
+
const typeHandler = this.typeResolver.findTypeHandler(context.valueType, false, undefined, value);
|
|
643
|
+
if (typeHandler.handler != null) {
|
|
644
|
+
return typeHandler.handler.safeDuplicate(value);
|
|
645
|
+
}
|
|
646
|
+
return structuredClone(value);
|
|
647
|
+
}
|
|
648
|
+
resolveMappingOf(context, targetType, value) {
|
|
649
|
+
if (context.valueType != null) {
|
|
650
|
+
const typeHandler = this.typeResolver.findTypeHandler(targetType, false, undefined, value);
|
|
651
|
+
if (typeHandler.handler != null) {
|
|
652
|
+
const ret = typeHandler.handler.getOrCreateMappingFrom(context.valueType, this.typeResolver);
|
|
653
|
+
if (ret != null) {
|
|
654
|
+
return ret;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return undefined;
|
|
659
|
+
}
|
|
660
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtResolverService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
661
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtResolverService, providedIn: 'root' }); }
|
|
508
662
|
}
|
|
509
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
663
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtResolverService, decorators: [{
|
|
510
664
|
type: Injectable,
|
|
511
665
|
args: [{
|
|
512
666
|
providedIn: 'root'
|
|
@@ -589,16 +743,16 @@ class XtRenderComponent {
|
|
|
589
743
|
}
|
|
590
744
|
}
|
|
591
745
|
}
|
|
592
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
593
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.
|
|
746
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtRenderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
747
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.3.9", type: XtRenderComponent, isStandalone: true, selector: "xt-render", inputs: { componentType: { classPropertyName: "componentType", publicName: "componentType", isSignal: true, isRequired: false, transformFunction: null }, displayMode: { classPropertyName: "displayMode", publicName: "displayMode", isSignal: true, isRequired: true, transformFunction: null }, valueType: { classPropertyName: "valueType", publicName: "valueType", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, formGroup: { classPropertyName: "formGroup", publicName: "formGroup", isSignal: true, isRequired: false, transformFunction: null }, subName: { classPropertyName: "subName", publicName: "subName", isSignal: true, isRequired: false, transformFunction: null }, inputs: { classPropertyName: "inputs", publicName: "inputs", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", outputs: "outputs" }, viewQueries: [{ propertyName: "outlet", first: true, predicate: NgComponentOutlet, descendants: true, isSignal: true }], ngImport: i0, template: "<ng-container *ngComponentOutlet=\"type(); inputs: {context:context ()}\" />\n", styles: [""], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"], exportAs: ["ngComponentOutlet"] }, { kind: "ngmodule", type: ReactiveFormsModule }] }); }
|
|
594
748
|
}
|
|
595
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
749
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtRenderComponent, decorators: [{
|
|
596
750
|
type: Component,
|
|
597
751
|
args: [{ selector: 'xt-render', standalone: true, imports: [
|
|
598
752
|
NgComponentOutlet,
|
|
599
753
|
ReactiveFormsModule
|
|
600
754
|
], template: "<ng-container *ngComponentOutlet=\"type(); inputs: {context:context ()}\" />\n" }]
|
|
601
|
-
}], ctorParameters: () => [] });
|
|
755
|
+
}], ctorParameters: () => [], propDecorators: { componentType: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentType", required: false }] }], displayMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "displayMode", required: true }] }], valueType: [{ type: i0.Input, args: [{ isSignal: true, alias: "valueType", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: false }] }], subName: [{ type: i0.Input, args: [{ isSignal: true, alias: "subName", required: false }] }], inputs: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputs", required: false }] }], outputs: [{ type: i0.Output, args: ["outputs"] }], outlet: [{ type: i0.ViewChild, args: [i0.forwardRef(() => NgComponentOutlet), { isSignal: true }] }] } });
|
|
602
756
|
|
|
603
757
|
/**
|
|
604
758
|
* Dynamically render a component that will display the given subValue.
|
|
@@ -650,16 +804,16 @@ class XtRenderSubComponent {
|
|
|
650
804
|
}
|
|
651
805
|
}
|
|
652
806
|
}
|
|
653
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
654
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.
|
|
807
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtRenderSubComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
808
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.3.9", type: XtRenderSubComponent, isStandalone: true, selector: "xt-render-sub", inputs: { context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: true, transformFunction: null }, componentType: { classPropertyName: "componentType", publicName: "componentType", isSignal: true, isRequired: false, transformFunction: null }, inputs: { classPropertyName: "inputs", publicName: "inputs", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { outputs: "outputs" }, viewQueries: [{ propertyName: "outlet", first: true, predicate: NgComponentOutlet, descendants: true, isSignal: true }], ngImport: i0, template: "{{componentType()}}\n<ng-container *ngComponentOutlet=\"type(); inputs: {context:context ()}\" />\n", styles: [""], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"], exportAs: ["ngComponentOutlet"] }, { kind: "ngmodule", type: ReactiveFormsModule }] }); }
|
|
655
809
|
}
|
|
656
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
810
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtRenderSubComponent, decorators: [{
|
|
657
811
|
type: Component,
|
|
658
812
|
args: [{ selector: 'xt-render-sub', standalone: true, imports: [
|
|
659
813
|
NgComponentOutlet,
|
|
660
814
|
ReactiveFormsModule
|
|
661
815
|
], template: "{{componentType()}}\n<ng-container *ngComponentOutlet=\"type(); inputs: {context:context ()}\" />\n" }]
|
|
662
|
-
}] });
|
|
816
|
+
}], propDecorators: { context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: true }] }], componentType: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentType", required: false }] }], inputs: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputs", required: false }] }], outputs: [{ type: i0.Output, args: ["outputs"] }], outlet: [{ type: i0.ViewChild, args: [i0.forwardRef(() => NgComponentOutlet), { isSignal: true }] }] } });
|
|
663
817
|
|
|
664
818
|
class XtBaseInput {
|
|
665
819
|
}
|
|
@@ -756,17 +910,17 @@ class XtSimpleComponent {
|
|
|
756
910
|
setupInputOutput() {
|
|
757
911
|
// Nothing to do here
|
|
758
912
|
}
|
|
759
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
760
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.
|
|
913
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtSimpleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
914
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.9", type: XtSimpleComponent, isStandalone: true, selector: "ng-component", inputs: { context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { outputs: "outputs" }, ngImport: i0, template: '', isInline: true }); }
|
|
761
915
|
}
|
|
762
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
916
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtSimpleComponent, decorators: [{
|
|
763
917
|
type: Component,
|
|
764
918
|
args: [{
|
|
765
919
|
standalone: true,
|
|
766
920
|
imports: [],
|
|
767
921
|
template: ''
|
|
768
922
|
}]
|
|
769
|
-
}], ctorParameters: () => [] });
|
|
923
|
+
}], ctorParameters: () => [], propDecorators: { context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: true }] }], outputs: [{ type: i0.Output, args: ["outputs"] }] } });
|
|
770
924
|
|
|
771
925
|
class XtCompositeComponent extends XtSimpleComponent {
|
|
772
926
|
constructor() {
|
|
@@ -808,25 +962,25 @@ class XtCompositeComponent extends XtSimpleComponent {
|
|
|
808
962
|
this.formGroupIfAny(); // Ensure the context is properly initialized
|
|
809
963
|
return this.context().subContext(subName, subType, this.resolverService.typeResolver);
|
|
810
964
|
}
|
|
811
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
812
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.
|
|
965
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtCompositeComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
966
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.9", type: XtCompositeComponent, isStandalone: true, selector: "ng-component", usesInheritance: true, ngImport: i0, template: '', isInline: true, styles: [""] }); }
|
|
813
967
|
}
|
|
814
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
968
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtCompositeComponent, decorators: [{
|
|
815
969
|
type: Component,
|
|
816
970
|
args: [{ standalone: true, imports: [], template: '' }]
|
|
817
971
|
}] });
|
|
818
972
|
|
|
819
|
-
class
|
|
973
|
+
class XtMessageHandler {
|
|
820
974
|
errorOccurred(error, errorMsg) {
|
|
821
975
|
console.error(errorMsg, error);
|
|
822
976
|
}
|
|
823
977
|
warningOccurred(warningMsg) {
|
|
824
978
|
console.warn(warningMsg);
|
|
825
979
|
}
|
|
826
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
827
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.
|
|
980
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtMessageHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
981
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtMessageHandler, providedIn: 'root' }); }
|
|
828
982
|
}
|
|
829
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
983
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: XtMessageHandler, decorators: [{
|
|
830
984
|
type: Injectable,
|
|
831
985
|
args: [{
|
|
832
986
|
providedIn: 'root'
|
|
@@ -931,10 +1085,10 @@ class HostTestSimpleComponent {
|
|
|
931
1085
|
this.displayMode = input('FULL_VIEW', ...(ngDevMode ? [{ debugName: "displayMode" }] : []));
|
|
932
1086
|
this.value = input(undefined, ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
933
1087
|
}
|
|
934
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
935
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.
|
|
1088
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: HostTestSimpleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1089
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.9", type: HostTestSimpleComponent, isStandalone: true, selector: "test-host", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: true, transformFunction: null }, displayMode: { classPropertyName: "displayMode", publicName: "displayMode", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: '<h1>Test Simple Component</h1> <xt-render [componentType]="type()" [displayMode]="displayMode()" [value]="value()" ></xt-render> ', isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: XtRenderComponent, selector: "xt-render", inputs: ["componentType", "displayMode", "valueType", "value", "formGroup", "subName", "inputs"], outputs: ["valueChange", "outputs"] }] }); }
|
|
936
1090
|
}
|
|
937
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
1091
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: HostTestSimpleComponent, decorators: [{
|
|
938
1092
|
type: Component,
|
|
939
1093
|
args: [{
|
|
940
1094
|
selector: 'test-host',
|
|
@@ -942,7 +1096,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.3", ngImpor
|
|
|
942
1096
|
imports: [CommonModule, XtRenderComponent],
|
|
943
1097
|
template: '<h1>Test Simple Component</h1> <xt-render [componentType]="type()" [displayMode]="displayMode()" [value]="value()" ></xt-render> '
|
|
944
1098
|
}]
|
|
945
|
-
}] });
|
|
1099
|
+
}], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: true }] }], displayMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "displayMode", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }] } });
|
|
946
1100
|
/**
|
|
947
1101
|
* Same as HostTestSimpleComponent but it includes everything in a form.
|
|
948
1102
|
* Just set the component type, the formGroup and the component name, and your component will be run.
|
|
@@ -980,10 +1134,10 @@ class HostTestFormComponent {
|
|
|
980
1134
|
else
|
|
981
1135
|
throw new Error("FormGroup not yet created. Did you set formGroup or formDescription property ?");
|
|
982
1136
|
}
|
|
983
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
984
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.
|
|
1137
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: HostTestFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1138
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.9", type: HostTestFormComponent, isStandalone: true, selector: "test-form-host", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: true, transformFunction: null }, controlName: { classPropertyName: "controlName", publicName: "controlName", isSignal: true, isRequired: true, transformFunction: null }, formDescription: { classPropertyName: "formDescription", publicName: "formDescription", isSignal: true, isRequired: false, transformFunction: null }, formGroup: { classPropertyName: "formGroup", publicName: "formGroup", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: '<h1>Test Form Component</h1> <form [formGroup]="computedFormGroup()"> <xt-render [componentType]="type()" displayMode="FULL_EDITABLE" [subName]="controlName()" [formGroup]="computedFormGroup()"></xt-render></form>', isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: XtRenderComponent, selector: "xt-render", inputs: ["componentType", "displayMode", "valueType", "value", "formGroup", "subName", "inputs"], outputs: ["valueChange", "outputs"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }] }); }
|
|
985
1139
|
}
|
|
986
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
1140
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: HostTestFormComponent, decorators: [{
|
|
987
1141
|
type: Component,
|
|
988
1142
|
args: [{
|
|
989
1143
|
selector: 'test-form-host',
|
|
@@ -991,7 +1145,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.3", ngImpor
|
|
|
991
1145
|
imports: [CommonModule, XtRenderComponent, ReactiveFormsModule],
|
|
992
1146
|
template: '<h1>Test Form Component</h1> <form [formGroup]="computedFormGroup()"> <xt-render [componentType]="type()" displayMode="FULL_EDITABLE" [subName]="controlName()" [formGroup]="computedFormGroup()"></xt-render></form>'
|
|
993
1147
|
}]
|
|
994
|
-
}] });
|
|
1148
|
+
}], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: true }] }], controlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlName", required: true }] }], formDescription: [{ type: i0.Input, args: [{ isSignal: true, alias: "formDescription", required: false }] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: false }] }] } });
|
|
995
1149
|
/**
|
|
996
1150
|
* Component that can be used to test your component based on the type it handles
|
|
997
1151
|
* Just set the type hierarchy to register, the value, and it will instantiate the right component in your plugin
|
|
@@ -1008,10 +1162,10 @@ class HostTestTypedComponent {
|
|
|
1008
1162
|
return ret;
|
|
1009
1163
|
}, ...(ngDevMode ? [{ debugName: "context" }] : []));
|
|
1010
1164
|
}
|
|
1011
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
1012
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.
|
|
1165
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: HostTestTypedComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1166
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.9", type: HostTestTypedComponent, isStandalone: true, selector: "test-typed-host", inputs: { displayMode: { classPropertyName: "displayMode", publicName: "displayMode", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, valueType: { classPropertyName: "valueType", publicName: "valueType", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: '<h1>Test Typed Component</h1> <xt-render-sub [context]="context()" ></xt-render-sub> ', isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: XtRenderSubComponent, selector: "xt-render-sub", inputs: ["context", "componentType", "inputs"], outputs: ["outputs"] }] }); }
|
|
1013
1167
|
}
|
|
1014
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
1168
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: HostTestTypedComponent, decorators: [{
|
|
1015
1169
|
type: Component,
|
|
1016
1170
|
args: [{
|
|
1017
1171
|
selector: 'test-typed-host',
|
|
@@ -1019,7 +1173,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.3", ngImpor
|
|
|
1019
1173
|
imports: [CommonModule, XtRenderSubComponent],
|
|
1020
1174
|
template: '<h1>Test Typed Component</h1> <xt-render-sub [context]="context()" ></xt-render-sub> '
|
|
1021
1175
|
}]
|
|
1022
|
-
}] });
|
|
1176
|
+
}], propDecorators: { displayMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "displayMode", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], valueType: [{ type: i0.Input, args: [{ isSignal: true, alias: "valueType", required: false }] }] } });
|
|
1023
1177
|
/**
|
|
1024
1178
|
* Same as HostTestSimpleComponent but it includes everything in a form.
|
|
1025
1179
|
* Just set the component type, the formGroup and the component name, and your component will be run.
|
|
@@ -1081,10 +1235,10 @@ class HostTestTypedFormComponent {
|
|
|
1081
1235
|
retrieveValue(controlName) {
|
|
1082
1236
|
return this.computeFormGroup().value[controlName];
|
|
1083
1237
|
}
|
|
1084
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
1085
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.
|
|
1238
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: HostTestTypedFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1239
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.9", type: HostTestTypedFormComponent, isStandalone: true, selector: "test-typed-form-host", inputs: { valueType: { classPropertyName: "valueType", publicName: "valueType", isSignal: true, isRequired: false, transformFunction: null }, controlName: { classPropertyName: "controlName", publicName: "controlName", isSignal: true, isRequired: false, transformFunction: null }, formDescription: { classPropertyName: "formDescription", publicName: "formDescription", isSignal: true, isRequired: false, transformFunction: null }, formGroup: { classPropertyName: "formGroup", publicName: "formGroup", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: '<h1>Test Typed Form Component</h1> <form [formGroup]="parentFormGroup"> <xt-render-sub [context]="subContext()"></xt-render-sub></form>', isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: XtRenderSubComponent, selector: "xt-render-sub", inputs: ["context", "componentType", "inputs"], outputs: ["outputs"] }] }); }
|
|
1086
1240
|
}
|
|
1087
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
1241
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: HostTestTypedFormComponent, decorators: [{
|
|
1088
1242
|
type: Component,
|
|
1089
1243
|
args: [{
|
|
1090
1244
|
selector: 'test-typed-form-host',
|
|
@@ -1092,7 +1246,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.3", ngImpor
|
|
|
1092
1246
|
imports: [CommonModule, ReactiveFormsModule, XtRenderSubComponent],
|
|
1093
1247
|
template: '<h1>Test Typed Form Component</h1> <form [formGroup]="parentFormGroup"> <xt-render-sub [context]="subContext()"></xt-render-sub></form>'
|
|
1094
1248
|
}]
|
|
1095
|
-
}] });
|
|
1249
|
+
}], propDecorators: { valueType: [{ type: i0.Input, args: [{ isSignal: true, alias: "valueType", required: false }] }], controlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlName", required: false }] }], formDescription: [{ type: i0.Input, args: [{ isSignal: true, alias: "formDescription", required: false }] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: false }] }] } });
|
|
1096
1250
|
function generateFormGroup(formDescription) {
|
|
1097
1251
|
if (typeof formDescription != 'object') {
|
|
1098
1252
|
throw new Error('Form Description should be an object of values');
|
|
@@ -1158,16 +1312,22 @@ class TestStoreProvider {
|
|
|
1158
1312
|
}
|
|
1159
1313
|
return ret;
|
|
1160
1314
|
}
|
|
1161
|
-
extractKey(value) {
|
|
1162
|
-
if (value.
|
|
1163
|
-
return value.
|
|
1315
|
+
extractKey(value, create) {
|
|
1316
|
+
if (value._id != null)
|
|
1317
|
+
return value._id; // ManagedData key
|
|
1164
1318
|
else if (value.id != null)
|
|
1165
1319
|
return value.id;
|
|
1166
|
-
else
|
|
1320
|
+
else {
|
|
1321
|
+
if (create === true) {
|
|
1322
|
+
const newId = new Date().getTime().toString();
|
|
1323
|
+
value._id = newId;
|
|
1324
|
+
return newId;
|
|
1325
|
+
}
|
|
1167
1326
|
return value.toString();
|
|
1327
|
+
}
|
|
1168
1328
|
}
|
|
1169
1329
|
storeEntity(name, entity) {
|
|
1170
|
-
this.getOrCreateArray(name).set(this.extractKey(entity), entity);
|
|
1330
|
+
this.getOrCreateArray(name).set(this.extractKey(entity, true), entity);
|
|
1171
1331
|
return Promise.resolve(entity);
|
|
1172
1332
|
}
|
|
1173
1333
|
safeLoadEntity(name, key) {
|
|
@@ -1184,7 +1344,15 @@ class TestStoreProvider {
|
|
|
1184
1344
|
return Promise.resolve(this.getOrCreateArray(name).delete(key));
|
|
1185
1345
|
}
|
|
1186
1346
|
searchEntities(name, ...criteria) {
|
|
1187
|
-
|
|
1347
|
+
if ((criteria != null) && (criteria.length > 0)) {
|
|
1348
|
+
throw new Error('Method not implemented.');
|
|
1349
|
+
}
|
|
1350
|
+
// No criteria defined, just send the full list
|
|
1351
|
+
const ret = new Array();
|
|
1352
|
+
for (const toAdd of this.getOrCreateArray(name).values()) {
|
|
1353
|
+
ret.push(toAdd);
|
|
1354
|
+
}
|
|
1355
|
+
return from([ret]);
|
|
1188
1356
|
}
|
|
1189
1357
|
searchAndPrepareEntities(name, sort, groupBy, transformer, ...criteria) {
|
|
1190
1358
|
throw new Error('Method not implemented.');
|
|
@@ -1216,5 +1384,5 @@ class TestDocumentInfo {
|
|
|
1216
1384
|
* Generated bundle index. Do not edit.
|
|
1217
1385
|
*/
|
|
1218
1386
|
|
|
1219
|
-
export { HostTestFormComponent, HostTestSimpleComponent, HostTestTypedComponent, HostTestTypedFormComponent,
|
|
1387
|
+
export { HostTestFormComponent, HostTestSimpleComponent, HostTestTypedComponent, HostTestTypedFormComponent, StoreSupport, StoreTestHelper, TestDocumentInfo, TestStoreManager, TestStoreProvider, XT_REGISTRY_TOKEN, XT_RESOLVER_TOKEN, XT_TYPE_RESOLVER_TOKEN, XtBaseContext, XtCompositeComponent, XtMessageHandler, XtPluginRegistry, XtRenderComponent, XtRenderSubComponent, XtResolvedComponent, XtResolverService, XtSimpleComponent, XtUnitTestHelper, attachToFormGroup, initXtPluginRegistry, updateFormGroupWithValue, xtPluginRegistry };
|
|
1220
1388
|
//# sourceMappingURL=xt-components.mjs.map
|