Socket
Socket
Sign inDemoInstall

@react-stately/numberfield

Package Overview
Dependencies
Maintainers
2
Versions
669
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-stately/numberfield - npm Package Compare versions

Comparing version 3.0.0-nightly.2912 to 3.0.0-nightly.2917

26

dist/useNumberFieldState.main.js

@@ -38,3 +38,3 @@ var $gPCRT$reactstatelyutils = require("@react-stately/utils");

let [numberValue, setNumberValue] = (0, $gPCRT$reactstatelyutils.useControlledState)(value, isNaN(defaultValue) ? NaN : defaultValue, onChange);
let [inputValue, setInputValue] = (0, $gPCRT$react.useState)(()=>isNaN(numberValue) ? "" : new (0, $gPCRT$internationalizednumber.NumberFormatter)(locale, formatOptions).format(numberValue));
let [inputValue, setInputValue] = (0, $gPCRT$react.useState)(()=>isNaN(numberValue) ? '' : new (0, $gPCRT$internationalizednumber.NumberFormatter)(locale, formatOptions).format(numberValue));
let numberParser = (0, $gPCRT$react.useMemo)(()=>new (0, $gPCRT$internationalizednumber.NumberParser)(locale, formatOptions), [

@@ -59,3 +59,3 @@ locale,

]);
let format = (0, $gPCRT$react.useCallback)((value)=>isNaN(value) || value === null ? "" : formatter.format(value), [
let format = (0, $gPCRT$react.useCallback)((value)=>isNaN(value) || value === null ? '' : formatter.format(value), [
formatter

@@ -68,3 +68,3 @@ ]);

let clampStep = step !== undefined && !isNaN(step) ? step : 1;
if (intlOptions.style === "percent" && (step === undefined || isNaN(step))) clampStep = 0.01;
if (intlOptions.style === 'percent' && (step === undefined || isNaN(step))) clampStep = 0.01;
// Update the input value when the number value or format options change. This is done

@@ -90,3 +90,3 @@ // in a useEffect so that the controlled behavior is correct and we only update the

setNumberValue(NaN);
setInputValue(value === undefined ? "" : format(numberValue));
setInputValue(value === undefined ? '' : format(numberValue));
return;

@@ -119,3 +119,3 @@ }

let newValue = (0, $gPCRT$reactstatelyutils.snapValueToStep)(prev, minValue, maxValue, clampStep);
if (operation === "+" && newValue > prev || operation === "-" && newValue < prev) return newValue;
if (operation === '+' && newValue > prev || operation === '-' && newValue < prev) return newValue;
return (0, $gPCRT$reactstatelyutils.snapValueToStep)($e18a693eeaf9c060$var$handleDecimalOperation(operation, prev, clampStep), minValue, maxValue, clampStep);

@@ -125,3 +125,3 @@ }

