@rxap/forms 14.0.0 → 14.1.0-dev.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.
@@ -42,8 +42,9 @@ export declare class RxapFormArray<T = any, E extends object = any, Parent exten
42
42
  *
43
43
  * @param index (optional) the index where the control should be created
44
44
  * @param state (optional) the initial state of the new control
45
+ * @param options (optional) ControlEventOptions
45
46
  */
46
- insertAt(index?: number, state?: T): void;
47
+ insertAt(index?: number, state?: T, options?: ControlEventOptions): void;
47
48
  disabledWhile(observable: Observable<boolean>, options?: ControlOptions): Subscription;
48
49
  enabledWhile(observable: Observable<boolean>, options?: ControlOptions): Subscription;
49
50
  mergeValidators(validators: Validator): void;
@@ -54,13 +55,14 @@ export declare class RxapFormArray<T = any, E extends object = any, Parent exten
54
55
  markAllAsUntouched(): void;
55
56
  validateOn(observableValidation: Observable<null | object>): Subscription;
56
57
  hasErrorAndTouched(errorCode: ExtractStrings<E>, path?: ControlPath): boolean;
58
+ private _patchValue;
57
59
  patchValue(valueOrObservable: any, options?: ControlEventOptions): Subscription | void;
58
60
  hasErrorAndDirty(errorCode: ExtractStrings<E>, path?: ControlPath): boolean;
59
61
  removeAt(index: number): void;
60
62
  setEnable(enable?: boolean, opts?: ControlEventOptions): void;
61
- push(control: AbstractControl<T>): void;
63
+ push(control: AbstractControl<T>, options?: ControlEventOptions): void;
62
64
  setDisable(disable?: boolean, opts?: ControlEventOptions): void;
63
- setControl(index: number, control: AbstractControl<T>): void;
65
+ setControl(index: number, control: AbstractControl<T>, options?: ControlEventOptions): void;
64
66
  markAsTouched(opts?: OnlySelf): void;
65
67
  markAsUntouched(opts?: OnlySelf): void;
66
68
  markAsPristine(opts?: OnlySelf): void;
@@ -49,6 +49,7 @@ export declare class RxapFormGroup<T extends Record<string, any> = any, E extend
49
49
  setControl<K extends ExtractStrings<T>>(name: K, control: AbstractControl<T[K]>): void;
50
50
  setValue(valueOrObservable: Observable<T>, options?: ControlEventOptions): Subscription;
51
51
  setValue(valueOrObservable: T, options?: ControlEventOptions): void;
52
+ private _patchValue;
52
53
  patchValue(valueOrObservable: Observable<Partial<T>>, options?: ControlEventOptions): Subscription;
53
54
  patchValue(valueOrObservable: Partial<T>, options?: ControlEventOptions): void;
54
55
  disabledWhile(observable: Observable<boolean>, options?: ControlOptions): Subscription;
package/lib/types.d.ts CHANGED
@@ -20,8 +20,33 @@ export interface ControlOptions {
20
20
  emitModelToViewChange?: boolean;
21
21
  emitViewToModelChange?: boolean;
22
22
  initial?: boolean;
23
+ /**
24
+ * used in the RxapFormArray patchValue method.
25
+ *
26
+ * true - if the value has not a control with any index. The control is created
27
+ * false - default behavior
28
+ */
29
+ coerce?: boolean;
30
+ /**
31
+ * used in the RxapFormArray patchValue method.
32
+ *
33
+ * true - the length of the control array is limited by the length of the value.
34
+ * false - default behavior
35
+ *
36
+ * example with strict = true
37
+ *
38
+ * current from array controls: [ 0: {}, 1: {}, 2: {} ]
39
+ *
40
+ * patch value A: [ 0: {}, 1: {}, 2: {} ]
41
+ * result: [ 0: {}, 1: {}, 2: {} ]
42
+ *
43
+ * path value B: [ 0: {}, 1: {} ]
44
+ * result: [ 0: {}, 1: {} ]
45
+ *
46
+ */
47
+ strict?: boolean;
23
48
  }
