@ngx-formly/core 7.0.1 → 8.0.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.
Files changed (72) hide show
  1. package/README.md +10 -0
  2. package/fesm2022/ngx-formly-core-json-schema.mjs +259 -39
  3. package/fesm2022/ngx-formly-core-json-schema.mjs.map +1 -1
  4. package/fesm2022/ngx-formly-core-preset.mjs +4 -4
  5. package/fesm2022/ngx-formly-core-preset.mjs.map +1 -1
  6. package/fesm2022/ngx-formly-core-select.mjs +28 -21
  7. package/fesm2022/ngx-formly-core-select.mjs.map +1 -1
  8. package/fesm2022/ngx-formly-core-testing.mjs +3 -3
  9. package/fesm2022/ngx-formly-core-testing.mjs.map +1 -1
  10. package/fesm2022/ngx-formly-core.mjs +621 -78
  11. package/fesm2022/ngx-formly-core.mjs.map +1 -1
  12. package/json-schema/formly-json-schema.service.d.ts +8 -0
  13. package/lib/components/formly.field.d.ts +7 -4
  14. package/lib/core.config.d.ts +1 -0
  15. package/lib/core.d.ts +2 -2
  16. package/lib/core.module.d.ts +7 -0
  17. package/lib/extensions/field-expression/field-expression.d.ts +3 -12
  18. package/lib/extensions/field-expression/utils.d.ts +4 -2
  19. package/lib/extensions/field-expression-legacy/field-expression.d.ts +16 -0
  20. package/lib/extensions/field-expression-legacy/utils.d.ts +5 -0
  21. package/lib/templates/field-array.type.d.ts +1 -1
  22. package/lib/templates/field.type.d.ts +1 -1
  23. package/lib/templates/field.wrapper.d.ts +1 -1
  24. package/lib/templates/formly.attributes.d.ts +5 -2
  25. package/lib/templates/formly.validation-message.d.ts +2 -2
  26. package/package.json +2 -12
  27. package/select/select-options.pipe.d.ts +1 -0
  28. package/esm2022/json-schema/formly-json-schema.service.mjs +0 -628
  29. package/esm2022/json-schema/ngx-formly-core-json-schema.mjs +0 -5
  30. package/esm2022/json-schema/public_api.mjs +0 -2
  31. package/esm2022/lib/components/formly.field.mjs +0 -292
  32. package/esm2022/lib/components/formly.form.mjs +0 -171
  33. package/esm2022/lib/components/formly.template.mjs +0 -36
  34. package/esm2022/lib/core.config.mjs +0 -50
  35. package/esm2022/lib/core.mjs +0 -20
  36. package/esm2022/lib/core.module.mjs +0 -74
  37. package/esm2022/lib/extensions/core/core.mjs +0 -144
  38. package/esm2022/lib/extensions/field-expression/field-expression.mjs +0 -246
  39. package/esm2022/lib/extensions/field-expression/utils.mjs +0 -17
  40. package/esm2022/lib/extensions/field-form/field-form.mjs +0 -141
  41. package/esm2022/lib/extensions/field-form/utils.mjs +0 -100
  42. package/esm2022/lib/extensions/field-validation/field-validation.mjs +0 -135
  43. package/esm2022/lib/extensions/index.mjs +0 -2
  44. package/esm2022/lib/models/config.mjs +0 -2
  45. package/esm2022/lib/models/fieldconfig.cache.mjs +0 -2
  46. package/esm2022/lib/models/fieldconfig.mjs +0 -2
  47. package/esm2022/lib/models/index.mjs +0 -4
  48. package/esm2022/lib/services/formly.builder.mjs +0 -98
  49. package/esm2022/lib/services/formly.config.mjs +0 -236
  50. package/esm2022/lib/templates/field-array.type.mjs +0 -84
  51. package/esm2022/lib/templates/field-template.type.mjs +0 -34
  52. package/esm2022/lib/templates/field.type.mjs +0 -57
  53. package/esm2022/lib/templates/field.wrapper.mjs +0 -21
  54. package/esm2022/lib/templates/formly.attributes.mjs +0 -201
  55. package/esm2022/lib/templates/formly.group.mjs +0 -31
  56. package/esm2022/lib/templates/formly.validation-message.mjs +0 -84
  57. package/esm2022/lib/utils.mjs +0 -312
  58. package/esm2022/ngx-formly-core.mjs +0 -5
  59. package/esm2022/preset/ngx-formly-core-preset.mjs +0 -5
  60. package/esm2022/preset/preset-substitution.extension.mjs +0 -30
  61. package/esm2022/preset/preset.config.mjs +0 -11
  62. package/esm2022/preset/preset.module.mjs +0 -18
  63. package/esm2022/preset/public_api.mjs +0 -3
  64. package/esm2022/public_api.mjs +0 -5
  65. package/esm2022/select/ngx-formly-core-select.mjs +0 -5
  66. package/esm2022/select/public_api.mjs +0 -3
  67. package/esm2022/select/select-options.pipe.mjs +0 -108
  68. package/esm2022/select/select.module.mjs +0 -16
  69. package/esm2022/testing/component-factory.mjs +0 -86
  70. package/esm2022/testing/ngx-formly-core-testing.mjs +0 -5
  71. package/esm2022/testing/public_api.mjs +0 -2
  72. package/lib/extensions/index.d.ts +0 -1
