opnform/resources/js/components/forms/CodeInput.vue

55 lines
1.4 KiB
Vue
Raw Normal View History

2022-09-20 19:59:52 +00:00
<template>
<div :class="wrapperClass">
<label v-if="label" :for="id?id:name"
:class="[theme.CodeInput.label,{'uppercase text-xs':uppercaseLabels, 'text-sm':!uppercaseLabels}]"
>
{{ label }}
<span v-if="required" class="text-red-500 required-dot">*</span>
</label>
<div :class="[theme.CodeInput.input,{ '!ring-red-500 !ring-2': hasValidation && form.errors.has(name), '!cursor-not-allowed !bg-gray-200':disabled }]">
<codemirror :id="id?id:name" v-model="compVal" :disabled="disabled"
:options="cmOptions"
2022-09-20 19:59:52 +00:00
:style="inputStyle" :name="name"
:placeholder="placeholder"
/>
</div>
2022-09-20 19:59:52 +00:00
<small v-if="help" :class="theme.CodeInput.help">
<slot name="help"><span class="field-help" v-html="help" /></slot>
2022-09-20 19:59:52 +00:00
</small>
<has-error v-if="hasValidation" :form="form" :field="name" />
</div>
</template>
<script>
import { codemirror } from 'vue-codemirror'
import 'codemirror/lib/codemirror.css'
import 'codemirror/mode/htmlmixed/htmlmixed.js'
import inputMixin from '~/mixins/forms/input.js'
2022-09-20 19:59:52 +00:00
export default {
name: 'CodeInput',
components: { codemirror },
2022-09-20 19:59:52 +00:00
mixins: [inputMixin],
data () {
return {
cmOptions: {
// codemirror options
tabSize: 4,
mode: 'text/html',
theme: 'default',
lineNumbers: true,
line: true
}
2022-09-20 19:59:52 +00:00
}
},
methods: {}
2022-09-20 19:59:52 +00:00
}
</script>