{"version":3,"file":"use-stops.js","sources":["../../../../../../../packages/components/slider/src/composables/use-stops.ts"],"sourcesContent":["import { computed } from 'vue'\nimport { debugWarn } from '@element-plus/utils'\nimport type { CSSProperties, ComputedRef } from 'vue'\nimport type { SliderInitData, SliderProps } from '../slider'\n\ntype Stops = {\n stops: ComputedRef\n getStopStyle: (position: number) => CSSProperties\n}\n\nexport const useStops = (\n props: SliderProps,\n initData: SliderInitData,\n minValue: ComputedRef,\n maxValue: ComputedRef\n): Stops => {\n const stops = computed(() => {\n if (!props.showStops || props.min > props.max) return []\n if (props.step === 0) {\n debugWarn('ElSlider', 'step should not be 0.')\n return []\n }\n\n const stopCount = (props.max - props.min) / props.step\n const stepWidth = (100 * props.step) / (props.max - props.min)\n const result = Array.from({ length: stopCount - 1 }).map(\n (_, index) => (index + 1) * stepWidth\n )\n\n if (props.range) {\n return result.filter((step) => {\n return (\n step <\n (100 * (minValue.value - props.min)) / (props.max - props.min) ||\n step > (100 * (maxValue.value - props.min)) / (props.max - props.min)\n )\n })\n } else {\n return result.filter(\n (step) =>\n step >\n (100 * (initData.firstValue - props.min)) / (props.max - props.min)\n )\n }\n })\n\n const getStopStyle = (position: number): CSSProperties => {\n return props.vertical\n ? { bottom: `${position}%` }\n : { left: `${position}%` }\n }\n\n return {\n stops,\n getStopStyle,\n }\n}\n"],"names":["computed","debugWarn"],"mappings":";;;;;;;;AAEY,MAAC,QAAQ,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,KAAK;AACjE,EAAE,MAAM,KAAK,GAAGA,YAAQ,CAAC,MAAM;AAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG;AACjD,MAAM,OAAO,EAAE,CAAC;AAChB,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE;AAC1B,MAAMC,eAAS,CAAC,UAAU,EAAE,uBAAuB,CAAC,CAAC;AACrD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