Skip to content

Commit

Permalink
feat(VNumberInput): precision validation message from locale
Browse files Browse the repository at this point in the history
  • Loading branch information
jsek committed Jul 30, 2024
1 parent 33fb8a8 commit 1fcdbc6
Show file tree
Hide file tree
Showing 44 changed files with 135 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vuetify/src/labs/VNumberInput/VNumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { clamp, genericComponent, getDecimals, omit, propsFactory, useRender } f
// Types
import type { PropType } from 'vue'
import type { VTextFieldSlots } from '@/components/VTextField/VTextField'
import { useLocale } from '@/composables'

type ControlSlot = {
click: (e: MouseEvent) => void
Expand Down Expand Up @@ -73,6 +74,8 @@ export const VNumberInput = genericComponent<VNumberInputSlots>()({
},

setup (props, { slots }) {
const { t } = useLocale()

const model = useProxiedModel(props, 'modelValue')
const inputText = ref<string | null>(null)

Expand Down Expand Up @@ -117,7 +120,9 @@ export const VNumberInput = genericComponent<VNumberInputSlots>()({
}, { immediate: true })

const precisionRules = computed(() => [
(v: string | null) => isNaN(Number(v)) || getDecimals(Number(v)) <= props.precision! || `Expected up to ${props.precision} decimal places`,
(v: string | null) => isNaN(Number(v)) ||
getDecimals(Number(v)) <= props.precision! ||
t('$vuetify.numberInput.precisionExceeded', props.precision),
])

function formatInputValue () {
Expand Down
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/af.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/az.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/bg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Зареди още',
empty: 'Няма повече',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/ckb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Načíst více',
empty: 'Žádné další',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Mehr laden',
empty: 'Nichts weiteres',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/et.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'بارگذاری بیشتر',
empty: 'پایان',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/fi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Charger plus',
empty: 'Aucune donnée supplémentaire',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/hr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/hu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Továbbiak',
empty: 'Nincsen több',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Carica altro',
empty: 'Nessun elemento',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/km.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'ទាញយកបន្ថែម',
empty: 'គ្មានទំព័រទៀត',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/lt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Užkrauti daugiau',
empty: 'Daugiau nėra',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/lv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Laad meer',
empty: 'Niet meer',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/no.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Last flere',
empty: 'Det var alt',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Wczytaj więcej',
empty: 'Brak kolejnych danych',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Carregar mais',
empty: 'Não há mais dados',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/ro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Încarcă mai multe',
empty: 'Nu mai există',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Загрузить ещё',
empty: 'Больше нечего загружать',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/sk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Načítať viac',
empty: 'Žiadne ďalšie',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/sl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Naloži več',
empty: 'Konec',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/sr-Cyrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/sr-Latn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/sv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/th.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/uk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/vi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/zh-Hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}
3 changes: 3 additions & 0 deletions packages/vuetify/src/locale/zh-Hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ export default {
loadMore: 'Load more',
empty: 'No more',
},
numberInput: {
precisionExceeded: 'Expected up to {0} decimal places',
},
}

0 comments on commit 1fcdbc6

Please sign in to comment.