@@ -15,8 +15,16 @@ export declare class FormlyJsonschema {
15
15
  private resolveSchema;
16
16
  private resolveAllOf;
17
17
  private resolveMultiSchema;
18
+ private createMultiSchemaField;
19
+ private ensureMultiSchemaField;
20
+ private getSchemaField;
21
+ private isRecursiveMultiSchema;
22
+ private getDefinition;
18
23
  private resolveDefinition;
19
24
  private resolveDependencies;
25
+ private extractIfCondition;
26
+ private resolveIfThenElse;
27
+ private resolveConditionalSchema;
20
28
  private guessSchemaType;
21
29
  private addValidator;
22
30
  private isEnum;
@@ -1,6 +1,6 @@
1
- import { ViewContainerRef, SimpleChanges, DoCheck, OnInit, OnChanges, OnDestroy, AfterContentInit, AfterViewInit, Renderer2, ElementRef } from '@angular/core';
1
+ import { ViewContainerRef, SimpleChanges, DoCheck, OnInit, OnChanges, OnDestroy, AfterContentInit, AfterViewInit, Renderer2, ElementRef, Injector } from '@angular/core';
2
2
  import { FormlyConfig } from '../services/formly.config';
3
- import { FormlyFieldConfig } from '../models';
3
+ import { FormlyFieldConfig, FormlyFieldConfigCache } from '../models';
4
4
  import { FormlyFieldTemplates } from './formly.template';
5
5
  import * as i0 from "@angular/core";
6
6
  /**
@@ -11,6 +11,7 @@ export declare class FormlyField implements DoCheck, OnInit, OnChanges, AfterCon
11
11
  private renderer;
12
12
  private _elementRef;
13
13
  private hostContainerRef;
14
+ private injector;
14
15
  private form;
15
16
  /** The field config. */
16
17
  field: FormlyFieldConfig;
@@ -22,7 +23,7 @@ export declare class FormlyField implements DoCheck, OnInit, OnChanges, AfterCon
22
23
  private get containerRef();
23
24
  private get elementRef();
24
25
  valueChangesUnsubscribe: () => void;
25
- constructor(config: FormlyConfig, renderer: Renderer2, _elementRef: ElementRef, hostContainerRef: ViewContainerRef, form: FormlyFieldTemplates);
26
+ constructor(config: FormlyConfig, renderer: Renderer2, _elementRef: ElementRef, hostContainerRef: ViewContainerRef, injector: Injector, form: FormlyFieldTemplates);
26
27
  ngAfterContentInit(): void;
27
28
  ngAfterViewInit(): void;
28
29
  ngDoCheck(): void;
@@ -31,11 +32,13 @@ export declare class FormlyField implements DoCheck, OnInit, OnChanges, AfterCon
31
32
  ngOnDestroy(): void;
32
33
  private renderField;
33
34
  private triggerHook;
35
+ attachLocalField(field?: FormlyFieldConfigCache, previousField?: FormlyFieldConfigCache): void;
36
+ private createFieldInjector;
34
37
  private attachComponentRef;
35
38
  private render;
36
39
  private resetRefs;
37
40
  private fieldChanges;
38
- static ɵfac: i0.ɵɵFactoryDeclaration<FormlyField, [null, null, null, null, { optional: true; }]>;
41
+ static ɵfac: i0.ɵɵFactoryDeclaration<FormlyField, [null, null, null, null, null, { optional: true; }]>;
39
42
  static ɵcmp: i0.ɵɵComponentDeclaration<FormlyField, "formly-field", never, { "field": { "alias": "field"; "required": false; }; }, {}, never, never, true, never>;
40
43
  }
