Socket
Book a DemoInstallSign in
Socket

@react-stately/utils

Package Overview
Dependencies
Maintainers
2
Versions
1120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-stately/utils - npm Package Compare versions

Comparing version

to
3.0.0-nightly-ecb05e28d-250909

10

dist/number.main.js

@@ -27,5 +27,11 @@

let roundedValue = value;
let precision = 0;
let stepString = step.toString();
let pointIndex = stepString.indexOf('.');
let precision = pointIndex >= 0 ? stepString.length - pointIndex : 0;
// Handle negative exponents in exponential notation (e.g., "1e-7" → precision 8)
let eIndex = stepString.toLowerCase().indexOf('e-');
if (eIndex > 0) precision = Math.abs(Math.floor(Math.log10(Math.abs(step)))) + eIndex;
else {
let pointIndex = stepString.indexOf('.');
if (pointIndex >= 0) precision = stepString.length - pointIndex;
}
if (precision > 0) {

@@ -32,0 +38,0 @@ let pow = Math.pow(10, precision);

@@ -19,5 +19,11 @@ /*

let roundedValue = value;
let precision = 0;
let stepString = step.toString();
let pointIndex = stepString.indexOf('.');
let precision = pointIndex >= 0 ? stepString.length - pointIndex : 0;
// Handle negative exponents in exponential notation (e.g., "1e-7" → precision 8)
let eIndex = stepString.toLowerCase().indexOf('e-');
if (eIndex > 0) precision = Math.abs(Math.floor(Math.log10(Math.abs(step)))) + eIndex;
else {
let pointIndex = stepString.indexOf('.');
if (pointIndex >= 0) precision = stepString.length - pointIndex;
}
if (precision > 0) {

@@ -24,0 +30,0 @@ let pow = Math.pow(10, precision);

4

dist/useControlledState.main.js

@@ -26,3 +26,3 @@ var $ecn6s$react = require("react");

let wasControlled = isControlledRef.current;
if (wasControlled !== isControlled) console.warn(`WARN: A component changed from ${wasControlled ? 'controlled' : 'uncontrolled'} to ${isControlled ? 'controlled' : 'uncontrolled'}.`);
if (wasControlled !== isControlled && process.env.NODE_ENV !== 'production') console.warn(`WARN: A component changed from ${wasControlled ? 'controlled' : 'uncontrolled'} to ${isControlled ? 'controlled' : 'uncontrolled'}.`);
isControlledRef.current = isControlled;

@@ -46,3 +46,3 @@ }, [

if (typeof value === 'function') {
console.warn('We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320');
if (process.env.NODE_ENV !== 'production') console.warn('We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320');
// this supports functional updates https://reactjs.org/docs/hooks-reference.html#functional-updates

@@ -49,0 +49,0 @@ // when someone using useControlledState calls setControlledState(myFunc)

@@ -20,3 +20,3 @@ import {useState as $3whtM$useState, useRef as $3whtM$useRef, useEffect as $3whtM$useEffect, useCallback as $3whtM$useCallback} from "react";

let wasControlled = isControlledRef.current;
if (wasControlled !== isControlled) console.warn(`WARN: A component changed from ${wasControlled ? 'controlled' : 'uncontrolled'} to ${isControlled ? 'controlled' : 'uncontrolled'}.`);
if (wasControlled !== isControlled && process.env.NODE_ENV !== 'production') console.warn(`WARN: A component changed from ${wasControlled ? 'controlled' : 'uncontrolled'} to ${isControlled ? 'controlled' : 'uncontrolled'}.`);
isControlledRef.current = isControlled;

@@ -40,3 +40,3 @@ }, [

if (typeof value === 'function') {
console.warn('We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320');
if (process.env.NODE_ENV !== 'production') console.warn('We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320');
// this supports functional updates https://reactjs.org/docs/hooks-reference.html#functional-updates

@@ -43,0 +43,0 @@ // when someone using useControlledState calls setControlledState(myFunc)

{
"name": "@react-stately/utils",
"version": "3.0.0-nightly-ec25ca46d-241211",
"version": "3.0.0-nightly-ecb05e28d-250909",
"description": "Spectrum UI components in React",

@@ -9,3 +9,7 @@ "license": "Apache-2.0",

"exports": {
"types": "./dist/types.d.ts",
"source": "./src/index.ts",
"types": [
"./dist/types.d.ts",
"./src/index.ts"
],
"import": "./dist/import.mjs",

@@ -12,0 +16,0 @@ "require": "./dist/main.js"

@@ -21,7 +21,16 @@ /*

export function roundToStepPrecision(value: number, step: number) {
export function roundToStepPrecision(value: number, step: number): number {
let roundedValue = value;
let precision = 0;
let stepString = step.toString();
let pointIndex = stepString.indexOf('.');
let precision = pointIndex >= 0 ? stepString.length - pointIndex : 0;
// Handle negative exponents in exponential notation (e.g., "1e-7" → precision 8)
let eIndex = stepString.toLowerCase().indexOf('e-');
if (eIndex > 0) {
precision = Math.abs(Math.floor(Math.log10(Math.abs(step)))) + eIndex;
} else {
let pointIndex = stepString.indexOf('.');
if (pointIndex >= 0) {
precision = stepString.length - pointIndex;
}
}
if (precision > 0) {

@@ -28,0 +37,0 @@ let pow = Math.pow(10, precision);

@@ -24,3 +24,3 @@ /*

let wasControlled = isControlledRef.current;
if (wasControlled !== isControlled) {
if (wasControlled !== isControlled && process.env.NODE_ENV !== 'production') {
console.warn(`WARN: A component changed from ${wasControlled ? 'controlled' : 'uncontrolled'} to ${isControlled ? 'controlled' : 'uncontrolled'}.`);

@@ -50,3 +50,5 @@ }

if (typeof value === 'function') {
console.warn('We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320');
if (process.env.NODE_ENV !== 'production') {
console.warn('We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320');
}
// this supports functional updates https://reactjs.org/docs/hooks-reference.html#functional-updates

@@ -53,0 +55,0 @@ // when someone using useControlledState calls setControlledState(myFunc)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet