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
package/index.d.ts
CHANGED
|
@@ -1,11 +1,49 @@
|
|
|
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 {
|
|
4
|
+
import { XtTypeInfo, XtTypeResolver, XtTypeHandler, MappingHelper } from 'xt-type';
|
|
5
5
|
import * as xt_components from 'xt-components';
|
|
6
6
|
import { NgComponentOutlet } from '@angular/common';
|
|
7
7
|
import { Observable } from 'rxjs';
|
|
8
8
|
|
|
9
|
+
type XtComponentInfo<T> = {
|
|
10
|
+
componentName: string;
|
|
11
|
+
componentClass: T;
|
|
12
|
+
typesHandled: string[];
|
|
13
|
+
outputs?: XtOutputType[];
|
|
14
|
+
};
|
|
15
|
+
type XtTypeHandlerInfo<T> = {
|
|
16
|
+
typesHandled: string[];
|
|
17
|
+
handlerClass: T;
|
|
18
|
+
};
|
|
19
|
+
type XtActionInfo<T> = {
|
|
20
|
+
description: string;
|
|
21
|
+
visible: boolean;
|
|
22
|
+
handlerClass: any;
|
|
23
|
+
iconUrl?: string;
|
|
24
|
+
};
|
|
25
|
+
type XtActionHandlerInfo<T> = {
|
|
26
|
+
types: string[];
|
|
27
|
+
actions: {
|
|
28
|
+
[name: string]: XtActionInfo<T>;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
type XtPluginInfo = {
|
|
32
|
+
name: string;
|
|
33
|
+
uriLogo?: string;
|
|
34
|
+
components?: XtComponentInfo<any>[];
|
|
35
|
+
types?: XtTypeInfo;
|
|
36
|
+
typeHandlers?: XtTypeHandlerInfo<any>[];
|
|
37
|
+
actionHandlers?: XtActionHandlerInfo<any>[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
declare class XtAction<T> {
|
|
41
|
+
name: string;
|
|
42
|
+
info: XtActionInfo<T>;
|
|
43
|
+
enabled: _angular_core.WritableSignal<boolean>;
|
|
44
|
+
constructor(name: string, info: XtActionInfo<T>, enabled?: boolean);
|
|
45
|
+
}
|
|
46
|
+
|
|
9
47
|
/**
|
|
10
48
|
* A XtContext provides all the necessary information for an ng-extended component to operate. It is passed from parent to child component and pass
|
|
11
49
|
* - The display mode - View, Inline view or Edit
|
|
@@ -33,6 +71,7 @@ type XtContext<T> = {
|
|
|
33
71
|
value(): T | null | undefined;
|
|
34
72
|
valueType?: string;
|
|
35
73
|
toString(): string;
|
|
74
|
+
listActions: WritableSignal<XtAction<T>[] | null>;
|
|
36
75
|
};
|
|
37
76
|
type XtDisplayMode = 'INLINE_VIEW' | 'FULL_VIEW' | 'FULL_EDITABLE' | 'LIST_VIEW';
|
|
38
77
|
declare class XtBaseContext<T> implements XtContext<T> {
|
|
@@ -59,6 +98,11 @@ declare class XtBaseContext<T> implements XtContext<T> {
|
|
|
59
98
|
*/
|
|
60
99
|
nonFormValue?: WritableSignal<T | null>;
|
|
61
100
|
valueType?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Keeps track of all the possible actions for this context
|
|
103
|
+
* @protected
|
|
104
|
+
*/
|
|
105
|
+
listActions: WritableSignal<XtAction<T>[] | null>;
|
|
62
106
|
/**
|
|
63
107
|
*
|
|
64
108
|
* @param displayMode
|
|
@@ -110,24 +154,6 @@ type XtComponentInput = {
|
|
|
110
154
|
[key in XtInputType]: InputSignal<any> | undefined;
|
|
111
155
|
};
|
|
112
156
|
|
|
113
|
-
type XtComponentInfo<T> = {
|
|
114
|
-
componentName: string;
|
|
115
|
-
componentClass: T;
|
|
116
|
-
typesHandled: string[];
|
|
117
|
-
outputs?: XtOutputType[];
|
|
118
|
-
};
|
|
119
|
-
type XtTypeHandlerInfo<T> = {
|
|
120
|
-
typesHandled: string[];
|
|
121
|
-
handlerClass: T;
|
|
122
|
-
};
|
|
123
|
-
type XtPluginInfo = {
|
|
124
|
-
name: string;
|
|
125
|
-
uriLogo?: string;
|
|
126
|
-
components?: XtComponentInfo<any>[];
|
|
127
|
-
types?: XtTypeInfo;
|
|
128
|
-
typeHandlers?: XtTypeHandlerInfo<any>[];
|
|
129
|
-
};
|
|
130
|
-
|
|
131
157
|
declare class XtResolvedComponent {
|
|
132
158
|
componentName: string;
|
|
133
159
|
componentClass: any;
|
|
@@ -144,6 +170,7 @@ declare class XtPluginRegistry {
|
|
|
144
170
|
pluginRegistry: Map<string, XtPluginInfo>;
|
|
145
171
|
componentRegistry: Map<string, XtComponentInfo<any>>;
|
|
146
172
|
componentByTypeCache: Map<string, XtComponentInfo<any>[]>;
|
|
173
|
+
protected actionByTypeRegistry: Map<string, Map<string, XtActionInfo<any>>>;
|
|
147
174
|
listComponents: _angular_core.WritableSignal<XtComponentInfo<any>[]>;
|
|
148
175
|
listPlugins: _angular_core.WritableSignal<XtPluginInfo[]>;
|
|
149
176
|
/**
|
|
@@ -170,23 +197,17 @@ declare class XtPluginRegistry {
|
|
|
170
197
|
static registry(): XtPluginRegistry;
|
|
171
198
|
findComponentInfo(type: Type<XtComponent<any>>): XtComponentInfo<any> | null;
|
|
172
199
|
getComponentInfo(type: Type<XtComponent<any>>): XtComponentInfo<any>;
|
|
200
|
+
registerActionHandler<T>(handlerInfo: XtActionHandlerInfo<T>): void;
|
|
201
|
+
findActionInfo<T>(type: string, actionName: string): XtActionInfo<T> | undefined;
|
|
202
|
+
listActionInfos<T>(type: string): {
|
|
203
|
+
name: string;
|
|
204
|
+
info: XtActionInfo<T>;
|
|
205
|
+
}[];
|
|
173
206
|
}
|
|
174
207
|
|
|
175
208
|
/**
|
|
176
|
-
*
|
|
177
|
-
* Plugins will register to this when loaded.
|
|
209
|
+
* An all in one helper class, enabling manipulation of the context, with data and type associated with it.
|
|
178
210
|
*/
|
|
179
|
-
|
|
180
|
-
declare global {
|
|
181
|
-
var XT_REGISTRY: XtPluginRegistry;
|
|
182
|
-
}
|
|
183
|
-
declare function initXtPluginRegistry(): void;
|
|
184
|
-
declare function xtPluginRegistry(): XtPluginRegistry;
|
|
185
|
-
|
|
186
|
-
declare const XT_RESOLVER_TOKEN: InjectionToken<XtResolver>;
|
|
187
|
-
declare const XT_TYPE_RESOLVER_TOKEN: InjectionToken<XtTypeResolver>;
|
|
188
|
-
declare const XT_REGISTRY_TOKEN: InjectionToken<XtPluginRegistry>;
|
|
189
|
-
|
|
190
211
|
declare class XtResolverService {
|
|
191
212
|
pluginRegistry: xt_components.XtPluginRegistry;
|
|
192
213
|
protected baseResolver: XtResolver | null;
|
|
@@ -204,6 +225,18 @@ declare class XtResolverService {
|
|
|
204
225
|
listSubNamesOfType<T>(valueType: string, value?: T): string[];
|
|
205
226
|
registerPlugin(info: XtPluginInfo): void;
|
|
206
227
|
registerTypes(types: XtTypeInfo | undefined, handlers?: XtTypeHandlerInfo<any>[]): void;
|
|
228
|
+
/**
|
|
229
|
+
* Calculates all the possible actions for a given context
|
|
230
|
+
* @param context
|
|
231
|
+
* @param onlyVisible
|
|
232
|
+
*/
|
|
233
|
+
possibleActions<T>(context: XtContext<T>, onlyVisible?: boolean): Array<XtAction<T>>;
|
|
234
|
+
/**
|
|
235
|
+
* Finds the possible action with the given name for the current type, and runs it in the current value.
|
|
236
|
+
* If the action is not possible in this context, try a parent context
|
|
237
|
+
* @param actionName
|
|
238
|
+
*/
|
|
239
|
+
runAction<T>(context: XtContext<T>, actionName: string, storeMgr?: any): Promise<XtActionResult<any>>;
|
|
207
240
|
protected handlerDefinedFor(newType: string, handlers: XtTypeHandlerInfo<any>[] | undefined): any;
|
|
208
241
|
getComponentInfo<T>(type: Type<XtComponent<T>>): XtResolvedComponent;
|
|
209
242
|
findComponentInfo<T>(type: Type<XtComponent<T>>): XtResolvedComponent | null;
|
|
@@ -216,10 +249,55 @@ declare class XtResolverService {
|
|
|
216
249
|
* @returns a Promise with the module loaded and already registered.
|
|
217
250
|
*/
|
|
218
251
|
loadPlugin(url: URL | string): Promise<any>;
|
|
252
|
+
/**
|
|
253
|
+
* Based on the type & value of the element, find which property is on its type and returns it's value
|
|
254
|
+
* @param context
|
|
255
|
+
* @param subPropertyType
|
|
256
|
+
* @param value
|
|
257
|
+
*/
|
|
258
|
+
findSubPropertyWithType<T>(context: XtContext<T>, subPropertyType: string, value: T): any;
|
|
259
|
+
/**
|
|
260
|
+
* Creates a duplicate of an object, using our knowledge on its type given by the context
|
|
261
|
+
* @param context
|
|
262
|
+
* @param value
|
|
263
|
+
*/
|
|
264
|
+
safeDuplicate<T>(context: XtContext<T>, value: T): T;
|
|
265
|
+
resolveMappingOf<U, T>(context: XtContext<T>, targetType: string, value?: T): MappingHelper<U, T> | undefined;
|
|
219
266
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtResolverService, never>;
|
|
220
267
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<XtResolverService>;
|
|
221
268
|
}
|
|
222
269
|
|
|
270
|
+
type XtActionResult<Type> = {
|
|
271
|
+
status: 'success' | 'error' | 'none';
|
|
272
|
+
warnings?: string[];
|
|
273
|
+
errors?: string[];
|
|
274
|
+
value?: Type | null;
|
|
275
|
+
};
|
|
276
|
+
type XtActionHandler<Type> = {
|
|
277
|
+
/**
|
|
278
|
+
* Runs an action on a item under the context
|
|
279
|
+
* @param context
|
|
280
|
+
* @param actionName
|
|
281
|
+
* @param store
|
|
282
|
+
*/
|
|
283
|
+
runAction(context: XtContext<Type>, actionName: string, resolver: XtResolverService, storeMgr?: any): Promise<XtActionResult<Type>>;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The global plugin registry.
|
|
288
|
+
* Plugins will register to this when loaded.
|
|
289
|
+
*/
|
|
290
|
+
|
|
291
|
+
declare global {
|
|
292
|
+
var XT_REGISTRY: XtPluginRegistry;
|
|
293
|
+
}
|
|
294
|
+
declare function initXtPluginRegistry(): void;
|
|
295
|
+
declare function xtPluginRegistry(): XtPluginRegistry;
|
|
296
|
+
|
|
297
|
+
declare const XT_RESOLVER_TOKEN: InjectionToken<XtResolver>;
|
|
298
|
+
declare const XT_TYPE_RESOLVER_TOKEN: InjectionToken<XtTypeResolver>;
|
|
299
|
+
declare const XT_REGISTRY_TOKEN: InjectionToken<XtPluginRegistry>;
|
|
300
|
+
|
|
223
301
|
declare class XtBaseOutput implements XtComponentOutput {
|
|
224
302
|
valueSelected: OutputEmitterRef<any> | undefined;
|
|
225
303
|
}
|
|
@@ -332,11 +410,11 @@ declare class XtCompositeComponent<T = any> extends XtSimpleComponent<T> {
|
|
|
332
410
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<XtCompositeComponent<any>, "ng-component", never, {}, {}, never, never, true, never>;
|
|
333
411
|
}
|
|
334
412
|
|
|
335
|
-
declare class
|
|
413
|
+
declare class XtMessageHandler {
|
|
336
414
|
errorOccurred(error: any, errorMsg?: string): void;
|
|
337
415
|
warningOccurred(warningMsg?: string): void;
|
|
338
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<
|
|
339
|
-
static ɵprov: _angular_core.ɵɵInjectableDeclaration<
|
|
416
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtMessageHandler, never>;
|
|
417
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<XtMessageHandler>;
|
|
340
418
|
}
|
|
341
419
|
|
|
342
420
|
/**
|
|
@@ -491,8 +569,8 @@ declare class TestStoreManager implements IStoreManager {
|
|
|
491
569
|
}
|
|
492
570
|
declare class TestStoreProvider<T = never> implements IStoreProvider<T> {
|
|
493
571
|
protected data: Map<string, Map<string, any>>;
|
|
494
|
-
protected getOrCreateArray(name: string): Map<string,
|
|
495
|
-
protected extractKey(value: any): string;
|
|
572
|
+
protected getOrCreateArray(name: string): Map<string, T>;
|
|
573
|
+
protected extractKey(value: any, create?: boolean): string;
|
|
496
574
|
storeEntity(name: string, entity: T): Promise<T>;
|
|
497
575
|
safeLoadEntity(name: string, key: any): Promise<T>;
|
|
498
576
|
loadEntity(name: string, key: any): Promise<T | undefined>;
|
|
@@ -510,5 +588,5 @@ declare class TestDocumentInfo implements IDocumentInfo {
|
|
|
510
588
|
constructor(documentName: string, isUrl: boolean, documentId?: string);
|
|
511
589
|
}
|
|
512
590
|
|
|
513
|
-
export { HostTestFormComponent, HostTestSimpleComponent, HostTestTypedComponent, HostTestTypedFormComponent,
|
|
514
|
-
export type { IDataTransformer, IDocumentInfo, IStoreManager, IStoreProvider, XtComponent, XtComponentInfo, XtComponentInput, XtComponentOutput, XtContext, XtDisplayMode, XtInputType, XtOutputType, XtPluginInfo, XtResolver, XtTypeHandlerInfo };
|
|
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 };
|