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AmB;AAEnB,WAAK,gBAAL,CAAsB,KAAtB;AACA,WAAK,KAAL,CAAW,QAAX,EAAqB,KAArB;AACD,KA7HM;;AA8HP,IAAA,gBAAgB,CAAE,KAAF,EAAe;AAC7B,WAAK,aAAL,GAAqB,KAAK,aAAL,CAAmB,GAAnB,CAAuB,CAAC,CAAD,EAAY,CAAZ,KAAyB;AACnE,YAAI,CAAC,KAAK,KAAK,WAAf,EAA4B,OAAO,KAAP,CAA5B,KACK,OAAO,MAAM,CAAC,CAAD,CAAb;AACN,OAHoB,CAArB;AAID;;AAnIM;AApEmB,CAAf,CAAf","sourcesContent":["// Styles\nimport './VRangeSlider.sass'\n\n// Components\nimport VSlider from '../VSlider'\n\n// Helpers\nimport {\n createRange,\n deepEqual,\n} from '../../util/helpers'\n\n// Types\nimport { PropValidator } from 'vue/types/options'\n\n/* @vue/component */\nexport default VSlider.extend({\n name: 'v-range-slider',\n\n props: {\n value: {\n type: Array,\n default: () => ([0, 0]),\n } as PropValidator<number[]>,\n },\n\n data () {\n return {\n activeThumb: null as null | number,\n lazyValue: this.value,\n }\n },\n\n computed: {\n classes (): object {\n return {\n ...VSlider.options.computed.classes.call(this),\n 'v-input--range-slider': true,\n }\n },\n internalValue: {\n get (): number[] {\n return this.lazyValue\n },\n set (val: number[]) {\n // Round value to ensure the\n // entire slider range can\n // be selected with step\n let value = val.map(v => this.roundValue(Math.min(Math.max(v, this.minValue), this.maxValue)))\n\n // Switch values if range and wrong order\n if (value[0] > value[1] || value[1] < value[0]) {\n if (this.activeThumb !== null) {\n const toFocus = this.activeThumb === 1 ? 0 : 1\n const el = this.$refs[`thumb_${toFocus}`] as HTMLElement\n el.focus()\n }\n value = [value[1], value[0]]\n }\n\n this.lazyValue = value\n if (!deepEqual(value, this.value)) this.$emit('input', value)\n\n this.validate()\n },\n },\n inputWidth (): number[] {\n return this.internalValue.map((v: number) => (\n this.roundValue(v) - this.minValue) / (this.maxValue - this.minValue) * 100\n )\n },\n trackFillStyles (): Partial<CSSStyleDeclaration> {\n const styles = VSlider.options.computed.trackFillStyles.call(this)\n const fillPercent = Math.abs(this.inputWidth[0] - this.inputWidth[1])\n const dir = this.vertical ? 'height' : 'width'\n const start = this.vertical ? this.$vuetify.rtl ? 'top' : 'bottom' : this.$vuetify.rtl ? 'right' : 'left'\n\n styles[dir] = `${fillPercent}%`\n styles[start] = `${this.inputWidth[0]}%`\n\n return styles\n },\n },\n\n methods: {\n getTrackStyle (startLength: number, endLength: number, startPadding = 0, endPadding = 0) {\n const startDir = this.vertical ? this.$vuetify.rtl ? 'top' : 'bottom' : this.$vuetify.rtl ? 'right' : 'left'\n const endDir = this.vertical ? 'height' : 'width'\n\n const start = `calc(${startLength}% + ${startPadding}px)`\n const end = `calc(${endLength}% + ${endPadding}px)`\n\n return {\n transition: this.trackTransition,\n [startDir]: start,\n [endDir]: end,\n }\n },\n getIndexOfClosestValue (arr: number[], v: number) {\n if (Math.abs(arr[0] - v) < Math.abs(arr[1] - v)) return 0\n else return 1\n },\n genInput () {\n return createRange(2).map(i => {\n const input = VSlider.options.methods.genInput.call(this)\n\n input.data = input.data || {}\n input.data.attrs = input.data.attrs || {}\n input.data.attrs.value = this.internalValue[i]\n\n return input\n })\n },\n genTrackContainer () {\n const children = []\n\n if (this.disabled) {\n const disabledPadding = 10\n const sections: [number, number, number, number][] = [\n [0, this.inputWidth[0], 0, -disabledPadding],\n [this.inputWidth[0], Math.abs(this.inputWidth[1] - this.inputWidth[0]), disabledPadding, disabledPadding * -2],\n [this.inputWidth[1], Math.abs(100 - this.inputWidth[1]), disabledPadding, 0],\n ]\n\n if (this.$vuetify.rtl) sections.reverse()\n\n children.push(...sections.map(section => this.$createElement('div', this.setBackgroundColor(this.computedTrackColor, {\n staticClass: 'v-slider__track-background',\n style: this.getTrackStyle(...section),\n }))))\n } else {\n children.push(\n this.$createElement('div', this.setBackgroundColor(this.computedTrackColor, {\n staticClass: 'v-slider__track-background',\n style: this.getTrackStyle(0, 100),\n })),\n this.$createElement('div', this.setBackgroundColor(this.computedColor, {\n staticClass: 'v-slider__track-fill',\n style: this.trackFillStyles,\n }))\n )\n }\n\n return this.$createElement('div', {\n staticClass: 'v-slider__track-container',\n ref: 'track',\n }, children)\n },\n genChildren () {\n return [\n this.genInput(),\n this.genTrackContainer(),\n this.genSteps(),\n createRange(2).map(index => {\n const value = this.internalValue[index]\n const onDrag = (e: MouseEvent) => {\n this.isActive = true\n this.activeThumb = index\n this.onThumbMouseDown(e)\n }\n const onFocus = (e: Event) => {\n this.isFocused = true\n this.activeThumb = index\n }\n\n const valueWidth = this.inputWidth[index]\n const isActive = this.isActive && this.activeThumb === index\n const isFocused = this.isFocused && this.activeThumb === index\n\n return this.genThumbContainer(value, valueWidth, isActive, isFocused, onDrag, onFocus, `thumb_${index}`)\n }),\n ]\n },\n onFocus (index: number) {\n this.isFocused = true\n this.activeThumb = index\n },\n onBlur () {\n this.isFocused = false\n this.activeThumb = null\n },\n onSliderClick (e: MouseEvent) {\n if (!this.isActive) {\n // It doesn't seem to matter if we focus on the wrong thumb here\n const thumb = this.$refs.thumb_1 as HTMLElement\n thumb.focus()\n\n this.onMouseMove(e, true)\n this.$emit('change', this.internalValue)\n }\n },\n onMouseMove (e: MouseEvent, trackClick = false) {\n const { value, isInsideTrack } = this.parseMouseMove(e)\n\n if (isInsideTrack) {\n if (trackClick) this.activeThumb = this.getIndexOfClosestValue(this.internalValue, value)\n }\n\n this.setInternalValue(value)\n },\n onKeyDown (e: KeyboardEvent) {\n if (this.activeThumb === null) return\n\n const value = this.parseKeyDown(e, this.internalValue[this.activeThumb])\n\n if (value == null) return\n\n this.setInternalValue(value)\n this.$emit('change', value)\n },\n setInternalValue (value: number) {\n this.internalValue = this.internalValue.map((v: number, i: number) => {\n if (i === this.activeThumb) return value\n else return Number(v)\n })\n },\n },\n})\n"],"sourceRoot":"","file":"VRangeSlider.js"} |