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gBApCO,sBAoCC;AAAA;;AACN,gBAAI,KAAK,UAAT,EAAqB;AAErB,gBAAM,QAAQ,KAAK,KAAnB;AACA,gBAAI,QAAQ,KAAK,aAAjB;AAEA,gBAAI,KAAK,UAAT,EAAqB;AACnB,oBAAI,CAAC,MAAM,OAAN,CAAc,KAAd,CAAL,EAA2B;AACzB,4BAAQ,EAAR;AACD;AAED,oBAAM,SAAS,MAAM,MAArB;AAEA,wBAAQ,MAAM,MAAN,CAAa;AAAA,2BAAQ,CAAC,OAAK,eAAL,CAAqB,IAArB,EAA2B,KAA3B,CAAT;AAAA,iBAAb,CAAR;AAEA,oBAAI,MAAM,MAAN,KAAiB,MAArB,EAA6B;AAC3B,0BAAM,IAAN,CAAW,KAAX;AACD;AACF,aAZD,MAYO,IAAI,KAAK,SAAL,KAAmB,SAAnB,IAAgC,KAAK,UAAL,KAAoB,SAAxD,EAAmE;AACxE,wBAAQ,KAAK,eAAL,CAAqB,KAArB,EAA4B,KAAK,SAAjC,IAA8C,KAAK,UAAnD,GAAgE,KAAK,SAA7E;AACD,aAFM,MAEA,IAAI,KAAJ,EAAW;AAChB,wBAAQ,KAAK,eAAL,CAAqB,KAArB,EAA4B,KAA5B,IAAqC,IAArC,GAA4C,KAApD;AACD,aAFM,MAEA;AACL,wBAAQ,CAAC,KAAT;AACD;AAED,iBAAK,QAAL,CAAc,IAAd,EAAoB,KAApB;AACA,iBAAK,aAAL,GAAqB,KAArB;AACD,SAhEM;AAiEP,eAjEO,qBAiEA;AACL,iBAAK,SAAL,GAAiB,IAAjB;AACD,SAnEM;;AAoEP;AACA,iBArEO,qBAqEI,CArEJ,EAqEK,CAAI;AArET;AAlEkB,CAAd,CAAf","sourcesContent":["// Components\nimport VInput from '../components/VInput'\n\n// Mixins\nimport Rippleable from './rippleable'\nimport Comparable from './comparable'\n\n/* @vue/component */\nexport default VInput.extend({\n name: 'selectable',\n\n mixins: [Rippleable, Comparable],\n\n model: {\n prop: 'inputValue',\n event: 'change'\n },\n\n props: {\n color: {\n type: String,\n default: 'accent'\n },\n id: String,\n inputValue: null,\n falseValue: null,\n trueValue: null,\n multiple: {\n type: Boolean,\n default: null\n },\n label: String\n },\n\n data: vm => ({\n lazyValue: vm.inputValue\n }),\n\n computed: {\n computedColor () {\n return this.isActive ? this.color : this.validationState\n },\n isMultiple () {\n return this.multiple === true || (this.multiple === null && Array.isArray(this.internalValue))\n },\n isActive () {\n const value = this.value\n const input = this.internalValue\n\n if (this.isMultiple) {\n if (!Array.isArray(input)) return false\n\n return input.some(item => this.valueComparator(item, value))\n }\n\n if (this.trueValue === undefined || this.falseValue === undefined) {\n return value\n ? this.valueComparator(value, input)\n : Boolean(input)\n }\n\n return this.valueComparator(input, this.trueValue)\n },\n isDirty () {\n return this.isActive\n }\n },\n\n watch: {\n inputValue (val) {\n this.lazyValue = val\n }\n },\n\n methods: {\n genLabel () {\n if (!this.hasLabel) return null\n\n const label = VInput.options.methods.genLabel.call(this)\n\n label.data.on = { click: this.onChange }\n\n return label\n },\n genInput (type, attrs) {\n return this.$createElement('input', {\n attrs: Object.assign({\n 'aria-label': this.label,\n 'aria-checked': this.isActive.toString(),\n disabled: this.isDisabled,\n id: this.id,\n role: type,\n type\n }, attrs),\n domProps: {\n value: this.value,\n checked: this.isActive\n },\n on: {\n blur: this.onBlur,\n change: this.onChange,\n focus: this.onFocus,\n keydown: this.onKeydown\n },\n ref: 'input'\n })\n },\n onBlur () {\n this.isFocused = false\n },\n onChange () {\n if (this.isDisabled) return\n\n const value = this.value\n let input = this.internalValue\n\n if (this.isMultiple) {\n if (!Array.isArray(input)) {\n input = []\n }\n\n const length = input.length\n\n input = input.filter(item => !this.valueComparator(item, value))\n\n if (input.length === length) {\n input.push(value)\n }\n } else if (this.trueValue !== undefined && this.falseValue !== undefined) {\n input = this.valueComparator(input, this.trueValue) ? this.falseValue : this.trueValue\n } else if (value) {\n input = this.valueComparator(input, value) ? null : value\n } else {\n input = !input\n }\n\n this.validate(true, input)\n this.internalValue = input\n },\n onFocus () {\n this.isFocused = true\n },\n /** @abstract */\n onKeydown (e) {}\n }\n})\n"],"sourceRoot":""}
|