@wemake4u/form-player-se 1.0.28 → 1.0.30

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 (29) hide show
  1. package/esm2022/lib/controls/displayfield.mjs +4 -0
  2. package/esm2022/lib/controls/factory.mjs +4 -1
  3. package/esm2022/lib/directives/dropdown.directive.mjs +14 -5
  4. package/esm2022/lib/directives/number.directive.mjs +20 -5
  5. package/esm2022/lib/dynamic-fields/dynamic-fields.component.mjs +16 -28
  6. package/esm2022/lib/dynamic-form/dynamic-form.component.mjs +79 -71
  7. package/esm2022/lib/services/disable.service.mjs +74 -0
  8. package/esm2022/lib/services/event.service.mjs +45 -13
  9. package/esm2022/lib/services/form.service.mjs +6 -6
  10. package/esm2022/lib/services/programmability.service.mjs +28 -190
  11. package/esm2022/lib/services/status.service.mjs +37 -0
  12. package/esm2022/lib/services/validation.service.mjs +179 -0
  13. package/esm2022/lib/utils/CallbackRegistry.mjs +16 -0
  14. package/esm2022/public-api.mjs +2 -1
  15. package/fesm2022/wemake4u-form-player-se.mjs +510 -330
  16. package/fesm2022/wemake4u-form-player-se.mjs.map +1 -1
  17. package/lib/controls/displayfield.d.ts +3 -0
  18. package/lib/directives/dropdown.directive.d.ts +4 -1
  19. package/lib/dynamic-fields/dynamic-fields.component.d.ts +1 -3
  20. package/lib/dynamic-form/dynamic-form.component.d.ts +11 -8
  21. package/lib/services/disable.service.d.ts +21 -0
  22. package/lib/services/event.service.d.ts +14 -10
  23. package/lib/services/form.service.d.ts +1 -1
  24. package/lib/services/programmability.service.d.ts +7 -14
  25. package/lib/services/status.service.d.ts +17 -0
  26. package/lib/services/validation.service.d.ts +36 -0
  27. package/lib/utils/CallbackRegistry.d.ts +6 -0
  28. package/package.json +1 -1
  29. package/public-api.d.ts +1 -0
@@ -0,0 +1,3 @@
1
+ import { Control } from "./control";
2
+ export declare class DisplayFieldControl extends Control {
3
+ }
@@ -6,16 +6,19 @@ export declare class DropdownDirective implements AfterViewInit, OnDestroy {
6
6
  private renderer;
7
7
  private sirioSelect;
8
8
  constructor(el: ElementRef, renderer: Renderer2, sirioSelect: SirioSelectComponent);
9
- private optionsSubscription?;
10
9
  ngAfterViewInit(): void;
10
+ ngOnInit(): void;
11
11
  ngOnDestroy(): void;
12
12
  private handleValue;
13
13
  private handleSearchable;
14
14
  private handleOptionsChanges;
15
+ private optionsSubscription?;
16
+ private canValidate;
15
17
  private validator;
16
18
  private addValidator;
17
19
  private removeValidator;
18
20
  private validateOptions;
21
+ private refreshValidators;
19
22
  private deactivate;
20
23
  private activate;
21
24
  private onKeyUp;
@@ -6,7 +6,6 @@ import { SanitizeService } from '../services/sanitize.service';
6
6
  import { MarkdownService } from '../services/markdown.service';
7
7
  import { MimeService } from '../services/mime.service';
8
8
  import { ProgrammabilityService } from '../services/programmability.service';
9
- import { EventService } from '../services/event.service';
10
9
  import { WeakService } from '../services/weak.service';
11
10
  import { RegisterService } from '../services/register.service';
12
11
  import { MetadataService } from '../services/metadata.service';
@@ -26,7 +25,6 @@ export declare class DynamicFieldsComponent implements OnInit, AfterViewInit, ID
26
25
  private markdown;
27
26
  private mime;
28
27
  private programmability;
29
- private events;
30
28
  private weak;
31
29
  private register;
32
30
  private metadata;
@@ -315,7 +313,7 @@ export declare class DynamicFieldsComponent implements OnInit, AfterViewInit, ID
315
313
  CloseMenu: string;
316
314
  LoadingFailed: string;
317
315
  };
