xt-components 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/xt-components.mjs +283 -192
- package/fesm2022/xt-components.mjs.map +1 -1
- package/globals.d.ts +10 -0
- package/lib/angular/message-handler.d.ts +7 -0
- package/lib/angular/xt-resolver.service.d.ts +19 -6
- package/lib/angular/xt-tokens.d.ts +2 -2
- package/lib/plugin/xt-plugin-info.d.ts +6 -3
- package/lib/registry/xt-plugin-registry.d.ts +2 -2
- package/lib/resolver/xt-registry-resolver.d.ts +3 -3
- package/lib/store/store-support.d.ts +60 -0
- package/lib/test/store-test-helper.d.ts +36 -0
- package/lib/type/type-helper.d.ts +4 -0
- package/lib/xt-context.d.ts +5 -3
- package/package.json +1 -1
- package/public-api.d.ts +5 -1
- package/lib/type/xt-type-resolver.d.ts +0 -42
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper around xt-store manager: You can use it to check if xt-store is included or not, and decide what to do
|
|
3
|
+
*
|
|
4
|
+
* This allow plugins to potentially use xt-store whenever included in the applications running the plugin
|
|
5
|
+
*/
|
|
6
|
+
import { Observable } from 'rxjs';
|
|
7
|
+
export declare class StoreSupport {
|
|
8
|
+
protected static testStoreManager?: IStoreManager;
|
|
9
|
+
static isStoreManagerAvailable(): boolean;
|
|
10
|
+
static getStoreManager(): IStoreManager;
|
|
11
|
+
static setTestStoreManager(testStoreManager: IStoreManager): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Interface definition for xt-store component.
|
|
15
|
+
* We re-define them here to avoid importing xt-store in all plugins that don't need it.
|
|
16
|
+
*/
|
|
17
|
+
export interface IDataTransformer<T> {
|
|
18
|
+
/**
|
|
19
|
+
* Enable transformation of data right after it has been loaded from the store
|
|
20
|
+
* @param source
|
|
21
|
+
*/
|
|
22
|
+
postLoadingTransformation(source: any[]): T[];
|
|
23
|
+
}
|
|
24
|
+
export interface IDocumentInfo {
|
|
25
|
+
documentName: string;
|
|
26
|
+
isUrl: boolean;
|
|
27
|
+
documentId?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface IStoreProvider<T> {
|
|
30
|
+
storeEntity(name: string, entity: T): Promise<T>;
|
|
31
|
+
/**
|
|
32
|
+
* Rejects the promise if the entity is not found
|
|
33
|
+
* @param name
|
|
34
|
+
* @param key
|
|
35
|
+
*/
|
|
36
|
+
safeLoadEntity(name: string, key: any): Promise<T>;
|
|
37
|
+
loadEntity(name: string, key: any): Promise<T | undefined>;
|
|
38
|
+
deleteEntity(name: string, key: any): Promise<boolean>;
|
|
39
|
+
searchEntities(name: string, ...criteria: any[]): Observable<Array<T>>;
|
|
40
|
+
searchAndPrepareEntities(name: string, sort?: any, groupBy?: any, transformer?: IDataTransformer<T>, ...criteria: any[]): Observable<any>;
|
|
41
|
+
canStoreDocument(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Upload one document to a server store and returns the url or the id needed to retrieve them.
|
|
44
|
+
* @param toStore
|
|
45
|
+
* @param position
|
|
46
|
+
*/
|
|
47
|
+
storeDocument(toStore: File): Promise<IDocumentInfo>;
|
|
48
|
+
/**
|
|
49
|
+
* Upload documents to a server store and returns the url or the id needed to retrieve them.
|
|
50
|
+
* @param toStore
|
|
51
|
+
* @param position
|
|
52
|
+
*/
|
|
53
|
+
storeDocuments(toStore: File[]): Observable<IDocumentInfo>;
|
|
54
|
+
}
|
|
55
|
+
export interface IStoreManager {
|
|
56
|
+
getProvider<T = never>(name?: string): IStoreProvider<T> | undefined;
|
|
57
|
+
getProviderSafe<T = never>(name?: string): IStoreProvider<T>;
|
|
58
|
+
getDefaultProvider<T = never>(): IStoreProvider<T> | undefined;
|
|
59
|
+
getDefaultProviderSafe<T = never>(): IStoreProvider<T>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { IDataTransformer, IDocumentInfo, IStoreManager, IStoreProvider } from '../store/store-support';
|
|
3
|
+
/**
|
|
4
|
+
* A very light and not 100% compatible storemanager in case you are not using xt-store.
|
|
5
|
+
* It can emulate XtStoreManager to some extends for doing some tests
|
|
6
|
+
*/
|
|
7
|
+
export declare class StoreTestHelper {
|
|
8
|
+
static ensureTestProviderOnly(): void;
|
|
9
|
+
}
|
|
10
|
+
export declare class TestStoreManager implements IStoreManager {
|
|
11
|
+
protected defaultProvider: TestStoreProvider<never>;
|
|
12
|
+
getProvider<T = never>(name?: string): IStoreProvider<T> | undefined;
|
|
13
|
+
getProviderSafe<T = never>(name?: string): IStoreProvider<T>;
|
|
14
|
+
getDefaultProvider<T = never>(): IStoreProvider<T> | undefined;
|
|
15
|
+
getDefaultProviderSafe<T = never>(): IStoreProvider<T>;
|
|
16
|
+
}
|
|
17
|
+
export declare class TestStoreProvider<T = never> implements IStoreProvider<T> {
|
|
18
|
+
protected data: Map<string, Map<string, any>>;
|
|
19
|
+
protected getOrCreateArray(name: string): Map<string, any>;
|
|
20
|
+
protected extractKey(value: any): string;
|
|
21
|
+
storeEntity(name: string, entity: T): Promise<T>;
|
|
22
|
+
safeLoadEntity(name: string, key: any): Promise<T>;
|
|
23
|
+
loadEntity(name: string, key: any): Promise<T | undefined>;
|
|
24
|
+
deleteEntity(name: string, key: any): Promise<boolean>;
|
|
25
|
+
searchEntities(name: string, ...criteria: any[]): Observable<T[]>;
|
|
26
|
+
searchAndPrepareEntities(name: string, sort?: any, groupBy?: any, transformer?: IDataTransformer<T> | undefined, ...criteria: any[]): Observable<any>;
|
|
27
|
+
canStoreDocument(): boolean;
|
|
28
|
+
storeDocument(toStore: File): Promise<IDocumentInfo>;
|
|
29
|
+
storeDocuments(toStore: File[]): Observable<IDocumentInfo>;
|
|
30
|
+
}
|
|
31
|
+
export declare class TestDocumentInfo implements IDocumentInfo {
|
|
32
|
+
documentName: string;
|
|
33
|
+
isUrl: boolean;
|
|
34
|
+
documentId?: string;
|
|
35
|
+
constructor(documentName: string, isUrl: boolean, documentId?: string);
|
|
36
|
+
}
|
package/lib/xt-context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FormGroup } from '@angular/forms';
|
|
2
|
-
import { XtTypeResolver } from '
|
|
2
|
+
import { XtTypeResolver } from 'xt-type';
|
|
3
3
|
import { Signal, WritableSignal } from '@angular/core';
|
|
4
4
|
/**
|
|
5
5
|
* A XtContext provides all the necessary information for an ng-extended component to operate. It is passed from parent to child component and pass
|
|
@@ -20,10 +20,11 @@ export type XtContext<T> = {
|
|
|
20
20
|
formControlNameOrNull(): string | null;
|
|
21
21
|
formControlValue(): any | null;
|
|
22
22
|
subValue(subName?: string): T | null | undefined;
|
|
23
|
-
subContext(subName: string | undefined | null, subType?: string, typeResolver?: XtTypeResolver
|
|
23
|
+
subContext(subName: string | undefined | null, subType?: string, typeResolver?: XtTypeResolver | null): XtContext<any>;
|
|
24
24
|
elementSetContext(subElement: any): XtContext<any>;
|
|
25
25
|
displayValue: Signal<T | null>;
|
|
26
26
|
setDisplayValue(newValue: T | null | undefined, type?: string): XtContext<T>;
|
|
27
|
+
setFormValue(newValue: T | null | undefined): boolean;
|
|
27
28
|
value(): T | null | undefined;
|
|
28
29
|
valueType?: string;
|
|
29
30
|
toString(): string;
|
|
@@ -72,13 +73,14 @@ export declare class XtBaseContext<T> implements XtContext<T> {
|
|
|
72
73
|
*/
|
|
73
74
|
protected updateSubDisplayValue(subName: string, subValue: any): void;
|
|
74
75
|
formControlValue(): T | null | undefined;
|
|
76
|
+
setFormValue(newValue: T | null | undefined): boolean;
|
|
75
77
|
/**
|
|
76
78
|
* Returns the context associated with a specific element in a set.
|
|
77
79
|
* Value must be an array.
|
|
78
80
|
* @param elementIndex
|
|
79
81
|
*/
|
|
80
82
|
elementSetContext(elementIndex: number): XtContext<any>;
|
|
81
|
-
subContext(subName: string | undefined | null, subType?: string, typeResolver?: XtTypeResolver
|
|
83
|
+
subContext(subName: string | undefined | null, subType?: string, typeResolver?: XtTypeResolver | null): XtContext<any>;
|
|
82
84
|
formGroup(): FormGroup | undefined;
|
|
83
85
|
toString(): string;
|
|
84
86
|
}
|
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -4,12 +4,16 @@ export * from './lib/xt-resolved-component';
|
|
|
4
4
|
export * from './lib/resolver/xt-resolver';
|
|
5
5
|
export * from './lib/registry/xt-plugin-registry';
|
|
6
6
|
export * from './lib/plugin/xt-plugin-info';
|
|
7
|
+
export * from './globals';
|
|
7
8
|
export * from './lib/angular/xt-tokens';
|
|
8
9
|
export * from './lib/angular/xt-resolver.service';
|
|
9
10
|
export * from './lib/render/xt-render.component';
|
|
10
11
|
export * from './lib/render/xt-render-sub.component';
|
|
11
12
|
export * from './lib/xt-simple/xt-simple.component';
|
|
12
13
|
export * from './lib/xt-composite/xt-composite.component';
|
|
13
|
-
export * from './lib/
|
|
14
|
+
export * from './lib/angular/message-handler';
|
|
15
|
+
export * from './lib/store/store-support';
|
|
16
|
+
export * from './lib/type/type-helper';
|
|
14
17
|
export * from './lib/test/xt-unit-test-helper';
|
|
15
18
|
export * from './lib/test/xt-test-helper-components';
|
|
19
|
+
export * from './lib/test/store-test-helper';
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { FormGroup } from '@angular/forms';
|
|
2
|
-
import { XtTypeInfo } from "../plugin/xt-plugin-info";
|
|
3
|
-
import { XtContext } from '../xt-context';
|
|
4
|
-
/**
|
|
5
|
-
* Determines the type of elements based on a hierarchy of type
|
|
6
|
-
*/
|
|
7
|
-
export type XtTypeResolver<TypeContext> = {
|
|
8
|
-
findType(typeInfo: TypeContext | null | undefined, subName?: string, value?: any): string | null | undefined;
|
|
9
|
-
listSubNames(typeInfo: TypeContext | null | undefined, value?: any): string[];
|
|
10
|
-
canUpdate(): boolean;
|
|
11
|
-
};
|
|
12
|
-
export type XtUpdatableTypeResolver<TypeContext> = XtTypeResolver<TypeContext> & {
|
|
13
|
-
addType(typeName: string, type: XtTypeInfo | string): void;
|
|
14
|
-
};
|
|
15
|
-
export declare class XtTypeHierarchyResolver<T> implements XtUpdatableTypeResolver<XtContext<T>> {
|
|
16
|
-
types: Map<string, XtTypeHierarchy>;
|
|
17
|
-
addType(typeName: string, type: XtTypeInfo | string): void;
|
|
18
|
-
canUpdate(): boolean;
|
|
19
|
-
findType(typeInfo: XtContext<T> | null | undefined, subName?: string, value?: any): string | null | undefined;
|
|
20
|
-
listSubNames(context: XtContext<T> | null | undefined, value?: any): string[];
|
|
21
|
-
}
|
|
22
|
-
export type XtTypeHierarchy = {
|
|
23
|
-
type?: string;
|
|
24
|
-
children?: {
|
|
25
|
-
[key: string]: XtTypeHierarchy;
|
|
26
|
-
};
|
|
27
|
-
parent?: XtTypeHierarchy;
|
|
28
|
-
addChild(key: string, child: XtTypeHierarchy): void;
|
|
29
|
-
};
|
|
30
|
-
export declare class XtBaseTypeHierarchy implements XtTypeHierarchy {
|
|
31
|
-
type?: string;
|
|
32
|
-
children?: {
|
|
33
|
-
[key: string]: XtTypeHierarchy;
|
|
34
|
-
};
|
|
35
|
-
parent?: XtTypeHierarchy;
|
|
36
|
-
constructor(type?: string, parent?: XtTypeHierarchy);
|
|
37
|
-
addChild(key: string, child: XtTypeHierarchy): void;
|
|
38
|
-
}
|
|
39
|
-
export declare function fromDescription(typeHierarchy: XtTypeInfo | string, name?: string, parent?: XtTypeHierarchy): XtTypeHierarchy;
|
|
40
|
-
export declare function updateFormGroupWithValue(formGroup: FormGroup, value: {
|
|
41
|
-
[key: string]: any;
|
|
42
|
-
}): void;
|