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,32 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Injectable({
|
|
4
|
+
providedIn: 'root'
|
|
5
|
+
})
|
|
6
|
+
export class SettingsService {
|
|
7
|
+
|
|
8
|
+
constructor() { }
|
|
9
|
+
|
|
10
|
+
getLocaleId() {
|
|
11
|
+
//Aqui implementar busca do LOCALE_ID
|
|
12
|
+
//return 'en-US';
|
|
13
|
+
return 'pt-BR';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getDefaultCurrencyCode() {
|
|
17
|
+
//Aqui implementar busca do DEFAULT_CURRENCY_CODE
|
|
18
|
+
//return 'USD';
|
|
19
|
+
return 'BRL';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getCurrencyBR ( numero: number ): string
|
|
23
|
+
{
|
|
24
|
+
const formata = new Intl.NumberFormat( 'pt-BR', {
|
|
25
|
+
style: 'currency',
|
|
26
|
+
currency: 'BRL',
|
|
27
|
+
minimumFractionDigits: 2
|
|
28
|
+
} );
|
|
29
|
+
return formata.format( numero );
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
export class Utils {
|
|
2
|
+
|
|
3
|
+
// Obtém a mensagem de erro de uma requisição http
|
|
4
|
+
public static getHttpErrorMessage(error: any): string {
|
|
5
|
+
|
|
6
|
+
let errorMessage: string = '';
|
|
7
|
+
|
|
8
|
+
if (error.error instanceof ErrorEvent) {
|
|
9
|
+
// Erro ocorreu no lado do client
|
|
10
|
+
errorMessage = error.error.message;
|
|
11
|
+
} else {
|
|
12
|
+
|
|
13
|
+
// Erro ocorreu no lado do servidor
|
|
14
|
+
if (error.status) {
|
|
15
|
+
|
|
16
|
+
if (error.status == 200) {
|
|
17
|
+
|
|
18
|
+
if (error.error) {
|
|
19
|
+
|
|
20
|
+
if (error.error.ErrorMessage) {
|
|
21
|
+
errorMessage = `${error.error.ErrorMessage}`;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
errorMessage = `${error.error.Message}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
} else {
|
|
28
|
+
errorMessage = error.message;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
|
|
34
|
+
if (error.error) {
|
|
35
|
+
|
|
36
|
+
if (error.error.ErrorMessage) {
|
|
37
|
+
errorMessage = `${error.error.ErrorMessage}<br><br>${error.status} - ${error.statusText}`;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
errorMessage = `${error.error.Message}<br><br>${error.status} - ${error.statusText}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
} else {
|
|
44
|
+
errorMessage = error.message;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
} else {
|
|
50
|
+
errorMessage = error.message;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return errorMessage;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
public static convertDateTimeToDateString(date: Date): string {
|
|
59
|
+
const dateString: string[] = date.toString().split('T')[0].split('-');
|
|
60
|
+
|
|
61
|
+
return `${dateString[0]}-${dateString[1]}-${dateString[2]}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public static convertStringToDate(text: string): Date {
|
|
65
|
+
const dateString: string[] = text.split('-');
|
|
66
|
+
|
|
67
|
+
return new Date(+dateString[0], (+dateString[1]) - 1, +dateString[2]);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Verifica se um determinado ano é bissexto.
|
|
72
|
+
* @param year Ano a ser verificado.
|
|
73
|
+
* @returns Retorna true se o ano for bissexto e false se ele não for, ou se o ano informado for inválido.
|
|
74
|
+
*/
|
|
75
|
+
public static isLeapYear(year: number | string): boolean {
|
|
76
|
+
const YEAR_NUMBER: number = typeof year === 'string' ? parseInt(year) : year;
|
|
77
|
+
|
|
78
|
+
if (!isNaN(YEAR_NUMBER)) {
|
|
79
|
+
if ((YEAR_NUMBER % 4 === 0 && YEAR_NUMBER % 100 !== 0) || YEAR_NUMBER % 400 === 0) return true;
|
|
80
|
+
else return false;
|
|
81
|
+
}
|
|
82
|
+
else return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Verifica se uma determinada data é indeterminada.
|
|
87
|
+
* @param dateTime Data a ser verificada.
|
|
88
|
+
* @returns Retorna true se for indeterminada e false se não for.
|
|
89
|
+
*/
|
|
90
|
+
public static verifyDateIsIndeterminate(dateTime: Date): boolean {
|
|
91
|
+
return dateTime.toString().split('T')[0] === '2099-12-31';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Verifica se uma determinada data é nula (igual a '1900-01-01T00:00:00').
|
|
96
|
+
* @param dateTime Data a ser verificada.
|
|
97
|
+
* @returns Retorna true se for nula e false se não for.
|
|
98
|
+
*/
|
|
99
|
+
public static verifyDateIsNull(dateTime: Date): boolean {
|
|
100
|
+
return dateTime.toString().split('T')[0] === '1900-01-01';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Tenta realizar um parse de uma data com os seguintes valores: dd/MM/yyyy HH:mm
|
|
105
|
+
*
|
|
106
|
+
* @param value String que contém a data formatada em pt-br
|
|
107
|
+
* @param dateSeparator Separador da data.
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
public static parseDateTime(value: string, dateSeparator: string = "/"): Date | undefined {
|
|
111
|
+
let usDate = "";
|
|
112
|
+
|
|
113
|
+
value = value.trim();
|
|
114
|
+
|
|
115
|
+
let dateAndTime: string[] = value.split(" ");
|
|
116
|
+
|
|
117
|
+
// Possui pelo menos 5 caracteres: 1/1/1
|
|
118
|
+
if (value.length >= 5) {
|
|
119
|
+
let dateSeparated: string[] = dateAndTime[0].split(dateSeparator);
|
|
120
|
+
|
|
121
|
+
if (dateSeparated.length !== 3) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (dateSeparated[2].length > 2) {
|
|
126
|
+
dateSeparated[2] = `${dateSeparated[2].charAt(0)}${dateSeparated[2].charAt(1)}`.trim();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
usDate = `${dateSeparated[1]}/${dateSeparated[0]}/${dateSeparated[2]}`
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (dateAndTime.length === 2) {
|
|
133
|
+
|
|
134
|
+
usDate += ` ${dateAndTime[1]}`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
let expectedDate: number = Date.parse(usDate);
|
|
138
|
+
|
|
139
|
+
if (expectedDate !== null || expectedDate < 0) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return new Date(expectedDate);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Obtém a Data local
|
|
147
|
+
public static getDateLocalTime(date: Date): Date {
|
|
148
|
+
return (new Date(date.getTime() - date.getTimezoneOffset() * 60000));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Obtém a Data local no Padrão Iso
|
|
152
|
+
public static getDateLocalTimeISO(date: Date): string {
|
|
153
|
+
return (this.getDateLocalTime(date).toISOString().replace('.000Z', ''));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public static getDatePickerDate(str: String): Date {
|
|
157
|
+
const [dateComponents, timeComponents] = str.split('T')
|
|
158
|
+
const [ano, mes, dia] = dateComponents.split('-');
|
|
159
|
+
const [hora, minuto, segundo] = timeComponents.split(':');
|
|
160
|
+
const date = new Date(Number(ano), Number(mes), Number(dia))
|
|
161
|
+
|
|
162
|
+
return date
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
public static AdicionaDias(data: Date, days: number): Date {
|
|
166
|
+
const find = new Date(Number(data))
|
|
167
|
+
|
|
168
|
+
find.setDate(data.getDate() + days)
|
|
169
|
+
|
|
170
|
+
return find
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
public static DiferencaDias(dataInicial: Date, dataFinal: Date): number {
|
|
174
|
+
var Time = dataFinal.getTime() - dataInicial.getTime();
|
|
175
|
+
|
|
176
|
+
return Time / (1000 * 3600 * 24);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
public static DiferencaMeses(dataInicial: Date, dataFinal: Date): number {
|
|
180
|
+
var meses = (dataFinal.getFullYear() - dataInicial.getFullYear()) * 12;
|
|
181
|
+
meses -= dataInicial.getMonth();
|
|
182
|
+
meses += dataFinal.getMonth();
|
|
183
|
+
|
|
184
|
+
return meses <= 0 ? 0 : meses;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
//Obtém a Data UTC com hora zerada
|
|
189
|
+
public static getDateUTC(date: Date): Date {
|
|
190
|
+
//codigo original
|
|
191
|
+
//return new Date(date.getTime() + (date.getTimezoneOffset() * 60000));
|
|
192
|
+
let dataSaida: Date;
|
|
193
|
+
|
|
194
|
+
try {
|
|
195
|
+
dataSaida = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0);
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
//Quando date chega neste formato: 2022-06-20T00:00:00
|
|
199
|
+
//tento pegar ano/mes/dia direto
|
|
200
|
+
//Date(DtIniFer.getUTCFullYear(), DtIniFer.getUTCMonth(), DtIniFer.getUTCDate(), 0 , 0 , 0);
|
|
201
|
+
//e não funciona
|
|
202
|
+
const dia: string = date.toString().substring(8, 10);
|
|
203
|
+
const mes: string = date.toString().substring(5, 7);
|
|
204
|
+
const ano: string = date.toString().substring(0, 4);
|
|
205
|
+
dataSaida = new Date(Number(ano), Number(mes) - 1, Number(dia), 0, 0, 0);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return dataSaida;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
//Obtém a Data UTC com hora zerada
|
|
212
|
+
public static getDateddMMyyy(date: Date): string {
|
|
213
|
+
//codigo original
|
|
214
|
+
//return new Date(date.getTime() + (date.getTimezoneOffset() * 60000));
|
|
215
|
+
let dataSaida: Date;
|
|
216
|
+
|
|
217
|
+
try {
|
|
218
|
+
dataSaida = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0);
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
//Quando date chega neste formato: 2022-06-20T00:00:00
|
|
222
|
+
//tento pegar ano/mes/dia direto
|
|
223
|
+
//Date(DtIniFer.getUTCFullYear(), DtIniFer.getUTCMonth(), DtIniFer.getUTCDate(), 0 , 0 , 0);
|
|
224
|
+
//e não funciona
|
|
225
|
+
const dia: string = date.toString().substring(8, 10);
|
|
226
|
+
const mes: string = date.toString().substring(5, 7);
|
|
227
|
+
const ano: string = date.toString().substring(0, 4);
|
|
228
|
+
|
|
229
|
+
dataSaida = new Date(Number(ano), Number(mes) - 1, Number(dia), 0, 0, 0);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function pad(s: any) { return (s < 10) ? '0' + s : s; }
|
|
233
|
+
|
|
234
|
+
return [pad(dataSaida.getUTCDate()), pad(dataSaida.getUTCMonth() + 1), pad(dataSaida.getUTCFullYear())].join('/');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
//Obtém a Data UTC com a hora
|
|
238
|
+
public static getDateddMMyyyyHhmmss(date: Date): string {
|
|
239
|
+
let dataSaida: Date;
|
|
240
|
+
|
|
241
|
+
try {
|
|
242
|
+
dataSaida = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getHours(), date.getMinutes(), date.getSeconds());
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
//Quando date chega neste formato: 2022-06-20T00:00:00
|
|
246
|
+
//tento pegar ano/mes/dia direto
|
|
247
|
+
//Date(DtIniFer.getUTCFullYear(), DtIniFer.getUTCMonth(), DtIniFer.getUTCDate(), 0 , 0 , 0);
|
|
248
|
+
//e não funciona
|
|
249
|
+
const dia: string = date.toString().substring(8, 10);
|
|
250
|
+
const mes: string = date.toString().substring(5, 7);
|
|
251
|
+
const ano: string = date.toString().substring(0, 4);
|
|
252
|
+
const hora: string = date.toString().substring(11, 13);
|
|
253
|
+
const minutos: string = date.toString().substring(14, 16);
|
|
254
|
+
const segundos: string = date.toString().substring(17, 19);
|
|
255
|
+
|
|
256
|
+
dataSaida = new Date(Number(ano), Number(mes) - 1, Number(dia), Number(hora), Number(minutos), Number(segundos));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function pad(s: any) { return (s < 10) ? '0' + s : s; }
|
|
260
|
+
|
|
261
|
+
let dataFormatada: string = [pad(dataSaida.getDate()), pad(dataSaida.getUTCMonth() + 1), pad(dataSaida.getUTCFullYear())].join('/');
|
|
262
|
+
|
|
263
|
+
dataFormatada += " ";
|
|
264
|
+
dataFormatada += [pad(dataSaida.getHours()), pad(dataSaida.getMinutes()), pad(dataSaida.getSeconds())].join(':');
|
|
265
|
+
|
|
266
|
+
return dataFormatada;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
static UltimoDiaMes(data: Date): Date {
|
|
270
|
+
let dataSaida: Date = this.getDateTimeUTC(data);
|
|
271
|
+
// adiciona 1 mes
|
|
272
|
+
dataSaida.setMonth(dataSaida.getUTCMonth() + 1);
|
|
273
|
+
//Posiciona no dia 01 do mes adicionado
|
|
274
|
+
dataSaida = new Date(dataSaida.getUTCFullYear(), dataSaida.getUTCMonth(), 1, 0, 0, 0);
|
|
275
|
+
// subtrai 1 dia para ir para o ultimo dia do mes
|
|
276
|
+
dataSaida.setDate(dataSaida.getDate() - 1);
|
|
277
|
+
|
|
278
|
+
return dataSaida;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
//Obtém a Data/hora UTC
|
|
282
|
+
public static getDateTimeUTC(date: Date): Date {
|
|
283
|
+
let dataSaida: Date;
|
|
284
|
+
|
|
285
|
+
try {
|
|
286
|
+
dataSaida = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getHours(), date.getMinutes(), date.getSeconds());
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
//Quando date chega neste formato: 2022-06-20T11:12:13
|
|
290
|
+
const dia: string = date.toString().substring(8, 10);
|
|
291
|
+
const mes: string = date.toString().substring(5, 7);
|
|
292
|
+
const ano: string = date.toString().substring(0, 4);
|
|
293
|
+
const hora: string = date.toString().substring(11, 13);
|
|
294
|
+
const min: string = date.toString().substring(14, 16);
|
|
295
|
+
const seg: string = date.toString().substring(17, 19);
|
|
296
|
+
dataSaida = new Date(Number(ano), Number(mes) - 1, Number(dia), Number(hora), Number(min), Number(seg));
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return dataSaida;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
public static compareEqualDates(date1: Date, date2: Date): boolean {
|
|
303
|
+
let strDate1: string = Utils.getDateddMMyyy(date1);
|
|
304
|
+
let strDate2: string = Utils.getDateddMMyyy(date2);
|
|
305
|
+
|
|
306
|
+
if (strDate1 === strDate2) {
|
|
307
|
+
return true;
|
|
308
|
+
} else {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
public static convertMMYYYYToDate(value: string): Date {
|
|
314
|
+
value = value.replace('/', '');
|
|
315
|
+
|
|
316
|
+
let month: number = Number(value.substring(0, 2));
|
|
317
|
+
let year: number = Number(value.substring(2, 6));
|
|
318
|
+
|
|
319
|
+
//Diminui 1 pois no angular existe um índice do mês que não é igual ao mês.
|
|
320
|
+
month = month - 1;
|
|
321
|
+
|
|
322
|
+
return new Date(year, month, 1);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
public static getNullDate(): Date {
|
|
326
|
+
return new Date(1900, 0, 1, 0, 0, 0);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
public static getDateWebServiceFormat(value: Date): string {
|
|
330
|
+
|
|
331
|
+
if (value.toString() == '') {
|
|
332
|
+
return '1900-01-01';
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
let data = Utils.getDateddMMyyy(value);
|
|
336
|
+
|
|
337
|
+
return data.substring(6, 10) + '-' + data.substring(3, 5) + '-' + data.substring(0, 2);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
public static getDateTimeWebServiceFormat(value: Date): string {
|
|
341
|
+
|
|
342
|
+
if (value.toString() == '' || Utils.getDateddMMyyy(value) == Utils.getDateddMMyyy(this.getNullDate())) {
|
|
343
|
+
return '1900-01-01T00:00:00';
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
let data = this.getDateddMMyyyyHhmmss(value);
|
|
347
|
+
|
|
348
|
+
let dataFormatada: string = data.substring(6, 10) + '-' + data.substring(3, 5) + '-' + data.substring(0, 2);
|
|
349
|
+
dataFormatada = dataFormatada + 'T';
|
|
350
|
+
dataFormatada = dataFormatada + data.substring(11, 13) + ':' + data.substring(14, 16) + ':' + data.substring(17, 19);
|
|
351
|
+
|
|
352
|
+
return dataFormatada;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
//Transforma a string Base64 num array de bytes e faz o download do arquivo.
|
|
356
|
+
public static downloadFileBase64(fleName: string, file: string): void {
|
|
357
|
+
const byteString = window.atob(file);
|
|
358
|
+
const arrayBuffer = new ArrayBuffer(byteString.length);
|
|
359
|
+
const int8Array = new Uint8Array(arrayBuffer);
|
|
360
|
+
|
|
361
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
362
|
+
int8Array[i] = byteString.charCodeAt(i);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const blob = new Blob([int8Array]);
|
|
366
|
+
|
|
367
|
+
const url = window.URL.createObjectURL(blob);
|
|
368
|
+
|
|
369
|
+
//Abio
|
|
370
|
+
//O window.open foi comentado porque no download dos arquivos digitais abria uma janela com o blob do arquivo.
|
|
371
|
+
//Comentar não afetou o download do contra-cheque.
|
|
372
|
+
//window.open(url);
|
|
373
|
+
var a = document.createElement('a');
|
|
374
|
+
|
|
375
|
+
a.href = url;
|
|
376
|
+
a.target = '_blank';
|
|
377
|
+
a.download = fleName;
|
|
378
|
+
|
|
379
|
+
document.body.appendChild(a);
|
|
380
|
+
|
|
381
|
+
a.click();
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Abre o popup do navegador para baixar um arquivo que veio de um blob.
|
|
386
|
+
*
|
|
387
|
+
* @param blob Conteúdo do arquivo binário a ser baixado.
|
|
388
|
+
* @param fileName Nome do arquivo a ser salvo.
|
|
389
|
+
*/
|
|
390
|
+
public static downloadFile(blob: Blob, fileName: string): void {
|
|
391
|
+
const anchor = window.document.createElement('a');
|
|
392
|
+
|
|
393
|
+
anchor.href = window.URL.createObjectURL(blob);
|
|
394
|
+
anchor.download = fileName;
|
|
395
|
+
|
|
396
|
+
document.body.appendChild(anchor);
|
|
397
|
+
|
|
398
|
+
anchor.click();
|
|
399
|
+
|
|
400
|
+
document.body.removeChild(anchor);
|
|
401
|
+
window.URL.revokeObjectURL(anchor.href);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
public static b64DecodeUnicode(str: string): string {
|
|
405
|
+
// Going backwards: from bytestream, to percent-encoding, to original string.
|
|
406
|
+
return decodeURIComponent(atob(str).split('').map(c => {
|
|
407
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
408
|
+
}).join(''));
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
public static b64EncodeUnicode(str: string) {
|
|
412
|
+
// first we use encodeURIComponent to get percent-encoded UTF-8,
|
|
413
|
+
// then we convert the percent encodings into raw bytes which
|
|
414
|
+
// can be fed into btoa.
|
|
415
|
+
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
|
|
416
|
+
(match, p1) => {
|
|
417
|
+
return String.fromCharCode(("0x" + p1) as any);
|
|
418
|
+
}));
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
//Largura a partir de onde remonta o ngx_datatable para mobile
|
|
422
|
+
public static getIsMobile() {
|
|
423
|
+
const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
424
|
+
return width < 768;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Directive } from '@angular/core';
|
|
2
|
+
import { Validator, NG_VALIDATORS } from '@angular/forms';
|
|
3
|
+
import { CpfCnpjValidator } from './cpf-cnpj.validator';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@Directive({
|
|
7
|
+
selector: '[appCpfCnpjValidate][ngModel]',
|
|
8
|
+
providers: [{
|
|
9
|
+
provide: NG_VALIDATORS,
|
|
10
|
+
useExisting: CpfCnpjValidatorDirective,
|
|
11
|
+
multi: true
|
|
12
|
+
}]
|
|
13
|
+
})
|
|
14
|
+
export class CpfCnpjValidatorDirective extends CpfCnpjValidator implements Validator { }
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Validator, AbstractControl } from '@angular/forms';
|
|
2
|
+
import { ValidationErrors } from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
//Origem https://pedrohtbranco.com.br/validacao-cpf-e-cnpj-com-angular-12/
|
|
5
|
+
|
|
6
|
+
export class CpfCnpjValidator implements Validator {
|
|
7
|
+
|
|
8
|
+
static cpfLength = 11;
|
|
9
|
+
static cnpjLength = 14;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Calcula o dígito verificador do CPF ou CNPJ.
|
|
13
|
+
*/
|
|
14
|
+
static buildDigit(arr: number[]): number {
|
|
15
|
+
|
|
16
|
+
const isCpf = arr.length < CpfCnpjValidator.cpfLength;
|
|
17
|
+
const digit = arr
|
|
18
|
+
.map((val, idx) => val * ((!isCpf ? idx % 8 : idx) + 2))
|
|
19
|
+
.reduce((total, current) => total + current) % CpfCnpjValidator.cpfLength;
|
|
20
|
+
|
|
21
|
+
if (digit < 2 && isCpf) {
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
else if (digit < 2)
|
|
25
|
+
{
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return CpfCnpjValidator.cpfLength - digit;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Valida um CPF ou CNPJ de acordo com seu dígito verificador.
|
|
35
|
+
*/
|
|
36
|
+
static validate(c: AbstractControl): ValidationErrors | null {
|
|
37
|
+
|
|
38
|
+
const cpfCnpj = c.value.replace(/\D/g, '');
|
|
39
|
+
|
|
40
|
+
if (cpfCnpj === '') {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Verifica o tamanho da string.
|
|
45
|
+
if ([CpfCnpjValidator.cpfLength, CpfCnpjValidator.cnpjLength].indexOf(cpfCnpj.length) < 0) {
|
|
46
|
+
return { cpcnpjInvalid: true };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Verifica se todos os dígitos são iguais, exceto para CPF com dígitos zerados.
|
|
50
|
+
if (/^([0-9])\1*$/.test(cpfCnpj) && cpfCnpj !== '00000000000') {
|
|
51
|
+
return { cpcnpjInvalid: true };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// A seguir é realizado o cálculo verificador.
|
|
55
|
+
const cpfCnpjArr: number[] = cpfCnpj.split('').reverse().slice(2);
|
|
56
|
+
|
|
57
|
+
cpfCnpjArr.unshift(CpfCnpjValidator.buildDigit(cpfCnpjArr));
|
|
58
|
+
cpfCnpjArr.unshift(CpfCnpjValidator.buildDigit(cpfCnpjArr));
|
|
59
|
+
|
|
60
|
+
if (cpfCnpj !== cpfCnpjArr.reverse().join('')) {
|
|
61
|
+
// Dígito verificador não é válido, resultando em falha.
|
|
62
|
+
return { cpcnpjInvalidDigit: true };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Implementa a interface de um validator.
|
|
70
|
+
*/
|
|
71
|
+
validate(c: AbstractControl): ValidationErrors | null {
|
|
72
|
+
return CpfCnpjValidator.validate(c);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* Breadcrumbs padrão Sispro.
|
|
4
|
+
*
|
|
5
|
+
* ## Utilização
|
|
6
|
+
*
|
|
7
|
+
* Colocar o componente infra-breadcrumb com elementos li que possuem o seletor infra-breadcrumb-item.
|
|
8
|
+
* Como demonstrado da seguinte forma:
|
|
9
|
+
*
|
|
10
|
+
* <infra-breadcrumb>
|
|
11
|
+
* <li infra-breadcrumb-item>
|
|
12
|
+
* <a routerLinkActive="/home">Home</a>
|
|
13
|
+
* </li>
|
|
14
|
+
* <li infra-breadcrumb-item>
|
|
15
|
+
* Consultar
|
|
16
|
+
* </li>
|
|
17
|
+
* </infra-breadcrumb>
|
|
18
|
+
*
|
|
19
|
+
* ## Peculiaridades
|
|
20
|
+
*
|
|
21
|
+
* Não é necessário colocar o item como ativo pois ele verifica se algum dos filhos do elemento li é
|
|
22
|
+
* uma âncora (<a></a>)
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
@Component({
|
|
26
|
+
selector: 'infra-breadcrumb',
|
|
27
|
+
templateUrl: './infra-breadcrumb.component.html',
|
|
28
|
+
styleUrls: ['./infra-breadcrumb.component.css']
|
|
29
|
+
})
|
|
30
|
+
export class InfraBreadcrumbComponent {
|
|
31
|
+
|
|
32
|
+
constructor() { }
|
|
33
|
+
|
|
34
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<ng-content></ng-content>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Component, ElementRef, OnInit } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Item da lista padrão da Sispro.
|
|
5
|
+
*
|
|
6
|
+
* Deve ser utilizado em conjunto com o InfraBreadCrumb
|
|
7
|
+
*/
|
|
8
|
+
@Component({
|
|
9
|
+
// eslint-disable-next-line @angular-eslint/component-selector
|
|
10
|
+
selector: 'li[infra-breadcrumb-item]',
|
|
11
|
+
templateUrl: './infra-breadcrumb-item.component.html',
|
|
12
|
+
styleUrls: ['./infra-breadcrumb-item.component.css']
|
|
13
|
+
})
|
|
14
|
+
export class InfraBreadcrumbItemComponent implements OnInit {
|
|
15
|
+
|
|
16
|
+
constructor(private elem: ElementRef<HTMLDataListElement>) { }
|
|
17
|
+
|
|
18
|
+
ngOnInit(): void {
|
|
19
|
+
this.elem.nativeElement.classList.add("breadcrumb-item")
|
|
20
|
+
|
|
21
|
+
if (this.elem.nativeElement.children.length > 0) {
|
|
22
|
+
let isAnchor = this.elem.nativeElement.children[0] instanceof HTMLAnchorElement;
|
|
23
|
+
|
|
24
|
+
if (isAnchor) {
|
|
25
|
+
this.elem.nativeElement.classList.add("active");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
File without changes
|
package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/portalrh-breadcrumb/breadcrumb.component.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component, OnInit, Input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'app-breadcrumb',
|
|
5
|
+
templateUrl: './breadcrumb.component.html',
|
|
6
|
+
styleUrls: ['./breadcrumb.component.css']
|
|
7
|
+
})
|
|
8
|
+
export class BreadcrumbComponent implements OnInit {
|
|
9
|
+
|
|
10
|
+
@Input() menu: string = '';
|
|
11
|
+
@Input() opcao: string = '';
|
|
12
|
+
|
|
13
|
+
constructor() { }
|
|
14
|
+
|
|
15
|
+
ngOnInit(): void {
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|