@tamagui/slider 2.0.0-rc.4 → 2.0.0-rc.40
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/cjs/Slider.cjs +450 -429
- package/dist/cjs/Slider.native.js +452 -458
- package/dist/cjs/Slider.native.js.map +1 -1
- package/dist/cjs/SliderImpl.cjs +127 -100
- package/dist/cjs/SliderImpl.native.js +147 -117
- package/dist/cjs/SliderImpl.native.js.map +1 -1
- package/dist/cjs/constants.cjs +39 -37
- package/dist/cjs/constants.native.js +40 -38
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/helpers.cjs +32 -20
- package/dist/cjs/helpers.native.js +34 -26
- package/dist/cjs/helpers.native.js.map +1 -1
- package/dist/cjs/index.cjs +15 -13
- package/dist/cjs/index.native.js +15 -13
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +7 -5
- package/dist/cjs/types.native.js +7 -5
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/Slider.mjs +407 -395
- package/dist/esm/Slider.mjs.map +1 -1
- package/dist/esm/Slider.native.js +408 -423
- package/dist/esm/Slider.native.js.map +1 -1
- package/dist/esm/SliderImpl.mjs +95 -70
- package/dist/esm/SliderImpl.mjs.map +1 -1
- package/dist/esm/SliderImpl.native.js +115 -87
- package/dist/esm/SliderImpl.native.js.map +1 -1
- package/dist/esm/constants.mjs +27 -27
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/constants.native.js +27 -27
- package/dist/esm/constants.native.js.map +1 -1
- package/dist/esm/helpers.mjs +20 -10
- package/dist/esm/helpers.mjs.map +1 -1
- package/dist/esm/helpers.native.js +22 -16
- package/dist/esm/helpers.native.js.map +1 -1
- package/dist/esm/index.js +4 -7
- package/dist/esm/index.js.map +1 -6
- package/dist/jsx/Slider.mjs +407 -395
- package/dist/jsx/Slider.mjs.map +1 -1
- package/dist/jsx/Slider.native.js +452 -458
- package/dist/jsx/Slider.native.js.map +1 -1
- package/dist/jsx/SliderImpl.mjs +95 -70
- package/dist/jsx/SliderImpl.mjs.map +1 -1
- package/dist/jsx/SliderImpl.native.js +147 -117
- package/dist/jsx/SliderImpl.native.js.map +1 -1
- package/dist/jsx/constants.mjs +27 -27
- package/dist/jsx/constants.mjs.map +1 -1
- package/dist/jsx/constants.native.js +40 -38
- package/dist/jsx/constants.native.js.map +1 -1
- package/dist/jsx/helpers.mjs +20 -10
- package/dist/jsx/helpers.mjs.map +1 -1
- package/dist/jsx/helpers.native.js +34 -26
- package/dist/jsx/helpers.native.js.map +1 -1
- package/dist/jsx/index.js +4 -7
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +15 -13
- package/dist/jsx/types.native.js +7 -5
- package/package.json +16 -19
- package/dist/cjs/Slider.js +0 -486
- package/dist/cjs/Slider.js.map +0 -6
- package/dist/cjs/SliderImpl.js +0 -115
- package/dist/cjs/SliderImpl.js.map +0 -6
- package/dist/cjs/constants.js +0 -47
- package/dist/cjs/constants.js.map +0 -6
- package/dist/cjs/helpers.js +0 -74
- package/dist/cjs/helpers.js.map +0 -6
- package/dist/cjs/index.js +0 -23
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/types.js +0 -14
- package/dist/cjs/types.js.map +0 -6
- package/dist/esm/Slider.js +0 -499
- package/dist/esm/Slider.js.map +0 -6
- package/dist/esm/SliderImpl.js +0 -98
- package/dist/esm/SliderImpl.js.map +0 -6
- package/dist/esm/constants.js +0 -31
- package/dist/esm/constants.js.map +0 -6
- package/dist/esm/helpers.js +0 -58
- package/dist/esm/helpers.js.map +0 -6
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -6
- package/dist/jsx/Slider.js +0 -499
- package/dist/jsx/Slider.js.map +0 -6
- package/dist/jsx/SliderImpl.js +0 -98
- package/dist/jsx/SliderImpl.js.map +0 -6
- package/dist/jsx/constants.js +0 -31
- package/dist/jsx/constants.js.map +0 -6
- package/dist/jsx/helpers.js +0 -58
- package/dist/jsx/helpers.js.map +0 -6
- package/dist/jsx/types.js +0 -1
- package/dist/jsx/types.js.map +0 -6
package/dist/cjs/Slider.cjs
CHANGED
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var Slider_exports = {};
|
|
33
35
|
__export(Slider_exports, {
|
|
34
36
|
Range: () => Range,
|
|
@@ -43,47 +45,48 @@ __export(Slider_exports, {
|
|
|
43
45
|
Track: () => Track
|
|
44
46
|
});
|
|
45
47
|
module.exports = __toCommonJS(Slider_exports);
|
|
46
|
-
var import_compose_refs = require("@tamagui/compose-refs")
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
49
|
+
var import_constants = require("@tamagui/constants");
|
|
50
|
+
var import_core = require("@tamagui/core");
|
|
51
|
+
var import_get_token = require("@tamagui/get-token");
|
|
52
|
+
var import_helpers = require("@tamagui/helpers");
|
|
53
|
+
var import_stacks = require("@tamagui/stacks");
|
|
54
|
+
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
55
|
+
var import_use_direction = require("@tamagui/use-direction");
|
|
56
|
+
var React = __toESM(require("react"), 1);
|
|
57
|
+
var import_constants2 = require("./constants.cjs");
|
|
58
|
+
var import_helpers2 = require("./helpers.cjs");
|
|
59
|
+
var import_SliderImpl = require("./SliderImpl.cjs");
|
|
60
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
59
61
|
const activeSliderMeasureListeners = /* @__PURE__ */new Set();
|
|
60
|
-
process.env.TAMAGUI_DISABLE_SLIDER_INTERVAL
|
|
62
|
+
if (!process.env.TAMAGUI_DISABLE_SLIDER_INTERVAL) setInterval?.(() => {
|
|
61
63
|
activeSliderMeasureListeners.forEach(cb => cb());
|
|
62
64
|
},
|
|
63
65
|
// really doesn't need to be super often
|
|
64
66
|
1e3);
|
|
65
67
|
const SliderHorizontal = React.forwardRef((props, forwardedRef) => {
|
|
66
68
|
const {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
69
|
+
min,
|
|
70
|
+
max,
|
|
71
|
+
dir,
|
|
72
|
+
onSlideStart,
|
|
73
|
+
onSlideMove,
|
|
74
|
+
onStepKeyDown,
|
|
75
|
+
onSlideEnd,
|
|
76
|
+
...sliderProps
|
|
77
|
+
} = props;
|
|
78
|
+
const direction = (0, import_use_direction.useDirection)(dir);
|
|
79
|
+
const isDirectionLTR = direction === "ltr";
|
|
80
|
+
const sliderRef = React.useRef(null);
|
|
81
|
+
const [state, setState_] = React.useState(() => ({
|
|
82
|
+
size: 0,
|
|
83
|
+
offset: 0
|
|
84
|
+
}));
|
|
85
|
+
const setState = (0, import_core.useCreateShallowSetState)(setState_);
|
|
84
86
|
function getValueFromPointer(pointerPosition) {
|
|
85
87
|
const input = [0, state.size];
|
|
86
|
-
|
|
88
|
+
const output = isDirectionLTR ? [min, max] : [max, min];
|
|
89
|
+
return (0, import_helpers2.linearScale)(input, output)(pointerPosition);
|
|
87
90
|
}
|
|
88
91
|
const measure = () => {
|
|
89
92
|
sliderRef.current?.measure((_x, _y, width, _height, pageX, _pageY) => {
|
|
@@ -93,7 +96,8 @@ const SliderHorizontal = React.forwardRef((props, forwardedRef) => {
|
|
|
93
96
|
});
|
|
94
97
|
});
|
|
95
98
|
};
|
|
96
|
-
|
|
99
|
+
useSliderMeasure(sliderRef, measure);
|
|
100
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_constants2.SliderOrientationProvider, {
|
|
97
101
|
scope: props.__scopeSlider,
|
|
98
102
|
startEdge: isDirectionLTR ? "left" : "right",
|
|
99
103
|
endEdge: isDirectionLTR ? "right" : "left",
|
|
@@ -108,15 +112,15 @@ const SliderHorizontal = React.forwardRef((props, forwardedRef) => {
|
|
|
108
112
|
onLayout: measure,
|
|
109
113
|
onSlideStart: (event, target) => {
|
|
110
114
|
const value = getValueFromPointer(event.nativeEvent.locationX);
|
|
111
|
-
value
|
|
115
|
+
if (value) onSlideStart?.(value, target, event);
|
|
112
116
|
},
|
|
113
117
|
onSlideMove: event => {
|
|
114
118
|
const value = getValueFromPointer(event.nativeEvent.pageX - state.offset);
|
|
115
|
-
value
|
|
119
|
+
if (value) onSlideMove?.(value, event);
|
|
116
120
|
},
|
|
117
121
|
onSlideEnd: event => {
|
|
118
122
|
const value = getValueFromPointer(event.nativeEvent.pageX - state.offset);
|
|
119
|
-
value
|
|
123
|
+
if (value) onSlideEnd?.(event, value);
|
|
120
124
|
},
|
|
121
125
|
onStepKeyDown: event => {
|
|
122
126
|
const isBackKey = import_constants2.BACK_KEYS[direction].includes(event.key);
|
|
@@ -132,407 +136,424 @@ function useOnDebouncedWindowResize(callback, amt = 200) {
|
|
|
132
136
|
React.useEffect(() => {
|
|
133
137
|
let last;
|
|
134
138
|
const onResize = () => {
|
|
135
|
-
clearTimeout(last)
|
|
139
|
+
clearTimeout(last);
|
|
140
|
+
last = setTimeout(callback, amt);
|
|
136
141
|
};
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
window.addEventListener("resize", onResize);
|
|
143
|
+
return () => {
|
|
144
|
+
clearTimeout(last);
|
|
145
|
+
window.removeEventListener("resize", onResize);
|
|
139
146
|
};
|
|
140
147
|
}, []);
|
|
141
148
|
}
|
|
142
149
|
function useSliderMeasure(sliderRef, measure) {
|
|
143
|
-
useOnDebouncedWindowResize(measure)
|
|
150
|
+
useOnDebouncedWindowResize(measure);
|
|
151
|
+
React.useEffect(() => {
|
|
144
152
|
const node = sliderRef.current;
|
|
145
153
|
if (!node) return;
|
|
146
154
|
let measureTm;
|
|
147
155
|
const debouncedMeasure = () => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
clearTimeout(measureTm);
|
|
157
|
+
measureTm = setTimeout(() => {
|
|
158
|
+
measure();
|
|
159
|
+
}, 200);
|
|
160
|
+
};
|
|
161
|
+
const io = new IntersectionObserver(entries => {
|
|
162
|
+
debouncedMeasure();
|
|
163
|
+
if (entries?.[0].isIntersecting) activeSliderMeasureListeners.add(debouncedMeasure);else activeSliderMeasureListeners.delete(debouncedMeasure);
|
|
164
|
+
}, {
|
|
165
|
+
root: null,
|
|
166
|
+
rootMargin: "0px",
|
|
167
|
+
threshold: [0, .5, 1]
|
|
168
|
+
});
|
|
169
|
+
io.observe(node);
|
|
170
|
+
return () => {
|
|
171
|
+
activeSliderMeasureListeners.delete(debouncedMeasure);
|
|
172
|
+
io.disconnect();
|
|
161
173
|
};
|
|
162
174
|
}, []);
|
|
163
175
|
}
|
|
164
176
|
const SliderVertical = React.forwardRef((props, forwardedRef) => {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
177
|
+
const {
|
|
178
|
+
min,
|
|
179
|
+
max,
|
|
180
|
+
onSlideStart,
|
|
181
|
+
onSlideMove,
|
|
182
|
+
onStepKeyDown,
|
|
183
|
+
onSlideEnd,
|
|
184
|
+
...sliderProps
|
|
185
|
+
} = props;
|
|
186
|
+
const [state, setState_] = React.useState(() => ({
|
|
187
|
+
size: 0,
|
|
188
|
+
offset: 0
|
|
189
|
+
}));
|
|
190
|
+
const setState = (0, import_core.useCreateShallowSetState)(setState_);
|
|
191
|
+
const sliderRef = React.useRef(null);
|
|
192
|
+
const configuration = (0, import_core.useConfiguration)();
|
|
193
|
+
const insets = import_constants.isIos && configuration.insets ? configuration.insets : {
|
|
194
|
+
top: 0,
|
|
195
|
+
bottom: 0
|
|
196
|
+
};
|
|
197
|
+
function getValueFromPointer(pointerPosition) {
|
|
198
|
+
const input = [0, state.size];
|
|
199
|
+
const output = [max, min];
|
|
200
|
+
return (0, import_helpers2.linearScale)(input, output)(pointerPosition);
|
|
201
|
+
}
|
|
202
|
+
const measure = () => {
|
|
203
|
+
sliderRef.current?.measure((_x, _y, _width, height, _pageX, pageY) => {
|
|
204
|
+
setState({
|
|
205
|
+
size: height,
|
|
206
|
+
offset: pageY + (import_constants.isIos ? insets.top : 0)
|
|
195
207
|
});
|
|
196
|
-
};
|
|
197
|
-
return useSliderMeasure(sliderRef, measure), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_constants2.SliderOrientationProvider, {
|
|
198
|
-
scope: props.__scopeSlider,
|
|
199
|
-
startEdge: "bottom",
|
|
200
|
-
endEdge: "top",
|
|
201
|
-
sizeProp: "height",
|
|
202
|
-
size: state.size,
|
|
203
|
-
direction: 1,
|
|
204
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_SliderImpl.SliderImpl, {
|
|
205
|
-
ref: (0, import_compose_refs.composeRefs)(forwardedRef, sliderRef),
|
|
206
|
-
...sliderProps,
|
|
207
|
-
orientation: "vertical",
|
|
208
|
-
onLayout: measure,
|
|
209
|
-
onSlideStart: (event, target) => {
|
|
210
|
-
const value = getValueFromPointer(event.nativeEvent.locationY);
|
|
211
|
-
value && onSlideStart?.(value, target, event);
|
|
212
|
-
},
|
|
213
|
-
onSlideMove: event => {
|
|
214
|
-
const value = getValueFromPointer(event.nativeEvent.pageY - state.offset);
|
|
215
|
-
value && onSlideMove?.(value, event);
|
|
216
|
-
},
|
|
217
|
-
onSlideEnd: event => {
|
|
218
|
-
const value = getValueFromPointer(event.nativeEvent.pageY - state.offset);
|
|
219
|
-
onSlideEnd?.(event, value);
|
|
220
|
-
},
|
|
221
|
-
onStepKeyDown: event => {
|
|
222
|
-
const isBackKey = import_constants2.BACK_KEYS.ltr.includes(event.key);
|
|
223
|
-
onStepKeyDown?.({
|
|
224
|
-
event,
|
|
225
|
-
direction: isBackKey ? -1 : 1
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
})
|
|
229
208
|
});
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
209
|
+
};
|
|
210
|
+
useSliderMeasure(sliderRef, measure);
|
|
211
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_constants2.SliderOrientationProvider, {
|
|
212
|
+
scope: props.__scopeSlider,
|
|
213
|
+
startEdge: "bottom",
|
|
214
|
+
endEdge: "top",
|
|
215
|
+
sizeProp: "height",
|
|
216
|
+
size: state.size,
|
|
217
|
+
direction: 1,
|
|
218
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_SliderImpl.SliderImpl, {
|
|
219
|
+
ref: (0, import_compose_refs.composeRefs)(forwardedRef, sliderRef),
|
|
220
|
+
...sliderProps,
|
|
221
|
+
orientation: "vertical",
|
|
222
|
+
onLayout: measure,
|
|
223
|
+
onSlideStart: (event, target) => {
|
|
224
|
+
const value = getValueFromPointer(event.nativeEvent.locationY);
|
|
225
|
+
if (value) onSlideStart?.(value, target, event);
|
|
226
|
+
},
|
|
227
|
+
onSlideMove: event => {
|
|
228
|
+
const value = getValueFromPointer(event.nativeEvent.pageY - state.offset);
|
|
229
|
+
if (value) onSlideMove?.(value, event);
|
|
230
|
+
},
|
|
231
|
+
onSlideEnd: event => {
|
|
232
|
+
const value = getValueFromPointer(event.nativeEvent.pageY - state.offset);
|
|
233
|
+
onSlideEnd?.(event, value);
|
|
234
|
+
},
|
|
235
|
+
onStepKeyDown: event => {
|
|
236
|
+
const isBackKey = import_constants2.BACK_KEYS.ltr.includes(event.key);
|
|
237
|
+
onStepKeyDown?.({
|
|
238
|
+
event,
|
|
239
|
+
direction: isBackKey ? -1 : 1
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
const SliderTrackFrame = (0, import_core.styled)(import_SliderImpl.SliderFrame, {
|
|
246
|
+
name: "Slider",
|
|
247
|
+
variants: {
|
|
248
|
+
unstyled: {
|
|
249
|
+
false: {
|
|
250
|
+
height: "100%",
|
|
251
|
+
width: "100%",
|
|
252
|
+
backgroundColor: "$background",
|
|
253
|
+
position: "relative",
|
|
254
|
+
borderRadius: 1e5,
|
|
255
|
+
overflow: "hidden"
|
|
243
256
|
}
|
|
244
|
-
},
|
|
245
|
-
defaultVariants: {
|
|
246
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
247
257
|
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
258
|
+
},
|
|
259
|
+
defaultVariants: {
|
|
260
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
const SliderTrack = React.forwardRef(function SliderTrack2(props, forwardedRef) {
|
|
264
|
+
const {
|
|
265
|
+
__scopeSlider,
|
|
266
|
+
...trackProps
|
|
267
|
+
} = props;
|
|
268
|
+
const context = (0, import_constants2.useSliderContext)(__scopeSlider);
|
|
269
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(SliderTrackFrame, {
|
|
270
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
271
|
+
"data-orientation": context.orientation,
|
|
272
|
+
orientation: context.orientation,
|
|
273
|
+
size: context.size,
|
|
274
|
+
...trackProps,
|
|
275
|
+
ref: forwardedRef
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
const SliderActiveFrame = (0, import_core.styled)(import_SliderImpl.SliderFrame, {
|
|
279
|
+
name: "SliderActive",
|
|
280
|
+
position: "absolute",
|
|
281
|
+
pointerEvents: "box-none",
|
|
282
|
+
variants: {
|
|
283
|
+
unstyled: {
|
|
284
|
+
false: {
|
|
285
|
+
backgroundColor: "$background",
|
|
286
|
+
borderRadius: 1e5
|
|
274
287
|
}
|
|
275
|
-
},
|
|
276
|
-
defaultVariants: {
|
|
277
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
278
288
|
}
|
|
279
|
-
}),
|
|
280
|
-
SliderActive = React.forwardRef(function (props, forwardedRef) {
|
|
281
|
-
const {
|
|
282
|
-
__scopeSlider,
|
|
283
|
-
...rangeProps
|
|
284
|
-
} = props,
|
|
285
|
-
context = (0, import_constants2.useSliderContext)(__scopeSlider),
|
|
286
|
-
orientation = (0, import_constants2.useSliderOrientationContext)(__scopeSlider),
|
|
287
|
-
ref = React.useRef(null),
|
|
288
|
-
composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref),
|
|
289
|
-
valuesCount = context.values.length,
|
|
290
|
-
percentages = context.values.map(value => (0, import_helpers2.convertValueToPercentage)(value, context.min, context.max)),
|
|
291
|
-
offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0,
|
|
292
|
-
offsetEnd = 100 - Math.max(...percentages);
|
|
293
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(SliderActiveFrame, {
|
|
294
|
-
orientation: context.orientation,
|
|
295
|
-
"data-orientation": context.orientation,
|
|
296
|
-
"data-disabled": context.disabled ? "" : void 0,
|
|
297
|
-
size: context.size,
|
|
298
|
-
animateOnly: ["left", "top", "right", "bottom"],
|
|
299
|
-
...rangeProps,
|
|
300
|
-
ref: composedRefs,
|
|
301
|
-
[orientation.startEdge]: `${offsetStart}%`,
|
|
302
|
-
[orientation.endEdge]: `${offsetEnd}%`,
|
|
303
|
-
...(orientation.sizeProp === "width" ? {
|
|
304
|
-
height: "100%"
|
|
305
|
-
} : {
|
|
306
|
-
left: 0,
|
|
307
|
-
right: 0
|
|
308
|
-
})
|
|
309
|
-
});
|
|
310
|
-
}),
|
|
311
|
-
getThumbSize = val => {
|
|
312
|
-
const tokens = (0, import_core.getTokens)(),
|
|
313
|
-
size = typeof val == "number" ? val : (0, import_get_token.getSize)(tokens.size[val], {
|
|
314
|
-
shift: -1
|
|
315
|
-
});
|
|
316
|
-
return {
|
|
317
|
-
width: size,
|
|
318
|
-
height: size,
|
|
319
|
-
minWidth: size,
|
|
320
|
-
minHeight: size
|
|
321
|
-
};
|
|
322
289
|
},
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
290
|
+
defaultVariants: {
|
|
291
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
const SliderActive = React.forwardRef(function SliderActive2(props, forwardedRef) {
|
|
295
|
+
const {
|
|
296
|
+
__scopeSlider,
|
|
297
|
+
...rangeProps
|
|
298
|
+
} = props;
|
|
299
|
+
const context = (0, import_constants2.useSliderContext)(__scopeSlider);
|
|
300
|
+
const orientation = (0, import_constants2.useSliderOrientationContext)(__scopeSlider);
|
|
301
|
+
const ref = React.useRef(null);
|
|
302
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
303
|
+
const valuesCount = context.values.length;
|
|
304
|
+
const percentages = context.values.map(value => (0, import_helpers2.convertValueToPercentage)(value, context.min, context.max));
|
|
305
|
+
const offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0;
|
|
306
|
+
const offsetEnd = 100 - Math.max(...percentages);
|
|
307
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(SliderActiveFrame, {
|
|
308
|
+
orientation: context.orientation,
|
|
309
|
+
"data-orientation": context.orientation,
|
|
310
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
311
|
+
size: context.size,
|
|
312
|
+
animateOnly: ["left", "top", "right", "bottom"],
|
|
313
|
+
...rangeProps,
|
|
314
|
+
ref: composedRefs,
|
|
315
|
+
[orientation.startEdge]: `${offsetStart}%`,
|
|
316
|
+
[orientation.endEdge]: `${offsetEnd}%`,
|
|
317
|
+
...(orientation.sizeProp === "width" ? {
|
|
318
|
+
height: "100%"
|
|
319
|
+
} : {
|
|
320
|
+
left: 0,
|
|
321
|
+
right: 0
|
|
322
|
+
})
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
const getThumbSize = val => {
|
|
326
|
+
const tokens = (0, import_core.getTokens)();
|
|
327
|
+
const size = typeof val === "number" ? val : (0, import_get_token.getSize)(tokens.size[val], {
|
|
328
|
+
shift: -1
|
|
329
|
+
});
|
|
330
|
+
return {
|
|
331
|
+
width: size,
|
|
332
|
+
height: size,
|
|
333
|
+
minWidth: size,
|
|
334
|
+
minHeight: size
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
const SliderThumbFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
338
|
+
name: "SliderThumb",
|
|
339
|
+
variants: {
|
|
340
|
+
size: {
|
|
341
|
+
"...size": getThumbSize,
|
|
342
|
+
":number": getThumbSize
|
|
343
|
+
},
|
|
344
|
+
unstyled: {
|
|
345
|
+
false: {
|
|
346
|
+
position: "absolute",
|
|
347
|
+
borderWidth: 2,
|
|
348
|
+
borderColor: "$borderColor",
|
|
349
|
+
backgroundColor: "$background",
|
|
350
|
+
pressStyle: {
|
|
351
|
+
backgroundColor: "$backgroundPress",
|
|
352
|
+
borderColor: "$borderColorPress"
|
|
353
|
+
},
|
|
354
|
+
hoverStyle: {
|
|
355
|
+
backgroundColor: "$backgroundHover",
|
|
356
|
+
borderColor: "$borderColorHover"
|
|
357
|
+
},
|
|
358
|
+
focusVisibleStyle: {
|
|
359
|
+
outlineStyle: "solid",
|
|
360
|
+
outlineWidth: 2,
|
|
361
|
+
outlineColor: "$outlineColor"
|
|
349
362
|
}
|
|
350
363
|
}
|
|
351
|
-
},
|
|
352
|
-
defaultVariants: {
|
|
353
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
354
364
|
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
365
|
+
},
|
|
366
|
+
defaultVariants: {
|
|
367
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
const SliderThumb = SliderThumbFrame.styleable(function SliderThumb2(props, forwardedRef) {
|
|
371
|
+
const {
|
|
372
|
+
__scopeSlider,
|
|
373
|
+
index = 0,
|
|
374
|
+
circular,
|
|
375
|
+
size: sizeProp,
|
|
376
|
+
...thumbProps
|
|
377
|
+
} = props;
|
|
378
|
+
const context = (0, import_constants2.useSliderContext)(__scopeSlider);
|
|
379
|
+
const orientation = (0, import_constants2.useSliderOrientationContext)(__scopeSlider);
|
|
380
|
+
const [thumb, setThumb] = React.useState(null);
|
|
381
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, setThumb);
|
|
382
|
+
const value = context.values[index];
|
|
383
|
+
const percent = value === void 0 ? 0 : (0, import_helpers2.convertValueToPercentage)(value, context.min, context.max);
|
|
384
|
+
const label = (0, import_helpers2.getLabel)(index, context.values.length);
|
|
385
|
+
const sizeIn = sizeProp ?? context.size ?? "$true";
|
|
386
|
+
const [size, setSize] = React.useState(() => {
|
|
387
|
+
return (0, import_core.getVariableValue)(getThumbSize(sizeIn).width);
|
|
388
|
+
});
|
|
389
|
+
const thumbInBoundsOffset = size ? (0, import_helpers2.getThumbInBoundsOffset)(size, percent, orientation.direction) : 0;
|
|
390
|
+
React.useEffect(() => {
|
|
391
|
+
if (thumb) {
|
|
392
|
+
context.thumbs.set(thumb, index);
|
|
393
|
+
return () => {
|
|
376
394
|
context.thumbs.delete(thumb);
|
|
377
395
|
};
|
|
378
|
-
}, [thumb, context.thumbs, index]);
|
|
379
|
-
const positionalStyles = context.orientation === "horizontal" ? {
|
|
380
|
-
x: (thumbInBoundsOffset - size / 2) * orientation.direction,
|
|
381
|
-
y: -size / 2,
|
|
382
|
-
top: "50%",
|
|
383
|
-
...(size === 0 && {
|
|
384
|
-
top: "auto",
|
|
385
|
-
bottom: "auto"
|
|
386
|
-
})
|
|
387
|
-
} : {
|
|
388
|
-
x: -size / 2,
|
|
389
|
-
y: size / 2,
|
|
390
|
-
left: "50%",
|
|
391
|
-
...(size === 0 && {
|
|
392
|
-
left: "auto",
|
|
393
|
-
right: "auto"
|
|
394
|
-
})
|
|
395
|
-
};
|
|
396
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(SliderThumbFrame, {
|
|
397
|
-
ref: composedRefs,
|
|
398
|
-
role: "slider",
|
|
399
|
-
"aria-label": props["aria-label"] || label,
|
|
400
|
-
"aria-valuemin": context.min,
|
|
401
|
-
"aria-valuenow": value,
|
|
402
|
-
"aria-valuemax": context.max,
|
|
403
|
-
"aria-orientation": context.orientation,
|
|
404
|
-
"data-orientation": context.orientation,
|
|
405
|
-
"data-disabled": context.disabled ? "" : void 0,
|
|
406
|
-
tabIndex: context.disabled ? void 0 : 0,
|
|
407
|
-
animateOnly: ["transform", "left", "top", "right", "bottom"],
|
|
408
|
-
...positionalStyles,
|
|
409
|
-
[orientation.startEdge]: `${percent}%`,
|
|
410
|
-
size: sizeIn,
|
|
411
|
-
circular,
|
|
412
|
-
...thumbProps,
|
|
413
|
-
onLayout: e => {
|
|
414
|
-
setSize(e.nativeEvent.layout[orientation.sizeProp]);
|
|
415
|
-
},
|
|
416
|
-
onFocus: (0, import_helpers.composeEventHandlers)(props.onFocus, () => {
|
|
417
|
-
context.valueIndexToChangeRef.current = index;
|
|
418
|
-
})
|
|
419
|
-
});
|
|
420
|
-
}, {
|
|
421
|
-
staticConfig: {
|
|
422
|
-
memo: !0
|
|
423
|
-
}
|
|
424
|
-
}),
|
|
425
|
-
SliderComponent = React.forwardRef((props, forwardedRef) => {
|
|
426
|
-
const {
|
|
427
|
-
name,
|
|
428
|
-
min = 0,
|
|
429
|
-
max = 100,
|
|
430
|
-
step = 1,
|
|
431
|
-
orientation = "horizontal",
|
|
432
|
-
disabled = !1,
|
|
433
|
-
minStepsBetweenThumbs = 0,
|
|
434
|
-
defaultValue = [min],
|
|
435
|
-
value,
|
|
436
|
-
onValueChange = () => {},
|
|
437
|
-
size: sizeProp,
|
|
438
|
-
onSlideEnd,
|
|
439
|
-
onSlideMove,
|
|
440
|
-
onSlideStart,
|
|
441
|
-
...sliderProps
|
|
442
|
-
} = props,
|
|
443
|
-
sliderRef = React.useRef(null),
|
|
444
|
-
composedRefs = (0, import_compose_refs.useComposedRefs)(sliderRef, forwardedRef),
|
|
445
|
-
thumbRefs = React.useRef(/* @__PURE__ */new Map()),
|
|
446
|
-
valueIndexToChangeRef = React.useRef(0),
|
|
447
|
-
isHorizontal = orientation === "horizontal",
|
|
448
|
-
[values = [], setValues] = (0, import_use_controllable_state.useControllableState)({
|
|
449
|
-
prop: value,
|
|
450
|
-
defaultProp: defaultValue,
|
|
451
|
-
transition: !0,
|
|
452
|
-
onChange: value2 => {
|
|
453
|
-
updateThumbFocus(valueIndexToChangeRef.current), onValueChange(value2);
|
|
454
|
-
}
|
|
455
|
-
});
|
|
456
|
-
import_constants.isWeb && React.useEffect(() => {
|
|
457
|
-
const node = sliderRef.current;
|
|
458
|
-
if (!node) return;
|
|
459
|
-
const preventDefault = e => {
|
|
460
|
-
e.preventDefault();
|
|
461
|
-
};
|
|
462
|
-
return node.addEventListener("touchstart", preventDefault), () => {
|
|
463
|
-
node.removeEventListener("touchstart", preventDefault);
|
|
464
|
-
};
|
|
465
|
-
}, []);
|
|
466
|
-
function updateThumbFocus(focusIndex) {
|
|
467
|
-
if (import_constants.isWeb) {
|
|
468
|
-
for (const [node, index] of thumbRefs.current.entries()) if (index === focusIndex) {
|
|
469
|
-
node.focus();
|
|
470
|
-
return;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
396
|
}
|
|
474
|
-
|
|
475
|
-
|
|
397
|
+
}, [thumb, context.thumbs, index]);
|
|
398
|
+
const positionalStyles = context.orientation === "horizontal" ? {
|
|
399
|
+
x: (thumbInBoundsOffset - size / 2) * orientation.direction,
|
|
400
|
+
y: -size / 2,
|
|
401
|
+
top: "50%",
|
|
402
|
+
...(size === 0 && {
|
|
403
|
+
top: "auto",
|
|
404
|
+
bottom: "auto"
|
|
405
|
+
})
|
|
406
|
+
} : {
|
|
407
|
+
x: -size / 2,
|
|
408
|
+
y: size / 2,
|
|
409
|
+
left: "50%",
|
|
410
|
+
...(size === 0 && {
|
|
411
|
+
left: "auto",
|
|
412
|
+
right: "auto"
|
|
413
|
+
})
|
|
414
|
+
};
|
|
415
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(SliderThumbFrame, {
|
|
416
|
+
ref: composedRefs,
|
|
417
|
+
role: "slider",
|
|
418
|
+
"aria-label": props["aria-label"] || label,
|
|
419
|
+
"aria-valuemin": context.min,
|
|
420
|
+
"aria-valuenow": value,
|
|
421
|
+
"aria-valuemax": context.max,
|
|
422
|
+
"aria-orientation": context.orientation,
|
|
423
|
+
"data-orientation": context.orientation,
|
|
424
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
425
|
+
tabIndex: context.disabled ? void 0 : 0,
|
|
426
|
+
animateOnly: ["transform", "left", "top", "right", "bottom"],
|
|
427
|
+
...positionalStyles,
|
|
428
|
+
[orientation.startEdge]: `${percent}%`,
|
|
429
|
+
size: sizeIn,
|
|
430
|
+
circular,
|
|
431
|
+
...thumbProps,
|
|
432
|
+
onLayout: e => {
|
|
433
|
+
setSize(e.nativeEvent.layout[orientation.sizeProp]);
|
|
434
|
+
},
|
|
435
|
+
onFocus: (0, import_helpers.composeEventHandlers)(props.onFocus, () => {
|
|
436
|
+
context.valueIndexToChangeRef.current = index;
|
|
437
|
+
})
|
|
438
|
+
});
|
|
439
|
+
}, {
|
|
440
|
+
staticConfig: {
|
|
441
|
+
memo: true
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
const SliderComponent = React.forwardRef((props, forwardedRef) => {
|
|
445
|
+
const {
|
|
446
|
+
name,
|
|
447
|
+
min = 0,
|
|
448
|
+
max = 100,
|
|
449
|
+
step = 1,
|
|
450
|
+
orientation = "horizontal",
|
|
451
|
+
disabled = false,
|
|
452
|
+
minStepsBetweenThumbs = 0,
|
|
453
|
+
defaultValue = [min],
|
|
454
|
+
value,
|
|
455
|
+
onValueChange = () => {},
|
|
456
|
+
size: sizeProp,
|
|
457
|
+
onSlideEnd,
|
|
458
|
+
onSlideMove,
|
|
459
|
+
onSlideStart,
|
|
460
|
+
...sliderProps
|
|
461
|
+
} = props;
|
|
462
|
+
const sliderRef = React.useRef(null);
|
|
463
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(sliderRef, forwardedRef);
|
|
464
|
+
const thumbRefs = React.useRef(/* @__PURE__ */new Map());
|
|
465
|
+
const valueIndexToChangeRef = React.useRef(0);
|
|
466
|
+
const isHorizontal = orientation === "horizontal";
|
|
467
|
+
const [values = [], setValues] = (0, import_use_controllable_state.useControllableState)({
|
|
468
|
+
prop: value,
|
|
469
|
+
defaultProp: defaultValue,
|
|
470
|
+
transition: true,
|
|
471
|
+
onChange: value2 => {
|
|
472
|
+
updateThumbFocus(valueIndexToChangeRef.current);
|
|
473
|
+
onValueChange(value2);
|
|
476
474
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
475
|
+
});
|
|
476
|
+
if (import_constants.isWeb) React.useEffect(() => {
|
|
477
|
+
const node = sliderRef.current;
|
|
478
|
+
if (!node) return;
|
|
479
|
+
const preventDefault = e => {
|
|
480
|
+
e.preventDefault();
|
|
481
|
+
};
|
|
482
|
+
node.addEventListener("touchstart", preventDefault);
|
|
483
|
+
return () => {
|
|
484
|
+
node.removeEventListener("touchstart", preventDefault);
|
|
485
|
+
};
|
|
486
|
+
}, []);
|
|
487
|
+
function updateThumbFocus(focusIndex) {
|
|
488
|
+
if (!import_constants.isWeb) return;
|
|
489
|
+
for (const [node, index] of thumbRefs.current.entries()) if (index === focusIndex) {
|
|
490
|
+
node.focus();
|
|
491
|
+
return;
|
|
485
492
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
493
|
+
}
|
|
494
|
+
function handleSlideMove(value2, event) {
|
|
495
|
+
updateValues(value2, valueIndexToChangeRef.current);
|
|
496
|
+
onSlideMove?.(event, value2);
|
|
497
|
+
}
|
|
498
|
+
function updateValues(value2, atIndex) {
|
|
499
|
+
const decimalCount = (0, import_helpers2.getDecimalCount)(step);
|
|
500
|
+
const snapToStep = (0, import_helpers2.roundValue)(Math.round((value2 - min) / step) * step + min, decimalCount);
|
|
501
|
+
const nextValue = (0, import_helpers.clamp)(snapToStep, [min, max]);
|
|
502
|
+
setValues((prevValues = []) => {
|
|
503
|
+
const nextValues = (0, import_helpers2.getNextSortedValues)(prevValues, nextValue, atIndex);
|
|
504
|
+
if ((0, import_helpers2.hasMinStepsBetweenValues)(nextValues, minStepsBetweenThumbs * step)) {
|
|
505
|
+
valueIndexToChangeRef.current = nextValues.indexOf(nextValue);
|
|
506
|
+
return String(nextValues) === String(prevValues) ? prevValues : nextValues;
|
|
507
|
+
}
|
|
508
|
+
return prevValues;
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
const SliderOriented = isHorizontal ? SliderHorizontal : SliderVertical;
|
|
512
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_constants2.SliderProvider, {
|
|
513
|
+
scope: props.__scopeSlider,
|
|
514
|
+
disabled,
|
|
515
|
+
min,
|
|
516
|
+
max,
|
|
517
|
+
valueIndexToChangeRef,
|
|
518
|
+
thumbs: thumbRefs.current,
|
|
519
|
+
values,
|
|
520
|
+
orientation,
|
|
521
|
+
size: sizeProp,
|
|
522
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(SliderOriented, {
|
|
523
|
+
"aria-disabled": disabled,
|
|
524
|
+
"data-disabled": disabled ? "" : void 0,
|
|
525
|
+
...sliderProps,
|
|
526
|
+
ref: composedRefs,
|
|
490
527
|
min,
|
|
491
528
|
max,
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
}
|
|
510
|
-
onSlideStart?.(event, value2, target);
|
|
511
|
-
},
|
|
512
|
-
onSlideMove: disabled ? void 0 : handleSlideMove,
|
|
513
|
-
onHomeKeyDown: () => !disabled && updateValues(min, 0),
|
|
514
|
-
onEndKeyDown: () => !disabled && updateValues(max, values.length - 1),
|
|
515
|
-
onStepKeyDown: ({
|
|
516
|
-
event,
|
|
517
|
-
direction: stepDirection
|
|
518
|
-
}) => {
|
|
519
|
-
if (!disabled) {
|
|
520
|
-
const multiplier = import_constants2.PAGE_KEYS.includes(event.key) || event.shiftKey && import_constants2.ARROW_KEYS.includes(event.key) ? 10 : 1,
|
|
521
|
-
atIndex = valueIndexToChangeRef.current,
|
|
522
|
-
value2 = values[atIndex],
|
|
523
|
-
stepInDirection = step * multiplier * stepDirection;
|
|
524
|
-
updateValues(value2 + stepInDirection, atIndex);
|
|
525
|
-
}
|
|
529
|
+
onSlideEnd,
|
|
530
|
+
onSlideStart: disabled ? void 0 : (value2, target, event) => {
|
|
531
|
+
if (target !== "thumb") updateValues(value2, (0, import_helpers2.getClosestValueIndex)(values, value2));
|
|
532
|
+
onSlideStart?.(event, value2, target);
|
|
533
|
+
},
|
|
534
|
+
onSlideMove: disabled ? void 0 : handleSlideMove,
|
|
535
|
+
onHomeKeyDown: () => !disabled && updateValues(min, 0),
|
|
536
|
+
onEndKeyDown: () => !disabled && updateValues(max, values.length - 1),
|
|
537
|
+
onStepKeyDown: ({
|
|
538
|
+
event,
|
|
539
|
+
direction: stepDirection
|
|
540
|
+
}) => {
|
|
541
|
+
if (!disabled) {
|
|
542
|
+
const multiplier = import_constants2.PAGE_KEYS.includes(event.key) || event.shiftKey && import_constants2.ARROW_KEYS.includes(event.key) ? 10 : 1;
|
|
543
|
+
const atIndex = valueIndexToChangeRef.current;
|
|
544
|
+
const value2 = values[atIndex];
|
|
545
|
+
updateValues(value2 + step * multiplier * stepDirection, atIndex);
|
|
526
546
|
}
|
|
527
|
-
}
|
|
528
|
-
})
|
|
529
|
-
}),
|
|
530
|
-
Slider = (0, import_helpers.withStaticProperties)(SliderComponent, {
|
|
531
|
-
Track: SliderTrack,
|
|
532
|
-
TrackActive: SliderActive,
|
|
533
|
-
Thumb: SliderThumb
|
|
547
|
+
}
|
|
548
|
+
})
|
|
534
549
|
});
|
|
550
|
+
});
|
|
551
|
+
const Slider = (0, import_helpers.withStaticProperties)(SliderComponent, {
|
|
552
|
+
Track: SliderTrack,
|
|
553
|
+
TrackActive: SliderActive,
|
|
554
|
+
Thumb: SliderThumb
|
|
555
|
+
});
|
|
535
556
|
Slider.displayName = import_constants2.SLIDER_NAME;
|
|
536
|
-
const Track = SliderTrack
|
|
537
|
-
|
|
538
|
-
|
|
557
|
+
const Track = SliderTrack;
|
|
558
|
+
const Range = SliderActive;
|
|
559
|
+
const Thumb = SliderThumb;
|