opnform/client/components/forms/CodeInput.client.vue

52 lines
1.1 KiB
Vue
Raw Permalink Normal View History

2023-12-09 14:47:03 +00:00
<template>
<input-wrapper
v-bind="inputWrapperProps"
>
<template #label>
<slot name="label" />
</template>
<template #help>
<slot name="help" />
</template>
<div
:class="[theme.CodeInput.input,{ '!ring-red-500 !ring-2': hasError, '!cursor-not-allowed !bg-gray-200':disabled }]"
>
<codemirror :id="id?id:name" v-model="compVal" :disabled="disabled?true:null"
2024-01-16 11:20:05 +00:00
:extensions="extensions"
:style="inputStyle" :name="name" :tab-size="4"
2023-12-09 14:47:03 +00:00
:placeholder="placeholder"
/>
</div>
<template #error>
<slot name="error" />
</template>
</input-wrapper>
</template>
<script>
2024-01-16 11:20:05 +00:00
import { Codemirror } from 'vue-codemirror'
2023-12-09 14:47:03 +00:00
2024-01-16 11:20:05 +00:00
import {html} from '@codemirror/lang-html'
2023-12-09 14:47:03 +00:00
import { inputProps, useFormInput } from './useFormInput.js'
import InputWrapper from './components/InputWrapper.vue'
export default {
2024-01-16 11:20:05 +00:00
components: { InputWrapper, Codemirror },
2023-12-09 14:47:03 +00:00
props: {
...inputProps
},
setup (props, context) {
2024-01-16 11:20:05 +00:00
const extensions = [html()]
2023-12-09 14:47:03 +00:00
return {
2024-01-16 11:20:05 +00:00
...useFormInput(props, context),
extensions
2023-12-09 14:47:03 +00:00
}
}
}
</script>