@react-stately/slider
Advanced tools
Comparing version 3.0.0-nightly.2358 to 3.0.0-nightly.2359
@@ -39,7 +39,3 @@ var { | ||
const isEditablesRef = useRef(new Array(values.length).fill(true)); | ||
const [focusedIndex, setFocusedIndex] = useState(undefined); // We keep some of the dragging state on refs as well, because they are read by event | ||
// handlers. In useDrag1D, the same drag event handler is used for the entire drag motion, | ||
// so the state object within their closure is already stale. | ||
const realTimeDragging = useRef(false); | ||
const [focusedIndex, setFocusedIndex] = useState(undefined); | ||
const formatter = useNumberFormatter(formatOptions); | ||
@@ -75,15 +71,4 @@ | ||
value = clamp(getRoundedValue(value), thisMin, thisMax); // Do nothing if slider hasn't moved | ||
if (value === values[index]) { | ||
return; | ||
} | ||
const newValues = $bc3294032743285adead374b6f67$var$replaceIndex(values, index, value); | ||
setValues(newValues); | ||
if (props.onChangeEnd && !realTimeDragging.current) { | ||
// If not in the middle of dragging, call onChangeEnd | ||
props.onChangeEnd(newValues); | ||
} | ||
value = clamp(getRoundedValue(value), thisMin, thisMax); | ||
setValues(values => $bc3294032743285adead374b6f67$var$replaceIndex(values, index, value)); | ||
} | ||
@@ -97,4 +82,7 @@ | ||
const newDraggings = $bc3294032743285adead374b6f67$var$replaceIndex(isDraggings, index, dragging); | ||
setDraggings(newDraggings); | ||
realTimeDragging.current = newDraggings.some(Boolean); | ||
setDraggings(newDraggings); // Call onChangeEnd if no handles are dragging. | ||
if (props.onChangeEnd && isDraggings[index] && !newDraggings.some(Boolean)) { | ||
props.onChangeEnd(values); | ||
} | ||
} | ||
@@ -144,4 +132,8 @@ | ||
function $bc3294032743285adead374b6f67$var$replaceIndex(array, index, value) { | ||
if (array[index] === value) { | ||
return array; | ||
} | ||
return [...array.slice(0, index), value, ...array.slice(index + 1)]; | ||
} | ||
//# sourceMappingURL=main.js.map |
@@ -22,7 +22,3 @@ import { useRef, useState } from "react"; | ||
const isEditablesRef = useRef(new Array(values.length).fill(true)); | ||
const [focusedIndex, setFocusedIndex] = useState(undefined); // We keep some of the dragging state on refs as well, because they are read by event | ||
// handlers. In useDrag1D, the same drag event handler is used for the entire drag motion, | ||
// so the state object within their closure is already stale. | ||
const realTimeDragging = useRef(false); | ||
const [focusedIndex, setFocusedIndex] = useState(undefined); | ||
const formatter = useNumberFormatter(formatOptions); | ||
@@ -58,15 +54,4 @@ | ||
value = clamp(getRoundedValue(value), thisMin, thisMax); // Do nothing if slider hasn't moved | ||
if (value === values[index]) { | ||
return; | ||
} | ||
const newValues = $dcc38d2f5fc04b76254f325fa36d$var$replaceIndex(values, index, value); | ||
setValues(newValues); | ||
if (props.onChangeEnd && !realTimeDragging.current) { | ||
// If not in the middle of dragging, call onChangeEnd | ||
props.onChangeEnd(newValues); | ||
} | ||
value = clamp(getRoundedValue(value), thisMin, thisMax); | ||
setValues(values => $dcc38d2f5fc04b76254f325fa36d$var$replaceIndex(values, index, value)); | ||
} | ||
@@ -80,4 +65,7 @@ | ||
const newDraggings = $dcc38d2f5fc04b76254f325fa36d$var$replaceIndex(isDraggings, index, dragging); | ||
setDraggings(newDraggings); | ||
realTimeDragging.current = newDraggings.some(Boolean); | ||
setDraggings(newDraggings); // Call onChangeEnd if no handles are dragging. | ||
if (props.onChangeEnd && isDraggings[index] && !newDraggings.some(Boolean)) { | ||
props.onChangeEnd(values); | ||
} | ||
} | ||
@@ -125,4 +113,8 @@ | ||
function $dcc38d2f5fc04b76254f325fa36d$var$replaceIndex(array, index, value) { | ||
if (array[index] === value) { | ||
return array; | ||
} | ||
return [...array.slice(0, index), value, ...array.slice(index + 1)]; | ||
} | ||
//# sourceMappingURL=module.js.map |
{ | ||
"name": "@react-stately/slider", | ||
"version": "3.0.0-nightly.2358+3ee5685e", | ||
"version": "3.0.0-nightly.2359+1ad0f163", | ||
"description": "Spectrum UI components in React", | ||
@@ -21,6 +21,6 @@ "license": "Apache-2.0", | ||
"@babel/runtime": "^7.6.2", | ||
"@react-aria/i18n": "3.0.0-nightly.680+3ee5685e", | ||
"@react-aria/utils": "3.0.0-nightly.680+3ee5685e", | ||
"@react-stately/utils": "3.0.0-nightly.680+3ee5685e", | ||
"@react-types/slider": "3.0.0-nightly.2358+3ee5685e" | ||
"@react-aria/i18n": "3.0.0-nightly.681+1ad0f163", | ||
"@react-aria/utils": "3.0.0-nightly.681+1ad0f163", | ||
"@react-stately/utils": "3.0.0-nightly.681+1ad0f163", | ||
"@react-types/slider": "3.0.0-nightly.2359+1ad0f163" | ||
}, | ||
@@ -36,3 +36,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "3ee5685e293447fb1995ddec4c70b56c8e3aaa8e" | ||
"gitHead": "1ad0f16354f7114e4ecfa5c75b16ec6f11ff1ec0" | ||
} |
@@ -78,6 +78,2 @@ /* | ||
// We keep some of the dragging state on refs as well, because they are read by event | ||
// handlers. In useDrag1D, the same drag event handler is used for the entire drag motion, | ||
// so the state object within their closure is already stale. | ||
const realTimeDragging = useRef(false); | ||
const formatter = useNumberFormatter(formatOptions); | ||
@@ -113,15 +109,3 @@ | ||
value = clamp(getRoundedValue(value), thisMin, thisMax); | ||
// Do nothing if slider hasn't moved | ||
if (value === values[index]) { | ||
return; | ||
} | ||
const newValues = replaceIndex(values, index, value); | ||
setValues(newValues); | ||
if (props.onChangeEnd && !realTimeDragging.current) { | ||
// If not in the middle of dragging, call onChangeEnd | ||
props.onChangeEnd(newValues); | ||
} | ||
setValues(values => replaceIndex(values, index, value)); | ||
} | ||
@@ -133,5 +117,10 @@ | ||
} | ||
const newDraggings = replaceIndex(isDraggings, index, dragging); | ||
setDraggings(newDraggings); | ||
realTimeDragging.current = newDraggings.some(Boolean); | ||
// Call onChangeEnd if no handles are dragging. | ||
if (props.onChangeEnd && isDraggings[index] && !newDraggings.some(Boolean)) { | ||
props.onChangeEnd(values); | ||
} | ||
} | ||
@@ -179,3 +168,7 @@ | ||
function replaceIndex<T>(array: T[], index: number, value: T) { | ||
if (array[index] === value) { | ||
return array; | ||
} | ||
return [...array.slice(0, index), value, ...array.slice(index + 1)]; | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
50484
383