Skip to content

Beautiful Open-Source Form Builder

scale input in vue3

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