opnform-host-nginx/client/components/forms/CodeInput.client.vue

61 lines
1.2 KiB
Vue
Raw Normal View History

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