Files
716d43a9a8 Nuxt 3 migration (#4342)
Update the nuxt3 version.

Co-authored-by: Jonathan Adeline <jonathan@baserow.io>
Co-authored-by: Bram Wiepjes <bramw@protonmail.com>
Co-authored-by: Cezary <cezary@baserow.io>
Co-authored-by: Tsering Paljor <tsering@baserow.io>
Co-authored-by: Przemyslaw Kukulski <przemyslaw+gh@baserow.io>
Co-authored-by: Bram <bram2w@users.noreply.github.com>
2026-01-22 10:27:19 +01:00

60 lines
1.1 KiB
Vue

<template>
<input
v-model="inputValue"
v-bind="$attrs"
class="preview-navigation-bar-input"
:class="{
'preview-navigation-bar-input--invalid': invalidValueForType,
}"
/>
</template>
<script>
import _ from 'lodash'
export default {
inheritAttrs: false,
props: {
defaultValue: {
type: [String, Number, Array],
required: false,
default: '',
},
validationFn: {
type: Function,
required: true,
},
},
emits: ['change'],
data() {
return {
value: this.defaultValue,
invalidValueForType: false,
}
},
computed: {
inputValue: {
get() {
return this.value
},
set(inputValue) {
this.invalidValueForType = false
this.value = inputValue
try {
this.$emit('change', this.validationFn(this.value))
} catch (error) {
this.invalidValueForType = true
}
},
},
},
watch: {
defaultValue(newValue) {
if (!_.isEqual(this.inputValue, newValue)) {
this.inputValue = newValue
}
},
},
}
</script>