24
- export declare type ControlEventOptions = Pick<ControlOptions, 'emitEvent' | 'onlySelf'>;
49
+ export declare type ControlEventOptions = Pick<ControlOptions, 'emitEvent' | 'onlySelf' | 'coerce' | 'strict'>;
25
50
  export declare type OnlySelf = Pick<ControlOptions, 'onlySelf'>;
26
51
  export declare type EmitEvent = Pick<ControlOptions, 'emitEvent'>;
27
52
  export declare type ControlPath = Array<string | number> | string;
@@ -11,6 +11,8 @@ import { IsPhoneNumber } from './is-phone-number';
11
11
  import { IsEmail } from './is-email';
12
12
  import { IsUrl } from './is-url';
13
13
  import { IsIP } from './is-ip';
14
+ import { IsPort } from './is-port';
15
+ import { IsUUID } from './is-uuid';
14
16
  export declare const RxapValidators: {
15
17
  IsNumber: typeof IsNumber;
16
18
  IsBoolean: typeof IsBoolean;
@@ -25,4 +27,6 @@ export declare const RxapValidators: {
25
27
  IsEmail: typeof IsEmail;
26
28
  IsUrl: typeof IsUrl;
27
29
  IsIP: typeof IsIP;
30
+ IsPort: typeof IsPort;
31
+ IsUUID: typeof IsUUID;
28
32
  };
@@ -0,0 +1,4 @@
1
+ import { AbstractControl, ValidationErrors } from '@angular/forms';
2
+ export declare function IsPort({ message }?: {
3
+ message?: string;
4
+ }): (control: AbstractControl) => ValidationErrors | null;
@@ -0,0 +1,5 @@
1
+ import { AbstractControl, ValidationErrors } from '@angular/forms';
2
+ export declare function IsUUID({ message, version }?: {
3
+ message?: string;
4
+ version?: string;
5
+ }): (control: AbstractControl) => ValidationErrors | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxap/forms",
3
- "version": "14.0.0",
3
+ "version": "14.1.0-dev.0",
4
4
  "private": false,
5
5
  "author": "Merzough Münker",
6
6
  "homepage": "https://gitlab.com/rxap/packages/libs/forms",
@@ -25,16 +25,16 @@
25
25
  "@angular/platform-browser": "^14.2.2",
26
26
  "@angular/platform-browser-dynamic": "^14.2.2",
27
27
  "@angular/router": "^14.2.2",
28
- "@rxap/definition": "^13.0.0",
29
- "@rxap/directives": "^13.0.0",
30
- "@rxap/services": "^13.0.0",
31
- "@rxap/utilities": "^13.0.0",
28
+ "@rxap/definition": "^14.0.3",
29
+ "@rxap/directives": "^14.0.3",
30
+ "@rxap/services": "^14.0.5",
31
+ "@rxap/utilities": "^14.1.0-dev.0",
32
32
  "reflect-metadata": "^0.1.13",
33
33
  "rxjs": "^6.6.0"
34
34
  },
35
35
  "dependencies": {
36
36
  "@rxap/schematics-utilities": "^14.0.0",
37
- "@rxap/validator": "^1.0.0",
37
+ "@rxap/validator": "^1.0.2",
38
38
  "ts-morph": "^13.0.3",
39
39
  "tslib": "^2.3.1"
40
40
  },