318
- constructor(sanitizer: SanitizeService, markdown: MarkdownService, mime: MimeService, programmability: ProgrammabilityService, events: EventService, weak: WeakService, register: RegisterService, metadata: MetadataService, languageService: LanguageService, global: GlobalService, formService: FormService, grid: GridService, chart: ChartService, el: ElementRef, cdr: ChangeDetectorRef);
316
+ constructor(sanitizer: SanitizeService, markdown: MarkdownService, mime: MimeService, programmability: ProgrammabilityService, weak: WeakService, register: RegisterService, metadata: MetadataService, languageService: LanguageService, global: GlobalService, formService: FormService, grid: GridService, chart: ChartService, el: ElementRef, cdr: ChangeDetectorRef);
319
317
  ngOnInit(): void;
320
318
  ngAfterViewInit(): void;
321
319
  getRegister(): RegisterService;
@@ -1,7 +1,10 @@
1
1
  import { OnChanges, OnDestroy, SimpleChanges, EventEmitter, ElementRef, Injector } from '@angular/core';
2
2
  import { FormBuilder, FormGroup } from '@angular/forms';
3
3
  import { ProgrammabilityService } from '../services/programmability.service';
4
- import { CommandEvent, EventService } from '../services/event.service';
4
+ import { ValidationService } from '../services/validation.service';
5
+ import { DisableService } from '../services/disable.service';
6
+ import { StatusService } from '../services/status.service';
7
+ import { EventService } from '../services/event.service';
5
8
  import { MetadataService } from '../services/metadata.service';
6
9
  import { FormService } from '../services/form.service';
7
10
  import { DialogService, FormDialogOptions } from '../services/dialog.service';
