@ldquocc/dynamic-form 0.0.9 → 0.0.11
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 +4928 -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 +22 -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,38 +0,0 @@
|
|
|
1
|
-
import { FormControl, ValidatorFn } from '@angular/forms';
|
|
2
|
-
import { FieldTypeEnum, InputFieldTypeEnum } from '../../../enums/fields';
|
|
3
|
-
import { InputBaseField } from './input-field.model';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Interface của Input Field type là Password.
|
|
7
|
-
*/
|
|
8
|
-
export class InputPasswordField extends InputBaseField {
|
|
9
|
-
constructor(init: Partial<InputPasswordField>) {
|
|
10
|
-
super(init);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Input Password.
|
|
14
|
-
*/
|
|
15
|
-
this.type = FieldTypeEnum.InputPassword;
|
|
16
|
-
|
|
17
|
-
Object.assign(this, init);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Mảng ValidatorFn các validation chung được hỗ trợ sẵn bởi Reactive form của angular cho Input Password.
|
|
21
|
-
protected getInputPasswordCommonValidators(): ValidatorFn[] {
|
|
22
|
-
const validators = this.getInputCommonValidators();
|
|
23
|
-
return validators;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Mảng ValidatorFn các validation chung được hỗ trợ sẵn bởi angular cho Input Password.
|
|
27
|
-
protected getInputPasswordCustomValidators(): ValidatorFn[] {
|
|
28
|
-
const validators = this.getInputCustomValidators();
|
|
29
|
-
return validators;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Tạo Form Control cho Input Password Field.
|
|
33
|
-
override toFormControl(): FormControl {
|
|
34
|
-
const commonValidators = this.getInputPasswordCommonValidators();
|
|
35
|
-
const customValidators = this.getInputPasswordCustomValidators();
|
|
36
|
-
return new FormControl(this.value ?? '', [...commonValidators, ...customValidators]);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FormControl } from '@angular/forms';
|
|
2
|
-
import { FieldTypeEnum } from '../../../enums/fields';
|
|
3
|
-
import { InputBaseField } from './input-field.model';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Interface của Input Field type là Text.
|
|
7
|
-
*/
|
|
8
|
-
export class InputTextField extends InputBaseField {
|
|
9
|
-
constructor(init: Partial<InputTextField>) {
|
|
10
|
-
super(init);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Input Text.
|
|
14
|
-
*/
|
|
15
|
-
this.type = FieldTypeEnum.InputText;
|
|
16
|
-
|
|
17
|
-
Object.assign(this, init);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Tạo Form Control cho Input Text Field.
|
|
21
|
-
override toFormControl(): FormControl {
|
|
22
|
-
const commonValidators = this.getInputCommonValidators();
|
|
23
|
-
const customValidators = this.getInputCustomValidators();
|
|
24
|
-
return new FormControl(this.value ?? '', [...commonValidators, ...customValidators]);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
File without changes
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { FormControl, ValidatorFn } from '@angular/forms';
|
|
2
|
-
import {
|
|
3
|
-
DEFAULT_BIND_LABEL,
|
|
4
|
-
DEFAULT_BIND_VALUE,
|
|
5
|
-
SELECT_FIELD_TYPES,
|
|
6
|
-
} from '../../../consts/fields/select-field.const';
|
|
7
|
-
import { BaseField } from '../field.model';
|
|
8
|
-
import { ApiConfig, FieldDependency } from '../../common';
|
|
9
|
-
import { SelectOutputValueType } from '../../common/output-value-type.model';
|
|
10
|
-
import { SelectOutputValueTypeEnum } from '../../../enums/common';
|
|
11
|
-
import { ControlTypeEnum } from '../../../enums/controls';
|
|
12
|
-
import { FieldTypeEnum } from '../../../enums/fields';
|
|
13
|
-
import { RADIO_FIELD_TYPES } from '../../../consts/fields/radio-field.const';
|
|
14
|
-
|
|
15
|
-
export type RadioFieldType = (typeof RADIO_FIELD_TYPES)[number];
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Interface base chung cho Các dạng Radio.
|
|
19
|
-
*/
|
|
20
|
-
export abstract class RadioBaseField<K, TOptions = Record<string, unknown>> extends BaseField<K> {
|
|
21
|
-
// Key lấy ra nhãn hiển thị ở options.
|
|
22
|
-
bindLabel!: string;
|
|
23
|
-
|
|
24
|
-
// Key lấy ra giá trị ngầm ở options.
|
|
25
|
-
bindValue!: string;
|
|
26
|
-
|
|
27
|
-
// Mảng options cho việc lựa chọn được truyền tĩnh từ config.
|
|
28
|
-
options?: TOptions[];
|
|
29
|
-
|
|
30
|
-
// Cấu hình api nếu danh sách select dựa vào việc gọi api GET. Ưu tiên hơn options tĩnh truyền vào từ config.
|
|
31
|
-
apiConfig?: ApiConfig;
|
|
32
|
-
|
|
33
|
-
// Phụ thuộc vào một giá trị từ bất kỳ dạng field nào khác: Select, Input,...
|
|
34
|
-
dependsOn?: FieldDependency[];
|
|
35
|
-
|
|
36
|
-
// Biến đổi hiển thị option label từ option của options.
|
|
37
|
-
transformLabel?: (option: TOptions) => string;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Props validation chung cho các dạng Radio.
|
|
41
|
-
*/
|
|
42
|
-
// ................. Chưa có .................
|
|
43
|
-
|
|
44
|
-
constructor(init: Partial<RadioBaseField<K, TOptions>>) {
|
|
45
|
-
super(init);
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Radio.
|
|
49
|
-
*/
|
|
50
|
-
this.controlType = ControlTypeEnum.Radio;
|
|
51
|
-
this.bindLabel = DEFAULT_BIND_LABEL;
|
|
52
|
-
this.bindValue = DEFAULT_BIND_VALUE;
|
|
53
|
-
this.dependsOn = [];
|
|
54
|
-
|
|
55
|
-
Object.assign(this, init);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Mảng ValidatorFn các validation chung được hỗ trợ sẵn bởi Reactive form của angular cho Radio.
|
|
59
|
-
protected getCommonSelectValidators(): ValidatorFn[] {
|
|
60
|
-
const validators = this.getCommonValidators();
|
|
61
|
-
return validators;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Mảng ValidatorFn các custom validation có thể dùng cho Radio.
|
|
65
|
-
protected getCustomSelectValidators(): ValidatorFn[] {
|
|
66
|
-
const validators = this.getCustomValidators();
|
|
67
|
-
return validators;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Tạo Form Control cho Input Field.
|
|
71
|
-
override toFormControl(): FormControl {
|
|
72
|
-
const commonValidators = this.getCommonSelectValidators();
|
|
73
|
-
const customValidators = this.getCustomSelectValidators();
|
|
74
|
-
return new FormControl(this.value ?? '', [...commonValidators, ...customValidators]);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
abstract override getDefaultValue(): K;
|
|
78
|
-
|
|
79
|
-
abstract override toFormValue(modelValue: K): K;
|
|
80
|
-
|
|
81
|
-
override getErrorMessage(errorKey: string, errorValue: any, allFields: BaseField<any>[]): string {
|
|
82
|
-
return super.getErrorMessage(errorKey, errorValue, allFields);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
File without changes
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { FieldTypeEnum } from '../../../enums/fields';
|
|
2
|
-
import { SelectBaseField } from './select-base-field.model';
|
|
3
|
-
|
|
4
|
-
const DEFAULT_MULTI_SELECT_VALUE: string[] = [];
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Interface của Select Field type là dạng Multi.
|
|
8
|
-
*/
|
|
9
|
-
export class MultiSelectField extends SelectBaseField<string[] | Record<string, unknown>[]> {
|
|
10
|
-
// Số lựa chọn (option) sẽ được hiển thị khi người dùng chọn nhiều.
|
|
11
|
-
maxTagCount?: number;
|
|
12
|
-
maxMultipleCount?: number;
|
|
13
|
-
|
|
14
|
-
constructor(init: Partial<MultiSelectField>) {
|
|
15
|
-
super(init);
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Multi Select.
|
|
19
|
-
*/
|
|
20
|
-
this.type = FieldTypeEnum.MultiSelect;
|
|
21
|
-
this.value = DEFAULT_MULTI_SELECT_VALUE;
|
|
22
|
-
this.initialValue = DEFAULT_MULTI_SELECT_VALUE;
|
|
23
|
-
this.maxTagCount = 53;
|
|
24
|
-
this.maxMultipleCount = Infinity;
|
|
25
|
-
|
|
26
|
-
Object.assign(this, init);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
override getDefaultValue(): string[] | Record<string, unknown>[] {
|
|
30
|
-
return DEFAULT_MULTI_SELECT_VALUE;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
override toFormValue(modelValue: unknown): string[] | Record<string, unknown>[] {
|
|
34
|
-
const value = modelValue as string[] | Record<string, unknown>[];
|
|
35
|
-
|
|
36
|
-
const optionsValue = value!.map((val: string | number | Record<string, unknown>) => {
|
|
37
|
-
if (typeof val === 'object') {
|
|
38
|
-
let transformVal = (val?.[this.bindValue] as string) ?? '';
|
|
39
|
-
return transformVal;
|
|
40
|
-
}
|
|
41
|
-
return val as string;
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return optionsValue;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { FormControl, ValidatorFn } from "@angular/forms";
|
|
2
|
-
import {
|
|
3
|
-
DEFAULT_BIND_LABEL,
|
|
4
|
-
DEFAULT_BIND_VALUE,
|
|
5
|
-
SELECT_FIELD_TYPES,
|
|
6
|
-
} from "../../../consts/fields/select-field.const";
|
|
7
|
-
import { BaseField } from "../field.model";
|
|
8
|
-
import { ApiConfig, FieldDependency, FieldDependencyType } from "../../common";
|
|
9
|
-
import { SelectOutputValueType } from "../../common/output-value-type.model";
|
|
10
|
-
import {
|
|
11
|
-
DependTypeEnum,
|
|
12
|
-
SelectOutputValueTypeEnum,
|
|
13
|
-
} from "../../../enums/common";
|
|
14
|
-
import { ControlTypeEnum } from "../../../enums/controls";
|
|
15
|
-
import { Suffix } from "../../common/common.model";
|
|
16
|
-
|
|
17
|
-
export type SelectFieldType = (typeof SELECT_FIELD_TYPES)[number];
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Interface base chung cho Các dạng Input Field.
|
|
21
|
-
*/
|
|
22
|
-
export abstract class SelectBaseField<K> extends BaseField<K> {
|
|
23
|
-
// Key lấy ra nhãn hiển thị ở options.
|
|
24
|
-
bindLabel!: string;
|
|
25
|
-
|
|
26
|
-
// Key lấy ra giá trị ngầm ở options.
|
|
27
|
-
bindValue!: string;
|
|
28
|
-
|
|
29
|
-
// Dữ liệu sẽ gửi từ form khi submit.
|
|
30
|
-
outputAs!: SelectOutputValueType;
|
|
31
|
-
|
|
32
|
-
matchSelectWidth: boolean;
|
|
33
|
-
|
|
34
|
-
// Mảng options cho việc lựa chọn được truyền tĩnh từ config.
|
|
35
|
-
options: Record<string, unknown>[];
|
|
36
|
-
|
|
37
|
-
// Luôn chèn vào vị trí 0
|
|
38
|
-
optionsToPrepend: Record<string, unknown>[];
|
|
39
|
-
|
|
40
|
-
// Luôn chèn vào vị trí cuối
|
|
41
|
-
optionsToAppend: Record<string, unknown>[];
|
|
42
|
-
|
|
43
|
-
exceptOptions: Record<string, unknown>[];
|
|
44
|
-
|
|
45
|
-
// Phụ thuộc vào một giá trị từ bất kỳ dạng field nào khác: Select, Input,...
|
|
46
|
-
dependsOn: FieldDependency[];
|
|
47
|
-
|
|
48
|
-
// Cấu hình api nếu danh sách select dựa vào việc gọi api GET. Ưu tiên hơn options tĩnh truyền vào từ config.
|
|
49
|
-
apiConfig?: ApiConfig;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* dependType:
|
|
53
|
-
* - 'all' → cần tất cả field cha có giá trị mới gọi API
|
|
54
|
-
* - 'any' → chỉ cần 1 field cha có giá trị cũng gọi API theo từng cha
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
dependType: FieldDependencyType;
|
|
58
|
-
|
|
59
|
-
// Biến đổi hiển thị option label từ option của options.
|
|
60
|
-
transformLabel?: (option: Record<string, unknown>) => string;
|
|
61
|
-
|
|
62
|
-
// Các nút nằm ở hậu tố (bên phải control).
|
|
63
|
-
suffixes: Suffix[];
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Props validation chung cho các dạng Select.
|
|
67
|
-
*/
|
|
68
|
-
// ................. Chưa có .................
|
|
69
|
-
|
|
70
|
-
constructor(init: Partial<SelectBaseField<K>>) {
|
|
71
|
-
super(init);
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Select.
|
|
75
|
-
*/
|
|
76
|
-
this.controlType = ControlTypeEnum.Select;
|
|
77
|
-
this.bindLabel = DEFAULT_BIND_LABEL;
|
|
78
|
-
this.bindValue = DEFAULT_BIND_VALUE;
|
|
79
|
-
this.matchSelectWidth = true;
|
|
80
|
-
this.outputAs = SelectOutputValueTypeEnum.Object;
|
|
81
|
-
this.dependsOn = [];
|
|
82
|
-
this.dependType = DependTypeEnum.All;
|
|
83
|
-
this.suffixes = [];
|
|
84
|
-
this.optionsToPrepend = [];
|
|
85
|
-
this.optionsToAppend = [];
|
|
86
|
-
this.options = [];
|
|
87
|
-
this.exceptOptions = [];
|
|
88
|
-
|
|
89
|
-
Object.assign(this, init);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Mảng ValidatorFn các validation chung được hỗ trợ sẵn bởi Reactive form của angular cho Select.
|
|
93
|
-
protected getCommonSelectValidators(): ValidatorFn[] {
|
|
94
|
-
const validators = this.getCommonValidators();
|
|
95
|
-
return validators;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Mảng ValidatorFn các custom validation có thể dùng cho Select.
|
|
99
|
-
protected getCustomSelectValidators(): ValidatorFn[] {
|
|
100
|
-
const validators = this.getCustomValidators();
|
|
101
|
-
return validators;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Tạo Form Control cho Input Field.
|
|
105
|
-
override toFormControl(): FormControl {
|
|
106
|
-
const commonValidators = this.getCommonSelectValidators();
|
|
107
|
-
const customValidators = this.getCustomSelectValidators();
|
|
108
|
-
return new FormControl(this.value ?? "", [
|
|
109
|
-
...commonValidators,
|
|
110
|
-
...customValidators,
|
|
111
|
-
]);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
abstract override getDefaultValue(): K;
|
|
115
|
-
|
|
116
|
-
abstract override toFormValue(modelValue: unknown): K;
|
|
117
|
-
|
|
118
|
-
override getErrorMessage(
|
|
119
|
-
errorKey: string,
|
|
120
|
-
errorValue: any,
|
|
121
|
-
allFields: BaseField<any>[],
|
|
122
|
-
): string {
|
|
123
|
-
return super.getErrorMessage(errorKey, errorValue, allFields);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { FieldTypeEnum } from '../../../enums/fields';
|
|
2
|
-
import { SelectBaseField } from './select-base-field.model';
|
|
3
|
-
|
|
4
|
-
const DEFAULT_SINGLE_SELECT_VALUE = null;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Interface của Select Field type là dạng Single.
|
|
8
|
-
*/
|
|
9
|
-
export class SingleSelectField extends SelectBaseField<string | Record<string, unknown> | null> {
|
|
10
|
-
constructor(init: Partial<SingleSelectField>) {
|
|
11
|
-
super(init);
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Single Select.
|
|
15
|
-
*/
|
|
16
|
-
this.type = FieldTypeEnum.SingleSelect;
|
|
17
|
-
this.value = DEFAULT_SINGLE_SELECT_VALUE;
|
|
18
|
-
this.initialValue = DEFAULT_SINGLE_SELECT_VALUE;
|
|
19
|
-
|
|
20
|
-
Object.assign(this, init);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
override getDefaultValue(): string | Record<string, unknown> | null {
|
|
24
|
-
return DEFAULT_SINGLE_SELECT_VALUE;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
override toFormValue(modelValue: unknown): string | Record<string, unknown> | null {
|
|
28
|
-
if (!modelValue) return null;
|
|
29
|
-
const value = modelValue as string | Record<string, unknown>;
|
|
30
|
-
|
|
31
|
-
if (typeof value === 'object') {
|
|
32
|
-
const valueFromObj = value?.[this.bindValue];
|
|
33
|
-
const typeOfValueFromObj = typeof valueFromObj;
|
|
34
|
-
if (typeOfValueFromObj !== 'object') return String(valueFromObj);
|
|
35
|
-
else {
|
|
36
|
-
console.warn('Từ bindValue nhưng đối tượng vẫn là dạng object');
|
|
37
|
-
return '';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return String(value);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { FieldTypeEnum } from '../../../enums/fields';
|
|
2
|
-
import { SelectBaseField } from './select-base-field.model';
|
|
3
|
-
|
|
4
|
-
const DEFAULT_TREE_SELECT_VALUE = null;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Interface của Select Field type là dạng Single.
|
|
8
|
-
*/
|
|
9
|
-
export class TreeSelectField extends SelectBaseField<string | Record<string, unknown> | null> {
|
|
10
|
-
groupBy?: string;
|
|
11
|
-
constructor(init: Partial<TreeSelectField>) {
|
|
12
|
-
super(init);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Single Select.
|
|
16
|
-
*/
|
|
17
|
-
this.type = FieldTypeEnum.TreeSelect;
|
|
18
|
-
this.value = DEFAULT_TREE_SELECT_VALUE;
|
|
19
|
-
this.initialValue = DEFAULT_TREE_SELECT_VALUE;
|
|
20
|
-
|
|
21
|
-
Object.assign(this, init);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
override getDefaultValue(): string | Record<string, unknown> | null {
|
|
25
|
-
return DEFAULT_TREE_SELECT_VALUE;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
override toFormValue(modelValue: unknown): string | Record<string, unknown> | null {
|
|
29
|
-
if (!modelValue) return null;
|
|
30
|
-
const value = modelValue as string | Record<string, unknown>;
|
|
31
|
-
|
|
32
|
-
if (typeof value === 'object') {
|
|
33
|
-
const valueFromObj = value?.[this.bindValue];
|
|
34
|
-
const typeOfValueFromObj = typeof valueFromObj;
|
|
35
|
-
if (typeOfValueFromObj !== 'object') return String(valueFromObj);
|
|
36
|
-
else {
|
|
37
|
-
console.warn('Từ bindValue nhưng đối tượng vẫn là dạng object');
|
|
38
|
-
return '';
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return String(value);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
File without changes
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { FormControl, ValidatorFn, Validators } from '@angular/forms';
|
|
2
|
-
import { FieldTypeEnum } from '../../../enums/fields';
|
|
3
|
-
import { BaseField } from '../field.model';
|
|
4
|
-
import {
|
|
5
|
-
getDefaultMaxLengthErrorMessage,
|
|
6
|
-
getDefaultMinLengthErrorMessage,
|
|
7
|
-
getDefaultPatternErrorMessage,
|
|
8
|
-
getLeadingSpaceErrorMessage,
|
|
9
|
-
noLeadingSpaceValidator,
|
|
10
|
-
resolvePattern,
|
|
11
|
-
} from '../../../utils/validators';
|
|
12
|
-
import { CommonValidaterEnum, CustomValidaterEnum } from '../../../enums/validators';
|
|
13
|
-
import { ControlTypeEnum } from '../../../enums/controls';
|
|
14
|
-
|
|
15
|
-
const DEFAULT_TEXTAREA_VALUE = '';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Interface cho Các dạng Textarea.
|
|
19
|
-
*/
|
|
20
|
-
export class TextareaField extends BaseField<string> {
|
|
21
|
-
/**
|
|
22
|
-
* Props validation chung cho dạng Textarea.
|
|
23
|
-
*/
|
|
24
|
-
// Độ dài tối thiểu của chuỗi nhập vào.
|
|
25
|
-
minLength?: number;
|
|
26
|
-
// Độ dài tối đa của chuỗi nhập vào.
|
|
27
|
-
maxLength?: number;
|
|
28
|
-
// Theo mẫu regex hoặc đối tượng RegExr
|
|
29
|
-
pattern?: string | RegExp;
|
|
30
|
-
|
|
31
|
-
constructor(init: Partial<TextareaField>) {
|
|
32
|
-
super(init);
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Input.
|
|
36
|
-
*/
|
|
37
|
-
this.controlType = ControlTypeEnum.Textarea;
|
|
38
|
-
this.type = FieldTypeEnum.Textarea;
|
|
39
|
-
this.value = DEFAULT_TEXTAREA_VALUE;
|
|
40
|
-
this.initialValue = DEFAULT_TEXTAREA_VALUE;
|
|
41
|
-
|
|
42
|
-
Object.assign(this, init);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Mảng ValidatorFn các validation chung được hỗ trợ sẵn bởi Reactive form của angular cho Input.
|
|
46
|
-
protected getCommonTextareaValidators(): ValidatorFn[] {
|
|
47
|
-
const validators = this.getCommonValidators();
|
|
48
|
-
|
|
49
|
-
if (this.minLength) validators.push(Validators.minLength(this.minLength));
|
|
50
|
-
if (this.maxLength) validators.push(Validators.maxLength(this.maxLength));
|
|
51
|
-
if (this.pattern) {
|
|
52
|
-
const resolvePatternResult = resolvePattern(this.pattern);
|
|
53
|
-
if (resolvePatternResult?.type !== 'unknown')
|
|
54
|
-
validators.push(Validators.pattern(resolvePatternResult.value));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return validators;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Mảng ValidatorFn các custom validation có thể dùng cho Input.
|
|
61
|
-
protected getCustomTextareaValidators(): ValidatorFn[] {
|
|
62
|
-
const validators = this.getCustomValidators();
|
|
63
|
-
|
|
64
|
-
validators.push(noLeadingSpaceValidator());
|
|
65
|
-
|
|
66
|
-
return validators;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Tạo Form Control cho Input Field.
|
|
70
|
-
override toFormControl(): FormControl {
|
|
71
|
-
const commonValidators = this.getCommonTextareaValidators();
|
|
72
|
-
const customValidators = this.getCustomTextareaValidators();
|
|
73
|
-
return new FormControl(this.value ?? '', [...commonValidators, ...customValidators]);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Giá trị mặc định.
|
|
77
|
-
override getDefaultValue(): string {
|
|
78
|
-
return DEFAULT_TEXTAREA_VALUE;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
override toFormValue(modelValue: unknown): string {
|
|
82
|
-
return String(modelValue);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
override getErrorMessage(errorKey: string, errorValue: any, allFields: BaseField<any>[]): string {
|
|
86
|
-
if (errorKey === CommonValidaterEnum.Pattern) {
|
|
87
|
-
if (this.pattern) return getDefaultPatternErrorMessage(this.label, this.pattern);
|
|
88
|
-
}
|
|
89
|
-
if (errorKey === CommonValidaterEnum.MinLength)
|
|
90
|
-
return getDefaultMinLengthErrorMessage(this.label, errorValue);
|
|
91
|
-
if (errorKey === CommonValidaterEnum.MaxLength)
|
|
92
|
-
return getDefaultMaxLengthErrorMessage(this.label, errorValue);
|
|
93
|
-
if (errorKey === CustomValidaterEnum.LeadingSpace)
|
|
94
|
-
return getLeadingSpaceErrorMessage(this.label);
|
|
95
|
-
return super.getErrorMessage(errorKey, errorValue, allFields);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { BaseUploadField } from './base-upload-field.model';
|
|
2
|
-
import { FieldTypeEnum } from '../../../enums/fields';
|
|
3
|
-
import { DEFAULT_ACCEPTED_IMAGE_MIME_TYPES } from '../../../consts/common';
|
|
4
|
-
|
|
5
|
-
const DEFAULT_AVATAR_UPLOAD_VALUE = '';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Interface của Avatar upload.
|
|
9
|
-
*/
|
|
10
|
-
export class AvatarUploadField extends BaseUploadField<string | Record<string, unknown>> {
|
|
11
|
-
constructor(init: Partial<AvatarUploadField>) {
|
|
12
|
-
super(init);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Avatar upload.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
this.type = FieldTypeEnum.AvatarUpload;
|
|
19
|
-
this.value = DEFAULT_AVATAR_UPLOAD_VALUE;
|
|
20
|
-
this.acceptedMimeTypes = DEFAULT_ACCEPTED_IMAGE_MIME_TYPES;
|
|
21
|
-
this.initialValue = DEFAULT_AVATAR_UPLOAD_VALUE;
|
|
22
|
-
|
|
23
|
-
Object.assign(this, init);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
override getDefaultValue(): string | Record<string, unknown> {
|
|
27
|
-
return DEFAULT_AVATAR_UPLOAD_VALUE;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
override toFormValue(modelValue: unknown): string | Record<string, unknown> {
|
|
31
|
-
return String(modelValue);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { FormControl, ValidatorFn } from '@angular/forms';
|
|
2
|
-
import { FieldTypeEnum } from '../../../enums/fields';
|
|
3
|
-
import { BaseField } from '../field.model';
|
|
4
|
-
import { UPLOAD_FIELD_TYPES } from '../../../consts/fields/upload-field.const';
|
|
5
|
-
import { ApiConfig, ApiFileConfig, UploadOutputValueType } from '../../common';
|
|
6
|
-
import {
|
|
7
|
-
acceptedMimeTypesValidator,
|
|
8
|
-
getDefaultAcptMimeTypesErrorMessage,
|
|
9
|
-
getDefaultMaxSizeInMBErrorMessage,
|
|
10
|
-
maxFileSizeInMBValidator,
|
|
11
|
-
} from '../../../utils/validators';
|
|
12
|
-
import { DEFAULT_ACCEPTED_MIME_TYPES } from '../../../consts/common';
|
|
13
|
-
import { CustomValidaterEnum } from '../../../enums/validators';
|
|
14
|
-
import { getExtensions } from '../../../utils/file';
|
|
15
|
-
import { UploadOutputValueTypeEnum } from '../../../enums/common';
|
|
16
|
-
import { ControlTypeEnum } from '../../../enums/controls';
|
|
17
|
-
|
|
18
|
-
export type UploadFieldType = (typeof UPLOAD_FIELD_TYPES)[number];
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Interface base chung cho Các dạng Date.
|
|
22
|
-
*/
|
|
23
|
-
export abstract class BaseUploadField<K> extends BaseField<K> {
|
|
24
|
-
// Dữ liệu sẽ gửi từ form khi submit.
|
|
25
|
-
outputAs!: UploadOutputValueType;
|
|
26
|
-
|
|
27
|
-
// Config api file liên quan: upload, delete.
|
|
28
|
-
apiFileConfig: ApiFileConfig;
|
|
29
|
-
|
|
30
|
-
// Các loại mimetypes được chấp nhận.
|
|
31
|
-
acceptedMimeTypes: string[];
|
|
32
|
-
|
|
33
|
-
// Kích thước tối đa của tập tin tải lên tính bằng MB.
|
|
34
|
-
maxSizeInMB: number;
|
|
35
|
-
|
|
36
|
-
// Hiển thị thông tin hướng dẫn các định dạng file được phép upload theo config của acceptedMimeTypes
|
|
37
|
-
showAcceptedExtensionGuide: boolean;
|
|
38
|
-
|
|
39
|
-
// Mở/tắt cơ chế upload tạm.
|
|
40
|
-
uploadTemp: boolean;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Props validation chung cho các dạng Date.
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
constructor(init: Partial<BaseUploadField<K>>) {
|
|
47
|
-
super(init);
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Gán giá trị cho các props cần giá trị mặc định ở Date.
|
|
51
|
-
*/
|
|
52
|
-
this.controlType = ControlTypeEnum.Upload;
|
|
53
|
-
this.outputAs = UploadOutputValueTypeEnum.Object;
|
|
54
|
-
this.apiFileConfig = {
|
|
55
|
-
uploadUrl: '',
|
|
56
|
-
deleteUrl: '',
|
|
57
|
-
};
|
|
58
|
-
this.acceptedMimeTypes = DEFAULT_ACCEPTED_MIME_TYPES;
|
|
59
|
-
this.maxSizeInMB = 25;
|
|
60
|
-
this.showAcceptedExtensionGuide = true;
|
|
61
|
-
this.uploadTemp = true;
|
|
62
|
-
|
|
63
|
-
Object.assign(this, init);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Mảng ValidatorFn các validation chung được hỗ trợ sẵn bởi angular cho Input Password.
|
|
67
|
-
protected getCustomBaseUploadValidators(): ValidatorFn[] {
|
|
68
|
-
const validators = this.getCustomValidators();
|
|
69
|
-
|
|
70
|
-
// Kiểm tra xem file tải lên có type nằm trong mảng acceptedMimeTypes đã chỉ định hay không.
|
|
71
|
-
if (this.acceptedMimeTypes?.length > 0)
|
|
72
|
-
validators.push(acceptedMimeTypesValidator(this.acceptedMimeTypes));
|
|
73
|
-
|
|
74
|
-
// Kiểm tra kích thước tối đa mà file tải lên được cho phép.
|
|
75
|
-
validators.push(maxFileSizeInMBValidator(this.maxSizeInMB));
|
|
76
|
-
|
|
77
|
-
return validators;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Tạo Form Control cho Input Field.
|
|
81
|
-
override toFormControl(): FormControl {
|
|
82
|
-
const commonValidators = this.getCommonValidators();
|
|
83
|
-
const customValidators = this.getCustomBaseUploadValidators();
|
|
84
|
-
return new FormControl(this.value ?? '', [...commonValidators, ...customValidators]);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
abstract override getDefaultValue(): K;
|
|
88
|
-
|
|
89
|
-
abstract override toFormValue(modelValue: unknown): K;
|
|
90
|
-
|
|
91
|
-
override getErrorMessage(errorKey: string, errorValue: any, allFields: BaseField<any>[]): string {
|
|
92
|
-
// Lấy error message mặc định của acceptedMimeTypes.
|
|
93
|
-
if (errorKey === CustomValidaterEnum.AcceptedMimiTypes) {
|
|
94
|
-
const typeString = getExtensions(this.acceptedMimeTypes).join(', ');
|
|
95
|
-
return getDefaultAcptMimeTypesErrorMessage(typeString);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Lấy error message mặc định của maxSizeInMB.
|
|
99
|
-
if (errorKey === CustomValidaterEnum.MaxSizeInMB) {
|
|
100
|
-
return getDefaultMaxSizeInMBErrorMessage(this.maxSizeInMB);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return super.getErrorMessage(errorKey, errorValue, allFields);
|
|
104
|
-
}
|
|
105
|
-
}
|