ngx-sp-infra 0.0.0
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/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/2a/a3/eba6ea21e2e566c49202226aa3c1a4d439fa0a2c077374e48d864f20f5f804dbd931f042ddaa359fd35903a0bd3663a223e24dc11e1ec44501cc688a0a9c +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/46/44/91b55887c08130e8014b3dbe56b69c0c29f4e127bceafcd610165f4c8e77fefa799ab68c415c1b45cc4fa114565650f3fc3c258e1dc7b792935cbee43fa7 +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/7e/62/f8e6238b8f05aeaee2346bcaeda2226be7ab048d3b15e3dbbdf37170d9d7fade0fdfc6cc265d1ecc1b47509c962115d0d4b9a503907d6790c632e191001b +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/8d/53/ad58764bc240411378ae1c47c0c20525da378a3b143795a11bc3fdbf6c9cde6fb2de6c3947d673d5872b9ce205d6274114b3b4dfd27609a636df7fd0b600 +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/9e/70/9fc33090191a9df303901910a34f5d1cc7ea38ac92e21006bf923a814a4dffe9ad5b7357989f95d4e371cd00318c29339ec3e935832e84f3571ba0ed5f25 +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/a1/3a/6a6f351adef4b7c8b7d643b092ca26e0ceeb2a285456285f866504493c9c7db8d420d3a4f282c699a11f2f9933c828c8f8388f28e96372408d7b456f32a1 +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/d3/e3/2852d10551b620a4dfaabb1268bf0ac681e206bfb66451e18ac43a2e5c7cdc8a75291e3a1a4038129f3e40cc11317edffe8434d7110d9579585a25843e15 +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/f2/ee/05ff4c2260f161b6295a8507440a1b86c0f666f313866e5bf1de6829ae5fe384d6612d732d09c815fe515bd3d6379ed5f8136cf4a4e228b322309840240e +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/fe/15/fb0370939f075c14617e0d5fd8411f76edb53e439e19683e5c4554ae7cabd0387c922f6ec6893ced3321ed77df2c851b82eea6a70b38b7396f68493eea19 +1 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/10/17/ae308ad3e0cad0afd27bf9eafe0177fdb23b463e70e0dd30d23c117517f6 +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/14/18/88eabde022c32e7a38011f4ab6f7945e52f018be1abbe6a96864f8f9e22c +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/1c/b7/dcd00bf2f1de70eab7d9e1d9601fbd87f49d46c7b49671d81ccd4b20b3f1 +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/4b/31/217b5311dae6305f9b5dc82062276c77f272d61fc3e27c2df5eb0d6b1fb7 +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/6a/b0/e5091f9ee02b3fcac9821e92cc5113d6b0593bd8bacfb5cbac7dfca306c3 +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/9b/66/70a7c5990683795072c8b98eb25407b36f55f8efa8d2e0bdef67a8e989ab +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/a6/8b/af2670adca8f5d06d3d9577ffad4449e4897eaf85de2f4e7f43f93934a16 +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/da/da/502cfd37a0e9e7f413a569ccf28dc682f9e942ec5e460c93c1dd7c4e531f +3 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/f3/8b/4e00bb8eddd473ae09b0b5dee39fa8416aee7b659a770d18c767e5027992 +2 -0
- package/.editorconfig +16 -0
- package/README.md +27 -0
- package/angular.json +41 -0
- package/dist/ngx-sp-infra/README.md +12 -0
- package/dist/ngx-sp-infra/esm2022/lib/infra.module.mjs +137 -0
- package/dist/ngx-sp-infra/esm2022/lib/message/alert/alert.component.mjs +32 -0
- package/dist/ngx-sp-infra/esm2022/lib/message/confirm/confirm.component.mjs +52 -0
- package/dist/ngx-sp-infra/esm2022/lib/message/confirm-modal/confirm-modal.component.mjs +72 -0
- package/dist/ngx-sp-infra/esm2022/lib/message/message-enum.mjs +23 -0
- package/dist/ngx-sp-infra/esm2022/lib/message/message.service.mjs +132 -0
- package/dist/ngx-sp-infra/esm2022/lib/message/save/save.component.mjs +46 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/DownloadArquivos.mjs +3 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/email-model.mjs +35 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/ierror.mjs +2 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/ipagination.mjs +2 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/report-file.mjs +7 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/ret-error.mjs +3 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/ret-feedback-message.mjs +7 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/ret-report-file.mjs +3 -0
- package/dist/ngx-sp-infra/esm2022/lib/pipes/cpf-cnpj.pipe.mjs +23 -0
- package/dist/ngx-sp-infra/esm2022/lib/pipes/currency.pipe.mjs +16 -0
- package/dist/ngx-sp-infra/esm2022/lib/pipes/to-url.pipe.mjs +32 -0
- package/dist/ngx-sp-infra/esm2022/lib/utils/check-url-and-method.service.mjs +70 -0
- package/dist/ngx-sp-infra/esm2022/lib/utils/form-utils.mjs +38 -0
- package/dist/ngx-sp-infra/esm2022/lib/utils/ip-service.service.mjs +22 -0
- package/dist/ngx-sp-infra/esm2022/lib/utils/settings.service.mjs +32 -0
- package/dist/ngx-sp-infra/esm2022/lib/utils/utils.mjs +335 -0
- package/dist/ngx-sp-infra/esm2022/lib/validators/cpf-cnpj.validator.directive.mjs +24 -0
- package/dist/ngx-sp-infra/esm2022/lib/validators/cpf-cnpj.validator.mjs +54 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/breadcrumb/infra-breadcrumb/infra-breadcrumb.component.mjs +35 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/breadcrumb/infra-breadcrumb-item/infra-breadcrumb-item.component.mjs +28 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/breadcrumb/portalrh-breadcrumb/breadcrumb.component.mjs +21 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/click-outside/clickoutside.directive.mjs +167 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/combobox/combobox.component.mjs +545 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/combobox/pipes/filter-by.pipe.mjs +44 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/combobox/pipes/limit-to.pipe.mjs +19 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/field-control-error/field-control-error.component.mjs +23 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/field-error-message/field-error-message.component.mjs +33 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/loading/loading.component.mjs +12 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/loading-button/loading-button.component.mjs +15 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/ordering/ordering.component.mjs +56 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/svg-storage/svg-storage.component.mjs +94 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/tree/models/ret-tree.mjs +3 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/tree/models/tree-item.mjs +7 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/tree/pipes/search-tree.pipe.mjs +17 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/tree/tree.component.mjs +91 -0
- package/dist/ngx-sp-infra/esm2022/ngx-sp-infra.mjs +5 -0
- package/dist/ngx-sp-infra/esm2022/public-api.mjs +51 -0
- package/dist/ngx-sp-infra/fesm2022/ngx-sp-infra.mjs +2313 -0
- package/dist/ngx-sp-infra/fesm2022/ngx-sp-infra.mjs.map +1 -0
- package/dist/ngx-sp-infra/index.d.ts +5 -0
- package/dist/ngx-sp-infra/lib/infra.module.d.ts +32 -0
- package/dist/ngx-sp-infra/lib/message/alert/alert.component.d.ts +14 -0
- package/dist/ngx-sp-infra/lib/message/confirm/confirm.component.d.ts +22 -0
- package/dist/ngx-sp-infra/lib/message/confirm-modal/confirm-modal.component.d.ts +33 -0
- package/dist/ngx-sp-infra/lib/message/message-enum.d.ts +20 -0
- package/dist/ngx-sp-infra/lib/message/message.service.d.ts +31 -0
- package/dist/ngx-sp-infra/lib/message/save/save.component.d.ts +21 -0
- package/dist/ngx-sp-infra/lib/models/DownloadArquivos.d.ts +11 -0
- package/dist/ngx-sp-infra/lib/models/email-model.d.ts +30 -0
- package/dist/ngx-sp-infra/lib/models/ierror.d.ts +4 -0
- package/dist/ngx-sp-infra/lib/models/ipagination.d.ts +5 -0
- package/dist/ngx-sp-infra/lib/models/report-file.d.ts +4 -0
- package/dist/ngx-sp-infra/lib/models/ret-error.d.ts +5 -0
- package/dist/ngx-sp-infra/lib/models/ret-feedback-message.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/models/ret-report-file.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/pipes/cpf-cnpj.pipe.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/pipes/currency.pipe.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/pipes/to-url.pipe.d.ts +16 -0
- package/dist/ngx-sp-infra/lib/utils/check-url-and-method.service.d.ts +35 -0
- package/dist/ngx-sp-infra/lib/utils/form-utils.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/utils/ip-service.service.d.ts +9 -0
- package/dist/ngx-sp-infra/lib/utils/settings.service.d.ts +9 -0
- package/dist/ngx-sp-infra/lib/utils/utils.d.ts +58 -0
- package/dist/ngx-sp-infra/lib/validators/cpf-cnpj.validator.d.ts +18 -0
- package/dist/ngx-sp-infra/lib/validators/cpf-cnpj.validator.directive.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/widgets/breadcrumb/infra-breadcrumb/infra-breadcrumb.component.d.ts +29 -0
- package/dist/ngx-sp-infra/lib/widgets/breadcrumb/infra-breadcrumb-item/infra-breadcrumb-item.component.d.ts +14 -0
- package/dist/ngx-sp-infra/lib/widgets/breadcrumb/portalrh-breadcrumb/breadcrumb.component.d.ts +10 -0
- package/dist/ngx-sp-infra/lib/widgets/click-outside/clickoutside.directive.d.ts +40 -0
- package/dist/ngx-sp-infra/lib/widgets/combobox/combobox.component.d.ts +174 -0
- package/dist/ngx-sp-infra/lib/widgets/combobox/pipes/filter-by.pipe.d.ts +10 -0
- package/dist/ngx-sp-infra/lib/widgets/combobox/pipes/limit-to.pipe.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/widgets/field-control-error/field-control-error.component.d.ts +12 -0
- package/dist/ngx-sp-infra/lib/widgets/field-error-message/field-error-message.component.d.ts +14 -0
- package/dist/ngx-sp-infra/lib/widgets/loading/loading.component.d.ts +6 -0
- package/dist/ngx-sp-infra/lib/widgets/loading-button/loading-button.component.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/widgets/ordering/ordering.component.d.ts +18 -0
- package/dist/ngx-sp-infra/lib/widgets/svg-storage/svg-storage.component.d.ts +16 -0
- package/dist/ngx-sp-infra/lib/widgets/tree/models/ret-tree.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/widgets/tree/models/tree-item.d.ts +11 -0
- package/dist/ngx-sp-infra/lib/widgets/tree/pipes/search-tree.pipe.d.ts +8 -0
- package/dist/ngx-sp-infra/lib/widgets/tree/tree.component.d.ts +20 -0
- package/dist/ngx-sp-infra/package.json +37 -0
- package/dist/ngx-sp-infra/public-api.d.ts +47 -0
- package/package.json +43 -0
- package/projects/ngx-sp-infra/README.md +12 -0
- package/projects/ngx-sp-infra/karma.conf.js +44 -0
- package/projects/ngx-sp-infra/ng-package.json +7 -0
- package/projects/ngx-sp-infra/package-lock.json +225 -0
- package/projects/ngx-sp-infra/package.json +18 -0
- package/projects/ngx-sp-infra/src/lib/infra.module.ts +85 -0
- package/projects/ngx-sp-infra/src/lib/message/alert/alert.component.html +6 -0
- package/projects/ngx-sp-infra/src/lib/message/alert/alert.component.scss +5 -0
- package/projects/ngx-sp-infra/src/lib/message/alert/alert.component.ts +39 -0
- package/projects/ngx-sp-infra/src/lib/message/confirm/confirm.component.html +15 -0
- package/projects/ngx-sp-infra/src/lib/message/confirm/confirm.component.scss +0 -0
- package/projects/ngx-sp-infra/src/lib/message/confirm/confirm.component.ts +52 -0
- package/projects/ngx-sp-infra/src/lib/message/confirm-modal/confirm-modal.component.html +39 -0
- package/projects/ngx-sp-infra/src/lib/message/confirm-modal/confirm-modal.component.scss +0 -0
- package/projects/ngx-sp-infra/src/lib/message/confirm-modal/confirm-modal.component.ts +73 -0
- package/projects/ngx-sp-infra/src/lib/message/message-enum.ts +21 -0
- package/projects/ngx-sp-infra/src/lib/message/message.service.ts +169 -0
- package/projects/ngx-sp-infra/src/lib/message/save/save.component.html +35 -0
- package/projects/ngx-sp-infra/src/lib/message/save/save.component.scss +110 -0
- package/projects/ngx-sp-infra/src/lib/message/save/save.component.ts +44 -0
- package/projects/ngx-sp-infra/src/lib/models/DownloadArquivos.ts +12 -0
- package/projects/ngx-sp-infra/src/lib/models/email-model.ts +33 -0
- package/projects/ngx-sp-infra/src/lib/models/ierror.ts +4 -0
- package/projects/ngx-sp-infra/src/lib/models/ipagination.ts +5 -0
- package/projects/ngx-sp-infra/src/lib/models/report-file.ts +4 -0
- package/projects/ngx-sp-infra/src/lib/models/ret-error.ts +6 -0
- package/projects/ngx-sp-infra/src/lib/models/ret-feedback-message.ts +8 -0
- package/projects/ngx-sp-infra/src/lib/models/ret-report-file.ts +8 -0
- package/projects/ngx-sp-infra/src/lib/pipes/cpf-cnpj.pipe.ts +21 -0
- package/projects/ngx-sp-infra/src/lib/pipes/currency.pipe.ts +13 -0
- package/projects/ngx-sp-infra/src/lib/pipes/to-url.pipe.ts +33 -0
- package/projects/ngx-sp-infra/src/lib/utils/check-url-and-method.service.ts +84 -0
- package/projects/ngx-sp-infra/src/lib/utils/form-utils.ts +50 -0
- package/projects/ngx-sp-infra/src/lib/utils/ip-service.service.ts +22 -0
- package/projects/ngx-sp-infra/src/lib/utils/settings.service.ts +32 -0
- package/projects/ngx-sp-infra/src/lib/utils/utils.ts +427 -0
- package/projects/ngx-sp-infra/src/lib/validators/cpf-cnpj.validator.directive.ts +14 -0
- package/projects/ngx-sp-infra/src/lib/validators/cpf-cnpj.validator.ts +74 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/infra-breadcrumb/infra-breadcrumb.component.css +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/infra-breadcrumb/infra-breadcrumb.component.html +3 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/infra-breadcrumb/infra-breadcrumb.component.ts +34 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/infra-breadcrumb-item/infra-breadcrumb-item.component.css +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/infra-breadcrumb-item/infra-breadcrumb-item.component.html +1 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/infra-breadcrumb-item/infra-breadcrumb-item.component.ts +29 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/portalrh-breadcrumb/breadcrumb.component.css +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/portalrh-breadcrumb/breadcrumb.component.html +5 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/portalrh-breadcrumb/breadcrumb.component.ts +18 -0
- package/projects/ngx-sp-infra/src/lib/widgets/click-outside/clickoutside.directive.ts +183 -0
- package/projects/ngx-sp-infra/src/lib/widgets/combobox/combobox.component.html +40 -0
- package/projects/ngx-sp-infra/src/lib/widgets/combobox/combobox.component.scss +185 -0
- package/projects/ngx-sp-infra/src/lib/widgets/combobox/combobox.component.ts +637 -0
- package/projects/ngx-sp-infra/src/lib/widgets/combobox/combobox.service.ts +15 -0
- package/projects/ngx-sp-infra/src/lib/widgets/combobox/pipes/filter-by.pipe.ts +38 -0
- package/projects/ngx-sp-infra/src/lib/widgets/combobox/pipes/limit-to.pipe.ts +13 -0
- package/projects/ngx-sp-infra/src/lib/widgets/field-control-error/field-control-error.component.css +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/field-control-error/field-control-error.component.html +4 -0
- package/projects/ngx-sp-infra/src/lib/widgets/field-control-error/field-control-error.component.ts +18 -0
- package/projects/ngx-sp-infra/src/lib/widgets/field-error-message/field-error-message.component.css +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/field-error-message/field-error-message.component.html +4 -0
- package/projects/ngx-sp-infra/src/lib/widgets/field-error-message/field-error-message.component.ts +35 -0
- package/projects/ngx-sp-infra/src/lib/widgets/loading/loading.component.css +7 -0
- package/projects/ngx-sp-infra/src/lib/widgets/loading/loading.component.html +4 -0
- package/projects/ngx-sp-infra/src/lib/widgets/loading/loading.component.ts +12 -0
- package/projects/ngx-sp-infra/src/lib/widgets/loading-button/loading-button.component.css +3 -0
- package/projects/ngx-sp-infra/src/lib/widgets/loading-button/loading-button.component.html +2 -0
- package/projects/ngx-sp-infra/src/lib/widgets/loading-button/loading-button.component.ts +13 -0
- package/projects/ngx-sp-infra/src/lib/widgets/ordering/ordering.component.html +23 -0
- package/projects/ngx-sp-infra/src/lib/widgets/ordering/ordering.component.scss +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/ordering/ordering.component.ts +50 -0
- package/projects/ngx-sp-infra/src/lib/widgets/svg-storage/svg-storage.component.html +728 -0
- package/projects/ngx-sp-infra/src/lib/widgets/svg-storage/svg-storage.component.scss +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/svg-storage/svg-storage.component.ts +105 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/README.md +33 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/models/ret-tree.ts +8 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/models/tree-item.ts +11 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/pipes/search-tree.pipe.ts +15 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/tree.component.html +51 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/tree.component.scss +57 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/tree.component.ts +88 -0
- package/projects/ngx-sp-infra/src/public-api.ts +58 -0
- package/projects/ngx-sp-infra/src/test.ts +15 -0
- package/projects/ngx-sp-infra/tsconfig.lib.json +15 -0
- package/projects/ngx-sp-infra/tsconfig.lib.prod.json +10 -0
- package/projects/ngx-sp-infra/tsconfig.spec.json +17 -0
- package/sp-ng-infra-0.0.0.tgz +0 -0
- package/tsconfig.json +42 -0
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component, OnInit, Input,
|
|
3
|
+
EventEmitter,
|
|
4
|
+
Output,
|
|
5
|
+
HostListener,
|
|
6
|
+
OnChanges,
|
|
7
|
+
SimpleChanges,
|
|
8
|
+
ViewChildren,
|
|
9
|
+
ElementRef,
|
|
10
|
+
QueryList,
|
|
11
|
+
AfterViewInit,
|
|
12
|
+
ChangeDetectorRef,
|
|
13
|
+
forwardRef
|
|
14
|
+
} from '@angular/core';
|
|
15
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
16
|
+
import { FilterByPipe } from './pipes/filter-by.pipe';
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@Component( {
|
|
20
|
+
selector: 'app-combobox',
|
|
21
|
+
templateUrl: './combobox.component.html',
|
|
22
|
+
styleUrls: [ './combobox.component.scss' ],
|
|
23
|
+
providers: [
|
|
24
|
+
{
|
|
25
|
+
provide: NG_VALUE_ACCESSOR,
|
|
26
|
+
useExisting: forwardRef( () => ComboboxComponent ),
|
|
27
|
+
multi: true,
|
|
28
|
+
},
|
|
29
|
+
]
|
|
30
|
+
} )
|
|
31
|
+
export class ComboboxComponent implements OnInit, OnChanges, AfterViewInit {
|
|
32
|
+
|
|
33
|
+
/** value of the dropdown */
|
|
34
|
+
@Input() public _value: any;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get the required inputs
|
|
38
|
+
*/
|
|
39
|
+
@Input() public options: any = [];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* configuration options
|
|
43
|
+
*/
|
|
44
|
+
@Input() public config: any = {};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Whether multiple selection or single selection allowed
|
|
48
|
+
*/
|
|
49
|
+
@Input() public multiple = false;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Value
|
|
53
|
+
*/
|
|
54
|
+
@Input() public disabled: boolean;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* change event when value changes to provide user to handle things in change event
|
|
58
|
+
*/
|
|
59
|
+
@Output() public change: EventEmitter<any> = new EventEmitter();
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The search text change event emitter emitted when user type in the search input
|
|
63
|
+
*/
|
|
64
|
+
@Output() public searchChange: EventEmitter<any> = new EventEmitter();
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Event emitted when dropdown is open.
|
|
68
|
+
*/
|
|
69
|
+
@Output() public open: EventEmitter<any> = new EventEmitter();
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Event emitted when dropdown is open.
|
|
73
|
+
*/
|
|
74
|
+
@Output() public close: EventEmitter<any> = new EventEmitter();
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Toogle the dropdown list
|
|
78
|
+
*/
|
|
79
|
+
public toggleDropdown = false;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Available items for selection
|
|
83
|
+
*/
|
|
84
|
+
public availableItems: any = [];
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Selected Items
|
|
88
|
+
*/
|
|
89
|
+
public selectedItems: any = [];
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Selection text to be Displayed
|
|
93
|
+
*/
|
|
94
|
+
public selectedDisplayText = '-';
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Search text
|
|
98
|
+
*/
|
|
99
|
+
public searchText: string | undefined;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* variable to track if clicked inside or outside of component
|
|
103
|
+
*/
|
|
104
|
+
public clickedInside = false;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* variable to track keypress event inside and outsid of component
|
|
108
|
+
*/
|
|
109
|
+
public insideKeyPress = false;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* variable to track the focused item whenuser uses arrow keys to select item
|
|
113
|
+
*/
|
|
114
|
+
public focusedItemIndex: number | null;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* element to show not found text when not itmes match the search
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
public showNotFound = false;
|
|
121
|
+
/**
|
|
122
|
+
* Hold the reference to available items in the list to focus on the item when scrolling
|
|
123
|
+
*/
|
|
124
|
+
@ViewChildren( 'availableOption' )
|
|
125
|
+
public availableOptions: QueryList<ElementRef>;
|
|
126
|
+
|
|
127
|
+
get value () {
|
|
128
|
+
return this._value;
|
|
129
|
+
}
|
|
130
|
+
set value ( val ) {
|
|
131
|
+
this._value = val;
|
|
132
|
+
this.onChange( val );
|
|
133
|
+
this.onTouched();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
constructor (
|
|
137
|
+
private cdref: ChangeDetectorRef,
|
|
138
|
+
public _elementRef: ElementRef
|
|
139
|
+
) {
|
|
140
|
+
this.multiple = false;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public onChange: any = () => {
|
|
144
|
+
// empty
|
|
145
|
+
}
|
|
146
|
+
public onTouched: any = () => {
|
|
147
|
+
// empty
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* click listener for host inside this component i.e
|
|
152
|
+
* if many instances are there, this detects if clicked inside
|
|
153
|
+
* this instance
|
|
154
|
+
*/
|
|
155
|
+
@HostListener( 'click' )
|
|
156
|
+
public clickInsideComponent () {
|
|
157
|
+
this.clickedInside = true;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@HostListener( 'blur' ) public blur () {
|
|
161
|
+
this.toggleDropdown = false;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@HostListener( 'focus' ) public focus () {
|
|
165
|
+
/* istanbul ignore else */
|
|
166
|
+
if ( !this.disabled )
|
|
167
|
+
{
|
|
168
|
+
this.toggleSelectDropdown();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* click handler on documnent to hide the open dropdown if clicked outside
|
|
173
|
+
*/
|
|
174
|
+
@HostListener( 'document:click' )
|
|
175
|
+
public clickOutsideComponent () {
|
|
176
|
+
/* istanbul ignore else */
|
|
177
|
+
if ( !this.clickedInside )
|
|
178
|
+
{
|
|
179
|
+
this.toggleDropdown = false;
|
|
180
|
+
this.resetArrowKeyActiveElement();
|
|
181
|
+
// clear searh on close
|
|
182
|
+
this.searchText = undefined;
|
|
183
|
+
this.close.emit();
|
|
184
|
+
}
|
|
185
|
+
this.clickedInside = false;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* click handler on documnent to hide the open dropdown if clicked outside
|
|
190
|
+
*/
|
|
191
|
+
@HostListener( 'document:keydown' )
|
|
192
|
+
public KeyPressOutsideComponent () {
|
|
193
|
+
/* istanbul ignore else */
|
|
194
|
+
if ( !this.insideKeyPress )
|
|
195
|
+
{
|
|
196
|
+
this.toggleDropdown = false;
|
|
197
|
+
this.resetArrowKeyActiveElement();
|
|
198
|
+
}
|
|
199
|
+
this.insideKeyPress = false;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Event handler for key up and down event and enter press for selecting element
|
|
203
|
+
*/
|
|
204
|
+
@HostListener( 'keydown', [ '$event' ] )
|
|
205
|
+
public handleKeyboardEvent ( $event: KeyboardEvent) {
|
|
206
|
+
this.insideKeyPress = true;
|
|
207
|
+
/* istanbul ignore else */
|
|
208
|
+
if ( $event.keyCode === 27 || this.disabled )
|
|
209
|
+
{
|
|
210
|
+
this.toggleDropdown = false;
|
|
211
|
+
this.insideKeyPress = false;
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const avaOpts = this.availableOptions.toArray();
|
|
215
|
+
/* istanbul ignore else */
|
|
216
|
+
if ( $event.keyCode !== 9 && avaOpts.length === 0 && !this.toggleDropdown )
|
|
217
|
+
{
|
|
218
|
+
this.toggleDropdown = true;
|
|
219
|
+
}
|
|
220
|
+
// Arrow Down
|
|
221
|
+
/* istanbul ignore else */
|
|
222
|
+
if ( $event.keyCode === 40 && avaOpts.length > 0 )
|
|
223
|
+
{
|
|
224
|
+
this.onArrowKeyDown();
|
|
225
|
+
/* istanbul ignore else */
|
|
226
|
+
if ( this.focusedItemIndex! >= avaOpts.length )
|
|
227
|
+
{
|
|
228
|
+
this.focusedItemIndex = 0;
|
|
229
|
+
}
|
|
230
|
+
avaOpts[ this.focusedItemIndex! ].nativeElement.focus();
|
|
231
|
+
$event.preventDefault();
|
|
232
|
+
}
|
|
233
|
+
// Arrow Up
|
|
234
|
+
/* istanbul ignore else */
|
|
235
|
+
if ( $event.keyCode === 38 && avaOpts.length )
|
|
236
|
+
{
|
|
237
|
+
this.onArrowKeyUp();
|
|
238
|
+
/* istanbul ignore else */
|
|
239
|
+
if ( this.focusedItemIndex! >= avaOpts.length )
|
|
240
|
+
{
|
|
241
|
+
this.focusedItemIndex = avaOpts.length - 1;
|
|
242
|
+
}
|
|
243
|
+
avaOpts[ this.focusedItemIndex! ].nativeElement.focus();
|
|
244
|
+
$event.preventDefault();
|
|
245
|
+
}
|
|
246
|
+
// Enter
|
|
247
|
+
/* istanbul ignore else */
|
|
248
|
+
if ( $event.keyCode === 13 && this.focusedItemIndex !== null )
|
|
249
|
+
{
|
|
250
|
+
const filteredItems = new FilterByPipe().transform(
|
|
251
|
+
this.availableItems,
|
|
252
|
+
this.searchText!,
|
|
253
|
+
this.config.searchOnKey
|
|
254
|
+
);
|
|
255
|
+
this.selectItem(
|
|
256
|
+
filteredItems[ this.focusedItemIndex ],
|
|
257
|
+
this.availableItems.indexOf( filteredItems[ this.focusedItemIndex ] )
|
|
258
|
+
);
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return $event.key
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Component onInit
|
|
268
|
+
*/
|
|
269
|
+
public ngOnInit () {
|
|
270
|
+
/* istanbul ignore else */
|
|
271
|
+
if ( typeof this.options !== 'undefined' && Array.isArray( this.options ) )
|
|
272
|
+
{
|
|
273
|
+
this.availableItems = [
|
|
274
|
+
...this.options.sort( this.config.customComparator ),
|
|
275
|
+
];
|
|
276
|
+
this.initDropdownValuesAndOptions();
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* after view init to subscribe to available option changes
|
|
282
|
+
*/
|
|
283
|
+
public ngAfterViewInit () {
|
|
284
|
+
this.availableOptions.changes.subscribe( this.setNotFoundState.bind( this ) );
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
public registerOnChange ( fn: any ) {
|
|
288
|
+
this.onChange = fn;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
public registerOnTouched ( fn: any ) {
|
|
292
|
+
this.onTouched = fn;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
public setDisabledState ( isDisabled: boolean ) {
|
|
296
|
+
this.disabled = isDisabled;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
public writeValue ( value: any, internal?: boolean ) {
|
|
300
|
+
if ( value )
|
|
301
|
+
{
|
|
302
|
+
if ( Array.isArray( value ) )
|
|
303
|
+
{
|
|
304
|
+
if ( this.multiple )
|
|
305
|
+
{
|
|
306
|
+
this.value = value;
|
|
307
|
+
} else if ( value.length > 0 )
|
|
308
|
+
{
|
|
309
|
+
this.value = value[ 0 ];
|
|
310
|
+
}
|
|
311
|
+
} else
|
|
312
|
+
{
|
|
313
|
+
this.value = value;
|
|
314
|
+
}
|
|
315
|
+
/* istanbul ignore else */
|
|
316
|
+
if ( this.selectedItems.length === 0 )
|
|
317
|
+
{
|
|
318
|
+
if ( Array.isArray( value ) )
|
|
319
|
+
{
|
|
320
|
+
this.selectedItems = value;
|
|
321
|
+
} else
|
|
322
|
+
{
|
|
323
|
+
this.selectedItems.push( value );
|
|
324
|
+
}
|
|
325
|
+
this.initDropdownValuesAndOptions();
|
|
326
|
+
}
|
|
327
|
+
} else
|
|
328
|
+
{
|
|
329
|
+
this.value = [];
|
|
330
|
+
/* istanbul ignore else */
|
|
331
|
+
if ( !internal )
|
|
332
|
+
{
|
|
333
|
+
this.reset();
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/* istanbul ignore else */
|
|
337
|
+
if ( !internal )
|
|
338
|
+
{
|
|
339
|
+
this.reset();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
public reset () {
|
|
344
|
+
this.selectedItems = [];
|
|
345
|
+
this.availableItems = [ ...this.options.sort( this.config.customComparator ) ];
|
|
346
|
+
this.initDropdownValuesAndOptions();
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* function sets whether to show items not found text or not
|
|
350
|
+
*/
|
|
351
|
+
public setNotFoundState () {
|
|
352
|
+
if ( this.availableOptions.length === 0 )
|
|
353
|
+
{
|
|
354
|
+
this.showNotFound = true;
|
|
355
|
+
} else
|
|
356
|
+
{
|
|
357
|
+
this.showNotFound = false;
|
|
358
|
+
}
|
|
359
|
+
this.cdref.detectChanges();
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Component onchage i.e when any of the input properties change
|
|
363
|
+
*/
|
|
364
|
+
public ngOnChanges ( changes: SimpleChanges ) {
|
|
365
|
+
this.selectedItems = [];
|
|
366
|
+
// this.searchText = null;
|
|
367
|
+
this.options = this.options || [];
|
|
368
|
+
/* istanbul ignore else */
|
|
369
|
+
if ( changes[ 'options' ] )
|
|
370
|
+
{
|
|
371
|
+
this.availableItems = [
|
|
372
|
+
...this.options.sort( this.config.customComparator ),
|
|
373
|
+
];
|
|
374
|
+
}
|
|
375
|
+
/* istanbul ignore else */
|
|
376
|
+
if ( changes[ 'value' ] )
|
|
377
|
+
{
|
|
378
|
+
/* istanbul ignore else */
|
|
379
|
+
if (
|
|
380
|
+
JSON.stringify( changes[ 'value' ].currentValue ) === JSON.stringify( [] ) ||
|
|
381
|
+
changes[ 'value' ].currentValue === '' ||
|
|
382
|
+
changes[ 'value' ].currentValue === null
|
|
383
|
+
)
|
|
384
|
+
{
|
|
385
|
+
this.availableItems = [
|
|
386
|
+
...this.options.sort( this.config.customComparator ),
|
|
387
|
+
];
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
this.initDropdownValuesAndOptions();
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Deselct a selected items
|
|
395
|
+
* @param item: item to be deselected
|
|
396
|
+
* @param index: index of the item
|
|
397
|
+
*/
|
|
398
|
+
public deselectItem ( item: any, index: number ) {
|
|
399
|
+
this.selectedItems.forEach( ( element: any, i: number ) => {
|
|
400
|
+
/* istanbul ignore else */
|
|
401
|
+
if ( item === element )
|
|
402
|
+
{
|
|
403
|
+
this.selectedItems.splice( i, 1 );
|
|
404
|
+
}
|
|
405
|
+
} );
|
|
406
|
+
let sortedItems = [ ...this.availableItems ];
|
|
407
|
+
/* istanbul ignore else */
|
|
408
|
+
if ( !this.availableItems.includes( item ) )
|
|
409
|
+
{
|
|
410
|
+
this.availableItems.push( item );
|
|
411
|
+
sortedItems = this.availableItems.sort( this.config.customComparator );
|
|
412
|
+
}
|
|
413
|
+
this.selectedItems = [ ...this.selectedItems ];
|
|
414
|
+
this.availableItems = [ ...sortedItems ];
|
|
415
|
+
/* istanbul ignore else */
|
|
416
|
+
if ( !Array.isArray( this.value ) )
|
|
417
|
+
{
|
|
418
|
+
this.value = [];
|
|
419
|
+
}
|
|
420
|
+
this.valueChanged();
|
|
421
|
+
this.resetArrowKeyActiveElement();
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Select an item
|
|
426
|
+
* @param item: item to be selected
|
|
427
|
+
* @param index: index of the item
|
|
428
|
+
*/
|
|
429
|
+
public selectItem ( item: string, index?: number ) {
|
|
430
|
+
/* istanbul ignore else */
|
|
431
|
+
if ( !this.multiple )
|
|
432
|
+
{
|
|
433
|
+
/* istanbul ignore else */
|
|
434
|
+
if ( this.selectedItems.length > 0 )
|
|
435
|
+
{
|
|
436
|
+
this.availableItems.push( this.selectedItems[ 0 ] );
|
|
437
|
+
}
|
|
438
|
+
this.selectedItems = [];
|
|
439
|
+
this.toggleDropdown = false;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
this.availableItems.forEach( ( element: any, i: number ) => {
|
|
443
|
+
/* istanbul ignore else */
|
|
444
|
+
if ( item === element )
|
|
445
|
+
{
|
|
446
|
+
this.selectedItems.push( item );
|
|
447
|
+
this.availableItems.splice( i, 1 );
|
|
448
|
+
}
|
|
449
|
+
} );
|
|
450
|
+
|
|
451
|
+
/* istanbul ignore else */
|
|
452
|
+
if ( this.config.clearOnSelection )
|
|
453
|
+
{
|
|
454
|
+
this.searchText = undefined;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
this.selectedItems = [ ...this.selectedItems ];
|
|
458
|
+
this.availableItems = [ ...this.availableItems ];
|
|
459
|
+
this.selectedItems.sort( this.config.customComparator );
|
|
460
|
+
this.availableItems.sort( this.config.customComparator );
|
|
461
|
+
// this.searchText = null;
|
|
462
|
+
this.valueChanged();
|
|
463
|
+
this.resetArrowKeyActiveElement();
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* When selected items changes trigger the chaange back to parent
|
|
468
|
+
*/
|
|
469
|
+
public valueChanged () {
|
|
470
|
+
this.writeValue( this.selectedItems, true );
|
|
471
|
+
// this.valueChange.emit(this.value);
|
|
472
|
+
this.change.emit( { value: this.value } );
|
|
473
|
+
this.setSelectedDisplayText();
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Toggle the dropdownlist on/off
|
|
478
|
+
*/
|
|
479
|
+
public toggleSelectDropdown () {
|
|
480
|
+
this.toggleDropdown = !this.toggleDropdown;
|
|
481
|
+
if ( this.toggleDropdown )
|
|
482
|
+
{
|
|
483
|
+
this.open.emit();
|
|
484
|
+
} else
|
|
485
|
+
{
|
|
486
|
+
this.searchText = undefined;
|
|
487
|
+
this.close.emit();
|
|
488
|
+
}
|
|
489
|
+
this.resetArrowKeyActiveElement();
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* The change handler for search text
|
|
494
|
+
*/
|
|
495
|
+
public searchTextChanged () {
|
|
496
|
+
this.searchChange.emit( this.searchText );
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
public changeSearchText ( $event: any ) {
|
|
500
|
+
$event.stopPropagation();
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* initialize the config and other properties
|
|
505
|
+
*/
|
|
506
|
+
private initDropdownValuesAndOptions () {
|
|
507
|
+
const config: any = {
|
|
508
|
+
displayKey: 'description',
|
|
509
|
+
height: 'auto',
|
|
510
|
+
search: false,
|
|
511
|
+
placeholder: '-',
|
|
512
|
+
searchPlaceholder: 'Pesquisar ',
|
|
513
|
+
limitTo: 0,
|
|
514
|
+
customComparator: undefined,
|
|
515
|
+
noResultsFound: 'Nada encontrado!',
|
|
516
|
+
moreText: 'Selecionados',
|
|
517
|
+
searchOnKey: null,
|
|
518
|
+
clearOnSelection: false,
|
|
519
|
+
inputDirection: 'ltr',
|
|
520
|
+
};
|
|
521
|
+
/* istanbul ignore else */
|
|
522
|
+
if ( this.config === 'undefined' || Object.keys( this.config ).length === 0 )
|
|
523
|
+
{
|
|
524
|
+
this.config = { ...config };
|
|
525
|
+
}
|
|
526
|
+
for ( const key of Object.keys( config ) )
|
|
527
|
+
{
|
|
528
|
+
this.config[ key ] = this.config[ key ] ? this.config[ key ] : config[ key ];
|
|
529
|
+
}
|
|
530
|
+
this.config = { ...this.config };
|
|
531
|
+
// Adding placeholder in config as default param
|
|
532
|
+
this.selectedDisplayText = this.config[ 'placeholder' ];
|
|
533
|
+
/* istanbul ignore else */
|
|
534
|
+
if ( this.value !== '' && typeof this.value !== 'undefined' )
|
|
535
|
+
{
|
|
536
|
+
if ( Array.isArray( this.value ) )
|
|
537
|
+
{
|
|
538
|
+
this.selectedItems = this.value;
|
|
539
|
+
} else if ( this.value !== '' && this.value !== null )
|
|
540
|
+
{
|
|
541
|
+
this.selectedItems[ 0 ] = this.value;
|
|
542
|
+
} else
|
|
543
|
+
{
|
|
544
|
+
this.selectedItems = [];
|
|
545
|
+
this.value = [];
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
this.selectedItems.forEach( ( item: any ) => {
|
|
549
|
+
const ind = this.availableItems.findIndex(
|
|
550
|
+
( aItem: any ) => JSON.stringify( item ) === JSON.stringify( aItem )
|
|
551
|
+
);
|
|
552
|
+
if ( ind !== -1 )
|
|
553
|
+
{
|
|
554
|
+
this.availableItems.splice( ind, 1 );
|
|
555
|
+
}
|
|
556
|
+
} );
|
|
557
|
+
}
|
|
558
|
+
this.setSelectedDisplayText();
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* set the text to be displayed
|
|
563
|
+
*/
|
|
564
|
+
private setSelectedDisplayText () {
|
|
565
|
+
let text: string = this.selectedItems[ 0 ];
|
|
566
|
+
/* istanbul ignore else */
|
|
567
|
+
if ( typeof this.selectedItems[ 0 ] === 'object' )
|
|
568
|
+
{
|
|
569
|
+
text = this.config.displayFn
|
|
570
|
+
? this.config.displayFn( this.selectedItems[ 0 ] )
|
|
571
|
+
: this.selectedItems[ 0 ][ this.config.displayKey ];
|
|
572
|
+
}
|
|
573
|
+
if ( this.multiple && this.selectedItems.length > 0 )
|
|
574
|
+
{
|
|
575
|
+
this.selectedDisplayText =
|
|
576
|
+
this.selectedItems.length === 1
|
|
577
|
+
? text
|
|
578
|
+
: text +
|
|
579
|
+
` + ${ this.selectedItems.length - 1 } ${ this.config.moreText }`;
|
|
580
|
+
} else
|
|
581
|
+
{
|
|
582
|
+
this.selectedDisplayText =
|
|
583
|
+
this.selectedItems.length === 0 ? this.config.placeholder : text;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Event handler for arrow key up event thats focuses on a item
|
|
589
|
+
*/
|
|
590
|
+
private onArrowKeyUp () {
|
|
591
|
+
/* istanbul ignore else */
|
|
592
|
+
if ( this.focusedItemIndex === 0 )
|
|
593
|
+
{
|
|
594
|
+
this.focusedItemIndex = this.availableItems.length - 1;
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
/* istanbul ignore else */
|
|
598
|
+
if ( this.onArrowKey() )
|
|
599
|
+
{
|
|
600
|
+
this.focusedItemIndex!;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Event handler for arrow key down event thats focuses on a item
|
|
606
|
+
*/
|
|
607
|
+
private onArrowKeyDown () {
|
|
608
|
+
/* istanbul ignore else */
|
|
609
|
+
if ( this.focusedItemIndex === this.availableItems.length - 1 )
|
|
610
|
+
{
|
|
611
|
+
this.focusedItemIndex = 0;
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
/* istanbul ignore else */
|
|
615
|
+
if ( this.onArrowKey() )
|
|
616
|
+
{
|
|
617
|
+
this.focusedItemIndex!++;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
private onArrowKey () {
|
|
622
|
+
/* istanbul ignore else */
|
|
623
|
+
if ( this.focusedItemIndex === null )
|
|
624
|
+
{
|
|
625
|
+
this.focusedItemIndex = 0;
|
|
626
|
+
return false;
|
|
627
|
+
}
|
|
628
|
+
return true;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* will reset the element that is marked active using arrow keys
|
|
633
|
+
*/
|
|
634
|
+
private resetArrowKeyActiveElement () {
|
|
635
|
+
this.focusedItemIndex = null;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Injectable( {
|
|
4
|
+
providedIn: 'root'
|
|
5
|
+
} )
|
|
6
|
+
export class ComboboxService {
|
|
7
|
+
private _isOpen: boolean;
|
|
8
|
+
constructor () {
|
|
9
|
+
// constructor
|
|
10
|
+
this._isOpen = false;
|
|
11
|
+
}
|
|
12
|
+
get isOpen () {
|
|
13
|
+
return this._isOpen;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* filters an array based on searctext
|
|
5
|
+
*/
|
|
6
|
+
@Pipe({
|
|
7
|
+
name: 'filterBy'
|
|
8
|
+
})
|
|
9
|
+
export class FilterByPipe implements PipeTransform {
|
|
10
|
+
public transform(array: any[], searchText?: string, keyName?: string) {
|
|
11
|
+
if (!array || !searchText || !Array.isArray(array)) {
|
|
12
|
+
return array;
|
|
13
|
+
}
|
|
14
|
+
if (typeof array[0] === 'string') {
|
|
15
|
+
return array.filter((item) => item.toLowerCase().indexOf(searchText.toLowerCase()) > -1);
|
|
16
|
+
}
|
|
17
|
+
// filter array, items which match and return true will be
|
|
18
|
+
// kept, false will be filtered out
|
|
19
|
+
if (!keyName) {
|
|
20
|
+
return array.filter((item: any) => {
|
|
21
|
+
for (const key in item) {
|
|
22
|
+
if (typeof item[key] !== 'object' && item[key].toString().toLowerCase().indexOf(searchText.toLowerCase()) > -1) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
return array.filter((item: any) => {
|
|
30
|
+
if (typeof item[keyName] !== 'object' && item[keyName].toString().toLowerCase().indexOf(searchText.toLowerCase()) > -1) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Pipe({
|
|
4
|
+
name: 'limitTo'
|
|
5
|
+
})
|
|
6
|
+
export class LimitToPipe implements PipeTransform {
|
|
7
|
+
public transform(array: any[], itemsCount: number, startIndex: number = 0) {
|
|
8
|
+
if (!Array.isArray(array) || itemsCount === 0) {
|
|
9
|
+
return array;
|
|
10
|
+
}
|
|
11
|
+
return array.slice(startIndex, startIndex + itemsCount);
|
|
12
|
+
}
|
|
13
|
+
}
|
package/projects/ngx-sp-infra/src/lib/widgets/field-control-error/field-control-error.component.css
ADDED
|
File without changes
|