@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,212 +0,0 @@
|
|
|
1
|
-
import { Component, computed, forwardRef, untracked } from "@angular/core";
|
|
2
|
-
import { CORE_MODULES, FORM_MODULES } from "../../../../consts/common";
|
|
3
|
-
import { NG_VALUE_ACCESSOR } from "@angular/forms";
|
|
4
|
-
import { BaseSelectComponent } from "../../../../base/base-select.component";
|
|
5
|
-
import { MultiSelectField } from "../../../../models/fields/select/multi-select-field.model";
|
|
6
|
-
import { createMultiSelectPlaceholder } from "../../../../utils/dynamic-form/dynamic-form";
|
|
7
|
-
import { SelectOutputValueTypeEnum } from "../../../../enums/common";
|
|
8
|
-
import { NO_INFO_TEXT } from "../../../../consts/common/common.const";
|
|
9
|
-
import { FieldTypeEnum } from "../../../../enums/fields";
|
|
10
|
-
import { ControlTypeEnum } from "../../../../enums/controls";
|
|
11
|
-
import { SuffixComponent } from "../../components/suffix/suffix.component";
|
|
12
|
-
import { NzSelectModule } from "ng-zorro-antd/select";
|
|
13
|
-
import { NzInputModule } from "ng-zorro-antd/input";
|
|
14
|
-
import { NzSpinModule } from "ng-zorro-antd/spin";
|
|
15
|
-
|
|
16
|
-
const ZORRO_MODULES = [NzSelectModule, NzInputModule, NzSpinModule];
|
|
17
|
-
const COMPONENTS = [SuffixComponent];
|
|
18
|
-
|
|
19
|
-
@Component({
|
|
20
|
-
selector: "app-multi-select",
|
|
21
|
-
standalone: true,
|
|
22
|
-
imports: [...CORE_MODULES, ...FORM_MODULES, ...ZORRO_MODULES, ...COMPONENTS],
|
|
23
|
-
templateUrl: "./multi-select.component.html",
|
|
24
|
-
styleUrls: ["./multi-select.component.scss"],
|
|
25
|
-
providers: [
|
|
26
|
-
{
|
|
27
|
-
provide: NG_VALUE_ACCESSOR,
|
|
28
|
-
useExisting: forwardRef(() => MultiSelectComponent),
|
|
29
|
-
multi: true,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
})
|
|
33
|
-
export class MultiSelectComponent extends BaseSelectComponent<
|
|
34
|
-
string[] | number[] | Record<string, unknown>[]
|
|
35
|
-
> {
|
|
36
|
-
readonly field = computed(() => {
|
|
37
|
-
const base = this.fieldInput();
|
|
38
|
-
if (
|
|
39
|
-
!(base instanceof MultiSelectField) ||
|
|
40
|
-
(base.type !== FieldTypeEnum.MultiSelect &&
|
|
41
|
-
base.controlType !== ControlTypeEnum.Select)
|
|
42
|
-
) {
|
|
43
|
-
throw new Error("Expected MultiSelectField");
|
|
44
|
-
}
|
|
45
|
-
return base;
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
displayNoValueText = NO_INFO_TEXT;
|
|
49
|
-
|
|
50
|
-
// Biến đổi dữ liệu hiển thị ở chế độ View
|
|
51
|
-
viewDisplayValue = computed(() => {
|
|
52
|
-
if (!this.isView()) return [];
|
|
53
|
-
console.log("viewDisplayValue", this.field().modelValue || []);
|
|
54
|
-
|
|
55
|
-
return this.getDisplayValue(this.field().modelValue || []);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
constructor() {
|
|
59
|
-
super();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
protected override onApiOptionsLoaded(): void {
|
|
63
|
-
const field = this.field();
|
|
64
|
-
if (field.outputAs === SelectOutputValueTypeEnum.SourceObject) {
|
|
65
|
-
const newOutputValue =
|
|
66
|
-
this.value && this.getValueByOutputAs(this.value as string[]);
|
|
67
|
-
this.patchFormData(this.fieldKey(), newOutputValue);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Xử lý tạo placeholder text tự động nếu chưa truyền placeholder vào config của field
|
|
72
|
-
override resolvePlaceholderText(): string {
|
|
73
|
-
return createMultiSelectPlaceholder(this.field());
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
handleChangeOptions(optionValue: string[]): void {
|
|
77
|
-
this.propagateValue(optionValue);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Chạy khi value form được gán bởi các hàm reset, patchValue, setValue.
|
|
81
|
-
protected override writeValueToView(value: string[]): void {
|
|
82
|
-
if (!this.isAddOrEdit()) return;
|
|
83
|
-
|
|
84
|
-
this.fieldService.emitDependValueChange(
|
|
85
|
-
this.fieldKey(),
|
|
86
|
-
value.length ? value.join(",") : "",
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
// Gán data vào đầu ra của form.
|
|
90
|
-
const newOutputValue = value && this.getValueByOutputAs(value);
|
|
91
|
-
this.patchFormData(this.fieldKey(), newOutputValue);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Xử lý phụ thuộc khi change value
|
|
95
|
-
protected override handleValueChange(value: string[]): void {
|
|
96
|
-
const { isParent } = this.field();
|
|
97
|
-
if (isParent) {
|
|
98
|
-
console.log("cscs");
|
|
99
|
-
|
|
100
|
-
this.fieldService.emitDependValueChange(
|
|
101
|
-
this.fieldKey(),
|
|
102
|
-
value.length ? value.join(",") : "",
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const newOutputValue = value && this.getValueByOutputAs(value);
|
|
107
|
-
this.patchFormData(this.fieldKey(), newOutputValue);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Xử lý output value đầu ra theo outputAs mà người dùng mong muốn.
|
|
111
|
-
private getValueByOutputAs(
|
|
112
|
-
singleValueArr: string[] | number[],
|
|
113
|
-
): string[] | Record<string, unknown>[] {
|
|
114
|
-
const field = this.field();
|
|
115
|
-
const { outputAs, bindValue, modelValue } = field;
|
|
116
|
-
|
|
117
|
-
if (singleValueArr.length === 0) {
|
|
118
|
-
return singleValueArr.map(String);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Nếu outputAs là dạng single.
|
|
122
|
-
let value: string[] | Record<string, unknown>[] =
|
|
123
|
-
singleValueArr.map(String);
|
|
124
|
-
|
|
125
|
-
// Nếu outputAs là dạng object.
|
|
126
|
-
if (outputAs === SelectOutputValueTypeEnum.Object) {
|
|
127
|
-
value = value.map((val) => ({
|
|
128
|
-
[bindValue]: val,
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Nếu outputAs là dạng SourceObject.
|
|
133
|
-
if (outputAs === SelectOutputValueTypeEnum.SourceObject) {
|
|
134
|
-
const options = untracked(() => this.options());
|
|
135
|
-
value = (singleValueArr as string[]).map((val) => {
|
|
136
|
-
// 1. Tìm trong options hiện tại
|
|
137
|
-
let foundValue = options.find((opt) => opt[bindValue] === val);
|
|
138
|
-
|
|
139
|
-
// 2. Fallback tìm trong modelValue (vì modelValue có thể là array of objects)
|
|
140
|
-
// if (!foundValue && modelValue && Array.isArray(modelValue)) {
|
|
141
|
-
// foundValue = modelValue.find(
|
|
142
|
-
// (mOpt: any) => typeof mOpt === "object" && mOpt[bindValue] === val
|
|
143
|
-
// );
|
|
144
|
-
// }
|
|
145
|
-
|
|
146
|
-
// 3. Fallback cuối cùng
|
|
147
|
-
return foundValue ?? { [bindValue]: val };
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return value;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Làm phẳng giá trị để hiện thị ở chế độ View.
|
|
155
|
-
protected getDisplayValue(value: string[] | Record<string, unknown>[]) {
|
|
156
|
-
const optionsValue = value!.map(
|
|
157
|
-
(val: string | number | Record<string, unknown>) => {
|
|
158
|
-
if (typeof val === "object") {
|
|
159
|
-
return this.getCustomLabel(val);
|
|
160
|
-
}
|
|
161
|
-
return val as string;
|
|
162
|
-
},
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
return optionsValue;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
protected transformOptionValue(option: Record<string, unknown>): unknown {
|
|
169
|
-
const field = this.field();
|
|
170
|
-
|
|
171
|
-
let optionValue: unknown;
|
|
172
|
-
|
|
173
|
-
optionValue = option[field.bindValue];
|
|
174
|
-
|
|
175
|
-
return optionValue;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
protected getOptionLabel(option: Record<string, unknown>): string {
|
|
179
|
-
return this.getCustomLabel(option);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Biến đổi label nếu có thuộc tính hàm biến đổi transformLabel.
|
|
183
|
-
private getCustomLabel(option: Record<string, unknown>): string {
|
|
184
|
-
const field = this.field();
|
|
185
|
-
|
|
186
|
-
// 1. Ưu tiên lấy bindLabel, nếu không có thì fallback sang bindValue
|
|
187
|
-
let rawLabel = option[field.bindLabel];
|
|
188
|
-
if (rawLabel === undefined || rawLabel === null || rawLabel === "") {
|
|
189
|
-
rawLabel = option[field.bindValue];
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// 2. Kiểm tra nếu không tồn tại hoặc là dạng object/function (kể cả array)
|
|
193
|
-
if (
|
|
194
|
-
rawLabel === undefined ||
|
|
195
|
-
rawLabel === null ||
|
|
196
|
-
typeof rawLabel === "object" ||
|
|
197
|
-
typeof rawLabel === "function"
|
|
198
|
-
) {
|
|
199
|
-
return NO_INFO_TEXT;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
let optionLabel = String(rawLabel);
|
|
203
|
-
|
|
204
|
-
// 3. Biến đổi theo transformLabel nếu có
|
|
205
|
-
if (field.transformLabel) {
|
|
206
|
-
const tranformLabelValue = field.transformLabel(option);
|
|
207
|
-
if (tranformLabelValue) optionLabel = tranformLabelValue;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return optionLabel;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
<div class="d-flex">
|
|
2
|
-
@if (isView()) {
|
|
3
|
-
@if (viewMode() === viewModeEnum.form) {
|
|
4
|
-
<input
|
|
5
|
-
[title]="viewDisplayValue()"
|
|
6
|
-
nz-input
|
|
7
|
-
[value]="viewDisplayValue()"
|
|
8
|
-
class="modeView"
|
|
9
|
-
/>
|
|
10
|
-
}
|
|
11
|
-
@if (viewMode() === viewModeEnum.text) {
|
|
12
|
-
<span [title]="viewDisplayValue()" class="modeView break-work">{{
|
|
13
|
-
viewDisplayValue()
|
|
14
|
-
}}</span>
|
|
15
|
-
}
|
|
16
|
-
} @else {
|
|
17
|
-
<nz-select
|
|
18
|
-
[id]="fieldKey()"
|
|
19
|
-
nzShowSearch
|
|
20
|
-
nzAllowClear
|
|
21
|
-
[nzDisabled]="disabled()"
|
|
22
|
-
[nzPlaceHolder]="displayPlaceholder()"
|
|
23
|
-
[nzSuffixIcon]="optionsResource.isLoading() ? loadingIcon : null"
|
|
24
|
-
[title]="field().tooltip || ''"
|
|
25
|
-
[nzDropdownMatchSelectWidth]="field().matchSelectWidth"
|
|
26
|
-
[ngModel]="value"
|
|
27
|
-
class="flex-1 min-w-0"
|
|
28
|
-
(ngModelChange)="handleChangeOptions($event)"
|
|
29
|
-
>
|
|
30
|
-
@for (
|
|
31
|
-
option of options();
|
|
32
|
-
track `${option[this.field().bindValue]}-${$index}`
|
|
33
|
-
) {
|
|
34
|
-
<nz-option
|
|
35
|
-
[nzValue]="transformOptionValue(option)"
|
|
36
|
-
[nzLabel]="getOptionLabel(option)"
|
|
37
|
-
>
|
|
38
|
-
</nz-option>
|
|
39
|
-
}
|
|
40
|
-
</nz-select>
|
|
41
|
-
|
|
42
|
-
<ng-template #loadingIcon>
|
|
43
|
-
<nz-spin nzSimple [nzSize]="'small'"></nz-spin>
|
|
44
|
-
</ng-template>
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
<!-- Suffixes -->
|
|
48
|
-
@if (field().suffixes.length > 0) {
|
|
49
|
-
@for (suffix of field().suffixes; track $index) {
|
|
50
|
-
@if (suffix.visibleOn?.includes(this.modeSignal())) {
|
|
51
|
-
<app-suffix [suffixConfig]="suffix" [formId]="formId"> </app-suffix>
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
</div>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/src/lib/shared/components/fields/select/single-select/single-select.component.spec.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { SingleSelectComponent } from './single-select.component';
|
|
4
|
-
|
|
5
|
-
describe('SingleSelectComponent', () => {
|
|
6
|
-
let component: SingleSelectComponent;
|
|
7
|
-
let fixture: ComponentFixture<SingleSelectComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
TestBed.configureTestingModule({
|
|
11
|
-
imports: [SingleSelectComponent],
|
|
12
|
-
});
|
|
13
|
-
fixture = TestBed.createComponent(SingleSelectComponent);
|
|
14
|
-
component = fixture.componentInstance;
|
|
15
|
-
fixture.detectChanges();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should create', () => {
|
|
19
|
-
expect(component).toBeTruthy();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
computed,
|
|
4
|
-
forwardRef,
|
|
5
|
-
Input,
|
|
6
|
-
untracked,
|
|
7
|
-
} from "@angular/core";
|
|
8
|
-
import {
|
|
9
|
-
FormsModule,
|
|
10
|
-
NG_VALUE_ACCESSOR,
|
|
11
|
-
ReactiveFormsModule,
|
|
12
|
-
} from "@angular/forms";
|
|
13
|
-
import { BaseSelectComponent } from "../../../../base/base-select.component";
|
|
14
|
-
import { SingleSelectField } from "../../../../models/fields/select/single-select-field.model";
|
|
15
|
-
import { createSingleSelectPlaceholder } from "../../../../utils/dynamic-form/dynamic-form";
|
|
16
|
-
import { NO_INFO_TEXT } from "../../../../consts/common/common.const";
|
|
17
|
-
import { SelectOutputValueTypeEnum } from "../../../../enums/common";
|
|
18
|
-
import { ApiResponse } from "../../../../models/common/api-response.model";
|
|
19
|
-
import {
|
|
20
|
-
FieldDependency,
|
|
21
|
-
FieldDependencyType,
|
|
22
|
-
} from "../../../../models/common/field-dependency.model";
|
|
23
|
-
import { FieldTypeEnum } from "../../../../enums/fields";
|
|
24
|
-
import { ControlTypeEnum } from "../../../../enums/controls";
|
|
25
|
-
import { SuffixComponent } from "../../components/suffix/suffix.component";
|
|
26
|
-
import { NzSelectModule } from "ng-zorro-antd/select";
|
|
27
|
-
import { NzSpinModule } from "ng-zorro-antd/spin";
|
|
28
|
-
import { NzInputModule } from "ng-zorro-antd/input";
|
|
29
|
-
import { CommonModule } from "@angular/common";
|
|
30
|
-
|
|
31
|
-
const modules = [CommonModule, FormsModule, ReactiveFormsModule];
|
|
32
|
-
const zorroModules = [NzSelectModule, NzSpinModule, NzInputModule];
|
|
33
|
-
const components = [SuffixComponent];
|
|
34
|
-
|
|
35
|
-
@Component({
|
|
36
|
-
selector: "app-single-select",
|
|
37
|
-
standalone: true,
|
|
38
|
-
imports: [...modules, ...zorroModules, ...components],
|
|
39
|
-
templateUrl: "./single-select.component.html",
|
|
40
|
-
styleUrls: ["./single-select.component.scss"],
|
|
41
|
-
providers: [
|
|
42
|
-
{
|
|
43
|
-
provide: NG_VALUE_ACCESSOR,
|
|
44
|
-
useExisting: forwardRef(() => SingleSelectComponent),
|
|
45
|
-
multi: true,
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
})
|
|
49
|
-
export class SingleSelectComponent extends BaseSelectComponent<
|
|
50
|
-
string | Record<string, unknown>
|
|
51
|
-
> {
|
|
52
|
-
@Input() isCustomInputText!: boolean;
|
|
53
|
-
readonly field = computed(() => {
|
|
54
|
-
const base = this.fieldInput();
|
|
55
|
-
if (
|
|
56
|
-
!(base instanceof SingleSelectField) ||
|
|
57
|
-
(base.type !== FieldTypeEnum.SingleSelect &&
|
|
58
|
-
base.controlType !== ControlTypeEnum.Select)
|
|
59
|
-
) {
|
|
60
|
-
throw new Error("Expected SingleSelectField");
|
|
61
|
-
}
|
|
62
|
-
return base;
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Giá trị dùng hiển thị ở chế độ View.
|
|
66
|
-
readonly viewDisplayValue = computed(() => {
|
|
67
|
-
if (!this.isView()) return "";
|
|
68
|
-
return this.getDisplayValue(
|
|
69
|
-
(this.field().modelValue as any) || this.valueSignal(),
|
|
70
|
-
);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
constructor() {
|
|
74
|
-
super();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
protected override onApiOptionsLoaded(): void {
|
|
78
|
-
const field = this.field();
|
|
79
|
-
if (field.outputAs === SelectOutputValueTypeEnum.SourceObject) {
|
|
80
|
-
const newOutputValue =
|
|
81
|
-
this.value && this.getValueByOutputAs(this.value as string);
|
|
82
|
-
this.patchFormData(this.fieldKey(), newOutputValue);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Xử lý tạo placeholder text tự động nếu chưa truyền placeholder vào config của field
|
|
87
|
-
override resolvePlaceholderText(): string {
|
|
88
|
-
return createSingleSelectPlaceholder(this.field());
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Chạy khi value form được gán bởi các hàm reset, patchValue, setValue.
|
|
92
|
-
protected override writeValueToView(value: string | null): void {
|
|
93
|
-
if (!this.isAddOrEdit()) return;
|
|
94
|
-
|
|
95
|
-
// Bắn giá trị mới vào BehaviorSubject của FieldService.
|
|
96
|
-
// Việc này báo cho các component Con biết Parent vừa thay đổi data.
|
|
97
|
-
// Lợi ích: Dòng data chạy thẳng đứng (Push) vào ống, không phụ thuộc vào Signal tracking ẩn.
|
|
98
|
-
this.fieldService.emitDependValueChange(this.fieldKey(), value ?? "");
|
|
99
|
-
|
|
100
|
-
// Gán data vào đầu ra của form.
|
|
101
|
-
const newOutputValue = value && this.getValueByOutputAs(value);
|
|
102
|
-
this.patchFormData(this.fieldKey(), newOutputValue);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Xử lý phụ thuộc khi change value
|
|
106
|
-
protected override handleValueChange(value: string): void {
|
|
107
|
-
const { isParent } = this.field();
|
|
108
|
-
if (isParent) {
|
|
109
|
-
this.fieldService.emitDependValueChange(this.fieldKey(), value);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Gán data vào đầu ra của form.
|
|
113
|
-
const newOutputValue = value && this.getValueByOutputAs(value);
|
|
114
|
-
this.patchFormData(this.fieldKey(), newOutputValue);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
handleChangeOptions(optionValue: string): void {
|
|
118
|
-
const { enableFieldChange, bindValue } = untracked(() => this.field());
|
|
119
|
-
|
|
120
|
-
if (enableFieldChange) {
|
|
121
|
-
const option = this.options().find(
|
|
122
|
-
(option) => option[bindValue] === optionValue,
|
|
123
|
-
);
|
|
124
|
-
this.fieldService.onFieldChange(this.fieldKey(), option);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
this.propagateValue(optionValue);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Xử lý output value đầu ra theo outputAs mà người dùng mong muốn.
|
|
131
|
-
private getValueByOutputAs(
|
|
132
|
-
singleValue: string,
|
|
133
|
-
): string | Record<string, unknown> {
|
|
134
|
-
const { outputAs, bindValue, bindLabel, modelValue } = this.field();
|
|
135
|
-
|
|
136
|
-
if (singleValue) {
|
|
137
|
-
// Nếu outputAs là dạng single.
|
|
138
|
-
let value: string | Record<string, unknown> = singleValue;
|
|
139
|
-
|
|
140
|
-
// Nếu outputAs là dạng object.
|
|
141
|
-
if (outputAs === SelectOutputValueTypeEnum.Object) {
|
|
142
|
-
value = {
|
|
143
|
-
[bindValue]: singleValue,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Nếu outputAs là dạng sourceObject.
|
|
148
|
-
if (outputAs === SelectOutputValueTypeEnum.SourceObject) {
|
|
149
|
-
value =
|
|
150
|
-
this.options().find((option) => option[bindValue] === singleValue) ??
|
|
151
|
-
(modelValue && typeof modelValue === "object"
|
|
152
|
-
? modelValue
|
|
153
|
-
: { [bindValue]: value });
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return value;
|
|
157
|
-
}
|
|
158
|
-
return singleValue;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Làm phẳng giá trị để hiện thị ở chế độ View.
|
|
162
|
-
protected getDisplayValue(value: string | Record<string, unknown>): string {
|
|
163
|
-
if (!value) return NO_INFO_TEXT;
|
|
164
|
-
|
|
165
|
-
if (typeof value === "object") {
|
|
166
|
-
return this.getCustomLabel(value);
|
|
167
|
-
}
|
|
168
|
-
return value as string;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Lấy value ở option tag.
|
|
172
|
-
protected transformOptionValue(option: Record<string, unknown>): unknown {
|
|
173
|
-
const field = this.field()!;
|
|
174
|
-
|
|
175
|
-
let optionValue: unknown;
|
|
176
|
-
|
|
177
|
-
optionValue = option[field.bindValue];
|
|
178
|
-
|
|
179
|
-
return optionValue;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Lấy label.
|
|
183
|
-
protected getOptionLabel(option: Record<string, unknown>): string {
|
|
184
|
-
return this.getCustomLabel(option);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Biến đổi label nếu có thuộc tính hàm biến đổi transformLabel.
|
|
188
|
-
private getCustomLabel(option: Record<string, unknown>): string {
|
|
189
|
-
const field = this.field();
|
|
190
|
-
|
|
191
|
-
// 1. Ưu tiên lấy bindLabel, nếu không có thì fallback sang bindValue
|
|
192
|
-
let rawLabel = option[field.bindLabel];
|
|
193
|
-
if (rawLabel === undefined || rawLabel === null || rawLabel === "") {
|
|
194
|
-
rawLabel = option[field.bindValue];
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// 2. Kiểm tra nếu không tồn tại hoặc là dạng object/function (kể cả array)
|
|
198
|
-
if (
|
|
199
|
-
rawLabel === undefined ||
|
|
200
|
-
rawLabel === null ||
|
|
201
|
-
typeof rawLabel === "object" ||
|
|
202
|
-
typeof rawLabel === "function"
|
|
203
|
-
) {
|
|
204
|
-
return NO_INFO_TEXT;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
let optionLabel = String(rawLabel);
|
|
208
|
-
|
|
209
|
-
// 3. Biến đổi theo transformLabel nếu có
|
|
210
|
-
if (field.transformLabel) {
|
|
211
|
-
const tranformLabelValue = field.transformLabel(option);
|
|
212
|
-
if (tranformLabelValue) optionLabel = tranformLabelValue;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return optionLabel;
|
|
216
|
-
}
|
|
217
|
-
}
|