@react-stately/slider 3.0.4-nightly.3085 → 3.0.4-nightly.3086
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +22 -22
- package/dist/module.js +22 -22
- package/package.json +6 -6
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
1
|
+
var $ewMrq$reactariautils = require("@react-aria/utils");
|
|
2
|
+
var $ewMrq$reactstatelyutils = require("@react-stately/utils");
|
|
3
|
+
var $ewMrq$react = require("react");
|
|
4
4
|
|
|
5
5
|
function $parcel$exportWildcard(dest, source) {
|
|
6
6
|
Object.keys(source).forEach(function(key) {
|
|
@@ -21,26 +21,26 @@ function $parcel$exportWildcard(dest, source) {
|
|
|
21
21
|
function $parcel$export(e, n, v, s) {
|
|
22
22
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
23
23
|
}
|
|
24
|
-
var $
|
|
24
|
+
var $16a7c389e53c069a$exports = {};
|
|
25
25
|
|
|
26
|
-
$parcel$export($
|
|
26
|
+
$parcel$export($16a7c389e53c069a$exports, "useSliderState", () => $16a7c389e53c069a$export$e5fda3247f5d67f9);
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
const $
|
|
31
|
-
const $
|
|
32
|
-
const $
|
|
33
|
-
function $
|
|
34
|
-
const { isDisabled: isDisabled , minValue: minValue = $
|
|
35
|
-
const [values, setValues] = $
|
|
30
|
+
const $16a7c389e53c069a$var$DEFAULT_MIN_VALUE = 0;
|
|
31
|
+
const $16a7c389e53c069a$var$DEFAULT_MAX_VALUE = 100;
|
|
32
|
+
const $16a7c389e53c069a$var$DEFAULT_STEP_VALUE = 1;
|
|
33
|
+
function $16a7c389e53c069a$export$e5fda3247f5d67f9(props) {
|
|
34
|
+
const { isDisabled: isDisabled , minValue: minValue = $16a7c389e53c069a$var$DEFAULT_MIN_VALUE , maxValue: maxValue = $16a7c389e53c069a$var$DEFAULT_MAX_VALUE , numberFormatter: formatter , step: step = $16a7c389e53c069a$var$DEFAULT_STEP_VALUE } = props;
|
|
35
|
+
const [values, setValues] = $ewMrq$reactstatelyutils.useControlledState(props.value, props.defaultValue ?? [
|
|
36
36
|
minValue
|
|
37
37
|
], props.onChange);
|
|
38
|
-
const [isDraggings, setDraggings] = $
|
|
39
|
-
const isEditablesRef = $
|
|
40
|
-
const [focusedIndex, setFocusedIndex] = $
|
|
41
|
-
const valuesRef = $
|
|
38
|
+
const [isDraggings, setDraggings] = $ewMrq$react.useState(new Array(values.length).fill(false));
|
|
39
|
+
const isEditablesRef = $ewMrq$react.useRef(new Array(values.length).fill(true));
|
|
40
|
+
const [focusedIndex, setFocusedIndex] = $ewMrq$react.useState(undefined);
|
|
41
|
+
const valuesRef = $ewMrq$react.useRef(null);
|
|
42
42
|
valuesRef.current = values;
|
|
43
|
-
const isDraggingsRef = $
|
|
43
|
+
const isDraggingsRef = $ewMrq$react.useRef(null);
|
|
44
44
|
isDraggingsRef.current = isDraggings;
|
|
45
45
|
function getValuePercent(value) {
|
|
46
46
|
return (value - minValue) / (maxValue - minValue);
|
|
@@ -62,14 +62,14 @@ function $ec80cfa9a3830ae5$export$e5fda3247f5d67f9(props) {
|
|
|
62
62
|
const thisMin = getThumbMinValue(index);
|
|
63
63
|
const thisMax = getThumbMaxValue(index);
|
|
64
64
|
// Round value to multiple of step, clamp value between min and max
|
|
65
|
-
value = $
|
|
66
|
-
valuesRef.current = $
|
|
65
|
+
value = $ewMrq$reactariautils.snapValueToStep(value, thisMin, thisMax, step);
|
|
66
|
+
valuesRef.current = $16a7c389e53c069a$var$replaceIndex(valuesRef.current, index, value);
|
|
67
67
|
setValues(valuesRef.current);
|
|
68
68
|
}
|
|
69
69
|
function updateDragging(index, dragging) {
|
|
70
70
|
if (isDisabled || !isThumbEditable(index)) return;
|
|
71
71
|
const wasDragging = isDraggingsRef.current[index];
|
|
72
|
-
isDraggingsRef.current = $
|
|
72
|
+
isDraggingsRef.current = $16a7c389e53c069a$var$replaceIndex(isDraggingsRef.current, index, dragging);
|
|
73
73
|
setDraggings(isDraggingsRef.current);
|
|
74
74
|
// Call onChangeEnd if no handles are dragging.
|
|
75
75
|
if (props.onChangeEnd && wasDragging && !isDraggingsRef.current.some(Boolean)) props.onChangeEnd(valuesRef.current);
|
|
@@ -85,7 +85,7 @@ function $ec80cfa9a3830ae5$export$e5fda3247f5d67f9(props) {
|
|
|
85
85
|
}
|
|
86
86
|
function getPercentValue(percent) {
|
|
87
87
|
const val = percent * (maxValue - minValue) + minValue;
|
|
88
|
-
return $
|
|
88
|
+
return $ewMrq$reactariautils.clamp(getRoundedValue(val), minValue, maxValue);
|
|
89
89
|
}
|
|
90
90
|
return {
|
|
91
91
|
values: values,
|
|
@@ -112,7 +112,7 @@ function $ec80cfa9a3830ae5$export$e5fda3247f5d67f9(props) {
|
|
|
112
112
|
step: step
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
function $
|
|
115
|
+
function $16a7c389e53c069a$var$replaceIndex(array, index, value) {
|
|
116
116
|
if (array[index] === value) return array;
|
|
117
117
|
return [
|
|
118
118
|
...array.slice(0, index),
|
|
@@ -122,7 +122,7 @@ function $ec80cfa9a3830ae5$var$replaceIndex(array, index, value) {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
|
|
125
|
-
$parcel$exportWildcard(module.exports, $
|
|
125
|
+
$parcel$exportWildcard(module.exports, $16a7c389e53c069a$exports);
|
|
126
126
|
|
|
127
127
|
|
|
128
128
|
//# sourceMappingURL=main.js.map
|
package/dist/module.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {snapValueToStep as $
|
|
2
|
-
import {useControlledState as $
|
|
3
|
-
import {useState as $
|
|
1
|
+
import {snapValueToStep as $35Cqk$snapValueToStep, clamp as $35Cqk$clamp} from "@react-aria/utils";
|
|
2
|
+
import {useControlledState as $35Cqk$useControlledState} from "@react-stately/utils";
|
|
3
|
+
import {useState as $35Cqk$useState, useRef as $35Cqk$useRef} from "react";
|
|
4
4
|
|
|
5
5
|
function $parcel$export(e, n, v, s) {
|
|
6
6
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
7
|
}
|
|
8
|
-
var $
|
|
8
|
+
var $41e91674a959b70c$exports = {};
|
|
9
9
|
|
|
10
|
-
$parcel$export($
|
|
10
|
+
$parcel$export($41e91674a959b70c$exports, "useSliderState", () => $41e91674a959b70c$export$e5fda3247f5d67f9);
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
const $
|
|
15
|
-
const $
|
|
16
|
-
const $
|
|
17
|
-
function $
|
|
18
|
-
const { isDisabled: isDisabled , minValue: minValue = $
|
|
19
|
-
const [values, setValues] = $
|
|
14
|
+
const $41e91674a959b70c$var$DEFAULT_MIN_VALUE = 0;
|
|
15
|
+
const $41e91674a959b70c$var$DEFAULT_MAX_VALUE = 100;
|
|
16
|
+
const $41e91674a959b70c$var$DEFAULT_STEP_VALUE = 1;
|
|
17
|
+
function $41e91674a959b70c$export$e5fda3247f5d67f9(props) {
|
|
18
|
+
const { isDisabled: isDisabled , minValue: minValue = $41e91674a959b70c$var$DEFAULT_MIN_VALUE , maxValue: maxValue = $41e91674a959b70c$var$DEFAULT_MAX_VALUE , numberFormatter: formatter , step: step = $41e91674a959b70c$var$DEFAULT_STEP_VALUE } = props;
|
|
19
|
+
const [values, setValues] = $35Cqk$useControlledState(props.value, props.defaultValue ?? [
|
|
20
20
|
minValue
|
|
21
21
|
], props.onChange);
|
|
22
|
-
const [isDraggings, setDraggings] = $
|
|
23
|
-
const isEditablesRef = $
|
|
24
|
-
const [focusedIndex, setFocusedIndex] = $
|
|
25
|
-
const valuesRef = $
|
|
22
|
+
const [isDraggings, setDraggings] = $35Cqk$useState(new Array(values.length).fill(false));
|
|
23
|
+
const isEditablesRef = $35Cqk$useRef(new Array(values.length).fill(true));
|
|
24
|
+
const [focusedIndex, setFocusedIndex] = $35Cqk$useState(undefined);
|
|
25
|
+
const valuesRef = $35Cqk$useRef(null);
|
|
26
26
|
valuesRef.current = values;
|
|
27
|
-
const isDraggingsRef = $
|
|
27
|
+
const isDraggingsRef = $35Cqk$useRef(null);
|
|
28
28
|
isDraggingsRef.current = isDraggings;
|
|
29
29
|
function getValuePercent(value) {
|
|
30
30
|
return (value - minValue) / (maxValue - minValue);
|
|
@@ -46,14 +46,14 @@ function $bc616ccd4b00f45f$export$e5fda3247f5d67f9(props) {
|
|
|
46
46
|
const thisMin = getThumbMinValue(index);
|
|
47
47
|
const thisMax = getThumbMaxValue(index);
|
|
48
48
|
// Round value to multiple of step, clamp value between min and max
|
|
49
|
-
value = $
|
|
50
|
-
valuesRef.current = $
|
|
49
|
+
value = $35Cqk$snapValueToStep(value, thisMin, thisMax, step);
|
|
50
|
+
valuesRef.current = $41e91674a959b70c$var$replaceIndex(valuesRef.current, index, value);
|
|
51
51
|
setValues(valuesRef.current);
|
|
52
52
|
}
|
|
53
53
|
function updateDragging(index, dragging) {
|
|
54
54
|
if (isDisabled || !isThumbEditable(index)) return;
|
|
55
55
|
const wasDragging = isDraggingsRef.current[index];
|
|
56
|
-
isDraggingsRef.current = $
|
|
56
|
+
isDraggingsRef.current = $41e91674a959b70c$var$replaceIndex(isDraggingsRef.current, index, dragging);
|
|
57
57
|
setDraggings(isDraggingsRef.current);
|
|
58
58
|
// Call onChangeEnd if no handles are dragging.
|
|
59
59
|
if (props.onChangeEnd && wasDragging && !isDraggingsRef.current.some(Boolean)) props.onChangeEnd(valuesRef.current);
|
|
@@ -69,7 +69,7 @@ function $bc616ccd4b00f45f$export$e5fda3247f5d67f9(props) {
|
|
|
69
69
|
}
|
|
70
70
|
function getPercentValue(percent) {
|
|
71
71
|
const val = percent * (maxValue - minValue) + minValue;
|
|
72
|
-
return $
|
|
72
|
+
return $35Cqk$clamp(getRoundedValue(val), minValue, maxValue);
|
|
73
73
|
}
|
|
74
74
|
return {
|
|
75
75
|
values: values,
|
|
@@ -96,7 +96,7 @@ function $bc616ccd4b00f45f$export$e5fda3247f5d67f9(props) {
|
|
|
96
96
|
step: step
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
function $
|
|
99
|
+
function $41e91674a959b70c$var$replaceIndex(array, index, value) {
|
|
100
100
|
if (array[index] === value) return array;
|
|
101
101
|
return [
|
|
102
102
|
...array.slice(0, index),
|
|
@@ -108,5 +108,5 @@ function $bc616ccd4b00f45f$var$replaceIndex(array, index, value) {
|
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
export {$
|
|
111
|
+
export {$41e91674a959b70c$export$e5fda3247f5d67f9 as useSliderState};
|
|
112
112
|
//# sourceMappingURL=module.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/slider",
|
|
3
|
-
"version": "3.0.4-nightly.
|
|
3
|
+
"version": "3.0.4-nightly.3086+b2abc5d94",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
22
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
23
|
-
"@react-stately/utils": "3.0.0-nightly.
|
|
24
|
-
"@react-types/slider": "3.0.3-nightly.
|
|
21
|
+
"@react-aria/i18n": "3.0.0-nightly.1395+b2abc5d94",
|
|
22
|
+
"@react-aria/utils": "3.0.0-nightly.1395+b2abc5d94",
|
|
23
|
+
"@react-stately/utils": "3.0.0-nightly.1395+b2abc5d94",
|
|
24
|
+
"@react-types/slider": "3.0.3-nightly.3086+b2abc5d94"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": "^16.8.0 || ^17.0.0-rc.1"
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "b2abc5d94162a7bd614fffcdf11e3d3754dc7d9f"
|
|
33
33
|
}
|