UNPKG

@dialpad/dialtone

Version:

Dialpad's Dialtone design system monorepo

121 lines (120 loc) 3.14 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const Vue = require("vue"); const _pluginVue2_normalizer = require("../../_virtual/_plugin-vue2_normalizer.cjs"); const input_group = require("../input_group/input_group.vue.cjs"); const _sfc_main = { name: "DtCheckboxGroup", extends: input_group.default, model: { prop: "selectedValues" }, props: { /** * Not supported by this component, please use selectedValues */ value: { type: [], default: null, validator: (value) => { if (!value) { return true; } Vue.util.warn( "Component uses selectedValues to initialize the model, value is not supported by this component", void 0 ); return false; } }, /** * A provided list of selected values(s) for the checkbox group * @model selectedValues */ selectedValues: { type: Array, default() { return []; } }, /** * A data qa tag for the radio group */ dataQaGroup: { type: String, default: "checkbox-group" }, /** * A data qa tag for the radio group legend */ dataQaGroupLegend: { type: String, default: "checkbox-group-legend" }, /** * A data qa tag for the radio group messages */ dataQaGroupMessages: { type: String, default: "checkbox-group-messages" } }, emits: [ /** * Native input event * * @event input * @type {Array} */ "input" ], data() { return { internalValue: this.selectedValues, // wrap values in object to make reactive provideObj: { selectedValues: this.selectedValues } }; }, watch: { selectedValues(newSelectedValues) { this.internalValue = newSelectedValues; }, /* * watching value to support 2 way binding for slotted checkboxes. * need this to pass value to slotted checkboxes if modified outside * checkbox group. */ internalValue(newInternalValue) { this.provideObj.selectedValues = newInternalValue; } }, methods: { /* * provided value to support 2 way binding for slotted checkboxes. * slotted checkbox will change this value and need to emit new value up. */ setGroupValue(value, checked) { if (!checked) { this.internalValue = this.internalValue.filter((checkedValue) => checkedValue !== value); } else if (!this.internalValue.includes(value)) { this.internalValue.push(value); } this.$emit("input", this.internalValue); }, getMessageKey(type, index) { return `checkbox-group-message-${type}-${index}-${this.id}`; } } }; const _sfc_render = null; const _sfc_staticRenderFns = null; var __component__ = /* @__PURE__ */ _pluginVue2_normalizer.default( _sfc_main, _sfc_render, _sfc_staticRenderFns ); const checkbox_group = __component__.exports; exports.default = checkbox_group; //# sourceMappingURL=checkbox_group.vue.cjs.map