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AAK,gBAAL,CAAsB,KAAtB;AACD,KAnHM;AAoHP,IAAA,SApHO,qBAoHI,CApHJ,EAoHoB;AACzB,UAAI,KAAK,WAAL,KAAqB,IAAzB,EAA+B;AAE/B,UAAM,KAAK,GAAG,KAAK,YAAL,CAAkB,CAAlB,EAAqB,KAAK,aAAL,CAAmB,KAAK,WAAxB,CAArB,CAAd;AAEA,UAAI,KAAK,IAAI,IAAb,EAAmB;AAEnB,WAAK,gBAAL,CAAsB,KAAtB;AACA,WAAK,KAAL,CAAW,QAAX,EAAqB,KAArB;AACD,KA7HM;AA8HP,IAAA,gBA9HO,4BA8HW,KA9HX,EA8HwB;AAAA;;AAC7B,WAAK,aAAL,GAAqB,KAAK,aAAL,CAAmB,GAAnB,CAAuB,UAAC,CAAD,EAAY,CAAZ,EAAyB;AACnE,YAAI,CAAC,KAAK,MAAI,CAAC,WAAf,EAA4B,OAAO,KAAP,CAA5B,KACK,OAAO,MAAM,CAAC,CAAD,CAAb;AACN,OAHoB,CAArB;AAID;AAnIM;AApEmB,CAAf,C","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"} |