{"version":3,"file":"VItemGroup-CdEpqTeC.js","sources":["../../../node_modules/.pnpm/vuetify@2.7.2_vue@2.7.16/node_modules/vuetify/lib/components/VItemGroup/VItemGroup.js"],"sourcesContent":["// Styles\nimport \"../../../src/components/VItemGroup/VItemGroup.sass\"; // Mixins\n\nimport Comparable from '../../mixins/comparable';\nimport Proxyable from '../../mixins/proxyable';\nimport Themeable from '../../mixins/themeable'; // Utilities\n\nimport mixins from '../../util/mixins';\nimport { consoleWarn } from '../../util/console';\nimport { getSlot } from '../../util/helpers';\nexport const BaseItemGroup = mixins(Comparable, Proxyable, Themeable).extend({\n name: 'base-item-group',\n props: {\n activeClass: {\n type: String,\n default: 'v-item--active'\n },\n mandatory: Boolean,\n max: {\n type: [Number, String],\n default: null\n },\n multiple: Boolean,\n tag: {\n type: String,\n default: 'div'\n }\n },\n\n data() {\n return {\n // As long as a value is defined, show it\n // Otherwise, check if multiple\n // to determine which default to provide\n internalLazyValue: this.value !== undefined ? this.value : this.multiple ? [] : undefined,\n items: []\n };\n },\n\n computed: {\n classes() {\n return {\n 'v-item-group': true,\n ...this.themeClasses\n };\n },\n\n selectedIndex() {\n return this.selectedItem && this.items.indexOf(this.selectedItem) || -1;\n },\n\n selectedItem() {\n if (this.multiple) return undefined;\n return this.selectedItems[0];\n },\n\n selectedItems() {\n return this.items.filter((item, index) => {\n return this.toggleMethod(this.getValue(item, index));\n });\n },\n\n selectedValues() {\n if (this.internalValue == null) return [];\n return Array.isArray(this.internalValue) ? this.internalValue : [this.internalValue];\n },\n\n toggleMethod() {\n if (!this.multiple) {\n return v => this.valueComparator(this.internalValue, v);\n }\n\n const internalValue = this.internalValue;\n\n if (Array.isArray(internalValue)) {\n return v => internalValue.some(intern => this.valueComparator(intern, v));\n }\n\n return () => false;\n }\n\n },\n watch: {\n internalValue: 'updateItemsState',\n items: 'updateItemsState'\n },\n\n created() {\n if (this.multiple && !Array.isArray(this.internalValue)) {\n consoleWarn('Model must be bound to an array if the multiple property is true.', this);\n }\n },\n\n methods: {\n genData() {\n return {\n class: this.classes\n };\n },\n\n getValue(item, i) {\n return item.value === undefined ? i : item.value;\n },\n\n onClick(item) {\n this.updateInternalValue(this.getValue(item, this.items.indexOf(item)));\n },\n\n register(item) {\n const index = this.items.push(item) - 1;\n item.$on('change', () => this.onClick(item)); // If no value provided and mandatory,\n // assign first registered item\n\n if (this.mandatory && !this.selectedValues.length) {\n this.updateMandatory();\n }\n\n this.updateItem(item, index);\n },\n\n unregister(item) {\n if (this._isDestroyed) return;\n const index = this.items.indexOf(item);\n const value = this.getValue(item, index);\n this.items.splice(index, 1);\n const valueIndex = this.selectedValues.indexOf(value); // Items is not selected, do nothing\n\n if (valueIndex < 0) return; // If not mandatory, use regular update process\n\n if (!this.mandatory) {\n return this.updateInternalValue(value);\n } // Remove the value\n\n\n if (this.multiple && Array.isArray(this.internalValue)) {\n this.internalValue = this.internalValue.filter(v => v !== value);\n } else {\n this.internalValue = undefined;\n } // If mandatory and we have no selection\n // add the last item as value\n\n /* istanbul ignore else */\n\n\n if (!this.selectedItems.length) {\n this.updateMandatory(true);\n }\n },\n\n updateItem(item, index) {\n const value = this.getValue(item, index);\n item.isActive = this.toggleMethod(value);\n },\n\n // https://github.com/vuetifyjs/vuetify/issues/5352\n updateItemsState() {\n this.$nextTick(() => {\n if (this.mandatory && !this.selectedItems.length) {\n return this.updateMandatory();\n } // TODO: Make this smarter so it\n // doesn't have to iterate every\n // child in an update\n\n\n this.items.forEach(this.updateItem);\n });\n },\n\n updateInternalValue(value) {\n this.multiple ? this.updateMultiple(value) : this.updateSingle(value);\n },\n\n updateMandatory(last) {\n if (!this.items.length) return;\n const items = this.items.slice();\n if (last) items.reverse();\n const item = items.find(item => !item.disabled); // If no tabs are available\n // aborts mandatory value\n\n if (!item) return;\n const index = this.items.indexOf(item);\n this.updateInternalValue(this.getValue(item, index));\n },\n\n updateMultiple(value) {\n const defaultValue = Array.isArray(this.internalValue) ? this.internalValue : [];\n const internalValue = defaultValue.slice();\n const index = internalValue.findIndex(val => this.valueComparator(val, value));\n if (this.mandatory && // Item already exists\n index > -1 && // value would be reduced below min\n internalValue.length - 1 < 1) return;\n if ( // Max is set\n this.max != null && // Item doesn't exist\n index < 0 && // value would be increased above max\n internalValue.length + 1 > this.max) return;\n index > -1 ? internalValue.splice(index, 1) : internalValue.push(value);\n this.internalValue = internalValue;\n },\n\n updateSingle(value) {\n const isSame = this.valueComparator(this.internalValue, value);\n if (this.mandatory && isSame) return;\n this.internalValue = isSame ? undefined : value;\n }\n\n },\n\n render(h) {\n return h(this.tag, this.genData(), getSlot(this));\n }\n\n});\nexport default BaseItemGroup.extend({\n name: 'v-item-group',\n\n provide() {\n return {\n itemGroup: this\n };\n }\n\n});\n//# sourceMappingURL=VItemGroup.js.map"],"names":["BaseItemGroup","mixins","Comparable","Proxyable","Themeable","__spreadValues","item","index","v","internalValue","intern","consoleWarn","i","value","last","items","val","isSame","h","getSlot","__unplugin_components_0"],"mappings":"m3BAUY,MAACA,EAAgBC,EAAOC,EAAYC,EAAWC,CAAS,EAAE,OAAO,CAC3E,KAAM,kBACN,MAAO,CACL,YAAa,CACX,KAAM,OACN,QAAS,gBACV,EACD,UAAW,QACX,IAAK,CACH,KAAM,CAAC,OAAQ,MAAM,EACrB,QAAS,IACV,EACD,SAAU,QACV,IAAK,CACH,KAAM,OACN,QAAS,KACf,CACG,EAED,MAAO,CACL,MAAO,CAIL,kBAAmB,KAAK,QAAU,OAAY,KAAK,MAAQ,KAAK,SAAW,CAAA,EAAK,OAChF,MAAO,CAAA,CACR,CACF,EAED,SAAU,CACR,SAAU,CACR,OAAOC,EAAA,CACL,eAAgB,IACb,KAAK,aAEX,EAED,eAAgB,CACd,OAAO,KAAK,cAAgB,KAAK,MAAM,QAAQ,KAAK,YAAY,GAAK,EACtE,EAED,cAAe,CACb,GAAI,MAAK,SACT,OAAO,KAAK,cAAc,CAAC,CAC5B,EAED,eAAgB,CACd,OAAO,KAAK,MAAM,OAAO,CAACC,EAAMC,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