|
|
@@ -1,28 +1,30 @@
|
|
|
<!--
|
|
|
An input for numeric values
|
|
|
-->
|
|
|
+<!-- eslint-disable vue/valid-v-bind -->
|
|
|
|
|
|
<template>
|
|
|
<v-text-field
|
|
|
ref="input"
|
|
|
- :modelValue.number="modelValue"
|
|
|
+ :model-value.number="modelValue"
|
|
|
:label="label || field ? $t(label ?? field) : undefined"
|
|
|
hide-details
|
|
|
:density="density"
|
|
|
type="number"
|
|
|
:variant="variant"
|
|
|
- @update:modelValue="onModelUpdate($event)"
|
|
|
+ @update:model-value="onModelUpdate($event)"
|
|
|
/>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import type { PropType } from 'vue'
|
|
|
+import type { PropType, Ref } from 'vue'
|
|
|
|
|
|
type Density = null | 'default' | 'comfortable' | 'compact'
|
|
|
|
|
|
const props = defineProps({
|
|
|
modelValue: {
|
|
|
type: Number,
|
|
|
+ required: true,
|
|
|
},
|
|
|
/**
|
|
|
* Nom de la propriété d'une entité lorsque l'input concerne cette propriété
|
|
|
@@ -85,6 +87,7 @@ const props = defineProps({
|
|
|
/**
|
|
|
* Reference to the v-text-field
|
|
|
*/
|
|
|
+// eslint-disable-next-line
|
|
|
const input: Ref<any> = ref(null)
|
|
|
|
|
|
/**
|
|
|
@@ -117,26 +120,20 @@ const keepInRange = (val: number) => {
|
|
|
return val
|
|
|
}
|
|
|
|
|
|
-const onModelUpdate = (event: string) => {
|
|
|
- // eslint-disable-next-line vue/no-mutating-props
|
|
|
- props.modelValue = keepInRange(cast(event))
|
|
|
- emitUpdate()
|
|
|
-}
|
|
|
-
|
|
|
const emit = defineEmits(['update:modelValue'])
|
|
|
|
|
|
-/**
|
|
|
- * Emit the update event
|
|
|
- */
|
|
|
-const emitUpdate = () => {
|
|
|
- emit('update:modelValue', props.modelValue)
|
|
|
+const onModelUpdate = (event: string) => {
|
|
|
+ // eslint-disable-next-line vue/no-mutating-props
|
|
|
+ // props.modelValue = keepInRange(cast(event))
|
|
|
+ // emitUpdate()
|
|
|
+ emit('update:modelValue', keepInRange(cast(event)))
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Setup min and max values at the input level
|
|
|
*/
|
|
|
onMounted(() => {
|
|
|
- const inputElement = input.value.$el.querySelector('input')
|
|
|
+ const inputElement = input.value!.$el.querySelector('input')
|
|
|
if (props.min !== null) {
|
|
|
inputElement.min = props.min
|
|
|
}
|