@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
1 lines • 1.19 kB
Source Map (JSON)
{"version":3,"file":"get-change-value.mjs","names":[],"sources":["../../../../../src/components/Slider/utils/get-change-value/get-change-value.ts"],"sourcesContent":["interface GetChangeValue {\n value: number;\n containerWidth?: number;\n min: number;\n max: number;\n step: number;\n precision?: number;\n}\n\nexport function getChangeValue({\n value,\n containerWidth,\n min,\n max,\n step,\n precision,\n}: GetChangeValue) {\n const left = !containerWidth\n ? value\n : Math.min(Math.max(value, 0), containerWidth) / containerWidth;\n const dx = left * (max - min);\n const nextValue = (dx !== 0 ? Math.round(dx / step) * step : 0) + min;\n\n const nextValueWithinStep = Math.max(nextValue, min);\n\n if (precision !== undefined) {\n return Number(nextValueWithinStep.toFixed(precision));\n }\n\n return nextValueWithinStep;\n}\n"],"mappings":";;AASA,SAAgB,eAAe,EAC7B,OACA,gBACA,KACA,KACA,MACA,aACiB;CAIjB,MAAM,MAHO,CAAC,iBACV,QACA,KAAK,IAAI,KAAK,IAAI,OAAO,EAAE,EAAE,eAAe,GAAG,mBAChC,MAAM;CACzB,MAAM,aAAa,OAAO,IAAI,KAAK,MAAM,KAAK,KAAK,GAAG,OAAO,KAAK;CAElE,MAAM,sBAAsB,KAAK,IAAI,WAAW,IAAI;AAEpD,KAAI,cAAc,KAAA,EAChB,QAAO,OAAO,oBAAoB,QAAQ,UAAU,CAAC;AAGvD,QAAO"}