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
package/index.d.ts
CHANGED
|
@@ -1,5 +1,592 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { Signal, WritableSignal, InputSignal, OutputEmitterRef, Type, InjectionToken, AfterViewInit, OnInit } from '@angular/core';
|
|
3
|
+
import { FormGroup, AbstractControl, FormBuilder } from '@angular/forms';
|
|
4
|
+
import { XtTypeInfo, XtTypeResolver, XtTypeHandler, MappingHelper } from 'xt-type';
|
|
5
|
+
import * as xt_components from 'xt-components';
|
|
6
|
+
import { NgComponentOutlet } from '@angular/common';
|
|
7
|
+
import { Observable } from 'rxjs';
|
|
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
|
+
|
|
1
47
|
/**
|
|
2
|
-
*
|
|
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
|
|
49
|
+
* - The display mode - View, Inline view or Edit
|
|
50
|
+
* - The value, either directly as a signal or in a formgroup when editing.
|
|
51
|
+
* - The valueType, necessary to find the right ng-extended component to display
|
|
52
|
+
*
|
|
53
|
+
* To do this, it maintains a hierarchy of context and subContexts by name.
|
|
3
54
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
55
|
+
type XtContext<T> = {
|
|
56
|
+
displayMode: XtDisplayMode;
|
|
57
|
+
subName?: string;
|
|
58
|
+
parentFormGroup?: FormGroup;
|
|
59
|
+
localFormGroup?: FormGroup;
|
|
60
|
+
parentContext?: XtContext<any>;
|
|
61
|
+
isInForm(): boolean;
|
|
62
|
+
formGroup(): FormGroup | undefined;
|
|
63
|
+
formControlNameOrNull(): string | null;
|
|
64
|
+
formControlValue(): any | null;
|
|
65
|
+
subValue(subName?: string): T | null | undefined;
|
|
66
|
+
subContext(subName: string | undefined | null, subType?: string, typeResolver?: XtTypeResolver | null): XtContext<any>;
|
|
67
|
+
elementSetContext(subElement: any): XtContext<any>;
|
|
68
|
+
displayValue: Signal<T | null>;
|
|
69
|
+
setDisplayValue(newValue: T | null | undefined, type?: string): XtContext<T>;
|
|
70
|
+
setFormValue(newValue: T | null | undefined, markAsDirty?: boolean): boolean;
|
|
71
|
+
value(): T | null | undefined;
|
|
72
|
+
valueType?: string;
|
|
73
|
+
toString(): string;
|
|
74
|
+
listActions: WritableSignal<XtAction<T>[] | null>;
|
|
75
|
+
};
|
|
76
|
+
type XtDisplayMode = 'INLINE_VIEW' | 'FULL_VIEW' | 'FULL_EDITABLE' | 'LIST_VIEW';
|
|
77
|
+
declare class XtBaseContext<T> implements XtContext<T> {
|
|
78
|
+
displayMode: XtDisplayMode;
|
|
79
|
+
/**
|
|
80
|
+
* When editable, the value is stored in a parent formGroup
|
|
81
|
+
*/
|
|
82
|
+
subName?: string;
|
|
83
|
+
parentFormGroup?: FormGroup<any>;
|
|
84
|
+
/**
|
|
85
|
+
* When the context is a child, it potentially needs to update its parent value
|
|
86
|
+
*/
|
|
87
|
+
parentContext?: XtBaseContext<any>;
|
|
88
|
+
/**
|
|
89
|
+
* All child contexts are kept in this map
|
|
90
|
+
*/
|
|
91
|
+
protected childContexts?: Map<string, XtBaseContext<any>>;
|
|
92
|
+
/**
|
|
93
|
+
* localFormGroup exists only for composite components: it's children are all gathered in a form group
|
|
94
|
+
*/
|
|
95
|
+
localFormGroup?: FormGroup<any>;
|
|
96
|
+
/**
|
|
97
|
+
* When not managed by a form, the value is here
|
|
98
|
+
*/
|
|
99
|
+
nonFormValue?: WritableSignal<T | null>;
|
|
100
|
+
valueType?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Keeps track of all the possible actions for this context
|
|
103
|
+
* @protected
|
|
104
|
+
*/
|
|
105
|
+
listActions: WritableSignal<XtAction<T>[] | null>;
|
|
106
|
+
/**
|
|
107
|
+
*
|
|
108
|
+
* @param displayMode
|
|
109
|
+
* @param readOnly
|
|
110
|
+
* @param parentGroup
|
|
111
|
+
* @param controlName
|
|
112
|
+
*/
|
|
113
|
+
constructor(displayMode: XtDisplayMode, subName?: string, parentGroup?: FormGroup, parentContext?: XtBaseContext<any>);
|
|
114
|
+
setDisplayValue(newValue: T | null | undefined, type?: string, updateParent?: boolean): XtBaseContext<T>;
|
|
115
|
+
displayValue: Signal<T | null>;
|
|
116
|
+
isInForm(): boolean;
|
|
117
|
+
formControlNameOrNull(): string | null;
|
|
118
|
+
value(): T | null | undefined;
|
|
119
|
+
subValue(subsubName?: string): any | null | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* Enable child contexts to update its own value in the parent context whenever it's value changes
|
|
122
|
+
*/
|
|
123
|
+
protected updateSubDisplayValue(subName: string, subValue: any): void;
|
|
124
|
+
formControlValue(): T | null | undefined;
|
|
125
|
+
setFormValue(newValue: T | null | undefined, markAsDirty?: boolean): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Returns the context associated with a specific element in a set.
|
|
128
|
+
* Value must be an array.
|
|
129
|
+
* @param elementIndex
|
|
130
|
+
*/
|
|
131
|
+
elementSetContext(elementIndex: number): XtContext<any>;
|
|
132
|
+
subContext(subName: string | undefined | null, subType?: string, typeResolver?: XtTypeResolver | null): XtContext<any>;
|
|
133
|
+
formGroup(): FormGroup | undefined;
|
|
134
|
+
toString(): string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type XtComponent<T = any> = {
|
|
138
|
+
context: InputSignal<XtContext<T>>;
|
|
139
|
+
inputsObject?: XtComponentInput;
|
|
140
|
+
outputsObject?: XtComponentOutput;
|
|
141
|
+
inputs?: InputSignal<XtComponentInput>;
|
|
142
|
+
outputs?: OutputEmitterRef<XtComponentOutput>;
|
|
143
|
+
isInForm(): boolean;
|
|
144
|
+
formControlName(): string | undefined;
|
|
145
|
+
formGroup(): FormGroup;
|
|
146
|
+
formGroupIfAny(): FormGroup | undefined;
|
|
147
|
+
};
|
|
148
|
+
type XtOutputType = 'valueSelected';
|
|
149
|
+
type XtInputType = 'valueSelected';
|
|
150
|
+
type XtComponentOutput = {
|
|
151
|
+
[key in XtOutputType]: OutputEmitterRef<any> | undefined;
|
|
152
|
+
};
|
|
153
|
+
type XtComponentInput = {
|
|
154
|
+
[key in XtInputType]: InputSignal<any> | undefined;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
declare class XtResolvedComponent {
|
|
158
|
+
componentName: string;
|
|
159
|
+
componentClass: any;
|
|
160
|
+
outputs: boolean;
|
|
161
|
+
constructor(componantName: string, componentClass: any, outputs?: boolean);
|
|
162
|
+
static from(info: XtComponentInfo<any>): XtResolvedComponent;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
type XtResolver = {
|
|
166
|
+
resolve<T>(baseContext: XtContext<T>, subName?: string): XtResolvedComponent | null;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
declare class XtPluginRegistry {
|
|
170
|
+
pluginRegistry: Map<string, XtPluginInfo>;
|
|
171
|
+
componentRegistry: Map<string, XtComponentInfo<any>>;
|
|
172
|
+
componentByTypeCache: Map<string, XtComponentInfo<any>[]>;
|
|
173
|
+
protected actionByTypeRegistry: Map<string, Map<string, XtActionInfo<any>>>;
|
|
174
|
+
listComponents: _angular_core.WritableSignal<XtComponentInfo<any>[]>;
|
|
175
|
+
listPlugins: _angular_core.WritableSignal<XtPluginInfo[]>;
|
|
176
|
+
/**
|
|
177
|
+
* The component can manage any standard javascript primitives types. That's usually the default whenever we don't know any particular type
|
|
178
|
+
* string
|
|
179
|
+
* number
|
|
180
|
+
* bigint
|
|
181
|
+
* boolean
|
|
182
|
+
* undefined
|
|
183
|
+
* null
|
|
184
|
+
* symbol is not managed
|
|
185
|
+
* Date, while an object and not a primitive, is managed
|
|
186
|
+
*/
|
|
187
|
+
static readonly ANY_PRIMITIVE_TYPE = "ANY_PRIMITIVE_TYPE";
|
|
188
|
+
/**
|
|
189
|
+
* The components can manage any composite javascript type. Default when no type has been defined and it's a user defined javascript object (not a data type)
|
|
190
|
+
*/
|
|
191
|
+
static readonly ANY_OBJECT_TYPE = "ANY_OBJECT_TYPE";
|
|
192
|
+
static readonly ANY_PRIMITIVE_SET = "ANY_PRIMITIVE_SET";
|
|
193
|
+
static readonly ANY_OBJECT_SET = "ANY_OBJECT_SET";
|
|
194
|
+
registerPlugin(info: XtPluginInfo): void;
|
|
195
|
+
registerComponent<T>(info: XtComponentInfo<T>): void;
|
|
196
|
+
findComponentsForType<T>(valueType: string | null | undefined, value?: T): XtComponentInfo<any>[];
|
|
197
|
+
static registry(): XtPluginRegistry;
|
|
198
|
+
findComponentInfo(type: Type<XtComponent<any>>): XtComponentInfo<any> | null;
|
|
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
|
+
}[];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* An all in one helper class, enabling manipulation of the context, with data and type associated with it.
|
|
210
|
+
*/
|
|
211
|
+
declare class XtResolverService {
|
|
212
|
+
pluginRegistry: xt_components.XtPluginRegistry;
|
|
213
|
+
protected baseResolver: XtResolver | null;
|
|
214
|
+
protected baseTypeResolver: XtTypeResolver | null;
|
|
215
|
+
resolver: XtResolver;
|
|
216
|
+
typeResolver: XtTypeResolver;
|
|
217
|
+
constructor();
|
|
218
|
+
findBestComponent<T>(baseContext: XtContext<T>, subName?: string): XtResolvedComponent;
|
|
219
|
+
findTypeOf<T>(baseContext: XtContext<T>, subName?: string, value?: T): string | null | undefined;
|
|
220
|
+
findTypeHandlerOf<T>(baseContext: XtContext<T>, subName?: string, value?: T): {
|
|
221
|
+
typeName?: string | null;
|
|
222
|
+
handler?: XtTypeHandler<any>;
|
|
223
|
+
};
|
|
224
|
+
listSubNamesOf<T>(baseContext: XtContext<T>, value?: T): string[];
|
|
225
|
+
listSubNamesOfType<T>(valueType: string, value?: T): string[];
|
|
226
|
+
registerPlugin(info: XtPluginInfo): void;
|
|
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>>;
|
|
240
|
+
protected handlerDefinedFor(newType: string, handlers: XtTypeHandlerInfo<any>[] | undefined): any;
|
|
241
|
+
getComponentInfo<T>(type: Type<XtComponent<T>>): XtResolvedComponent;
|
|
242
|
+
findComponentInfo<T>(type: Type<XtComponent<T>>): XtResolvedComponent | null;
|
|
243
|
+
listComponents: _angular_core.Signal<XtComponentInfo<any>[]>;
|
|
244
|
+
listPlugins: _angular_core.Signal<XtPluginInfo[]>;
|
|
245
|
+
/**
|
|
246
|
+
* Dynamically load a register a plugin from the given url
|
|
247
|
+
* The plugin must export at least a Register entrypoint that will be called right after loading..
|
|
248
|
+
* @param url
|
|
249
|
+
* @returns a Promise with the module loaded and already registered.
|
|
250
|
+
*/
|
|
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;
|
|
266
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtResolverService, never>;
|
|
267
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<XtResolverService>;
|
|
268
|
+
}
|
|
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
|
+
|
|
301
|
+
declare class XtBaseOutput implements XtComponentOutput {
|
|
302
|
+
valueSelected: OutputEmitterRef<any> | undefined;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
declare class XtBaseInput implements XtComponentInput {
|
|
306
|
+
valueSelected: InputSignal<any> | undefined;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Offers a nice and easy to dynamically embed a component.
|
|
311
|
+
* You set the type, the display mode, and either the value or the formgroup & subName to use.
|
|
312
|
+
* XtRender will then instantiate the component, bind it to the value or form, and display it.
|
|
313
|
+
*/
|
|
314
|
+
declare class XtRenderComponent<T> implements AfterViewInit {
|
|
315
|
+
resolverService: XtResolverService;
|
|
316
|
+
componentType: _angular_core.InputSignal<Type<XtComponent<T>> | undefined>;
|
|
317
|
+
displayMode: _angular_core.InputSignal<XtDisplayMode>;
|
|
318
|
+
valueType: _angular_core.InputSignal<string | undefined>;
|
|
319
|
+
value: _angular_core.ModelSignal<T | undefined>;
|
|
320
|
+
formGroup: _angular_core.InputSignal<FormGroup<any> | undefined>;
|
|
321
|
+
subName: _angular_core.InputSignal<string | undefined>;
|
|
322
|
+
outputsObject: XtBaseOutput;
|
|
323
|
+
inputs: _angular_core.InputSignal<XtBaseInput | undefined>;
|
|
324
|
+
outputs: _angular_core.OutputEmitterRef<XtComponentOutput>;
|
|
325
|
+
outlet: Signal<NgComponentOutlet<any>>;
|
|
326
|
+
constructor();
|
|
327
|
+
context: Signal<XtContext<any>>;
|
|
328
|
+
type: Signal<Type<XtComponent<T>> | null>;
|
|
329
|
+
/**
|
|
330
|
+
* Transfers the input and outputs from the host to the rendered component
|
|
331
|
+
*/
|
|
332
|
+
ngAfterViewInit(): void;
|
|
333
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtRenderComponent<any>, never>;
|
|
334
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<XtRenderComponent<any>, "xt-render", never, { "componentType": { "alias": "componentType"; "required": false; "isSignal": true; }; "displayMode": { "alias": "displayMode"; "required": true; "isSignal": true; }; "valueType": { "alias": "valueType"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "formGroup": { "alias": "formGroup"; "required": false; "isSignal": true; }; "subName": { "alias": "subName"; "required": false; "isSignal": true; }; "inputs": { "alias": "inputs"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "outputs": "outputs"; }, never, never, true, never>;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Dynamically render a component that will display the given subValue.
|
|
339
|
+
* To be used only inside an XtSimpleComponent or XtCompositeComponent
|
|
340
|
+
*/
|
|
341
|
+
declare class XtRenderSubComponent<T> implements AfterViewInit {
|
|
342
|
+
context: _angular_core.InputSignal<XtContext<T>>;
|
|
343
|
+
componentType: _angular_core.InputSignal<Type<XtComponent<T>> | undefined>;
|
|
344
|
+
outputsObject: XtBaseOutput;
|
|
345
|
+
inputs: _angular_core.InputSignal<XtBaseInput | undefined>;
|
|
346
|
+
outputs: _angular_core.OutputEmitterRef<XtComponentOutput>;
|
|
347
|
+
outlet: Signal<NgComponentOutlet<any>>;
|
|
348
|
+
resolverService: XtResolverService;
|
|
349
|
+
type: Signal<Type<XtComponent<T>> | null>;
|
|
350
|
+
/**
|
|
351
|
+
* Transfers the input and outputs from the host to the rendered component
|
|
352
|
+
*/
|
|
353
|
+
ngAfterViewInit(): void;
|
|
354
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtRenderSubComponent<any>, never>;
|
|
355
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<XtRenderSubComponent<any>, "xt-render-sub", never, { "context": { "alias": "context"; "required": true; "isSignal": true; }; "componentType": { "alias": "componentType"; "required": false; "isSignal": true; }; "inputs": { "alias": "inputs"; "required": false; "isSignal": true; }; }, { "outputs": "outputs"; }, never, never, true, never>;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* An XtSimpleComponent just displays the given value or element in a form.
|
|
360
|
+
* If you need to dynamically embed other XtComponents to display sub elements, then please use the XtCompositeComponent
|
|
361
|
+
*/
|
|
362
|
+
declare class XtSimpleComponent<T = any> implements XtComponent<T>, OnInit {
|
|
363
|
+
context: _angular_core.InputSignal<XtContext<T>>;
|
|
364
|
+
outputsObject: XtBaseOutput;
|
|
365
|
+
inputsObject: XtBaseInput;
|
|
366
|
+
outputs: _angular_core.OutputEmitterRef<XtComponentOutput>;
|
|
367
|
+
isInForm: _angular_core.Signal<boolean>;
|
|
368
|
+
formControlNameIfAny: _angular_core.Signal<string | undefined>;
|
|
369
|
+
formGroupIfAny: _angular_core.Signal<FormGroup<any> | undefined>;
|
|
370
|
+
formGroup: _angular_core.Signal<FormGroup<any>>;
|
|
371
|
+
/**
|
|
372
|
+
* Returns the component form name, which is for now the subName
|
|
373
|
+
*/
|
|
374
|
+
componentNameInForm: _angular_core.Signal<string>;
|
|
375
|
+
constructor();
|
|
376
|
+
ngOnInit(): void;
|
|
377
|
+
manageFormControl<T>(ctrlName: string, create?: boolean): AbstractControl<T> | undefined;
|
|
378
|
+
safelyGetSubName: _angular_core.Signal<string>;
|
|
379
|
+
/**
|
|
380
|
+
* Returns the form control name and create a form control behind the scene
|
|
381
|
+
*/
|
|
382
|
+
formControlName: _angular_core.Signal<string>;
|
|
383
|
+
formControl: _angular_core.Signal<AbstractControl<any, any, any>>;
|
|
384
|
+
componentDescriptor(): string;
|
|
385
|
+
getValue: _angular_core.Signal<T | null | undefined>;
|
|
386
|
+
displayValue: _angular_core.Signal<T | null>;
|
|
387
|
+
/**
|
|
388
|
+
* This is where components can assign their output() and input() into the XtComponent inputs and outputs member
|
|
389
|
+
* @protected
|
|
390
|
+
*/
|
|
391
|
+
protected setupInputOutput(): void;
|
|
392
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtSimpleComponent<any>, never>;
|
|
393
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<XtSimpleComponent<any>, "ng-component", never, { "context": { "alias": "context"; "required": true; "isSignal": true; }; }, { "outputs": "outputs"; }, never, never, true, never>;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
declare class XtCompositeComponent<T = any> extends XtSimpleComponent<T> {
|
|
397
|
+
resolverService: XtResolverService;
|
|
398
|
+
formGroupIfAny: _angular_core.Signal<FormGroup<any> | undefined>;
|
|
399
|
+
/**
|
|
400
|
+
* We need to create a new form group to manage the sub elements.
|
|
401
|
+
*/
|
|
402
|
+
formGroup: _angular_core.Signal<FormGroup<any>>;
|
|
403
|
+
/**
|
|
404
|
+
* Helper function to calculate the sub context
|
|
405
|
+
* @param subName
|
|
406
|
+
* @param subType
|
|
407
|
+
*/
|
|
408
|
+
subContext(subName: string, subType?: string): XtContext<any>;
|
|
409
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtCompositeComponent<any>, never>;
|
|
410
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<XtCompositeComponent<any>, "ng-component", never, {}, {}, never, never, true, never>;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
declare class XtMessageHandler {
|
|
414
|
+
errorOccurred(error: any, errorMsg?: string): void;
|
|
415
|
+
warningOccurred(warningMsg?: string): void;
|
|
416
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtMessageHandler, never>;
|
|
417
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<XtMessageHandler>;
|
|
418
|
+
}
|
|
419
|
+
|
|
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
|
+
declare function attachToFormGroup(formGroup: FormGroup, controlName: string, value: any, valueType?: string, resolver?: XtTypeResolver): void;
|
|
482
|
+
declare function updateFormGroupWithValue(formGroup: FormGroup, value: {
|
|
483
|
+
[key: string]: any;
|
|
484
|
+
}, valueType?: string, resolver?: XtTypeResolver): void;
|
|
485
|
+
|
|
486
|
+
declare class XtUnitTestHelper {
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Component that can be used to bootstrap tests.
|
|
491
|
+
* Just set the value and component type, and it will be injected in your test.
|
|
492
|
+
*/
|
|
493
|
+
declare class HostTestSimpleComponent {
|
|
494
|
+
type: _angular_core.InputSignal<Type<XtComponent<any>>>;
|
|
495
|
+
displayMode: _angular_core.InputSignal<XtDisplayMode>;
|
|
496
|
+
value: _angular_core.InputSignal<any>;
|
|
497
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<HostTestSimpleComponent, never>;
|
|
498
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<HostTestSimpleComponent, "test-host", never, { "type": { "alias": "type"; "required": true; "isSignal": true; }; "displayMode": { "alias": "displayMode"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Same as HostTestSimpleComponent but it includes everything in a form.
|
|
502
|
+
* Just set the component type, the formGroup and the component name, and your component will be run.
|
|
503
|
+
* You can as well easily read and set the value.
|
|
504
|
+
*/
|
|
505
|
+
declare class HostTestFormComponent {
|
|
506
|
+
builder: FormBuilder;
|
|
507
|
+
type: _angular_core.InputSignal<Type<XtComponent<any>>>;
|
|
508
|
+
controlName: _angular_core.InputSignal<string>;
|
|
509
|
+
formDescription: _angular_core.InputSignal<any>;
|
|
510
|
+
formGroup: _angular_core.InputSignal<FormGroup<any> | undefined>;
|
|
511
|
+
createdFormGroup: FormGroup | null;
|
|
512
|
+
computedFormGroup(): FormGroup<any>;
|
|
513
|
+
patchValue(newVal: any): void;
|
|
514
|
+
retrieveValue(): any;
|
|
515
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<HostTestFormComponent, never>;
|
|
516
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<HostTestFormComponent, "test-form-host", never, { "type": { "alias": "type"; "required": true; "isSignal": true; }; "controlName": { "alias": "controlName"; "required": true; "isSignal": true; }; "formDescription": { "alias": "formDescription"; "required": false; "isSignal": true; }; "formGroup": { "alias": "formGroup"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Component that can be used to test your component based on the type it handles
|
|
520
|
+
* Just set the type hierarchy to register, the value, and it will instantiate the right component in your plugin
|
|
521
|
+
*/
|
|
522
|
+
declare class HostTestTypedComponent {
|
|
523
|
+
displayMode: _angular_core.InputSignal<XtDisplayMode>;
|
|
524
|
+
value: _angular_core.InputSignal<any>;
|
|
525
|
+
valueType: _angular_core.InputSignal<string | undefined>;
|
|
526
|
+
context: _angular_core.Signal<XtBaseContext<unknown>>;
|
|
527
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<HostTestTypedComponent, never>;
|
|
528
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<HostTestTypedComponent, "test-typed-host", never, { "displayMode": { "alias": "displayMode"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "valueType": { "alias": "valueType"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Same as HostTestSimpleComponent but it includes everything in a form.
|
|
532
|
+
* Just set the component type, the formGroup and the component name, and your component will be run.
|
|
533
|
+
* You can as well easily read and set the value.
|
|
534
|
+
*/
|
|
535
|
+
declare class HostTestTypedFormComponent implements OnInit {
|
|
536
|
+
builder: FormBuilder;
|
|
537
|
+
resolver: XtResolverService;
|
|
538
|
+
static readonly CONTROL_NAME = "ForTest";
|
|
539
|
+
valueType: _angular_core.InputSignal<string | undefined>;
|
|
540
|
+
controlName: _angular_core.InputSignal<string | undefined>;
|
|
541
|
+
formDescription: _angular_core.InputSignal<any>;
|
|
542
|
+
formGroup: _angular_core.InputSignal<FormGroup<any> | undefined>;
|
|
543
|
+
parentFormGroup: FormGroup<{
|
|
544
|
+
[x: string]: AbstractControl<any, any, any>;
|
|
545
|
+
}>;
|
|
546
|
+
createdFormGroup: FormGroup | null;
|
|
547
|
+
ngOnInit(): void;
|
|
548
|
+
computeFormGroup(): FormGroup<any>;
|
|
549
|
+
subContext(): XtBaseContext<any>;
|
|
550
|
+
patchValue(controlName: string, newVal: any): void;
|
|
551
|
+
retrieveValue(controlName: string): any;
|
|
552
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<HostTestTypedFormComponent, never>;
|
|
553
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<HostTestTypedFormComponent, "test-typed-form-host", never, { "valueType": { "alias": "valueType"; "required": false; "isSignal": true; }; "controlName": { "alias": "controlName"; "required": false; "isSignal": true; }; "formDescription": { "alias": "formDescription"; "required": false; "isSignal": true; }; "formGroup": { "alias": "formGroup"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* A very light and not 100% compatible storemanager in case you are not using xt-store.
|
|
558
|
+
* It can emulate XtStoreManager to some extends for doing some tests
|
|
559
|
+
*/
|
|
560
|
+
declare class StoreTestHelper {
|
|
561
|
+
static ensureTestProviderOnly(): void;
|
|
562
|
+
}
|
|
563
|
+
declare class TestStoreManager implements IStoreManager {
|
|
564
|
+
protected defaultProvider: TestStoreProvider<never>;
|
|
565
|
+
getProvider<T = never>(name?: string): IStoreProvider<T> | undefined;
|
|
566
|
+
getProviderSafe<T = never>(name?: string): IStoreProvider<T>;
|
|
567
|
+
getDefaultProvider<T = never>(): IStoreProvider<T> | undefined;
|
|
568
|
+
getDefaultProviderSafe<T = never>(): IStoreProvider<T>;
|
|
569
|
+
}
|
|
570
|
+
declare class TestStoreProvider<T = never> implements IStoreProvider<T> {
|
|
571
|
+
protected data: Map<string, Map<string, any>>;
|
|
572
|
+
protected getOrCreateArray(name: string): Map<string, T>;
|
|
573
|
+
protected extractKey(value: any, create?: boolean): string;
|
|
574
|
+
storeEntity(name: string, entity: T): Promise<T>;
|
|
575
|
+
safeLoadEntity(name: string, key: any): Promise<T>;
|
|
576
|
+
loadEntity(name: string, key: any): Promise<T | undefined>;
|
|
577
|
+
deleteEntity(name: string, key: any): Promise<boolean>;
|
|
578
|
+
searchEntities(name: string, ...criteria: any[]): Observable<T[]>;
|
|
579
|
+
searchAndPrepareEntities(name: string, sort?: any, groupBy?: any, transformer?: IDataTransformer<T> | undefined, ...criteria: any[]): Observable<any>;
|
|
580
|
+
canStoreDocument(): boolean;
|
|
581
|
+
storeDocument(toStore: File): Promise<IDocumentInfo>;
|
|
582
|
+
storeDocuments(toStore: File[]): Observable<IDocumentInfo>;
|
|
583
|
+
}
|
|
584
|
+
declare class TestDocumentInfo implements IDocumentInfo {
|
|
585
|
+
documentName: string;
|
|
586
|
+
isUrl: boolean;
|
|
587
|
+
documentId?: string;
|
|
588
|
+
constructor(documentName: string, isUrl: boolean, documentId?: string);
|
|
589
|
+
}
|
|
590
|
+
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xt-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@angular/animations": "^
|
|
6
|
-
"@angular/common": "^
|
|
7
|
-
"@angular/compiler": "^
|
|
8
|
-
"@angular/core": "^
|
|
9
|
-
"@angular/forms": "^
|
|
10
|
-
"@angular/platform-browser": "^
|
|
11
|
-
"@angular/platform-browser-dynamic": "^
|
|
12
|
-
"@angular/router": "
|
|
13
|
-
"rxjs": "~7.8.
|
|
14
|
-
"primeng": "
|
|
15
|
-
"primeicons": "
|
|
5
|
+
"@angular/animations": "^20.2.3",
|
|
6
|
+
"@angular/common": "^20.2.3",
|
|
7
|
+
"@angular/compiler": "^20.2.3",
|
|
8
|
+
"@angular/core": "^20.2.3",
|
|
9
|
+
"@angular/forms": "^20.2.3",
|
|
10
|
+
"@angular/platform-browser": "^20.2.3",
|
|
11
|
+
"@angular/platform-browser-dynamic": "^20.2.3",
|
|
12
|
+
"@angular/router": "^20.2.3",
|
|
13
|
+
"rxjs": "~7.8.2",
|
|
14
|
+
"primeng": "^20.0.1",
|
|
15
|
+
"primeicons": "^7.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"tslib": "^2.
|
|
18
|
+
"tslib": "^2.8.1"
|
|
19
19
|
},
|
|
20
20
|
"module": "fesm2022/xt-components.mjs",
|
|
21
21
|
"typings": "index.d.ts",
|
package/globals.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The global plugin registry.
|
|
3
|
-
* Plugins will register to this when loaded.
|
|
4
|
-
*/
|
|
5
|
-
import { XtPluginRegistry } from './lib/registry/xt-plugin-registry';
|
|
6
|
-
declare global {
|
|
7
|
-
var XT_REGISTRY: XtPluginRegistry;
|
|
8
|
-
}
|
|
9
|
-
export declare function initXtPluginRegistry(): void;
|
|
10
|
-
export declare function xtPluginRegistry(): XtPluginRegistry;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
export declare class MessageHandler {
|
|
3
|
-
errorOccurred(error: any, errorMsg?: string): void;
|
|
4
|
-
warningOccurred(warningMsg?: string): void;
|
|
5
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<MessageHandler, never>;
|
|
6
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<MessageHandler>;
|
|
7
|
-
}
|