xt-components 0.5.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/xt-components.mjs +500 -324
- package/fesm2022/xt-components.mjs.map +1 -1
- package/index.d.ts +141 -66
- package/package.json +4 -1
package/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
2
|
import { Signal, WritableSignal, InputSignal, OutputEmitterRef, Type, InjectionToken, AfterViewInit, OnInit } from '@angular/core';
|
|
3
3
|
import { FormGroup, AbstractControl, FormBuilder } from '@angular/forms';
|
|
4
|
-
import { XtTypeInfo, XtTypeResolver, XtTypeHandler, MappingHelper } from 'xt-type';
|
|
4
|
+
import { XtTypeInfo, XtTypeReference, XtTypeResolver, XtTypeHandler, MappingHelper } from 'xt-type';
|
|
5
5
|
import * as xt_components from 'xt-components';
|
|
6
|
-
import { NgComponentOutlet } from '@angular/common';
|
|
7
6
|
import { Observable } from 'rxjs';
|
|
7
|
+
import { NgComponentOutlet } from '@angular/common';
|
|
8
8
|
|
|
9
9
|
type XtComponentInfo<T> = {
|
|
10
10
|
componentName: string;
|
|
@@ -57,6 +57,24 @@ type XtContext<T> = {
|
|
|
57
57
|
subName?: string;
|
|
58
58
|
parentFormGroup?: FormGroup;
|
|
59
59
|
localFormGroup?: FormGroup;
|
|
60
|
+
/**
|
|
61
|
+
* When the value in the context is a reference to another type
|
|
62
|
+
*/
|
|
63
|
+
reference?: XtTypeReference;
|
|
64
|
+
/**
|
|
65
|
+
* If it's a reference, we keep the context referenced
|
|
66
|
+
*/
|
|
67
|
+
referencedContext?: XtContext<any>;
|
|
68
|
+
/**
|
|
69
|
+
* creates the referencedContext by using this referenced value
|
|
70
|
+
* @param val
|
|
71
|
+
*
|
|
72
|
+
updateReferencedContext(val: any, valueType?:string): void;*/
|
|
73
|
+
/**
|
|
74
|
+
* Signal when all the asynchronously defined subreferences are resolved.
|
|
75
|
+
*
|
|
76
|
+
subReferencesResolved: WritableSignal<boolean>;
|
|
77
|
+
*/
|
|
60
78
|
parentContext?: XtContext<any>;
|
|
61
79
|
isInForm(): boolean;
|
|
62
80
|
formGroup(): FormGroup | undefined;
|
|
@@ -72,6 +90,8 @@ type XtContext<T> = {
|
|
|
72
90
|
valueType?: string;
|
|
73
91
|
toString(): string;
|
|
74
92
|
listActions: WritableSignal<XtAction<T>[] | null>;
|
|
93
|
+
isReference(): boolean;
|
|
94
|
+
setReferenceInfo(ref: XtTypeReference): void;
|
|
75
95
|
};
|
|
76
96
|
type XtDisplayMode = 'INLINE_VIEW' | 'FULL_VIEW' | 'FULL_EDITABLE' | 'LIST_VIEW';
|
|
77
97
|
declare class XtBaseContext<T> implements XtContext<T> {
|
|
@@ -98,6 +118,14 @@ declare class XtBaseContext<T> implements XtContext<T> {
|
|
|
98
118
|
*/
|
|
99
119
|
nonFormValue?: WritableSignal<T | null>;
|
|
100
120
|
valueType?: string;
|
|
121
|
+
/**
|
|
122
|
+
* When the value in the context is a reference to another type
|
|
123
|
+
*/
|
|
124
|
+
reference?: XtTypeReference;
|
|
125
|
+
/**
|
|
126
|
+
* If it's a reference, we keep the context referenced
|
|
127
|
+
*
|
|
128
|
+
referencedContext?:XtContext<any>;*/
|
|
101
129
|
/**
|
|
102
130
|
* Keeps track of all the possible actions for this context
|
|
103
131
|
* @protected
|
|
@@ -131,6 +159,23 @@ declare class XtBaseContext<T> implements XtContext<T> {
|
|
|
131
159
|
elementSetContext(elementIndex: number): XtContext<any>;
|
|
132
160
|
subContext(subName: string | undefined | null, subType?: string, typeResolver?: XtTypeResolver | null): XtContext<any>;
|
|
133
161
|
formGroup(): FormGroup | undefined;
|
|
162
|
+
isReference(): boolean;
|
|
163
|
+
setReferenceInfo(reference: XtTypeReference): void;
|
|
164
|
+
/**
|
|
165
|
+
* creates the referencedContext by using this referenced value
|
|
166
|
+
* @param val
|
|
167
|
+
*
|
|
168
|
+
updateReferencedContext(val: any, valueType?:string): void {
|
|
169
|
+
if (!this.isReference()) throw new Error ('This context '+this.toString()+' is not a reference.');
|
|
170
|
+
|
|
171
|
+
if( this.referencedContext==null) {
|
|
172
|
+
let refDisplayMode = 'INLINE_VIEW' as XtDisplayMode;
|
|
173
|
+
if (this.displayMode=='FULL_VIEW') refDisplayMode = 'FULL_VIEW';
|
|
174
|
+
this.referencedContext = new XtBaseContext(refDisplayMode);
|
|
175
|
+
}
|
|
176
|
+
this.referencedContext.setDisplayValue(val);
|
|
177
|
+
if( valueType!=null) this.referencedContext.valueType=valueType;
|
|
178
|
+
}*/
|
|
134
179
|
toString(): string;
|
|
135
180
|
}
|
|
136
181
|
|
|
@@ -191,6 +236,11 @@ declare class XtPluginRegistry {
|
|
|
191
236
|
static readonly ANY_OBJECT_TYPE = "ANY_OBJECT_TYPE";
|
|
192
237
|
static readonly ANY_PRIMITIVE_SET = "ANY_PRIMITIVE_SET";
|
|
193
238
|
static readonly ANY_OBJECT_SET = "ANY_OBJECT_SET";
|
|
239
|
+
/**
|
|
240
|
+
* Whenever a component can handle any type of reference to a single entity or to multiple entities.
|
|
241
|
+
*/
|
|
242
|
+
static readonly ANY_SINGLE_REFERENCE = "ANY_SINGLE_REFERENCE";
|
|
243
|
+
static readonly ANY_MULTIPLE_REFERENCE = "ANY_MULTIPLE_REFERENCE";
|
|
194
244
|
registerPlugin(info: XtPluginInfo): void;
|
|
195
245
|
registerComponent<T>(info: XtComponentInfo<T>): void;
|
|
196
246
|
findComponentsForType<T>(valueType: string | null | undefined, value?: T): XtComponentInfo<any>[];
|
|
@@ -205,6 +255,75 @@ declare class XtPluginRegistry {
|
|
|
205
255
|
}[];
|
|
206
256
|
}
|
|
207
257
|
|
|
258
|
+
/**
|
|
259
|
+
* Wrapper around xt-store manager: You can use it to check if xt-store is included or not, and decide what to do
|
|
260
|
+
*
|
|
261
|
+
* This allows plugins to potentially use xt-store whenever included in the applications running the plugin
|
|
262
|
+
*/
|
|
263
|
+
|
|
264
|
+
declare class StoreSupport {
|
|
265
|
+
protected static testStoreManager?: IStoreManager;
|
|
266
|
+
static isStoreManagerAvailable(): boolean;
|
|
267
|
+
static getStoreManager(): IStoreManager;
|
|
268
|
+
static setTestStoreManager(testStoreManager: IStoreManager): void;
|
|
269
|
+
static newStoreCriteria(name: string, value: any, operator?: IStoreCriteriaOperator): IStoreCriteria;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Interface definition for xt-store component.
|
|
273
|
+
* We re-define them here to avoid importing xt-store in all plugins that don't need it.
|
|
274
|
+
*/
|
|
275
|
+
interface IDataTransformer<T> {
|
|
276
|
+
/**
|
|
277
|
+
* Enable transformation of data right after it has been loaded from the store
|
|
278
|
+
* @param source
|
|
279
|
+
*/
|
|
280
|
+
postLoadingTransformation(source: any[]): T[];
|
|
281
|
+
}
|
|
282
|
+
interface IDocumentInfo {
|
|
283
|
+
documentName: string;
|
|
284
|
+
isUrl: boolean;
|
|
285
|
+
documentId?: string;
|
|
286
|
+
}
|
|
287
|
+
type IStoreCriteriaOperator = '=' | '<' | '<=';
|
|
288
|
+
interface IStoreCriteria {
|
|
289
|
+
name: string;
|
|
290
|
+
value: any;
|
|
291
|
+
operator: IStoreCriteriaOperator;
|
|
292
|
+
}
|
|
293
|
+
interface IStoreProvider<T> {
|
|
294
|
+
storeEntity(name: string, entity: T): Promise<T>;
|
|
295
|
+
/**
|
|
296
|
+
* Rejects the promise if the entity is not found
|
|
297
|
+
* @param name
|
|
298
|
+
* @param key
|
|
299
|
+
*/
|
|
300
|
+
safeLoadEntity(name: string, key: any): Promise<T>;
|
|
301
|
+
loadEntity(name: string, key: any): Promise<T | undefined>;
|
|
302
|
+
deleteEntity(name: string, key: any): Promise<boolean>;
|
|
303
|
+
searchEntities(name: string, ...criteria: IStoreCriteria[]): Observable<Array<T>>;
|
|
304
|
+
searchAndPrepareEntities(name: string, sort?: any, groupBy?: any, transformer?: IDataTransformer<T>, ...criteria: any[]): Observable<any>;
|
|
305
|
+
canStoreDocument(): boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Upload one document to a server store and returns the url or the id needed to retrieve them.
|
|
308
|
+
* @param toStore
|
|
309
|
+
* @param position
|
|
310
|
+
*/
|
|
311
|
+
storeDocument(toStore: File): Promise<IDocumentInfo>;
|
|
312
|
+
/**
|
|
313
|
+
* Upload documents to a server store and returns the url or the id needed to retrieve them.
|
|
314
|
+
* @param toStore
|
|
315
|
+
* @param position
|
|
316
|
+
*/
|
|
317
|
+
storeDocuments(toStore: File[]): Observable<IDocumentInfo>;
|
|
318
|
+
}
|
|
319
|
+
interface IStoreManager {
|
|
320
|
+
getProvider<T = never>(name?: string): IStoreProvider<T> | undefined;
|
|
321
|
+
getProviderSafe<T = never>(name?: string): IStoreProvider<T>;
|
|
322
|
+
getDefaultProvider<T = never>(): IStoreProvider<T> | undefined;
|
|
323
|
+
getDefaultProviderSafe<T = never>(): IStoreProvider<T>;
|
|
324
|
+
newStoreCriteria(name: string, value: any, operator: IStoreCriteriaOperator): IStoreCriteria;
|
|
325
|
+
}
|
|
326
|
+
|
|
208
327
|
/**
|
|
209
328
|
* An all in one helper class, enabling manipulation of the context, with data and type associated with it.
|
|
210
329
|
*/
|
|
@@ -263,6 +382,13 @@ declare class XtResolverService {
|
|
|
263
382
|
*/
|
|
264
383
|
safeDuplicate<T>(context: XtContext<T>, value: T): T;
|
|
265
384
|
resolveMappingOf<U, T>(context: XtContext<T>, targetType: string, value?: T): MappingHelper<U, T> | undefined;
|
|
385
|
+
resolveReferencedValue<T, U>(context: XtContext<T>, storeMgr: IStoreManager): Promise<U | U[] | null | undefined>;
|
|
386
|
+
resolvePendingReferences(): void;
|
|
387
|
+
/**
|
|
388
|
+
* Calculates the values that can be referenced by the reference & value of this context
|
|
389
|
+
* @param context
|
|
390
|
+
*/
|
|
391
|
+
findPossibleReferences<T, U>(context: XtContext<T>): Observable<U[]>;
|
|
266
392
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtResolverService, never>;
|
|
267
393
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<XtResolverService>;
|
|
268
394
|
}
|
|
@@ -325,6 +451,7 @@ declare class XtRenderComponent<T> implements AfterViewInit {
|
|
|
325
451
|
outlet: Signal<NgComponentOutlet<any>>;
|
|
326
452
|
constructor();
|
|
327
453
|
context: Signal<XtContext<any>>;
|
|
454
|
+
realContext: Signal<XtContext<any>>;
|
|
328
455
|
type: Signal<Type<XtComponent<T>> | null>;
|
|
329
456
|
/**
|
|
330
457
|
* Transfers the input and outputs from the host to the rendered component
|
|
@@ -346,6 +473,7 @@ declare class XtRenderSubComponent<T> implements AfterViewInit {
|
|
|
346
473
|
outputs: _angular_core.OutputEmitterRef<XtComponentOutput>;
|
|
347
474
|
outlet: Signal<NgComponentOutlet<any>>;
|
|
348
475
|
resolverService: XtResolverService;
|
|
476
|
+
realContext: Signal<XtContext<T>>;
|
|
349
477
|
type: Signal<Type<XtComponent<T>> | null>;
|
|
350
478
|
/**
|
|
351
479
|
* Transfers the input and outputs from the host to the rendered component
|
|
@@ -417,67 +545,6 @@ declare class XtMessageHandler {
|
|
|
417
545
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<XtMessageHandler>;
|
|
418
546
|
}
|
|
419
547
|
|
|
420
|
-
/**
|
|
421
|
-
* Wrapper around xt-store manager: You can use it to check if xt-store is included or not, and decide what to do
|
|
422
|
-
*
|
|
423
|
-
* This allow plugins to potentially use xt-store whenever included in the applications running the plugin
|
|
424
|
-
*/
|
|
425
|
-
|
|
426
|
-
declare class StoreSupport {
|
|
427
|
-
protected static testStoreManager?: IStoreManager;
|
|
428
|
-
static isStoreManagerAvailable(): boolean;
|
|
429
|
-
static getStoreManager(): IStoreManager;
|
|
430
|
-
static setTestStoreManager(testStoreManager: IStoreManager): void;
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Interface definition for xt-store component.
|
|
434
|
-
* We re-define them here to avoid importing xt-store in all plugins that don't need it.
|
|
435
|
-
*/
|
|
436
|
-
interface IDataTransformer<T> {
|
|
437
|
-
/**
|
|
438
|
-
* Enable transformation of data right after it has been loaded from the store
|
|
439
|
-
* @param source
|
|
440
|
-
*/
|
|
441
|
-
postLoadingTransformation(source: any[]): T[];
|
|
442
|
-
}
|
|
443
|
-
interface IDocumentInfo {
|
|
444
|
-
documentName: string;
|
|
445
|
-
isUrl: boolean;
|
|
446
|
-
documentId?: string;
|
|
447
|
-
}
|
|
448
|
-
interface IStoreProvider<T> {
|
|
449
|
-
storeEntity(name: string, entity: T): Promise<T>;
|
|
450
|
-
/**
|
|
451
|
-
* Rejects the promise if the entity is not found
|
|
452
|
-
* @param name
|
|
453
|
-
* @param key
|
|
454
|
-
*/
|
|
455
|
-
safeLoadEntity(name: string, key: any): Promise<T>;
|
|
456
|
-
loadEntity(name: string, key: any): Promise<T | undefined>;
|
|
457
|
-
deleteEntity(name: string, key: any): Promise<boolean>;
|
|
458
|
-
searchEntities(name: string, ...criteria: any[]): Observable<Array<T>>;
|
|
459
|
-
searchAndPrepareEntities(name: string, sort?: any, groupBy?: any, transformer?: IDataTransformer<T>, ...criteria: any[]): Observable<any>;
|
|
460
|
-
canStoreDocument(): boolean;
|
|
461
|
-
/**
|
|
462
|
-
* Upload one document to a server store and returns the url or the id needed to retrieve them.
|
|
463
|
-
* @param toStore
|
|
464
|
-
* @param position
|
|
465
|
-
*/
|
|
466
|
-
storeDocument(toStore: File): Promise<IDocumentInfo>;
|
|
467
|
-
/**
|
|
468
|
-
* Upload documents to a server store and returns the url or the id needed to retrieve them.
|
|
469
|
-
* @param toStore
|
|
470
|
-
* @param position
|
|
471
|
-
*/
|
|
472
|
-
storeDocuments(toStore: File[]): Observable<IDocumentInfo>;
|
|
473
|
-
}
|
|
474
|
-
interface IStoreManager {
|
|
475
|
-
getProvider<T = never>(name?: string): IStoreProvider<T> | undefined;
|
|
476
|
-
getProviderSafe<T = never>(name?: string): IStoreProvider<T>;
|
|
477
|
-
getDefaultProvider<T = never>(): IStoreProvider<T> | undefined;
|
|
478
|
-
getDefaultProviderSafe<T = never>(): IStoreProvider<T>;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
548
|
declare function attachToFormGroup(formGroup: FormGroup, controlName: string, value: any, valueType?: string, resolver?: XtTypeResolver): void;
|
|
482
549
|
declare function updateFormGroupWithValue(formGroup: FormGroup, value: {
|
|
483
550
|
[key: string]: any;
|
|
@@ -566,6 +633,7 @@ declare class TestStoreManager implements IStoreManager {
|
|
|
566
633
|
getProviderSafe<T = never>(name?: string): IStoreProvider<T>;
|
|
567
634
|
getDefaultProvider<T = never>(): IStoreProvider<T> | undefined;
|
|
568
635
|
getDefaultProviderSafe<T = never>(): IStoreProvider<T>;
|
|
636
|
+
newStoreCriteria(name: string, value: any, operator: IStoreCriteriaOperator): IStoreCriteria;
|
|
569
637
|
}
|
|
570
638
|
declare class TestStoreProvider<T = never> implements IStoreProvider<T> {
|
|
571
639
|
protected data: Map<string, Map<string, any>>;
|
|
@@ -575,7 +643,7 @@ declare class TestStoreProvider<T = never> implements IStoreProvider<T> {
|
|
|
575
643
|
safeLoadEntity(name: string, key: any): Promise<T>;
|
|
576
644
|
loadEntity(name: string, key: any): Promise<T | undefined>;
|
|
577
645
|
deleteEntity(name: string, key: any): Promise<boolean>;
|
|
578
|
-
searchEntities(name: string, ...criteria:
|
|
646
|
+
searchEntities(name: string, ...criteria: TestStoreCriteria[]): Observable<T[]>;
|
|
579
647
|
searchAndPrepareEntities(name: string, sort?: any, groupBy?: any, transformer?: IDataTransformer<T> | undefined, ...criteria: any[]): Observable<any>;
|
|
580
648
|
canStoreDocument(): boolean;
|
|
581
649
|
storeDocument(toStore: File): Promise<IDocumentInfo>;
|
|
@@ -587,6 +655,13 @@ declare class TestDocumentInfo implements IDocumentInfo {
|
|
|
587
655
|
documentId?: string;
|
|
588
656
|
constructor(documentName: string, isUrl: boolean, documentId?: string);
|
|
589
657
|
}
|
|
658
|
+
declare class TestStoreCriteria implements IStoreCriteria {
|
|
659
|
+
name: string;
|
|
660
|
+
value: any;
|
|
661
|
+
operator: '=' | '<=' | '<';
|
|
662
|
+
constructor(name: string, value: any, operator?: IStoreCriteriaOperator);
|
|
663
|
+
filter(toFilter: any): boolean;
|
|
664
|
+
}
|
|
590
665
|
|
|
591
|
-
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 };
|
|
592
|
-
export type { IDataTransformer, IDocumentInfo, IStoreManager, IStoreProvider, XtActionHandler, XtActionHandlerInfo, XtActionInfo, XtActionResult, XtComponent, XtComponentInfo, XtComponentInput, XtComponentOutput, XtContext, XtDisplayMode, XtInputType, XtOutputType, XtPluginInfo, XtResolver, XtTypeHandlerInfo };
|
|
666
|
+
export { HostTestFormComponent, HostTestSimpleComponent, HostTestTypedComponent, HostTestTypedFormComponent, StoreSupport, StoreTestHelper, TestDocumentInfo, TestStoreCriteria, 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 };
|
|
667
|
+
export type { IDataTransformer, IDocumentInfo, IStoreCriteria, IStoreCriteriaOperator, IStoreManager, IStoreProvider, XtActionHandler, XtActionHandlerInfo, XtActionInfo, XtActionResult, XtComponent, XtComponentInfo, XtComponentInput, XtComponentOutput, XtContext, XtDisplayMode, XtInputType, XtOutputType, XtPluginInfo, XtResolver, XtTypeHandlerInfo };
|
package/package.json
CHANGED