ngx-nz-formly 0.0.2 → 0.0.4
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/ng-package.json +7 -0
- package/package.json +18 -31
- package/src/lib/components/nz-formly-button/nz-formly-button.component.html +16 -0
- package/src/lib/components/nz-formly-button/nz-formly-button.component.scss +0 -0
- package/src/lib/components/nz-formly-button/nz-formly-button.component.ts +18 -0
- package/src/lib/components/nz-formly-field-checkbox/nz-formly-field-checkbox.component.html +9 -0
- package/src/lib/components/nz-formly-field-checkbox/nz-formly-field-checkbox.component.scss +8 -0
- package/src/lib/components/nz-formly-field-checkbox/nz-formly-field-checkbox.component.ts +38 -0
- package/src/lib/components/nz-formly-field-input/nz-formly-field-input.component.html +33 -0
- package/src/lib/components/nz-formly-field-input/nz-formly-field-input.component.scss +7 -0
- package/src/lib/components/nz-formly-field-input/nz-formly-field-input.component.ts +118 -0
- package/src/lib/components/nz-formly-field-input/phone-mask.config.ts +1469 -0
- package/src/lib/components/nz-formly-field-radio/nz-formly-field-radio.component.html +32 -0
- package/src/lib/components/nz-formly-field-radio/nz-formly-field-radio.component.scss +0 -0
- package/src/lib/components/nz-formly-field-radio/nz-formly-field-radio.component.ts +44 -0
- package/src/lib/components/nz-formly-field-select/nz-formly-field-select.component.html +54 -0
- package/src/lib/components/nz-formly-field-select/nz-formly-field-select.component.scss +3 -0
- package/src/lib/components/nz-formly-field-select/nz-formly-field-select.component.ts +38 -0
- package/src/lib/components/nz-formly-field-switch/nz-formly-field-switch.component.html +10 -0
- package/src/lib/components/nz-formly-field-switch/nz-formly-field-switch.component.scss +0 -0
- package/src/lib/components/nz-formly-field-switch/nz-formly-field-switch.component.ts +44 -0
- package/src/lib/ngx-nz-formly-props.model.ts +158 -0
- package/src/lib/ngx-nz-formly-type-safe.model.ts +81 -0
- package/src/lib/ngx-nz-formly-validators.ts +92 -0
- package/src/lib/ngx-nz-formly.module.ts +260 -0
- package/src/lib/wrappers/nz-formly-default-wrapper/nz-formly-default-wrapper.component.html +16 -0
- package/src/lib/wrappers/nz-formly-default-wrapper/nz-formly-default-wrapper.component.scss +12 -0
- package/src/lib/wrappers/nz-formly-default-wrapper/nz-formly-default-wrapper.component.ts +25 -0
- package/src/lib/wrappers/nz-formly-label-wrapper/nz-formly-label-wrapper.component.html +27 -0
- package/src/lib/wrappers/nz-formly-label-wrapper/nz-formly-label-wrapper.component.scss +55 -0
- package/src/lib/wrappers/nz-formly-label-wrapper/nz-formly-label-wrapper.component.ts +12 -0
- package/tsconfig.lib.json +14 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
- package/esm2022/lib/components/formly-button/formly-button.component.mjs +0 -21
- package/esm2022/lib/components/formly-field-checkbox/formly-field-checkbox.component.mjs +0 -33
- package/esm2022/lib/components/formly-field-input/formly-field-input.component.mjs +0 -105
- package/esm2022/lib/components/formly-field-input/phone-mask.config.mjs +0 -1463
- package/esm2022/lib/components/formly-field-radio/formly-field-radio.component.mjs +0 -39
- package/esm2022/lib/components/formly-field-select/formly-field-select.component.mjs +0 -34
- package/esm2022/lib/components/formly-field-switch/formly-field-switch.component.mjs +0 -38
- package/esm2022/lib/ngx-nz-formly-props.model.mjs +0 -6
- package/esm2022/lib/ngx-nz-formly-type-safe.model.mjs +0 -44
- package/esm2022/lib/ngx-nz-formly-validators.mjs +0 -52
- package/esm2022/lib/ngx-nz-formly.module.mjs +0 -263
- package/esm2022/lib/wrappers/formly-default-wrapper/formly-default-wrapper.component.mjs +0 -39
- package/esm2022/lib/wrappers/formly-label-wrapper/formly-label-wrapper.component.mjs +0 -13
- package/esm2022/ngx-nz-formly.mjs +0 -5
- package/esm2022/public-api.mjs +0 -5
- package/fesm2022/ngx-nz-formly.mjs +0 -2101
- package/fesm2022/ngx-nz-formly.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/components/formly-button/formly-button.component.d.ts +0 -8
- package/lib/components/formly-field-checkbox/formly-field-checkbox.component.d.ts +0 -13
- package/lib/components/formly-field-input/formly-field-input.component.d.ts +0 -24
- package/lib/components/formly-field-input/phone-mask.config.d.ts +0 -11
- package/lib/components/formly-field-radio/formly-field-radio.component.d.ts +0 -14
- package/lib/components/formly-field-select/formly-field-select.component.d.ts +0 -13
- package/lib/components/formly-field-switch/formly-field-switch.component.d.ts +0 -14
- package/lib/ngx-nz-formly-props.model.d.ts +0 -145
- package/lib/ngx-nz-formly-type-safe.model.d.ts +0 -14
- package/lib/ngx-nz-formly-validators.d.ts +0 -16
- package/lib/ngx-nz-formly.module.d.ts +0 -28
- package/lib/wrappers/formly-default-wrapper/formly-default-wrapper.component.d.ts +0 -7
- package/lib/wrappers/formly-label-wrapper/formly-label-wrapper.component.d.ts +0 -7
- /package/{public-api.d.ts → src/public-api.ts} +0 -0
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,31 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ngx-nz-formly",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"peerDependencies": {
|
|
5
|
-
"@angular/common": "^16.2.0",
|
|
6
|
-
"@angular/core": "^16.2.0",
|
|
7
|
-
"@ngx-formly/core": "6",
|
|
8
|
-
"@ngx-formly/ng-zorro-antd": "6",
|
|
9
|
-
"bootstrap": "^5.2.3",
|
|
10
|
-
"ng-zorro-antd": "^16.1.0",
|
|
11
|
-
"ngx-mask": "^13.1.3",
|
|
12
|
-
"rxjs": "~7.5.0"
|
|
13
|
-
},
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"tslib": "^2.3.0"
|
|
16
|
-
},
|
|
17
|
-
"sideEffects": false
|
|
18
|
-
|
|
19
|
-
"typings": "index.d.ts",
|
|
20
|
-
"exports": {
|
|
21
|
-
"./package.json": {
|
|
22
|
-
"default": "./package.json"
|
|
23
|
-
},
|
|
24
|
-
".": {
|
|
25
|
-
"types": "./index.d.ts",
|
|
26
|
-
"esm2022": "./esm2022/ngx-nz-formly.mjs",
|
|
27
|
-
"esm": "./esm2022/ngx-nz-formly.mjs",
|
|
28
|
-
"default": "./fesm2022/ngx-nz-formly.mjs"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ngx-nz-formly",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^16.2.0",
|
|
6
|
+
"@angular/core": "^16.2.0",
|
|
7
|
+
"@ngx-formly/core": "6",
|
|
8
|
+
"@ngx-formly/ng-zorro-antd": "6",
|
|
9
|
+
"bootstrap": "^5.2.3",
|
|
10
|
+
"ng-zorro-antd": "^16.1.0",
|
|
11
|
+
"ngx-mask": "^13.1.3",
|
|
12
|
+
"rxjs": "~7.5.0"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"tslib": "^2.3.0"
|
|
16
|
+
},
|
|
17
|
+
"sideEffects": false
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<button
|
|
2
|
+
nz-button
|
|
3
|
+
type="button"
|
|
4
|
+
[disabled]="props.disabled"
|
|
5
|
+
[nzGhost]="props.nzGhost"
|
|
6
|
+
[nzLoading]="props.nzLoading"
|
|
7
|
+
[nzShape]="props.nzShape"
|
|
8
|
+
[nzSize]="props.nzSize"
|
|
9
|
+
[nzType]="props.nzType"
|
|
10
|
+
[nzBlock]="props.nzBlock"
|
|
11
|
+
[nzDanger]="props.nzDanger"
|
|
12
|
+
[ngClass]="props.classList"
|
|
13
|
+
(click)="onClick()"
|
|
14
|
+
>
|
|
15
|
+
{{props.text}}
|
|
16
|
+
</button>
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component } from "@angular/core";
|
|
2
|
+
import { FieldType, FormlyFieldConfig } from "@ngx-formly/core";
|
|
3
|
+
import { NzFormlyButtonProps } from "../../ngx-nz-formly-props.model";
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: "app-nz-formly-button",
|
|
7
|
+
templateUrl: "./nz-formly-button.component.html",
|
|
8
|
+
styleUrls: ["./nz-formly-button.component.scss"],
|
|
9
|
+
})
|
|
10
|
+
export class NzFormlyButtonComponent extends FieldType<
|
|
11
|
+
FormlyFieldConfig<NzFormlyButtonProps>
|
|
12
|
+
> {
|
|
13
|
+
onClick() {
|
|
14
|
+
if (typeof this.props?.click == "function") {
|
|
15
|
+
this.props.click();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Component, OnDestroy, OnInit } from "@angular/core";
|
|
2
|
+
import { FieldType, FieldTypeConfig } from "@ngx-formly/core";
|
|
3
|
+
import { NzFormlyCheckboxProps } from "../../ngx-nz-formly-props.model";
|
|
4
|
+
import { Subject, takeUntil, tap } from "rxjs";
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: "app-nz-formly-field-checkbox",
|
|
8
|
+
templateUrl: "./nz-formly-field-checkbox.component.html",
|
|
9
|
+
styleUrls: ["./nz-formly-field-checkbox.component.scss"],
|
|
10
|
+
})
|
|
11
|
+
export class NzFormlyFieldCheckboxComponent
|
|
12
|
+
extends FieldType<FieldTypeConfig<NzFormlyCheckboxProps>>
|
|
13
|
+
implements OnInit, OnDestroy
|
|
14
|
+
{
|
|
15
|
+
unSubscribeAll$ = new Subject<void>();
|
|
16
|
+
|
|
17
|
+
ngOnInit() {
|
|
18
|
+
this.formControl.valueChanges
|
|
19
|
+
.pipe(
|
|
20
|
+
takeUntil(this.unSubscribeAll$),
|
|
21
|
+
tap((value: string) => {
|
|
22
|
+
if (typeof this.props?.change == "function") {
|
|
23
|
+
this.props.change(this.field, value);
|
|
24
|
+
}
|
|
25
|
+
}),
|
|
26
|
+
)
|
|
27
|
+
.subscribe();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get fieldID() {
|
|
31
|
+
return "control-" + this.field.key;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
ngOnDestroy() {
|
|
35
|
+
this.unSubscribeAll$.next();
|
|
36
|
+
this.unSubscribeAll$.complete();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<nz-input-group
|
|
2
|
+
[nzAddOnAfter]="props.nzAddOnAfter"
|
|
3
|
+
[nzAddOnBefore]="props.nzAddOnBefore"
|
|
4
|
+
[nzAddOnAfterIcon]="props.nzAddOnAfterIcon"
|
|
5
|
+
[nzAddOnBeforeIcon]="props.nzAddOnBeforeIcon"
|
|
6
|
+
[nzPrefix]="props.nzPrefix"
|
|
7
|
+
[nzSuffix]="props.nzSuffix"
|
|
8
|
+
[nzSize]="props.nzSize || 'default'"
|
|
9
|
+
>
|
|
10
|
+
<input
|
|
11
|
+
#input
|
|
12
|
+
nz-input
|
|
13
|
+
[id]="fieldID"
|
|
14
|
+
[formControl]="formControl"
|
|
15
|
+
[formlyAttributes]="field"
|
|
16
|
+
[mask]="mask"
|
|
17
|
+
[thousandSeparator]="props.thousandSeparator"
|
|
18
|
+
[type]="type"
|
|
19
|
+
[nzStatus]="status"
|
|
20
|
+
[disabled]="props.disabled"
|
|
21
|
+
[readonly]="props.readonly"
|
|
22
|
+
[placeholder]="props.placeholder"
|
|
23
|
+
[nzBorderless]="props.nzBorderless"
|
|
24
|
+
/>
|
|
25
|
+
<div class="show-password" *ngIf="props.type === 'password'">
|
|
26
|
+
<span
|
|
27
|
+
nz-icon
|
|
28
|
+
nzTheme="outline"
|
|
29
|
+
(click)="changeShowPassword(input)"
|
|
30
|
+
[nzType]="showPassword(input) ? 'eye-invisible' : 'eye'"
|
|
31
|
+
></span>
|
|
32
|
+
</div>
|
|
33
|
+
</nz-input-group>
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { AfterViewInit, Component, OnDestroy } from "@angular/core";
|
|
2
|
+
import { FieldType, FieldTypeConfig } from "@ngx-formly/core";
|
|
3
|
+
import { NzFormlyInputProps } from "../../ngx-nz-formly-props.model";
|
|
4
|
+
import { debounceTime, Subject, takeUntil, tap } from "rxjs";
|
|
5
|
+
import { CountryCodeMask, CountryMasks2 } from "./phone-mask.config";
|
|
6
|
+
|
|
7
|
+
const DefaultPhoneMask: CountryCodeMask = {
|
|
8
|
+
countryShortName: "IR",
|
|
9
|
+
prefix: "+98",
|
|
10
|
+
globalMask: "+00(000)000-0000",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
@Component({
|
|
14
|
+
selector: "app-nz-formly-field-input",
|
|
15
|
+
templateUrl: "./nz-formly-field-input.component.html",
|
|
16
|
+
styleUrls: ["./nz-formly-field-input.component.scss"],
|
|
17
|
+
})
|
|
18
|
+
export class NzFormlyFieldInputComponent
|
|
19
|
+
extends FieldType<FieldTypeConfig<NzFormlyInputProps>>
|
|
20
|
+
implements AfterViewInit, OnDestroy
|
|
21
|
+
{
|
|
22
|
+
mask: string | undefined;
|
|
23
|
+
unSubscribeAll$ = new Subject<void>();
|
|
24
|
+
|
|
25
|
+
ngAfterViewInit() {
|
|
26
|
+
this.createInitState();
|
|
27
|
+
this.onValueChange();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
createInitState() {
|
|
31
|
+
if (this.props.mask === "phone") {
|
|
32
|
+
this.mask = DefaultPhoneMask.globalMask;
|
|
33
|
+
this.handlePhoneMask();
|
|
34
|
+
} else {
|
|
35
|
+
this.mask = this.props.mask;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
handlePhoneMask() {
|
|
40
|
+
this.formControl.valueChanges
|
|
41
|
+
.pipe(
|
|
42
|
+
takeUntil(this.unSubscribeAll$),
|
|
43
|
+
tap((value: string) => {
|
|
44
|
+
if (value == "") {
|
|
45
|
+
// hint: without setTimeout we don't have Ctrl + A -> delete
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
this.mask = DefaultPhoneMask.globalMask;
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
let mask = this.findAppropriateMask(value);
|
|
51
|
+
if (mask && this.mask !== mask.globalMask) {
|
|
52
|
+
this.mask = mask.globalMask?.replace(/#|[1-9]/g, "0");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
)
|
|
57
|
+
.subscribe();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
onValueChange() {
|
|
61
|
+
this.formControl.valueChanges
|
|
62
|
+
.pipe(
|
|
63
|
+
takeUntil(this.unSubscribeAll$),
|
|
64
|
+
debounceTime(300),
|
|
65
|
+
tap((value: string) => {
|
|
66
|
+
if (typeof this.props?.change == "function") {
|
|
67
|
+
this.props.change(this.field, value);
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
)
|
|
71
|
+
.subscribe();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
findAppropriateMask(value: string): CountryCodeMask | null {
|
|
75
|
+
let newMask = CountryMasks2.filter(item =>
|
|
76
|
+
this.exactEquality(value, item.prefix),
|
|
77
|
+
).find(item => value.length <= item.globalMask.length);
|
|
78
|
+
if (newMask) return newMask;
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
exactEquality(str: string, prefix: string): boolean {
|
|
83
|
+
// hint: replace function removes all characters except numbers to return clean numeric string
|
|
84
|
+
// hint: index of convince us to match prefix on first index of input value
|
|
85
|
+
let new_str = str.replace(/[^0-9.]/g, "");
|
|
86
|
+
let new_prefix = prefix.replace(/[^0-9.]/g, "");
|
|
87
|
+
return new_str.indexOf(new_prefix) == 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
changeShowPassword(input: any) {
|
|
91
|
+
if (input.type === "password") {
|
|
92
|
+
input.type = "text";
|
|
93
|
+
} else {
|
|
94
|
+
input.type = "password";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
showPassword(input: any): boolean {
|
|
99
|
+
return input.type === "text";
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
get type() {
|
|
103
|
+
return this.props.type ?? "text";
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get fieldID() {
|
|
107
|
+
return "control-" + this.field.key;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get status() {
|
|
111
|
+
return this.formControl.touched && this.formControl.invalid ? "error" : "";
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
ngOnDestroy() {
|
|
115
|
+
this.unSubscribeAll$.next();
|
|
116
|
+
this.unSubscribeAll$.complete();
|
|
117
|
+
}
|
|
118
|
+
}
|