{"version":3,"file":"use-stops.mjs","names":[],"sources":["../../../../../../../packages/components/slider/src/composables/use-stops.ts"],"sourcesContent":["import { computed } from 'vue'\nimport { debugWarn } from '@element-plus/utils'\n\nimport type { CSSProperties, ComputedRef } from 'vue'\nimport type { SliderInitData, SliderProps } from '../slider'\n\ntype Stops = {\n  stops: ComputedRef<number[]>\n  getStopStyle: (position: number) => CSSProperties\n}\n\nexport const useStops = (\n  props: SliderProps,\n  initData: SliderInitData,\n  minValue: ComputedRef<number>,\n  maxValue: ComputedRef<number>\n): Stops => {\n  const stops = computed(() => {\n    if (!props.showStops || props.min > props.max) return []\n    if (props.step === 'mark' || props.step === 0) {\n      if (props.step === 0) debugWarn('ElSlider', 'step should not be 0.')\n      return []\n    }\n\n    const stopCount = Math.ceil((props.max - props.min) / props.step)\n    const stepWidth = (100 * props.step) / (props.max - props.min)\n    const result = Array.from<number>({ 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"],"mappings":";;;;AAWA,MAAa,YACX,OACA,UACA,UACA,aACU;CACV,MAAM,QAAQ,eAAe;AAC3B,MAAI,CAAC,MAAM,aAAa,MAAM,MAAM,MAAM,IAAK,QAAO,EAAE;AACxD,MAAI,MAAM,SAAS,UAAU,MAAM,SAAS,GAAG;AAC7C,OAAI,MAAM,SAAS,EAAG,WAAU,YAAY,wBAAwB;AACpE,UAAO,EAAE;;EAGX,MAAM,YAAY,KAAK,MAAM,MAAM,MAAM,MAAM,OAAO,MAAM,KAAK;EACjE,MAAM,YAAa,MAAM,MAAM,QAAS,MAAM,MAAM,MAAM;EAC1D,MAAM,SAAS,MAAM,KAAa,EAAE,QAAQ,YAAY,GAAG,CAAC,CAAC,KAC1D,GAAG,WAAW,QAAQ,KAAK,UAC7B;AAED,MAAI,MAAM,MACR,QAAO,OAAO,QAAQ,SAAS;AAC7B,UACE,OACG,OAAO,SAAS,QAAQ,MAAM,QAAS,MAAM,MAAM,MAAM,QAC5D,OAAQ,OAAO,SAAS,QAAQ,MAAM,QAAS,MAAM,MAAM,MAAM;IAEnE;MAEF,QAAO,OAAO,QACX,SACC,OACC,OAAO,SAAS,aAAa,MAAM,QAAS,MAAM,MAAM,MAAM,KAClE;GAEH;CAEF,MAAM,gBAAgB,aAAoC;AACxD,SAAO,MAAM,WACT,EAAE,QAAQ,GAAG,SAAS,IAAI,GAC1B,EAAE,MAAM,GAAG,SAAS,IAAI;;AAG9B,QAAO;EACL;EACA;EACD"}