xt-components 0.4.8 → 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 +279 -98
- package/fesm2022/xt-components.mjs.map +1 -1
- package/index.d.ts +590 -3
- package/package.json +13 -13
- package/globals.d.ts +0 -10
- package/lib/angular/message-handler.d.ts +0 -7
- package/lib/angular/xt-resolver.service.d.ts +0 -40
- package/lib/angular/xt-tokens.d.ts +0 -7
- package/lib/output/xt-base-input.d.ts +0 -5
- package/lib/output/xt-base-output.d.ts +0 -5
- package/lib/plugin/xt-plugin-info.d.ts +0 -19
- package/lib/registry/xt-plugin-registry.d.ts +0 -34
- package/lib/render/xt-render-sub.component.d.ts +0 -28
- package/lib/render/xt-render.component.d.ts +0 -36
- package/lib/resolver/xt-registry-resolver.d.ts +0 -11
- package/lib/resolver/xt-resolver.d.ts +0 -5
- package/lib/store/store-support.d.ts +0 -60
- package/lib/test/store-test-helper.d.ts +0 -36
- package/lib/test/xt-test-helper-components.d.ts +0 -72
- package/lib/test/xt-unit-test-helper.d.ts +0 -2
- package/lib/type/type-helper.d.ts +0 -5
- package/lib/xt-component.d.ts +0 -22
- package/lib/xt-composite/xt-composite.component.d.ts +0 -21
- package/lib/xt-context.d.ts +0 -86
- package/lib/xt-resolved-component.d.ts +0 -8
- package/lib/xt-simple/xt-simple.component.d.ts +0 -44
- package/public-api.d.ts +0 -19
|
@@ -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();
|
|
@@ -23,11 +29,18 @@ class XtBaseContext {
|
|
|
23
29
|
else {
|
|
24
30
|
throw new Error("Cannot display a value that does not exist. Are you sure you're not using Reactive Form with this context? " + this.toString());
|
|
25
31
|
}
|
|
26
|
-
});
|
|
32
|
+
}, ...(ngDevMode ? [{ debugName: "displayValue" }] : []));
|
|
27
33
|
this.displayMode = displayMode;
|
|
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) {
|
|
@@ -35,7 +48,7 @@ class XtBaseContext {
|
|
|
35
48
|
if (this.nonFormValue == null) {
|
|
36
49
|
if ((this.childContexts != null) && (this.childContexts.size > 0))
|
|
37
50
|
throw new Error('An XtContext with no values cannot have children ', { cause: this });
|
|
38
|
-
this.nonFormValue = signal(newValue);
|
|
51
|
+
this.nonFormValue = signal(newValue, ...(ngDevMode ? [{ debugName: "nonFormValue" }] : []));
|
|
39
52
|
}
|
|
40
53
|
else {
|
|
41
54
|
this.nonFormValue.set(newValue);
|
|
@@ -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,8 +247,9 @@ class XtPluginRegistry {
|
|
|
234
247
|
this.pluginRegistry = new Map();
|
|
235
248
|
this.componentRegistry = new Map();
|
|
236
249
|
this.componentByTypeCache = new Map();
|
|
237
|
-
this.
|
|
238
|
-
this.
|
|
250
|
+
this.actionByTypeRegistry = new Map();
|
|
251
|
+
this.listComponents = signal(new Array(), ...(ngDevMode ? [{ debugName: "listComponents" }] : []));
|
|
252
|
+
this.listPlugins = signal(new Array(), ...(ngDevMode ? [{ debugName: "listPlugins" }] : []));
|
|
239
253
|
}
|
|
240
254
|
/**
|
|
241
255
|
* The component can manage any standard javascript primitives types. That's usually the default whenever we don't know any particular type
|
|
@@ -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);
|
|
@@ -411,10 +474,10 @@ class XtResolverService {
|
|
|
411
474
|
this.baseTypeResolver = inject(XT_TYPE_RESOLVER_TOKEN, { optional: true });
|
|
412
475
|
this.listComponents = computed(() => {
|
|
413
476
|
return this.pluginRegistry.listComponents();
|
|
414
|
-
});
|
|
477
|
+
}, ...(ngDevMode ? [{ debugName: "listComponents" }] : []));
|
|
415
478
|
this.listPlugins = computed(() => {
|
|
416
479
|
return this.pluginRegistry.listPlugins();
|
|
417
|
-
});
|
|
480
|
+
}, ...(ngDevMode ? [{ debugName: "listPlugins" }] : []));
|
|
418
481
|
if (this.baseTypeResolver == null) {
|
|
419
482
|
this.typeResolver = xtTypeManager();
|
|
420
483
|
}
|
|
@@ -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: "
|
|
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'
|
|
@@ -524,16 +678,16 @@ class XtBaseOutput {
|
|
|
524
678
|
class XtRenderComponent {
|
|
525
679
|
constructor() {
|
|
526
680
|
this.resolverService = inject(XtResolverService);
|
|
527
|
-
this.componentType = input();
|
|
528
|
-
this.displayMode = input.required();
|
|
529
|
-
this.valueType = input();
|
|
681
|
+
this.componentType = input(...(ngDevMode ? [undefined, { debugName: "componentType" }] : []));
|
|
682
|
+
this.displayMode = input.required(...(ngDevMode ? [{ debugName: "displayMode" }] : []));
|
|
683
|
+
this.valueType = input(...(ngDevMode ? [undefined, { debugName: "valueType" }] : []));
|
|
530
684
|
// Either we set the value directly
|
|
531
|
-
this.value = model();
|
|
685
|
+
this.value = model(...(ngDevMode ? [undefined, { debugName: "value" }] : []));
|
|
532
686
|
// Or we are inside a Form
|
|
533
|
-
this.formGroup = input();
|
|
534
|
-
this.subName = input();
|
|
687
|
+
this.formGroup = input(...(ngDevMode ? [undefined, { debugName: "formGroup" }] : []));
|
|
688
|
+
this.subName = input(...(ngDevMode ? [undefined, { debugName: "subName" }] : []));
|
|
535
689
|
this.outputsObject = new XtBaseOutput();
|
|
536
|
-
this.inputs = input();
|
|
690
|
+
this.inputs = input(...(ngDevMode ? [undefined, { debugName: "inputs" }] : []));
|
|
537
691
|
this.outputs = output();
|
|
538
692
|
this.outlet = viewChild.required(NgComponentOutlet);
|
|
539
693
|
this.context = computed(() => {
|
|
@@ -551,7 +705,7 @@ class XtRenderComponent {
|
|
|
551
705
|
}
|
|
552
706
|
}
|
|
553
707
|
return ret;
|
|
554
|
-
});
|
|
708
|
+
}, ...(ngDevMode ? [{ debugName: "context" }] : []));
|
|
555
709
|
this.type = computed(() => {
|
|
556
710
|
//console.debug("Calculating type in XtRenderSubComponent");
|
|
557
711
|
let type = this.componentType();
|
|
@@ -565,7 +719,7 @@ class XtRenderComponent {
|
|
|
565
719
|
type = compFound.componentClass;
|
|
566
720
|
}
|
|
567
721
|
return type ?? null;
|
|
568
|
-
});
|
|
722
|
+
}, ...(ngDevMode ? [{ debugName: "type" }] : []));
|
|
569
723
|
}
|
|
570
724
|
/**
|
|
571
725
|
* Transfers the input and outputs from the host to the rendered component
|
|
@@ -589,16 +743,16 @@ class XtRenderComponent {
|
|
|
589
743
|
}
|
|
590
744
|
}
|
|
591
745
|
}
|
|
592
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
593
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "
|
|
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: "
|
|
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.
|
|
@@ -606,10 +760,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
|
|
|
606
760
|
*/
|
|
607
761
|
class XtRenderSubComponent {
|
|
608
762
|
constructor() {
|
|
609
|
-
this.context = input.required();
|
|
610
|
-
this.componentType = input();
|
|
763
|
+
this.context = input.required(...(ngDevMode ? [{ debugName: "context" }] : []));
|
|
764
|
+
this.componentType = input(...(ngDevMode ? [undefined, { debugName: "componentType" }] : []));
|
|
611
765
|
this.outputsObject = new XtBaseOutput();
|
|
612
|
-
this.inputs = input();
|
|
766
|
+
this.inputs = input(...(ngDevMode ? [undefined, { debugName: "inputs" }] : []));
|
|
613
767
|
this.outputs = output();
|
|
614
768
|
this.outlet = viewChild.required(NgComponentOutlet);
|
|
615
769
|
this.resolverService = inject(XtResolverService);
|
|
@@ -626,7 +780,7 @@ class XtRenderSubComponent {
|
|
|
626
780
|
type = compFound.componentClass;
|
|
627
781
|
}
|
|
628
782
|
return type ?? null;
|
|
629
|
-
});
|
|
783
|
+
}, ...(ngDevMode ? [{ debugName: "type" }] : []));
|
|
630
784
|
}
|
|
631
785
|
/**
|
|
632
786
|
* Transfers the input and outputs from the host to the rendered component
|
|
@@ -650,16 +804,16 @@ class XtRenderSubComponent {
|
|
|
650
804
|
}
|
|
651
805
|
}
|
|
652
806
|
}
|
|
653
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
654
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "
|
|
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: "
|
|
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
|
}
|
|
@@ -670,37 +824,37 @@ class XtBaseInput {
|
|
|
670
824
|
*/
|
|
671
825
|
class XtSimpleComponent {
|
|
672
826
|
constructor() {
|
|
673
|
-
this.context = input.required();
|
|
827
|
+
this.context = input.required(...(ngDevMode ? [{ debugName: "context" }] : []));
|
|
674
828
|
this.outputsObject = new XtBaseOutput();
|
|
675
829
|
this.inputsObject = new XtBaseInput();
|
|
676
830
|
this.outputs = output();
|
|
677
831
|
this.isInForm = computed(() => {
|
|
678
832
|
return this.context()?.isInForm() ?? false;
|
|
679
|
-
});
|
|
833
|
+
}, ...(ngDevMode ? [{ debugName: "isInForm" }] : []));
|
|
680
834
|
this.formControlNameIfAny = computed(() => {
|
|
681
835
|
return this.context()?.subName;
|
|
682
|
-
});
|
|
836
|
+
}, ...(ngDevMode ? [{ debugName: "formControlNameIfAny" }] : []));
|
|
683
837
|
this.formGroupIfAny = computed(() => {
|
|
684
838
|
return this.context()?.formGroup();
|
|
685
|
-
});
|
|
839
|
+
}, ...(ngDevMode ? [{ debugName: "formGroupIfAny" }] : []));
|
|
686
840
|
this.formGroup = computed(() => {
|
|
687
841
|
const ret = this.context()?.formGroup();
|
|
688
842
|
if (ret == null)
|
|
689
843
|
throw new Error('No form groups in this component of type ' + this.componentDescriptor());
|
|
690
844
|
return ret;
|
|
691
|
-
});
|
|
845
|
+
}, ...(ngDevMode ? [{ debugName: "formGroup" }] : []));
|
|
692
846
|
/**
|
|
693
847
|
* Returns the component form name, which is for now the subName
|
|
694
848
|
*/
|
|
695
849
|
this.componentNameInForm = computed(() => {
|
|
696
850
|
return this.safelyGetSubName();
|
|
697
|
-
});
|
|
851
|
+
}, ...(ngDevMode ? [{ debugName: "componentNameInForm" }] : []));
|
|
698
852
|
this.safelyGetSubName = computed(() => {
|
|
699
853
|
const ret = this.context()?.subName;
|
|
700
854
|
if (ret == null)
|
|
701
855
|
throw new Error('This component has no name in the form ' + this.componentDescriptor());
|
|
702
856
|
return ret;
|
|
703
|
-
});
|
|
857
|
+
}, ...(ngDevMode ? [{ debugName: "safelyGetSubName" }] : []));
|
|
704
858
|
/**
|
|
705
859
|
* Returns the form control name and create a form control behind the scene
|
|
706
860
|
*/
|
|
@@ -708,20 +862,20 @@ class XtSimpleComponent {
|
|
|
708
862
|
const ret = this.safelyGetSubName();
|
|
709
863
|
//this.manageFormControl<any>(ret); // Don't create anything at this point. It's a computed value.
|
|
710
864
|
return ret;
|
|
711
|
-
});
|
|
865
|
+
}, ...(ngDevMode ? [{ debugName: "formControlName" }] : []));
|
|
712
866
|
this.formControl = computed(() => {
|
|
713
867
|
const subName = this.safelyGetSubName();
|
|
714
868
|
const formControl = this.manageFormControl(subName, false);
|
|
715
869
|
if (formControl == null)
|
|
716
870
|
throw new Error("Calling formControl for subName " + subName + " when none exist.");
|
|
717
871
|
return formControl;
|
|
718
|
-
});
|
|
872
|
+
}, ...(ngDevMode ? [{ debugName: "formControl" }] : []));
|
|
719
873
|
this.getValue = computed(() => {
|
|
720
874
|
return this.context().value();
|
|
721
|
-
});
|
|
875
|
+
}, ...(ngDevMode ? [{ debugName: "getValue" }] : []));
|
|
722
876
|
this.displayValue = computed(() => {
|
|
723
877
|
return this.context().displayValue();
|
|
724
|
-
});
|
|
878
|
+
}, ...(ngDevMode ? [{ debugName: "displayValue" }] : []));
|
|
725
879
|
}
|
|
726
880
|
ngOnInit() {
|
|
727
881
|
this.setupInputOutput();
|
|
@@ -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: "
|
|
760
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "
|
|
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: "
|
|
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() {
|
|
@@ -788,7 +942,7 @@ class XtCompositeComponent extends XtSimpleComponent {
|
|
|
788
942
|
ret = context.localFormGroup;
|
|
789
943
|
}
|
|
790
944
|
return ret;
|
|
791
|
-
});
|
|
945
|
+
}, ...(ngDevMode ? [{ debugName: "formGroupIfAny" }] : []));
|
|
792
946
|
/**
|
|
793
947
|
* We need to create a new form group to manage the sub elements.
|
|
794
948
|
*/
|
|
@@ -797,7 +951,7 @@ class XtCompositeComponent extends XtSimpleComponent {
|
|
|
797
951
|
if (ret == null)
|
|
798
952
|
throw new Error('No form groups in this component of type ' + this.componentDescriptor());
|
|
799
953
|
return ret;
|
|
800
|
-
});
|
|
954
|
+
}, ...(ngDevMode ? [{ debugName: "formGroup" }] : []));
|
|
801
955
|
}
|
|
802
956
|
/**
|
|
803
957
|
* Helper function to calculate the sub context
|
|
@@ -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: "
|
|
812
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
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: "
|
|
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: "
|
|
827
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
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: "
|
|
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'
|
|
@@ -847,6 +1001,19 @@ class StoreSupport {
|
|
|
847
1001
|
}
|
|
848
1002
|
}
|
|
849
1003
|
|
|
1004
|
+
function attachToFormGroup(formGroup, controlName, value, valueType, resolver) {
|
|
1005
|
+
// If it's a single value, just create the control
|
|
1006
|
+
if (((value != null) && (isPrimitive(value))
|
|
1007
|
+
|| (resolver?.isPrimitiveType(valueType)))) {
|
|
1008
|
+
const simpleControl = new FormControl(value);
|
|
1009
|
+
formGroup.addControl(controlName, simpleControl);
|
|
1010
|
+
}
|
|
1011
|
+
else {
|
|
1012
|
+
const complexGroup = new FormGroup({});
|
|
1013
|
+
updateFormGroupWithValue(complexGroup, value, valueType, resolver);
|
|
1014
|
+
formGroup.addControl(controlName, complexGroup);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
850
1017
|
function updateFormGroupWithValue(formGroup, value, valueType, resolver) {
|
|
851
1018
|
const toDelete = new Set(Object.keys(formGroup.controls));
|
|
852
1019
|
// We merge the properties of the value if any, with the properties of the model
|
|
@@ -860,7 +1027,7 @@ function updateFormGroupWithValue(formGroup, value, valueType, resolver) {
|
|
|
860
1027
|
for (const valueKey of keySet) {
|
|
861
1028
|
const subValue = (value != null) ? value[valueKey] : null;
|
|
862
1029
|
const subType = resolver?.findTypeName(valueType, valueKey, subValue) ?? undefined;
|
|
863
|
-
const primitive = (subType != null) ? resolver?.isPrimitiveType(subType) : isPrimitive(subValue);
|
|
1030
|
+
const primitive = (subType != null) ? resolver?.isPrimitiveType(subType, subValue) : isPrimitive(subValue);
|
|
864
1031
|
if (toDelete.delete(valueKey)) {
|
|
865
1032
|
// Already a control
|
|
866
1033
|
const oldControl = formGroup.get(valueKey);
|
|
@@ -914,14 +1081,14 @@ class XtUnitTestHelper {
|
|
|
914
1081
|
*/
|
|
915
1082
|
class HostTestSimpleComponent {
|
|
916
1083
|
constructor() {
|
|
917
|
-
this.type = input.required();
|
|
918
|
-
this.displayMode = input('FULL_VIEW');
|
|
919
|
-
this.value = input(undefined);
|
|
1084
|
+
this.type = input.required(...(ngDevMode ? [{ debugName: "type" }] : []));
|
|
1085
|
+
this.displayMode = input('FULL_VIEW', ...(ngDevMode ? [{ debugName: "displayMode" }] : []));
|
|
1086
|
+
this.value = input(undefined, ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
920
1087
|
}
|
|
921
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
922
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "
|
|
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"] }] }); }
|
|
923
1090
|
}
|
|
924
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1091
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: HostTestSimpleComponent, decorators: [{
|
|
925
1092
|
type: Component,
|
|
926
1093
|
args: [{
|
|
927
1094
|
selector: 'test-host',
|
|
@@ -929,7 +1096,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
|
|
|
929
1096
|
imports: [CommonModule, XtRenderComponent],
|
|
930
1097
|
template: '<h1>Test Simple Component</h1> <xt-render [componentType]="type()" [displayMode]="displayMode()" [value]="value()" ></xt-render> '
|
|
931
1098
|
}]
|
|
932
|
-
}] });
|
|
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 }] }] } });
|
|
933
1100
|
/**
|
|
934
1101
|
* Same as HostTestSimpleComponent but it includes everything in a form.
|
|
935
1102
|
* Just set the component type, the formGroup and the component name, and your component will be run.
|
|
@@ -938,12 +1105,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
|
|
|
938
1105
|
class HostTestFormComponent {
|
|
939
1106
|
constructor() {
|
|
940
1107
|
this.builder = inject(FormBuilder);
|
|
941
|
-
this.type = input.required();
|
|
942
|
-
this.controlName = input.required();
|
|
1108
|
+
this.type = input.required(...(ngDevMode ? [{ debugName: "type" }] : []));
|
|
1109
|
+
this.controlName = input.required(...(ngDevMode ? [{ debugName: "controlName" }] : []));
|
|
943
1110
|
// You can send the description to be used in a FormBuilder to create the formgroup;
|
|
944
|
-
this.formDescription = input({});
|
|
1111
|
+
this.formDescription = input({}, ...(ngDevMode ? [{ debugName: "formDescription" }] : []));
|
|
945
1112
|
// Or set the FormGroup directly
|
|
946
|
-
this.formGroup = input();
|
|
1113
|
+
this.formGroup = input(...(ngDevMode ? [undefined, { debugName: "formGroup" }] : []));
|
|
947
1114
|
this.createdFormGroup = null;
|
|
948
1115
|
}
|
|
949
1116
|
computedFormGroup() {
|
|
@@ -967,10 +1134,10 @@ class HostTestFormComponent {
|
|
|
967
1134
|
else
|
|
968
1135
|
throw new Error("FormGroup not yet created. Did you set formGroup or formDescription property ?");
|
|
969
1136
|
}
|
|
970
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
971
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "
|
|
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"] }] }); }
|
|
972
1139
|
}
|
|
973
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1140
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: HostTestFormComponent, decorators: [{
|
|
974
1141
|
type: Component,
|
|
975
1142
|
args: [{
|
|
976
1143
|
selector: 'test-form-host',
|
|
@@ -978,27 +1145,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
|
|
|
978
1145
|
imports: [CommonModule, XtRenderComponent, ReactiveFormsModule],
|
|
979
1146
|
template: '<h1>Test Form Component</h1> <form [formGroup]="computedFormGroup()"> <xt-render [componentType]="type()" displayMode="FULL_EDITABLE" [subName]="controlName()" [formGroup]="computedFormGroup()"></xt-render></form>'
|
|
980
1147
|
}]
|
|
981
|
-
}] });
|
|
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 }] }] } });
|
|
982
1149
|
/**
|
|
983
1150
|
* Component that can be used to test your component based on the type it handles
|
|
984
1151
|
* Just set the type hierarchy to register, the value, and it will instantiate the right component in your plugin
|
|
985
1152
|
*/
|
|
986
1153
|
class HostTestTypedComponent {
|
|
987
1154
|
constructor() {
|
|
988
|
-
this.displayMode = input('FULL_VIEW');
|
|
989
|
-
this.value = input();
|
|
990
|
-
this.valueType = input();
|
|
1155
|
+
this.displayMode = input('FULL_VIEW', ...(ngDevMode ? [{ debugName: "displayMode" }] : []));
|
|
1156
|
+
this.value = input(...(ngDevMode ? [undefined, { debugName: "value" }] : []));
|
|
1157
|
+
this.valueType = input(...(ngDevMode ? [undefined, { debugName: "valueType" }] : []));
|
|
991
1158
|
this.context = computed(() => {
|
|
992
1159
|
const ret = new XtBaseContext(this.displayMode());
|
|
993
1160
|
ret.valueType = this.valueType();
|
|
994
1161
|
ret.setDisplayValue(this.value());
|
|
995
1162
|
return ret;
|
|
996
|
-
});
|
|
1163
|
+
}, ...(ngDevMode ? [{ debugName: "context" }] : []));
|
|
997
1164
|
}
|
|
998
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
999
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "
|
|
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"] }] }); }
|
|
1000
1167
|
}
|
|
1001
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1168
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: HostTestTypedComponent, decorators: [{
|
|
1002
1169
|
type: Component,
|
|
1003
1170
|
args: [{
|
|
1004
1171
|
selector: 'test-typed-host',
|
|
@@ -1006,7 +1173,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
|
|
|
1006
1173
|
imports: [CommonModule, XtRenderSubComponent],
|
|
1007
1174
|
template: '<h1>Test Typed Component</h1> <xt-render-sub [context]="context()" ></xt-render-sub> '
|
|
1008
1175
|
}]
|
|
1009
|
-
}] });
|
|
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 }] }] } });
|
|
1010
1177
|
/**
|
|
1011
1178
|
* Same as HostTestSimpleComponent but it includes everything in a form.
|
|
1012
1179
|
* Just set the component type, the formGroup and the component name, and your component will be run.
|
|
@@ -1016,12 +1183,12 @@ class HostTestTypedFormComponent {
|
|
|
1016
1183
|
constructor() {
|
|
1017
1184
|
this.builder = inject(FormBuilder);
|
|
1018
1185
|
this.resolver = inject(XtResolverService);
|
|
1019
|
-
this.valueType = input();
|
|
1020
|
-
this.controlName = input();
|
|
1186
|
+
this.valueType = input(...(ngDevMode ? [undefined, { debugName: "valueType" }] : []));
|
|
1187
|
+
this.controlName = input(...(ngDevMode ? [undefined, { debugName: "controlName" }] : []));
|
|
1021
1188
|
// You can send the description to be used in a FormBuilder to create the formgroup;
|
|
1022
|
-
this.formDescription = input(null);
|
|
1189
|
+
this.formDescription = input(null, ...(ngDevMode ? [{ debugName: "formDescription" }] : []));
|
|
1023
1190
|
// Or set the FormGroup directly
|
|
1024
|
-
this.formGroup = input();
|
|
1191
|
+
this.formGroup = input(...(ngDevMode ? [undefined, { debugName: "formGroup" }] : []));
|
|
1025
1192
|
this.parentFormGroup = this.builder.group({});
|
|
1026
1193
|
this.createdFormGroup = null;
|
|
1027
1194
|
}
|
|
@@ -1068,10 +1235,10 @@ class HostTestTypedFormComponent {
|
|
|
1068
1235
|
retrieveValue(controlName) {
|
|
1069
1236
|
return this.computeFormGroup().value[controlName];
|
|
1070
1237
|
}
|
|
1071
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1072
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "
|
|
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"] }] }); }
|
|
1073
1240
|
}
|
|
1074
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1241
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: HostTestTypedFormComponent, decorators: [{
|
|
1075
1242
|
type: Component,
|
|
1076
1243
|
args: [{
|
|
1077
1244
|
selector: 'test-typed-form-host',
|
|
@@ -1079,7 +1246,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
|
|
|
1079
1246
|
imports: [CommonModule, ReactiveFormsModule, XtRenderSubComponent],
|
|
1080
1247
|
template: '<h1>Test Typed Form Component</h1> <form [formGroup]="parentFormGroup"> <xt-render-sub [context]="subContext()"></xt-render-sub></form>'
|
|
1081
1248
|
}]
|
|
1082
|
-
}] });
|
|
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 }] }] } });
|
|
1083
1250
|
function generateFormGroup(formDescription) {
|
|
1084
1251
|
if (typeof formDescription != 'object') {
|
|
1085
1252
|
throw new Error('Form Description should be an object of values');
|
|
@@ -1145,16 +1312,22 @@ class TestStoreProvider {
|
|
|
1145
1312
|
}
|
|
1146
1313
|
return ret;
|
|
1147
1314
|
}
|
|
1148
|
-
extractKey(value) {
|
|
1149
|
-
if (value.
|
|
1150
|
-
return value.
|
|
1315
|
+
extractKey(value, create) {
|
|
1316
|
+
if (value._id != null)
|
|
1317
|
+
return value._id; // ManagedData key
|
|
1151
1318
|
else if (value.id != null)
|
|
1152
1319
|
return value.id;
|
|
1153
|
-
else
|
|
1320
|
+
else {
|
|
1321
|
+
if (create === true) {
|
|
1322
|
+
const newId = new Date().getTime().toString();
|
|
1323
|
+
value._id = newId;
|
|
1324
|
+
return newId;
|
|
1325
|
+
}
|
|
1154
1326
|
return value.toString();
|
|
1327
|
+
}
|
|
1155
1328
|
}
|
|
1156
1329
|
storeEntity(name, entity) {
|
|
1157
|
-
this.getOrCreateArray(name).set(this.extractKey(entity), entity);
|
|
1330
|
+
this.getOrCreateArray(name).set(this.extractKey(entity, true), entity);
|
|
1158
1331
|
return Promise.resolve(entity);
|
|
1159
1332
|
}
|
|
1160
1333
|
safeLoadEntity(name, key) {
|
|
@@ -1171,7 +1344,15 @@ class TestStoreProvider {
|
|
|
1171
1344
|
return Promise.resolve(this.getOrCreateArray(name).delete(key));
|
|
1172
1345
|
}
|
|
1173
1346
|
searchEntities(name, ...criteria) {
|
|
1174
|
-
|
|
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]);
|
|
1175
1356
|
}
|
|
1176
1357
|
searchAndPrepareEntities(name, sort, groupBy, transformer, ...criteria) {
|
|
1177
1358
|
throw new Error('Method not implemented.');
|
|
@@ -1203,5 +1384,5 @@ class TestDocumentInfo {
|
|
|
1203
1384
|
* Generated bundle index. Do not edit.
|
|
1204
1385
|
*/
|
|
1205
1386
|
|
|
1206
|
-
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 };
|
|
1207
1388
|
//# sourceMappingURL=xt-components.mjs.map
|