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AZD,MAYO,IAAI,KAAK,SAAL,KAAmB,SAAnB,IAAgC,KAAK,UAAL,KAAoB,SAAxD,EAAmE;AACxE,QAAA,KAAK,GAAG,KAAK,eAAL,CAAqB,KAArB,EAA4B,KAAK,SAAjC,IAA8C,KAAK,UAAnD,GAAgE,KAAK,SAA7E;AACD,OAFM,MAEA,IAAI,KAAJ,EAAW;AAChB,QAAA,KAAK,GAAG,KAAK,eAAL,CAAqB,KAArB,EAA4B,KAA5B,IAAqC,IAArC,GAA4C,KAApD;AACD,OAFM,MAEA;AACL,QAAA,KAAK,GAAG,CAAC,KAAT;AACD;;AAED,WAAK,QAAL,CAAc,IAAd,EAAoB,KAApB;AACA,WAAK,aAAL,GAAqB,KAArB;AACA,WAAK,QAAL,GAAgB,KAAhB;AACD,KAzEM;AA0EP,IAAA,OA1EO,qBA0EA;AACL,WAAK,SAAL,GAAiB,IAAjB;AACD,KA5EM;;AA6EP;AACA,IAAA,SA9EO,qBA8EI,CA9EJ,EA8EY,CAAI;AA9EhB;AAnEF,CAJM,C","sourcesContent":["// Components\nimport VInput from '../../components/VInput'\n\n// Mixins\nimport Rippleable from '../rippleable'\nimport Comparable from '../comparable'\n\n// Utilities\nimport mixins from '../../util/mixins'\n\n/* @vue/component */\nexport default mixins(\n VInput,\n Rippleable,\n Comparable\n).extend({\n name: 'selectable',\n\n model: {\n prop: 'inputValue',\n event: 'change',\n },\n\n props: {\n id: String,\n inputValue: null as any,\n falseValue: null as any,\n trueValue: null as any,\n multiple: {\n type: Boolean,\n default: null,\n },\n label: String,\n },\n\n data () {\n return {\n hasColor: this.inputValue,\n lazyValue: this.inputValue,\n }\n },\n\n computed: {\n computedColor (): string | undefined {\n if (!this.isActive) return undefined\n if (this.color) return this.color\n if (this.isDark && !this.appIsDark) return 'white'\n return 'accent'\n },\n isMultiple (): boolean {\n return this.multiple === true || (this.multiple === null && Array.isArray(this.internalValue))\n },\n isActive (): boolean {\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 (): boolean {\n return this.isActive\n },\n },\n\n watch: {\n inputValue (val) {\n this.lazyValue = val\n this.hasColor = val\n },\n },\n\n methods: {\n genLabel () {\n const label = VInput.options.methods.genLabel.call(this)\n\n if (!label) return label\n\n label!.data!.on = {\n click: (e: Event) => {\n // Prevent label from\n // causing the input\n // to focus\n e.preventDefault()\n\n this.onChange()\n },\n }\n\n return label\n },\n genInput (type: string, attrs: object) {\n return this.$createElement('input', {\n attrs: Object.assign({\n 'aria-checked': this.isActive.toString(),\n disabled: this.isDisabled,\n id: this.computedId,\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: any) => !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 this.hasColor = input\n },\n onFocus () {\n this.isFocused = true\n },\n /** @abstract */\n onKeydown (e: Event) {},\n },\n})\n"],"sourceRoot":"","file":"index.js"} |