43 lines
1.3 KiB
Vue
43 lines
1.3 KiB
Vue
<template>
|
|
<label class="w-full border border-solid border-gray-500 focus-within:border-primary rounded-lg relative flex">
|
|
<input
|
|
:id="field.key"
|
|
v-model="inner"
|
|
:name="field.key"
|
|
type="text"
|
|
placeholder=""
|
|
class="bg-white rounded-lg focus:outline-none text-gray-600 text-left py-1 px-2 @sm:py-2 text-sm @sm:text-base @sm:px-3 w-full"
|
|
/>
|
|
<field-label :name="field.name" :required="field.required"></field-label>
|
|
</label>
|
|
</template>
|
|
|
|
<script setup>
|
|
import {computed} from 'vue';
|
|
import FieldLabel from '../FieldLabel.vue';
|
|
|
|
const emit = defineEmits(['update:modelValue']);
|
|
const props = defineProps({
|
|
modelValue: {
|
|
required: true,
|
|
validator: (value) => typeof value === 'string',
|
|
},
|
|
field: {
|
|
required: true,
|
|
validator: (value) =>
|
|
hasKeys(value, ['required', 'type', 'key', 'columns', 'name', 'default']) &&
|
|
typeof value.required === 'boolean' &&
|
|
typeof value.key === 'string' &&
|
|
value.key.length > 0 &&
|
|
typeof value.name === 'string' &&
|
|
value.name.length > 0 &&
|
|
hasKeys(value.columns, ['mobile', 'desktop', 'tablet']),
|
|
},
|
|
});
|
|
|
|
const inner = computed({
|
|
get: () => props.modelValue,
|
|
set: (v) => emit('update:modelValue', v),
|
|
});
|
|
</script>
|