Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update quasar import #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 22 additions & 30 deletions src/component/QDecimal.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import Vue from 'vue'
import { Quasar } from 'quasar'

import {
import Quasar, {
QField,
QInput
} from 'quasar'

export default function ({ ssrContext }) {
return Vue.extend({
name: 'QDecimal',
mixins: [ QField ],
mixins: [QField],
props: {
value: Number,
lang: String,
Expand Down Expand Up @@ -72,11 +70,11 @@ export default function ({ ssrContext }) {
intl () {
return {
language: this.language,
options: {
style: this.mode,
currency: this.currency,
currencyDisplay: this.display,
minimumFractionDigits: this.cPrecision,
options: {
style: this.mode,
currency: this.currency,
currencyDisplay: this.display,
minimumFractionDigits: this.cPrecision,
maximumFractionDigits: this.cPrecision
}
}
Expand All @@ -85,14 +83,18 @@ export default function ({ ssrContext }) {
return Intl.NumberFormat(this.intl.language, this.intl.options)
},
numberFormatter () {
return Intl.NumberFormat(this.intl.language, { style: 'decimal', minimumFractionDigits: this.cPrecision, maximumFractionDigits: this.cPrecision })
return Intl.NumberFormat(this.intl.language, {
style: 'decimal',
minimumFractionDigits: this.cPrecision,
maximumFractionDigits: this.cPrecision
})
},
formatter () {
if (!this.prefix && !this.suffix) {
return this.valueFormatter
return this.valueFormatter
}
if (typeof this.prefix === "boolean" || typeof this.suffix === "boolean") {
return this.numberFormatter
return this.numberFormatter
}
return this.valueFormatter
},
Expand All @@ -106,7 +108,7 @@ export default function ({ ssrContext }) {
return this.suffix ? (typeof this.suffix === "boolean" ? this.currencyText : this.suffix) : null
},
cValue: {
get () {
get () {
return this.formatter.format(this.value)
},
set (value) {
Expand All @@ -125,12 +127,11 @@ export default function ({ ssrContext }) {
intl: {
immediate: true,
handler () {
switch(this.mode)
{
case 'decimal':
switch (this.mode) {
case 'decimal':
this.currencyText = ''
break
case 'percent':
case 'percent':
this.currencyText = '%'
break
default:
Expand Down Expand Up @@ -170,16 +171,7 @@ export default function ({ ssrContext }) {
case evt.keyCode === 46:
event.target.selectionStart = event.target.selectionEnd = evt.end
break
// len = { new: event.target.value.length, old: evt.value.length }
// inc = len.new - len.old + del
// pos = evt.end - inc < 0 ? evt.end : evt.end - inc
// event.target.selectionStart = event.target.selectionEnd = pos
// break
case evt.keyCode === 8:
// len = { new: event.target.value.length, old: evt.value.length }
// inc = len.new - len.old - del
// pos = evt.end + inc < 0 ? evt.end : evt.end + inc
// event.target.selectionStart = event.target.selectionEnd = pos
case evt.value !== event.target.value:
len = { new: event.target.value.length, old: evt.value.length }
inc = len.new - len.old
Expand Down Expand Up @@ -234,10 +226,10 @@ export default function ({ ssrContext }) {
}
if (!event.shiftKey) {
switch (event.keyCode) {
case 38:
self.$emit('input', self.value + self.step)
case 38:
self.$emit('input', self.value + self.step)
break
case 40:
case 40:
if (self.value - self.step > 0) {
self.$emit('input', self.value - self.step)
} else {
Expand All @@ -257,4 +249,4 @@ export default function ({ ssrContext }) {
}, [])
}
})
}
}