@@ -13,7 +16,10 @@ import * as i0 from "@angular/core";
13
16
  export declare class DynamicFormComponent implements OnChanges, OnDestroy {
14
17
  private fb;
15
18
  private programmability;
16
- private events;
19
+ private validationService;
20
+ private disableService;
21
+ private statusService;
22
+ private eventService;
17
23
  private registerService;
18
24
  private languageService;
19
25
  private metadata;
@@ -31,10 +37,9 @@ export declare class DynamicFormComponent implements OnChanges, OnDestroy {
31
37
  progressStatus: boolean;
32
38
  valueChange: EventEmitter<any>;
33
39
  initialized: EventEmitter<FormGroup<any>>;
34
- onCommand: EventEmitter<CommandEvent>;
35
40
  activeNavChange: EventEmitter<any>;
36
41
  formDiv: ElementRef<HTMLDivElement>;
37
- constructor(fb: FormBuilder, programmability: ProgrammabilityService, events: EventService, registerService: RegisterService, languageService: LanguageService, metadata: MetadataService, formService: FormService, dialog: DialogService, injector: Injector);
42
+ constructor(fb: FormBuilder, programmability: ProgrammabilityService, validationService: ValidationService, disableService: DisableService, statusService: StatusService, eventService: EventService, registerService: RegisterService, languageService: LanguageService, metadata: MetadataService, formService: FormService, dialog: DialogService, injector: Injector);
38
43
  Texts: {
39
44
  i18n: {
40
45
  it: {
@@ -325,7 +330,7 @@ export declare class DynamicFormComponent implements OnChanges, OnDestroy {
325
330
  set activeNav(value: number);
326
331
  getFormGroup(path: string | null): FormGroup;
327
332
  getFormStatus(form: any, index: number): SirioStepperProgressStatus;
328
- getErrors(form: any): number;
333
+ countInvalids(form: any): number;
329
334
  activateForm(event: NgxSirioEvent<SirioStepperProgressBarComponent>): void;
330
335
  evaluateBoolean(value: boolean | string | null): boolean | null;
331
336
  evaluateTemplate(value: string | null): string;
@@ -338,7 +343,6 @@ export declare class DynamicFormComponent implements OnChanges, OnDestroy {
338
343
  private _forms;
339
344
  private _activeNav;
340
345
  private defaultValue;
341
- private controlMap;
342
346
  private get language();
343
347
  private onChangeSchema;
344
348
  private onChangeValue;
@@ -353,7 +357,6 @@ export declare class DynamicFormComponent implements OnChanges, OnDestroy {
353
357
  private clearHandlers;
354
358
  private buildForm;
355
359
  private addControls;
356
- private getValidationRules;
357
360
  private createFormArray;
358
361
  private resizeFormArray;
359
362
  private hasPath;
@@ -368,5 +371,5 @@ export declare class DynamicFormComponent implements OnChanges, OnDestroy {
368
371
  private getDefaultValue;
369
372
  private splitPath;
370
373
  static ɵfac: i0.ɵɵFactoryDeclaration<DynamicFormComponent, never>;
371
- static ɵcmp: i0.ɵɵComponentDeclaration<DynamicFormComponent, "app-dynamic-form", never, { "schema": { "alias": "schema"; "required": false; }; "formGroup": { "alias": "formGroup"; "required": false; }; "value": { "alias": "value"; "required": false; }; "strict": { "alias": "strict"; "required": false; }; "showNav": { "alias": "showNav"; "required": false; }; "showNavButton": { "alias": "showNavButton"; "required": false; }; "showProgress": { "alias": "showProgress"; "required": false; }; "showFormTitle": { "alias": "showFormTitle"; "required": false; }; "progressStatus": { "alias": "progressStatus"; "required": false; }; "activeNav": { "alias": "activeNav"; "required": false; }; }, { "valueChange": "valueChange"; "initialized": "initialized"; "onCommand": "onCommand"; "activeNavChange": "activeNavChange"; }, never, never, true, never>;
374
+ static ɵcmp: i0.ɵɵComponentDeclaration<DynamicFormComponent, "app-dynamic-form", never, { "schema": { "alias": "schema"; "required": false; }; "formGroup": { "alias": "formGroup"; "required": false; }; "value": { "alias": "value"; "required": false; }; "strict": { "alias": "strict"; "required": false; }; "showNav": { "alias": "showNav"; "required": false; }; "showNavButton": { "alias": "showNavButton"; "required": false; }; "showProgress": { "alias": "showProgress"; "required": false; }; "showFormTitle": { "alias": "showFormTitle"; "required": false; }; "progressStatus": { "alias": "progressStatus"; "required": false; }; "activeNav": { "alias": "activeNav"; "required": false; }; }, { "valueChange": "valueChange"; "initialized": "initialized"; "activeNavChange": "activeNavChange"; }, never, never, true, never>;
372
375
  }
@@ -0,0 +1,21 @@
1
+ import { ProgrammabilityService } from './programmability.service';
2
+ import { FormService } from './form.service';
3
+ import { AbstractControl, FormGroup } from '@angular/forms';
4
+ import * as i0 from "@angular/core";
5
+ export declare class DisableService {
6
+ private programmability;
7
+ private formService;
8
+ constructor(programmability: ProgrammabilityService, formService: FormService);
9
+ createCollection(): DisableCollection;
10
+ addToCollection(collection: DisableCollection, control: AbstractControl, parentGroup: FormGroup, disabled: any): void;
11
+ setupCollection(collection: DisableCollection): void;
12
+ private applyRule;
13
+ private getPath;
14
+ static ɵfac: i0.ɵɵFactoryDeclaration<DisableService, never>;
15
+ static ɵprov: i0.ɵɵInjectableDeclaration<DisableService>;
16
+ }
17
+ export interface DisableContext {
18
+ parentGroup: FormGroup;
19
+ disabled: any;
20
+ }
21
+ export type DisableCollection = Map<AbstractControl, DisableContext>;
@@ -1,15 +1,19 @@
1
- import { FormGroup } from '@angular/forms';
1
+ import { ProgrammabilityService } from '../services/programmability.service';
2
+ import { AbstractControl, FormGroup } from '@angular/forms';
2
3
  import * as i0 from "@angular/core";
3
- export interface CommandEvent {
4
- name: string;
5
- component: any;
6
- formGroup: FormGroup;
7
- event: any;
8
- }
9
4
  export declare class EventService {
10
- private commandSubject;
11
- onCommand: import("rxjs").Observable<CommandEvent>;
12
- emitCommand(data: CommandEvent): void;
5
+ private programmability;
6
+ constructor(programmability: ProgrammabilityService);
7
+ suppress: boolean;
8
+ createCollection(): EventCollection;
9
+ addToCollection(collection: EventCollection, control: AbstractControl, component: any, formGroup: FormGroup): void;
10
+ setupCollection(collection: EventCollection): void;
11
+ private processHandler;
13
12
  static ɵfac: i0.ɵɵFactoryDeclaration<EventService, never>;
14
13
  static ɵprov: i0.ɵɵInjectableDeclaration<EventService>;
15
14
  }
15
+ export interface EventContext {
16
+ component: any;
17
+ formGroup: FormGroup;
18
+ }
19
+ export type EventCollection = Map<AbstractControl, EventContext>;
@@ -28,7 +28,7 @@ export declare class FormService implements IEvaluatorProvider {
28
28
  moveUp(control: AbstractControl, path: Path, index: number): boolean;
29
29
  moveDown(control: AbstractControl, path: Path, index: number): boolean;
30
30
  status(control: AbstractControl, path: Path, pathOptions?: PathOptions): FormControlStatus | undefined;
31
- errors(controls: Iterable<AbstractControl>): number;
31
+ countInvalid(controls: Iterable<AbstractControl>): number;
32
32
  getInvalidControls(control: AbstractControl): {
33
33
  path: string;
34
34
  control: AbstractControl;
@@ -1,5 +1,5 @@
1
1
  import { OnDestroy } from '@angular/core';
2
- import { AbstractControl, FormGroup, ValidatorFn, AsyncValidatorFn } from '@angular/forms';
2
+ import { AbstractControl, FormGroup } from '@angular/forms';
3
3
  import { FeelService } from '../services/feel.service';
4
4
  import { ScopeService } from '../services/scope.service';
5
5
  import { RegisterService } from '../services/register.service';
@@ -10,6 +10,7 @@ import { FormService } from './form.service';
10
10
  import { DialogService } from '../services/dialog.service';
11
11
  import { FormatterService } from '../services/formatter.service';
12
12
  import { WeakService } from '../services/weak.service';
13
+ import { Observable } from "rxjs";
13
14
  import * as i0 from "@angular/core";
14
15
  export declare class ProgrammabilityService implements OnDestroy {
15
16
  private feelService;
@@ -37,10 +38,11 @@ export declare class ProgrammabilityService implements OnDestroy {
37
38
  invalidate(value: string | null): void;
38
39
  watch(formGroup: FormGroup, dependencies: (string | string[])[], callback: () => void): void;
39
40
  getDependencies(expression: string): (string | string[])[];
40
- disable(formGroup: FormGroup, control: AbstractControl, value: boolean | string | null): void;
41
- validate(formGroup: FormGroup, key: string, required?: boolean, validations?: ValidationRule[]): [ValidatorFn[], AsyncValidatorFn[], (control: AbstractControl) => void];
42
- private cacheable;
43
- private verbose;
41
+ subscribeChanges<T>(observable$: Observable<T>, control: AbstractControl, initial: T, callback: (() => void) | ((oldValue: T, newValue: T) => void), logFn?: (control: AbstractControl) => void): void;
42
+ get verbose(): boolean;
43
+ get cacheable(): boolean;
44
+ private _verbose;
45
+ private _cacheable;
44
46
  private onErrorHandler;
45
47
  private Init;
46
48
  private evalUnaryTest;
@@ -59,10 +61,6 @@ export declare class ProgrammabilityService implements OnDestroy {
59
61
  private invalidateExpression;
60
62
  private processDependencies;
61
63
  private getPath;
62
- private validateFn;
63
- private invalidateFn;
64
- private createValidators;
65
- private watchForValidation;
66
64
  static ɵfac: i0.ɵɵFactoryDeclaration<ProgrammabilityService, [null, null, null, null, null, null, null, null, { optional: true; }, { optional: true; }]>;
67
65
  static ɵprov: i0.ɵɵInjectableDeclaration<ProgrammabilityService>;
68
66
  }
@@ -74,8 +72,3 @@ export interface EvaluateOptions {
74
72
  extendContext?: ExtendContextFn;
75
73
  }
76
74
  export type ExtendContextFn = () => Record<string, any>;
77
- export interface ValidationRule {
78
- expression: string;
79
- type: "validate" | "invalidate";
80
- message: string;
81
- }
@@ -0,0 +1,17 @@
1
+ import { FormService } from './form.service';
2
+ import { AbstractControl } from '@angular/forms';
3
+ import { ProgrammabilityService } from '../services/programmability.service';
4
+ import * as i0 from "@angular/core";
5
+ export declare class StatusService {
6
+ private programmability;
7
+ private formService;
8
+ constructor(programmability: ProgrammabilityService, formService: FormService);
9
+ createCollection(): StatusCollection;
10
+ addToCollection(collection: StatusCollection, control: AbstractControl): void;
11
+ setupCollection(key: any, collection: StatusCollection): void;
12
+ countInvalid(key: any): number;
13
+ private invalidMap;
14
+ static ɵfac: i0.ɵɵFactoryDeclaration<StatusService, never>;
15
+ static ɵprov: i0.ɵɵInjectableDeclaration<StatusService>;
16
+ }
17
+ export type StatusCollection = Set<AbstractControl>;
@@ -0,0 +1,36 @@
1
+ import { ProgrammabilityService } from '../services/programmability.service';
2
+ import { AbstractControl, FormGroup } from '@angular/forms';
3
+ import { LanguageService } from '@wemake4u/interact';
4
+ import * as i0 from "@angular/core";
5
+ export declare class ValidationService {
6
+ private languageService;
7
+ private programmability;
8
+ constructor(languageService: LanguageService, programmability: ProgrammabilityService);
9
+ suppress: boolean;
10
+ createCollection(): ValidationCollection;
11
+ addToCollection(collection: ValidationCollection, control: AbstractControl, component: any, formGroup: FormGroup): void;
12
+ setupCollection(collection: ValidationCollection): void;
13
+ private getRules;
14
+ private validateRules;
15
+ private createValidator;
16
+ private createAsyncValidator;
17
+ private validationErrors;
18
+ private watchForValidation;
19
+ private logValidation;
20
+ private readonly nullObserver;
21
+ private get language();
22
+ private locale;
23
+ static ɵfac: i0.ɵɵFactoryDeclaration<ValidationService, never>;
24
+ static ɵprov: i0.ɵɵInjectableDeclaration<ValidationService>;
25
+ }
26
+ export interface ComponentContext {
27
+ component: any;
28
+ formGroup: FormGroup;
29
+ }
30
+ export interface ValidationRule {
31
+ expression: string;
32
+ type: "validate" | "invalidate";
33
+ message: string;
34
+ async: boolean;
35
+ }
36
+ export type ValidationCollection = Map<AbstractControl, ComponentContext>;
@@ -0,0 +1,6 @@
1
+ export declare class CallbackRegistry {
2
+ private callbacks;
3
+ register(callback: () => void): void;
4
+ clear(): void;
5
+ invoke(): void;
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wemake4u/form-player-se",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "peerDependencies": {
5
5
  "@angular/cdk": "^18.2.0",
6
6
  "@angular/common": "^18.2.0",
package/public-api.d.ts CHANGED
@@ -9,6 +9,7 @@ export * from './lib/services/data.service';
9
9
  export * from './lib/services/scope.service';
10
10
  export * from './lib/services/dialog.service';
11
11
  export * from './lib/services/global.service';
12
+ export * from './lib/services/form.service';
12
13
  export * from './lib/interact/confirmation';
13
14
  export * from './lib/interact/notification';
14
15
  export * from './lib/interact/prompt';