|
@@ -6,16 +6,16 @@
|
|
|
v-model="model"
|
|
v-model="model"
|
|
|
v-bind="inputAttrs"
|
|
v-bind="inputAttrs"
|
|
|
hide-bottom-space
|
|
hide-bottom-space
|
|
|
- :label-color
|
|
|
|
|
|
|
+ :bg-color="bgColor"
|
|
|
|
|
+ :class="inputClass"
|
|
|
:color
|
|
:color
|
|
|
- :label
|
|
|
|
|
- :error="!!error"
|
|
|
|
|
|
|
+ :error="!!error || !!errorMessageProp"
|
|
|
:error-message="errorMessage"
|
|
:error-message="errorMessage"
|
|
|
|
|
+ :input-class="nativeInputClass"
|
|
|
|
|
+ :label
|
|
|
|
|
+ :label-color
|
|
|
:rules
|
|
:rules
|
|
|
:outlined
|
|
:outlined
|
|
|
- :bg-color
|
|
|
|
|
- :class="inputClass"
|
|
|
|
|
- :input-class="nativeInputClass"
|
|
|
|
|
@update:model-value="error = null"
|
|
@update:model-value="error = null"
|
|
|
>
|
|
>
|
|
|
<template v-for="(_, slotName) in $slots" #[slotName]>
|
|
<template v-for="(_, slotName) in $slots" #[slotName]>
|
|
@@ -34,55 +34,59 @@
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
import {
|
|
import {
|
|
|
- ref,
|
|
|
|
|
|
|
+ computed,
|
|
|
onBeforeMount,
|
|
onBeforeMount,
|
|
|
|
|
+ ref,
|
|
|
useAttrs,
|
|
useAttrs,
|
|
|
- computed,
|
|
|
|
|
- watch,
|
|
|
|
|
useTemplateRef,
|
|
useTemplateRef,
|
|
|
|
|
+ watch,
|
|
|
} from "vue";
|
|
} from "vue";
|
|
|
|
|
|
|
|
defineOptions({
|
|
defineOptions({
|
|
|
inheritAttrs: false,
|
|
inheritAttrs: false,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-const { label, nativeInputClass, inputClass, rules, icon, bgColor, outlined } =
|
|
|
|
|
|
|
+const { bgColor, errorMessage: errorMessageProp, icon, inputClass, label, labelColor, nativeInputClass, rules, outlined } =
|
|
|
defineProps({
|
|
defineProps({
|
|
|
- label: {
|
|
|
|
|
|
|
+ bgColor: {
|
|
|
type: String,
|
|
type: String,
|
|
|
- default: "",
|
|
|
|
|
|
|
+ default: "white",
|
|
|
},
|
|
},
|
|
|
- icon: {
|
|
|
|
|
|
|
+ color: {
|
|
|
type: String,
|
|
type: String,
|
|
|
- default: "",
|
|
|
|
|
- },
|
|
|
|
|
- rules: {
|
|
|
|
|
- type: Array,
|
|
|
|
|
- default: () => [],
|
|
|
|
|
|
|
+ default: "secondary",
|
|
|
},
|
|
},
|
|
|
- nativeInputClass: {
|
|
|
|
|
|
|
+ errorMessage: {
|
|
|
type: String,
|
|
type: String,
|
|
|
default: null,
|
|
default: null,
|
|
|
},
|
|
},
|
|
|
|
|
+ icon: {
|
|
|
|
|
+ type: String,
|
|
|
|
|
+ default: "",
|
|
|
|
|
+ },
|
|
|
inputClass: {
|
|
inputClass: {
|
|
|
type: String,
|
|
type: String,
|
|
|
default: null,
|
|
default: null,
|
|
|
},
|
|
},
|
|
|
- bgColor: {
|
|
|
|
|
|
|
+ label: {
|
|
|
type: String,
|
|
type: String,
|
|
|
- default: "white",
|
|
|
|
|
- },
|
|
|
|
|
- outlined: {
|
|
|
|
|
- type: Boolean,
|
|
|
|
|
- default: true,
|
|
|
|
|
|
|
+ default: "",
|
|
|
},
|
|
},
|
|
|
labelColor: {
|
|
labelColor: {
|
|
|
type: String,
|
|
type: String,
|
|
|
default: "secondary",
|
|
default: "secondary",
|
|
|
},
|
|
},
|
|
|
- color: {
|
|
|
|
|
|
|
+ nativeInputClass: {
|
|
|
type: String,
|
|
type: String,
|
|
|
- default: "secondary",
|
|
|
|
|
|
|
+ default: null,
|
|
|
|
|
+ },
|
|
|
|
|
+ outlined: {
|
|
|
|
|
+ type: Boolean,
|
|
|
|
|
+ default: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ rules: {
|
|
|
|
|
+ type: Array,
|
|
|
|
|
+ default: () => [],
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -91,6 +95,7 @@ const attrs = useAttrs();
|
|
|
const inputRef = useTemplateRef("inputRef");
|
|
const inputRef = useTemplateRef("inputRef");
|
|
|
|
|
|
|
|
const model = defineModel({ type: [String, Object, Array, Boolean, null] });
|
|
const model = defineModel({ type: [String, Object, Array, Boolean, null] });
|
|
|
|
|
+
|
|
|
const error = defineModel("error", {
|
|
const error = defineModel("error", {
|
|
|
type: [String, Object, Array, Boolean, null],
|
|
type: [String, Object, Array, Boolean, null],
|
|
|
});
|
|
});
|
|
@@ -104,12 +109,18 @@ const inputAttrs = computed(() => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const errorMessage = computed(() => {
|
|
const errorMessage = computed(() => {
|
|
|
|
|
+ if (errorMessageProp != null) {
|
|
|
|
|
+ return errorMessageProp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (error.value == null) {
|
|
if (error.value == null) {
|
|
|
return void 0;
|
|
return void 0;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if (typeof error.value === "boolean") {
|
|
if (typeof error.value === "boolean") {
|
|
|
return void 0;
|
|
return void 0;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return String(error.value);
|
|
return String(error.value);
|
|
|
});
|
|
});
|
|
|
|
|
|