image input in vue3

This commit is contained in:
Forms Dev 2023-11-28 15:23:29 +05:30
parent f74959214d
commit 0a3a6092f6
1 changed files with 38 additions and 17 deletions

View File

@ -1,11 +1,11 @@
<template> <template>
<div :class="wrapperClass"> <input-wrapper
<label v-if="label" v-bind="$props"
:class="[theme.default.label,{'uppercase text-xs':uppercaseLabels, 'text-sm':!uppercaseLabels}]"
> >
{{ label }} <template #label>
<span v-if="required" class="text-red-500 required-dot">*</span> <slot name="label" />
</label> </template>
<span class="inline-block w-full rounded-md shadow-sm"> <span class="inline-block w-full rounded-md shadow-sm">
<button type="button" aria-haspopup="listbox" aria-expanded="true" aria-labelledby="listbox-label" <button type="button" aria-haspopup="listbox" aria-expanded="true" aria-labelledby="listbox-label"
class="cursor-pointer relative w-full" :class="[theme.default.input,{'ring-red-500 ring-2': hasValidation && form.errors.has(name)}]" class="cursor-pointer relative w-full" :class="[theme.default.input,{'ring-red-500 ring-2': hasValidation && form.errors.has(name)}]"
@ -35,10 +35,13 @@
</div> </div>
</button> </button>
</span> </span>
<small v-if="help" :class="theme.default.help">
<slot name="help"><span class="field-help" v-html="help" /></slot> <template #help>
</small> <slot name="help" />
<has-error v-if="hasValidation" :form="form" :field="name" /> </template>
<template #error>
<slot name="error" />
</template>
<!-- Modal --> <!-- Modal -->
<modal :show="showUploadModal" @close="showUploadModal=false"> <modal :show="showUploadModal" @close="showUploadModal=false">
@ -100,20 +103,38 @@
</div> </div>
</div> </div>
</modal> </modal>
</div> </input-wrapper>
</template> </template>
<script> <script>
import Modal from '../Modal.vue'
import axios from 'axios' import axios from 'axios'
import inputMixin from '~/mixins/forms/input.js' import { inputProps, useFormInput } from './useFormInput.js'
import InputWrapper from './components/InputWrapper.vue'
import Modal from '../Modal.vue'
export default { export default {
name: 'ImageInput', name: 'ImageInput',
components: { InputWrapper, Modal },
mixins: [],
props: {
...inputProps
},
components: { Modal }, setup (props, context) {
mixins: [inputMixin], const {
props: {}, compVal,
inputStyle,
hasValidation,
hasError
} = useFormInput(props, context)
return {
compVal,
inputStyle,
hasValidation,
hasError
}
},
data: () => ({ data: () => ({
showUploadModal: false, showUploadModal: false,