@sumaris-net/ngx-components 18.12.6 → 18.12.8

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sumaris-net/ngx-components",
3
3
  "description": "SUMARiS Angular components",
4
- "version": "18.12.6",
4
+ "version": "18.12.8",
5
5
  "author": "contact@e-is.pro",
6
6
  "license": "AGPL-3.0",
7
7
  "readmeFilename": "README.md",
@@ -1,7 +1,7 @@
1
1
  import { AbstractControl } from '@angular/forms';
2
2
  import { filterNumberInput, selectInputContent, selectInputContentFromEvent } from '../../shared/inputs';
3
3
  import { WaitForOptions } from '../../shared/observables';
4
- import { addValueInArray, clearValueInArray, copyEntity2Form, disableAndClearControl, disableAndClearControls, disableControl, disableControls, enableControl, enableControls, filterFormErrors, filterFormErrorsByPath, filterFormErrorsByPrefix, getControlFromPath, getFormErrors, getFormValueFromEntity, logFormErrors, markAllAsTouched, markAsUntouched, removeValueInArray, resizeArray, setControlEnabled, setControlsEnabled, updateValueAndValidity, waitIdle, waitWhilePending } from '../../shared/forms';
4
+ import { addValueInArray, clearValueInArray, copyEntity2Form, disableAndClearControl, disableAndClearControls, disableControl, disableControls, enableControl, enableControls, filterFormErrors, filterFormErrorsByPath, filterFormErrorsByPrefix, getControlFromPath, getFormErrors, getFormValueFromEntity, logFormErrors, markAllAsTouched, markAsUntouched, removeValueInArray, resizeArray, setControlEnabled, setControlsEnabled, setFormErrors, updateValueAndValidity, waitIdle, waitWhilePending } from '../../shared/forms';
5
5
  export declare type IAppFormGetter = () => IAppForm;
