monkey-front-components 0.0.383 → 0.0.384
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/karma.conf.js +44 -0
- package/monkey-front-components-0.0.384.tgz +0 -0
- package/ng-package.json +10 -0
- package/package.json +7 -27
- package/src/lib/components/base/base-component.ts +359 -0
- package/src/lib/components/base/base-dynamic-array.ts +233 -0
- package/src/lib/components/base/base-dynamic.ts +90 -0
- package/src/lib/components/base/base-scroll-component.ts +52 -0
- package/src/lib/components/base/base-validators.ts +19 -0
- package/{lib/components/base/index.d.ts → src/lib/components/base/index.ts} +5 -5
- package/src/lib/components/dynamic/button/button.component.html +4 -0
- package/src/lib/components/dynamic/button/button.component.scss +7 -0
- package/src/lib/components/dynamic/button/button.component.ts +47 -0
- package/{lib/components/dynamic/button/index.d.ts → src/lib/components/dynamic/button/index.ts} +1 -1
- package/src/lib/components/dynamic/dynamic-directive.ts +102 -0
- package/src/lib/components/dynamic/dynamic.module.ts +53 -0
- package/src/lib/components/dynamic/file-upload/file-upload.component.html +10 -0
- package/src/lib/components/dynamic/file-upload/file-upload.component.ts +46 -0
- package/{lib/components/dynamic/file-upload/index.d.ts → src/lib/components/dynamic/file-upload/index.ts} +1 -1
- package/src/lib/components/dynamic/form/dynamic-form-array.component.html +19 -0
- package/src/lib/components/dynamic/form/dynamic-form-array.component.scss +10 -0
- package/src/lib/components/dynamic/form/dynamic-form-array.component.ts +75 -0
- package/src/lib/components/dynamic/form/dynamic-form.component.html +7 -0
- package/src/lib/components/dynamic/form/dynamic-form.component.ts +49 -0
- package/{lib/components/dynamic/form/index.d.ts → src/lib/components/dynamic/form/index.ts} +2 -2
- package/{lib/components/dynamic/index.d.ts → src/lib/components/dynamic/index.ts} +8 -8
- package/{lib/components/dynamic/input/index.d.ts → src/lib/components/dynamic/input/index.ts} +1 -1
- package/src/lib/components/dynamic/input/input.component.html +9 -0
- package/src/lib/components/dynamic/input/input.component.ts +58 -0
- package/{lib/components/dynamic/input-phone/index.d.ts → src/lib/components/dynamic/input-phone/index.ts} +1 -1
- package/src/lib/components/dynamic/input-phone/input-phone.component.html +7 -0
- package/src/lib/components/dynamic/input-phone/input-phone.component.ts +58 -0
- package/{lib/components/dynamic/radio/index.d.ts → src/lib/components/dynamic/radio/index.ts} +1 -1
- package/src/lib/components/dynamic/radio/radio.component.html +8 -0
- package/src/lib/components/dynamic/radio/radio.component.ts +22 -0
- package/{lib/components/dynamic/select/index.d.ts → src/lib/components/dynamic/select/index.ts} +1 -1
- package/src/lib/components/dynamic/select/select.component.html +14 -0
- package/src/lib/components/dynamic/select/select.component.ts +75 -0
- package/{lib/components/dynamic/select-search/index.d.ts → src/lib/components/dynamic/select-search/index.ts} +1 -1
- package/src/lib/components/dynamic/select-search/select-search.component.html +15 -0
- package/src/lib/components/dynamic/select-search/select-search.component.ts +76 -0
- package/{lib/components/index.d.ts → src/lib/components/index.ts} +3 -3
- package/src/lib/components/shared/filter/filter.component.html +51 -0
- package/src/lib/components/shared/filter/filter.component.scss +79 -0
- package/src/lib/components/shared/filter/filter.component.ts +117 -0
- package/src/lib/components/shared/filter/filter.module.ts +36 -0
- package/{lib/components/shared/filter/index.d.ts → src/lib/components/shared/filter/index.ts} +2 -2
- package/{lib/components/shared/filter/menu/index.d.ts → src/lib/components/shared/filter/menu/index.ts} +1 -1
- package/src/lib/components/shared/filter/menu/menu.component.html +28 -0
- package/src/lib/components/shared/filter/menu/menu.component.scss +62 -0
- package/src/lib/components/shared/filter/menu/menu.component.ts +122 -0
- package/src/lib/components/shared/filter/menu/menu.module.ts +41 -0
- package/src/lib/components/shared/filter/options/children/children.component.html +6 -0
- package/src/lib/components/shared/filter/options/children/children.component.scss +30 -0
- package/src/lib/components/shared/filter/options/children/children.component.ts +58 -0
- package/{lib/components/shared/filter/options/children/index.d.ts → src/lib/components/shared/filter/options/children/index.ts} +1 -1
- package/src/lib/components/shared/filter/options/currency/currency.component.html +3 -0
- package/src/lib/components/shared/filter/options/currency/currency.component.scss +19 -0
- package/src/lib/components/shared/filter/options/currency/currency.component.ts +52 -0
- package/{lib/components/shared/filter/options/currency/index.d.ts → src/lib/components/shared/filter/options/currency/index.ts} +1 -1
- package/src/lib/components/shared/filter/options/date-range/date-range.component.html +3 -0
- package/src/lib/components/shared/filter/options/date-range/date-range.component.scss +34 -0
- package/src/lib/components/shared/filter/options/date-range/date-range.component.ts +72 -0
- package/{lib/components/shared/filter/options/date-range/index.d.ts → src/lib/components/shared/filter/options/date-range/index.ts} +1 -1
- package/{lib/components/shared/filter/options/index.d.ts → src/lib/components/shared/filter/options/index.ts} +1 -1
- package/{lib/components/shared/filter/options/input/index.d.ts → src/lib/components/shared/filter/options/input/index.ts} +1 -1
- package/src/lib/components/shared/filter/options/input/input.component.html +3 -0
- package/src/lib/components/shared/filter/options/input/input.component.scss +19 -0
- package/src/lib/components/shared/filter/options/input/input.component.ts +52 -0
- package/src/lib/components/shared/filter/options/options.component.html +43 -0
- package/src/lib/components/shared/filter/options/options.component.scss +56 -0
- package/src/lib/components/shared/filter/options/options.component.ts +58 -0
- package/src/lib/components/shared/filter/options/options.module.ts +58 -0
- package/{lib/components/shared/filter/options/status/index.d.ts → src/lib/components/shared/filter/options/status/index.ts} +1 -1
- package/src/lib/components/shared/filter/options/status/status.component.html +4 -0
- package/src/lib/components/shared/filter/options/status/status.component.scss +29 -0
- package/src/lib/components/shared/filter/options/status/status.component.ts +73 -0
- package/{lib/components/shared/filter/selected/index.d.ts → src/lib/components/shared/filter/selected/index.ts} +1 -1
- package/src/lib/components/shared/filter/selected/item/children/children.component.html +19 -0
- package/src/lib/components/shared/filter/selected/item/children/children.component.scss +68 -0
- package/src/lib/components/shared/filter/selected/item/children/children.component.ts +49 -0
- package/{lib/components/shared/filter/selected/item/children/index.d.ts → src/lib/components/shared/filter/selected/item/children/index.ts} +1 -1
- package/src/lib/components/shared/filter/selected/item/currency/currency.component.html +1 -0
- package/src/lib/components/shared/filter/selected/item/currency/currency.component.scss +4 -0
- package/src/lib/components/shared/filter/selected/item/currency/currency.component.ts +26 -0
- package/{lib/components/shared/filter/selected/item/currency/index.d.ts → src/lib/components/shared/filter/selected/item/currency/index.ts} +1 -1
- package/src/lib/components/shared/filter/selected/item/date-range/date-range.component.html +2 -0
- package/src/lib/components/shared/filter/selected/item/date-range/date-range.component.scss +4 -0
- package/src/lib/components/shared/filter/selected/item/date-range/date-range.component.ts +39 -0
- package/{lib/components/shared/filter/selected/item/date-range/index.d.ts → src/lib/components/shared/filter/selected/item/date-range/index.ts} +1 -1
- package/src/lib/components/shared/filter/selected/item/date-with-action/date-with-action.component.html +1 -0
- package/src/lib/components/shared/filter/selected/item/date-with-action/date-with-action.component.scss +4 -0
- package/src/lib/components/shared/filter/selected/item/date-with-action/date-with-action.component.ts +29 -0
- package/{lib/components/shared/filter/selected/item/date-with-action/index.d.ts → src/lib/components/shared/filter/selected/item/date-with-action/index.ts} +1 -1
- package/{lib/components/shared/filter/selected/item/index.d.ts → src/lib/components/shared/filter/selected/item/index.ts} +7 -7
- package/{lib/components/shared/filter/selected/item/input/index.d.ts → src/lib/components/shared/filter/selected/item/input/index.ts} +1 -1
- package/src/lib/components/shared/filter/selected/item/input/input.component.html +1 -0
- package/src/lib/components/shared/filter/selected/item/input/input.component.scss +4 -0
- package/src/lib/components/shared/filter/selected/item/input/input.component.ts +26 -0
- package/src/lib/components/shared/filter/selected/item/item.component.html +38 -0
- package/src/lib/components/shared/filter/selected/item/item.component.scss +72 -0
- package/src/lib/components/shared/filter/selected/item/item.component.ts +71 -0
- package/{lib/components/shared/filter/selected/item/status/index.d.ts → src/lib/components/shared/filter/selected/item/status/index.ts} +1 -1
- package/src/lib/components/shared/filter/selected/item/status/status.component.html +1 -0
- package/src/lib/components/shared/filter/selected/item/status/status.component.scss +4 -0
- package/src/lib/components/shared/filter/selected/item/status/status.component.ts +36 -0
- package/src/lib/components/shared/filter/selected/selected.component.html +3 -0
- package/src/lib/components/shared/filter/selected/selected.component.scss +9 -0
- package/src/lib/components/shared/filter/selected/selected.component.ts +76 -0
- package/src/lib/components/shared/filter/selected/selected.module.ts +60 -0
- package/{lib/components/shared/index.d.ts → src/lib/components/shared/index.ts} +4 -4
- package/{lib/components/shared/password-strength/index.d.ts → src/lib/components/shared/password-strength/index.ts} +2 -2
- package/src/lib/components/shared/password-strength/password-strength.component.html +50 -0
- package/src/lib/components/shared/password-strength/password-strength.component.scss +70 -0
- package/src/lib/components/shared/password-strength/password-strength.component.ts +89 -0
- package/src/lib/components/shared/password-strength/password-strength.module.ts +24 -0
- package/src/lib/components/shared/password-strength/password-strength.ts +5 -0
- package/src/lib/components/shared/products/filter/filter.component.html +6 -0
- package/src/lib/components/shared/products/filter/filter.component.scss +20 -0
- package/src/lib/components/shared/products/filter/filter.component.ts +34 -0
- package/{lib/components/shared/products/index.d.ts → src/lib/components/shared/products/index.ts} +2 -2
- package/src/lib/components/shared/products/products.component.html +15 -0
- package/src/lib/components/shared/products/products.component.scss +70 -0
- package/src/lib/components/shared/products/products.component.ts +104 -0
- package/src/lib/components/shared/products/products.module.ts +13 -0
- package/{lib/components/shared/products/providers/index.d.ts → src/lib/components/shared/products/providers/index.ts} +1 -1
- package/src/lib/components/shared/products/providers/products.model.ts +60 -0
- package/{lib/components/shared/progress-bar/index.d.ts → src/lib/components/shared/progress-bar/index.ts} +3 -3
- package/src/lib/components/shared/progress-bar/progress-bar.component.html +3 -0
- package/src/lib/components/shared/progress-bar/progress-bar.component.scss +6 -0
- package/src/lib/components/shared/progress-bar/progress-bar.component.ts +27 -0
- package/src/lib/components/shared/progress-bar/progress-bar.module.ts +10 -0
- package/src/lib/components/shared/progress-bar/progress-bar.service.ts +59 -0
- package/src/lib/interfaces/field-config.ts +58 -0
- package/{lib/interfaces/index.d.ts → src/lib/interfaces/index.ts} +1 -1
- package/src/public-api.ts +5 -0
- package/src/test.ts +26 -0
- package/tsconfig.lib.json +20 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/esm2020/lib/components/base/base-component.mjs +0 -322
- package/esm2020/lib/components/base/base-dynamic-array.mjs +0 -221
- package/esm2020/lib/components/base/base-dynamic.mjs +0 -99
- package/esm2020/lib/components/base/base-scroll-component.mjs +0 -55
- package/esm2020/lib/components/base/base-validators.mjs +0 -19
- package/esm2020/lib/components/base/index.mjs +0 -6
- package/esm2020/lib/components/dynamic/button/button.component.mjs +0 -52
- package/esm2020/lib/components/dynamic/button/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/dynamic-directive.mjs +0 -95
- package/esm2020/lib/components/dynamic/dynamic.module.mjs +0 -84
- package/esm2020/lib/components/dynamic/file-upload/file-upload.component.mjs +0 -52
- package/esm2020/lib/components/dynamic/file-upload/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/form/dynamic-form-array.component.mjs +0 -72
- package/esm2020/lib/components/dynamic/form/dynamic-form.component.mjs +0 -46
- package/esm2020/lib/components/dynamic/form/index.mjs +0 -3
- package/esm2020/lib/components/dynamic/index.mjs +0 -9
- package/esm2020/lib/components/dynamic/input/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/input/input.component.mjs +0 -65
- package/esm2020/lib/components/dynamic/input-phone/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/input-phone/input-phone.component.mjs +0 -65
- package/esm2020/lib/components/dynamic/radio/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/radio/radio.component.mjs +0 -33
- package/esm2020/lib/components/dynamic/select/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/select/select.component.mjs +0 -80
- package/esm2020/lib/components/dynamic/select-search/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/select-search/select-search.component.mjs +0 -80
- package/esm2020/lib/components/index.mjs +0 -4
- package/esm2020/lib/components/shared/filter/filter.component.mjs +0 -119
- package/esm2020/lib/components/shared/filter/filter.module.mjs +0 -63
- package/esm2020/lib/components/shared/filter/index.mjs +0 -3
- package/esm2020/lib/components/shared/filter/menu/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/menu/menu.component.mjs +0 -120
- package/esm2020/lib/components/shared/filter/menu/menu.module.mjs +0 -70
- package/esm2020/lib/components/shared/filter/options/children/children.component.mjs +0 -50
- package/esm2020/lib/components/shared/filter/options/children/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/options/currency/currency.component.mjs +0 -46
- package/esm2020/lib/components/shared/filter/options/currency/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/options/date-range/date-range.component.mjs +0 -65
- package/esm2020/lib/components/shared/filter/options/date-range/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/options/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/options/input/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/options/input/input.component.mjs +0 -46
- package/esm2020/lib/components/shared/filter/options/options.component.mjs +0 -68
- package/esm2020/lib/components/shared/filter/options/options.module.mjs +0 -95
- package/esm2020/lib/components/shared/filter/options/status/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/options/status/status.component.mjs +0 -66
- package/esm2020/lib/components/shared/filter/selected/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/children/children.component.mjs +0 -57
- package/esm2020/lib/components/shared/filter/selected/item/children/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/currency/currency.component.mjs +0 -29
- package/esm2020/lib/components/shared/filter/selected/item/currency/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/date-range/date-range.component.mjs +0 -42
- package/esm2020/lib/components/shared/filter/selected/item/date-range/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/date-with-action/date-with-action.component.mjs +0 -33
- package/esm2020/lib/components/shared/filter/selected/item/date-with-action/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/index.mjs +0 -8
- package/esm2020/lib/components/shared/filter/selected/item/input/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/input/input.component.mjs +0 -28
- package/esm2020/lib/components/shared/filter/selected/item/item.component.mjs +0 -74
- package/esm2020/lib/components/shared/filter/selected/item/status/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/status/status.component.mjs +0 -39
- package/esm2020/lib/components/shared/filter/selected/selected.component.mjs +0 -80
- package/esm2020/lib/components/shared/filter/selected/selected.module.mjs +0 -90
- package/esm2020/lib/components/shared/index.mjs +0 -5
- package/esm2020/lib/components/shared/password-strength/index.mjs +0 -3
- package/esm2020/lib/components/shared/password-strength/password-strength.component.mjs +0 -85
- package/esm2020/lib/components/shared/password-strength/password-strength.mjs +0 -2
- package/esm2020/lib/components/shared/password-strength/password-strength.module.mjs +0 -50
- package/esm2020/lib/components/shared/products/filter/filter.component.mjs +0 -36
- package/esm2020/lib/components/shared/products/index.mjs +0 -3
- package/esm2020/lib/components/shared/products/products.component.mjs +0 -91
- package/esm2020/lib/components/shared/products/products.module.mjs +0 -22
- package/esm2020/lib/components/shared/products/providers/index.mjs +0 -2
- package/esm2020/lib/components/shared/products/providers/products.model.mjs +0 -38
- package/esm2020/lib/components/shared/progress-bar/index.mjs +0 -4
- package/esm2020/lib/components/shared/progress-bar/progress-bar.component.mjs +0 -28
- package/esm2020/lib/components/shared/progress-bar/progress-bar.module.mjs +0 -18
- package/esm2020/lib/components/shared/progress-bar/progress-bar.service.mjs +0 -49
- package/esm2020/lib/interfaces/field-config.mjs +0 -2
- package/esm2020/lib/interfaces/index.mjs +0 -2
- package/esm2020/monkey-front-components.mjs +0 -5
- package/esm2020/public-api.mjs +0 -5
- package/fesm2015/monkey-front-components.mjs +0 -2877
- package/fesm2015/monkey-front-components.mjs.map +0 -1
- package/fesm2020/monkey-front-components.mjs +0 -2859
- package/fesm2020/monkey-front-components.mjs.map +0 -1
- package/lib/components/base/base-component.d.ts +0 -50
- package/lib/components/base/base-dynamic-array.d.ts +0 -34
- package/lib/components/base/base-dynamic.d.ts +0 -24
- package/lib/components/base/base-scroll-component.d.ts +0 -16
- package/lib/components/base/base-validators.d.ts +0 -1
- package/lib/components/dynamic/button/button.component.d.ts +0 -17
- package/lib/components/dynamic/dynamic-directive.d.ts +0 -22
- package/lib/components/dynamic/dynamic.module.d.ts +0 -20
- package/lib/components/dynamic/file-upload/file-upload.component.d.ts +0 -17
- package/lib/components/dynamic/form/dynamic-form-array.component.d.ts +0 -16
- package/lib/components/dynamic/form/dynamic-form.component.d.ts +0 -14
- package/lib/components/dynamic/input/input.component.d.ts +0 -20
- package/lib/components/dynamic/input-phone/input-phone.component.d.ts +0 -20
- package/lib/components/dynamic/radio/radio.component.d.ts +0 -11
- package/lib/components/dynamic/select/select.component.d.ts +0 -16
- package/lib/components/dynamic/select-search/select-search.component.d.ts +0 -16
- package/lib/components/shared/filter/filter.component.d.ts +0 -32
- package/lib/components/shared/filter/filter.module.d.ts +0 -14
- package/lib/components/shared/filter/menu/menu.component.d.ts +0 -24
- package/lib/components/shared/filter/menu/menu.module.d.ts +0 -14
- package/lib/components/shared/filter/options/children/children.component.d.ts +0 -17
- package/lib/components/shared/filter/options/currency/currency.component.d.ts +0 -17
- package/lib/components/shared/filter/options/date-range/date-range.component.d.ts +0 -24
- package/lib/components/shared/filter/options/input/input.component.d.ts +0 -17
- package/lib/components/shared/filter/options/options.component.d.ts +0 -20
- package/lib/components/shared/filter/options/options.module.d.ts +0 -18
- package/lib/components/shared/filter/options/status/status.component.d.ts +0 -19
- package/lib/components/shared/filter/selected/item/children/children.component.d.ts +0 -16
- package/lib/components/shared/filter/selected/item/currency/currency.component.d.ts +0 -11
- package/lib/components/shared/filter/selected/item/date-range/date-range.component.d.ts +0 -12
- package/lib/components/shared/filter/selected/item/date-with-action/date-with-action.component.d.ts +0 -11
- package/lib/components/shared/filter/selected/item/input/input.component.d.ts +0 -11
- package/lib/components/shared/filter/selected/item/item.component.d.ts +0 -20
- package/lib/components/shared/filter/selected/item/status/status.component.d.ts +0 -13
- package/lib/components/shared/filter/selected/selected.component.d.ts +0 -18
- package/lib/components/shared/filter/selected/selected.module.d.ts +0 -21
- package/lib/components/shared/password-strength/password-strength.component.d.ts +0 -23
- package/lib/components/shared/password-strength/password-strength.d.ts +0 -5
- package/lib/components/shared/password-strength/password-strength.module.d.ts +0 -12
- package/lib/components/shared/products/filter/filter.component.d.ts +0 -12
- package/lib/components/shared/products/products.component.d.ts +0 -20
- package/lib/components/shared/products/products.module.d.ts +0 -11
- package/lib/components/shared/products/providers/products.model.d.ts +0 -13
- package/lib/components/shared/progress-bar/progress-bar.component.d.ts +0 -12
- package/lib/components/shared/progress-bar/progress-bar.module.d.ts +0 -8
- package/lib/components/shared/progress-bar/progress-bar.service.d.ts +0 -14
- package/lib/interfaces/field-config.d.ts +0 -54
- package/monkey-front-components-0.0.383.tgz +0 -0
- package/monkey-front-components.d.ts +0 -5
- package/public-api.d.ts +0 -1
package/karma.conf.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Karma configuration file, see link for more information
|
|
2
|
+
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
|
3
|
+
|
|
4
|
+
module.exports = function (config) {
|
|
5
|
+
config.set({
|
|
6
|
+
basePath: '',
|
|
7
|
+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
|
8
|
+
plugins: [
|
|
9
|
+
require('karma-jasmine'),
|
|
10
|
+
require('karma-chrome-launcher'),
|
|
11
|
+
require('karma-jasmine-html-reporter'),
|
|
12
|
+
require('karma-coverage'),
|
|
13
|
+
require('@angular-devkit/build-angular/plugins/karma')
|
|
14
|
+
],
|
|
15
|
+
client: {
|
|
16
|
+
jasmine: {
|
|
17
|
+
// you can add configuration options for Jasmine here
|
|
18
|
+
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
|
|
19
|
+
// for example, you can disable the random execution with `random: false`
|
|
20
|
+
// or set a specific seed with `seed: 4321`
|
|
21
|
+
},
|
|
22
|
+
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|
23
|
+
},
|
|
24
|
+
jasmineHtmlReporter: {
|
|
25
|
+
suppressAll: true // removes the duplicated traces
|
|
26
|
+
},
|
|
27
|
+
coverageReporter: {
|
|
28
|
+
dir: require('path').join(__dirname, '../../coverage/monkey-front-components'),
|
|
29
|
+
subdir: '.',
|
|
30
|
+
reporters: [
|
|
31
|
+
{ type: 'html' },
|
|
32
|
+
{ type: 'text-summary' }
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
reporters: ['progress', 'kjhtml'],
|
|
36
|
+
port: 9876,
|
|
37
|
+
colors: true,
|
|
38
|
+
logLevel: config.LOG_INFO,
|
|
39
|
+
autoWatch: true,
|
|
40
|
+
browsers: ['Chrome'],
|
|
41
|
+
singleRun: false,
|
|
42
|
+
restartOnFileChange: true
|
|
43
|
+
});
|
|
44
|
+
};
|
|
Binary file
|
package/ng-package.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
|
|
3
|
+
"dest": "../../dist/monkey-front-components",
|
|
4
|
+
"assets": ["assets"],
|
|
5
|
+
"lib": {
|
|
6
|
+
"entryFile": "src/public-api.ts",
|
|
7
|
+
"styleIncludePaths": ["assets"]
|
|
8
|
+
},
|
|
9
|
+
"allowedNonPeerDependencies": ["."]
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monkey-front-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.384",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/common": "13.1.1",
|
|
6
6
|
"@angular/core": "13.1.1",
|
|
@@ -8,33 +8,13 @@
|
|
|
8
8
|
"@angular/router": "13.1.1",
|
|
9
9
|
"rxjs": "^6.6.3",
|
|
10
10
|
"@ngx-translate/core": "^13.0.0",
|
|
11
|
-
"monkey-style-guide": "2.0.
|
|
12
|
-
"monkey-front-core": "0.0.
|
|
11
|
+
"monkey-style-guide": "2.0.152",
|
|
12
|
+
"monkey-front-core": "0.0.238",
|
|
13
13
|
"ngx-mask": "^12.0.0"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"monkey-style-guide": "2.0.
|
|
17
|
-
"monkey-front-core": "0.0.
|
|
16
|
+
"monkey-style-guide": "2.0.152",
|
|
17
|
+
"monkey-front-core": "0.0.238",
|
|
18
18
|
"tslib": "^2.3.0"
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
"es2020": "fesm2020/monkey-front-components.mjs",
|
|
22
|
-
"esm2020": "esm2020/monkey-front-components.mjs",
|
|
23
|
-
"fesm2020": "fesm2020/monkey-front-components.mjs",
|
|
24
|
-
"fesm2015": "fesm2015/monkey-front-components.mjs",
|
|
25
|
-
"typings": "monkey-front-components.d.ts",
|
|
26
|
-
"exports": {
|
|
27
|
-
"./package.json": {
|
|
28
|
-
"default": "./package.json"
|
|
29
|
-
},
|
|
30
|
-
".": {
|
|
31
|
-
"types": "./monkey-front-components.d.ts",
|
|
32
|
-
"esm2020": "./esm2020/monkey-front-components.mjs",
|
|
33
|
-
"es2020": "./fesm2020/monkey-front-components.mjs",
|
|
34
|
-
"es2015": "./fesm2015/monkey-front-components.mjs",
|
|
35
|
-
"node": "./fesm2015/monkey-front-components.mjs",
|
|
36
|
-
"default": "./fesm2020/monkey-front-components.mjs"
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"sideEffects": false
|
|
40
|
-
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
import { AbstractControl, FormGroup } from '@angular/forms';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
import { OnDestroy, Directive } from '@angular/core';
|
|
5
|
+
import { takeUntil } from 'rxjs/operators';
|
|
6
|
+
import { MonkeyUtils } from 'monkey-style-guide';
|
|
7
|
+
import {
|
|
8
|
+
MonkeyEcxCommonsService,
|
|
9
|
+
MonkeyEcxErrorResponse,
|
|
10
|
+
MonkeyEcxPaginationOptions,
|
|
11
|
+
MonkeyEcxScrollOptions,
|
|
12
|
+
MonkeyEcxSupportOptions,
|
|
13
|
+
MonkeyEcxTranslateOptions,
|
|
14
|
+
ValidateUtils
|
|
15
|
+
} from 'monkey-front-core';
|
|
16
|
+
|
|
17
|
+
@Directive({
|
|
18
|
+
selector: '[baseComponent]'
|
|
19
|
+
})
|
|
20
|
+
export abstract class BaseComponent implements OnDestroy {
|
|
21
|
+
__monkeyecxFormErrors: any | any[];
|
|
22
|
+
|
|
23
|
+
__unsubscribeAll: Subject<any>;
|
|
24
|
+
|
|
25
|
+
__paginationOptions: MonkeyEcxPaginationOptions | null = null;
|
|
26
|
+
|
|
27
|
+
__i18n: any;
|
|
28
|
+
|
|
29
|
+
__isMobile = this.isMobile();
|
|
30
|
+
|
|
31
|
+
__locales = ['pt-BR', 'es-CL'];
|
|
32
|
+
|
|
33
|
+
private paginationFunc: any;
|
|
34
|
+
|
|
35
|
+
protected constructor() {
|
|
36
|
+
this.__unsubscribeAll = new Subject();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private isMobile() {
|
|
40
|
+
const isMobileWidth = (window.screen.width <= 640) ||
|
|
41
|
+
(window.matchMedia &&
|
|
42
|
+
window.matchMedia('only screen and (max-width: 640px)').matches
|
|
43
|
+
);
|
|
44
|
+
return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|Mobile/i.test(
|
|
45
|
+
navigator.userAgent
|
|
46
|
+
)) || isMobileWidth;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private handlePagination(create = true) {
|
|
50
|
+
const { __paginationOptions } = this;
|
|
51
|
+
|
|
52
|
+
if (__paginationOptions) {
|
|
53
|
+
const { mainElement, service } = __paginationOptions;
|
|
54
|
+
|
|
55
|
+
const element = document.getElementById(mainElement);
|
|
56
|
+
|
|
57
|
+
if (element) {
|
|
58
|
+
element.scroll = null;
|
|
59
|
+
element.onscroll = null;
|
|
60
|
+
|
|
61
|
+
element.removeEventListener('scroll', (element as any).eventListeners('scroll'));
|
|
62
|
+
element.removeEventListener('scroll', (element as any).eventListeners('scroll')[0]);
|
|
63
|
+
if (create) {
|
|
64
|
+
element.addEventListener('scroll', () => {
|
|
65
|
+
const { scrollTop, scrollHeight, offsetHeight } = element;
|
|
66
|
+
const contentHeight = scrollHeight - offsetHeight;
|
|
67
|
+
|
|
68
|
+
if (contentHeight <= scrollTop) {
|
|
69
|
+
service.doPagination();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private handleSupport(supportControls: MonkeyEcxSupportOptions) {
|
|
78
|
+
const { service, show } = supportControls;
|
|
79
|
+
const method = show ? 'show' : 'hide';
|
|
80
|
+
service[method.toLowerCase()]();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private handleTranslate(translateOptions: MonkeyEcxTranslateOptions) {
|
|
84
|
+
const { service } = translateOptions;
|
|
85
|
+
service.__oni18nDataChanged$
|
|
86
|
+
.pipe(takeUntil(this.__unsubscribeAll))
|
|
87
|
+
.subscribe(() => {
|
|
88
|
+
const data = service.__i18n;
|
|
89
|
+
if (data) {
|
|
90
|
+
this.__i18n = data;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private handleViewScroll(options: MonkeyEcxScrollOptions) {
|
|
96
|
+
const { elementId, service } = options;
|
|
97
|
+
|
|
98
|
+
if (elementId === service?.__savedState?.scrollElementId) {
|
|
99
|
+
this.goScroll(elementId);
|
|
100
|
+
|
|
101
|
+
service.__savedState.scrollElementId = null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private getErrorFirstMessageTranslated(formControl: AbstractControl | null = null) {
|
|
106
|
+
if (formControl?.hasError('required')) return 'FIELD-REQUIRED';
|
|
107
|
+
if (formControl?.hasError('invalid')) return 'FIELD-INVALID';
|
|
108
|
+
if (formControl?.hasError('email')) return 'INVALID-EMAIL';
|
|
109
|
+
if (formControl?.hasError('minlength')) return 'MIN-LENGTH';
|
|
110
|
+
if (formControl?.hasError('maxlength')) return 'MAX-LENGTH';
|
|
111
|
+
if (formControl?.hasError('max')) return 'MAX';
|
|
112
|
+
if (formControl?.hasError('min')) return 'MIN';
|
|
113
|
+
if (formControl?.hasError('passwordsNotMatching')) return 'MATCH-PASSWORD';
|
|
114
|
+
if (formControl?.hasError('invalidDate')) return 'INVALID-DATE';
|
|
115
|
+
if (formControl?.hasError('invalidTrue')) return 'INVALID-TRUE';
|
|
116
|
+
if (formControl?.hasError('invalidCpfCnpj')) return 'INVALID-DOCUMENT';
|
|
117
|
+
if (formControl?.hasError('invalidZipCode')) return 'INVALID-ZIPCODE';
|
|
118
|
+
if (formControl?.hasError('invalidCombo')) return 'INVALID-COMBO';
|
|
119
|
+
if (formControl?.hasError('invalidUrl')) return 'INVALID-URL';
|
|
120
|
+
if (formControl?.hasError('invalidUnlockRegister')) { return 'INVALID-UNLOCK-REGISTER'; }
|
|
121
|
+
if (formControl?.hasError('dateStartMustBeLessThanAnd')) {
|
|
122
|
+
return 'DATE-START-MUST-BE-LESS-THAN-AND';
|
|
123
|
+
}
|
|
124
|
+
if (formControl?.hasError('dateEndMustBeGreaterThanStart')) {
|
|
125
|
+
return 'DATE-END-MUST-BE-GREATER-THAN-SART';
|
|
126
|
+
}
|
|
127
|
+
if (formControl?.hasError('phone')) return 'INVALID-PHONE';
|
|
128
|
+
if (formControl?.hasError('invalidValueGreaterThanZero')) return 'INVALID-GREATER-THAN-ZERO';
|
|
129
|
+
|
|
130
|
+
return 'FIELD-INVALID';
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private getErrorLastMessageNotTranslated(formControl: AbstractControl | null = null) {
|
|
134
|
+
if (formControl?.hasError('minlength')) {
|
|
135
|
+
return `${formControl?.getError('minlength').requiredLength} caracteres.`;
|
|
136
|
+
}
|
|
137
|
+
if (formControl?.hasError('maxlength')) {
|
|
138
|
+
return `${formControl?.getError('maxlength').requiredLength} caracteres.`;
|
|
139
|
+
}
|
|
140
|
+
if (formControl?.hasError('max')) { return `${formControl?.getError('max').max}`; }
|
|
141
|
+
if (formControl?.hasError('min')) { return `${formControl?.getError('min').min}`; }
|
|
142
|
+
|
|
143
|
+
return '';
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public validateFormWithTranslate(f: FormGroup, index?: number): boolean {
|
|
147
|
+
const formErrors: any = f.value;
|
|
148
|
+
|
|
149
|
+
if (f.status === 'VALID') return true;
|
|
150
|
+
|
|
151
|
+
if (!formErrors) return true;
|
|
152
|
+
Object.entries(formErrors).forEach(([key, value]) => {
|
|
153
|
+
const control = f.get(key);
|
|
154
|
+
formErrors[key] = '';
|
|
155
|
+
if (control && !control.valid) {
|
|
156
|
+
const msg = {
|
|
157
|
+
first: `ERRORS.${this.getErrorFirstMessageTranslated(f.get(key))}`,
|
|
158
|
+
last: this.getErrorLastMessageNotTranslated(f.get(key))
|
|
159
|
+
};
|
|
160
|
+
formErrors[key] = msg;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
if (MonkeyUtils.persistNullEmptyUndefined(index)) { this.__monkeyecxFormErrors[index || 0] = formErrors; } else {
|
|
165
|
+
this.__monkeyecxFormErrors = formErrors;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public copyToClipboard(val: string) {
|
|
172
|
+
const selBox = document.createElement('textarea');
|
|
173
|
+
selBox.style.position = 'fixed';
|
|
174
|
+
selBox.style.left = '0';
|
|
175
|
+
selBox.style.top = '0';
|
|
176
|
+
selBox.style.opacity = '0';
|
|
177
|
+
selBox.value = val;
|
|
178
|
+
document.body.appendChild(selBox);
|
|
179
|
+
selBox.focus();
|
|
180
|
+
selBox.select();
|
|
181
|
+
document.execCommand('copy');
|
|
182
|
+
document.body.removeChild(selBox);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
public validateForm(f: FormGroup, index?: number, alias?: string): boolean {
|
|
186
|
+
const formErrors: any = f.value;
|
|
187
|
+
if (f.status === 'VALID') return true;
|
|
188
|
+
|
|
189
|
+
if (!formErrors) return true;
|
|
190
|
+
Object.entries(formErrors).forEach(([key, value]) => {
|
|
191
|
+
const control = f.get(key);
|
|
192
|
+
formErrors[key] = '';
|
|
193
|
+
if (control && !control.valid) {
|
|
194
|
+
const msg = {
|
|
195
|
+
firstMessage: `ERRORS.${this.getErrorFirstMessageTranslated(
|
|
196
|
+
f.get(key)
|
|
197
|
+
)}`,
|
|
198
|
+
lastMessage: this.getErrorLastMessageNotTranslated(f.get(key))
|
|
199
|
+
};
|
|
200
|
+
formErrors[key] = msg;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
if (MonkeyUtils.persistNullEmptyUndefined(index)) {
|
|
205
|
+
this.__monkeyecxFormErrors[index || 0] = formErrors;
|
|
206
|
+
} else {
|
|
207
|
+
let obj: any;
|
|
208
|
+
|
|
209
|
+
if (alias) {
|
|
210
|
+
obj = {
|
|
211
|
+
[alias]: {
|
|
212
|
+
...formErrors
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
} else {
|
|
216
|
+
obj = formErrors;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
this.__monkeyecxFormErrors = {
|
|
220
|
+
...this.__monkeyecxFormErrors,
|
|
221
|
+
...obj
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
f.markAllAsTouched();
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
public clearAllServiceData(clearData: boolean) {
|
|
229
|
+
const context = this;
|
|
230
|
+
Object.values(context).forEach((ctx: any) => {
|
|
231
|
+
if (ctx instanceof MonkeyEcxCommonsService) {
|
|
232
|
+
ctx.clear(clearData);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
public ngOnInit(args: {
|
|
238
|
+
paginationOptions?: MonkeyEcxPaginationOptions;
|
|
239
|
+
supportControls?: MonkeyEcxSupportOptions;
|
|
240
|
+
scrollOptions?: MonkeyEcxScrollOptions;
|
|
241
|
+
translateOptions?: MonkeyEcxTranslateOptions;
|
|
242
|
+
}) {
|
|
243
|
+
if (args?.paginationOptions) {
|
|
244
|
+
this.__paginationOptions = args?.paginationOptions;
|
|
245
|
+
this.handlePagination();
|
|
246
|
+
}
|
|
247
|
+
if (args?.supportControls) {
|
|
248
|
+
this.handleSupport(args?.supportControls);
|
|
249
|
+
}
|
|
250
|
+
if (args?.translateOptions) {
|
|
251
|
+
this.handleTranslate(args?.translateOptions);
|
|
252
|
+
}
|
|
253
|
+
if (args?.scrollOptions) {
|
|
254
|
+
this.handleViewScroll(args.scrollOptions);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
public ngOnDestroy(clearData: boolean = true) {
|
|
259
|
+
this.__unsubscribeAll.next();
|
|
260
|
+
this.__unsubscribeAll.complete();
|
|
261
|
+
this.clearAllServiceData(clearData);
|
|
262
|
+
this.handlePagination(false);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
public handleErrorFromServices(error: MonkeyEcxErrorResponse, f: FormGroup) {
|
|
266
|
+
this.__monkeyecxFormErrors = null;
|
|
267
|
+
if (error.type === 'Parameter_Error') {
|
|
268
|
+
Object.entries(f.value).forEach(([key, value]) => {
|
|
269
|
+
error.notifications.forEach((_: any) => {
|
|
270
|
+
const field = _.split(':')[0];
|
|
271
|
+
const description = _.split(':')[1];
|
|
272
|
+
if (field === key) {
|
|
273
|
+
const msg = {
|
|
274
|
+
firstMessage: '',
|
|
275
|
+
lastMessage: description
|
|
276
|
+
};
|
|
277
|
+
this.__monkeyecxFormErrors = {
|
|
278
|
+
...this.__monkeyecxFormErrors,
|
|
279
|
+
[key]: msg
|
|
280
|
+
};
|
|
281
|
+
f.controls[key].setErrors({
|
|
282
|
+
incorrect: true
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
f.markAllAsTouched();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
public goBack() {
|
|
293
|
+
window.history.back();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
public goScroll(id: string) {
|
|
297
|
+
const element = document.getElementById(id);
|
|
298
|
+
if (element) element.scrollIntoView();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
public getEmbeddedData(data: any, field: string): any[] | any {
|
|
302
|
+
const { _embedded } = data;
|
|
303
|
+
return _embedded ? _embedded[field] : null;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
public openWindow(url: string) {
|
|
307
|
+
window.open(`${url}`, '_blank');
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
public fillI18n(data: any) {
|
|
311
|
+
this.__i18n = data;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
public getCountryPrefix(country: string) {
|
|
315
|
+
return {
|
|
316
|
+
br: 55,
|
|
317
|
+
cl: 56
|
|
318
|
+
}[country];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
public getCountryCurrencyChartFormat(country: string) {
|
|
322
|
+
return {
|
|
323
|
+
br: 'R$ #,###,##0.00',
|
|
324
|
+
cl: 'CLP #,###,##0'
|
|
325
|
+
}[country];
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
public getCountryValidators(country: string) {
|
|
329
|
+
return {
|
|
330
|
+
br: {
|
|
331
|
+
governmentId: ValidateUtils.DocumentValidator
|
|
332
|
+
},
|
|
333
|
+
cl: {
|
|
334
|
+
governmentId: ValidateUtils.DocumentRutValidator
|
|
335
|
+
}
|
|
336
|
+
}[country];
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
public isAbleToHandlePagination() {
|
|
340
|
+
const { __paginationOptions } = this;
|
|
341
|
+
|
|
342
|
+
if (__paginationOptions) {
|
|
343
|
+
const { service } = __paginationOptions;
|
|
344
|
+
|
|
345
|
+
const links = service.__links;
|
|
346
|
+
if (links && links?.next) return true;
|
|
347
|
+
}
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
public onHandlePagination() {
|
|
352
|
+
const { __paginationOptions } = this;
|
|
353
|
+
|
|
354
|
+
if (__paginationOptions) {
|
|
355
|
+
const { service } = __paginationOptions;
|
|
356
|
+
service.doPagination();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { Directive, EventEmitter, Input, OnInit, OnChanges, Output } from '@angular/core';
|
|
2
|
+
import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
3
|
+
import { MonkeyUtils } from 'monkey-style-guide';
|
|
4
|
+
import { Subject } from 'rxjs';
|
|
5
|
+
import { takeUntil } from 'rxjs/operators';
|
|
6
|
+
import { MECXFieldConfig, MECXFieldConfigValidator } from '../../interfaces';
|
|
7
|
+
import { BaseComponent } from './base-component';
|
|
8
|
+
import { validators } from './base-validators';
|
|
9
|
+
|
|
10
|
+
@Directive({
|
|
11
|
+
selector: '[baseDynamicArray]'
|
|
12
|
+
})
|
|
13
|
+
export abstract class BaseDynamicArray extends BaseComponent implements OnInit, OnChanges {
|
|
14
|
+
@Input() onHandleSubmit = new EventEmitter<any>();
|
|
15
|
+
|
|
16
|
+
@Input() onHandleUpdateForm = new EventEmitter<any>();
|
|
17
|
+
|
|
18
|
+
@Output() onHandleSubmitFormReady: EventEmitter<any> = new EventEmitter<any>();
|
|
19
|
+
|
|
20
|
+
@Input() self: any;
|
|
21
|
+
|
|
22
|
+
@Input() fields: MECXFieldConfig[] = [];
|
|
23
|
+
|
|
24
|
+
@Input() data: any;
|
|
25
|
+
|
|
26
|
+
@Input() qtd: number = 1;
|
|
27
|
+
|
|
28
|
+
@Input() disabled: boolean = false;
|
|
29
|
+
|
|
30
|
+
_form: FormGroup | null = null;
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line object-curly-newline
|
|
33
|
+
_plusValidations: any[] = [];
|
|
34
|
+
|
|
35
|
+
private changesUnsubscribe = new Subject();
|
|
36
|
+
|
|
37
|
+
constructor(private fb: FormBuilder) {
|
|
38
|
+
super();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private handleInternalPlusValidation(
|
|
42
|
+
mainField: any,
|
|
43
|
+
data: any
|
|
44
|
+
) {
|
|
45
|
+
const { operator, field, value } = mainField;
|
|
46
|
+
const validators: any = {
|
|
47
|
+
e: (val1: any, val2: string) => { return val1 === val2; },
|
|
48
|
+
lt: (val1: any, val2: string) => { return val1 < val2; },
|
|
49
|
+
gt: (val1: any, val2: string) => { return val1 > val2; }
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return validators[operator](data?.[field] || data, value);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private makeInternalPlusValidation(
|
|
56
|
+
data: any,
|
|
57
|
+
sourceField: string,
|
|
58
|
+
settings: any,
|
|
59
|
+
rowIndex: number
|
|
60
|
+
) {
|
|
61
|
+
const changeFields = (show: boolean) => {
|
|
62
|
+
const saved = [...this.fields];
|
|
63
|
+
|
|
64
|
+
saved.map((val) => {
|
|
65
|
+
const valSaved = {
|
|
66
|
+
...val
|
|
67
|
+
};
|
|
68
|
+
if (val.name === sourceField) {
|
|
69
|
+
this._plusValidations[rowIndex] = {
|
|
70
|
+
[sourceField]: {
|
|
71
|
+
...valSaved,
|
|
72
|
+
alwaysShow: show
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
this.createOneControl(val.name, this.formValues?.controls[rowIndex], show);
|
|
76
|
+
} else {
|
|
77
|
+
this._plusValidations[rowIndex] = {
|
|
78
|
+
...valSaved
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const validated = this.handleInternalPlusValidation(settings, data);
|
|
86
|
+
changeFields(validated);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private createOneControl(fieldName: string, ctrl: any, create = true) {
|
|
90
|
+
const { fields } = this;
|
|
91
|
+
if (!fields) return;
|
|
92
|
+
|
|
93
|
+
fields.forEach((field: MECXFieldConfig) => {
|
|
94
|
+
const { fieldType, validations, name, disabled } = field;
|
|
95
|
+
if (name !== fieldName) return;
|
|
96
|
+
let { value } = field;
|
|
97
|
+
if (fieldType === 'button') return;
|
|
98
|
+
if (fieldType === 'radiobutton' || fieldType === 'checkbox' || fieldType === 'select') {
|
|
99
|
+
value = '';
|
|
100
|
+
}
|
|
101
|
+
if (create) {
|
|
102
|
+
const control = this.fb.control(value, this.bindValidations(validations || []));
|
|
103
|
+
if (disabled || this.disabled) control.disable();
|
|
104
|
+
ctrl.addControl(name, control);
|
|
105
|
+
} else {
|
|
106
|
+
ctrl.removeControl(name);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private createControl(data?: any) {
|
|
112
|
+
const { fields } = this;
|
|
113
|
+
if (!fields) return null;
|
|
114
|
+
// eslint-disable-next-line object-curly-newline
|
|
115
|
+
const group = this.fb.group({});
|
|
116
|
+
fields.forEach((field: MECXFieldConfig) => {
|
|
117
|
+
const { fieldType, validations, name, disabled, alwaysShow } = field;
|
|
118
|
+
let { value } = field;
|
|
119
|
+
if (field.alwaysShowPlusValidation) {
|
|
120
|
+
if (!this.handleInternalPlusValidation(field.alwaysShowPlusValidation, data)) return;
|
|
121
|
+
} else if (!alwaysShow) return;
|
|
122
|
+
if (fieldType === 'button') return;
|
|
123
|
+
if (fieldType === 'radiobutton' || fieldType === 'checkbox' || fieldType === 'select') {
|
|
124
|
+
value = '';
|
|
125
|
+
}
|
|
126
|
+
const control = this.fb.control(value, this.bindValidations(validations || []));
|
|
127
|
+
if (disabled || this.disabled) control.disable();
|
|
128
|
+
group.addControl(name as string, control);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
return group;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private bindValidations(validations: MECXFieldConfigValidator[]) {
|
|
135
|
+
if (validations.length > 0) {
|
|
136
|
+
const validList: any[] = [];
|
|
137
|
+
validations.forEach((valid: MECXFieldConfigValidator) => {
|
|
138
|
+
const validated = valid.param
|
|
139
|
+
? validators[valid.name](valid.param)
|
|
140
|
+
: validators[valid.name];
|
|
141
|
+
validList.push(validated);
|
|
142
|
+
});
|
|
143
|
+
return Validators.compose(validList);
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private buildForm(): FormGroup {
|
|
149
|
+
const form = this.fb.group({
|
|
150
|
+
fields: this.fb.array([])
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
form?.controls.fields?.valueChanges.subscribe((_) => {
|
|
154
|
+
this.watchForChanges();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
return form;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private watchForChanges() {
|
|
161
|
+
const { fields, changesUnsubscribe } = this;
|
|
162
|
+
changesUnsubscribe.next();
|
|
163
|
+
|
|
164
|
+
this.formValues?.controls?.map((control: any, index: number) => {
|
|
165
|
+
fields.forEach((fieldConfig: MECXFieldConfig) => {
|
|
166
|
+
const { name, alwaysShowPlusValidation } = fieldConfig;
|
|
167
|
+
if (!alwaysShowPlusValidation) return;
|
|
168
|
+
const { field } = alwaysShowPlusValidation;
|
|
169
|
+
if (field) {
|
|
170
|
+
control.controls[field]?.valueChanges.pipe(
|
|
171
|
+
takeUntil(changesUnsubscribe)).subscribe((_: any) => {
|
|
172
|
+
this.makeInternalPlusValidation(
|
|
173
|
+
_,
|
|
174
|
+
name as string,
|
|
175
|
+
alwaysShowPlusValidation,
|
|
176
|
+
index
|
|
177
|
+
);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
return null;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
public formBase = () => {
|
|
186
|
+
// return this.fb.group(this.createControl());
|
|
187
|
+
return this.createControl();
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
public get formValues() {
|
|
191
|
+
return this._form ? (this._form.get('fields') as FormArray) : null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
public fillValues() {
|
|
195
|
+
const { data, qtd } = this;
|
|
196
|
+
if ((!this._form) && qtd) return;
|
|
197
|
+
if (qtd > 0) {
|
|
198
|
+
Array<any>(qtd)
|
|
199
|
+
.fill(null)
|
|
200
|
+
.map((_, index) => {
|
|
201
|
+
let form = this.createControl();
|
|
202
|
+
if (data && data[index]) {
|
|
203
|
+
form = this.createControl(data[index]);
|
|
204
|
+
const handledData = data[index];
|
|
205
|
+
Object.entries(handledData).forEach(([key, value]) => {
|
|
206
|
+
if (MonkeyUtils.persistNullEmptyUndefined(value) && form?.controls[key]) {
|
|
207
|
+
form?.controls[key].setValue(value);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
this.formValues?.push(form as any);
|
|
212
|
+
|
|
213
|
+
return null;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
ngOnInit() {
|
|
219
|
+
this._form = this.buildForm();
|
|
220
|
+
this.fillValues();
|
|
221
|
+
|
|
222
|
+
this.onHandleUpdateForm.subscribe(() => {
|
|
223
|
+
this.fillValues();
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
ngOnChanges() {
|
|
228
|
+
if (!this._form) {
|
|
229
|
+
this._form = this.buildForm();
|
|
230
|
+
}
|
|
231
|
+
this.fillValues();
|
|
232
|
+
}
|
|
233
|
+
}
|