NumberInput, para formateo de numeros

This commit is contained in:
Juan Pablo Vial
2025-05-05 15:45:07 -04:00
parent ebe31a3d3d
commit 7e54b72587
2 changed files with 11 additions and 6 deletions

View File

@ -18,7 +18,8 @@
"predis/predis": "^2",
"robmorgan/phinx": "^0.16",
"slim/slim": "^4",
"symfony/string": "^7.2"
"symfony/string": "^7.2",
"tedivm/jshrink": "^1.7"
},
"require-dev": {
"fakerphp/faker": "^1",

View File

@ -1,5 +1,9 @@
@push('page_scripts')
<script>
if (typeof Intl.NumberFormat.isLocale === 'undefined' || typeof Intl.NumberFormat.isLocale !== 'function') {
// Load Intl.NumberFormat custom methods
@include('layout.body.scripts.number_format')
}
class NumberInput {
input
isRational
@ -10,7 +14,7 @@
constructor({input, isRational, outputLocale}) {
this.input = input
this.isRational = isRational
this.outputLocale = outputLocale
this.outputLocale = outputLocale || 'es-CL'
this.formatters = {}
const locales = ['es-CL', 'en-US']
@ -23,13 +27,13 @@
if (this.input.value !== '') {
this.currentValue = this.process(this.input.value)
this.input.value = this.format(this.currentValue)
}
}
watch() {
this.input.addEventListener('change', event => {
const value = this.process(event.target.value)
this.currentValue = value
this.input.value = this.format(value)
this.currentValue = this.process(event.currentTarget.value)
this.input.value = this.format(this.currentValue)
})
}
process(stringValue) {
@ -69,4 +73,4 @@
}
}
</script>
@endpush
@endpush