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