41
44
  export declare class LegacyFormlyField extends FormlyField {
@@ -6,5 +6,6 @@ import { FormlyConfig } from './services/formly.config';
6
6
  */
7
7
  export declare const FORMLY_CONFIG: InjectionToken<ConfigOption[]>;
8
8
  export declare function withDefaultConfig(config: FormlyConfig): ConfigOption;
9
+ export declare function withFormlyFieldExpression(): ConfigOption;
9
10
  export declare const provideFormlyCore: (configs?: ConfigOption | ConfigOption[]) => Provider;
10
11
  export declare const provideFormlyConfig: (configs?: ConfigOption | ConfigOption[]) => Provider;
package/lib/core.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { provideFormlyCore, provideFormlyConfig, FORMLY_CONFIG } from './core.config';
1
+ export { provideFormlyCore, provideFormlyConfig, FORMLY_CONFIG, withFormlyFieldExpression } from './core.config';
2
2
  export { LegacyFormlyForm, FormlyForm } from './components/formly.form';
3
- export { FormlyFieldConfig, FormlyTemplateOptions, FormlyFormOptions, FormlyFieldProps, ConfigOption, FormlyExtension, } from './models';
3
+ export { FormlyFieldConfig, FormlyTemplateOptions, FormlyFormOptions, FormlyFieldProps, ConfigOption, FormlyExtension, FormlyFieldConfigPresetProvider, FormlyAttributeEvent, ValidationMessageOption, } from './models';
4
4
  export { LegacyFormlyField, FormlyField } from './components/formly.field';
5
5
  export { LegacyFormlyAttributes, FormlyAttributes } from './templates/formly.attributes';
6
6
  export { FormlyGroup as ɵFormlyGroup } from './templates/formly.group';
@@ -9,6 +9,13 @@ import * as i5 from "./templates/formly.validation-message";
9
9
  import * as i6 from "./templates/formly.group";
10
10
  import * as i7 from "./templates/field-template.type";
11
11
  import * as i8 from "@angular/common";
12
+ /**
13
+ * Registers Formly components and configuration for NgModule-based applications.
14
+ *
15
+ * `forRoot()` provides the shared `FormlyConfig` at the application root, while
16
+ * `forChild()` adds feature configuration using the inherited service. This follows
17
+ * Angular's [root/child module registration convention](https://frontendatlas.com/angular/trivia/angular-forroot-forchild).
18
+ */
12
19
  export declare class FormlyModule {
13
20
  static forRoot(config?: ConfigOption): ModuleWithProviders<FormlyModule>;
14
21
  static forChild(config?: ConfigOption): ModuleWithProviders<FormlyModule>;
@@ -1,13 +1,4 @@
1
- import { FormlyFieldConfigCache } from '../../models';
2
- import { FormlyExtension } from '../../models';
3
- export declare class FieldExpressionExtension implements FormlyExtension {
4
- onPopulate(field: FormlyFieldConfigCache): void;
5
- postPopulate(field: FormlyFieldConfigCache): void;
6
- private parseExpressions;
7
- private checkExpressions;
8
- private changeDisabledState;
9
- private changeHideState;
10
- private evalExpr;
11
- private emitExpressionChanges;
12
- private _evalExpressionPath;
1
+ import { FieldExpressionExtension as FieldExpressionLegacyExtension } from '../field-expression-legacy/field-expression';
2
+ export declare class FieldExpressionExtension extends FieldExpressionLegacyExtension {
3
+ protected _evalStringExpression(expression: string, argNames: string[]): any;
13
4
  }
@@ -1,2 +1,4 @@
1
- export declare function evalStringExpression(expression: string, argNames: string[]): any;
2
- export declare function evalExpression(expression: string | ((...value: any[]) => any) | boolean, thisArg: any, argVal: any[]): any;
1
+ /**
2
+ * Uses CSP-safe implementation
3
+ */
4
+ export declare function parseExpression(expression: string, argNames: string[]): any;
@@ -0,0 +1,16 @@
1
+ import { FormlyFieldConfigCache } from '../../models';
2
+ import { FormlyExtension } from '../../models';
3
+ export declare class FieldExpressionExtension implements FormlyExtension {
4
+ onPopulate(field: FormlyFieldConfigCache): void;
5
+ postPopulate(field: FormlyFieldConfigCache): void;
6
+ protected parseExpressions(field: FormlyFieldConfigCache, path: string, expr: any): {
7
+ callback: (ignoreCache?: boolean) => boolean;
8
+ };
9
+ protected _evalStringExpression(expression: string, argNames: string[]): any;
10
+ private checkExpressions;
11
+ private changeDisabledState;
12
+ private changeHideState;
13
+ private evalExpr;
14
+ private emitExpressionChanges;
15
+ private _evalExpressionPath;
16
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Legacy implementation
3
+ */
4
+ export declare function evalStringExpressionLegacy(expression: string, argNames: string[]): any;
5
+ export declare function evalExpression(expression: string | ((...value: any[]) => any) | boolean, thisArg: any, argVal: any[]): any;
@@ -18,5 +18,5 @@ export declare abstract class FieldArrayType<F extends FormlyFieldConfig = Field
18
18
  private updateArrayElementKey;
19
19
  private markFieldForCheck;
20
20
  static ɵfac: i0.ɵɵFactoryDeclaration<FieldArrayType<any>, never>;
21
- static ɵdir: i0.ɵɵDirectiveDeclaration<FieldArrayType<any>, never, never, {}, {}, never, never, false, never>;
21
+ static ɵdir: i0.ɵɵDirectiveDeclaration<FieldArrayType<any>, never, never, {}, {}, never, never, true, never>;
22
22
  }
@@ -26,5 +26,5 @@ export declare abstract class FieldType<F extends FormlyFieldConfig = FormlyFiel
26
26
  get id(): string;
27
27
  get formState(): any;
28
28
  static ɵfac: i0.ɵɵFactoryDeclaration<FieldType<any>, never>;
29
- static ɵdir: i0.ɵɵDirectiveDeclaration<FieldType<any>, never, never, { "field": { "alias": "field"; "required": false; }; }, {}, never, never, false, never>;
29
+ static ɵdir: i0.ɵɵDirectiveDeclaration<FieldType<any>, never, never, { "field": { "alias": "field"; "required": false; }; }, {}, never, never, true, never>;
30
30
  }
@@ -8,5 +8,5 @@ export declare abstract class FieldWrapper<F extends FormlyFieldConfig = FormlyF
8
8
  fieldComponent: ViewContainerRef;
9
9
  set _staticContent(content: ViewContainerRef);
10
10
  static ɵfac: i0.ɵɵFactoryDeclaration<FieldWrapper<any>, never>;
11
- static ɵdir: i0.ɵɵDirectiveDeclaration<FieldWrapper<any>, never, never, {}, {}, never, never, false, never>;
11
+ static ɵdir: i0.ɵɵDirectiveDeclaration<FieldWrapper<any>, never, never, {}, {}, never, never, true, never>;
12
12
  }
@@ -1,5 +1,6 @@
1
1
  import { ElementRef, OnChanges, SimpleChanges, Renderer2, DoCheck, OnDestroy } from '@angular/core';
2
2
  import { FormlyFieldConfig } from '../models';
3
+ import { FormlyField } from '../components/formly.field';
3
4
  import * as i0 from "@angular/core";
4
5
  /**
5
6
  * Allow to link the `field` HTML attributes (`id`, `name` ...) and Event attributes (`focus`, `blur` ...) to an element in the DOM.
@@ -7,6 +8,7 @@ import * as i0 from "@angular/core";
7
8
  export declare class FormlyAttributes implements OnChanges, DoCheck, OnDestroy {
8
9
  private renderer;
9
10
  private elementRef;
11
+ private formlyField?;
10
12
  /** The field config. */
11
13
  field: FormlyFieldConfig;
12
14
  id: string;
@@ -22,7 +24,7 @@ export declare class FormlyAttributes implements OnChanges, DoCheck, OnDestroy {
22
24
  private uiEvents;
23
25
  private get props();
24
26
  private get fieldAttrElements();
25
- constructor(renderer: Renderer2, elementRef: ElementRef, _document: any);
27
+ constructor(renderer: Renderer2, elementRef: ElementRef, _document: any, formlyField?: FormlyField);
26
28
  ngOnChanges(changes: SimpleChanges): void;
27
29
  /**
28
30
  * We need to re-evaluate all the attributes on every change detection cycle, because
@@ -41,9 +43,10 @@ export declare class FormlyAttributes implements OnChanges, DoCheck, OnDestroy {
41
43
  onChange($event: any): void;
42
44
  private attachElementRef;
43
45
  private detachElementRef;
46
+ private getSafeAttributeValue;
44
47
  private setAttribute;
45
48
  private removeAttribute;
46
- static ɵfac: i0.ɵɵFactoryDeclaration<FormlyAttributes, never>;
49
+ static ɵfac: i0.ɵɵFactoryDeclaration<FormlyAttributes, [null, null, null, { optional: true; }]>;
47
50
  static ɵdir: i0.ɵɵDirectiveDeclaration<FormlyAttributes, "[formlyAttributes]", never, { "field": { "alias": "formlyAttributes"; "required": false; }; "id": { "alias": "id"; "required": false; }; }, {}, never, never, true, never>;
48
51
  }
49
52
  export declare class LegacyFormlyAttributes extends FormlyAttributes {
@@ -1,7 +1,7 @@
1
1
  import { OnChanges } from '@angular/core';
2
- import { FormlyConfig } from '../services/formly.config';
3
- import { FormlyFieldConfig } from '../models';
4
2
  import { Observable } from 'rxjs';
3
+ import { FormlyFieldConfig } from '../models';
4
+ import { FormlyConfig } from '../services/formly.config';
5
5
  import * as i0 from "@angular/core";
6
6
  /**
7
7
  * The `<formly-validation-message>` component renders the error message of a given `field`.
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ngx-formly/core",
3
- "version": "7.0.1",
3
+ "version": "8.0.0",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
6
  "tslib": "^2.0.0"
7
7
  },
8
8
  "peerDependencies": {
9
- "@angular/forms": ">=13.2.0",
9
+ "@angular/forms": ">=19.0.0",
10
10
  "rxjs": "^6.5.3 || ^7.0.0"
11
11
  },
12
12
  "module": "fesm2022/ngx-formly-core.mjs",
@@ -17,32 +17,22 @@
17
17
  },
18
18
  ".": {
19
19
  "types": "./index.d.ts",
20
- "esm2022": "./esm2022/ngx-formly-core.mjs",
21
- "esm": "./esm2022/ngx-formly-core.mjs",
22
20
  "default": "./fesm2022/ngx-formly-core.mjs"
23
21
  },
24
22
  "./json-schema": {
25
23
  "types": "./json-schema/index.d.ts",
26
- "esm2022": "./esm2022/json-schema/ngx-formly-core-json-schema.mjs",
27
- "esm": "./esm2022/json-schema/ngx-formly-core-json-schema.mjs",
28
24
  "default": "./fesm2022/ngx-formly-core-json-schema.mjs"
29
25
  },
30
26
  "./preset": {
31
27
  "types": "./preset/index.d.ts",
32
- "esm2022": "./esm2022/preset/ngx-formly-core-preset.mjs",
33
- "esm": "./esm2022/preset/ngx-formly-core-preset.mjs",
34
28
  "default": "./fesm2022/ngx-formly-core-preset.mjs"
35
29
  },
36
30
  "./select": {
37
31
  "types": "./select/index.d.ts",
38
- "esm2022": "./esm2022/select/ngx-formly-core-select.mjs",
39
- "esm": "./esm2022/select/ngx-formly-core-select.mjs",
40
32
  "default": "./fesm2022/ngx-formly-core-select.mjs"
41
33
  },
42
34
  "./testing": {
43
35
  "types": "./testing/index.d.ts",
44
- "esm2022": "./esm2022/testing/ngx-formly-core-testing.mjs",
45
- "esm": "./esm2022/testing/ngx-formly-core-testing.mjs",
46
36
  "default": "./fesm2022/ngx-formly-core-testing.mjs"
47
37
  }
48
38
  },
@@ -13,6 +13,7 @@ export interface FormlyFieldSelectProps extends FormlyFieldProps {
13
13
  labelProp?: string | ((option: any) => string);
14
14
  valueProp?: string | ((option: any) => any);
15
15
  disabledProp?: string | ((option: any) => boolean);
16
+ mapProp?: (option: any) => FormlySelectOption;
16
17
  }
17
18
  export declare class FormlySelectOptionsPipe implements PipeTransform, OnDestroy {
18
19
  private _subscription;