let increment = ()=>{
let newValue = safeNextStep("+", minValue);
let newValue = safeNextStep('+', minValue);
// if we've arrived at the same value that was previously in the state, the

@@ -136,3 +136,3 @@ // input value should be updated to match

let decrement = ()=>{
let newValue = safeNextStep("-", maxValue);
let newValue = safeNextStep('-', maxValue);
if (newValue === numberValue) setInputValue(format(newValue));

@@ -154,3 +154,3 @@ setNumberValue(newValue);

};
let canIncrement = (0, $gPCRT$react.useMemo)(()=>!isDisabled && !isReadOnly && (isNaN(parsedValue) || maxValue === undefined || isNaN(maxValue) || (0, $gPCRT$reactstatelyutils.snapValueToStep)(parsedValue, minValue, maxValue, clampStep) > parsedValue || $e18a693eeaf9c060$var$handleDecimalOperation("+", parsedValue, clampStep) <= maxValue), [
let canIncrement = (0, $gPCRT$react.useMemo)(()=>!isDisabled && !isReadOnly && (isNaN(parsedValue) || maxValue === undefined || isNaN(maxValue) || (0, $gPCRT$reactstatelyutils.snapValueToStep)(parsedValue, minValue, maxValue, clampStep) > parsedValue || $e18a693eeaf9c060$var$handleDecimalOperation('+', parsedValue, clampStep) <= maxValue), [
isDisabled,

@@ -163,3 +163,3 @@ isReadOnly,

]);
let canDecrement = (0, $gPCRT$react.useMemo)(()=>!isDisabled && !isReadOnly && (isNaN(parsedValue) || minValue === undefined || isNaN(minValue) || (0, $gPCRT$reactstatelyutils.snapValueToStep)(parsedValue, minValue, maxValue, clampStep) < parsedValue || $e18a693eeaf9c060$var$handleDecimalOperation("-", parsedValue, clampStep) >= minValue), [
let canDecrement = (0, $gPCRT$react.useMemo)(()=>!isDisabled && !isReadOnly && (isNaN(parsedValue) || minValue === undefined || isNaN(minValue) || (0, $gPCRT$reactstatelyutils.snapValueToStep)(parsedValue, minValue, maxValue, clampStep) < parsedValue || $e18a693eeaf9c060$var$handleDecimalOperation('-', parsedValue, clampStep) >= minValue), [
isDisabled,

@@ -192,7 +192,7 @@ isReadOnly,

function $e18a693eeaf9c060$var$handleDecimalOperation(operator, value1, value2) {
let result = operator === "+" ? value1 + value2 : value1 - value2;
let result = operator === '+' ? value1 + value2 : value1 - value2;
// Check if we have decimals
if (value1 % 1 !== 0 || value2 % 1 !== 0) {
const value1Decimal = value1.toString().split(".");
const value2Decimal = value2.toString().split(".");
const value1Decimal = value1.toString().split('.');
const value2Decimal = value2.toString().split('.');
const value1DecimalLength = value1Decimal[1] && value1Decimal[1].length || 0;

@@ -205,3 +205,3 @@ const value2DecimalLength = value2Decimal[1] && value2Decimal[1].length || 0;

// Perform the operation on integers values to make sure we don't get a fancy decimal value
result = operator === "+" ? value1 + value2 : value1 - value2;
result = operator === '+' ? value1 + value2 : value1 - value2;
// Transform the integer result back to decimal

@@ -208,0 +208,0 @@ result /= multiplier;

@@ -32,3 +32,3 @@ import {snapValueToStep as $kNCPO$snapValueToStep, clamp as $kNCPO$clamp, useControlledState as $kNCPO$useControlledState} from "@react-stately/utils";

let [numberValue, setNumberValue] = (0, $kNCPO$useControlledState)(value, isNaN(defaultValue) ? NaN : defaultValue, onChange);
let [inputValue, setInputValue] = (0, $kNCPO$useState)(()=>isNaN(numberValue) ? "" : new (0, $kNCPO$NumberFormatter)(locale, formatOptions).format(numberValue));
let [inputValue, setInputValue] = (0, $kNCPO$useState)(()=>isNaN(numberValue) ? '' : new (0, $kNCPO$NumberFormatter)(locale, formatOptions).format(numberValue));
let numberParser = (0, $kNCPO$useMemo)(()=>new (0, $kNCPO$NumberParser)(locale, formatOptions), [

@@ -53,3 +53,3 @@ locale,

]);
let format = (0, $kNCPO$useCallback)((value)=>isNaN(value) || value === null ? "" : formatter.format(value), [
let format = (0, $kNCPO$useCallback)((value)=>isNaN(value) || value === null ? '' : formatter.format(value), [
formatter

@@ -62,3 +62,3 @@ ]);

let clampStep = step !== undefined && !isNaN(step) ? step : 1;
if (intlOptions.style === "percent" && (step === undefined || isNaN(step))) clampStep = 0.01;
if (intlOptions.style === 'percent' && (step === undefined || isNaN(step))) clampStep = 0.01;
// Update the input value when the number value or format options change. This is done

@@ -84,3 +84,3 @@ // in a useEffect so that the controlled behavior is correct and we only update the

setNumberValue(NaN);
setInputValue(value === undefined ? "" : format(numberValue));
setInputValue(value === undefined ? '' : format(numberValue));
return;

@@ -113,3 +113,3 @@ }

let newValue = (0, $kNCPO$snapValueToStep)(prev, minValue, maxValue, clampStep);
if (operation === "+" && newValue > prev || operation === "-" && newValue < prev) return newValue;
if (operation === '+' && newValue > prev || operation === '-' && newValue < prev) return newValue;
return (0, $kNCPO$snapValueToStep)($de67e98908f0c6ee$var$handleDecimalOperation(operation, prev, clampStep), minValue, maxValue, clampStep);

@@ -119,3 +119,3 @@ }

let increment = ()=>{
let newValue = safeNextStep("+", minValue);
let newValue = safeNextStep('+', minValue);
// if we've arrived at the same value that was previously in the state, the

@@ -130,3 +130,3 @@ // input value should be updated to match

let decrement = ()=>{
let newValue = safeNextStep("-", maxValue);
let newValue = safeNextStep('-', maxValue);
if (newValue === numberValue) setInputValue(format(newValue));

@@ -148,3 +148,3 @@ setNumberValue(newValue);

};
let canIncrement = (0, $kNCPO$useMemo)(()=>!isDisabled && !isReadOnly && (isNaN(parsedValue) || maxValue === undefined || isNaN(maxValue) || (0, $kNCPO$snapValueToStep)(parsedValue, minValue, maxValue, clampStep) > parsedValue || $de67e98908f0c6ee$var$handleDecimalOperation("+", parsedValue, clampStep) <= maxValue), [
let canIncrement = (0, $kNCPO$useMemo)(()=>!isDisabled && !isReadOnly && (isNaN(parsedValue) || maxValue === undefined || isNaN(maxValue) || (0, $kNCPO$snapValueToStep)(parsedValue, minValue, maxValue, clampStep) > parsedValue || $de67e98908f0c6ee$var$handleDecimalOperation('+', parsedValue, clampStep) <= maxValue), [
isDisabled,

@@ -157,3 +157,3 @@ isReadOnly,

]);
let canDecrement = (0, $kNCPO$useMemo)(()=>!isDisabled && !isReadOnly && (isNaN(parsedValue) || minValue === undefined || isNaN(minValue) || (0, $kNCPO$snapValueToStep)(parsedValue, minValue, maxValue, clampStep) < parsedValue || $de67e98908f0c6ee$var$handleDecimalOperation("-", parsedValue, clampStep) >= minValue), [
let canDecrement = (0, $kNCPO$useMemo)(()=>!isDisabled && !isReadOnly && (isNaN(parsedValue) || minValue === undefined || isNaN(minValue) || (0, $kNCPO$snapValueToStep)(parsedValue, minValue, maxValue, clampStep) < parsedValue || $de67e98908f0c6ee$var$handleDecimalOperation('-', parsedValue, clampStep) >= minValue), [
isDisabled,

@@ -186,7 +186,7 @@ isReadOnly,

function $de67e98908f0c6ee$var$handleDecimalOperation(operator, value1, value2) {
let result = operator === "+" ? value1 + value2 : value1 - value2;
let result = operator === '+' ? value1 + value2 : value1 - value2;
// Check if we have decimals
if (value1 % 1 !== 0 || value2 % 1 !== 0) {
const value1Decimal = value1.toString().split(".");
const value2Decimal = value2.toString().split(".");
const value1Decimal = value1.toString().split('.');
const value2Decimal = value2.toString().split('.');
const value1DecimalLength = value1Decimal[1] && value1Decimal[1].length || 0;

@@ -199,3 +199,3 @@ const value2DecimalLength = value2Decimal[1] && value2Decimal[1].length || 0;

// Perform the operation on integers values to make sure we don't get a fancy decimal value
result = operator === "+" ? value1 + value2 : value1 - value2;
result = operator === '+' ? value1 + value2 : value1 - value2;
// Transform the integer result back to decimal

@@ -202,0 +202,0 @@ result /= multiplier;

{
"name": "@react-stately/numberfield",
"version": "3.0.0-nightly.2912+d80999e89",
"version": "3.0.0-nightly.2917+c34886769",
"description": "Spectrum UI components in React",

@@ -25,6 +25,6 @@ "license": "Apache-2.0",

"dependencies": {
"@internationalized/number": "3.5.3-nightly.4624+d80999e89",
"@react-stately/form": "3.0.3-nightly.4624+d80999e89",
"@react-stately/utils": "3.0.0-nightly.2912+d80999e89",
"@react-types/numberfield": "3.8.3-nightly.4624+d80999e89",
"@internationalized/number": "3.5.4-nightly.4629+c34886769",
"@react-stately/form": "3.0.4-nightly.4629+c34886769",
"@react-stately/utils": "3.0.0-nightly.2917+c34886769",
"@react-types/numberfield": "3.8.4-nightly.4629+c34886769",
"@swc/helpers": "^0.5.0"

@@ -38,3 +38,3 @@ },

},
"gitHead": "d80999e897b4d4db9fcfb4e9b8fcdc9fdd700882"
"gitHead": "c34886769d3e69bb56553a02eead6a0fd877e754"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc