UNPKG

@dialpad/dialtone

Version:

Dialpad's Dialtone design system monorepo

221 lines (220 loc) 4.07 kB
import { VALIDATION_MESSAGE_TYPES as e } from "../constants/index.js"; import { validationMessageValidator as t } from "../validators/index.js"; import { formatMessages as n } from "../utils/index.js"; import { warn as r } from "vue"; //#region common/mixins/input.js var i = { inheritAttrs: !1, props: { label: { type: String, default: "" }, name: { type: String, default: "" }, value: { type: [ String, Number, Boolean, Object ], default: null }, description: { type: String, default: "" }, disabled: { type: Boolean, default: !1 }, validationState: { type: String, default: "", validator: (t) => t ? Object.values(e).includes(t) : !0 }, inputClass: { type: [ String, Array, Object ], default: "" }, labelClass: { type: [ String, Array, Object ], default: "" }, descriptionClass: { type: [ String, Array, Object ], default: "" }, labelChildProps: { type: Object, default: () => ({}) }, descriptionChildProps: { type: Object, default: () => ({}) }, rootClass: { type: [ String, Object, Array ], default: "" } }, data() { return { internalDisabled: this.disabled, internalValidationState: this.validationState }; }, watch: { disabled(e) { this.internalDisabled = e; }, validationState(e) { this.internalValidationState = e; } }, methods: { validateInputLabels(e, t) { !e && !t && r("You must provide an aria-label when there is no label passed", this); } } }, a = { props: { modelValue: { type: Boolean, default: !1 }, indeterminate: { type: Boolean, default: !1 }, value: { type: [ String, Number, Boolean ], default: null } }, data() { return { internalChecked: this.modelValue, internalIndeterminate: this.indeterminate }; }, watch: { modelValue(e) { this.internalChecked = e; }, indeterminate(e) { this.internalIndeterminate = e; } } }, o = { inject: { groupContext: { default: {} }, setGroupValue: { default: () => () => {} } }, data() { return { internalValue: this.value }; }, computed: { hasGroup() { return Object.prototype.hasOwnProperty.call(this.groupContext, "name"); }, groupName() { return this.groupContext?.name ?? ""; }, groupValue() { return this.groupContext?.value; }, groupDisabled() { return this.groupContext?.disabled ?? !1; }, groupValidationState() { return this.groupContext?.validationState ?? null; }, internalName() { return this.name || this.groupName; } }, watch: { value(e) { this.internalValue = e; }, groupValue: { immediate: !0, handler(e) { this.hasGroup && (this.internalValue = e); } }, groupDisabled: { immediate: !0, handler(e) { this.hasGroup && (this.internalDisabled = this.disabled || e); } }, groupValidationState: { immediate: !0, handler(e) { this.hasGroup && (this.internalValidationState = e || this.validationState); } } }, created() { let e = Object.prototype.hasOwnProperty.call(this.groupContext, "name"), t = this.groupContext?.name; this.name && e && t !== this.name && r(`Component is being used inside a Group. Did you mean to override the name prop value (${t}) with (${this.name})? It is recommended to only set name at the Group level.`, this); } }, s = { props: { messagesClass: { type: [ String, Array, Object ], default: "" }, messagesChildProps: { type: Object, default: () => ({}) }, showMessages: { type: Boolean, default: !0 }, messages: { type: Array, default: () => [], validator: (e) => t(e) } }, computed: { formattedMessages() { return n(this.messages); } } }, c = { InputMixin: i, CheckableMixin: a, GroupableMixin: o, MessagesMixin: s }; //#endregion export { a as CheckableMixin, o as GroupableMixin, i as InputMixin, s as MessagesMixin, c as default }; //# sourceMappingURL=input.js.map