NumberInput, para formateo de numeros
This commit is contained in:
@ -18,7 +18,8 @@
|
|||||||
"predis/predis": "^2",
|
"predis/predis": "^2",
|
||||||
"robmorgan/phinx": "^0.16",
|
"robmorgan/phinx": "^0.16",
|
||||||
"slim/slim": "^4",
|
"slim/slim": "^4",
|
||||||
"symfony/string": "^7.2"
|
"symfony/string": "^7.2",
|
||||||
|
"tedivm/jshrink": "^1.7"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fakerphp/faker": "^1",
|
"fakerphp/faker": "^1",
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script>
|
<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 {
|
class NumberInput {
|
||||||
input
|
input
|
||||||
isRational
|
isRational
|
||||||
@ -10,7 +14,7 @@
|
|||||||
constructor({input, isRational, outputLocale}) {
|
constructor({input, isRational, outputLocale}) {
|
||||||
this.input = input
|
this.input = input
|
||||||
this.isRational = isRational
|
this.isRational = isRational
|
||||||
this.outputLocale = outputLocale
|
this.outputLocale = outputLocale || 'es-CL'
|
||||||
|
|
||||||
this.formatters = {}
|
this.formatters = {}
|
||||||
const locales = ['es-CL', 'en-US']
|
const locales = ['es-CL', 'en-US']
|
||||||
@ -23,13 +27,13 @@
|
|||||||
|
|
||||||
if (this.input.value !== '') {
|
if (this.input.value !== '') {
|
||||||
this.currentValue = this.process(this.input.value)
|
this.currentValue = this.process(this.input.value)
|
||||||
|
this.input.value = this.format(this.currentValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
watch() {
|
watch() {
|
||||||
this.input.addEventListener('change', event => {
|
this.input.addEventListener('change', event => {
|
||||||
const value = this.process(event.target.value)
|
this.currentValue = this.process(event.currentTarget.value)
|
||||||
this.currentValue = value
|
this.input.value = this.format(this.currentValue)
|
||||||
this.input.value = this.format(value)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
process(stringValue) {
|
process(stringValue) {
|
||||||
@ -69,4 +73,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
Reference in New Issue
Block a user