bootstrap-vue-wrapper
Version:
Bootstrap 5 components in Vue3 wrapper.
101 lines (100 loc) • 1.82 kB
JavaScript
import { useValidator as a } from "@zemkogabor/vue-form-validator";
import { defineComponent as i, ref as o } from "vue";
const n = i({
name: "BsInput",
props: {
/**
* Value for v-model
*/
modelValue: {
type: [String, Number, null],
default: null
},
/**
* Html id
*/
id: {
type: String,
required: !0
},
/**
* Label for input
*/
label: {
type: String,
default: void 0
},
/**
* Attribute hint
*/
hint: {
type: String,
default: void 0
},
/**
* Enable or disable validator
*/
validatorEnabled: {
type: Boolean,
default: !0
},
/**
* Convert empty string to null
*/
emptyStringToNull: {
type: Boolean,
default: !0
},
/**
* Trim input value
*/
trim: {
type: Boolean,
default: !0
},
/**
* Custom validator messages, e.g. minlength validation with custom message
*/
customValidatorMessages: {
type: Object,
default: void 0
}
},
emits: ["update:modelValue"],
setup(t) {
const e = o(null);
return {
inputRef: e,
validator: a(e, t.customValidatorMessages)
};
},
methods: {
/**
* Hint id is generated
*/
getHintId() {
return this.id + "Hint";
},
/**
* On input event
*
* @param event
*/
onInput(t) {
const e = t.target;
let l = e.value;
this.trim && (l = e.value.trim()), this.emptyStringToNull && l === "" && (l = null), this.$emit("update:modelValue", l);
},
/**
* On invalid event
*
* @param event
*/
onInvalid(t) {
this.validatorEnabled && this.validator.onInvalid(t);
}
}
});
export {
n as default
};