package/migration.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "schematics": {
3
- "v12-2-1": {
4
- "version": "12.2.1",
5
- "factory": "./src/migrations/v12-2-1/index",
6
- "description": "updates to v12.2.1"
7
- }
8
- },
9
- "$schema": "../../node_modules/@angular-devkit/schematics/collection-schema.json"
10
- }
@@ -1,5 +0,0 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- export declare function CreateEmptyInterface(content: string, className: string): string;
3
- export declare function AddMissingType(content: string): string | null;
4
- export declare function UpdateType(content: string): string | null;
5
- export default function (): Rule;
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UpdateType = exports.AddMissingType = exports.CreateEmptyInterface = void 0;
4
- const ts_morph_1 = require("ts-morph");
5
- function CreateEmptyInterface(content, className) {
6
- var _a;
7
- const project = new ts_morph_1.Project({
8
- manipulationSettings: {
9
- indentationText: ts_morph_1.IndentationText.TwoSpaces,
10
- quoteKind: ts_morph_1.QuoteKind.Single,
11
- },
12
- useInMemoryFileSystem: true,
13
- });
14
- const sourceFile = project.createSourceFile('file.ts', content);
15
- const interfaceStructure = {
16
- name: `I${className}`,
17
- isExported: true,
18
- };
19
- sourceFile.insertInterface(((_a = sourceFile
20
- .getImportDeclarations()
21
- .map((id) => id.getChildIndex())
22
- .sort()
23
- .reverse()[0]) !== null && _a !== void 0 ? _a : -1) + 1, interfaceStructure);
24
- return sourceFile.getFullText();
25
- }
26
- exports.CreateEmptyInterface = CreateEmptyInterface;
27
- function AddMissingType(content) {
28
- const regex = /new RxapFormBuilder\(([^,\)]+)/;
29
- let match = content.match(regex);
30
- if (match) {
31
- while ((match = content.match(regex))) {
32
- const formClass = match[1].trim();
33
- if (!content.includes(`I${formClass}`)) {
34
- content = CreateEmptyInterface(content, formClass);
35
- }
36
- content = content.replace(regex, 'new RxapFormBuilder<I$1>($1');
37
- }
38
- return content;
39
- }
40
- return null;
41
- }
42
- exports.AddMissingType = AddMissingType;
43
- function UpdateType(content) {
44
- const regex = /RxapFormBuilder<([^I][^>]+)>/;
45
- let match = content.match(regex);
46
- if (match) {
47
- while ((match = content.match(regex))) {
48
- const formClass = match[1].trim();
49
- if (!content.includes(`I${formClass}`)) {
50
- content = CreateEmptyInterface(content, formClass);
51
- }
52
- content = content.replace(regex, 'RxapFormBuilder<I$1>');
53
- }
54
- return content;
55
- }
56
- return null;
57
- }
58
- exports.UpdateType = UpdateType;
59
- function default_1() {
60
- return (host) => {
61
- host.visit((path, entry) => {
62
- var _a, _b;
63
- if (entry && path.match(/\.ts$/) && !path.match(/\/node_modules\//)) {
64
- let originalContent;
65
- let content = (originalContent = entry.content.toString('utf-8'));
66
- content = (_a = AddMissingType(content)) !== null && _a !== void 0 ? _a : content;
67
- content = (_b = UpdateType(content)) !== null && _b !== void 0 ? _b : content;
68
- if (originalContent !== content) {
69
- host.overwrite(path, content);
70
- }
71
- }
72
- });
73
- };
74
- }
75
- exports.default = default_1;
76
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/forms/src/migrations/v12-2-1/index.ts"],"names":[],"mappings":";;;AAMA,uCAMkB;AAElB,SAAgB,oBAAoB,CAClC,OAAe,EACf,SAAiB;;IAEjB,MAAM,OAAO,GAAG,IAAI,kBAAO,CAAC;QAC1B,oBAAoB,EAAE;YACpB,eAAe,EAAE,0BAAe,CAAC,SAAS;YAC1C,SAAS,EAAE,oBAAS,CAAC,MAAM;SAC5B;QACD,qBAAqB,EAAE,IAAI;KAC5B,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAChE,MAAM,kBAAkB,GAAgD;QACtE,IAAI,EAAE,IAAI,SAAS,EAAE;QACrB,UAAU,EAAE,IAAI;KACjB,CAAC;IACF,UAAU,CAAC,eAAe,CACxB,CAAC,MAAA,UAAU;SACR,qBAAqB,EAAE;SACvB,GAAG,CAAC,CAAC,EAAE,EAAE,E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