@sumaris-net/ngx-components 18.0.2-alpha2 → 18.0.2-alpha4

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.0.2-alpha2",
4
+ "version": "18.0.2-alpha4",
5
5
  "author": "contact@e-is.pro",
6
6
  "license": "AGPL-3.0",
7
7
  "readmeFilename": "README.md",
@@ -1,6 +1,6 @@
1
1
  import { PropertiesMap, Property } from '../../../shared/types';
2
2
  import { FormFieldDefinition } from '../../../shared/form/field.model';
3
- import { SuggestFn } from '../../../shared/services/entity-service.class';
3
+ import { EntitiesServiceLoadOptions, SuggestFn } from '../../../shared/services/entity-service.class';
4
4
  export declare class AppPropertiesUtils {
5
5
  /**
6
6
  * Converts an array of `Property` objects into a `PropertiesMap` object.
@@ -25,13 +25,26 @@ export declare class AppPropertiesUtils {
25
25
  }
26
26
  export declare class AppPropertyUtils {
27
27
  static key(source: Property | any): string;
28
- static asObject(source: Property | any, def?: FormFieldDefinition): {
28
+ /**
29
+ * Converts the given source to an object that contains a key-value pair.
30
+ *
31
+ * @param {Property<any> | any} source - The source property or any value to be converted.
32
+ * @param {FormFieldDefinition} [def] - The form field definition used for serialization.
33
+ * @param {Object} [opts] - Additional options for serialization.
34
+ * @param {string} [opts.defaultSerializeAttribute='id'] - The attribute to be used for default serialization.
35
+ * @return {{ key: string, value: string } | undefined} An object containing the serialized key-value pair, or undefined if the source is not provided.
36
+ */
37
+ static asObject(source: Property<any> | any, def?: FormFieldDefinition, opts?: {
38
+ defaultSerializeAttribute?: string;
39
+ }): {
29
40
  key: string;
30
41
  value: string;
31
42
  } | undefined;
32
43
  static fromObject(source: Property<string>, def: FormFieldDefinition, opts?: {
33
44
  defaultSuggestFn: SuggestFn<any, any>;
45
+ defaultSuggestOptions?: EntitiesServiceLoadOptions;
46
+ defaultSerializeAttribute?: string;
34
47
  }): Property<any> | Promise<Property<any>>;
35
- private static valueFromObject;
36
- private static resolveValueBySuggest;
48
+ private static resolveEntity;
49
+ private static resolveEntityBySuggest;
37
50
  }
@@ -19,8 +19,6 @@ export declare interface FormFieldDefinition<K = string, T = FormFieldType, E =
19
19
  isTransient?: boolean;
20
20
  values?: (string | Property)[] | InjectionToken<(string | Property)[]>;
21
21
  autocomplete?: MatAutocompleteFieldConfig<E>;
22
- deserialize?: (value: string) => E | Promise<E>;
23
- serialize?: (value: E) => string;
24
22
  disabled?: boolean;
25
23
  required?: boolean;
26
24
  extra?: {
@@ -30,6 +28,21 @@ export declare interface FormFieldDefinition<K = string, T = FormFieldType, E =
30
28
  };
31
29
  };
32
30
  minProfile?: UserProfileLabel;
31
+ /**
32
+ * Use for automatic serialization/deserialization to/from string (eg. using the autocomplete suggestFn).
33
+ * Default value: 'id'
34
+ */
35
+ serializeAttribute?: string;
36
+ /**
37
+ * Use to serialize an entity into string (see AppPropertiesUtils.***asObject())
38
+ * @param value
39
+ */
40
+ serialize?: (value: E) => string;
41
+ /**
42
+ * Use to deserialize a string into an entity (see AppPropertiesUtils.***fromObject())
43
+ * @param value
44
+ */
45
+ deserialize?: (value: string) => E | Promise<E>;
33
46
  }
34
47
  export declare type FormFieldDefinitionMap = ObjectMap<FormFieldDefinition>;
35
48
  export declare abstract class FormFieldValuesHolder {
@@ -1,9 +1,9 @@
1
- import { LoadResult, SuggestService } from '../../services/entity-service.class';
1
+ import { SuggestFn, SuggestService } from '../../services/entity-service.class';
2
2
  import { Observable } from 'rxjs';
3
3
  import { DisplayFn, EqualsFn } from '../../form/field.model';
4
4
  export declare interface MatAutocompleteFieldConfig<T = any, F = any> {
5
5
  attributes?: string[];
6
- suggestFn?: (value: any, options?: any) => Promise<T[] | LoadResult<T>>;
6
+ suggestFn?: SuggestFn<T, F>;
7
7
  filter?: Partial<F>;
8
8
  items?: Observable<T[]> | T[];
9
9
  columnSizes?: (number | 'auto' | undefined)[];
@@ -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.0.2-alpha2",
5
+ "version": "18.0.2-alpha4",
6
6
  "default_locale": "fr",
7
7
  "description": "Angular components for building beautiful and responsive Apps",
8
8
  "icons": [{