scale input in vue3

This commit is contained in:
Forms Dev 2023-11-29 09:41:17 +05:30
parent 9d7b8d9f7f
commit af30067eda
1 changed files with 33 additions and 18 deletions

View File

@ -1,14 +1,10 @@
<template> <template>
<div :class="wrapperClass" :style="inputStyle"> <input-wrapper
<label v-if="label" :for="id?id:name" v-bind="$props"
:class="[theme.default.label,{'uppercase text-xs':uppercaseLabels, 'text-sm':!uppercaseLabels}]" >
> <template #label>
{{ label }} <slot name="label" />
<span v-if="required" class="text-red-500 required-dot">*</span> </template>
</label>
<small v-if="help && helpPosition=='above_input'" :class="theme.default.help" class="flex mb-1">
<slot name="help"><span class="field-help" v-html="help" /></slot>
</small>
<div class="rectangle-outer grid grid-cols-5 gap-2"> <div class="rectangle-outer grid grid-cols-5 gap-2">
<div v-for="i in scaleList" :key="i" <div v-for="i in scaleList" :key="i"
@ -20,27 +16,46 @@
</div> </div>
</div> </div>
<small v-if="help && helpPosition=='below_input'" :class="theme.default.help"> <template #help>
<slot name="help"><span class="field-help" v-html="help" /></slot> <slot name="help" />
</small> </template>
<has-error v-if="hasValidation" :form="form" :field="name" /> <template #error>
</div> <slot name="error" />
</template>
</input-wrapper>
</template> </template>
<script> <script>
import inputMixin from '~/mixins/forms/input.js' import { inputProps, useFormInput } from './useFormInput.js'
import InputWrapper from './components/InputWrapper.vue'
export default { export default {
name: 'ScaleInput', name: 'ScaleInput',
components: { InputWrapper },
mixins: [inputMixin],
props: { props: {
...inputProps,
minScale: { type: Number, default: 1 }, minScale: { type: Number, default: 1 },
maxScale: { type: Number, default: 5 }, maxScale: { type: Number, default: 5 },
stepScale: { type: Number, default: 1 } stepScale: { type: Number, default: 1 }
}, },
setup (props, context) {
const {
compVal,
inputStyle,
hasValidation,
hasError
} = useFormInput(props, context)
return {
compVal,
inputStyle,
hasValidation,
hasError
}
},
data () { data () {
return {} return {}
}, },