@ldquocc/dynamic-form 0.0.6 → 0.0.8
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/fesm2022/ldquocc-dynamic-form.mjs +1013 -716
- package/fesm2022/ldquocc-dynamic-form.mjs.map +1 -1
- package/lib/shared/base/base-select.component.d.ts +19 -0
- package/lib/shared/base/base-value-accessor.d.ts +17 -10
- package/lib/shared/components/component.d.ts +2 -1
- package/lib/shared/components/field-user-config/field-user-config.component.d.ts +10 -0
- package/lib/shared/components/fields/date/date-picker/date-picker.component.d.ts +6 -4
- package/lib/shared/components/fields/date/date-range/date-range.component.d.ts +5 -4
- package/lib/shared/components/fields/input/input-formatted/input-formatted.component.d.ts +20 -0
- package/lib/shared/components/fields/input/input-password/input-password.component.d.ts +4 -3
- package/lib/shared/components/fields/input/input-text/input-text.component.d.ts +5 -5
- package/lib/shared/components/fields/select/multi-select/multi-select.component.d.ts +7 -11
- package/lib/shared/components/fields/select/single-select/single-select.component.d.ts +7 -12
- package/lib/shared/components/fields/select/tree-select/tree-select.component.d.ts +4 -3
- package/lib/shared/components/fields/textarea/textarea.component.d.ts +5 -4
- package/lib/shared/components/fields/upload/avatar-upload/avatar-upload.component.d.ts +12 -14
- package/lib/shared/components/fields/upload/multi-file-upload/multi-file-upload.component.d.ts +2 -4
- package/lib/shared/components/fields/upload/multi-image-upload/multi-image-upload.component.d.ts +10 -11
- package/lib/shared/components/fields/upload/single-file-upload/single-file-upload.component.d.ts +15 -16
- package/lib/shared/consts/common/common.const.d.ts +4 -0
- package/lib/shared/consts/fields/field.const.d.ts +1 -1
- package/lib/shared/consts/fields/index.d.ts +5 -4
- package/lib/shared/consts/fields/input-formatted-field.const.d.ts +4 -0
- package/lib/shared/enums/fields/field.enum.d.ts +1 -0
- package/lib/shared/enums/fields/index.d.ts +6 -5
- package/lib/shared/enums/fields/input-formatted-field.enum.d.ts +6 -0
- package/lib/shared/enums/validators/index.d.ts +2 -1
- package/lib/shared/enums/validators/regex.enum.d.ts +38 -0
- package/lib/shared/factories/auto-numeric-options.factory.d.ts +5 -0
- package/lib/shared/models/common/index.d.ts +7 -7
- package/lib/shared/models/fields/date/date-range-field.model.d.ts +3 -2
- package/lib/shared/models/fields/field-grid.model.d.ts +7 -7
- package/lib/shared/models/fields/field-user-config.model.d.ts +3 -0
- package/lib/shared/models/fields/field.model.d.ts +9 -7
- package/lib/shared/models/fields/index.d.ts +2 -0
- package/lib/shared/models/fields/input/index.d.ts +4 -3
- package/lib/shared/models/fields/input/input-formatted-field.model.d.ts +13 -0
- package/lib/shared/models/fields/select/select-base-field.model.d.ts +6 -6
- package/lib/shared/models/fields/upload/multi-image-upload-field.model.d.ts +1 -1
- package/lib/shared/services/field.service.d.ts +17 -5
- package/lib/shared/utils/dynamic-form/dynamic-form.d.ts +8 -4
- package/package.json +3 -4
- package/public-api.d.ts +2 -2
- package/styles/_common-form.scss +43 -0
- package/lib/shared/models/fields/index.model.d.ts +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { FormControl, ValidatorFn } from
|
|
2
|
-
import { FIELD_TYPES } from
|
|
3
|
-
import { FieldGrid } from
|
|
4
|
-
import { NzLabelAlignType } from
|
|
5
|
-
import { ControlType } from
|
|
6
|
-
import { FormMode } from
|
|
7
|
-
import { ViewMode } from
|
|
1
|
+
import { FormControl, ValidatorFn } from "@angular/forms";
|
|
2
|
+
import { FIELD_TYPES } from "../../consts/fields";
|
|
3
|
+
import { FieldGrid } from "./field-grid.model";
|
|
4
|
+
import { NzLabelAlignType } from "ng-zorro-antd/form";
|
|
5
|
+
import { ControlType } from "../controls";
|
|
6
|
+
import { FormMode } from "../form";
|
|
7
|
+
import { ViewMode } from "../common";
|
|
8
|
+
import { FieldUserConfig } from "../fields/field-user-config.model";
|
|
8
9
|
/**
|
|
9
10
|
* typeof FIELD_TYPES[number] có nghĩa là:
|
|
10
11
|
- FIELD_TYPES là readonly ['input', 'select', 'checkbox']
|
|
@@ -45,6 +46,7 @@ export declare abstract class BaseField<T> {
|
|
|
45
46
|
sublabel?: string;
|
|
46
47
|
seqNum: number;
|
|
47
48
|
enableFieldChange: boolean;
|
|
49
|
+
userConfigs?: FieldUserConfig;
|
|
48
50
|
constructor(init?: Partial<BaseField<T>>);
|
|
49
51
|
abstract toFormControl(): FormControl;
|
|
50
52
|
abstract getDefaultValue(): T;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./input-field.model";
|
|
2
|
+
export * from "./input-text-field.model";
|
|
3
|
+
export * from "./input-password-field.model";
|
|
4
|
+
export * from "./input-formatted-field.model";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FormControl } from "@angular/forms";
|
|
2
|
+
import { InputBaseField } from "./input-field.model";
|
|
3
|
+
import { NumericPreset } from "../../../enums/fields/input-formatted-field.enum";
|
|
4
|
+
import AutoNumeric from "@zeedhi/autonumeric";
|
|
5
|
+
/**
|
|
6
|
+
* Interface của Input Field dạng format.
|
|
7
|
+
*/
|
|
8
|
+
export declare class InputFormattedField extends InputBaseField {
|
|
9
|
+
format: NumericPreset;
|
|
10
|
+
autoNumericOptions?: Partial<AutoNumeric.Options>;
|
|
11
|
+
constructor(init: Partial<InputFormattedField>);
|
|
12
|
+
toFormControl(): FormControl;
|
|
13
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FormControl, ValidatorFn } from
|
|
2
|
-
import { SELECT_FIELD_TYPES } from
|
|
3
|
-
import { BaseField } from
|
|
4
|
-
import { ApiConfig, FieldDependency, FieldDependencyType } from
|
|
5
|
-
import { SelectOutputValueType } from
|
|
6
|
-
import { Suffix } from
|
|
1
|
+
import { FormControl, ValidatorFn } from "@angular/forms";
|
|
2
|
+
import { SELECT_FIELD_TYPES } from "../../../consts/fields/select-field.const";
|
|
3
|
+
import { BaseField } from "../field.model";
|
|
4
|
+
import { ApiConfig, FieldDependency, FieldDependencyType } from "../../common";
|
|
5
|
+
import { SelectOutputValueType } from "../../common/output-value-type.model";
|
|
6
|
+
import { Suffix } from "../../common/common.model";
|
|
7
7
|
export type SelectFieldType = (typeof SELECT_FIELD_TYPES)[number];
|
|
8
8
|
/**
|
|
9
9
|
* Interface base chung cho Các dạng Input Field.
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import { Signal } from
|
|
2
|
-
import { ApiResponse } from
|
|
3
|
-
import { LastChangedParent } from
|
|
1
|
+
import { Signal } from "@angular/core";
|
|
2
|
+
import { ApiResponse } from "../models/common/api-response.model";
|
|
3
|
+
import { LastChangedParent } from "../models/common";
|
|
4
|
+
import { Observable } from "rxjs";
|
|
4
5
|
import * as i0 from "@angular/core";
|
|
5
6
|
export declare class FieldService {
|
|
6
7
|
private httpClient;
|
|
7
|
-
getAllOptions<T = Record<string, unknown>>(apiUrl: string, queryParams: Record<string, unknown>):
|
|
8
|
+
getAllOptions<T = Record<string, unknown>>(apiUrl: string, queryParams: Record<string, unknown>): Observable<ApiResponse<T[]>>;
|
|
8
9
|
private dependValuesMap;
|
|
9
10
|
updateDependValuesMap(key: string, value: string): void;
|
|
10
11
|
getDependValuesMap(): Map<string, Signal<string>>;
|
|
12
|
+
private dependValuesSubjectMap;
|
|
13
|
+
/**
|
|
14
|
+
* Bắn (Emit) giá trị thay đổi của một trường Parent vào stream.
|
|
15
|
+
* Sẽ được gọi bởi Component đóng vai trò là Cha (isParent = true).
|
|
16
|
+
*/
|
|
17
|
+
emitDependValueChange(key: string, value: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Trả về Observable của một trường để các Component Con có thể subscribe/nghe ngóng.
|
|
20
|
+
* Sẽ được gọi bởi các Component có chứa `dependsOn`.
|
|
21
|
+
*/
|
|
22
|
+
getDependValueChanges$(key: string): Observable<string | null>;
|
|
11
23
|
private dependValues;
|
|
12
24
|
updateDependValues(key: string, value: string): void;
|
|
13
25
|
removeDependValues(key: string): void;
|
|
@@ -19,7 +31,7 @@ export declare class FieldService {
|
|
|
19
31
|
getLastChangedParent(): LastChangedParent | null;
|
|
20
32
|
clearLastChangedParent(): void;
|
|
21
33
|
private fieldChange;
|
|
22
|
-
fieldChange$:
|
|
34
|
+
fieldChange$: Observable<{
|
|
23
35
|
key: string;
|
|
24
36
|
value: any;
|
|
25
37
|
}>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { FormGroup } from
|
|
2
|
-
import { BaseField } from
|
|
3
|
-
import { FormMode } from
|
|
4
|
-
import { SelectBaseField } from
|
|
1
|
+
import { FormGroup } from "@angular/forms";
|
|
2
|
+
import { BaseField } from "../../models/fields/field.model";
|
|
3
|
+
import { FormMode } from "../../models/form";
|
|
4
|
+
import { SelectBaseField } from "../../models/fields/select/select-base-field.model";
|
|
5
5
|
export declare const buildForm: (fields: BaseField<any>[], mode: FormMode, model?: Record<string, any>) => FormGroup;
|
|
6
|
+
export declare const createInputPlaceholder: (field: BaseField<any>) => string;
|
|
7
|
+
export declare const createSingleSelectPlaceholder: (field: BaseField<any>) => string;
|
|
8
|
+
export declare const createMultiSelectPlaceholder: (field: BaseField<any>) => string;
|
|
9
|
+
export declare const createDatePickerPlaceholder: (field: BaseField<any>) => string;
|
|
6
10
|
export declare const createPlaceholder: (field: BaseField<any>) => string;
|
|
7
11
|
export declare const createSelectPlaceholder: <K>(field: SelectBaseField<K>) => string;
|
package/package.json
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldquocc/dynamic-form",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/common": "^19.2.0",
|
|
6
6
|
"@angular/core": "^19.2.0",
|
|
7
7
|
"@angular/forms": "^19.2.0",
|
|
8
8
|
"@angular/router": "^19.2.0",
|
|
9
|
-
"@ngx-translate/core": "^16.0.4",
|
|
10
9
|
"ng-zorro-antd": "^19.2.1",
|
|
11
10
|
"ngx-currency": "^19.0.0",
|
|
12
|
-
"ngx-toastr": "^19.0.0",
|
|
13
11
|
"rxjs": "~7.8.0"
|
|
14
12
|
},
|
|
15
13
|
"dependencies": {
|
|
16
14
|
"tslib": "^2.3.0",
|
|
17
15
|
"date-fns": "^2.30.0",
|
|
18
|
-
"lodash-es": "^4.17.21"
|
|
16
|
+
"lodash-es": "^4.17.21",
|
|
17
|
+
"@zeedhi/autonumeric": "^4.6.5"
|
|
19
18
|
},
|
|
20
19
|
"sideEffects": false,
|
|
21
20
|
"module": "fesm2022/ldquocc-dynamic-form.mjs",
|
package/public-api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./lib/shared/models/fields/field.model";
|
|
2
2
|
export * from "./lib/shared/models/fields/field-grid.model";
|
|
3
3
|
export * from "./lib/shared/models/fields/field-group.model";
|
|
4
|
-
export * from "./lib/shared/models/fields/index
|
|
4
|
+
export * from "./lib/shared/models/fields/index";
|
|
5
5
|
export * from "./lib/dynamic-form.component";
|
|
6
6
|
export * from "./lib/shared/config/dynamic-form.config";
|
|
7
7
|
export * from "./lib/shared/services/form-config.service";
|
|
@@ -18,11 +18,11 @@ export * from "./lib/shared/enums/form/index";
|
|
|
18
18
|
export * from "./lib/shared/models/common/index";
|
|
19
19
|
export * from "./lib/shared/models/common/table-models";
|
|
20
20
|
export * from "./lib/shared/models/fields/input/index";
|
|
21
|
+
export * from "./lib/shared/models/fields/input/input-formatted-field.model";
|
|
21
22
|
export * from "./lib/shared/models/fields/textarea/textarea-field.model";
|
|
22
23
|
export * from "./lib/shared/models/fields/date/index";
|
|
23
24
|
export * from "./lib/shared/models/fields/select/select-base-field.model";
|
|
24
25
|
export * from "./lib/shared/models/fields/select/single-select-field.model";
|
|
25
26
|
export * from "./lib/shared/models/fields/select/multi-select-field.model";
|
|
26
|
-
export * from "./lib/shared/models/fields/select/tree-select-field.model";
|
|
27
27
|
export * from "./lib/shared/models/fields/upload/index";
|
|
28
28
|
export * from "./lib/shared/models/fields/radio/radio-base-field.model";
|
package/styles/_common-form.scss
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// @import "@mdi/font/css/materialdesignicons.css";
|
|
2
|
+
|
|
3
|
+
.no-text-info {
|
|
4
|
+
pointer-events: none;
|
|
5
|
+
background-color: white;
|
|
6
|
+
font-size: 12px;
|
|
7
|
+
color: #575757 !important;
|
|
8
|
+
}
|
|
9
|
+
|
|
1
10
|
.w-100 {
|
|
2
11
|
width: 100%;
|
|
3
12
|
}
|
|
@@ -22,6 +31,18 @@
|
|
|
22
31
|
align-items: center;
|
|
23
32
|
}
|
|
24
33
|
|
|
34
|
+
.flex-1 {
|
|
35
|
+
flex: 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.gap-8 {
|
|
39
|
+
gap: 8px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.min-w-0 {
|
|
43
|
+
min-width: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
25
46
|
.mb-0 {
|
|
26
47
|
margin-bottom: 0 !important;
|
|
27
48
|
}
|
|
@@ -29,3 +50,25 @@
|
|
|
29
50
|
.break-work {
|
|
30
51
|
word-break: break-word;
|
|
31
52
|
}
|
|
53
|
+
|
|
54
|
+
.text-white {
|
|
55
|
+
color: #ffffff !important;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.fs-12 {
|
|
59
|
+
font-size: 12px !important;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.pointer {
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.text-danger {
|
|
67
|
+
color: #eb0c0c;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.modeView {
|
|
71
|
+
pointer-events: none;
|
|
72
|
+
color: #575757;
|
|
73
|
+
// font-size: 12px;
|
|
74
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './field.model';
|