xt-components 0.4.7 → 0.5.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/index.d.ts CHANGED
@@ -1,5 +1,514 @@
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 { XtTypeResolver, XtTypeInfo, XtTypeHandler } from 'xt-type';
5
+ import * as xt_components from 'xt-components';
6
+ import { NgComponentOutlet } from '@angular/common';
7
+ import { Observable } from 'rxjs';
8
+
1
9
  /**
2
- * Generated bundle index. Do not edit.
10
+ * 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
+ * - The display mode - View, Inline view or Edit
12
+ * - The value, either directly as a signal or in a formgroup when editing.
13
+ * - The valueType, necessary to find the right ng-extended component to display
14
+ *
15
+ * To do this, it maintains a hierarchy of context and subContexts by name.
3
16
  */
4
- /// <amd-module name="xt-components" />
5
- export * from './public-api';
17
+ type XtContext<T> = {
18
+ displayMode: XtDisplayMode;
19
+ subName?: string;
20
+ parentFormGroup?: FormGroup;
21
+ localFormGroup?: FormGroup;
22
+ parentContext?: XtContext<any>;
23
+ isInForm(): boolean;
24
+ formGroup(): FormGroup | undefined;
25
+ formControlNameOrNull(): string | null;
26
+ formControlValue(): any | null;
27
+ subValue(subName?: string): T | null | undefined;
28
+ subContext(subName: string | undefined | null, subType?: string, typeResolver?: XtTypeResolver | null): XtContext<any>;
29
+ elementSetContext(subElement: any): XtContext<any>;
30
+ displayValue: Signal<T | null>;
31
+ setDisplayValue(newValue: T | null | undefined, type?: string): XtContext<T>;
32
+ setFormValue(newValue: T | null | undefined, markAsDirty?: boolean): boolean;
33
+ value(): T | null | undefined;
34
+ valueType?: string;
35
+ toString(): string;
36
+ };
37
+ type XtDisplayMode = 'INLINE_VIEW' | 'FULL_VIEW' | 'FULL_EDITABLE' | 'LIST_VIEW';
38
+ declare class XtBaseContext<T> implements XtContext<T> {
39
+ displayMode: XtDisplayMode;
40
+ /**
41
+ * When editable, the value is stored in a parent formGroup
42
+ */
43
+ subName?: string;
44
+ parentFormGroup?: FormGroup<any>;
45
+ /**
46
+ * When the context is a child, it potentially needs to update its parent value
47
+ */
48
+ parentContext?: XtBaseContext<any>;
49
+ /**
50
+ * All child contexts are kept in this map
51
+ */
52
+ protected childContexts?: Map<string, XtBaseContext<any>>;
53
+ /**
54
+ * localFormGroup exists only for composite components: it's children are all gathered in a form group
55
+ */
56
+ localFormGroup?: FormGroup<any>;
57
+ /**
58
+ * When not managed by a form, the value is here
59
+ */
60
+ nonFormValue?: WritableSignal<T | null>;
61
+ valueType?: string;
62
+ /**
63
+ *
64
+ * @param displayMode
65
+ * @param readOnly
66
+ * @param parentGroup
67
+ * @param controlName
68
+ */
69
+ constructor(displayMode: XtDisplayMode, subName?: string, parentGroup?: FormGroup, parentContext?: XtBaseContext<any>);
70
+ setDisplayValue(newValue: T | null | undefined, type?: string, updateParent?: boolean): XtBaseContext<T>;
71
+ displayValue: Signal<T | null>;
72
+ isInForm(): boolean;
73
+ formControlNameOrNull(): string | null;
74
+ value(): T | null | undefined;
75
+ subValue(subsubName?: string): any | null | undefined;
76
+ /**
77
+ * Enable child contexts to update its own value in the parent context whenever it's value changes
78
+ */
79
+ protected updateSubDisplayValue(subName: string, subValue: any): void;
80
+ formControlValue(): T | null | undefined;
81
+ setFormValue(newValue: T | null | undefined, markAsDirty?: boolean): boolean;
82
+ /**
83
+ * Returns the context associated with a specific element in a set.
84
+ * Value must be an array.
85
+ * @param elementIndex
86
+ */
87
+ elementSetContext(elementIndex: number): XtContext<any>;
88
+ subContext(subName: string | undefined | null, subType?: string, typeResolver?: XtTypeResolver | null): XtContext<any>;
89
+ formGroup(): FormGroup | undefined;
90
+ toString(): string;
91
+ }
92
+
93
+ type XtComponent<T = any> = {
94
+ context: InputSignal<XtContext<T>>;
95
+ inputsObject?: XtComponentInput;
96
+ outputsObject?: XtComponentOutput;
97
+ inputs?: InputSignal<XtComponentInput>;
98
+ outputs?: OutputEmitterRef<XtComponentOutput>;
99
+ isInForm(): boolean;
100
+ formControlName(): string | undefined;
101
+ formGroup(): FormGroup;
102
+ formGroupIfAny(): FormGroup | undefined;
103
+ };
104
+ type XtOutputType = 'valueSelected';
105
+ type XtInputType = 'valueSelected';
106
+ type XtComponentOutput = {
107
+ [key in XtOutputType]: OutputEmitterRef<any> | undefined;
108
+ };
109
+ type XtComponentInput = {
110
+ [key in XtInputType]: InputSignal<any> | undefined;
111
+ };
112
+
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
+ declare class XtResolvedComponent {
132
+ componentName: string;
133
+ componentClass: any;
134
+ outputs: boolean;
135
+ constructor(componantName: string, componentClass: any, outputs?: boolean);
136
+ static from(info: XtComponentInfo<any>): XtResolvedComponent;
137
+ }
138
+
139
+ type XtResolver = {
140
+ resolve<T>(baseContext: XtContext<T>, subName?: string): XtResolvedComponent | null;
141
+ };
142
+
143
+ declare class XtPluginRegistry {
144
+ pluginRegistry: Map<string, XtPluginInfo>;
145
+ componentRegistry: Map<string, XtComponentInfo<any>>;
146
+ componentByTypeCache: Map<string, XtComponentInfo<any>[]>;
147
+ listComponents: _angular_core.WritableSignal<XtComponentInfo<any>[]>;
148
+ listPlugins: _angular_core.WritableSignal<XtPluginInfo[]>;
149
+ /**
150
+ * The component can manage any standard javascript primitives types. That's usually the default whenever we don't know any particular type
151
+ * string
152
+ * number
153
+ * bigint
154
+ * boolean
155
+ * undefined
156
+ * null
157
+ * symbol is not managed
158
+ * Date, while an object and not a primitive, is managed
159
+ */
160
+ static readonly ANY_PRIMITIVE_TYPE = "ANY_PRIMITIVE_TYPE";
161
+ /**
162
+ * 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)
163
+ */
164
+ static readonly ANY_OBJECT_TYPE = "ANY_OBJECT_TYPE";
165
+ static readonly ANY_PRIMITIVE_SET = "ANY_PRIMITIVE_SET";
166
+ static readonly ANY_OBJECT_SET = "ANY_OBJECT_SET";
167
+ registerPlugin(info: XtPluginInfo): void;
168
+ registerComponent<T>(info: XtComponentInfo<T>): void;
169
+ findComponentsForType<T>(valueType: string | null | undefined, value?: T): XtComponentInfo<any>[];
170
+ static registry(): XtPluginRegistry;
171
+ findComponentInfo(type: Type<XtComponent<any>>): XtComponentInfo<any> | null;
172
+ getComponentInfo(type: Type<XtComponent<any>>): XtComponentInfo<any>;
173
+ }
174
+
175
+ /**
176
+ * The global plugin registry.
177
+ * Plugins will register to this when loaded.
178
+ */
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
+ declare class XtResolverService {
191
+ pluginRegistry: xt_components.XtPluginRegistry;
192
+ protected baseResolver: XtResolver | null;
193
+ protected baseTypeResolver: XtTypeResolver | null;
194
+ resolver: XtResolver;
195
+ typeResolver: XtTypeResolver;
196
+ constructor();
197
+ findBestComponent<T>(baseContext: XtContext<T>, subName?: string): XtResolvedComponent;
198
+ findTypeOf<T>(baseContext: XtContext<T>, subName?: string, value?: T): string | null | undefined;
199
+ findTypeHandlerOf<T>(baseContext: XtContext<T>, subName?: string, value?: T): {
200
+ typeName?: string | null;
201
+ handler?: XtTypeHandler<any>;
202
+ };
203
+ listSubNamesOf<T>(baseContext: XtContext<T>, value?: T): string[];
204
+ listSubNamesOfType<T>(valueType: string, value?: T): string[];
205
+ registerPlugin(info: XtPluginInfo): void;
206
+ registerTypes(types: XtTypeInfo | undefined, handlers?: XtTypeHandlerInfo<any>[]): void;
207
+ protected handlerDefinedFor(newType: string, handlers: XtTypeHandlerInfo<any>[] | undefined): any;
208
+ getComponentInfo<T>(type: Type<XtComponent<T>>): XtResolvedComponent;
209
+ findComponentInfo<T>(type: Type<XtComponent<T>>): XtResolvedComponent | null;
210
+ listComponents: _angular_core.Signal<XtComponentInfo<any>[]>;
211
+ listPlugins: _angular_core.Signal<XtPluginInfo[]>;
212
+ /**
213
+ * Dynamically load a register a plugin from the given url
214
+ * The plugin must export at least a Register entrypoint that will be called right after loading..
215
+ * @param url
216
+ * @returns a Promise with the module loaded and already registered.
217
+ */
218
+ loadPlugin(url: URL | string): Promise<any>;
219
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtResolverService, never>;
220
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<XtResolverService>;
221
+ }
222
+
223
+ declare class XtBaseOutput implements XtComponentOutput {
224
+ valueSelected: OutputEmitterRef<any> | undefined;
225
+ }
226
+
227
+ declare class XtBaseInput implements XtComponentInput {
228
+ valueSelected: InputSignal<any> | undefined;
229
+ }
230
+
231
+ /**
232
+ * Offers a nice and easy to dynamically embed a component.
233
+ * You set the type, the display mode, and either the value or the formgroup & subName to use.
234
+ * XtRender will then instantiate the component, bind it to the value or form, and display it.
235
+ */
236
+ declare class XtRenderComponent<T> implements AfterViewInit {
237
+ resolverService: XtResolverService;
238
+ componentType: _angular_core.InputSignal<Type<XtComponent<T>> | undefined>;
239
+ displayMode: _angular_core.InputSignal<XtDisplayMode>;
240
+ valueType: _angular_core.InputSignal<string | undefined>;
241
+ value: _angular_core.ModelSignal<T | undefined>;
242
+ formGroup: _angular_core.InputSignal<FormGroup<any> | undefined>;
243
+ subName: _angular_core.InputSignal<string | undefined>;
244
+ outputsObject: XtBaseOutput;
245
+ inputs: _angular_core.InputSignal<XtBaseInput | undefined>;
246
+ outputs: _angular_core.OutputEmitterRef<XtComponentOutput>;
247
+ outlet: Signal<NgComponentOutlet<any>>;
248
+ constructor();
249
+ context: Signal<XtContext<any>>;
250
+ type: Signal<Type<XtComponent<T>> | null>;
251
+ /**
252
+ * Transfers the input and outputs from the host to the rendered component
253
+ */
254
+ ngAfterViewInit(): void;
255
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtRenderComponent<any>, never>;
256
+ 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>;
257
+ }
258
+
259
+ /**
260
+ * Dynamically render a component that will display the given subValue.
261
+ * To be used only inside an XtSimpleComponent or XtCompositeComponent
262
+ */
263
+ declare class XtRenderSubComponent<T> implements AfterViewInit {
264
+ context: _angular_core.InputSignal<XtContext<T>>;
265
+ componentType: _angular_core.InputSignal<Type<XtComponent<T>> | undefined>;
266
+ outputsObject: XtBaseOutput;
267
+ inputs: _angular_core.InputSignal<XtBaseInput | undefined>;
268
+ outputs: _angular_core.OutputEmitterRef<XtComponentOutput>;
269
+ outlet: Signal<NgComponentOutlet<any>>;
270
+ resolverService: XtResolverService;
271
+ type: Signal<Type<XtComponent<T>> | null>;
272
+ /**
273
+ * Transfers the input and outputs from the host to the rendered component
274
+ */
275
+ ngAfterViewInit(): void;
276
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtRenderSubComponent<any>, never>;
277
+ 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>;
278
+ }
279
+
280
+ /**
281
+ * An XtSimpleComponent just displays the given value or element in a form.
282
+ * If you need to dynamically embed other XtComponents to display sub elements, then please use the XtCompositeComponent
283
+ */
284
+ declare class XtSimpleComponent<T = any> implements XtComponent<T>, OnInit {
285
+ context: _angular_core.InputSignal<XtContext<T>>;
286
+ outputsObject: XtBaseOutput;
287
+ inputsObject: XtBaseInput;
288
+ outputs: _angular_core.OutputEmitterRef<XtComponentOutput>;
289
+ isInForm: _angular_core.Signal<boolean>;
290
+ formControlNameIfAny: _angular_core.Signal<string | undefined>;
291
+ formGroupIfAny: _angular_core.Signal<FormGroup<any> | undefined>;
292
+ formGroup: _angular_core.Signal<FormGroup<any>>;
293
+ /**
294
+ * Returns the component form name, which is for now the subName
295
+ */
296
+ componentNameInForm: _angular_core.Signal<string>;
297
+ constructor();
298
+ ngOnInit(): void;
299
+ manageFormControl<T>(ctrlName: string, create?: boolean): AbstractControl<T> | undefined;
300
+ safelyGetSubName: _angular_core.Signal<string>;
301
+ /**
302
+ * Returns the form control name and create a form control behind the scene
303
+ */
304
+ formControlName: _angular_core.Signal<string>;
305
+ formControl: _angular_core.Signal<AbstractControl<any, any, any>>;
306
+ componentDescriptor(): string;
307
+ getValue: _angular_core.Signal<T | null | undefined>;
308
+ displayValue: _angular_core.Signal<T | null>;
309
+ /**
310
+ * This is where components can assign their output() and input() into the XtComponent inputs and outputs member
311
+ * @protected
312
+ */
313
+ protected setupInputOutput(): void;
314
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtSimpleComponent<any>, never>;
315
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<XtSimpleComponent<any>, "ng-component", never, { "context": { "alias": "context"; "required": true; "isSignal": true; }; }, { "outputs": "outputs"; }, never, never, true, never>;
316
+ }
317
+
318
+ declare class XtCompositeComponent<T = any> extends XtSimpleComponent<T> {
319
+ resolverService: XtResolverService;
320
+ formGroupIfAny: _angular_core.Signal<FormGroup<any> | undefined>;
321
+ /**
322
+ * We need to create a new form group to manage the sub elements.
323
+ */
324
+ formGroup: _angular_core.Signal<FormGroup<any>>;
325
+ /**
326
+ * Helper function to calculate the sub context
327
+ * @param subName
328
+ * @param subType
329
+ */
330
+ subContext(subName: string, subType?: string): XtContext<any>;
331
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<XtCompositeComponent<any>, never>;
332
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<XtCompositeComponent<any>, "ng-component", never, {}, {}, never, never, true, never>;
333
+ }
334
+
335
+ declare class MessageHandler {
336
+ errorOccurred(error: any, errorMsg?: string): void;
337
+ warningOccurred(warningMsg?: string): void;
338
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<MessageHandler, never>;
339
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<MessageHandler>;
340
+ }
341
+
342
+ /**
343
+ * Wrapper around xt-store manager: You can use it to check if xt-store is included or not, and decide what to do
344
+ *
345
+ * This allow plugins to potentially use xt-store whenever included in the applications running the plugin
346
+ */
347
+
348
+ declare class StoreSupport {
349
+ protected static testStoreManager?: IStoreManager;
350
+ static isStoreManagerAvailable(): boolean;
351
+ static getStoreManager(): IStoreManager;
352
+ static setTestStoreManager(testStoreManager: IStoreManager): void;
353
+ }
354
+ /**
355
+ * Interface definition for xt-store component.
356
+ * We re-define them here to avoid importing xt-store in all plugins that don't need it.
357
+ */
358
+ interface IDataTransformer<T> {
359
+ /**
360
+ * Enable transformation of data right after it has been loaded from the store
361
+ * @param source
362
+ */
363
+ postLoadingTransformation(source: any[]): T[];
364
+ }
365
+ interface IDocumentInfo {
366
+ documentName: string;
367
+ isUrl: boolean;
368
+ documentId?: string;
369
+ }
370
+ interface IStoreProvider<T> {
371
+ storeEntity(name: string, entity: T): Promise<T>;
372
+ /**
373
+ * Rejects the promise if the entity is not found
374
+ * @param name
375
+ * @param key
376
+ */
377
+ safeLoadEntity(name: string, key: any): Promise<T>;
378
+ loadEntity(name: string, key: any): Promise<T | undefined>;
379
+ deleteEntity(name: string, key: any): Promise<boolean>;
380
+ searchEntities(name: string, ...criteria: any[]): Observable<Array<T>>;
381
+ searchAndPrepareEntities(name: string, sort?: any, groupBy?: any, transformer?: IDataTransformer<T>, ...criteria: any[]): Observable<any>;
382
+ canStoreDocument(): boolean;
383
+ /**
384
+ * Upload one document to a server store and returns the url or the id needed to retrieve them.
385
+ * @param toStore
386
+ * @param position
387
+ */
388
+ storeDocument(toStore: File): Promise<IDocumentInfo>;
389
+ /**
390
+ * Upload documents to a server store and returns the url or the id needed to retrieve them.
391
+ * @param toStore
392
+ * @param position
393
+ */
394
+ storeDocuments(toStore: File[]): Observable<IDocumentInfo>;
395
+ }
396
+ interface IStoreManager {
397
+ getProvider<T = never>(name?: string): IStoreProvider<T> | undefined;
398
+ getProviderSafe<T = never>(name?: string): IStoreProvider<T>;
399
+ getDefaultProvider<T = never>(): IStoreProvider<T> | undefined;
400
+ getDefaultProviderSafe<T = never>(): IStoreProvider<T>;
401
+ }
402
+
403
+ declare function attachToFormGroup(formGroup: FormGroup, controlName: string, value: any, valueType?: string, resolver?: XtTypeResolver): void;
404
+ declare function updateFormGroupWithValue(formGroup: FormGroup, value: {
405
+ [key: string]: any;
406
+ }, valueType?: string, resolver?: XtTypeResolver): void;
407
+
408
+ declare class XtUnitTestHelper {
409
+ }
410
+
411
+ /**
412
+ * Component that can be used to bootstrap tests.
413
+ * Just set the value and component type, and it will be injected in your test.
414
+ */
415
+ declare class HostTestSimpleComponent {
416
+ type: _angular_core.InputSignal<Type<XtComponent<any>>>;
417
+ displayMode: _angular_core.InputSignal<XtDisplayMode>;
418
+ value: _angular_core.InputSignal<any>;
419
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<HostTestSimpleComponent, never>;
420
+ 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>;
421
+ }
422
+ /**
423
+ * Same as HostTestSimpleComponent but it includes everything in a form.
424
+ * Just set the component type, the formGroup and the component name, and your component will be run.
425
+ * You can as well easily read and set the value.
426
+ */
427
+ declare class HostTestFormComponent {
428
+ builder: FormBuilder;
429
+ type: _angular_core.InputSignal<Type<XtComponent<any>>>;
430
+ controlName: _angular_core.InputSignal<string>;
431
+ formDescription: _angular_core.InputSignal<any>;
432
+ formGroup: _angular_core.InputSignal<FormGroup<any> | undefined>;
433
+ createdFormGroup: FormGroup | null;
434
+ computedFormGroup(): FormGroup<any>;
435
+ patchValue(newVal: any): void;
436
+ retrieveValue(): any;
437
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<HostTestFormComponent, never>;
438
+ 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>;
439
+ }
440
+ /**
441
+ * Component that can be used to test your component based on the type it handles
442
+ * Just set the type hierarchy to register, the value, and it will instantiate the right component in your plugin
443
+ */
444
+ declare class HostTestTypedComponent {
445
+ displayMode: _angular_core.InputSignal<XtDisplayMode>;
446
+ value: _angular_core.InputSignal<any>;
447
+ valueType: _angular_core.InputSignal<string | undefined>;
448
+ context: _angular_core.Signal<XtBaseContext<unknown>>;
449
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<HostTestTypedComponent, never>;
450
+ 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>;
451
+ }
452
+ /**
453
+ * Same as HostTestSimpleComponent but it includes everything in a form.
454
+ * Just set the component type, the formGroup and the component name, and your component will be run.
455
+ * You can as well easily read and set the value.
456
+ */
457
+ declare class HostTestTypedFormComponent implements OnInit {
458
+ builder: FormBuilder;
459
+ resolver: XtResolverService;
460
+ static readonly CONTROL_NAME = "ForTest";
461
+ valueType: _angular_core.InputSignal<string | undefined>;
462
+ controlName: _angular_core.InputSignal<string | undefined>;
463
+ formDescription: _angular_core.InputSignal<any>;
464
+ formGroup: _angular_core.InputSignal<FormGroup<any> | undefined>;
465
+ parentFormGroup: FormGroup<{
466
+ [x: string]: AbstractControl<any, any, any>;
467
+ }>;
468
+ createdFormGroup: FormGroup | null;
469
+ ngOnInit(): void;
470
+ computeFormGroup(): FormGroup<any>;
471
+ subContext(): XtBaseContext<any>;
472
+ patchValue(controlName: string, newVal: any): void;
473
+ retrieveValue(controlName: string): any;
474
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<HostTestTypedFormComponent, never>;
475
+ 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>;
476
+ }
477
+
478
+ /**
479
+ * A very light and not 100% compatible storemanager in case you are not using xt-store.
480
+ * It can emulate XtStoreManager to some extends for doing some tests
481
+ */
482
+ declare class StoreTestHelper {
483
+ static ensureTestProviderOnly(): void;
484
+ }
485
+ declare class TestStoreManager implements IStoreManager {
486
+ protected defaultProvider: TestStoreProvider<never>;
487
+ getProvider<T = never>(name?: string): IStoreProvider<T> | undefined;
488
+ getProviderSafe<T = never>(name?: string): IStoreProvider<T>;
489
+ getDefaultProvider<T = never>(): IStoreProvider<T> | undefined;
490
+ getDefaultProviderSafe<T = never>(): IStoreProvider<T>;
491
+ }
492
+ declare class TestStoreProvider<T = never> implements IStoreProvider<T> {
493
+ protected data: Map<string, Map<string, any>>;
494
+ protected getOrCreateArray(name: string): Map<string, any>;
495
+ protected extractKey(value: any): string;
496
+ storeEntity(name: string, entity: T): Promise<T>;
497
+ safeLoadEntity(name: string, key: any): Promise<T>;
498
+ loadEntity(name: string, key: any): Promise<T | undefined>;
499
+ deleteEntity(name: string, key: any): Promise<boolean>;
500
+ searchEntities(name: string, ...criteria: any[]): Observable<T[]>;
501
+ searchAndPrepareEntities(name: string, sort?: any, groupBy?: any, transformer?: IDataTransformer<T> | undefined, ...criteria: any[]): Observable<any>;
502
+ canStoreDocument(): boolean;
503
+ storeDocument(toStore: File): Promise<IDocumentInfo>;
504
+ storeDocuments(toStore: File[]): Observable<IDocumentInfo>;
505
+ }
506
+ declare class TestDocumentInfo implements IDocumentInfo {
507
+ documentName: string;
508
+ isUrl: boolean;
509
+ documentId?: string;
510
+ constructor(documentName: string, isUrl: boolean, documentId?: string);
511
+ }
512
+
513
+ export { HostTestFormComponent, HostTestSimpleComponent, HostTestTypedComponent, HostTestTypedFormComponent, MessageHandler, StoreSupport, StoreTestHelper, TestDocumentInfo, TestStoreManager, TestStoreProvider, XT_REGISTRY_TOKEN, XT_RESOLVER_TOKEN, XT_TYPE_RESOLVER_TOKEN, XtBaseContext, XtCompositeComponent, XtPluginRegistry, XtRenderComponent, XtRenderSubComponent, XtResolvedComponent, XtResolverService, XtSimpleComponent, XtUnitTestHelper, attachToFormGroup, initXtPluginRegistry, updateFormGroupWithValue, xtPluginRegistry };
514
+ export type { IDataTransformer, IDocumentInfo, IStoreManager, IStoreProvider, 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.4.7",
3
+ "version": "0.5.0",
4
4
  "peerDependencies": {
5
- "@angular/animations": "^18.1.2",
6
- "@angular/common": "^18.1.2",
7
- "@angular/compiler": "^18.1.2",
8
- "@angular/core": "^18.1.2",
9
- "@angular/forms": "^18.1.2",
10
- "@angular/platform-browser": "^18.1.2",
11
- "@angular/platform-browser-dynamic": "^18.1.2",
12
- "@angular/router": "~18.1.2",
13
- "rxjs": "~7.8.0",
14
- "primeng": "~17.18.6",
15
- "primeicons": "~7.0.0"
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.3.0"
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
- }
@@ -1,39 +0,0 @@
1
- import { Type } from '@angular/core';
2
- import { XtContext } from '../xt-context';
3
- import { XtResolvedComponent } from '../xt-resolved-component';
4
- import { XtTypeHandler, XtTypeInfo, XtTypeResolver } from 'xt-type';
5
- import { XtComponentInfo, XtPluginInfo, XtTypeHandlerInfo } from '../plugin/xt-plugin-info';
6
- import { XtResolver } from '../resolver/xt-resolver';
7
- import { XtComponent } from '../xt-component';
8
- import * as i0 from "@angular/core";
9
- export declare class XtResolverService {
10
- pluginRegistry: import("xt-components").XtPluginRegistry;
11
- protected baseResolver: XtResolver | null;
12
- protected baseTypeResolver: XtTypeResolver | null;
13
- resolver: XtResolver;
14
- typeResolver: XtTypeResolver;
15
- constructor();
16
- findBestComponent<T>(baseContext: XtContext<T>, subName?: string): XtResolvedComponent;
17
- findTypeOf<T>(baseContext: XtContext<T>, subName?: string, value?: T): string | null | undefined;
18
- findTypeHandlerOf<T>(baseContext: XtContext<T>, subName?: string, value?: T): {
19
- typeName?: string | null;
20
- handler?: XtTypeHandler<any>;
21
- };
22
- listSubNamesOf<T>(baseContext: XtContext<T>, value?: T): string[];
23
- registerPlugin(info: XtPluginInfo): void;
24
- registerTypes(types: XtTypeInfo | undefined, handlers?: XtTypeHandlerInfo<any>[]): void;
25
- protected handlerDefinedFor(newType: string, handlers: XtTypeHandlerInfo<any>[] | undefined): any;
26
- getComponentInfo<T>(type: Type<XtComponent<T>>): XtResolvedComponent;
27
- findComponentInfo<T>(type: Type<XtComponent<T>>): XtResolvedComponent | null;
28
- listComponents: import("@angular/core").Signal<XtComponentInfo<any>[]>;
29
- listPlugins: import("@angular/core").Signal<XtPluginInfo[]>;
30
- /**
31
- * Dynamically load a register a plugin from the given url
32
- * The plugin must export at least a Register entrypoint that will be called right after loading..
33
- * @param url
34
- * @returns a Promise with the module loaded and already registered.
35
- */
36
- loadPlugin(url: URL | string): Promise<any>;
37
- static ɵfac: i0.ɵɵFactoryDeclaration<XtResolverService, never>;
38
- static ɵprov: i0.ɵɵInjectableDeclaration<XtResolverService>;
39
- }
@@ -1,7 +0,0 @@
1
- import { InjectionToken } from "@angular/core";
2
- import { XtResolver } from "../resolver/xt-resolver";
3
- import { XtPluginRegistry } from "../registry/xt-plugin-registry";
4
- import { XtTypeResolver } from "xt-type";
5
- export declare const XT_RESOLVER_TOKEN: InjectionToken<XtResolver>;
6
- export declare const XT_TYPE_RESOLVER_TOKEN: InjectionToken<XtTypeResolver>;
7
- export declare const XT_REGISTRY_TOKEN: InjectionToken<XtPluginRegistry>;
@@ -1,5 +0,0 @@
1
- import { InputSignal } from '@angular/core';
2
- import { XtComponentInput } from '../xt-component';
3
- export declare class XtBaseInput implements XtComponentInput {
4
- valueSelected: InputSignal<any> | undefined;
5
- }
@@ -1,5 +0,0 @@
1
- import { OutputEmitterRef } from '@angular/core';
2
- import { XtComponentOutput } from '../xt-component';
3
- export declare class XtBaseOutput implements XtComponentOutput {
4
- valueSelected: OutputEmitterRef<any> | undefined;
5
- }
@@ -1,19 +0,0 @@
1
- import { XtTypeInfo } from 'xt-type';
2
- import { XtOutputType } from '../xt-component';
3
- export type XtComponentInfo<T> = {
4
- componentName: string;
5
- componentClass: T;
6
- typesHandled: string[];
7
- outputs?: XtOutputType[];
8
- };
9
- export type XtTypeHandlerInfo<T> = {
10
- typesHandled: string[];
11
- handlerClass: T;
12
- };
13
- export type XtPluginInfo = {
14
- name: string;
15
- uriLogo?: string;
16
- components?: XtComponentInfo<any>[];
17
- types?: XtTypeInfo;
18
- typeHandlers?: XtTypeHandlerInfo<any>[];
19
- };