You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
4.6 KiB
1 lines
4.6 KiB
{"ast":null,"code":"import { computed } from 'vue';\nimport { debugWarn } from '../../../../utils/error.mjs';\nconst useStops = (props, initData, minValue, maxValue) => {\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 const stopCount = (props.max - props.min) / props.step;\n const stepWidth = 100 * props.step / (props.max - props.min);\n const result = Array.from({\n length: stopCount - 1\n }).map((_, index) => (index + 1) * stepWidth);\n if (props.range) {\n return result.filter(step => {\n return step < 100 * (minValue.value - props.min) / (props.max - props.min) || step > 100 * (maxValue.value - props.min) / (props.max - props.min);\n });\n } else {\n return result.filter(step => step > 100 * (initData.firstValue - props.min) / (props.max - props.min));\n }\n });\n const getStopStyle = position => {\n return props.vertical ? {\n bottom: `${position}%`\n } : {\n left: `${position}%`\n };\n };\n return {\n stops,\n getStopStyle\n };\n};\nexport { useStops };","map":{"version":3,"names":["useStops","props","initData","minValue","maxValue","stops","computed","showStops","min","max","step","debugWarn","stopCount","stepWidth","result","Array","from","length","map","_","index","range","filter","value","firstValue","getStopStyle","position","vertical","bottom","left"],"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<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 === 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<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":";;AAEY,MAACA,QAAQ,GAAGA,CAACC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,QAAQ,KAAK;EAC/D,MAAMC,KAAK,GAAGC,QAAQ,CAAC,MAAM;IAC3B,IAAI,CAACL,KAAK,CAACM,SAAS,IAAIN,KAAK,CAACO,GAAG,GAAGP,KAAK,CAACQ,GAAG,EAC3C,OAAO,EAAE;IACX,IAAIR,KAAK,CAACS,IAAI,KAAK,CAAC,EAAE;MACpBC,SAAS,CAAC,UAAU,EAAE,uBAAuB,CAAC;MAC9C,OAAO,EAAE;IACf;IACI,MAAMC,SAAS,GAAG,CAACX,KAAK,CAACQ,GAAG,GAAGR,KAAK,CAACO,GAAG,IAAIP,KAAK,CAACS,IAAI;IACtD,MAAMG,SAAS,GAAG,GAAG,GAAGZ,KAAK,CAACS,IAAI,IAAIT,KAAK,CAACQ,GAAG,GAAGR,KAAK,CAACO,GAAG,CAAC;IAC5D,MAAMM,MAAM,GAAGC,KAAK,CAACC,IAAI,CAAC;MAAEC,MAAM,EAAEL,SAAS,GAAG;IAAC,CAAE,CAAC,CAACM,GAAG,CAAC,CAACC,CAAC,EAAEC,KAAK,KAAK,CAACA,KAAK,GAAG,CAAC,IAAIP,SAAS,CAAC;IAC/F,IAAIZ,KAAK,CAACoB,KAAK,EAAE;MACf,OAAOP,MAAM,CAACQ,MAAM,CAA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