Socket
Socket
Sign inDemoInstall

react-range

Package Overview
Dependencies
6
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.6 to 1.4.7

lib/index.js.flow

6

lib/utils.d.ts
/// <reference types="react" />
import Range from './Range';
import { TThumbOffsets, ITrackBackground, Direction } from './types';
export declare const getStepDecimals: (step: number) => number;
export declare function isTouchEvent(event: TouchEvent & MouseEvent): number;

@@ -26,3 +27,3 @@ export declare function normalizeValue(value: number, index: number, min: number, max: number, step: number, allowOverlap: boolean, values: number[]): number;

export declare function replaceAt(values: number[], index: number, value: number): number[];
export declare function getTrackBackground({ values, colors, min, max, direction, rtl, }: ITrackBackground): string;
export declare function getTrackBackground({ values, colors, min, max, direction, rtl }: ITrackBackground): string;
export declare function voidFn(): void;

@@ -36,5 +37,6 @@ export declare function assertUnreachable(x: never): never;

* @param index - thumb index
* @param step - step value, used to calculate the number of decimal places
* @param separator - string to separate thumb values
* @returns label value + styling for thumb label
*/
export declare const useThumbOverlap: (rangeRef: Range | null, values: number[], index: number, separator?: string) => (string | import("react").CSSProperties)[];
export declare const useThumbOverlap: (rangeRef: Range | null, values: number[], index: number, step?: number, separator?: string) => (string | import("react").CSSProperties)[];

@@ -12,2 +12,6 @@ "use strict";

var types_1 = require("./types");
exports.getStepDecimals = function (step) {
var decimals = step.toString().split('.')[1];
return decimals ? decimals.length : 0;
};
function isTouchEvent(event) {

@@ -34,3 +38,4 @@ return ((event.touches && event.touches.length) ||

var inverter = min < 0 ? -1 : 1;
var remainder = Math.round(value * BIG_NUM - inverter * min * BIG_NUM) % Math.round(step * BIG_NUM);
var remainder = Math.round(value * BIG_NUM - inverter * min * BIG_NUM) %
Math.round(step * BIG_NUM);
var closestBigNum = Math.round(value * BIG_NUM - remainder);

@@ -40,5 +45,5 @@ var rounded = remainder === 0 ? value : closestBigNum / BIG_NUM;

? rounded
: rounded + step * Math.sign(value);
var afterDot = step.toString().split('.')[1];
return afterDot ? parseFloat(res.toFixed(afterDot.length)) : res;
: rounded + step * (((value > 0) ? 1 : 0) + ((value < 0) ? -1 : 0) || +value);
var decimalPlaces = exports.getStepDecimals(step);
return parseFloat(res.toFixed(decimalPlaces));
}

@@ -237,10 +242,13 @@ exports.normalizeValue = normalizeValue;

* @param index - thumb index
* @param step - step value, used to calculate the number of decimal places
* @param separator - string to separate thumb values
* @returns label value + styling for thumb label
*/
exports.useThumbOverlap = function (rangeRef, values, index, separator) {
exports.useThumbOverlap = function (rangeRef, values, index, step, separator) {
if (step === void 0) { step = 0.1; }
if (separator === void 0) { separator = ' - '; }
var decimalPlaces = exports.getStepDecimals(step);
// Create initial label style and value. Label value defaults to thumb value
var _a = react_1.useState({}), labelStyle = _a[0], setLabelStyle = _a[1];
var _b = react_1.useState(values[index].toFixed(1)), labelValue = _b[0], setLabelValue = _b[1];
var _b = react_1.useState(values[index].toFixed(decimalPlaces)), labelValue = _b[0], setLabelValue = _b[1];
// When the rangeRef or values change, update the Thumb label values and styling

@@ -262,3 +270,3 @@ react_1.useEffect(function () {

// Set a default label value of the Thumb value
var labelValue_1 = values[index].toFixed(1);
var labelValue_1 = values[index].toFixed(decimalPlaces);
/**

@@ -291,3 +299,3 @@ * If there are overlaps for the Thumb, we need to calculate the correct

overlaps.forEach(function (thumb) {
labelValues_1.push(values[thumb].toFixed(1));
labelValues_1.push(values[thumb].toFixed(decimalPlaces));
});

@@ -294,0 +302,0 @@ /**

{
"name": "react-range",
"version": "1.4.6",
"version": "1.4.7",
"description": "Range input. Slides in all directions.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc