@ldquocc/dynamic-form 0.0.9 → 0.0.10
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 +4909 -0
- package/fesm2022/ldquocc-dynamic-form.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/dynamic-form.component.d.ts +67 -0
- package/lib/shared/base/base-select.component.d.ts +19 -0
- package/lib/shared/base/base-value-accessor.d.ts +69 -0
- package/{src/lib/shared/components/component.ts → lib/shared/components/component.d.ts} +14 -34
- package/lib/shared/components/dynamic-field/dynamic-field.component.d.ts +23 -0
- package/lib/shared/components/field-user-config/field-user-config.component.d.ts +10 -0
- package/lib/shared/components/fields/components/suffix/suffix.component.d.ts +12 -0
- package/lib/shared/components/fields/date/date-picker/date-picker.component.d.ts +17 -0
- package/lib/shared/components/fields/date/date-range/date-range.component.d.ts +17 -0
- 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 +12 -0
- package/lib/shared/components/fields/input/input-text/input-text.component.d.ts +14 -0
- package/lib/shared/components/fields/select/multi-select/multi-select.component.d.ts +21 -0
- package/lib/shared/components/fields/select/single-select/single-select.component.d.ts +21 -0
- package/lib/shared/components/fields/select/tree-select/tree-select.component.d.ts +28 -0
- package/lib/shared/components/fields/textarea/textarea.component.d.ts +14 -0
- package/lib/shared/components/fields/upload/avatar-upload/avatar-upload.component.d.ts +25 -0
- package/lib/shared/components/fields/upload/multi-file-upload/multi-file-upload.component.d.ts +76 -0
- package/lib/shared/components/fields/upload/multi-image-upload/multi-image-upload.component.d.ts +27 -0
- package/lib/shared/components/fields/upload/single-file-upload/single-file-upload.component.d.ts +29 -0
- package/lib/shared/config/dynamic-form.config.d.ts +9 -0
- package/lib/shared/consts/common/common.const.d.ts +5 -0
- package/lib/shared/consts/common/field-dependency.const.d.ts +1 -0
- package/lib/shared/consts/common/file.const.d.ts +148 -0
- package/{src/lib/shared/consts/common/index.ts → lib/shared/consts/common/index.d.ts} +4 -4
- package/lib/shared/consts/common/standalone-import.const.d.ts +7 -0
- package/lib/shared/consts/controls/control.const.d.ts +1 -0
- package/{src/lib/shared/consts/controls/index.ts → lib/shared/consts/controls/index.d.ts} +1 -1
- package/lib/shared/consts/fields/date-field.const.d.ts +7 -0
- package/lib/shared/consts/fields/field.const.d.ts +4 -0
- package/{src/lib/shared/consts/fields/index.ts → lib/shared/consts/fields/index.d.ts} +5 -5
- package/lib/shared/consts/fields/input-field.const.d.ts +4 -0
- package/lib/shared/consts/fields/input-formatted-field.const.d.ts +4 -0
- package/lib/shared/consts/fields/radio-field.const.d.ts +10 -0
- package/lib/shared/consts/fields/select-field.const.d.ts +6 -0
- package/lib/shared/consts/fields/upload-field.const.d.ts +1 -0
- package/lib/shared/consts/validators/pattern.const.d.ts +2 -0
- package/lib/shared/enums/common/field-dependency.enum.d.ts +9 -0
- package/lib/shared/enums/common/file-size-type.enum.d.ts +6 -0
- package/{src/lib/shared/enums/common/index.ts → lib/shared/enums/common/index.d.ts} +4 -4
- package/lib/shared/enums/common/output-value-type.enum.d.ts +19 -0
- package/lib/shared/enums/common/view-mode.enum.d.ts +4 -0
- package/lib/shared/enums/controls/control.enum.d.ts +11 -0
- package/{src/lib/shared/enums/controls/index.ts → lib/shared/enums/controls/index.d.ts} +1 -1
- package/lib/shared/enums/fields/date-field.enum.d.ts +4 -0
- package/lib/shared/enums/fields/field.enum.d.ts +20 -0
- package/{src/lib/shared/enums/fields/index.ts → lib/shared/enums/fields/index.d.ts} +6 -6
- package/lib/shared/enums/fields/input-field.enum.d.ts +6 -0
- package/lib/shared/enums/fields/input-formatted-field.enum.d.ts +6 -0
- package/lib/shared/enums/fields/select-field.enum.d.ts +4 -0
- package/lib/shared/enums/fields/upload-field.enum.d.ts +5 -0
- package/lib/shared/enums/form/dynamic-form.enum.d.ts +6 -0
- package/{src/lib/shared/enums/form/index.ts → lib/shared/enums/form/index.d.ts} +1 -1
- package/{src/lib/shared/enums/validators/index.ts → lib/shared/enums/validators/index.d.ts} +2 -2
- package/lib/shared/enums/validators/regex.enum.d.ts +38 -0
- package/lib/shared/enums/validators/validators.enum.d.ts +14 -0
- package/lib/shared/factories/auto-numeric-options.factory.d.ts +5 -0
- package/lib/shared/models/common/api-config.model.d.ts +4 -0
- package/lib/shared/models/common/api-response.model.d.ts +19 -0
- package/lib/shared/models/common/common.model.d.ts +29 -0
- package/lib/shared/models/common/field-dependency.model.d.ts +16 -0
- package/lib/shared/models/common/file-config.model.d.ts +11 -0
- package/{src/lib/shared/models/common/index.ts → lib/shared/models/common/index.d.ts} +7 -7
- package/lib/shared/models/common/obj-field.model.d.ts +59 -0
- package/lib/shared/models/common/object-storage.model.d.ts +15 -0
- package/{src/lib/shared/models/common/output-value-type.model.ts → lib/shared/models/common/output-value-type.model.d.ts} +4 -4
- package/lib/shared/models/common/table-models.d.ts +15 -0
- package/{src/lib/shared/models/common/view-mode.model.ts → lib/shared/models/common/view-mode.model.d.ts} +1 -1
- package/{src/lib/shared/models/controls/control.model.ts → lib/shared/models/controls/control.model.d.ts} +2 -3
- package/{src/lib/shared/models/controls/index.ts → lib/shared/models/controls/index.d.ts} +1 -1
- package/lib/shared/models/fields/date/base-date-field.model.d.ts +19 -0
- package/lib/shared/models/fields/date/date-picker-field.model.d.ts +12 -0
- package/lib/shared/models/fields/date/date-range-field.model.d.ts +12 -0
- package/{src/lib/shared/models/fields/date/index.ts → lib/shared/models/fields/date/index.d.ts} +3 -3
- package/lib/shared/models/fields/field-grid.model.d.ts +9 -0
- package/lib/shared/models/fields/field-group.model.d.ts +21 -0
- package/lib/shared/models/fields/field-user-config.model.d.ts +3 -0
- package/lib/shared/models/fields/field.model.d.ts +57 -0
- package/{src/lib/shared/models/fields/index.ts → lib/shared/models/fields/index.d.ts} +2 -2
- package/{src/lib/shared/models/fields/input/index.ts → lib/shared/models/fields/input/index.d.ts} +4 -4
- package/lib/shared/models/fields/input/input-field.model.d.ts +31 -0
- package/lib/shared/models/fields/input/input-formatted-field.model.d.ts +13 -0
- package/lib/shared/models/fields/input/input-password-field.model.d.ts +11 -0
- package/lib/shared/models/fields/input/input-text-field.model.d.ts +9 -0
- package/lib/shared/models/fields/radio/radio-base-field.model.d.ts +26 -0
- package/lib/shared/models/fields/select/multi-select-field.model.d.ts +11 -0
- package/lib/shared/models/fields/select/select-base-field.model.d.ts +40 -0
- package/lib/shared/models/fields/select/single-select-field.model.d.ts +9 -0
- package/lib/shared/models/fields/select/tree-select-field.model.d.ts +10 -0
- package/lib/shared/models/fields/textarea/textarea-field.model.d.ts +20 -0
- package/lib/shared/models/fields/upload/avatar-upload-field.model.d.ts +9 -0
- package/lib/shared/models/fields/upload/base-upload-field.model.d.ts +25 -0
- package/{src/lib/shared/models/fields/upload/index.ts → lib/shared/models/fields/upload/index.d.ts} +5 -5
- package/lib/shared/models/fields/upload/multi-file-upload-field.model.d.ts +10 -0
- package/lib/shared/models/fields/upload/multi-image-upload-field.model.d.ts +12 -0
- package/lib/shared/models/fields/upload/single-file-upload-field.model.d.ts +11 -0
- package/{src/lib/shared/models/form/dynamic-form.model.ts → lib/shared/models/form/dynamic-form.model.d.ts} +1 -1
- package/{src/lib/shared/models/form/index.ts → lib/shared/models/form/index.d.ts} +1 -1
- package/lib/shared/services/dynamic-form.service.d.ts +48 -0
- package/lib/shared/services/field.service.d.ts +41 -0
- package/lib/shared/services/file.service.d.ts +20 -0
- package/lib/shared/services/form-config.service.d.ts +10 -0
- package/lib/shared/services/form-data.service.d.ts +53 -0
- package/lib/shared/services/form-utils.d.ts +5 -0
- package/lib/shared/services/suffix.service.d.ts +12 -0
- package/lib/shared/services/validation.service.d.ts +10 -0
- package/lib/shared/utils/common/common.utils.d.ts +7 -0
- package/{src/lib/shared/utils/common/index.ts → lib/shared/utils/common/index.d.ts} +1 -1
- package/lib/shared/utils/date/date.utils.d.ts +6 -0
- package/{src/lib/shared/utils/date/index.ts → lib/shared/utils/date/index.d.ts} +1 -1
- package/lib/shared/utils/dynamic-form/dynamic-form.d.ts +11 -0
- package/lib/shared/utils/fields/fields.d.ts +20 -0
- package/{src/lib/shared/utils/fields/index.ts → lib/shared/utils/fields/index.d.ts} +1 -1
- package/lib/shared/utils/file/file.utils.d.ts +4 -0
- package/{src/lib/shared/utils/file/index.ts → lib/shared/utils/file/index.d.ts} +1 -1
- package/lib/shared/utils/validators/custom-validators.d.ts +11 -0
- package/lib/shared/utils/validators/default-error-message.d.ts +6 -0
- package/{src/lib/shared/utils/validators/index.ts → lib/shared/utils/validators/index.d.ts} +3 -3
- package/lib/shared/utils/validators/pattern.d.ts +4 -0
- package/package.json +31 -20
- package/{src/public-api.ts → public-api.d.ts} +29 -68
- package/ng-package.json +0 -15
- package/src/lib/dynamic-form.component.html +0 -121
- package/src/lib/dynamic-form.component.scss +0 -7
- package/src/lib/dynamic-form.component.spec.ts +0 -21
- package/src/lib/dynamic-form.component.ts +0 -237
- package/src/lib/dynamic-form.service.spec.ts +0 -16
- package/src/lib/dynamic-form.service.ts +0 -9
- package/src/lib/shared/base/base-select.component.ts +0 -183
- package/src/lib/shared/base/base-value-accessor.ts +0 -192
- package/src/lib/shared/components/d-form-testing/d-form-testing.component.html +0 -197
- package/src/lib/shared/components/d-form-testing/d-form-testing.component.less +0 -12
- package/src/lib/shared/components/d-form-testing/d-form-testing.component.spec.ts +0 -22
- package/src/lib/shared/components/d-form-testing/d-form-testing.component.ts +0 -197
- package/src/lib/shared/components/dynamic-field/dynamic-field.component.html +0 -218
- package/src/lib/shared/components/dynamic-field/dynamic-field.component.scss +0 -28
- package/src/lib/shared/components/dynamic-field/dynamic-field.component.spec.ts +0 -21
- package/src/lib/shared/components/dynamic-field/dynamic-field.component.ts +0 -67
- package/src/lib/shared/components/field-user-config/field-user-config.component.html +0 -38
- package/src/lib/shared/components/field-user-config/field-user-config.component.scss +0 -29
- package/src/lib/shared/components/field-user-config/field-user-config.component.ts +0 -33
- package/src/lib/shared/components/fields/components/suffix/suffix.component.html +0 -42
- package/src/lib/shared/components/fields/components/suffix/suffix.component.scss +0 -3
- package/src/lib/shared/components/fields/components/suffix/suffix.component.spec.ts +0 -22
- package/src/lib/shared/components/fields/components/suffix/suffix.component.ts +0 -32
- package/src/lib/shared/components/fields/date/date-picker/date-picker.component.html +0 -20
- package/src/lib/shared/components/fields/date/date-picker/date-picker.component.scss +0 -5
- package/src/lib/shared/components/fields/date/date-picker/date-picker.component.spec.ts +0 -21
- package/src/lib/shared/components/fields/date/date-picker/date-picker.component.ts +0 -148
- package/src/lib/shared/components/fields/date/date-range/date-range.component.html +0 -33
- package/src/lib/shared/components/fields/date/date-range/date-range.component.scss +0 -22
- package/src/lib/shared/components/fields/date/date-range/date-range.component.spec.ts +0 -21
- package/src/lib/shared/components/fields/date/date-range/date-range.component.ts +0 -133
- package/src/lib/shared/components/fields/input/input-formatted/input-formatted.component.html +0 -31
- package/src/lib/shared/components/fields/input/input-formatted/input-formatted.component.scss +0 -3
- package/src/lib/shared/components/fields/input/input-formatted/input-formatted.component.spec.ts +0 -21
- package/src/lib/shared/components/fields/input/input-formatted/input-formatted.component.ts +0 -148
- package/src/lib/shared/components/fields/input/input-password/input-password.component.html +0 -18
- package/src/lib/shared/components/fields/input/input-password/input-password.component.scss +0 -0
- package/src/lib/shared/components/fields/input/input-password/input-password.component.spec.ts +0 -21
- package/src/lib/shared/components/fields/input/input-password/input-password.component.ts +0 -56
- package/src/lib/shared/components/fields/input/input-text/input-text.component.html +0 -73
- package/src/lib/shared/components/fields/input/input-text/input-text.component.scss +0 -0
- package/src/lib/shared/components/fields/input/input-text/input-text.component.spec.ts +0 -21
- package/src/lib/shared/components/fields/input/input-text/input-text.component.ts +0 -98
- package/src/lib/shared/components/fields/select/multi-select/multi-select.component.html +0 -73
- package/src/lib/shared/components/fields/select/multi-select/multi-select.component.scss +0 -21
- package/src/lib/shared/components/fields/select/multi-select/multi-select.component.spec.ts +0 -21
- package/src/lib/shared/components/fields/select/multi-select/multi-select.component.ts +0 -212
- package/src/lib/shared/components/fields/select/single-select/single-select.component.html +0 -55
- package/src/lib/shared/components/fields/select/single-select/single-select.component.scss +0 -1
- package/src/lib/shared/components/fields/select/single-select/single-select.component.spec.ts +0 -21
- package/src/lib/shared/components/fields/select/single-select/single-select.component.ts +0 -217
- package/src/lib/shared/components/fields/select/single-select/sl.component.old.txt +0 -337
- package/src/lib/shared/components/fields/select/single-select/sl.component.old2.txt +0 -340
- package/src/lib/shared/components/fields/select/tree-select/tree-select.component.html +0 -38
- package/src/lib/shared/components/fields/select/tree-select/tree-select.component.scss +0 -1
- package/src/lib/shared/components/fields/select/tree-select/tree-select.component.spec.ts +0 -21
- package/src/lib/shared/components/fields/select/tree-select/tree-select.component.ts +0 -401
- package/src/lib/shared/components/fields/textarea/textarea.component.html +0 -29
- package/src/lib/shared/components/fields/textarea/textarea.component.scss +0 -17
- package/src/lib/shared/components/fields/textarea/textarea.component.spec.ts +0 -21
- package/src/lib/shared/components/fields/textarea/textarea.component.ts +0 -76
- package/src/lib/shared/components/fields/upload/avatar-upload/avatar-upload.component.html +0 -30
- package/src/lib/shared/components/fields/upload/avatar-upload/avatar-upload.component.scss +0 -22
- package/src/lib/shared/components/fields/upload/avatar-upload/avatar-upload.component.spec.ts +0 -22
- package/src/lib/shared/components/fields/upload/avatar-upload/avatar-upload.component.ts +0 -217
- package/src/lib/shared/components/fields/upload/multi-file-upload/multi-file-upload.component.html +0 -101
- package/src/lib/shared/components/fields/upload/multi-file-upload/multi-file-upload.component.scss +0 -117
- package/src/lib/shared/components/fields/upload/multi-file-upload/multi-file-upload.component.spec.ts +0 -22
- package/src/lib/shared/components/fields/upload/multi-file-upload/multi-file-upload.component.ts +0 -480
- package/src/lib/shared/components/fields/upload/multi-image-upload/multi-image-upload.component.html +0 -82
- package/src/lib/shared/components/fields/upload/multi-image-upload/multi-image-upload.component.less +0 -80
- package/src/lib/shared/components/fields/upload/multi-image-upload/multi-image-upload.component.spec.ts +0 -22
- package/src/lib/shared/components/fields/upload/multi-image-upload/multi-image-upload.component.ts +0 -288
- package/src/lib/shared/components/fields/upload/single-file-upload/single-file-upload.component.html +0 -104
- package/src/lib/shared/components/fields/upload/single-file-upload/single-file-upload.component.scss +0 -37
- package/src/lib/shared/components/fields/upload/single-file-upload/single-file-upload.component.spec.ts +0 -21
- package/src/lib/shared/components/fields/upload/single-file-upload/single-file-upload.component.ts +0 -317
- package/src/lib/shared/config/dynamic-form.config.ts +0 -11
- package/src/lib/shared/consts/common/common.const.ts +0 -5
- package/src/lib/shared/consts/common/field-dependency.const.ts +0 -1
- package/src/lib/shared/consts/common/file.const.ts +0 -130
- package/src/lib/shared/consts/common/sample-test.const.ts +0 -1648
- package/src/lib/shared/consts/common/standalone-import.const.ts +0 -51
- package/src/lib/shared/consts/controls/control.const.ts +0 -11
- package/src/lib/shared/consts/fields/date-field.const.ts +0 -12
- package/src/lib/shared/consts/fields/field.const.ts +0 -23
- package/src/lib/shared/consts/fields/input-field.const.ts +0 -4
- package/src/lib/shared/consts/fields/input-formatted-field.const.ts +0 -35
- package/src/lib/shared/consts/fields/radio-field.const.ts +0 -31
- package/src/lib/shared/consts/fields/select-field.const.ts +0 -7
- package/src/lib/shared/consts/fields/upload-field.const.ts +0 -1
- package/src/lib/shared/consts/validators/index.ts +0 -0
- package/src/lib/shared/consts/validators/pattern.const.ts +0 -117
- package/src/lib/shared/enums/common/component-ui.enum.ts +0 -8
- package/src/lib/shared/enums/common/field-dependency.enum.ts +0 -10
- package/src/lib/shared/enums/common/file-size-type.enum.ts +0 -6
- package/src/lib/shared/enums/common/output-value-type.enum.ts +0 -22
- package/src/lib/shared/enums/common/view-mode.enum.ts +0 -4
- package/src/lib/shared/enums/controls/control.enum.ts +0 -12
- package/src/lib/shared/enums/fields/date-field.enum.ts +0 -4
- package/src/lib/shared/enums/fields/field.enum.ts +0 -21
- package/src/lib/shared/enums/fields/input-field.enum.ts +0 -6
- package/src/lib/shared/enums/fields/input-formatted-field.enum.ts +0 -6
- package/src/lib/shared/enums/fields/select-field.enum.ts +0 -4
- package/src/lib/shared/enums/fields/upload-field.enum.ts +0 -5
- package/src/lib/shared/enums/form/dynamic-form.enum.ts +0 -6
- package/src/lib/shared/enums/validators/regex.enum.ts +0 -47
- package/src/lib/shared/enums/validators/validators.enum.ts +0 -17
- package/src/lib/shared/factories/auto-numeric-options.factory.ts +0 -14
- package/src/lib/shared/models/common/api-config.model.ts +0 -7
- package/src/lib/shared/models/common/api-response.model.ts +0 -20
- package/src/lib/shared/models/common/common.model.ts +0 -39
- package/src/lib/shared/models/common/field-dependency.model.ts +0 -27
- package/src/lib/shared/models/common/file-config.model.ts +0 -22
- package/src/lib/shared/models/common/obj-field.model.ts +0 -68
- package/src/lib/shared/models/common/object-storage.model.ts +0 -15
- package/src/lib/shared/models/common/table-models.ts +0 -16
- package/src/lib/shared/models/fields/date/base-date-field.model.ts +0 -52
- package/src/lib/shared/models/fields/date/date-picker-field.model.ts +0 -43
- package/src/lib/shared/models/fields/date/date-range-field.model.ts +0 -52
- package/src/lib/shared/models/fields/field-grid.model.ts +0 -10
- package/src/lib/shared/models/fields/field-group.model.ts +0 -50
- package/src/lib/shared/models/fields/field-user-config.model.ts +0 -8
- package/src/lib/shared/models/fields/field.model.ts +0 -184
- package/src/lib/shared/models/fields/input/input-field.model.ts +0 -111
- package/src/lib/shared/models/fields/input/input-formatted-field.model.ts +0 -38
- package/src/lib/shared/models/fields/input/input-password-field.model.ts +0 -38
- package/src/lib/shared/models/fields/input/input-text-field.model.ts +0 -26
- package/src/lib/shared/models/fields/radio/index.ts +0 -0
- package/src/lib/shared/models/fields/radio/radio-base-field.model.ts +0 -84
- package/src/lib/shared/models/fields/select/index.ts +0 -0
- package/src/lib/shared/models/fields/select/multi-select-field.model.ts +0 -46
- package/src/lib/shared/models/fields/select/select-base-field.model.ts +0 -125
- package/src/lib/shared/models/fields/select/single-select-field.model.ts +0 -43
- package/src/lib/shared/models/fields/select/tree-select-field.model.ts +0 -44
- package/src/lib/shared/models/fields/textarea/index.ts +0 -0
- package/src/lib/shared/models/fields/textarea/textarea-field.model.ts +0 -97
- package/src/lib/shared/models/fields/upload/avatar-upload-field.model.ts +0 -33
- package/src/lib/shared/models/fields/upload/base-upload-field.model.ts +0 -105
- package/src/lib/shared/models/fields/upload/multi-file-upload-field.model.ts +0 -34
- package/src/lib/shared/models/fields/upload/multi-image-upload-field.model.ts +0 -42
- package/src/lib/shared/models/fields/upload/single-file-upload-field.model.ts +0 -33
- package/src/lib/shared/models/validations/index.ts +0 -1
- package/src/lib/shared/models/validations/validations.model.ts +0 -14
- package/src/lib/shared/services/dynamic-form.service.spec.ts +0 -16
- package/src/lib/shared/services/dynamic-form.service.ts +0 -251
- package/src/lib/shared/services/field.service.spec.ts +0 -16
- package/src/lib/shared/services/field.service.ts +0 -152
- package/src/lib/shared/services/file.service.spec.ts +0 -16
- package/src/lib/shared/services/file.service.ts +0 -53
- package/src/lib/shared/services/form-config.service.ts +0 -53
- package/src/lib/shared/services/form-data.service.spec.ts +0 -16
- package/src/lib/shared/services/form-data.service.ts +0 -114
- package/src/lib/shared/services/form-utils.ts +0 -52
- package/src/lib/shared/services/suffix.service.spec.ts +0 -16
- package/src/lib/shared/services/suffix.service.ts +0 -16
- package/src/lib/shared/services/validation.service.spec.ts +0 -16
- package/src/lib/shared/services/validation.service.ts +0 -38
- package/src/lib/shared/utils/common/common.utils.ts +0 -52
- package/src/lib/shared/utils/date/date.utils.ts +0 -129
- package/src/lib/shared/utils/dynamic-field/dynamic-field.ts +0 -0
- package/src/lib/shared/utils/dynamic-field/index.ts +0 -0
- package/src/lib/shared/utils/dynamic-form/dynamic-form.ts +0 -114
- package/src/lib/shared/utils/dynamic-form/index.ts +0 -0
- package/src/lib/shared/utils/fields/fields.ts +0 -78
- package/src/lib/shared/utils/file/file.utils.ts +0 -37
- package/src/lib/shared/utils/validators/custom-validators.ts +0 -158
- package/src/lib/shared/utils/validators/default-error-message.ts +0 -42
- package/src/lib/shared/utils/validators/pattern.ts +0 -26
- package/tsconfig.lib.json +0 -15
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -15
- /package/{src/lib/shared/styles → styles}/_common-form.scss +0 -0
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface ApiFileConfig {
|
|
2
|
-
// Upload url để upload file đến máy chủ.
|
|
3
|
-
uploadUrl: string;
|
|
4
|
-
|
|
5
|
-
// Delete url để xóa file khỏi máy chủ.
|
|
6
|
-
deleteUrl: string;
|
|
7
|
-
|
|
8
|
-
uploadByPath?: boolean;
|
|
9
|
-
|
|
10
|
-
uploadPath?: string;
|
|
11
|
-
|
|
12
|
-
isOriginName?: boolean;
|
|
13
|
-
|
|
14
|
-
// Custom upload theo mimeTypes.
|
|
15
|
-
perMimeTypeConfig?: Record<
|
|
16
|
-
string,
|
|
17
|
-
{
|
|
18
|
-
uploadUrl?: string;
|
|
19
|
-
buildFormData?: (file: File, extraParams?: Record<string, any>) => FormData;
|
|
20
|
-
}
|
|
21
|
-
>;
|
|
22
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { RawColumn, TableCellTypeEnum } from './table-models';
|
|
2
|
-
import { BaseField } from '../fields/field.model';
|
|
3
|
-
|
|
4
|
-
export class ObjField {
|
|
5
|
-
required!: number;
|
|
6
|
-
componentUI!: string;
|
|
7
|
-
appliedFields?: string[];
|
|
8
|
-
allowShare: number = 0;
|
|
9
|
-
allowView?: number;
|
|
10
|
-
allowSort?: number;
|
|
11
|
-
allowStatistic?: number;
|
|
12
|
-
code!: string;
|
|
13
|
-
createdAt!: string;
|
|
14
|
-
dataType!: string;
|
|
15
|
-
id!: string;
|
|
16
|
-
name!: string;
|
|
17
|
-
nameEn!: string;
|
|
18
|
-
objClassCode!: string;
|
|
19
|
-
objClassSubCode!: string;
|
|
20
|
-
codeOnDb?: string;
|
|
21
|
-
value?: any;
|
|
22
|
-
apiURL?: string;
|
|
23
|
-
seqNum?: number;
|
|
24
|
-
parentCode?: string;
|
|
25
|
-
parentCondition?: string;
|
|
26
|
-
parentApiBindValue!: string;
|
|
27
|
-
preventEdit?: number;
|
|
28
|
-
minSize?: number;
|
|
29
|
-
maxSize?: number;
|
|
30
|
-
minValue?: string;
|
|
31
|
-
maxValue?: string;
|
|
32
|
-
validateRegex?: string;
|
|
33
|
-
extra?: string; // JSON string khi parse sẽ thành Extra model.
|
|
34
|
-
note?: string;
|
|
35
|
-
transportType?: any;
|
|
36
|
-
iconData?: string;
|
|
37
|
-
objTypeGroupCode?: string;
|
|
38
|
-
viewType?: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface FieldFormConfig {
|
|
42
|
-
formTypes: string[]; // mảng string động, từng giá trị là tên key truy cập cấu hình ở prop configs bên dưới.
|
|
43
|
-
configs: Record<string, BaseField<any>>; // config theo key formType.
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface Extra {
|
|
47
|
-
// form.
|
|
48
|
-
form?: FieldFormConfig;
|
|
49
|
-
|
|
50
|
-
// table.
|
|
51
|
-
table?: Partial<RawColumn> & {
|
|
52
|
-
cellType: TableCellTypeEnum;
|
|
53
|
-
seqNum: number;
|
|
54
|
-
valueConfig?: {
|
|
55
|
-
params: string[];
|
|
56
|
-
body: string;
|
|
57
|
-
};
|
|
58
|
-
subValueConfig?: {
|
|
59
|
-
params: string[];
|
|
60
|
-
body: string;
|
|
61
|
-
};
|
|
62
|
-
dateFormat: string;
|
|
63
|
-
};
|
|
64
|
-
// ..........................
|
|
65
|
-
|
|
66
|
-
// chart.
|
|
67
|
-
// ..........................
|
|
68
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface ObjectStorage {
|
|
2
|
-
id: string;
|
|
3
|
-
uid?: string; // Để xem là phần tử nào trong mảng NzUploadFile
|
|
4
|
-
name?: string;
|
|
5
|
-
contentType?: string;
|
|
6
|
-
size?: number;
|
|
7
|
-
bucket?: string;
|
|
8
|
-
isDir?: boolean;
|
|
9
|
-
createdAt?: string;
|
|
10
|
-
updatedAt?: string;
|
|
11
|
-
path?: string;
|
|
12
|
-
isPublic?: boolean;
|
|
13
|
-
originalName?: string;
|
|
14
|
-
nameAlias?: string;
|
|
15
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export enum TableCellTypeEnum {
|
|
2
|
-
ACTION = 'action',
|
|
3
|
-
CHECK = 'check',
|
|
4
|
-
SUBTEXT = 'subtext',
|
|
5
|
-
IMAGE = 'image',
|
|
6
|
-
BADGE = 'badge',
|
|
7
|
-
INDEX = 'index',
|
|
8
|
-
TEXT = 'text',
|
|
9
|
-
ICON_TEXT = 'icon-text',
|
|
10
|
-
SWAP_FUNC = 'swap',
|
|
11
|
-
EMPTY = 'empty',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface RawColumn {
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { FormControl } from '@angular/forms';
|
|
2
|
-
import { BaseField } from '../field.model';
|
|
3
|
-
import { DATE_FIELD_TYPES } from '../../../consts/fields';
|
|
4
|
-
import { ControlTypeEnum } from '../../../enums/controls';
|
|
5
|
-
|
|
6
|
-
export type DateFieldType = (typeof DATE_FIELD_TYPES)[number];
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Interface base chung cho Các dạng Date.
|
|
10
|
-
*/
|
|
11
|
-
export abstract class BaseDateField<K> extends BaseField<K> {
|
|
12
|
-
// Dạng date hiển thị.
|
|
13
|
-
format: string;
|
|
14
|
-
|
|
15
|
-
// Cho phép chọn ngày quá khứ?
|
|
16
|
-
allowPastDates?: boolean;
|
|
17
|
-
|
|
18
|
-
// Cho phép chọn ngày tương lai?
|
|
19
|
-
allowFutureDates?: boolean;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Props validation chung cho các dạng Date.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
constructor(init: Partial<BaseDateField<K>>) {
|
|
26
|
-
super(init);
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Date.
|
|
30
|
-
*/
|
|
31
|
-
this.controlType = ControlTypeEnum.Date;
|
|
32
|
-
|
|
33
|
-
this.allowPastDates = true;
|
|
34
|
-
this.allowFutureDates = true;
|
|
35
|
-
this.format = 'dd-MM-yyyy';
|
|
36
|
-
|
|
37
|
-
// this.value = undefined;
|
|
38
|
-
|
|
39
|
-
Object.assign(this, init);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Tạo Form Control cho Input Field.
|
|
43
|
-
override toFormControl(): FormControl {
|
|
44
|
-
const commonValidators = this.getCommonValidators();
|
|
45
|
-
const customValidators = this.getCustomValidators();
|
|
46
|
-
return new FormControl(this.value ?? '', [...commonValidators, ...customValidators]);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
abstract override getDefaultValue(): K;
|
|
50
|
-
|
|
51
|
-
abstract override toFormValue(modelValue: unknown): K;
|
|
52
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { DatePickerOutputValueTypeEnum } from '../../../enums/common';
|
|
2
|
-
import { FieldTypeEnum } from '../../../enums/fields';
|
|
3
|
-
import { normalizeToDate } from '../../../utils/date';
|
|
4
|
-
import { DatePickerOutputValueType } from '../../common';
|
|
5
|
-
import { BaseDateField } from './base-date-field.model';
|
|
6
|
-
|
|
7
|
-
const DEFAULT_DATE_PICKER_VALUE = '';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Interface của Date type là Picker.
|
|
11
|
-
*/
|
|
12
|
-
export class DatePickerField extends BaseDateField<string | Date | null> {
|
|
13
|
-
// Dữ liệu sẽ gửi từ form khi submit.
|
|
14
|
-
outputAs!: DatePickerOutputValueType;
|
|
15
|
-
|
|
16
|
-
// Custom function to disable dates
|
|
17
|
-
disabledDateFn?: (current: Date) => boolean;
|
|
18
|
-
|
|
19
|
-
constructor(init: Partial<DatePickerField>) {
|
|
20
|
-
super(init);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Date picker.
|
|
24
|
-
*/
|
|
25
|
-
this.type = FieldTypeEnum.DatePicker;
|
|
26
|
-
this.value = DEFAULT_DATE_PICKER_VALUE;
|
|
27
|
-
this.initialValue = DEFAULT_DATE_PICKER_VALUE;
|
|
28
|
-
this.outputAs = DatePickerOutputValueTypeEnum.String;
|
|
29
|
-
Object.assign(this, init);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
override getDefaultValue(): string | Date {
|
|
33
|
-
return DEFAULT_DATE_PICKER_VALUE;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
override toFormValue(modelValue: unknown): Date | null {
|
|
37
|
-
const value = modelValue as string | Date;
|
|
38
|
-
|
|
39
|
-
if (!value) return null;
|
|
40
|
-
|
|
41
|
-
return normalizeToDate(value);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { DateRangeOutputValueTypeEnum } from "../../../enums/common";
|
|
2
|
-
import { FieldTypeEnum } from "../../../enums/fields";
|
|
3
|
-
import { normalizeToDate } from "../../../utils/date";
|
|
4
|
-
import { DateRangeOutputValueType } from "../../common";
|
|
5
|
-
import { BaseDateField } from "./base-date-field.model";
|
|
6
|
-
|
|
7
|
-
const DEFAULT_DATE_RANGE_VALUE: string[] | Date[] = [];
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Interface của Date type là Range.
|
|
11
|
-
*/
|
|
12
|
-
export class DateRangeField extends BaseDateField<string | string[] | Date[]> {
|
|
13
|
-
// Dữ liệu sẽ gửi từ form khi submit.
|
|
14
|
-
outputAs!: DateRangeOutputValueType;
|
|
15
|
-
|
|
16
|
-
// Placeholder cho Date range (mảng gồm ngày bắt đầu và kết thúc)
|
|
17
|
-
placeholders?: string[];
|
|
18
|
-
|
|
19
|
-
constructor(init: Partial<DateRangeField>) {
|
|
20
|
-
super(init);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Date range.
|
|
24
|
-
*/
|
|
25
|
-
this.type = FieldTypeEnum.DateRange;
|
|
26
|
-
this.value = DEFAULT_DATE_RANGE_VALUE;
|
|
27
|
-
this.initialValue = DEFAULT_DATE_RANGE_VALUE;
|
|
28
|
-
this.outputAs = DateRangeOutputValueTypeEnum.StringArray;
|
|
29
|
-
Object.assign(this, init);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
override getDefaultValue(): string[] | Date[] {
|
|
33
|
-
return DEFAULT_DATE_RANGE_VALUE;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
override toFormValue(modelValue: unknown): string[] | Date[] {
|
|
37
|
-
let value = modelValue as string | string[] | Date[];
|
|
38
|
-
|
|
39
|
-
if (typeof value === "string") {
|
|
40
|
-
value = value.split(",").map((dateStr) => dateStr.trim());
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let dateRange: Date[] = [];
|
|
44
|
-
|
|
45
|
-
if (value?.length === 2) {
|
|
46
|
-
const startDate = normalizeToDate(value[0]);
|
|
47
|
-
const endDate = normalizeToDate(value[1]);
|
|
48
|
-
if (startDate && endDate) dateRange = [startDate, endDate];
|
|
49
|
-
}
|
|
50
|
-
return dateRange;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { EmbeddedProperty } from "ng-zorro-antd/grid";
|
|
2
|
-
|
|
3
|
-
export interface FieldGrid {
|
|
4
|
-
xs?: string | number | EmbeddedProperty | null;
|
|
5
|
-
sm?: string | number | EmbeddedProperty | null;
|
|
6
|
-
md?: string | number | EmbeddedProperty | null;
|
|
7
|
-
lg?: string | number | EmbeddedProperty | null;
|
|
8
|
-
xl?: string | number | EmbeddedProperty | null;
|
|
9
|
-
xxl?: string | number | EmbeddedProperty | null;
|
|
10
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { TemplateRef } from '@angular/core';
|
|
2
|
-
import { BaseField } from './field.model';
|
|
3
|
-
|
|
4
|
-
// Dữ liệu sau khi đã tiến hành xử lý gom nhóm từ fields và groups.
|
|
5
|
-
export class GroupedFields {
|
|
6
|
-
noGroup: BaseField<any>[];
|
|
7
|
-
grouped: {
|
|
8
|
-
group: FieldGroup;
|
|
9
|
-
fields: BaseField<any>[];
|
|
10
|
-
}[];
|
|
11
|
-
|
|
12
|
-
constructor(init: Partial<GroupedFields>) {
|
|
13
|
-
this.noGroup = [];
|
|
14
|
-
this.grouped = [];
|
|
15
|
-
|
|
16
|
-
Object.assign(this, init);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Đại diện cho 1 group.
|
|
21
|
-
export class FieldGroup {
|
|
22
|
-
// Nhãn của nhóm field.
|
|
23
|
-
label!: string;
|
|
24
|
-
|
|
25
|
-
// Mã nhóm field.
|
|
26
|
-
code!: string;
|
|
27
|
-
|
|
28
|
-
template?: TemplateRef<any>;
|
|
29
|
-
|
|
30
|
-
// Thứ tự hiển thị nhóm field.
|
|
31
|
-
order!: number;
|
|
32
|
-
|
|
33
|
-
// Có mở sẵn collapse hay không?
|
|
34
|
-
isActive: boolean;
|
|
35
|
-
|
|
36
|
-
showArrow: boolean;
|
|
37
|
-
|
|
38
|
-
required: boolean;
|
|
39
|
-
|
|
40
|
-
disabled: boolean;
|
|
41
|
-
|
|
42
|
-
constructor(init: Partial<FieldGroup>) {
|
|
43
|
-
this.isActive = false;
|
|
44
|
-
this.showArrow = true;
|
|
45
|
-
this.disabled = false;
|
|
46
|
-
this.required = false;
|
|
47
|
-
|
|
48
|
-
Object.assign(this, init);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface FieldUserConfig {
|
|
2
|
-
// Tại form public, cho phép người dùng bật/tắt required của một field đang thao tác.
|
|
3
|
-
allowOverrideRequired?: boolean;
|
|
4
|
-
|
|
5
|
-
// Sau này có thể mở rộng thêm:
|
|
6
|
-
// allowToggleVisibility?: boolean;
|
|
7
|
-
// allowToggleReadonly?: boolean;
|
|
8
|
-
}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { FormControl, ValidatorFn, Validators } from "@angular/forms";
|
|
2
|
-
import { FIELD_TYPES } from "../../consts/fields";
|
|
3
|
-
import { matchFieldsValidator } from "../../utils/validators/custom-validators";
|
|
4
|
-
import { FieldGrid } from "./field-grid.model";
|
|
5
|
-
import { NzLabelAlignType } from "ng-zorro-antd/form";
|
|
6
|
-
import {
|
|
7
|
-
CommonValidaterEnum,
|
|
8
|
-
CustomValidaterEnum,
|
|
9
|
-
} from "../../enums/validators";
|
|
10
|
-
import { ControlType } from "../controls";
|
|
11
|
-
import { FormMode } from "../form";
|
|
12
|
-
import { FormModeEnum } from "../../enums/form";
|
|
13
|
-
import { uuidGenerator } from "../../utils/common";
|
|
14
|
-
import { ViewMode } from "../common";
|
|
15
|
-
import { ViewModeEnum } from "../../enums/common";
|
|
16
|
-
import { FieldUserConfig } from "../fields/field-user-config.model";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* typeof FIELD_TYPES[number] có nghĩa là:
|
|
20
|
-
- FIELD_TYPES là readonly ['input', 'select', 'checkbox']
|
|
21
|
-
- FIELD_TYPES[number] = FIELD_TYPES[0] | FIELD_TYPES[1] | ... = 'input' | 'select' | 'checkbox'
|
|
22
|
-
=> FieldType = 'input' | 'select' | 'checkbox'
|
|
23
|
-
*/
|
|
24
|
-
export type FieldType = (typeof FIELD_TYPES)[number];
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Abstract class chung cho Field.
|
|
28
|
-
*/
|
|
29
|
-
export abstract class BaseField<T> {
|
|
30
|
-
id: string;
|
|
31
|
-
|
|
32
|
-
// Giá trị Binding với Reactive Form dùng ở formControlName.
|
|
33
|
-
key!: string;
|
|
34
|
-
|
|
35
|
-
// Nhãn hiển thị tên của Field.
|
|
36
|
-
label!: string;
|
|
37
|
-
|
|
38
|
-
// Giá trị của Field.
|
|
39
|
-
value?: T;
|
|
40
|
-
|
|
41
|
-
// Giá trị ban đầu để reset.
|
|
42
|
-
initialValue?: T;
|
|
43
|
-
|
|
44
|
-
// Giá gốc từ model.
|
|
45
|
-
modelValue?: T;
|
|
46
|
-
|
|
47
|
-
// Loại Field: input-text, single-select,...
|
|
48
|
-
type!: FieldType;
|
|
49
|
-
|
|
50
|
-
// Loại control: input, select,... gom nhóm các dạng field.
|
|
51
|
-
controlType!: ControlType;
|
|
52
|
-
|
|
53
|
-
// Nhãn hint.
|
|
54
|
-
placeholder?: string;
|
|
55
|
-
|
|
56
|
-
// Hiển thị text khi hover.
|
|
57
|
-
tooltip?: string;
|
|
58
|
-
|
|
59
|
-
/** Props validation chung */
|
|
60
|
-
required: boolean;
|
|
61
|
-
|
|
62
|
-
/** Props validation custom chung */
|
|
63
|
-
matchField?: string;
|
|
64
|
-
|
|
65
|
-
icon?: string;
|
|
66
|
-
|
|
67
|
-
// Custom error message theo validation props.
|
|
68
|
-
errorMessages?: Record<string, string>;
|
|
69
|
-
|
|
70
|
-
// Grid layout của Field.
|
|
71
|
-
grid: FieldGrid;
|
|
72
|
-
|
|
73
|
-
// Grid layout của Label nằm trong Field.
|
|
74
|
-
labelGrid: FieldGrid;
|
|
75
|
-
|
|
76
|
-
// Vị trí của Label khi ở trong một khối cụ thể.
|
|
77
|
-
labelAlign: NzLabelAlignType;
|
|
78
|
-
|
|
79
|
-
// Grid layout của Control nằm trong Field.
|
|
80
|
-
controlGrid: FieldGrid;
|
|
81
|
-
|
|
82
|
-
// Ẩn field và không thao tác bất kì gì liên quan.
|
|
83
|
-
isHidden: boolean;
|
|
84
|
-
|
|
85
|
-
// Vô hiệu hóa field.
|
|
86
|
-
isDisabled: boolean;
|
|
87
|
-
|
|
88
|
-
// Đánh dấu giá trị của field sẽ cần cho field khác có thuộc tính dependsOn.
|
|
89
|
-
isParent: boolean;
|
|
90
|
-
|
|
91
|
-
// Cho phép gán first data ở cả mode add hoặc edit hay không.
|
|
92
|
-
allowSetValue: FormMode[];
|
|
93
|
-
|
|
94
|
-
// Gom nhóm field theo mã của nhóm. Mã này sẽ config theo code của FieldGroup model và config ở FE.
|
|
95
|
-
groupCode?: string; // Không thuộc nhóm thì bỏ trống hoặc điền None.
|
|
96
|
-
|
|
97
|
-
// Mode view: form (view theo control được disable) hoặc text (chỉ hiện thị text có thể là paragraph). Riêng upload thì không áp dụng vì không phân biệt control.
|
|
98
|
-
viewMode: ViewMode;
|
|
99
|
-
|
|
100
|
-
// Nhãn phu hiển thị tên của Field.
|
|
101
|
-
sublabel?: string;
|
|
102
|
-
|
|
103
|
-
// Thứ tự hiển thị của field
|
|
104
|
-
seqNum: number = 0;
|
|
105
|
-
|
|
106
|
-
// Cho phép field phát sự kiện change khi thay đổi giá trị.
|
|
107
|
-
enableFieldChange: boolean;
|
|
108
|
-
|
|
109
|
-
// Cấu hình các tính năng cho phép người dùng tự thay đổi trên field
|
|
110
|
-
userConfigs?: FieldUserConfig;
|
|
111
|
-
|
|
112
|
-
constructor(init?: Partial<BaseField<T>>) {
|
|
113
|
-
if (!init?.key || !init?.label) {
|
|
114
|
-
throw new Error("key, label, and type are required");
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Gán giá trị cho các props cần giá trị mặc định ở BaseField.
|
|
119
|
-
*/
|
|
120
|
-
this.id = uuidGenerator();
|
|
121
|
-
this.required = false;
|
|
122
|
-
this.grid = { xs: 24 };
|
|
123
|
-
this.labelGrid = { xs: 24 };
|
|
124
|
-
this.controlGrid = { xs: 24 };
|
|
125
|
-
this.labelAlign = "left";
|
|
126
|
-
this.isHidden = false;
|
|
127
|
-
this.isDisabled = false;
|
|
128
|
-
this.isParent = false;
|
|
129
|
-
this.allowSetValue = [
|
|
130
|
-
FormModeEnum.Add,
|
|
131
|
-
FormModeEnum.Edit,
|
|
132
|
-
FormModeEnum.View,
|
|
133
|
-
];
|
|
134
|
-
this.viewMode = ViewModeEnum.form;
|
|
135
|
-
this.enableFieldChange = false;
|
|
136
|
-
|
|
137
|
-
Object.assign(this, init);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Tạo control cho từng loại field.
|
|
141
|
-
abstract toFormControl(): FormControl;
|
|
142
|
-
|
|
143
|
-
// Default value ban đầu cho từng loại field.
|
|
144
|
-
abstract getDefaultValue(): T;
|
|
145
|
-
|
|
146
|
-
abstract toFormValue(modelValue: unknown): T;
|
|
147
|
-
|
|
148
|
-
// Tạo các validate chung cho các props ở abstract. this khi gọi trong class con sẽ đại diện cho đối tượng tạo từ class đó.
|
|
149
|
-
protected getCommonValidators(): ValidatorFn[] {
|
|
150
|
-
const validators: ValidatorFn[] = [];
|
|
151
|
-
|
|
152
|
-
if (this.required) validators.push(Validators.required);
|
|
153
|
-
|
|
154
|
-
return validators;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Tạo các validate custom chung cho các props ở abstract. this khi gọi trong class con sẽ đại diện cho đối tượng tạo từ class đó.
|
|
158
|
-
protected getCustomValidators(): ValidatorFn[] {
|
|
159
|
-
const validators: ValidatorFn[] = [];
|
|
160
|
-
|
|
161
|
-
if (this.matchField) validators.push(matchFieldsValidator(this.matchField));
|
|
162
|
-
|
|
163
|
-
return validators;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
getErrorMessage(
|
|
167
|
-
errorKey: string,
|
|
168
|
-
errorValue: any,
|
|
169
|
-
allFields: BaseField<any>[],
|
|
170
|
-
): string {
|
|
171
|
-
if (errorKey === CommonValidaterEnum.Required) {
|
|
172
|
-
return `${this.label || "Trường này"} là bắt buộc`;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (errorKey === CustomValidaterEnum.MatchField) {
|
|
176
|
-
const matchKey = this.matchField;
|
|
177
|
-
const targetLabel =
|
|
178
|
-
allFields.find((f) => f.key === matchKey)?.label || matchKey;
|
|
179
|
-
return `${this.label} không khớp với ${targetLabel}`;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return "";
|
|
183
|
-
}
|
|
184
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { FormControl, ValidatorFn, Validators } from '@angular/forms';
|
|
2
|
-
import { INPUT_FIELD_TYPES } from '../../../consts/fields/input-field.const';
|
|
3
|
-
import { BaseField } from '../field.model';
|
|
4
|
-
import { noLeadingSpaceValidator } from '../../../utils/validators/custom-validators';
|
|
5
|
-
import { resolvePattern } from '../../../utils/validators/pattern';
|
|
6
|
-
import { CommonValidaterEnum, CustomValidaterEnum } from '../../../enums/validators';
|
|
7
|
-
import {
|
|
8
|
-
getDefaultMaxLengthErrorMessage,
|
|
9
|
-
getDefaultMinLengthErrorMessage,
|
|
10
|
-
getDefaultPatternErrorMessage,
|
|
11
|
-
getLeadingSpaceErrorMessage,
|
|
12
|
-
} from '../../../utils/validators';
|
|
13
|
-
import { ControlTypeEnum } from '../../../enums/controls';
|
|
14
|
-
import { Suffix } from '../../common/common.model';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* typeof FIELD_TYPES[number] có nghĩa là:
|
|
18
|
-
- INPUT_FIELD_TYPES là readonly ['text','email','password','number']
|
|
19
|
-
- INPUT_FIELD_TYPES[number] = INPUT_FIELD_TYPES[0] | INPUT_FIELD_TYPES[1] | ... = 'text' | 'email' | ...
|
|
20
|
-
=> FieldType = 'input' | 'select' | 'checkbox'
|
|
21
|
-
*/
|
|
22
|
-
export type InputFieldType = (typeof INPUT_FIELD_TYPES)[number];
|
|
23
|
-
|
|
24
|
-
const DEFAULT_INPUT_VALUE = '';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Interface base chung cho Các dạng Input Field.
|
|
28
|
-
*/
|
|
29
|
-
export abstract class InputBaseField extends BaseField<string> {
|
|
30
|
-
suffixes: Suffix[];
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Props validation chung cho các dạng Input.
|
|
34
|
-
*/
|
|
35
|
-
// Độ dài tối thiểu của chuỗi nhập vào.
|
|
36
|
-
minLength?: number;
|
|
37
|
-
// Độ dài tối đa của chuỗi nhập vào.
|
|
38
|
-
maxLength?: number;
|
|
39
|
-
// Theo mẫu regex hoặc đối tượng RegExr
|
|
40
|
-
pattern?: string | RegExp;
|
|
41
|
-
|
|
42
|
-
isCurrency: boolean;
|
|
43
|
-
|
|
44
|
-
constructor(init: Partial<InputBaseField>) {
|
|
45
|
-
super(init);
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Input.
|
|
49
|
-
*/
|
|
50
|
-
this.controlType = ControlTypeEnum.Input;
|
|
51
|
-
this.value = DEFAULT_INPUT_VALUE;
|
|
52
|
-
this.initialValue = DEFAULT_INPUT_VALUE;
|
|
53
|
-
this.suffixes = [];
|
|
54
|
-
this.isCurrency = false;
|
|
55
|
-
|
|
56
|
-
Object.assign(this, init);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Mảng ValidatorFn các validation chung được hỗ trợ sẵn bởi Reactive form của angular cho Input.
|
|
60
|
-
protected getInputCommonValidators(): ValidatorFn[] {
|
|
61
|
-
const validators = this.getCommonValidators();
|
|
62
|
-
|
|
63
|
-
if (this.minLength) validators.push(Validators.minLength(this.minLength));
|
|
64
|
-
if (this.maxLength) validators.push(Validators.maxLength(this.maxLength));
|
|
65
|
-
if (this.pattern) {
|
|
66
|
-
const resolvePatternResult = resolvePattern(this.pattern);
|
|
67
|
-
if (resolvePatternResult?.type !== 'unknown')
|
|
68
|
-
validators.push(Validators.pattern(resolvePatternResult.value));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return validators;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Mảng ValidatorFn các custom validation có thể dùng cho Input.
|
|
75
|
-
protected getInputCustomValidators(): ValidatorFn[] {
|
|
76
|
-
const validators = this.getCustomValidators();
|
|
77
|
-
|
|
78
|
-
validators.push(noLeadingSpaceValidator());
|
|
79
|
-
|
|
80
|
-
return validators;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Tạo Form Control cho Input Field.
|
|
84
|
-
override toFormControl(): FormControl {
|
|
85
|
-
const commonValidators = this.getInputCommonValidators();
|
|
86
|
-
const customValidators = this.getInputCustomValidators();
|
|
87
|
-
return new FormControl(this.value ?? '', [...commonValidators, ...customValidators]);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Giá trị mặc định.
|
|
91
|
-
override getDefaultValue(): string {
|
|
92
|
-
return DEFAULT_INPUT_VALUE;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
override toFormValue(modelValue: unknown): string {
|
|
96
|
-
return String(modelValue);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
override getErrorMessage(errorKey: string, errorValue: any, allFields: BaseField<any>[]): string {
|
|
100
|
-
if (errorKey === CommonValidaterEnum.Pattern) {
|
|
101
|
-
if (this.pattern) return getDefaultPatternErrorMessage(this.label, this.pattern);
|
|
102
|
-
}
|
|
103
|
-
if (errorKey === CommonValidaterEnum.MinLength)
|
|
104
|
-
return getDefaultMinLengthErrorMessage(this.label, errorValue);
|
|
105
|
-
if (errorKey === CommonValidaterEnum.MaxLength)
|
|
106
|
-
return getDefaultMaxLengthErrorMessage(this.label, errorValue);
|
|
107
|
-
if (errorKey === CustomValidaterEnum.LeadingSpace)
|
|
108
|
-
return getLeadingSpaceErrorMessage(this.label);
|
|
109
|
-
return super.getErrorMessage(errorKey, errorValue, allFields);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { FormControl } from "@angular/forms";
|
|
2
|
-
import { FieldTypeEnum } from "../../../enums/fields";
|
|
3
|
-
import { InputBaseField } from "./input-field.model";
|
|
4
|
-
import { NumericPreset } from "../../../enums/fields/input-formatted-field.enum";
|
|
5
|
-
import AutoNumeric from "@zeedhi/autonumeric";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Interface của Input Field dạng format.
|
|
9
|
-
*/
|
|
10
|
-
export class InputFormattedField extends InputBaseField {
|
|
11
|
-
// Kiểu định dạng số.
|
|
12
|
-
format: NumericPreset;
|
|
13
|
-
|
|
14
|
-
// Option cho autoNumeric. Có thê custom với dạng format là custom và truyền options từ ngoài vào.
|
|
15
|
-
autoNumericOptions?: Partial<AutoNumeric.Options>;
|
|
16
|
-
|
|
17
|
-
constructor(init: Partial<InputFormattedField>) {
|
|
18
|
-
super(init);
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Gán giá trị cho các props cần giá trị mặc định ở InputFormatted.
|
|
22
|
-
*/
|
|
23
|
-
this.type = FieldTypeEnum.InputFormatted;
|
|
24
|
-
this.format = NumericPreset.Integer;
|
|
25
|
-
|
|
26
|
-
Object.assign(this, init);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Tạo Form Control cho Input Formatted Field.
|
|
30
|
-
override toFormControl(): FormControl {
|
|
31
|
-
const commonValidators = this.getInputCommonValidators();
|
|
32
|
-
const customValidators = this.getInputCustomValidators();
|
|
33
|
-
return new FormControl(this.value ?? "", [
|
|
34
|
-
...commonValidators,
|
|
35
|
-
...customValidators,
|
|
36
|
-
]);
|
|
37
|
-
}
|
|
38
|
-
}
|