@dialpad/dialtone
Version:
Dialpad's Dialtone design system monorepo
111 lines (110 loc) • 2.08 kB
JavaScript
import { validationMessageValidator as e } from "../validators/index.js";
import { formatMessages as t, getUniqueString as n, getValidationState as r } from "../utils/index.js";
import i from "../../lib/validation-messages/validation-messages.js";
import { warn as a } from "vue";
//#region common/mixins/input_group.js
var o = {
components: { DtValidationMessages: i },
provide() {
return {
groupContext: this.provideObj,
setGroupValue: this.setGroupValue
};
},
props: {
id: {
type: String,
default() {
return n();
}
},
value: {
type: [
String,
Number,
Boolean,
Object
],
default: null
},
name: {
type: String,
required: !0
},
legend: {
type: String,
default: ""
},
disabled: {
type: Boolean,
default: !1
},
messages: {
type: Array,
default: () => [],
validator: (t) => e(t)
},
showMessages: {
type: Boolean,
default: !0
},
legendClass: {
type: [
String,
Array,
Object
],
default: ""
},
messagesClass: {
type: [
String,
Array,
Object
],
default: ""
},
legendChildProps: {
type: Object,
default: () => ({})
},
messagesChildProps: {
type: Object,
default: () => ({})
}
},
emits: ["input"],
data() {
let e = t(this.messages);
return { provideObj: {
name: this.name,
disabled: this.disabled,
validationState: r(e)
} };
},
computed: {
formattedMessages() {
return t(this.messages);
},
validationState() {
return r(this.formattedMessages);
}
},
watch: {
disabled(e) {
this.provideObj.disabled = e;
},
validationState(e) {
this.provideObj.validationState = e;
}
},
methods: { setGroupValue(e) {
this.internalValue = e, this.$emit("input", e);
} },
mounted() {
!this.legend && !this.$slots.legend && !this.$attrs["aria-label"] && a("It is expected that an aria-label is provided when there is no legend.", this);
}
}, s = { InputGroupMixin: o };
//#endregion
export { o as InputGroupMixin, s as default };
//# sourceMappingURL=input-group.js.map