@react-stately/slider 3.0.4-nightly.3040 → 3.0.4-nightly.3047
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 +116 -127
- package/dist/main.js.map +1 -1
- package/dist/module.js +103 -117
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/main.js
CHANGED
|
@@ -1,139 +1,128 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} = require("react");
|
|
1
|
+
var $lMkdD$reactariautils = require("@react-aria/utils");
|
|
2
|
+
var $lMkdD$reactstatelyutils = require("@react-stately/utils");
|
|
3
|
+
var $lMkdD$react = require("react");
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var {
|
|
11
|
-
clamp,
|
|
12
|
-
snapValueToStep
|
|
13
|
-
} = require("@react-aria/utils");
|
|
14
|
-
|
|
15
|
-
const $bc3294032743285adead374b6f67$var$DEFAULT_MIN_VALUE = 0;
|
|
16
|
-
const $bc3294032743285adead374b6f67$var$DEFAULT_MAX_VALUE = 100;
|
|
17
|
-
const $bc3294032743285adead374b6f67$var$DEFAULT_STEP_VALUE = 1;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Provides state management for a slider component. Stores values for all thumbs,
|
|
21
|
-
* formats values for localization, and provides methods to update the position
|
|
22
|
-
* of any thumbs.
|
|
23
|
-
* @param props
|
|
24
|
-
*/
|
|
25
|
-
function useSliderState(props) {
|
|
26
|
-
var _props$defaultValue;
|
|
27
|
-
|
|
28
|
-
const {
|
|
29
|
-
isDisabled,
|
|
30
|
-
minValue = $bc3294032743285adead374b6f67$var$DEFAULT_MIN_VALUE,
|
|
31
|
-
maxValue = $bc3294032743285adead374b6f67$var$DEFAULT_MAX_VALUE,
|
|
32
|
-
numberFormatter: formatter,
|
|
33
|
-
step = $bc3294032743285adead374b6f67$var$DEFAULT_STEP_VALUE
|
|
34
|
-
} = props;
|
|
35
|
-
const [values, setValues] = useControlledState(props.value, (_props$defaultValue = props.defaultValue) != null ? _props$defaultValue : [minValue], props.onChange);
|
|
36
|
-
const [isDraggings, setDraggings] = useState(new Array(values.length).fill(false));
|
|
37
|
-
const isEditablesRef = useRef(new Array(values.length).fill(true));
|
|
38
|
-
const [focusedIndex, setFocusedIndex] = useState(undefined);
|
|
39
|
-
const valuesRef = useRef(null);
|
|
40
|
-
valuesRef.current = values;
|
|
41
|
-
const isDraggingsRef = useRef(null);
|
|
42
|
-
isDraggingsRef.current = isDraggings;
|
|
43
|
-
|
|
44
|
-
function getValuePercent(value) {
|
|
45
|
-
return (value - minValue) / (maxValue - minValue);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function getThumbMinValue(index) {
|
|
49
|
-
return index === 0 ? minValue : values[index - 1];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function getThumbMaxValue(index) {
|
|
53
|
-
return index === values.length - 1 ? maxValue : values[index + 1];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function isThumbEditable(index) {
|
|
57
|
-
return isEditablesRef.current[index];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function setThumbEditable(index, editable) {
|
|
61
|
-
isEditablesRef.current[index] = editable;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function updateValue(index, value) {
|
|
65
|
-
if (isDisabled || !isThumbEditable(index)) {
|
|
5
|
+
function $parcel$exportWildcard(dest, source) {
|
|
6
|
+
Object.keys(source).forEach(function(key) {
|
|
7
|
+
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
66
8
|
return;
|
|
67
9
|
}
|
|
68
10
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
11
|
+
Object.defineProperty(dest, key, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function get() {
|
|
14
|
+
return source[key];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
76
18
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
19
|
+
return dest;
|
|
20
|
+
}
|
|
21
|
+
function $parcel$export(e, n, v, s) {
|
|
22
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
23
|
+
}
|
|
24
|
+
var $ec80cfa9a3830ae5$exports = {};
|
|
25
|
+
|
|
26
|
+
$parcel$export($ec80cfa9a3830ae5$exports, "useSliderState", () => $ec80cfa9a3830ae5$export$e5fda3247f5d67f9);
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
const $ec80cfa9a3830ae5$var$DEFAULT_MIN_VALUE = 0;
|
|
31
|
+
const $ec80cfa9a3830ae5$var$DEFAULT_MAX_VALUE = 100;
|
|
32
|
+
const $ec80cfa9a3830ae5$var$DEFAULT_STEP_VALUE = 1;
|
|
33
|
+
function $ec80cfa9a3830ae5$export$e5fda3247f5d67f9(props) {
|
|
34
|
+
const { isDisabled: isDisabled , minValue: minValue = $ec80cfa9a3830ae5$var$DEFAULT_MIN_VALUE , maxValue: maxValue = $ec80cfa9a3830ae5$var$DEFAULT_MAX_VALUE , numberFormatter: formatter , step: step = $ec80cfa9a3830ae5$var$DEFAULT_STEP_VALUE } = props;
|
|
35
|
+
const [values, setValues] = $lMkdD$reactstatelyutils.useControlledState(props.value, props.defaultValue ?? [
|
|
36
|
+
minValue
|
|
37
|
+
], props.onChange);
|
|
38
|
+
const [isDraggings, setDraggings] = $lMkdD$react.useState(new Array(values.length).fill(false));
|
|
39
|
+
const isEditablesRef = $lMkdD$react.useRef(new Array(values.length).fill(true));
|
|
40
|
+
const [focusedIndex, setFocusedIndex] = $lMkdD$react.useState(undefined);
|
|
41
|
+
const valuesRef = $lMkdD$react.useRef(null);
|
|
42
|
+
valuesRef.current = values;
|
|
43
|
+
const isDraggingsRef = $lMkdD$react.useRef(null);
|
|
44
|
+
isDraggingsRef.current = isDraggings;
|
|
45
|
+
function getValuePercent(value) {
|
|
46
|
+
return (value - minValue) / (maxValue - minValue);
|
|
80
47
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
isDraggingsRef.current = $bc3294032743285adead374b6f67$var$replaceIndex(isDraggingsRef.current, index, dragging);
|
|
84
|
-
setDraggings(isDraggingsRef.current); // Call onChangeEnd if no handles are dragging.
|
|
85
|
-
|
|
86
|
-
if (props.onChangeEnd && wasDragging && !isDraggingsRef.current.some(Boolean)) {
|
|
87
|
-
props.onChangeEnd(valuesRef.current);
|
|
48
|
+
function getThumbMinValue(index) {
|
|
49
|
+
return index === 0 ? minValue : values[index - 1];
|
|
88
50
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
51
|
+
function getThumbMaxValue(index) {
|
|
52
|
+
return index === values.length - 1 ? maxValue : values[index + 1];
|
|
53
|
+
}
|
|
54
|
+
function isThumbEditable(index) {
|
|
55
|
+
return isEditablesRef.current[index];
|
|
56
|
+
}
|
|
57
|
+
function setThumbEditable(index, editable) {
|
|
58
|
+
isEditablesRef.current[index] = editable;
|
|
59
|
+
}
|
|
60
|
+
function updateValue(index, value) {
|
|
61
|
+
if (isDisabled || !isThumbEditable(index)) return;
|
|
62
|
+
const thisMin = getThumbMinValue(index);
|
|
63
|
+
const thisMax = getThumbMaxValue(index);
|
|
64
|
+
// Round value to multiple of step, clamp value between min and max
|
|
65
|
+
value = $lMkdD$reactariautils.snapValueToStep(value, thisMin, thisMax, step);
|
|
66
|
+
valuesRef.current = $ec80cfa9a3830ae5$var$replaceIndex(valuesRef.current, index, value);
|
|
67
|
+
setValues(valuesRef.current);
|
|
68
|
+
}
|
|
69
|
+
function updateDragging(index, dragging) {
|
|
70
|
+
if (isDisabled || !isThumbEditable(index)) return;
|
|
71
|
+
const wasDragging = isDraggingsRef.current[index];
|
|
72
|
+
isDraggingsRef.current = $ec80cfa9a3830ae5$var$replaceIndex(isDraggingsRef.current, index, dragging);
|
|
73
|
+
setDraggings(isDraggingsRef.current);
|
|
74
|
+
// Call onChangeEnd if no handles are dragging.
|
|
75
|
+
if (props.onChangeEnd && wasDragging && !isDraggingsRef.current.some(Boolean)) props.onChangeEnd(valuesRef.current);
|
|
76
|
+
}
|
|
77
|
+
function getFormattedValue(value) {
|
|
78
|
+
return formatter.format(value);
|
|
79
|
+
}
|
|
80
|
+
function setThumbPercent(index, percent) {
|
|
81
|
+
updateValue(index, getPercentValue(percent));
|
|
82
|
+
}
|
|
83
|
+
function getRoundedValue(value) {
|
|
84
|
+
return Math.round((value - minValue) / step) * step + minValue;
|
|
85
|
+
}
|
|
86
|
+
function getPercentValue(percent) {
|
|
87
|
+
const val = percent * (maxValue - minValue) + minValue;
|
|
88
|
+
return $lMkdD$reactariautils.clamp(getRoundedValue(val), minValue, maxValue);
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
values: values,
|
|
92
|
+
getThumbValue: (index)=>values[index]
|
|
93
|
+
,
|
|
94
|
+
setThumbValue: updateValue,
|
|
95
|
+
setThumbPercent: setThumbPercent,
|
|
96
|
+
isThumbDragging: (index)=>isDraggings[index]
|
|
97
|
+
,
|
|
98
|
+
setThumbDragging: updateDragging,
|
|
99
|
+
focusedThumb: focusedIndex,
|
|
100
|
+
setFocusedThumb: setFocusedIndex,
|
|
101
|
+
getThumbPercent: (index)=>getValuePercent(values[index])
|
|
102
|
+
,
|
|
103
|
+
getValuePercent: getValuePercent,
|
|
104
|
+
getThumbValueLabel: (index)=>getFormattedValue(values[index])
|
|
105
|
+
,
|
|
106
|
+
getFormattedValue: getFormattedValue,
|
|
107
|
+
getThumbMinValue: getThumbMinValue,
|
|
108
|
+
getThumbMaxValue: getThumbMaxValue,
|
|
109
|
+
getPercentValue: getPercentValue,
|
|
110
|
+
isThumbEditable: isThumbEditable,
|
|
111
|
+
setThumbEditable: setThumbEditable,
|
|
112
|
+
step: step
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function $ec80cfa9a3830ae5$var$replaceIndex(array, index, value) {
|
|
116
|
+
if (array[index] === value) return array;
|
|
117
|
+
return [
|
|
118
|
+
...array.slice(0, index),
|
|
119
|
+
value,
|
|
120
|
+
...array.slice(index + 1)
|
|
121
|
+
];
|
|
128
122
|
}
|
|
129
123
|
|
|
130
|
-
exports.useSliderState = useSliderState;
|
|
131
124
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return array;
|
|
135
|
-
}
|
|
125
|
+
$parcel$exportWildcard(module.exports, $ec80cfa9a3830ae5$exports);
|
|
126
|
+
|
|
136
127
|
|
|
137
|
-
return [...array.slice(0, index), value, ...array.slice(index + 1)];
|
|
138
|
-
}
|
|
139
128
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;AA+HA,MAAMA,mDAAiB,GAAG,CAA1B;AACA,MAAMC,mDAAiB,GAAG,GAA1B;AACA,MAAMC,oDAAkB,GAAG,CAA3B;;AAMA;;;;;;AAMO,SAASC,cAAT,CAAwBC,KAAxB,EAAgE;AAAA;;AACrE,QAAM;AAACC,IAAAA,UAAD;AAAaC,IAAAA,QAAQ,GAAGN,mDAAxB;AAA2CO,I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kBAAkB,EAAGjC,KAAD,IAAmBgB,iBAAiB,CAACtC,MAAM,CAACsB,KAAD,CAAP,CAXnD;AAYLgB,IAAAA,iBAZK;AAaLjB,IAAAA,gBAbK;AAcLE,IAAAA,gBAdK;AAeLmB,IAAAA,eAfK;AAgBLlB,IAAAA,eAhBK;AAiBLC,IAAAA,gBAjBK;AAkBL1B,IAAAA;AAlBK,GAAP;AAoBD;;;;AAED,SAASgC,8CAAT,CAAyByB,KAAzB,EAAqClC,KAArC,EAAoDnB,KAApD,EAA8D;AAC5D,MAAIqD,KAAK,CAAClC,KAAD,CAAL,KAAiBnB,KAArB,EAA4B;AAC1B,WAAOqD,KAAP;AACD;;AAED,SAAO,CAAC,GAAGA,KAAK,CAACC,KAAN,CAAY,CAAZ,EAAenC,KAAf,CAAJ,EAA2BnB,KAA3B,EAAkC,GAAGqD,KAAK,CAACC,KAAN,CAAYnC,KAAK,GAAG,CAApB,CAArC,CAAP;AACD","sources":["./packages/@react-stately/slider/src/useSliderState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {clamp, snapValueToStep} from '@react-aria/utils';\nimport {SliderProps} from '@react-types/slider';\nimport {useControlledState} from '@react-stately/utils';\nimport {useRef, useState} from 'react';\n\nexport interface SliderState {\n /**\n * Values managed by the slider by thumb index.\n */\n readonly values: number[],\n /**\n * Get the value for the specified thumb.\n * @param index\n */\n getThumbValue(index: number): number,\n\n /**\n * Sets the value for the specified thumb.\n * The actual value set will be clamped and rounded according to min/max/step.\n * @param index\n * @param value\n */\n setThumbValue(index: number, value: number): void,\n\n /**\n * Sets value for the specified thumb by percent offset (between 0 and 1).\n * @param index\n * @param percent\n */\n setThumbPercent(index: number, percent: number): void,\n\n /**\n * Whether the specific thumb is being dragged.\n * @param index\n */\n isThumbDragging(index: number): boolean,\n /**\n * Set is dragging on the specified thumb.\n * @param index\n * @param dragging\n */\n setThumbDragging(index: number, dragging: boolean): void,\n\n /**\n * Currently-focused thumb index.\n */\n readonly focusedThumb: number | undefined,\n /**\n * Set focused true on specified thumb. This will remove focus from\n * any thumb that had it before.\n * @param index\n */\n setFocusedThumb(index: number | undefined): void,\n\n /**\n * Returns the specified thumb's value as a percentage from 0 to 1.\n * @param index\n */\n getThumbPercent(index: number): number,\n\n /**\n * Returns the value as a percent between the min and max of the slider.\n * @param index\n */\n getValuePercent(value: number): number,\n\n /**\n * Returns the string label for the specified thumb's value, per props.formatOptions.\n * @param index\n */\n getThumbValueLabel(index: number): string,\n\n /**\n * Returns the string label for the value, per props.formatOptions.\n * @param index\n */\n getFormattedValue(value: number): string,\n\n /**\n * Returns the min allowed value for the specified thumb.\n * @param index\n */\n getThumbMinValue(index: number): number,\n\n /**\n * Returns the max allowed value for the specified thumb.\n * @param index\n */\n getThumbMaxValue(index: number): number,\n\n /**\n * Converts a percent along track (between 0 and 1) to the corresponding value.\n * @param percent\n */\n getPercentValue(percent: number): number,\n\n /**\n * Returns if the specified thumb is editable.\n * @param index\n */\n isThumbEditable(index: number): boolean,\n\n /**\n * Set the specified thumb's editable state.\n * @param index\n * @param editable\n */\n setThumbEditable(index: number, editable: boolean): void,\n\n /**\n * The step amount for the slider.\n */\n readonly step: number\n}\n\nconst DEFAULT_MIN_VALUE = 0;\nconst DEFAULT_MAX_VALUE = 100;\nconst DEFAULT_STEP_VALUE = 1;\n\ninterface SliderStateOptions extends SliderProps {\n numberFormatter: Intl.NumberFormat\n}\n\n/**\n * Provides state management for a slider component. Stores values for all thumbs,\n * formats values for localization, and provides methods to update the position\n * of any thumbs.\n * @param props\n */\nexport function useSliderState(props: SliderStateOptions): SliderState {\n const {isDisabled, minValue = DEFAULT_MIN_VALUE, maxValue = DEFAULT_MAX_VALUE, numberFormatter: formatter, step = DEFAULT_STEP_VALUE} = props;\n\n const [values, setValues] = useControlledState<number[]>(\n props.value as any,\n props.defaultValue ?? [minValue] as any,\n props.onChange as any\n );\n const [isDraggings, setDraggings] = useState<boolean[]>(new Array(values.length).fill(false));\n const isEditablesRef = useRef<boolean[]>(new Array(values.length).fill(true));\n const [focusedIndex, setFocusedIndex] = useState<number | undefined>(undefined);\n\n const valuesRef = useRef<number[]>(null);\n valuesRef.current = values;\n const isDraggingsRef = useRef<boolean[]>(null);\n isDraggingsRef.current = isDraggings;\n\n function getValuePercent(value: number) {\n return (value - minValue) / (maxValue - minValue);\n }\n\n function getThumbMinValue(index: number) {\n return index === 0 ? minValue : values[index - 1];\n }\n function getThumbMaxValue(index: number) {\n return index === values.length - 1 ? maxValue : values[index + 1];\n }\n\n function isThumbEditable(index: number) {\n return isEditablesRef.current[index];\n }\n\n function setThumbEditable(index: number, editable: boolean) {\n isEditablesRef.current[index] = editable;\n }\n\n function updateValue(index: number, value: number) {\n if (isDisabled || !isThumbEditable(index)) {\n return;\n }\n const thisMin = getThumbMinValue(index);\n const thisMax = getThumbMaxValue(index);\n\n // Round value to multiple of step, clamp value between min and max\n value = snapValueToStep(value, thisMin, thisMax, step);\n valuesRef.current = replaceIndex(valuesRef.current, index, value);\n setValues(valuesRef.current);\n }\n\n function updateDragging(index: number, dragging: boolean) {\n if (isDisabled || !isThumbEditable(index)) {\n return;\n }\n\n const wasDragging = isDraggingsRef.current[index];\n isDraggingsRef.current = replaceIndex(isDraggingsRef.current, index, dragging);\n setDraggings(isDraggingsRef.current);\n\n // Call onChangeEnd if no handles are dragging.\n if (props.onChangeEnd && wasDragging && !isDraggingsRef.current.some(Boolean)) {\n props.onChangeEnd(valuesRef.current);\n }\n }\n\n function getFormattedValue(value: number) {\n return formatter.format(value);\n }\n\n function setThumbPercent(index: number, percent: number) {\n updateValue(index, getPercentValue(percent));\n }\n\n function getRoundedValue(value: number) {\n return Math.round((value - minValue) / step) * step + minValue;\n }\n\n function getPercentValue(percent: number) {\n const val = percent * (maxValue - minValue) + minValue;\n return clamp(getRoundedValue(val), minValue, maxValue);\n }\n\n return {\n values: values,\n getThumbValue: (index: number) => values[index],\n setThumbValue: updateValue,\n setThumbPercent,\n isThumbDragging: (index: number) => isDraggings[index],\n setThumbDragging: updateDragging,\n focusedThumb: focusedIndex,\n setFocusedThumb: setFocusedIndex,\n getThumbPercent: (index: number) => getValuePercent(values[index]),\n getValuePercent,\n getThumbValueLabel: (index: number) => getFormattedValue(values[index]),\n getFormattedValue,\n getThumbMinValue,\n getThumbMaxValue,\n getPercentValue,\n isThumbEditable,\n setThumbEditable,\n step\n };\n}\n\nfunction replaceIndex<T>(array: T[], index: number, value: T) {\n if (array[index] === value) {\n return array;\n }\n\n return [...array.slice(0, index), value, ...array.slice(index + 1)];\n}\n"],"names":["DEFAULT_MIN_VALUE","DEFAULT_MAX_VALUE","DEFAULT_STEP_VALUE","useSliderState","props","isDisabled","minValue","maxValue","numberFormatter","formatter","step","values","setValues","useControlledState","value","defaultValue","onChange","isDraggings","setDraggings","useState","Array","length","fill","isEditablesRef","useRef","focusedIndex","setFocusedIndex","undefined","valuesRef","current","isDraggingsRef","getValuePercent","getThumbMinValue","index","getThumbMaxValue","isThumbEditable","setThumbEditable","editable","updateValue","thisMin","thisMax","snapValueToStep","replaceIndex","updateDragging","dragging","wasDragging","onChangeEnd","some","Boolean","getFormattedValue","format","setThumbPercent","percent","getPercentValue","getRoundedValue","Math","round","val","clamp","getThumbValue","setThumbValue","isThumbDragging","setThumbDragging","focusedThumb","setFocusedThumb","getThumbPercent","getThumbValueLabel","array","slice"],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC+HA,KAAK,CAAC,uCAAiB,GAAG,CAAC;AAC3B,KAAK,CAAC,uCAAiB,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KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK;QAAG,KAAK;WAAK,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC;IAAC,CAAC;AACrE,CAAC","sources":["packages/@react-stately/slider/src/index.ts","packages/@react-stately/slider/src/useSliderState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useSliderState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {clamp, snapValueToStep} from '@react-aria/utils';\nimport {SliderProps} from '@react-types/slider';\nimport {useControlledState} from '@react-stately/utils';\nimport {useRef, useState} from 'react';\n\nexport interface SliderState {\n /**\n * Values managed by the slider by thumb index.\n */\n readonly values: number[],\n /**\n * Get the value for the specified thumb.\n * @param index\n */\n getThumbValue(index: number): number,\n\n /**\n * Sets the value for the specified thumb.\n * The actual value set will be clamped and rounded according to min/max/step.\n * @param index\n * @param value\n */\n setThumbValue(index: number, value: number): void,\n\n /**\n * Sets value for the specified thumb by percent offset (between 0 and 1).\n * @param index\n * @param percent\n */\n setThumbPercent(index: number, percent: number): void,\n\n /**\n * Whether the specific thumb is being dragged.\n * @param index\n */\n isThumbDragging(index: number): boolean,\n /**\n * Set is dragging on the specified thumb.\n * @param index\n * @param dragging\n */\n setThumbDragging(index: number, dragging: boolean): void,\n\n /**\n * Currently-focused thumb index.\n */\n readonly focusedThumb: number | undefined,\n /**\n * Set focused true on specified thumb. This will remove focus from\n * any thumb that had it before.\n * @param index\n */\n setFocusedThumb(index: number | undefined): void,\n\n /**\n * Returns the specified thumb's value as a percentage from 0 to 1.\n * @param index\n */\n getThumbPercent(index: number): number,\n\n /**\n * Returns the value as a percent between the min and max of the slider.\n * @param index\n */\n getValuePercent(value: number): number,\n\n /**\n * Returns the string label for the specified thumb's value, per props.formatOptions.\n * @param index\n */\n getThumbValueLabel(index: number): string,\n\n /**\n * Returns the string label for the value, per props.formatOptions.\n * @param index\n */\n getFormattedValue(value: number): string,\n\n /**\n * Returns the min allowed value for the specified thumb.\n * @param index\n */\n getThumbMinValue(index: number): number,\n\n /**\n * Returns the max allowed value for the specified thumb.\n * @param index\n */\n getThumbMaxValue(index: number): number,\n\n /**\n * Converts a percent along track (between 0 and 1) to the corresponding value.\n * @param percent\n */\n getPercentValue(percent: number): number,\n\n /**\n * Returns if the specified thumb is editable.\n * @param index\n */\n isThumbEditable(index: number): boolean,\n\n /**\n * Set the specified thumb's editable state.\n * @param index\n * @param editable\n */\n setThumbEditable(index: number, editable: boolean): void,\n\n /**\n * The step amount for the slider.\n */\n readonly step: number\n}\n\nconst DEFAULT_MIN_VALUE = 0;\nconst DEFAULT_MAX_VALUE = 100;\nconst DEFAULT_STEP_VALUE = 1;\n\ninterface SliderStateOptions extends SliderProps {\n numberFormatter: Intl.NumberFormat\n}\n\n/**\n * Provides state management for a slider component. Stores values for all thumbs,\n * formats values for localization, and provides methods to update the position\n * of any thumbs.\n * @param props\n */\nexport function useSliderState(props: SliderStateOptions): SliderState {\n const {isDisabled, minValue = DEFAULT_MIN_VALUE, maxValue = DEFAULT_MAX_VALUE, numberFormatter: formatter, step = DEFAULT_STEP_VALUE} = props;\n\n const [values, setValues] = useControlledState<number[]>(\n props.value as any,\n props.defaultValue ?? [minValue] as any,\n props.onChange as any\n );\n const [isDraggings, setDraggings] = useState<boolean[]>(new Array(values.length).fill(false));\n const isEditablesRef = useRef<boolean[]>(new Array(values.length).fill(true));\n const [focusedIndex, setFocusedIndex] = useState<number | undefined>(undefined);\n\n const valuesRef = useRef<number[]>(null);\n valuesRef.current = values;\n const isDraggingsRef = useRef<boolean[]>(null);\n isDraggingsRef.current = isDraggings;\n\n function getValuePercent(value: number) {\n return (value - minValue) / (maxValue - minValue);\n }\n\n function getThumbMinValue(index: number) {\n return index === 0 ? minValue : values[index - 1];\n }\n function getThumbMaxValue(index: number) {\n return index === values.length - 1 ? maxValue : values[index + 1];\n }\n\n function isThumbEditable(index: number) {\n return isEditablesRef.current[index];\n }\n\n function setThumbEditable(index: number, editable: boolean) {\n isEditablesRef.current[index] = editable;\n }\n\n function updateValue(index: number, value: number) {\n if (isDisabled || !isThumbEditable(index)) {\n return;\n }\n const thisMin = getThumbMinValue(index);\n const thisMax = getThumbMaxValue(index);\n\n // Round value to multiple of step, clamp value between min and max\n value = snapValueToStep(value, thisMin, thisMax, step);\n valuesRef.current = replaceIndex(valuesRef.current, index, value);\n setValues(valuesRef.current);\n }\n\n function updateDragging(index: number, dragging: boolean) {\n if (isDisabled || !isThumbEditable(index)) {\n return;\n }\n\n const wasDragging = isDraggingsRef.current[index];\n isDraggingsRef.current = replaceIndex(isDraggingsRef.current, index, dragging);\n setDraggings(isDraggingsRef.current);\n\n // Call onChangeEnd if no handles are dragging.\n if (props.onChangeEnd && wasDragging && !isDraggingsRef.current.some(Boolean)) {\n props.onChangeEnd(valuesRef.current);\n }\n }\n\n function getFormattedValue(value: number) {\n return formatter.format(value);\n }\n\n function setThumbPercent(index: number, percent: number) {\n updateValue(index, getPercentValue(percent));\n }\n\n function getRoundedValue(value: number) {\n return Math.round((value - minValue) / step) * step + minValue;\n }\n\n function getPercentValue(percent: number) {\n const val = percent * (maxValue - minValue) + minValue;\n return clamp(getRoundedValue(val), minValue, maxValue);\n }\n\n return {\n values: values,\n getThumbValue: (index: number) => values[index],\n setThumbValue: updateValue,\n setThumbPercent,\n isThumbDragging: (index: number) => isDraggings[index],\n setThumbDragging: updateDragging,\n focusedThumb: focusedIndex,\n setFocusedThumb: setFocusedIndex,\n getThumbPercent: (index: number) => getValuePercent(values[index]),\n getValuePercent,\n getThumbValueLabel: (index: number) => getFormattedValue(values[index]),\n getFormattedValue,\n getThumbMinValue,\n getThumbMaxValue,\n getPercentValue,\n isThumbEditable,\n setThumbEditable,\n step\n };\n}\n\nfunction replaceIndex<T>(array: T[], index: number, value: T) {\n if (array[index] === value) {\n return array;\n }\n\n return [...array.slice(0, index), value, ...array.slice(index + 1)];\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,126 +1,112 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useControlledState
|
|
3
|
-
import {
|
|
4
|
-
const $dcc38d2f5fc04b76254f325fa36d$var$DEFAULT_MIN_VALUE = 0;
|
|
5
|
-
const $dcc38d2f5fc04b76254f325fa36d$var$DEFAULT_MAX_VALUE = 100;
|
|
6
|
-
const $dcc38d2f5fc04b76254f325fa36d$var$DEFAULT_STEP_VALUE = 1;
|
|
1
|
+
import {snapValueToStep as $9LrbI$snapValueToStep, clamp as $9LrbI$clamp} from "@react-aria/utils";
|
|
2
|
+
import {useControlledState as $9LrbI$useControlledState} from "@react-stately/utils";
|
|
3
|
+
import {useState as $9LrbI$useState, useRef as $9LrbI$useRef} from "react";
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
numberFormatter: formatter,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return (value - minValue) / (maxValue - minValue);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function getThumbMinValue(index) {
|
|
38
|
-
return index === 0 ? minValue : values[index - 1];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function getThumbMaxValue(index) {
|
|
42
|
-
return index === values.length - 1 ? maxValue : values[index + 1];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function isThumbEditable(index) {
|
|
46
|
-
return isEditablesRef.current[index];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function setThumbEditable(index, editable) {
|
|
50
|
-
isEditablesRef.current[index] = editable;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function updateValue(index, value) {
|
|
54
|
-
if (isDisabled || !isThumbEditable(index)) {
|
|
55
|
-
return;
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
var $bc616ccd4b00f45f$exports = {};
|
|
9
|
+
|
|
10
|
+
$parcel$export($bc616ccd4b00f45f$exports, "useSliderState", () => $bc616ccd4b00f45f$export$e5fda3247f5d67f9);
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const $bc616ccd4b00f45f$var$DEFAULT_MIN_VALUE = 0;
|
|
15
|
+
const $bc616ccd4b00f45f$var$DEFAULT_MAX_VALUE = 100;
|
|
16
|
+
const $bc616ccd4b00f45f$var$DEFAULT_STEP_VALUE = 1;
|
|
17
|
+
function $bc616ccd4b00f45f$export$e5fda3247f5d67f9(props) {
|
|
18
|
+
const { isDisabled: isDisabled , minValue: minValue = $bc616ccd4b00f45f$var$DEFAULT_MIN_VALUE , maxValue: maxValue = $bc616ccd4b00f45f$var$DEFAULT_MAX_VALUE , numberFormatter: formatter , step: step = $bc616ccd4b00f45f$var$DEFAULT_STEP_VALUE } = props;
|
|
19
|
+
const [values, setValues] = $9LrbI$useControlledState(props.value, props.defaultValue ?? [
|
|
20
|
+
minValue
|
|
21
|
+
], props.onChange);
|
|
22
|
+
const [isDraggings, setDraggings] = $9LrbI$useState(new Array(values.length).fill(false));
|
|
23
|
+
const isEditablesRef = $9LrbI$useRef(new Array(values.length).fill(true));
|
|
24
|
+
const [focusedIndex, setFocusedIndex] = $9LrbI$useState(undefined);
|
|
25
|
+
const valuesRef = $9LrbI$useRef(null);
|
|
26
|
+
valuesRef.current = values;
|
|
27
|
+
const isDraggingsRef = $9LrbI$useRef(null);
|
|
28
|
+
isDraggingsRef.current = isDraggings;
|
|
29
|
+
function getValuePercent(value) {
|
|
30
|
+
return (value - minValue) / (maxValue - minValue);
|
|
56
31
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const thisMax = getThumbMaxValue(index); // Round value to multiple of step, clamp value between min and max
|
|
60
|
-
|
|
61
|
-
value = snapValueToStep(value, thisMin, thisMax, step);
|
|
62
|
-
valuesRef.current = $dcc38d2f5fc04b76254f325fa36d$var$replaceIndex(valuesRef.current, index, value);
|
|
63
|
-
setValues(valuesRef.current);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function updateDragging(index, dragging) {
|
|
67
|
-
if (isDisabled || !isThumbEditable(index)) {
|
|
68
|
-
return;
|
|
32
|
+
function getThumbMinValue(index) {
|
|
33
|
+
return index === 0 ? minValue : values[index - 1];
|
|
69
34
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
isDraggingsRef.current = $dcc38d2f5fc04b76254f325fa36d$var$replaceIndex(isDraggingsRef.current, index, dragging);
|
|
73
|
-
setDraggings(isDraggingsRef.current); // Call onChangeEnd if no handles are dragging.
|
|
74
|
-
|
|
75
|
-
if (props.onChangeEnd && wasDragging && !isDraggingsRef.current.some(Boolean)) {
|
|
76
|
-
props.onChangeEnd(valuesRef.current);
|
|
35
|
+
function getThumbMaxValue(index) {
|
|
36
|
+
return index === values.length - 1 ? maxValue : values[index + 1];
|
|
77
37
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
38
|
+
function isThumbEditable(index) {
|
|
39
|
+
return isEditablesRef.current[index];
|
|
40
|
+
}
|
|
41
|
+
function setThumbEditable(index, editable) {
|
|
42
|
+
isEditablesRef.current[index] = editable;
|
|
43
|
+
}
|
|
44
|
+
function updateValue(index, value) {
|
|
45
|
+
if (isDisabled || !isThumbEditable(index)) return;
|
|
46
|
+
const thisMin = getThumbMinValue(index);
|
|
47
|
+
const thisMax = getThumbMaxValue(index);
|
|
48
|
+
// Round value to multiple of step, clamp value between min and max
|
|
49
|
+
value = $9LrbI$snapValueToStep(value, thisMin, thisMax, step);
|
|
50
|
+
valuesRef.current = $bc616ccd4b00f45f$var$replaceIndex(valuesRef.current, index, value);
|
|
51
|
+
setValues(valuesRef.current);
|
|
52
|
+
}
|
|
53
|
+
function updateDragging(index, dragging) {
|
|
54
|
+
if (isDisabled || !isThumbEditable(index)) return;
|
|
55
|
+
const wasDragging = isDraggingsRef.current[index];
|
|
56
|
+
isDraggingsRef.current = $bc616ccd4b00f45f$var$replaceIndex(isDraggingsRef.current, index, dragging);
|
|
57
|
+
setDraggings(isDraggingsRef.current);
|
|
58
|
+
// Call onChangeEnd if no handles are dragging.
|
|
59
|
+
if (props.onChangeEnd && wasDragging && !isDraggingsRef.current.some(Boolean)) props.onChangeEnd(valuesRef.current);
|
|
60
|
+
}
|
|
61
|
+
function getFormattedValue(value) {
|
|
62
|
+
return formatter.format(value);
|
|
63
|
+
}
|
|
64
|
+
function setThumbPercent(index, percent) {
|
|
65
|
+
updateValue(index, getPercentValue(percent));
|
|
66
|
+
}
|
|
67
|
+
function getRoundedValue(value) {
|
|
68
|
+
return Math.round((value - minValue) / step) * step + minValue;
|
|
69
|
+
}
|
|
70
|
+
function getPercentValue(percent) {
|
|
71
|
+
const val = percent * (maxValue - minValue) + minValue;
|
|
72
|
+
return $9LrbI$clamp(getRoundedValue(val), minValue, maxValue);
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
values: values,
|
|
76
|
+
getThumbValue: (index)=>values[index]
|
|
77
|
+
,
|
|
78
|
+
setThumbValue: updateValue,
|
|
79
|
+
setThumbPercent: setThumbPercent,
|
|
80
|
+
isThumbDragging: (index)=>isDraggings[index]
|
|
81
|
+
,
|
|
82
|
+
setThumbDragging: updateDragging,
|
|
83
|
+
focusedThumb: focusedIndex,
|
|
84
|
+
setFocusedThumb: setFocusedIndex,
|
|
85
|
+
getThumbPercent: (index)=>getValuePercent(values[index])
|
|
86
|
+
,
|
|
87
|
+
getValuePercent: getValuePercent,
|
|
88
|
+
getThumbValueLabel: (index)=>getFormattedValue(values[index])
|
|
89
|
+
,
|
|
90
|
+
getFormattedValue: getFormattedValue,
|
|
91
|
+
getThumbMinValue: getThumbMinValue,
|
|
92
|
+
getThumbMaxValue: getThumbMaxValue,
|
|
93
|
+
getPercentValue: getPercentValue,
|
|
94
|
+
isThumbEditable: isThumbEditable,
|
|
95
|
+
setThumbEditable: setThumbEditable,
|
|
96
|
+
step: step
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function $bc616ccd4b00f45f$var$replaceIndex(array, index, value) {
|
|
100
|
+
if (array[index] === value) return array;
|
|
101
|
+
return [
|
|
102
|
+
...array.slice(0, index),
|
|
103
|
+
value,
|
|
104
|
+
...array.slice(index + 1)
|
|
105
|
+
];
|
|
106
|
+
}
|
|
91
107
|
|
|
92
|
-
function getPercentValue(percent) {
|
|
93
|
-
const val = percent * (maxValue - minValue) + minValue;
|
|
94
|
-
return clamp(getRoundedValue(val), minValue, maxValue);
|
|
95
|
-
}
|
|
96
108
|
|
|
97
|
-
return {
|
|
98
|
-
values: values,
|
|
99
|
-
getThumbValue: index => values[index],
|
|
100
|
-
setThumbValue: updateValue,
|
|
101
|
-
setThumbPercent,
|
|
102
|
-
isThumbDragging: index => isDraggings[index],
|
|
103
|
-
setThumbDragging: updateDragging,
|
|
104
|
-
focusedThumb: focusedIndex,
|
|
105
|
-
setFocusedThumb: setFocusedIndex,
|
|
106
|
-
getThumbPercent: index => getValuePercent(values[index]),
|
|
107
|
-
getValuePercent,
|
|
108
|
-
getThumbValueLabel: index => getFormattedValue(values[index]),
|
|
109
|
-
getFormattedValue,
|
|
110
|
-
getThumbMinValue,
|
|
111
|
-
getThumbMaxValue,
|
|
112
|
-
getPercentValue,
|
|
113
|
-
isThumbEditable,
|
|
114
|
-
setThumbEditable,
|
|
115
|
-
step
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
109
|
|
|
119
|
-
function $dcc38d2f5fc04b76254f325fa36d$var$replaceIndex(array, index, value) {
|
|
120
|
-
if (array[index] === value) {
|
|
121
|
-
return array;
|
|
122
|
-
}
|
|
123
110
|
|
|
124
|
-
|
|
125
|
-
}
|
|
111
|
+
export {$bc616ccd4b00f45f$export$e5fda3247f5d67f9 as useSliderState};
|
|
126
112
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AA+HA,MAAMA,mDAAiB,GAAG,CAA1B;AACA,MAAMC,mDAAiB,GAAG,GAA1B;AACA,MAAMC,oDAAkB,GAAG,CAA3B;;AAMA;;;;;;OAMO,SAASC,cAAT,CAAwBC,KAAxB,EAAgE;AAAA;;AACrE,QAAM;AAACC,IAAAA,UAAD;AAAaC,IAAAA,QAAQ,GAAGN,mDAAxB;AAA2CO,IAAAA,QAAQ,GAAGN,mDAAtD;AAAyEO,IAAAA,eAAe,EAAEC,SAA1F;AAAqGC,IAAAA,IAAI,GAAGR;AAA5G,MAAkIE,KAAxI;AAEA,QAAM,CAACO,MAAD,EAASC,SAAT,IAAsBC,kBAAkB,CAC5CT,KAA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AAA,eAhBK;AAiBLC,IAAAA,gBAjBK;AAkBL1B,IAAAA;AAlBK,GAAP;AAoBD;;AAED,SAASgC,8CAAT,CAAyByB,KAAzB,EAAqClC,KAArC,EAAoDnB,KAApD,EAA8D;AAC5D,MAAIqD,KAAK,CAAClC,KAAD,CAAL,KAAiBnB,KAArB,EAA4B;AAC1B,WAAOqD,KAAP;AACD;;AAED,SAAO,CAAC,GAAGA,KAAK,CAACC,KAAN,CAAY,CAAZ,EAAenC,KAAf,CAAJ,EAA2BnB,KAA3B,EAAkC,GAAGqD,KAAK,CAACC,KAAN,CAAYnC,KAAK,GAAG,CAApB,CAArC,CAAP;AACD","sources":["./packages/@react-stately/slider/src/useSliderState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {clamp, snapValueToStep} from '@react-aria/utils';\nimport {SliderProps} from '@react-types/slider';\nimport {useControlledState} from '@react-stately/utils';\nimport {useRef, useState} from 'react';\n\nexport interface SliderState {\n /**\n * Values managed by the slider by thumb index.\n */\n readonly values: number[],\n /**\n * Get the value for the specified thumb.\n * @param index\n */\n getThumbValue(index: number): number,\n\n /**\n * Sets the value for the specified thumb.\n * The actual value set will be clamped and rounded according to min/max/step.\n * @param index\n * @param value\n */\n setThumbValue(index: number, value: number): void,\n\n /**\n * Sets value for the specified thumb by percent offset (between 0 and 1).\n * @param index\n * @param percent\n */\n setThumbPercent(index: number, percent: number): void,\n\n /**\n * Whether the specific thumb is being dragged.\n * @param index\n */\n isThumbDragging(index: number): boolean,\n /**\n * Set is dragging on the specified thumb.\n * @param index\n * @param dragging\n */\n setThumbDragging(index: number, dragging: boolean): void,\n\n /**\n * Currently-focused thumb index.\n */\n readonly focusedThumb: number | undefined,\n /**\n * Set focused true on specified thumb. This will remove focus from\n * any thumb that had it before.\n * @param index\n */\n setFocusedThumb(index: number | undefined): void,\n\n /**\n * Returns the specified thumb's value as a percentage from 0 to 1.\n * @param index\n */\n getThumbPercent(index: number): number,\n\n /**\n * Returns the value as a percent between the min and max of the slider.\n * @param index\n */\n getValuePercent(value: number): number,\n\n /**\n * Returns the string label for the specified thumb's value, per props.formatOptions.\n * @param index\n */\n getThumbValueLabel(index: number): string,\n\n /**\n * Returns the string label for the value, per props.formatOptions.\n * @param index\n */\n getFormattedValue(value: number): string,\n\n /**\n * Returns the min allowed value for the specified thumb.\n * @param index\n */\n getThumbMinValue(index: number): number,\n\n /**\n * Returns the max allowed value for the specified thumb.\n * @param index\n */\n getThumbMaxValue(index: number): number,\n\n /**\n * Converts a percent along track (between 0 and 1) to the corresponding value.\n * @param percent\n */\n getPercentValue(percent: number): number,\n\n /**\n * Returns if the specified thumb is editable.\n * @param index\n */\n isThumbEditable(index: number): boolean,\n\n /**\n * Set the specified thumb's editable state.\n * @param index\n * @param editable\n */\n setThumbEditable(index: number, editable: boolean): void,\n\n /**\n * The step amount for the slider.\n */\n readonly step: number\n}\n\nconst DEFAULT_MIN_VALUE = 0;\nconst DEFAULT_MAX_VALUE = 100;\nconst DEFAULT_STEP_VALUE = 1;\n\ninterface SliderStateOptions extends SliderProps {\n numberFormatter: Intl.NumberFormat\n}\n\n/**\n * Provides state management for a slider component. Stores values for all thumbs,\n * formats values for localization, and provides methods to update the position\n * of any thumbs.\n * @param props\n */\nexport function useSliderState(props: SliderStateOptions): SliderState {\n const {isDisabled, minValue = DEFAULT_MIN_VALUE, maxValue = DEFAULT_MAX_VALUE, numberFormatter: formatter, step = DEFAULT_STEP_VALUE} = props;\n\n const [values, setValues] = useControlledState<number[]>(\n props.value as any,\n props.defaultValue ?? [minValue] as any,\n props.onChange as any\n );\n const [isDraggings, setDraggings] = useState<boolean[]>(new Array(values.length).fill(false));\n const isEditablesRef = useRef<boolean[]>(new Array(values.length).fill(true));\n const [focusedIndex, setFocusedIndex] = useState<number | undefined>(undefined);\n\n const valuesRef = useRef<number[]>(null);\n valuesRef.current = values;\n const isDraggingsRef = useRef<boolean[]>(null);\n isDraggingsRef.current = isDraggings;\n\n function getValuePercent(value: number) {\n return (value - minValue) / (maxValue - minValue);\n }\n\n function getThumbMinValue(index: number) {\n return index === 0 ? minValue : values[index - 1];\n }\n function getThumbMaxValue(index: number) {\n return index === values.length - 1 ? maxValue : values[index + 1];\n }\n\n function isThumbEditable(index: number) {\n return isEditablesRef.current[index];\n }\n\n function setThumbEditable(index: number, editable: boolean) {\n isEditablesRef.current[index] = editable;\n }\n\n function updateValue(index: number, value: number) {\n if (isDisabled || !isThumbEditable(index)) {\n return;\n }\n const thisMin = getThumbMinValue(index);\n const thisMax = getThumbMaxValue(index);\n\n // Round value to multiple of step, clamp value between min and max\n value = snapValueToStep(value, thisMin, thisMax, step);\n valuesRef.current = replaceIndex(valuesRef.current, index, value);\n setValues(valuesRef.current);\n }\n\n function updateDragging(index: number, dragging: boolean) {\n if (isDisabled || !isThumbEditable(index)) {\n return;\n }\n\n const wasDragging = isDraggingsRef.current[index];\n isDraggingsRef.current = replaceIndex(isDraggingsRef.current, index, dragging);\n setDraggings(isDraggingsRef.current);\n\n // Call onChangeEnd if no handles are dragging.\n if (props.onChangeEnd && wasDragging && !isDraggingsRef.current.some(Boolean)) {\n props.onChangeEnd(valuesRef.current);\n }\n }\n\n function getFormattedValue(value: number) {\n return formatter.format(value);\n }\n\n function setThumbPercent(index: number, percent: number) {\n updateValue(index, getPercentValue(percent));\n }\n\n function getRoundedValue(value: number) {\n return Math.round((value - minValue) / step) * step + minValue;\n }\n\n function getPercentValue(percent: number) {\n const val = percent * (maxValue - minValue) + minValue;\n return clamp(getRoundedValue(val), minValue, maxValue);\n }\n\n return {\n values: values,\n getThumbValue: (index: number) => values[index],\n setThumbValue: updateValue,\n setThumbPercent,\n isThumbDragging: (index: number) => isDraggings[index],\n setThumbDragging: updateDragging,\n focusedThumb: focusedIndex,\n setFocusedThumb: setFocusedIndex,\n getThumbPercent: (index: number) => getValuePercent(values[index]),\n getValuePercent,\n getThumbValueLabel: (index: number) => getFormattedValue(values[index]),\n getFormattedValue,\n getThumbMinValue,\n getThumbMaxValue,\n getPercentValue,\n isThumbEditable,\n setThumbEditable,\n step\n };\n}\n\nfunction replaceIndex<T>(array: T[], index: number, value: T) {\n if (array[index] === value) {\n return array;\n }\n\n return [...array.slice(0, index), value, ...array.slice(index + 1)];\n}\n"],"names":["DEFAULT_MIN_VALUE","DEFAULT_MAX_VALUE","DEFAULT_STEP_VALUE","useSliderState","props","isDisabled","minValue","maxValue","numberFormatter","formatter","step","values","setValues","useControlledState","value","defaultValue","onChange","isDraggings","setDraggings","useState","Array","length","fill","isEditablesRef","useRef","focusedIndex","setFocusedIndex","undefined","valuesRef","current","isDraggingsRef","getValuePercent","getThumbMinValue","index","getThumbMaxValue","isThumbEditable","setThumbEditable","editable","updateValue","thisMin","thisMax","snapValueToStep","replaceIndex","updateDragging","dragging","wasDragging","onChangeEnd","some","Boolean","getFormattedValue","format","setThumbPercent","percent","getPercentValue","getRoundedValue","Math","round","val","clamp","getThumbValue","setThumbValue","isThumbDragging","setThumbDragging","focusedThumb","setFocusedThumb","getThumbPercent","getThumbValueLabel","array","slice"],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AC+HA,KAAK,CAAC,uCAAiB,GAAG,CAAC;AAC3B,KAAK,CAAC,uCAAiB,GAAG,GAAG;AAC7B,KAAK,CAAC,wCAAkB,GAAG,CAAC;SAYZ,yCAAc,CAAC,KAAyB,EAAe,CAAC;IACtE,KAAK,CAAC,CAAC,aAAA,UAAU,aAAE,QAAQ,GAAG,uCAAiB,aAAE,QAAQ,GAAG,uCAAiB,GAAE,eAAe,EAAE,SA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adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useSliderState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {clamp, snapValueToStep} from '@react-aria/utils';\nimport {SliderProps} from '@react-types/slider';\nimport {useControlledState} from '@react-stately/utils';\nimport {useRef, useState} from 'react';\n\nexport interface SliderState {\n /**\n * Values managed by the slider by thumb index.\n */\n readonly values: number[],\n /**\n * Get the value for the specified thumb.\n * @param index\n */\n getThumbValue(index: number): number,\n\n /**\n * Sets the value for the specified thumb.\n * The actual value set will be clamped and rounded according to min/max/step.\n * @param index\n * @param value\n */\n setThumbValue(index: number, value: number): void,\n\n /**\n * Sets value for the specified thumb by percent offset (between 0 and 1).\n * @param index\n * @param percent\n */\n setThumbPercent(index: number, percent: number): void,\n\n /**\n * Whether the specific thumb is being dragged.\n * @param index\n */\n isThumbDragging(index: number): boolean,\n /**\n * Set is dragging on the specified thumb.\n * @param index\n * @param dragging\n */\n setThumbDragging(index: number, dragging: boolean): void,\n\n /**\n * Currently-focused thumb index.\n */\n readonly focusedThumb: number | undefined,\n /**\n * Set focused true on specified thumb. This will remove focus from\n * any thumb that had it before.\n * @param index\n */\n setFocusedThumb(index: number | undefined): void,\n\n /**\n * Returns the specified thumb's value as a percentage from 0 to 1.\n * @param index\n */\n getThumbPercent(index: number): number,\n\n /**\n * Returns the value as a percent between the min and max of the slider.\n * @param index\n */\n getValuePercent(value: number): number,\n\n /**\n * Returns the string label for the specified thumb's value, per props.formatOptions.\n * @param index\n */\n getThumbValueLabel(index: number): string,\n\n /**\n * Returns the string label for the value, per props.formatOptions.\n * @param index\n */\n getFormattedValue(value: number): string,\n\n /**\n * Returns the min allowed value for the specified thumb.\n * @param index\n */\n getThumbMinValue(index: number): number,\n\n /**\n * Returns the max allowed value for the specified thumb.\n * @param index\n */\n getThumbMaxValue(index: number): number,\n\n /**\n * Converts a percent along track (between 0 and 1) to the corresponding value.\n * @param percent\n */\n getPercentValue(percent: number): number,\n\n /**\n * Returns if the specified thumb is editable.\n * @param index\n */\n isThumbEditable(index: number): boolean,\n\n /**\n * Set the specified thumb's editable state.\n * @param index\n * @param editable\n */\n setThumbEditable(index: number, editable: boolean): void,\n\n /**\n * The step amount for the slider.\n */\n readonly step: number\n}\n\nconst DEFAULT_MIN_VALUE = 0;\nconst DEFAULT_MAX_VALUE = 100;\nconst DEFAULT_STEP_VALUE = 1;\n\ninterface SliderStateOptions extends SliderProps {\n numberFormatter: Intl.NumberFormat\n}\n\n/**\n * Provides state management for a slider component. Stores values for all thumbs,\n * formats values for localization, and provides methods to update the position\n * of any thumbs.\n * @param props\n */\nexport function useSliderState(props: SliderStateOptions): SliderState {\n const {isDisabled, minValue = DEFAULT_MIN_VALUE, maxValue = DEFAULT_MAX_VALUE, numberFormatter: formatter, step = DEFAULT_STEP_VALUE} = props;\n\n const [values, setValues] = useControlledState<number[]>(\n props.value as any,\n props.defaultValue ?? [minValue] as any,\n props.onChange as any\n );\n const [isDraggings, setDraggings] = useState<boolean[]>(new Array(values.length).fill(false));\n const isEditablesRef = useRef<boolean[]>(new Array(values.length).fill(true));\n const [focusedIndex, setFocusedIndex] = useState<number | undefined>(undefined);\n\n const valuesRef = useRef<number[]>(null);\n valuesRef.current = values;\n const isDraggingsRef = useRef<boolean[]>(null);\n isDraggingsRef.current = isDraggings;\n\n function getValuePercent(value: number) {\n return (value - minValue) / (maxValue - minValue);\n }\n\n function getThumbMinValue(index: number) {\n return index === 0 ? minValue : values[index - 1];\n }\n function getThumbMaxValue(index: number) {\n return index === values.length - 1 ? maxValue : values[index + 1];\n }\n\n function isThumbEditable(index: number) {\n return isEditablesRef.current[index];\n }\n\n function setThumbEditable(index: number, editable: boolean) {\n isEditablesRef.current[index] = editable;\n }\n\n function updateValue(index: number, value: number) {\n if (isDisabled || !isThumbEditable(index)) {\n return;\n }\n const thisMin = getThumbMinValue(index);\n const thisMax = getThumbMaxValue(index);\n\n // Round value to multiple of step, clamp value between min and max\n value = snapValueToStep(value, thisMin, thisMax, step);\n valuesRef.current = replaceIndex(valuesRef.current, index, value);\n setValues(valuesRef.current);\n }\n\n function updateDragging(index: number, dragging: boolean) {\n if (isDisabled || !isThumbEditable(index)) {\n return;\n }\n\n const wasDragging = isDraggingsRef.current[index];\n isDraggingsRef.current = replaceIndex(isDraggingsRef.current, index, dragging);\n setDraggings(isDraggingsRef.current);\n\n // Call onChangeEnd if no handles are dragging.\n if (props.onChangeEnd && wasDragging && !isDraggingsRef.current.some(Boolean)) {\n props.onChangeEnd(valuesRef.current);\n }\n }\n\n function getFormattedValue(value: number) {\n return formatter.format(value);\n }\n\n function setThumbPercent(index: number, percent: number) {\n updateValue(index, getPercentValue(percent));\n }\n\n function getRoundedValue(value: number) {\n return Math.round((value - minValue) / step) * step + minValue;\n }\n\n function getPercentValue(percent: number) {\n const val = percent * (maxValue - minValue) + minValue;\n return clamp(getRoundedValue(val), minValue, maxValue);\n }\n\n return {\n values: values,\n getThumbValue: (index: number) => values[index],\n setThumbValue: updateValue,\n setThumbPercent,\n isThumbDragging: (index: number) => isDraggings[index],\n setThumbDragging: updateDragging,\n focusedThumb: focusedIndex,\n setFocusedThumb: setFocusedIndex,\n getThumbPercent: (index: number) => getValuePercent(values[index]),\n getValuePercent,\n getThumbValueLabel: (index: number) => getFormattedValue(values[index]),\n getFormattedValue,\n getThumbMinValue,\n getThumbMaxValue,\n getPercentValue,\n isThumbEditable,\n setThumbEditable,\n step\n };\n}\n\nfunction replaceIndex<T>(array: T[], index: number, value: T) {\n if (array[index] === value) {\n return array;\n }\n\n return [...array.slice(0, index), value, ...array.slice(index + 1)];\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";AAiBA;IACE;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAErC;;;;;OAKG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAElD;;;;OAIG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtD;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IACxC;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAEzD;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C;;;;OAIG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAEjD;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAEvC;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAEvC;;;OAGG;IACH,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1C;;;OAGG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzC;;;OAGG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAExC;;;OAGG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAExC;;;OAGG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzC;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAExC;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAEzD;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAMD,4BAA6B,SAAQ,WAAW;IAC9C,eAAe,EAAE,KAAK,YAAY,CAAA;CACnC;AAED;;;;;GAKG;AACH,+BAA+B,KAAK,EAAE,kBAAkB,GAAG,WAAW,CAqGrE","sources":["packages/@react-stately/slider/src/packages/@react-stately/slider/src/useSliderState.ts","packages/@react-stately/slider/src/packages/@react-stately/slider/src/index.ts","packages/@react-stately/slider/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useSliderState';\n"],"names":[],"version":3,"file":"types.d.ts.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.3047+87960ad25",
|
|
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.1356+87960ad25",
|
|
22
|
+
"@react-aria/utils": "3.0.0-nightly.1356+87960ad25",
|
|
23
|
+
"@react-stately/utils": "3.0.0-nightly.1356+87960ad25",
|
|
24
|
+
"@react-types/slider": "3.0.3-nightly.3047+87960ad25"
|
|
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": "87960ad25c26bc4cd6af506bb5e7e0f06621556c"
|
|
33
33
|
}
|