6
6
  export declare interface OnReady {
7
7
  ngOnReady(): any;
@@ -207,7 +207,15 @@ export declare class AppFormProvider<F extends IAppForm = IAppForm> implements I
207
207
  export declare class AppFormUtils {
208
208
  static copyEntity2Form: typeof copyEntity2Form;
209
209
  static getFormValueFromEntity: typeof getFormValueFromEntity;
210
- static logFormErrors: typeof logFormErrors;
210
+ /**
211
+ * Retrieves a control from the provided form/control structure using a dot-separated path.
212
+ *
213
+ * @param {AbstractControl} form - The root form group, form array, or control to start searching from.
214
+ * @param {string} path - The dot-separated path specifying the control. For example, 'groupName.controlName' or 'arrayName.0.controlName'.
215
+ * @param {boolean} [strict=true] - If true, throws an error if the full path cannot be resolved; if false, returns the last valid control encountered.
216
+ * @return {AbstractControl} - The control at the specified path or the closest valid control if strict mode is disabled.
217
+ * @throws {Error} - Throws an error if the path cannot be resolved and strict mode is enabled.
218
+ */
211
219
  static getControlFromPath: typeof getControlFromPath;
212
220
  static filterNumberInput: typeof filterNumberInput;
213
221
  static enableControls: typeof enableControls;
@@ -234,7 +242,6 @@ export declare class AppFormUtils {
234
242
  static waitWhilePending: typeof waitWhilePending;
235
243
  static waitIdle: typeof waitIdle;
236
244
  static updateValueAndValidity: typeof updateValueAndValidity;
237
- static getFormErrors: typeof getFormErrors;
238
245
  static isForm(object: any): object is IAppForm;
239
246
  static canSave(object: any): object is IAppForm & CanSave;
240
247
  static addValueInArray: typeof addValueInArray;
@@ -245,9 +252,29 @@ export declare class AppFormUtils {
245
252
  static isControlHasInput: typeof isControlHasInput;
246
253
  static setCalculatedValue: typeof setCalculatedValue;
247
254
  static resetCalculatedValue: typeof resetCalculatedValue;
255
+ static logFormErrors: typeof logFormErrors;
248
256
  static filterErrorsByPrefix: typeof filterFormErrorsByPrefix;
249
257
  static filterErrorsByPath: typeof filterFormErrorsByPath;
250
258
  static filterErrors: typeof filterFormErrors;
259
+ /**
260
+ * Retrieves all validation errors from a given form control, including its child controls if it is a form group or array.
261
+ *
262
+ * @param {AbstractControl} control - The form control to retrieve errors from. This can be a form group, a form array, or a simple form control.
263
+ * @param {Object} [opts] - Optional configurations for error retrieval.
264
+ * @param {string} [opts.controlName] - The name or path of the control being processed, used for structuring error keys in the result.
265
+ * @param {FormErrors} [opts.result] - The object to which errors will be added, allowing for aggregation and persistence between calls.
266
+ * @param {boolean} [opts.recursive=true] - Whether to recursively collect errors from child controls within a form group or array. Defaults to true.
267
+ * @return {FormErrors} The collected errors as a key-value object where keys represent control names or paths and values represent their respective errors. Returns `undefined` if the provided control is valid and has no errors.
268
+ */
269
+ static getFormErrors: typeof getFormErrors;
270
+ /**
271
+ * Sets form errors on an AbstractControl, including nested controls within form groups or arrays.
272
+ *
273
+ * @param {AbstractControl} control - The form control, form group, or form array to apply the errors to.
274
+ * @param {FormErrors} errors - An object representing the errors to be set on the control or its children.
275
+ * @return {void} Does not return a value.
276
+ */
277
+ static setFormErrors: typeof setFormErrors;
251
278
  }
252
279
  export declare function isControlHasInput(controls: {
253
280
  [key: string]: AbstractControl;
@@ -1,13 +1,13 @@
1
1
  import { IEntity } from './entity.model';
2
2
  import { EntityFilter } from './filter.model';
3
3
  import { FilterFn } from '../../../shared/types';
4
- export declare interface ITreeItemEntity<T extends IEntity<T, ID>, ID = number> {
4
+ export declare interface ITreeItemEntity<T extends IEntity<T, ID>, ID = number> extends IEntity<T, ID> {
5
5
  parentId: ID;
6
6
  parent: T;
7
7
  children: T[];
8
8
  }
9
9
  export declare class TreeItemEntityUtils {
10
- static forward<T extends ITreeItemEntity<any>, ID = number>(node: T, filterFn?: FilterFn<T>, loopCount?: number): T;
10
+ static forward<T extends ITreeItemEntity<any>>(node: T, filterFn?: FilterFn<T>, loopCount?: number): T;
11
11
  static backward<T extends ITreeItemEntity<any>, ID = number>(node: T, filterFn?: FilterFn<T>, loopCount?: number): T;
12
12
  static first<T extends ITreeItemEntity<any>>(node: T, filterFn?: FilterFn<T>): T;
13
13
  static lastLeaf<T extends ITreeItemEntity<any>>(node: T, filterFn?: FilterFn<T>): T;
@@ -50,4 +50,12 @@ export declare class TreeItemEntityUtils {
50
50
  * @param source
51
51
  */
52
52
  static treeFillParent<T extends ITreeItemEntity<any>>(source: T): any;
53
+ /**
54
+ * Converts an array of objects into a tree hierarchy based on parent-child relationships.
55
+ *
56
+ * @param {T[]} sources - The array of source objects to be converted into tree structure.
57
+ * @param {new () => T} [dataType] - An optional class constructor used to shape the objects within the tree.
58
+ * @return {T[] | undefined} An array of root elements representing the tree structure, or undefined if the input is empty.
59
+ */
60
+ static fromObjectArrayAsTrees<T extends ITreeItemEntity<any>>(sources: T[], dataType?: new () => T): T[];
53
61
  }
@@ -27,12 +27,31 @@ export declare function getFormValueFromEntity(entity: any | undefined, form: Un
27
27
  */
28
28
  export declare function adaptValueToControl(source: any | undefined, control: AbstractControl, path?: string): any;
29
29
  export declare function logFormErrors(control: AbstractControl, logPrefix?: string, path?: string): void;
30
+ /**
31
+ * Retrieves all validation errors from a given form control, including its child controls if it is a form group or array.
32
+ *
33
+ * @param {AbstractControl} control - The form control to retrieve errors from. This can be a form group, a form array, or a simple form control.
34
+ * @param {Object} [opts] - Optional configurations for error retrieval.
35
+ * @param {string} [opts.controlName] - The name or path of the control being processed, used for structuring error keys in the result.
36
+ * @param {FormErrors} [opts.result] - The object to which errors will be added, allowing for aggregation and persistence between calls.
37
+ * @param {boolean} [opts.recursive=true] - Whether to recursively collect errors from child controls within a form group or array. Defaults to true.
38
+ * @return {FormErrors} The collected errors as a key-value object where keys represent control names or paths and values represent their respective errors. Returns `undefined` if the provided control is valid and has no errors.
39
+ */
30
40
  export declare function getFormErrors(control: AbstractControl, opts?: {
31
41
  controlName?: string;
32
42
  result?: FormErrors;
33
43
  recursive?: boolean;
34
44
  }): FormErrors;
35
- export declare function getControlFromPath(form: UntypedFormGroup, path: string): AbstractControl;
45
+ /**
46
+ * Retrieves a control from the provided form/control structure using a dot-separated path.
47
+ *
48
+ * @param {AbstractControl} form - The root form group, form array, or control to start searching from.
49
+ * @param {string} path - The dot-separated path specifying the control. For example, 'groupName.controlName' or 'arrayName.0.controlName'.
50
+ * @param {boolean} [strict=true] - If true, throws an error if the full path cannot be resolved; if false, returns the last valid control encountered.
51
+ * @return {AbstractControl} - The control at the specified path or the closest valid control if strict mode is disabled.
52
+ * @throws {Error} - Throws an error if the path cannot be resolved and strict mode is enabled.
53
+ */
54
+ export declare function getControlFromPath(form: AbstractControl, path: string, strict?: boolean): AbstractControl;
36
55
  export declare function disableControls(form: UntypedFormGroup, paths: string[], opts?: {
37
56
  onlySelf?: boolean;
38
57
  emitEvent?: boolean;
@@ -53,6 +72,14 @@ export declare function setControlsEnabled(form: UntypedFormGroup, enabled: bool
53
72
  emitEvent?: boolean;
54
73
  required?: boolean;
55
74
  }): void;
75
+ /**
76
+ * Sets form errors on an AbstractControl, including nested controls within form groups or arrays.
77
+ *
78
+ * @param {AbstractControl} control - The form control, form group, or form array to apply the errors to.
79
+ * @param {FormErrors} errors - An object representing the errors to be set on the control or its children.
80
+ * @return {void} Does not return a value.
81
+ */
82
+ export declare function setFormErrors(control: AbstractControl, errors: FormErrors): void;
56
83
  export declare function enableControl(control: AbstractControl, opts?: {
57
84
  onlySelf?: boolean;
58
85
  emitEvent?: boolean;
@@ -17,7 +17,7 @@ export interface InputElement extends FocusableElement {
17
17
  }
18
18
  export declare function isInputElement(object: any): object is InputElement;
19
19
  export declare function asInputElement<T = any>(object: ElementRef<T>): InputElement | undefined;
20
- export declare function tabindexComparator(a: InputElement, b: InputElement): 0 | 1 | -1;
20
+ export declare function tabindexComparator(a: InputElement, b: InputElement): 1 | -1 | 0;
21
21
  export interface CanGainFocusOptions {
22
22
  minTabindex?: number;
23
23
  maxTabindex?: number;
@@ -2,7 +2,7 @@
2
2
  "name": "ngx-sumaris-components",
3
3
  "short_name": "ngx-sumaris-components",
4
4
  "manifest_version": 1,
5
- "version": "18.12.6",
5
+ "version": "18.12.8",
6
6
  "default_locale": "fr",
7
7
  "description": "Angular components for building beautiful and responsive Apps",
8
8
  "icons": [{