ng-components-tsi 0.0.36 → 0.0.38
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/ng-package.json +7 -0
- package/package.json +23 -31
- package/src/lib/directivas/acciones/atajos.directive.ts +26 -0
- package/src/lib/directivas/animaciones/fade-animation.ts +45 -0
- package/src/lib/directivas/animaciones/fade.directive.ts +43 -0
- package/src/lib/directivas/estilos/animated-checkbox.directive.ts +26 -0
- package/src/lib/directivas/estilos/button.constants.ts +66 -0
- package/src/lib/directivas/estilos/buttons-modal.directive.ts +36 -0
- package/src/lib/directivas/estilos/buttons-outline-directive.ts +27 -0
- package/src/lib/directivas/estilos/icons.directive.ts +26 -0
- package/src/lib/directivas/inputs/caracteres-codigo.directive.ts +63 -0
- package/src/lib/directivas/inputs/decimal.directive.ts +51 -0
- package/src/lib/directivas/inputs/only-day.directive.ts +53 -0
- package/src/lib/directivas/inputs/only-number-flex.directive.ts +50 -0
- package/src/lib/directivas/inputs/only-number.directive.ts +53 -0
- package/src/lib/enums/table-events.ts +5 -0
- package/src/lib/modals/general/md-generico/md-generico.component.html +44 -0
- package/src/lib/modals/general/md-generico/md-generico.component.scss +4 -0
- package/src/lib/modals/general/md-generico/md-generico.component.ts +50 -0
- package/src/lib/models/button-color.model.ts +9 -0
- package/{lib/models/button-properties.model.d.ts → src/lib/models/button-properties.model.ts} +8 -7
- package/src/lib/models/cell-rendered.ts +12 -0
- package/src/lib/models/comercial/documentos-cab-auxiliares.model.ts +18 -0
- package/{lib/models/dropdownoption.model.d.ts → src/lib/models/dropdownoption.model.ts} +15 -14
- package/src/lib/models/general/recursos.model.ts +285 -0
- package/src/lib/models/general/utils.interface.ts +66 -0
- package/src/lib/models/input-config.ts +26 -0
- package/{lib/models/selected-row.d.ts → src/lib/models/selected-row.ts} +4 -4
- package/{lib/models/table-data.model.d.ts → src/lib/models/table-data.model.ts} +21 -21
- package/src/lib/service/alert-confirmation.service.ts +87 -0
- package/src/lib/service/alert-error.service.ts +27 -0
- package/src/lib/service/alert.service.ts +216 -0
- package/src/lib/service/formateador.service.ts +49 -0
- package/src/lib/service/toast.service.ts +75 -0
- package/src/lib/ui/alerts/alert-confirmation/alert-confirmation.component.html +40 -0
- package/src/lib/ui/alerts/alert-confirmation/alert-confirmation.component.scss +42 -0
- package/src/lib/ui/alerts/alert-confirmation/alert-confirmation.component.ts +118 -0
- package/src/lib/ui/alerts/alert-error/alert-error.component.html +11 -0
- package/src/lib/ui/alerts/alert-error/alert-error.component.scss +39 -0
- package/src/lib/ui/alerts/alert-error/alert-error.component.ts +27 -0
- package/src/lib/ui/alerts/alerta/alerta.component.html +18 -0
- package/src/lib/ui/alerts/alerta/alerta.component.scss +104 -0
- package/src/lib/ui/alerts/alerta/alerta.component.ts +25 -0
- package/src/lib/ui/alerts/badge/badge.component.ts +16 -0
- package/src/lib/ui/alerts/toaster/toaster.component.html +52 -0
- package/src/lib/ui/alerts/toaster/toaster.component.scss +275 -0
- package/src/lib/ui/alerts/toaster/toaster.component.ts +50 -0
- package/src/lib/ui/dropdown/dropdown-cdk/dropdown-cdk.component.html +20 -0
- package/src/lib/ui/dropdown/dropdown-cdk/dropdown-cdk.component.scss +11 -0
- package/src/lib/ui/dropdown/dropdown-cdk/dropdown-cdk.component.ts +18 -0
- package/src/lib/ui/dropdown/dropdown-simple/dropdown.component.html +10 -0
- package/src/lib/ui/dropdown/dropdown-simple/dropdown.component.scss +54 -0
- package/src/lib/ui/dropdown/dropdown-simple/dropdown.component.ts +36 -0
- package/src/lib/ui/forms/button/button.component.html +69 -0
- package/src/lib/ui/forms/button/button.component.scss +126 -0
- package/src/lib/ui/forms/button/button.component.ts +137 -0
- package/src/lib/ui/forms/filter-toggle/filter-toggle.component.scss +22 -0
- package/src/lib/ui/forms/filter-toggle/filter-toggle.component.ts +29 -0
- package/src/lib/ui/forms/header/header.component.html +22 -0
- package/src/lib/ui/forms/header/header.component.scss +22 -0
- package/src/lib/ui/forms/header/header.component.ts +40 -0
- package/src/lib/ui/forms/inputs/autocomplete/autocomplete.component.html +46 -0
- package/src/lib/ui/forms/inputs/autocomplete/autocomplete.component.scss +90 -0
- package/src/lib/ui/forms/inputs/autocomplete/autocomplete.component.ts +203 -0
- package/src/lib/ui/forms/inputs/autocomplete-cdk/autocomplete.component.html +61 -0
- package/src/lib/ui/forms/inputs/autocomplete-cdk/autocomplete.component.scss +128 -0
- package/src/lib/ui/forms/inputs/autocomplete-cdk/autocomplete.component.ts +145 -0
- package/src/lib/ui/forms/inputs/check-box/check-box.component.html +6 -0
- package/src/lib/ui/forms/inputs/check-box/check-box.component.ts +24 -0
- package/src/lib/ui/forms/inputs/doble-input/doble-input.component.html +60 -0
- package/src/lib/ui/forms/inputs/doble-input/doble-input.component.scss +86 -0
- package/src/lib/ui/forms/inputs/doble-input/doble-input.component.ts +129 -0
- package/src/lib/ui/forms/inputs/input/input.component.html +169 -0
- package/src/lib/ui/forms/inputs/input/input.component.scss +74 -0
- package/src/lib/ui/forms/inputs/input/input.component.ts +147 -0
- package/src/lib/ui/forms/inputs/input-clase/input-clase.component.html +30 -0
- package/src/lib/ui/forms/inputs/input-clase/input-clase.component.scss +0 -0
- package/src/lib/ui/forms/inputs/input-clase/input-clase.component.ts +28 -0
- package/src/lib/ui/forms/inputs/input-dinamico/input-dinamico.component.html +41 -0
- package/src/lib/ui/forms/inputs/input-dinamico/input-dinamico.component.scss +0 -0
- package/src/lib/ui/forms/inputs/input-dinamico/input-dinamico.component.ts +17 -0
- package/src/lib/ui/forms/inputs/input-radio/input-radio.component.html +26 -0
- package/src/lib/ui/forms/inputs/input-radio/input-radio.component.scss +53 -0
- package/src/lib/ui/forms/inputs/input-radio/input-radio.component.ts +36 -0
- package/src/lib/ui/forms/inputs/multiselected/multiselected.component.html +56 -0
- package/src/lib/ui/forms/inputs/multiselected/multiselected.component.scss +145 -0
- package/src/lib/ui/forms/inputs/multiselected/multiselected.component.ts +109 -0
- package/src/lib/ui/forms/inputs/radio/radio.component.html +7 -0
- package/src/lib/ui/forms/inputs/radio/radio.component.scss +0 -0
- package/src/lib/ui/forms/inputs/radio/radio.component.ts +23 -0
- package/src/lib/ui/forms/inputs/switch/switch.component.html +12 -0
- package/src/lib/ui/forms/inputs/switch/switch.component.scss +48 -0
- package/src/lib/ui/forms/inputs/switch/switch.component.ts +50 -0
- package/src/lib/ui/forms/inputs/switch-activo/switch-activo.component.html +12 -0
- package/src/lib/ui/forms/inputs/switch-activo/switch-activo.component.scss +65 -0
- package/src/lib/ui/forms/inputs/switch-activo/switch-activo.component.ts +52 -0
- package/src/lib/ui/forms/lists/list-option/list-option.component.html +24 -0
- package/src/lib/ui/forms/lists/list-option/list-option.component.scss +49 -0
- package/src/lib/ui/forms/lists/list-option/list-option.component.ts +35 -0
- package/src/lib/ui/forms/lists/list-situaciones/list-situaciones.component.html +29 -0
- package/src/lib/ui/forms/lists/list-situaciones/list-situaciones.component.scss +0 -0
- package/src/lib/ui/forms/lists/list-situaciones/list-situaciones.component.ts +99 -0
- package/src/lib/ui/forms/lists/multi-select-dropdown/multi-select-dropdown.component.html +46 -0
- package/src/lib/ui/forms/lists/multi-select-dropdown/multi-select-dropdown.component.scss +30 -0
- package/src/lib/ui/forms/lists/multi-select-dropdown/multi-select-dropdown.component.ts +96 -0
- package/src/lib/ui/forms/sidebar/sidebar.component.html +33 -0
- package/src/lib/ui/forms/sidebar/sidebar.component.scss +85 -0
- package/src/lib/ui/forms/sidebar/sidebar.component.ts +61 -0
- package/src/lib/ui/general/detalle-credito/detalle-credito.component.html +35 -0
- package/src/lib/ui/general/detalle-credito/detalle-credito.component.scss +35 -0
- package/src/lib/ui/general/detalle-credito/detalle-credito.component.ts +14 -0
- package/src/lib/ui/general/montos-calcular/montos-calcular.component.html +17 -0
- package/src/lib/ui/general/montos-calcular/montos-calcular.component.scss +36 -0
- package/src/lib/ui/general/montos-calcular/montos-calcular.component.ts +19 -0
- package/src/lib/ui/general/spinner/spinner.component.html +8 -0
- package/src/lib/ui/general/spinner/spinner.component.scss +96 -0
- package/src/lib/ui/general/spinner/spinner.component.ts +11 -0
- package/src/lib/ui/tables/card-mobile/card-mobile.component.html +34 -0
- package/src/lib/ui/tables/card-mobile/card-mobile.component.scss +0 -0
- package/src/lib/ui/tables/card-mobile/card-mobile.component.ts +36 -0
- package/src/lib/ui/tables/dropdown-menu/dropdown-menu.component.html +59 -0
- package/src/lib/ui/tables/dropdown-menu/dropdown-menu.component.scss +88 -0
- package/src/lib/ui/tables/dropdown-menu/dropdown-menu.component.ts +171 -0
- package/src/lib/ui/tables/paginador/paginador.component.html +12 -0
- package/src/lib/ui/tables/paginador/paginador.component.scss +27 -0
- package/src/lib/ui/tables/paginador/paginador.component.ts +49 -0
- package/src/lib/ui/tables/table-advance/table-advance.component.html +322 -0
- package/src/lib/ui/tables/table-advance/table-advance.component.scss +282 -0
- package/src/lib/ui/tables/table-advance/table-advance.component.ts +421 -0
- package/src/lib/ui/tables/table-advance-optimizada/table-advance-optimizada.component.html +226 -0
- package/src/lib/ui/tables/table-advance-optimizada/table-advance-optimizada.component.scss +282 -0
- package/src/lib/ui/tables/table-advance-optimizada/table-advance-optimizada.component.ts +352 -0
- package/src/lib/ui/tables/table-agrupada/table-agrupada.component.html +340 -0
- package/src/lib/ui/tables/table-agrupada/table-agrupada.component.scss +282 -0
- package/src/lib/ui/tables/table-agrupada/table-agrupada.component.ts +425 -0
- package/src/lib/ui/tables/table-busqueda/table-busqueda.component.html +130 -0
- package/src/lib/ui/tables/table-busqueda/table-busqueda.component.scss +189 -0
- package/src/lib/ui/tables/table-busqueda/table-busqueda.component.ts +199 -0
- package/src/lib/ui/tables/table-detalle/table-detalle.component.html +220 -0
- package/src/lib/ui/tables/table-detalle/table-detalle.component.scss +135 -0
- package/src/lib/ui/tables/table-detalle/table-detalle.component.ts +336 -0
- package/src/lib/ui/tables/table-simple/table-simple.component.html +116 -0
- package/src/lib/ui/tables/table-simple/table-simple.component.scss +70 -0
- package/src/lib/ui/tables/table-simple/table-simple.component.ts +141 -0
- package/src/lib/ui/tables/table-ultimate/table-ultimate.component.html +268 -0
- package/src/lib/ui/tables/table-ultimate/table-ultimate.component.scss +282 -0
- package/src/lib/ui/tables/table-ultimate/table-ultimate.component.ts +383 -0
- package/src/lib/ui/tabs/nav-tabs/nav-tabs.component.html +12 -0
- package/src/lib/ui/tabs/nav-tabs/nav-tabs.component.scss +100 -0
- package/src/lib/ui/tabs/nav-tabs/nav-tabs.component.ts +19 -0
- package/src/lib/ui/tabs/tab-item/tab-item.component.html +0 -0
- package/src/lib/ui/tabs/tab-item/tab-item.component.scss +0 -0
- package/src/lib/ui/tabs/tab-item/tab-item.component.ts +13 -0
- package/src/lib/utils/ayuda-global/datatable.ts +67 -0
- package/src/lib/utils/ayuda-global/filtros-busqueda.ts +51 -0
- package/src/lib/utils/general/validaciones-simple.ts +14 -0
- package/src/lib/utils/general/validaciones.ts +123 -0
- package/src/lib/utils/helpers/api-result.ts +95 -0
- package/src/lib/utils/helpers/modal-result.ts +34 -0
- package/{public-api.d.ts → src/public-api.ts} +99 -68
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/fesm2022/ng-components-tsi.mjs +0 -5033
- package/fesm2022/ng-components-tsi.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/directivas/acciones/atajos.directive.d.ts +0 -8
- package/lib/directivas/animaciones/fade-animation.d.ts +0 -3
- package/lib/directivas/estilos/animated-checkbox.directive.d.ts +0 -9
- package/lib/directivas/estilos/button.constants.d.ts +0 -64
- package/lib/directivas/estilos/buttons-modal.directive.d.ts +0 -11
- package/lib/directivas/estilos/buttons-outline-directive.d.ts +0 -11
- package/lib/directivas/estilos/icons.directive.d.ts +0 -11
- package/lib/directivas/inputs/caracteres-codigo.directive.d.ts +0 -12
- package/lib/directivas/inputs/decimal.directive.d.ts +0 -13
- package/lib/directivas/inputs/only-day.directive.d.ts +0 -8
- package/lib/directivas/inputs/only-number-flex.directive.d.ts +0 -9
- package/lib/directivas/inputs/only-number.directive.d.ts +0 -8
- package/lib/enums/table-events.d.ts +0 -5
- package/lib/modals/general/md-generico/md-generico.component.d.ts +0 -25
- package/lib/models/button-color.model.d.ts +0 -3
- package/lib/models/cell-rendered.d.ts +0 -11
- package/lib/models/comercial/documentos-cab-auxiliares.model.d.ts +0 -17
- package/lib/models/general/recursos.model.d.ts +0 -271
- package/lib/models/general/utils.interface.d.ts +0 -57
- package/lib/models/input-config.d.ts +0 -25
- package/lib/service/alert-confirmation.service.d.ts +0 -25
- package/lib/service/alert-error.service.d.ts +0 -9
- package/lib/service/alert.service.d.ts +0 -33
- package/lib/service/formateador.service.d.ts +0 -10
- package/lib/service/toast.service.d.ts +0 -25
- package/lib/ui/alerts/alert-confirmation/alert-confirmation.component.d.ts +0 -32
- package/lib/ui/alerts/alert-error/alert-error.component.d.ts +0 -9
- package/lib/ui/alerts/alerta/alerta.component.d.ts +0 -12
- package/lib/ui/alerts/badge/badge.component.d.ts +0 -8
- package/lib/ui/alerts/toaster/toaster.component.d.ts +0 -17
- package/lib/ui/dropdown/dropdown-cdk/dropdown-cdk.component.d.ts +0 -11
- package/lib/ui/dropdown/dropdown-simple/dropdown.component.d.ts +0 -13
- package/lib/ui/forms/button/button.component.d.ts +0 -43
- package/lib/ui/forms/filter-toggle/filter-toggle.component.d.ts +0 -9
- package/lib/ui/forms/header/header.component.d.ts +0 -17
- package/lib/ui/forms/inputs/autocomplete/autocomplete.component.d.ts +0 -43
- package/lib/ui/forms/inputs/autocomplete-cdk/autocomplete.component.d.ts +0 -48
- package/lib/ui/forms/inputs/check-box/check-box.component.d.ts +0 -14
- package/lib/ui/forms/inputs/doble-input/doble-input.component.d.ts +0 -47
- package/lib/ui/forms/inputs/input/input.component.d.ts +0 -56
- package/lib/ui/forms/inputs/input-clase/input-clase.component.d.ts +0 -13
- package/lib/ui/forms/inputs/input-dinamico/input-dinamico.component.d.ts +0 -8
- package/lib/ui/forms/inputs/input-radio/input-radio.component.d.ts +0 -24
- package/lib/ui/forms/inputs/multiselected/multiselected.component.d.ts +0 -39
- package/lib/ui/forms/inputs/radio/radio.component.d.ts +0 -14
- package/lib/ui/forms/inputs/switch/switch.component.d.ts +0 -20
- package/lib/ui/forms/inputs/switch-activo/switch-activo.component.d.ts +0 -21
- package/lib/ui/forms/lists/list-option/list-option.component.d.ts +0 -23
- package/lib/ui/forms/lists/list-situaciones/list-situaciones.component.d.ts +0 -28
- package/lib/ui/forms/lists/multi-select-dropdown/multi-select-dropdown.component.d.ts +0 -26
- package/lib/ui/forms/sidebar/sidebar.component.d.ts +0 -15
- package/lib/ui/general/detalle-credito/detalle-credito.component.d.ts +0 -8
- package/lib/ui/general/montos-calcular/montos-calcular.component.d.ts +0 -12
- package/lib/ui/general/spinner/spinner.component.d.ts +0 -5
- package/lib/ui/tables/card-mobile/card-mobile.component.d.ts +0 -17
- package/lib/ui/tables/dropdown-menu/dropdown-menu.component.d.ts +0 -43
- package/lib/ui/tables/paginador/paginador.component.d.ts +0 -20
- package/lib/ui/tables/table-advance/table-advance.component.d.ts +0 -94
- package/lib/ui/tables/table-advance-optimizada/table-advance-optimizada.component.d.ts +0 -82
- package/lib/ui/tables/table-agrupada/table-agrupada.component.d.ts +0 -96
- package/lib/ui/tables/table-busqueda/table-busqueda.component.d.ts +0 -48
- package/lib/ui/tables/table-detalle/table-detalle.component.d.ts +0 -59
- package/lib/ui/tables/table-simple/table-simple.component.d.ts +0 -39
- package/lib/ui/tables/table-ultimate/table-ultimate.component.d.ts +0 -84
- package/lib/ui/tabs/nav-tabs/nav-tabs.component.d.ts +0 -9
- package/lib/ui/tabs/tab-item/tab-item.component.d.ts +0 -9
- package/lib/utils/general/validaciones-simple.d.ts +0 -2
- package/lib/utils/general/validaciones.d.ts +0 -11
- package/lib/utils/helpers/api-result.d.ts +0 -17
- package/lib/utils/helpers/modal-result.d.ts +0 -10
- package/ng-components-tsi-0.0.36.tgz +0 -0
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,31 +1,23 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ng-components-tsi",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"peerDependencies": {
|
|
5
|
-
"shared-tsi": "^0.0.13",
|
|
6
|
-
"core-tsi": "^0.0.13",
|
|
7
|
-
"@angular/animations": "^19.2.6",
|
|
8
|
-
"@angular/cdk": "^19.2.6",
|
|
9
|
-
"sweetalert2": "^11.19.1",
|
|
10
|
-
"@ng-bootstrap/ng-bootstrap": "^18.0.0",
|
|
11
|
-
"@popperjs/core": "^2.11.8",
|
|
12
|
-
"bootstrap": "^5.3.5",
|
|
13
|
-
"@angular/common": "^19.2.0",
|
|
14
|
-
"@angular/core": "^19.2.0"
|
|
15
|
-
},
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"tslib": "^2.3.0"
|
|
18
|
-
},
|
|
19
|
-
"sideEffects": false,
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"default": "./package.json"
|
|
25
|
-
},
|
|
26
|
-
".": {
|
|
27
|
-
"types": "./index.d.ts",
|
|
28
|
-
"default": "./fesm2022/ng-components-tsi.mjs"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ng-components-tsi",
|
|
3
|
+
"version": "0.0.38",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"shared-tsi": "^0.0.13",
|
|
6
|
+
"core-tsi": "^0.0.13",
|
|
7
|
+
"@angular/animations": "^19.2.6",
|
|
8
|
+
"@angular/cdk": "^19.2.6",
|
|
9
|
+
"sweetalert2": "^11.19.1",
|
|
10
|
+
"@ng-bootstrap/ng-bootstrap": "^18.0.0",
|
|
11
|
+
"@popperjs/core": "^2.11.8",
|
|
12
|
+
"bootstrap": "^5.3.5",
|
|
13
|
+
"@angular/common": "^19.2.0",
|
|
14
|
+
"@angular/core": "^19.2.0"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"tslib": "^2.3.0"
|
|
18
|
+
},
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"scripts": {
|
|
21
|
+
"release:lib": "npm version patch && ng build ng-components-tsi && npm publish --prefix dist/ng-components-tsi"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Directive, HostListener, input, output } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive({
|
|
4
|
+
selector: '[atajoTecla]'
|
|
5
|
+
})
|
|
6
|
+
export class AtajosDirective {
|
|
7
|
+
|
|
8
|
+
altKeyCombination = input<string>('')
|
|
9
|
+
emitirAtajo = output<void>()
|
|
10
|
+
|
|
11
|
+
@HostListener('window:keydown', ['$event'])
|
|
12
|
+
onKeyDown(event: KeyboardEvent) {
|
|
13
|
+
|
|
14
|
+
const key = event.key?.toLowerCase?.();
|
|
15
|
+
if (!key) return;
|
|
16
|
+
|
|
17
|
+
if (event.ctrlKey &&
|
|
18
|
+
!event.altKey &&
|
|
19
|
+
!event.metaKey &&
|
|
20
|
+
!event.shiftKey &&
|
|
21
|
+
key === this.altKeyCombination().toLowerCase()) {
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
this.emitirAtajo.emit();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { animate, state, style, transition, trigger } from "@angular/animations";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const fadeInOut = trigger('fadeInOut', [
|
|
5
|
+
transition(':enter', [
|
|
6
|
+
style({ opacity: 0, transform: 'translateY(-5px)' }),
|
|
7
|
+
animate('200ms ease-out', style({ opacity: 1, transform: 'translateY(0)' })),
|
|
8
|
+
]),
|
|
9
|
+
transition(':leave', [
|
|
10
|
+
animate('200ms ease-in', style({ opacity: 0, transform: 'translateY(-5px)' })),
|
|
11
|
+
]),
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export const dropdownAnimation = trigger('dropdownAnimation', [
|
|
16
|
+
transition(':enter', [
|
|
17
|
+
style({ height: '0', opacity: 0, transform: 'translateY(-10px)', overflow: 'hidden' }),
|
|
18
|
+
animate(
|
|
19
|
+
'200ms ease-out',
|
|
20
|
+
style({ height: '*', opacity: 1, transform: 'translateY(0)' })
|
|
21
|
+
),
|
|
22
|
+
]),
|
|
23
|
+
transition(':leave', [
|
|
24
|
+
animate(
|
|
25
|
+
'200ms ease-in',
|
|
26
|
+
style({ height: '0', opacity: 0, transform: 'translateY(-10px)' })
|
|
27
|
+
),
|
|
28
|
+
]),
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
export const dropdownAnimationV2 = trigger('dropdownAnimation', [
|
|
32
|
+
state('cerrado', style({
|
|
33
|
+
height: '0px',
|
|
34
|
+
opacity: 0,
|
|
35
|
+
transform: 'translateY(-10px)',
|
|
36
|
+
overflow: 'hidden',
|
|
37
|
+
})),
|
|
38
|
+
state('abierto', style({
|
|
39
|
+
height: '*',
|
|
40
|
+
opacity: 1,
|
|
41
|
+
transform: 'translateY(0)',
|
|
42
|
+
overflow: 'hidden',
|
|
43
|
+
})),
|
|
44
|
+
transition('cerrado <=> abierto', animate('300ms ease')),
|
|
45
|
+
]);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { animate, AnimationBuilder, AnimationPlayer, style } from '@angular/animations';
|
|
2
|
+
import { Directive, ElementRef, inject, input, OnDestroy, OnInit } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
@Directive({
|
|
5
|
+
selector: '[fade]'
|
|
6
|
+
})
|
|
7
|
+
export class FadeDirective implements OnInit, OnDestroy{
|
|
8
|
+
|
|
9
|
+
private elementRef = inject(ElementRef)
|
|
10
|
+
private builder = inject(AnimationBuilder)
|
|
11
|
+
|
|
12
|
+
fadeIn = input<boolean>(true)
|
|
13
|
+
|
|
14
|
+
private player: AnimationPlayer;
|
|
15
|
+
|
|
16
|
+
playAnimation(fadeIn: boolean){
|
|
17
|
+
const animation = fadeIn
|
|
18
|
+
? [
|
|
19
|
+
style({ opacity: 0, transform: 'translateY(-5px)' }),
|
|
20
|
+
animate('200ms ease-out', style({ opacity: 1, transform: 'translateY(0)' })),
|
|
21
|
+
]
|
|
22
|
+
: [
|
|
23
|
+
style({ opacity: 1, transform: 'translateY(0)' }),
|
|
24
|
+
animate('200ms ease-in', style({ opacity: 0, transform: 'translateY(-5px)' })),
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const factory = this.builder.build(animation);
|
|
28
|
+
this.player = factory.create(this.elementRef.nativeElement);
|
|
29
|
+
this.player.play();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
ngOnInit(): void {
|
|
33
|
+
this.playAnimation(this.fadeIn());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
ngOnDestroy(): void {
|
|
37
|
+
if (this.player) {
|
|
38
|
+
this.playAnimation(false);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Directive, ElementRef, inject, Input, Renderer2 } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive({
|
|
4
|
+
selector: 'input[type=checkbox][animatedCheckbox]',
|
|
5
|
+
standalone: true
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
export class AnimatedCheckboxDirective {
|
|
9
|
+
|
|
10
|
+
@Input() cbClass: 'success' | 'danger' | 'warning' | 'info' | '' = '';
|
|
11
|
+
|
|
12
|
+
private el = inject(ElementRef<HTMLInputElement>);
|
|
13
|
+
private renderer = inject(Renderer2);
|
|
14
|
+
|
|
15
|
+
ngOnInit() {
|
|
16
|
+
const input = this.el.nativeElement;
|
|
17
|
+
const label = input.closest('label');
|
|
18
|
+
if (!label) return;
|
|
19
|
+
|
|
20
|
+
this.renderer.addClass(label, 'checkbox-animated');
|
|
21
|
+
|
|
22
|
+
if (this.cbClass) {
|
|
23
|
+
this.renderer.addClass(label, this.cbClass);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export const COLOR_CLASSES = {
|
|
2
|
+
azul: 'btn-info',
|
|
3
|
+
rojo: 'btn-danger',
|
|
4
|
+
rojo_alerta: 'btn-danger-alert',
|
|
5
|
+
verde: 'btn-success',
|
|
6
|
+
negro: 'btn-dark',
|
|
7
|
+
amarillo: 'btn-warning',
|
|
8
|
+
gris: 'btn-secondary',
|
|
9
|
+
plomo: 'btn-dark bg-mid-button'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const OUTLINE_COLOR_CLASSES = {
|
|
13
|
+
azul: 'btn-outline-info',
|
|
14
|
+
rojo: 'btn-outline-danger',
|
|
15
|
+
verde: 'btn-outline-success',
|
|
16
|
+
negro: 'btn-outline-dark',
|
|
17
|
+
amarillo: 'btn-outline-warning',
|
|
18
|
+
gris: 'btn-outline-secondary',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const ICON_CLASSES = {
|
|
22
|
+
agregar: 'fa-plus',
|
|
23
|
+
buscar: 'fa-search',
|
|
24
|
+
guardar: 'fa-save',
|
|
25
|
+
nocancelar: 'fa-check-circle',
|
|
26
|
+
cancelar: 'fa-times-circle',
|
|
27
|
+
cancelar2: 'fa-times',
|
|
28
|
+
marcar: 'fa-file',
|
|
29
|
+
atras: 'fa-angle-double-left',
|
|
30
|
+
adelante: 'fa-angle-double-right',
|
|
31
|
+
eliminar: 'fa-trash-alt',
|
|
32
|
+
imprimir: 'fa-print',
|
|
33
|
+
subir: 'fa-upload',
|
|
34
|
+
bajar: 'fa-download',
|
|
35
|
+
ver: 'fa-eye',
|
|
36
|
+
comentario: 'fa-comment',
|
|
37
|
+
editar: 'fa-pencil-alt',
|
|
38
|
+
calcular: 'fa-calculator',
|
|
39
|
+
aprobar: 'fa-thumbs-up',
|
|
40
|
+
desaprobar: 'fa-thumbs-down',
|
|
41
|
+
check: 'fa-check',
|
|
42
|
+
excel: 'fa-file-excel',
|
|
43
|
+
pdf: 'fa-file-pdf',
|
|
44
|
+
refresh: 'fa-sync-alt',
|
|
45
|
+
cerrar: 'fa-times',
|
|
46
|
+
visar: 'fa-paper-plane',
|
|
47
|
+
anular: 'fa-ban',
|
|
48
|
+
trazabilidad: 'fa-copy',
|
|
49
|
+
correo: 'fa-envelope-open',
|
|
50
|
+
usuario: 'fa-user-alt',
|
|
51
|
+
enviarSunat: 'fa-location-arrow',
|
|
52
|
+
descargar: 'fa-download',
|
|
53
|
+
borrar: 'fa-eraser',
|
|
54
|
+
lista: 'fa-list',
|
|
55
|
+
monedas: 'fa-coins',
|
|
56
|
+
izquierda: 'fa-arrow-left',
|
|
57
|
+
derecha: 'fa-arrow-right',
|
|
58
|
+
caja: 'fas fa-folder-plus',
|
|
59
|
+
cerrar_caja: 'fas fa-rectangle-xmark',
|
|
60
|
+
abrir_caja: 'fas fa-box-open',
|
|
61
|
+
liquidar: 'fas fa-cash-register',
|
|
62
|
+
configuracion: 'fas fa-cog',
|
|
63
|
+
contrato: 'fas fa-file-contract',
|
|
64
|
+
bloquear: 'fas fa-lock',
|
|
65
|
+
desbloquear: 'fas fa-unlock'
|
|
66
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Directive, ElementRef, inject, input, OnInit, Renderer2 } from '@angular/core';
|
|
2
|
+
import { COLOR_CLASSES } from './button.constants';
|
|
3
|
+
|
|
4
|
+
@Directive({
|
|
5
|
+
selector: '[colorBtn]',
|
|
6
|
+
standalone: true
|
|
7
|
+
})
|
|
8
|
+
export class ButtonsModalDirective implements OnInit {
|
|
9
|
+
color = input<'azul' | 'rojo' | 'verde' | 'negro' | 'amarillo' | 'gris' | 'plomo' | 'none' | string>('azul', { alias: 'colorBtn' })
|
|
10
|
+
|
|
11
|
+
private el = inject(ElementRef)
|
|
12
|
+
private renderer = inject(Renderer2)
|
|
13
|
+
|
|
14
|
+
ngOnInit(): void {
|
|
15
|
+
this.aplicarEstilos()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
aplicarEstilos() {
|
|
19
|
+
const baseClasses = ['btn', 'btn-sm', 'py-2', 'px-4', 'btn-rounded', 'me-1']
|
|
20
|
+
baseClasses.forEach(cls => this.renderer.addClass(this.el.nativeElement, cls))
|
|
21
|
+
|
|
22
|
+
if (this.color() === 'none') {
|
|
23
|
+
this.renderer.removeClass(this.el.nativeElement, 'py-2')
|
|
24
|
+
this.renderer.removeClass(this.el.nativeElement, 'px-4')
|
|
25
|
+
this.renderer.addClass(this.el.nativeElement, 'bg-none')
|
|
26
|
+
this.renderer.addClass(this.el.nativeElement, 'border-0')
|
|
27
|
+
this.renderer.addClass(this.el.nativeElement, 'fs-6')
|
|
28
|
+
this.renderer.addClass(this.el.nativeElement, 'fw-7')
|
|
29
|
+
} else {
|
|
30
|
+
const colorClass = COLOR_CLASSES[this.color()]
|
|
31
|
+
if (colorClass) {
|
|
32
|
+
this.renderer.addClass(this.el.nativeElement, colorClass)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Directive, ElementRef, inject, input, OnInit, Renderer2 } from '@angular/core';
|
|
2
|
+
import { OUTLINE_COLOR_CLASSES } from './button.constants';
|
|
3
|
+
|
|
4
|
+
@Directive({
|
|
5
|
+
selector: '[colorOutlineBtn]',
|
|
6
|
+
standalone: true
|
|
7
|
+
})
|
|
8
|
+
export class ButtonsOutlineDirective implements OnInit {
|
|
9
|
+
color = input<'azul' | 'rojo' | 'verde' | 'negro' | 'amarillo' | 'gris' | 'plomo' | string>('azul', { alias: 'colorOutlineBtn' })
|
|
10
|
+
|
|
11
|
+
private el = inject(ElementRef)
|
|
12
|
+
private renderer = inject(Renderer2)
|
|
13
|
+
|
|
14
|
+
ngOnInit(): void {
|
|
15
|
+
this.aplicarEstilos()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
aplicarEstilos() {
|
|
19
|
+
const baseClasses = ['btn', 'btn-rounded', 'me-1', 'fs-8', 'px-3']
|
|
20
|
+
baseClasses.forEach(cls => this.renderer.addClass(this.el.nativeElement, cls))
|
|
21
|
+
|
|
22
|
+
const colorClass = OUTLINE_COLOR_CLASSES[this.color()]
|
|
23
|
+
if (colorClass) {
|
|
24
|
+
this.renderer.addClass(this.el.nativeElement, colorClass)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Directive, ElementRef, inject, input, OnInit, Renderer2 } from '@angular/core';
|
|
2
|
+
import { ICON_CLASSES } from './button.constants';
|
|
3
|
+
|
|
4
|
+
@Directive({
|
|
5
|
+
selector: '[iconName]',
|
|
6
|
+
standalone: true
|
|
7
|
+
})
|
|
8
|
+
export class IconsDirective implements OnInit {
|
|
9
|
+
name = input<keyof typeof ICON_CLASSES | string>('agregar', { alias: 'iconName' })
|
|
10
|
+
|
|
11
|
+
private elementRef = inject(ElementRef)
|
|
12
|
+
private renderer = inject(Renderer2)
|
|
13
|
+
|
|
14
|
+
ngOnInit(): void {
|
|
15
|
+
this.aplicarEstilo()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
aplicarEstilo() {
|
|
19
|
+
this.renderer.addClass(this.elementRef.nativeElement, 'fa')
|
|
20
|
+
|
|
21
|
+
const iconClass = ICON_CLASSES[this.name()]
|
|
22
|
+
if (iconClass) {
|
|
23
|
+
this.renderer.addClass(this.elementRef.nativeElement, iconClass)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Directive, HostListener, inject, input } from '@angular/core';
|
|
2
|
+
import { ToastService } from '../../service/toast.service';
|
|
3
|
+
|
|
4
|
+
@Directive({
|
|
5
|
+
selector: '[caracteresCodigo]'
|
|
6
|
+
})
|
|
7
|
+
export class CaracteresCodigoDirective {
|
|
8
|
+
|
|
9
|
+
private regex: RegExp = /^[a-zA-Z0-9.\-/]*$/
|
|
10
|
+
private toast = inject(ToastService)
|
|
11
|
+
|
|
12
|
+
caracteresCodigo = input<boolean>(true)
|
|
13
|
+
|
|
14
|
+
@HostListener('keypress', ['$event'])
|
|
15
|
+
onKeyPress(event: KeyboardEvent): void {
|
|
16
|
+
if (!this.caracteresCodigo()) return
|
|
17
|
+
const allowedKeys = ['Delete', 'Backspace', 'Tab', 'Escape', 'Enter']
|
|
18
|
+
const isCtrlCombination =
|
|
19
|
+
event.ctrlKey && ['a', 'c', 'v', 'x'].includes(event.key.toLowerCase())
|
|
20
|
+
if (allowedKeys.includes(event.key) || isCtrlCombination) {
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
if (!/^[a-zA-Z0-9.\-/]$/.test(event.key)) {
|
|
24
|
+
event.preventDefault()
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@HostListener('input', ['$event'])
|
|
29
|
+
onInput(event: Event) {
|
|
30
|
+
if (!this.caracteresCodigo()) return
|
|
31
|
+
const input = event.target as HTMLInputElement
|
|
32
|
+
const originalValue = input.value
|
|
33
|
+
|
|
34
|
+
const newValue = originalValue.replace(/[^a-zA-Z0-9.\-/]/g, '')
|
|
35
|
+
|
|
36
|
+
if (originalValue != newValue) {
|
|
37
|
+
input.value = newValue
|
|
38
|
+
this.toast.warning('Advertencia',`Solo se permiten caracteres alfanuméricos, guion (-), punto (.) y slash (/)`)
|
|
39
|
+
input.dispatchEvent(new Event('input'))
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@HostListener('paste', ['$event'])
|
|
44
|
+
onPaste(event: ClipboardEvent) {
|
|
45
|
+
if (!this.caracteresCodigo()) return
|
|
46
|
+
const clipboardData = event.clipboardData?.getData('text/plain') || ''
|
|
47
|
+
if (!this.regex.test(clipboardData)) {
|
|
48
|
+
event.preventDefault()
|
|
49
|
+
this.toast.warning('Advertencia', `Solo se permiten caracteres alfanuméricos, guion (-), punto (.) y slash (/)`)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@HostListener('drop', ['$event'])
|
|
54
|
+
onDrop(event: DragEvent) {
|
|
55
|
+
if (!this.caracteresCodigo()) return
|
|
56
|
+
const textData = event.dataTransfer?.getData('text') || ''
|
|
57
|
+
if (!this.regex.test(textData)) {
|
|
58
|
+
event.preventDefault()
|
|
59
|
+
this.toast.warning('Advertencia',`Solo se permiten caracteres alfanuméricos, guion (-), punto (.) y slash (/)`)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DecimalPipe } from '@angular/common';
|
|
2
|
+
import { Directive, ElementRef, HostListener, inject, input } from '@angular/core';
|
|
3
|
+
import { NgModel } from '@angular/forms';
|
|
4
|
+
import { cleanNumber } from 'shared-tsi';
|
|
5
|
+
|
|
6
|
+
@Directive({
|
|
7
|
+
selector: '[appDecimal]',
|
|
8
|
+
providers: [DecimalPipe]
|
|
9
|
+
})
|
|
10
|
+
export class DecimalDirective {
|
|
11
|
+
|
|
12
|
+
appDecimal = input<string>('1.2-2')
|
|
13
|
+
|
|
14
|
+
private elementRef = inject(ElementRef)
|
|
15
|
+
private decimalPipe = inject(DecimalPipe)
|
|
16
|
+
private ngModel = inject(NgModel)
|
|
17
|
+
|
|
18
|
+
private isFocused = false
|
|
19
|
+
|
|
20
|
+
ngAfterViewInit(): void {
|
|
21
|
+
queueMicrotask(() => {
|
|
22
|
+
this.formatValue()
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@HostListener('blur')
|
|
27
|
+
onBlur(): void {
|
|
28
|
+
this.isFocused = false
|
|
29
|
+
this.formatValue()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// @HostListener('input', ['$event'])
|
|
33
|
+
// onInput(event: Event): void {
|
|
34
|
+
// const input = event.target as HTMLInputElement
|
|
35
|
+
// const rawValue = input.value
|
|
36
|
+
|
|
37
|
+
// const cleaned = rawValue.replace(/[^0-9.,-]/g, '')
|
|
38
|
+
// const normalized = cleaned.replace(',', '.')
|
|
39
|
+
// const parsed = parseFloat(normalized)
|
|
40
|
+
|
|
41
|
+
// if (!isNaN(parsed)) {
|
|
42
|
+
// this.ngModel.update.emit(parsed)
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
|
+
|
|
46
|
+
private formatValue(): void {
|
|
47
|
+
const value = cleanNumber(this.ngModel.model)
|
|
48
|
+
const formatted = this.decimalPipe.transform(value, (this.appDecimal() ?? '1.2-2'))
|
|
49
|
+
this.elementRef.nativeElement.value = formatted !== null ? formatted : this.decimalPipe.transform(0, (this.appDecimal() ?? '1.2-2'))
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Directive, ElementRef, HostListener, inject } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive({
|
|
4
|
+
selector: '[onlyDay]'
|
|
5
|
+
})
|
|
6
|
+
export class OnlyDayDirective {
|
|
7
|
+
private elementRef = inject(ElementRef<HTMLInputElement>)
|
|
8
|
+
|
|
9
|
+
@HostListener('keypress', ['$event'])
|
|
10
|
+
onKeyPress(event: KeyboardEvent): void {
|
|
11
|
+
const inputChar = event.key
|
|
12
|
+
|
|
13
|
+
if (event.ctrlKey || event.metaKey || inputChar.length > 1) return
|
|
14
|
+
|
|
15
|
+
if (!/^[0-9]$/.test(inputChar)) {
|
|
16
|
+
event.preventDefault()
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const input = this.elementRef.nativeElement
|
|
21
|
+
const currentValue = input.value
|
|
22
|
+
const start = input.selectionStart ?? currentValue.length
|
|
23
|
+
const end = input.selectionEnd ?? currentValue.length
|
|
24
|
+
|
|
25
|
+
const proposed = currentValue.substring(0, start) + inputChar + currentValue.substring(end)
|
|
26
|
+
const num = Number(proposed)
|
|
27
|
+
|
|
28
|
+
if (num < 1 || num > 31) {
|
|
29
|
+
event.preventDefault()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@HostListener('paste', ['$event'])
|
|
34
|
+
onPaste(event: ClipboardEvent): void {
|
|
35
|
+
const pasted = event.clipboardData?.getData('text') || ''
|
|
36
|
+
|
|
37
|
+
if (!/^\d+$/.test(pasted)) {
|
|
38
|
+
event.preventDefault()
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const input = this.elementRef.nativeElement
|
|
43
|
+
const currentValue = input.value
|
|
44
|
+
const start = input.selectionStart ?? currentValue.length
|
|
45
|
+
const end = input.selectionEnd ?? currentValue.length
|
|
46
|
+
|
|
47
|
+
const proposed = currentValue.substring(0, start) + pasted + currentValue.substring(end)
|
|
48
|
+
const num = Number(proposed)
|
|
49
|
+
if (num < 1 || num > 31) {
|
|
50
|
+
event.preventDefault()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Directive, ElementRef, HostListener, inject } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive({
|
|
4
|
+
selector: '[onlyNumberFlex]'
|
|
5
|
+
})
|
|
6
|
+
export class OnlyNumberFlexDirective {
|
|
7
|
+
|
|
8
|
+
private elementRef = inject(ElementRef)
|
|
9
|
+
private regex = /^-?[\d.,]*$/;
|
|
10
|
+
|
|
11
|
+
@HostListener('keypress', ['$event'])
|
|
12
|
+
onKeyPress(event: KeyboardEvent): void {
|
|
13
|
+
const inputChar = event.key
|
|
14
|
+
|
|
15
|
+
if (event.ctrlKey || event.metaKey || inputChar.length > 1) return
|
|
16
|
+
|
|
17
|
+
const input = this.elementRef.nativeElement
|
|
18
|
+
const currentValue = input.value
|
|
19
|
+
const start = input.selectionStart ?? currentValue.length
|
|
20
|
+
const end = input.selectionEnd ?? currentValue.length
|
|
21
|
+
|
|
22
|
+
const proposed =
|
|
23
|
+
currentValue.substring(0, start) +
|
|
24
|
+
inputChar +
|
|
25
|
+
currentValue.substring(end)
|
|
26
|
+
|
|
27
|
+
if (!this.regex.test(proposed)) {
|
|
28
|
+
event.preventDefault()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@HostListener('paste', ['$event'])
|
|
33
|
+
onPaste(event: ClipboardEvent): void {
|
|
34
|
+
const pasted = event.clipboardData?.getData('text') || ''
|
|
35
|
+
const input = this.elementRef.nativeElement
|
|
36
|
+
const currentValue = input.value
|
|
37
|
+
const start = input.selectionStart ?? currentValue.length
|
|
38
|
+
const end = input.selectionEnd ?? currentValue.length
|
|
39
|
+
|
|
40
|
+
const proposed =
|
|
41
|
+
currentValue.substring(0, start) +
|
|
42
|
+
pasted +
|
|
43
|
+
currentValue.substring(end)
|
|
44
|
+
|
|
45
|
+
if (!this.regex.test(proposed)) {
|
|
46
|
+
event.preventDefault()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Directive, ElementRef, HostListener, inject } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive({
|
|
4
|
+
selector: '[onlyNumber]'
|
|
5
|
+
})
|
|
6
|
+
export class OnlyNumberDirective {
|
|
7
|
+
|
|
8
|
+
private elementRef = inject(ElementRef)
|
|
9
|
+
|
|
10
|
+
@HostListener('keypress', ['$event'])
|
|
11
|
+
onKeyPress(event: KeyboardEvent): void {
|
|
12
|
+
const inputChar = event.key
|
|
13
|
+
|
|
14
|
+
if (event.ctrlKey || event.metaKey || inputChar.length > 1) return
|
|
15
|
+
|
|
16
|
+
const input = this.elementRef.nativeElement
|
|
17
|
+
const currentValue = input.value
|
|
18
|
+
const start = input.selectionStart ?? currentValue.length
|
|
19
|
+
const end = input.selectionEnd ?? currentValue.length
|
|
20
|
+
|
|
21
|
+
const proposed =
|
|
22
|
+
currentValue.substring(0, start) +
|
|
23
|
+
inputChar +
|
|
24
|
+
currentValue.substring(end)
|
|
25
|
+
|
|
26
|
+
const regex = /^-?\d*\.?\d*$/
|
|
27
|
+
|
|
28
|
+
if (!regex.test(proposed)) {
|
|
29
|
+
event.preventDefault()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@HostListener('paste', ['$event'])
|
|
34
|
+
onPaste(event: ClipboardEvent): void {
|
|
35
|
+
const pasted = event.clipboardData?.getData('text') || ''
|
|
36
|
+
const input = this.elementRef.nativeElement
|
|
37
|
+
const currentValue = input.value
|
|
38
|
+
const start = input.selectionStart ?? currentValue.length
|
|
39
|
+
const end = input.selectionEnd ?? currentValue.length
|
|
40
|
+
|
|
41
|
+
const proposed =
|
|
42
|
+
currentValue.substring(0, start) +
|
|
43
|
+
pasted +
|
|
44
|
+
currentValue.substring(end)
|
|
45
|
+
|
|
46
|
+
const regex = /^-?\d*\.?\d*$/
|
|
47
|
+
|
|
48
|
+
if (!regex.test(proposed)) {
|
|
49
|
+
event.preventDefault()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|