@cdx-ui/primitives 0.0.1-beta.115 → 0.0.1-beta.117
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/README.md +5 -0
- package/lib/commonjs/index.js +35 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/overlay/useAnchorPosition.js +60 -11
- package/lib/commonjs/overlay/useAnchorPosition.js.map +1 -1
- package/lib/commonjs/slider/SliderRail.js +131 -0
- package/lib/commonjs/slider/SliderRail.js.map +1 -0
- package/lib/commonjs/slider/SliderRoot.js +186 -0
- package/lib/commonjs/slider/SliderRoot.js.map +1 -0
- package/lib/commonjs/slider/SliderThumb.js +228 -0
- package/lib/commonjs/slider/SliderThumb.js.map +1 -0
- package/lib/commonjs/slider/context.js +11 -0
- package/lib/commonjs/slider/context.js.map +1 -0
- package/lib/commonjs/slider/index.js +65 -0
- package/lib/commonjs/slider/index.js.map +1 -0
- package/lib/commonjs/slider/types.js +6 -0
- package/lib/commonjs/slider/types.js.map +1 -0
- package/lib/commonjs/slider/useSliderPointer.js +116 -0
- package/lib/commonjs/slider/useSliderPointer.js.map +1 -0
- package/lib/commonjs/slider/utils.js +155 -0
- package/lib/commonjs/slider/utils.js.map +1 -0
- package/lib/commonjs/utils/assignRef.js +16 -0
- package/lib/commonjs/utils/assignRef.js.map +1 -0
- package/lib/commonjs/utils/createPortal.js +3 -1
- package/lib/commonjs/utils/createPortal.js.map +1 -1
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/overlay/useAnchorPosition.js +60 -11
- package/lib/module/overlay/useAnchorPosition.js.map +1 -1
- package/lib/module/slider/SliderRail.js +127 -0
- package/lib/module/slider/SliderRail.js.map +1 -0
- package/lib/module/slider/SliderRoot.js +182 -0
- package/lib/module/slider/SliderRoot.js.map +1 -0
- package/lib/module/slider/SliderThumb.js +224 -0
- package/lib/module/slider/SliderThumb.js.map +1 -0
- package/lib/module/slider/context.js +5 -0
- package/lib/module/slider/context.js.map +1 -0
- package/lib/module/slider/index.js +8 -0
- package/lib/module/slider/index.js.map +1 -0
- package/lib/module/slider/types.js +4 -0
- package/lib/module/slider/types.js.map +1 -0
- package/lib/module/slider/useSliderPointer.js +110 -0
- package/lib/module/slider/useSliderPointer.js.map +1 -0
- package/lib/module/slider/utils.js +138 -0
- package/lib/module/slider/utils.js.map +1 -0
- package/lib/module/utils/assignRef.js +12 -0
- package/lib/module/utils/assignRef.js.map +1 -0
- package/lib/module/utils/createPortal.js +3 -1
- package/lib/module/utils/createPortal.js.map +1 -1
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/overlay/useAnchorPosition.d.ts +7 -1
- package/lib/typescript/overlay/useAnchorPosition.d.ts.map +1 -1
- package/lib/typescript/slider/SliderRail.d.ts +6 -0
- package/lib/typescript/slider/SliderRail.d.ts.map +1 -0
- package/lib/typescript/slider/SliderRoot.d.ts +7 -0
- package/lib/typescript/slider/SliderRoot.d.ts.map +1 -0
- package/lib/typescript/slider/SliderThumb.d.ts +6 -0
- package/lib/typescript/slider/SliderThumb.d.ts.map +1 -0
- package/lib/typescript/slider/context.d.ts +37 -0
- package/lib/typescript/slider/context.d.ts.map +1 -0
- package/lib/typescript/slider/index.d.ts +8 -0
- package/lib/typescript/slider/index.d.ts.map +1 -0
- package/lib/typescript/slider/types.d.ts +37 -0
- package/lib/typescript/slider/types.d.ts.map +1 -0
- package/lib/typescript/slider/useSliderPointer.d.ts +23 -0
- package/lib/typescript/slider/useSliderPointer.d.ts.map +1 -0
- package/lib/typescript/slider/utils.d.ts +23 -0
- package/lib/typescript/slider/utils.d.ts.map +1 -0
- package/lib/typescript/utils/assignRef.d.ts +3 -0
- package/lib/typescript/utils/assignRef.d.ts.map +1 -0
- package/lib/typescript/utils/createPortal.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +4 -0
- package/src/overlay/useAnchorPosition.ts +79 -11
- package/src/slider/SliderRail.tsx +143 -0
- package/src/slider/SliderRoot.tsx +266 -0
- package/src/slider/SliderThumb.tsx +268 -0
- package/src/slider/context.tsx +38 -0
- package/src/slider/index.ts +19 -0
- package/src/slider/types.ts +44 -0
- package/src/slider/useSliderPointer.ts +157 -0
- package/src/slider/utils.ts +181 -0
- package/src/utils/assignRef.ts +11 -0
- package/src/utils/createPortal.ts +3 -1
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SliderThumb = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _utils = require("@cdx-ui/utils");
|
|
10
|
+
var _focus = require("@react-native-aria/focus");
|
|
11
|
+
var _interactions = require("@react-native-aria/interactions");
|
|
12
|
+
var _slot = require("../slot");
|
|
13
|
+
var _assignRef = require("../utils/assignRef");
|
|
14
|
+
var _dataAttributes = require("../utils/dataAttributes");
|
|
15
|
+
var _context = require("./context");
|
|
16
|
+
var _useSliderPointer = require("./useSliderPointer");
|
|
17
|
+
var _utils2 = require("./utils");
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
const SliderThumb = exports.SliderThumb = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
20
|
+
asChild,
|
|
21
|
+
style,
|
|
22
|
+
onLayout,
|
|
23
|
+
onHoverIn,
|
|
24
|
+
onHoverOut,
|
|
25
|
+
onFocus,
|
|
26
|
+
onBlur,
|
|
27
|
+
onPressIn,
|
|
28
|
+
onPressOut,
|
|
29
|
+
children,
|
|
30
|
+
...props
|
|
31
|
+
}, ref) => {
|
|
32
|
+
const {
|
|
33
|
+
percent,
|
|
34
|
+
orientation,
|
|
35
|
+
isDisabled,
|
|
36
|
+
isDragging,
|
|
37
|
+
trackLayout,
|
|
38
|
+
thumbSize,
|
|
39
|
+
setValueFromRatio,
|
|
40
|
+
setIsDragging,
|
|
41
|
+
setIsHovered,
|
|
42
|
+
setIsFocused,
|
|
43
|
+
setThumbSize,
|
|
44
|
+
thumbRef
|
|
45
|
+
} = (0, _context.useSliderContext)();
|
|
46
|
+
const percentRef = (0, _react.useRef)(percent);
|
|
47
|
+
percentRef.current = percent;
|
|
48
|
+
const dragStartRatio = (0, _react.useRef)(0);
|
|
49
|
+
const lastRatioRef = (0, _react.useRef)(percent / 100);
|
|
50
|
+
|
|
51
|
+
// The native PanResponder is created once (stable across renders) so an
|
|
52
|
+
// in-flight gesture is never handed a fresh internal `gestureState`
|
|
53
|
+
// mid-drag. In controlled mode `setValueFromRatio`/`trackLayout` change
|
|
54
|
+
// identity on every value update, so the handlers read the current values
|
|
55
|
+
// through refs instead of closing over them (which would force the
|
|
56
|
+
// `useMemo` to re-create the responder on every move and reset `dx`).
|
|
57
|
+
const orientationRef = (0, _react.useRef)(orientation);
|
|
58
|
+
orientationRef.current = orientation;
|
|
59
|
+
const trackLayoutRef = (0, _react.useRef)(trackLayout);
|
|
60
|
+
trackLayoutRef.current = trackLayout;
|
|
61
|
+
const thumbSizeRef = (0, _react.useRef)(thumbSize);
|
|
62
|
+
thumbSizeRef.current = thumbSize;
|
|
63
|
+
const isDisabledRef = (0, _react.useRef)(isDisabled);
|
|
64
|
+
isDisabledRef.current = isDisabled;
|
|
65
|
+
const setValueFromRatioRef = (0, _react.useRef)(setValueFromRatio);
|
|
66
|
+
setValueFromRatioRef.current = setValueFromRatio;
|
|
67
|
+
const setIsDraggingRef = (0, _react.useRef)(setIsDragging);
|
|
68
|
+
setIsDraggingRef.current = setIsDragging;
|
|
69
|
+
const {
|
|
70
|
+
hoverProps,
|
|
71
|
+
isHovered
|
|
72
|
+
} = (0, _interactions.useHover)();
|
|
73
|
+
const {
|
|
74
|
+
focusProps,
|
|
75
|
+
isFocused
|
|
76
|
+
} = (0, _focus.useFocus)();
|
|
77
|
+
const {
|
|
78
|
+
isFocusVisible,
|
|
79
|
+
focusProps: focusRingProps
|
|
80
|
+
} = (0, _focus.useFocusRing)();
|
|
81
|
+
const {
|
|
82
|
+
pressProps: pressableProps,
|
|
83
|
+
isPressed
|
|
84
|
+
} = (0, _interactions.usePress)({
|
|
85
|
+
isDisabled
|
|
86
|
+
});
|
|
87
|
+
const {
|
|
88
|
+
startDrag
|
|
89
|
+
} = (0, _useSliderPointer.useWebSliderDrag)({
|
|
90
|
+
isDisabled,
|
|
91
|
+
setIsDragging,
|
|
92
|
+
setValueFromRatio,
|
|
93
|
+
trackLayout,
|
|
94
|
+
orientation,
|
|
95
|
+
thumbSize
|
|
96
|
+
});
|
|
97
|
+
const panResponder = (0, _react.useMemo)(() => _reactNative.PanResponder.create({
|
|
98
|
+
onStartShouldSetPanResponder: () => !isDisabledRef.current,
|
|
99
|
+
onMoveShouldSetPanResponder: () => !isDisabledRef.current,
|
|
100
|
+
onPanResponderGrant: () => {
|
|
101
|
+
if (isDisabledRef.current) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
setIsDraggingRef.current(true);
|
|
105
|
+
dragStartRatio.current = percentRef.current / 100;
|
|
106
|
+
lastRatioRef.current = dragStartRatio.current;
|
|
107
|
+
},
|
|
108
|
+
onPanResponderMove: (_event, gestureState) => {
|
|
109
|
+
const layout = trackLayoutRef.current;
|
|
110
|
+
if (!layout) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const isHorizontal = orientationRef.current === 'horizontal';
|
|
114
|
+
const trackSize = isHorizontal ? layout.width : layout.height;
|
|
115
|
+
const travel = (0, _utils2.getThumbTravel)(trackSize, thumbSizeRef.current);
|
|
116
|
+
if (travel <= 0) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const delta = isHorizontal ? gestureState.dx : -gestureState.dy;
|
|
120
|
+
const nextRatio = (0, _utils2.clamp)(dragStartRatio.current + delta / travel, 0, 1);
|
|
121
|
+
lastRatioRef.current = nextRatio;
|
|
122
|
+
setValueFromRatioRef.current(nextRatio);
|
|
123
|
+
},
|
|
124
|
+
onPanResponderRelease: () => {
|
|
125
|
+
setIsDraggingRef.current(false);
|
|
126
|
+
setValueFromRatioRef.current(lastRatioRef.current, true);
|
|
127
|
+
},
|
|
128
|
+
onPanResponderTerminate: () => {
|
|
129
|
+
setIsDraggingRef.current(false);
|
|
130
|
+
setValueFromRatioRef.current(lastRatioRef.current, true);
|
|
131
|
+
}
|
|
132
|
+
}), []);
|
|
133
|
+
const thumbStyle = (0, _react.useMemo)(() => {
|
|
134
|
+
const trackSize = trackLayout == null ? 0 : orientation === 'horizontal' ? trackLayout.width : trackLayout.height;
|
|
135
|
+
const offset = (0, _utils2.percentToThumbOffset)(percent, trackSize, thumbSize);
|
|
136
|
+
if (orientation === 'vertical') {
|
|
137
|
+
return {
|
|
138
|
+
position: 'absolute',
|
|
139
|
+
left: '50%',
|
|
140
|
+
bottom: offset,
|
|
141
|
+
marginLeft: -thumbSize / 2,
|
|
142
|
+
zIndex: 2
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
position: 'absolute',
|
|
147
|
+
top: '50%',
|
|
148
|
+
left: offset,
|
|
149
|
+
transform: [{
|
|
150
|
+
translateY: -thumbSize / 2
|
|
151
|
+
}],
|
|
152
|
+
zIndex: 2
|
|
153
|
+
};
|
|
154
|
+
}, [orientation, percent, thumbSize, trackLayout]);
|
|
155
|
+
const handleLayout = (0, _react.useCallback)(event => {
|
|
156
|
+
const {
|
|
157
|
+
width,
|
|
158
|
+
height
|
|
159
|
+
} = event.nativeEvent.layout;
|
|
160
|
+
const measured = orientation === 'horizontal' ? width : height;
|
|
161
|
+
if (measured > 0) {
|
|
162
|
+
setThumbSize(measured);
|
|
163
|
+
}
|
|
164
|
+
if (onLayout) {
|
|
165
|
+
onLayout(event);
|
|
166
|
+
}
|
|
167
|
+
}, [onLayout, orientation, setThumbSize]);
|
|
168
|
+
const handlePointerDown = (0, _react.useCallback)(event => {
|
|
169
|
+
if (_reactNative.Platform.OS !== 'web' || isDisabled) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
event.preventDefault();
|
|
173
|
+
event.stopPropagation();
|
|
174
|
+
const {
|
|
175
|
+
x,
|
|
176
|
+
y
|
|
177
|
+
} = (0, _useSliderPointer.getPointerCoords)(event.nativeEvent);
|
|
178
|
+
startDrag(x, y, percentRef.current / 100);
|
|
179
|
+
}, [isDisabled, startDrag]);
|
|
180
|
+
const isWeb = _reactNative.Platform.OS === 'web';
|
|
181
|
+
|
|
182
|
+
// Native drag is driven by PanResponder. Its `panHandlers` set the same
|
|
183
|
+
// responder props (`onResponderGrant/Move/Release`, etc.) that RN's
|
|
184
|
+
// `Pressable`/`Pressability` also set internally — and `Pressable` spreads
|
|
185
|
+
// its own handlers last, silently clobbering ours. So on native the thumb
|
|
186
|
+
// must be a plain `View` that carries `panHandlers` directly. Web keeps
|
|
187
|
+
// `Pressable` for its pointer-event, hover, and focus-ring behavior.
|
|
188
|
+
const Comp = asChild ? _slot.Slot : isWeb ? _reactNative.Pressable : _reactNative.View;
|
|
189
|
+
const setThumbRef = (0, _react.useCallback)(node => {
|
|
190
|
+
thumbRef.current = node;
|
|
191
|
+
(0, _assignRef.assignRef)(ref, node);
|
|
192
|
+
}, [ref, thumbRef]);
|
|
193
|
+
const webInteractionProps = {
|
|
194
|
+
onPointerDown: handlePointerDown,
|
|
195
|
+
onHoverIn: (0, _utils.composeEventHandlers)(onHoverIn, (0, _utils.composeEventHandlers)(hoverProps.onHoverIn, () => setIsHovered(true))),
|
|
196
|
+
onHoverOut: (0, _utils.composeEventHandlers)(onHoverOut, (0, _utils.composeEventHandlers)(hoverProps.onHoverOut, () => setIsHovered(false))),
|
|
197
|
+
onPressIn: (0, _utils.composeEventHandlers)(onPressIn, pressableProps.onPressIn),
|
|
198
|
+
onPressOut: (0, _utils.composeEventHandlers)(onPressOut, pressableProps.onPressOut),
|
|
199
|
+
disabled: isDisabled,
|
|
200
|
+
tabIndex: -1
|
|
201
|
+
};
|
|
202
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, {
|
|
203
|
+
ref: setThumbRef,
|
|
204
|
+
...props,
|
|
205
|
+
...(isWeb ? webInteractionProps : panResponder.panHandlers),
|
|
206
|
+
onLayout: handleLayout,
|
|
207
|
+
onFocus: (0, _utils.composeEventHandlers)((0, _utils.composeEventHandlers)(onFocus, focusProps.onFocus), (0, _utils.composeEventHandlers)(focusRingProps.onFocus, () => setIsFocused(true))),
|
|
208
|
+
onBlur: (0, _utils.composeEventHandlers)((0, _utils.composeEventHandlers)(onBlur, focusProps.onBlur), (0, _utils.composeEventHandlers)(focusRingProps.onBlur, () => setIsFocused(false))),
|
|
209
|
+
style: [thumbStyle, style],
|
|
210
|
+
accessibilityRole: "none",
|
|
211
|
+
importantForAccessibility: "no",
|
|
212
|
+
...(0, _dataAttributes.dataAttributes)({
|
|
213
|
+
slot: 'slider-thumb',
|
|
214
|
+
hover: isHovered,
|
|
215
|
+
focus: isFocused,
|
|
216
|
+
focusVisible: isFocusVisible,
|
|
217
|
+
// On native there is no `Pressable`, so `usePress` never fires; the
|
|
218
|
+
// drag state stands in for "active" so the thumb still scales while
|
|
219
|
+
// the user is dragging (see `data-[active=true]:scale-105`).
|
|
220
|
+
active: isPressed || isDragging,
|
|
221
|
+
dragging: isDragging,
|
|
222
|
+
disabled: isDisabled
|
|
223
|
+
}),
|
|
224
|
+
children: children
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
SliderThumb.displayName = 'SliderThumb';
|
|
228
|
+
//# sourceMappingURL=SliderThumb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_utils","_focus","_interactions","_slot","_assignRef","_dataAttributes","_context","_useSliderPointer","_utils2","_jsxRuntime","SliderThumb","exports","forwardRef","asChild","style","onLayout","onHoverIn","onHoverOut","onFocus","onBlur","onPressIn","onPressOut","children","props","ref","percent","orientation","isDisabled","isDragging","trackLayout","thumbSize","setValueFromRatio","setIsDragging","setIsHovered","setIsFocused","setThumbSize","thumbRef","useSliderContext","percentRef","useRef","current","dragStartRatio","lastRatioRef","orientationRef","trackLayoutRef","thumbSizeRef","isDisabledRef","setValueFromRatioRef","setIsDraggingRef","hoverProps","isHovered","useHover","focusProps","isFocused","useFocus","isFocusVisible","focusRingProps","useFocusRing","pressProps","pressableProps","isPressed","usePress","startDrag","useWebSliderDrag","panResponder","useMemo","PanResponder","create","onStartShouldSetPanResponder","onMoveShouldSetPanResponder","onPanResponderGrant","onPanResponderMove","_event","gestureState","layout","isHorizontal","trackSize","width","height","travel","getThumbTravel","delta","dx","dy","nextRatio","clamp","onPanResponderRelease","onPanResponderTerminate","thumbStyle","offset","percentToThumbOffset","position","left","bottom","marginLeft","zIndex","top","transform","translateY","handleLayout","useCallback","event","nativeEvent","measured","handlePointerDown","Platform","OS","preventDefault","stopPropagation","x","y","getPointerCoords","isWeb","Comp","Slot","Pressable","View","setThumbRef","node","assignRef","webInteractionProps","onPointerDown","composeEventHandlers","disabled","tabIndex","jsx","panHandlers","accessibilityRole","importantForAccessibility","dataAttributes","slot","hover","focus","focusVisible","active","dragging","displayName"],"sourceRoot":"../../../src","sources":["slider/SliderThumb.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAUA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAEA,IAAAS,iBAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AAAsE,IAAAW,WAAA,GAAAX,OAAA;AAI/D,MAAMY,WAAW,GAAAC,OAAA,CAAAD,WAAA,gBAAG,IAAAE,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ACvBjF,OAAO,EAAE,IAAAwG,2BAAoB,EAC3B,IAAAA,2BAAoB,EAACxG,OAAO,EAAqCkC,UAAU,CAAClC,OAAO,CAAC,EACpF,IAAAwG,2BAAoB,EAAClE,cAAc,CAACtC,OAAO,EAAE,MAAMgB,YAAY,CAAC,IAAI,CAAC,CACvE,CAAE;IACFf,MAAM,EAAE,IAAAuG,2BAAoB,EAC1B,IAAAA,2BAAoB,EAACvG,MAAM,EAAqCiC,UAAU,CAACjC,MAAM,CAAC,EAClF,IAAAuG,2BAAoB,EAAClE,cAAc,CAACrC,MAAM,EAAE,MAAMe,YAAY,CAAC,KAAK,CAAC,CACvE,CAAE;IACFpB,KAAK,EAAE,CAAC0E,UAAU,EAAE1E,KAAK,CAAE;IAC3BiH,iBAAiB,EAAC,MAAM;IACxBC,yBAAyB,EAAC,IAAI;IAAA,GAC1B,IAAAC,8BAAc,EAAC;MACjBC,IAAI,EAAE,cAAc;MACpBC,KAAK,EAAEjF,SAAS;MAChBkF,KAAK,EAAE/E,SAAS;MAChBgF,YAAY,EAAE9E,cAAc;MAC5B;MACA;MACA;MACA+E,MAAM,EAAE1E,SAAS,IAAIhC,UAAU;MAC/B2G,QAAQ,EAAE3G,UAAU;MACpB+F,QAAQ,EAAEhG;IACZ,CAAC,CAAC;IAAAL,QAAA,EAEDA;EAAQ,CACL,CAAC;AAEX,CACF,CAAC;AAEDZ,WAAW,CAAC8H,WAAW,GAAG,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSliderContext = exports.SliderProvider = void 0;
|
|
7
|
+
var _utils = require("@cdx-ui/utils");
|
|
8
|
+
const [SliderProvider, useSliderContext] = (0, _utils.createContext)('SliderContext');
|
|
9
|
+
exports.useSliderContext = useSliderContext;
|
|
10
|
+
exports.SliderProvider = SliderProvider;
|
|
11
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_utils","require","SliderProvider","useSliderContext","createContext","exports"],"sourceRoot":"../../../src","sources":["slider/context.tsx"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAkCO,MAAM,CAACC,cAAc,EAAEC,gBAAgB,CAAC,GAC7C,IAAAC,oBAAa,EAAqB,eAAe,CAAC;AAACC,OAAA,CAAAF,gBAAA,GAAAA,gBAAA;AAAAE,OAAA,CAAAH,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "SLIDER_MARKER_SIZE", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _utils.SLIDER_MARKER_SIZE;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "SliderRail", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _SliderRail.SliderRail;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "SliderRoot", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _SliderRoot.SliderRoot;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "SliderThumb", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _SliderThumb.SliderThumb;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "getMarkerPositionStyle", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _utils.getMarkerPositionStyle;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "getMarkerStepValues", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _utils.getMarkerStepValues;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "percentToFillExtent", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _utils.percentToFillExtent;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "useSliderContext", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _context.useSliderContext;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "valueToPercent", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _utils.valueToPercent;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var _context = require("./context");
|
|
61
|
+
var _SliderRoot = require("./SliderRoot");
|
|
62
|
+
var _SliderRail = require("./SliderRail");
|
|
63
|
+
var _SliderThumb = require("./SliderThumb");
|
|
64
|
+
var _utils = require("./utils");
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_context","require","_SliderRoot","_SliderRail","_SliderThumb","_utils"],"sourceRoot":"../../../src","sources":["slider/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["slider/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPointerCoords = getPointerCoords;
|
|
7
|
+
exports.getRatioFromPagePoint = getRatioFromPagePoint;
|
|
8
|
+
exports.useWebSliderDrag = useWebSliderDrag;
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
var _utils = require("./utils");
|
|
12
|
+
function getPointerCoords(nativeEvent) {
|
|
13
|
+
if (_reactNative.Platform.OS === 'web' && nativeEvent.clientX != null && nativeEvent.clientY != null) {
|
|
14
|
+
return {
|
|
15
|
+
x: nativeEvent.clientX,
|
|
16
|
+
y: nativeEvent.clientY
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
x: nativeEvent.pageX ?? 0,
|
|
21
|
+
y: nativeEvent.pageY ?? 0
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function getRatioFromPagePoint(pageX, pageY, trackLayout, orientation, thumbSize) {
|
|
25
|
+
if (!trackLayout) {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
if (orientation === 'horizontal') {
|
|
29
|
+
return (0, _utils.pointerCoordToRatio)(pageX, trackLayout.x, trackLayout.width, thumbSize);
|
|
30
|
+
}
|
|
31
|
+
return (0, _utils.pointerCoordToVerticalRatio)(pageY, trackLayout.y, trackLayout.height, thumbSize);
|
|
32
|
+
}
|
|
33
|
+
function useWebSliderDrag({
|
|
34
|
+
isDisabled,
|
|
35
|
+
setIsDragging,
|
|
36
|
+
setValueFromRatio,
|
|
37
|
+
trackLayout,
|
|
38
|
+
orientation,
|
|
39
|
+
thumbSize
|
|
40
|
+
}) {
|
|
41
|
+
const draggingRef = (0, _react.useRef)(false);
|
|
42
|
+
const lastRatioRef = (0, _react.useRef)(0);
|
|
43
|
+
const dragContextRef = (0, _react.useRef)(null);
|
|
44
|
+
const cleanupRef = (0, _react.useRef)(null);
|
|
45
|
+
(0, _react.useEffect)(() => {
|
|
46
|
+
return () => {
|
|
47
|
+
cleanupRef.current?.();
|
|
48
|
+
cleanupRef.current = null;
|
|
49
|
+
};
|
|
50
|
+
}, []);
|
|
51
|
+
const endDrag = (0, _react.useCallback)(() => {
|
|
52
|
+
if (!draggingRef.current) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
draggingRef.current = false;
|
|
56
|
+
dragContextRef.current = null;
|
|
57
|
+
setIsDragging(false);
|
|
58
|
+
setValueFromRatio(lastRatioRef.current, true);
|
|
59
|
+
}, [setIsDragging, setValueFromRatio]);
|
|
60
|
+
const startDrag = (0, _react.useCallback)((pageX, pageY, anchorRatio, trackLayoutOverride) => {
|
|
61
|
+
if (isDisabled || _reactNative.Platform.OS !== 'web' || typeof window === 'undefined') {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const layout = trackLayoutOverride ?? trackLayout;
|
|
65
|
+
if (!layout) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const trackSize = orientation === 'horizontal' ? layout.width : layout.height;
|
|
69
|
+
const travel = (0, _utils.getThumbTravel)(trackSize, thumbSize);
|
|
70
|
+
if (travel <= 0) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const startPointer = orientation === 'horizontal' ? pageX : pageY;
|
|
74
|
+
const startRatio = anchorRatio != null ? (0, _utils.clamp)(anchorRatio, 0, 1) : getRatioFromPagePoint(pageX, pageY, layout, orientation, thumbSize);
|
|
75
|
+
lastRatioRef.current = startRatio;
|
|
76
|
+
draggingRef.current = true;
|
|
77
|
+
dragContextRef.current = {
|
|
78
|
+
startPointer,
|
|
79
|
+
startRatio,
|
|
80
|
+
travel
|
|
81
|
+
};
|
|
82
|
+
setIsDragging(true);
|
|
83
|
+
setValueFromRatio(startRatio);
|
|
84
|
+
const onMove = event => {
|
|
85
|
+
if (!draggingRef.current || !dragContextRef.current) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
const pointer = orientation === 'horizontal' ? event.clientX : event.clientY;
|
|
90
|
+
const delta = pointer - dragContextRef.current.startPointer;
|
|
91
|
+
const deltaAlongTrack = orientation === 'horizontal' ? delta : -delta;
|
|
92
|
+
const nextRatio = (0, _utils.clamp)(dragContextRef.current.startRatio + deltaAlongTrack / dragContextRef.current.travel, 0, 1);
|
|
93
|
+
lastRatioRef.current = nextRatio;
|
|
94
|
+
setValueFromRatio(nextRatio);
|
|
95
|
+
};
|
|
96
|
+
const onUp = () => {
|
|
97
|
+
cleanupRef.current = null;
|
|
98
|
+
window.removeEventListener('pointermove', onMove);
|
|
99
|
+
window.removeEventListener('pointerup', onUp);
|
|
100
|
+
window.removeEventListener('pointercancel', onUp);
|
|
101
|
+
endDrag();
|
|
102
|
+
};
|
|
103
|
+
window.addEventListener('pointermove', onMove);
|
|
104
|
+
window.addEventListener('pointerup', onUp);
|
|
105
|
+
window.addEventListener('pointercancel', onUp);
|
|
106
|
+
cleanupRef.current = () => {
|
|
107
|
+
window.removeEventListener('pointermove', onMove);
|
|
108
|
+
window.removeEventListener('pointerup', onUp);
|
|
109
|
+
window.removeEventListener('pointercancel', onUp);
|
|
110
|
+
};
|
|
111
|
+
}, [endDrag, isDisabled, orientation, setIsDragging, setValueFromRatio, thumbSize, trackLayout]);
|
|
112
|
+
return {
|
|
113
|
+
startDrag
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=useSliderPointer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_utils","getPointerCoords","nativeEvent","Platform","OS","clientX","clientY","x","y","pageX","pageY","getRatioFromPagePoint","trackLayout","orientation","thumbSize","pointerCoordToRatio","width","pointerCoordToVerticalRatio","height","useWebSliderDrag","isDisabled","setIsDragging","setValueFromRatio","draggingRef","useRef","lastRatioRef","dragContextRef","cleanupRef","useEffect","current","endDrag","useCallback","startDrag","anchorRatio","trackLayoutOverride","window","layout","trackSize","travel","getThumbTravel","startPointer","startRatio","clamp","onMove","event","preventDefault","pointer","delta","deltaAlongTrack","nextRatio","onUp","removeEventListener","addEventListener"],"sourceRoot":"../../../src","sources":["slider/useSliderPointer.ts"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAGA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,gBAAgBA,CAACC,WAKhC,EAA4B;EAC3B,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAIF,WAAW,CAACG,OAAO,IAAI,IAAI,IAAIH,WAAW,CAACI,OAAO,IAAI,IAAI,EAAE;IACvF,OAAO;MAAEC,CAAC,EAAEL,WAAW,CAACG,OAAO;MAAEG,CAAC,EAAEN,WAAW,CAACI;IAAQ,CAAC;EAC3D;EAEA,OAAO;IACLC,CAAC,EAAEL,WAAW,CAACO,KAAK,IAAI,CAAC;IACzBD,CAAC,EAAEN,WAAW,CAACQ,KAAK,IAAI;EAC1B,CAAC;AACH;AAEO,SAASC,qBAAqBA,CACnCF,KAAa,EACbC,KAAa,EACbE,WAAqC,EACrCC,WAA8B,EAC9BC,SAAiB,EACT;EACR,IAAI,CAACF,WAAW,EAAE;IAChB,OAAO,CAAC;EACV;EAEA,IAAIC,WAAW,KAAK,YAAY,EAAE;IAChC,OAAO,IAAAE,0BAAmB,EAACN,KAAK,EAAEG,WAAW,CAACL,CAAC,EAAEK,WAAW,CAACI,KAAK,EAAEF,SAAS,CAAC;EAChF;EAEA,OAAO,IAAAG,kCAA2B,EAACP,KAAK,EAAEE,WAAW,CAACJ,CAAC,EAAEI,WAAW,CAACM,MAAM,EAAEJ,SAAS,CAAC;AACzF;AAQO,SAASK,gBAAgBA,CAAC;EAC/BC,UAAU;EACVC,aAAa;EACbC,iBAAiB;EACjBV,WAAW;EACXC,WAAW;EACXC;AAQF,CAAC,EAAE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AO,GAAG,IAAI;MACzBM,MAAM,CAACgB,mBAAmB,CAAC,aAAa,EAAER,MAAM,CAAC;MACjDR,MAAM,CAACgB,mBAAmB,CAAC,WAAW,EAAED,IAAI,CAAC;MAC7Cf,MAAM,CAACgB,mBAAmB,CAAC,eAAe,EAAED,IAAI,CAAC;MACjDpB,OAAO,CAAC,CAAC;IACX,CAAC;IAEDK,MAAM,CAACiB,gBAAgB,CAAC,aAAa,EAAET,MAAM,CAAC;IAC9CR,MAAM,CAACiB,gBAAgB,CAAC,WAAW,EAAEF,IAAI,CAAC;IAC1Cf,MAAM,CAACiB,gBAAgB,CAAC,eAAe,EAAEF,IAAI,CAAC;IAE9CvB,UAAU,CAACE,OAAO,GAAG,MAAM;MACzBM,MAAM,CAACgB,mBAAmB,CAAC,aAAa,EAAER,MAAM,CAAC;MACjDR,MAAM,CAACgB,mBAAmB,CAAC,WAAW,EAAED,IAAI,CAAC;MAC7Cf,MAAM,CAACgB,mBAAmB,CAAC,eAAe,EAAED,IAAI,CAAC;IACnD,CAAC;EACH,CAAC,EACD,CAACpB,OAAO,EAAEV,UAAU,EAAEP,WAAW,EAAEQ,aAAa,EAAEC,iBAAiB,EAAER,SAAS,EAAEF,WAAW,CAC7F,CAAC;EAED,OAAO;IAAEoB;EAAU,CAAC;AACtB","ignoreList":[]}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SLIDER_MARKER_SIZE = void 0;
|
|
7
|
+
exports.clamp = clamp;
|
|
8
|
+
exports.formatSliderValue = formatSliderValue;
|
|
9
|
+
exports.getMarkerPositionStyle = getMarkerPositionStyle;
|
|
10
|
+
exports.getMarkerStepValues = getMarkerStepValues;
|
|
11
|
+
exports.getThumbTravel = getThumbTravel;
|
|
12
|
+
exports.percentToFillExtent = percentToFillExtent;
|
|
13
|
+
exports.percentToMarkerCenterOffset = percentToMarkerCenterOffset;
|
|
14
|
+
exports.percentToThumbOffset = percentToThumbOffset;
|
|
15
|
+
exports.percentToValue = percentToValue;
|
|
16
|
+
exports.pointerCoordToRatio = pointerCoordToRatio;
|
|
17
|
+
exports.pointerCoordToVerticalRatio = pointerCoordToVerticalRatio;
|
|
18
|
+
exports.snapToStep = snapToStep;
|
|
19
|
+
exports.valueToPercent = valueToPercent;
|
|
20
|
+
function toPercentDimension(percent) {
|
|
21
|
+
return `${String(percent)}%`;
|
|
22
|
+
}
|
|
23
|
+
const SLIDER_MARKER_SIZE = exports.SLIDER_MARKER_SIZE = 3;
|
|
24
|
+
function clamp(value, min, max) {
|
|
25
|
+
return Math.min(max, Math.max(min, value));
|
|
26
|
+
}
|
|
27
|
+
function getThumbTravel(trackSize, _thumbSize) {
|
|
28
|
+
return Math.max(trackSize, 0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Thumb leading-edge offset along the track axis (center-based). */
|
|
32
|
+
function percentToThumbOffset(percent, trackSize, thumbSize) {
|
|
33
|
+
if (trackSize <= 0) return 0;
|
|
34
|
+
return clamp(percent, 0, 100) / 100 * trackSize - thumbSize / 2;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Filled track extent to the thumb center. */
|
|
38
|
+
function percentToFillExtent(percent, trackSize, _thumbSize) {
|
|
39
|
+
if (trackSize <= 0) return 0;
|
|
40
|
+
return clamp(percent, 0, 100) / 100 * trackSize;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Map a pointer coordinate on the track axis to a 0–1 ratio. */
|
|
44
|
+
function pointerCoordToRatio(pointerCoord, trackStart, trackSize, _thumbSize) {
|
|
45
|
+
if (trackSize <= 0) {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
return clamp((pointerCoord - trackStart) / trackSize, 0, 1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Vertical slider: bottom = min (0), top = max (1). */
|
|
52
|
+
function pointerCoordToVerticalRatio(pointerCoord, trackStart, trackSize, _thumbSize) {
|
|
53
|
+
if (trackSize <= 0) {
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
return clamp((trackStart + trackSize - pointerCoord) / trackSize, 0, 1);
|
|
57
|
+
}
|
|
58
|
+
function snapToStep(value, min, max, step) {
|
|
59
|
+
if (step <= 0) {
|
|
60
|
+
return clamp(value, min, max);
|
|
61
|
+
}
|
|
62
|
+
const stepped = min + Math.round((value - min) / step) * step;
|
|
63
|
+
return clamp(stepped, min, max);
|
|
64
|
+
}
|
|
65
|
+
function valueToPercent(value, min, max) {
|
|
66
|
+
if (max <= min) {
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
return (clamp(value, min, max) - min) / (max - min) * 100;
|
|
70
|
+
}
|
|
71
|
+
function percentToValue(percent, min, max, step) {
|
|
72
|
+
const ratio = clamp(percent, 0, 100) / 100;
|
|
73
|
+
return snapToStep(min + ratio * (max - min), min, max, step);
|
|
74
|
+
}
|
|
75
|
+
function formatSliderValue(value) {
|
|
76
|
+
return Number.isInteger(value) ? String(value) : value.toFixed(1);
|
|
77
|
+
}
|
|
78
|
+
function getMarkerStepValues(min, max, step) {
|
|
79
|
+
if (step <= 0 || max <= min) {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
const decimals = getDecimalPlaces(step);
|
|
83
|
+
const stepCount = Math.floor((max - min) / step);
|
|
84
|
+
const values = Array.from({
|
|
85
|
+
length: stepCount + 1
|
|
86
|
+
}, (_, index) => roundTo(min + index * step, decimals));
|
|
87
|
+
if (values[values.length - 1] < max) {
|
|
88
|
+
values.push(max);
|
|
89
|
+
}
|
|
90
|
+
return values;
|
|
91
|
+
}
|
|
92
|
+
function getDecimalPlaces(n) {
|
|
93
|
+
const str = String(n);
|
|
94
|
+
const dotIndex = str.indexOf('.');
|
|
95
|
+
return dotIndex === -1 ? 0 : str.length - dotIndex - 1;
|
|
96
|
+
}
|
|
97
|
+
function roundTo(value, decimals) {
|
|
98
|
+
const factor = 10 ** decimals;
|
|
99
|
+
return Math.round(value * factor) / factor;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Marker leading-edge offset (center-aligned to the thumb coordinate system). */
|
|
103
|
+
function percentToMarkerCenterOffset(percent, trackSize, markerSize = SLIDER_MARKER_SIZE) {
|
|
104
|
+
if (trackSize <= 0) return 0;
|
|
105
|
+
return clamp(percent, 0, 100) / 100 * trackSize - markerSize / 2;
|
|
106
|
+
}
|
|
107
|
+
function getMarkerPositionStyle(percent, orientation, trackLayout, _thumbSize, markerSize = SLIDER_MARKER_SIZE) {
|
|
108
|
+
const trackSize = trackLayout == null ? 0 : orientation === 'horizontal' ? trackLayout.width : trackLayout.height;
|
|
109
|
+
if (trackSize > 0) {
|
|
110
|
+
const offset = percentToMarkerCenterOffset(percent, trackSize, markerSize);
|
|
111
|
+
if (orientation === 'vertical') {
|
|
112
|
+
return {
|
|
113
|
+
position: 'absolute',
|
|
114
|
+
left: '50%',
|
|
115
|
+
bottom: offset,
|
|
116
|
+
width: markerSize,
|
|
117
|
+
height: markerSize,
|
|
118
|
+
marginLeft: -markerSize / 2
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
position: 'absolute',
|
|
123
|
+
top: '50%',
|
|
124
|
+
left: offset,
|
|
125
|
+
width: markerSize,
|
|
126
|
+
height: markerSize,
|
|
127
|
+
marginTop: -markerSize / 2
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (orientation === 'vertical') {
|
|
131
|
+
return {
|
|
132
|
+
position: 'absolute',
|
|
133
|
+
left: '50%',
|
|
134
|
+
bottom: toPercentDimension(percent),
|
|
135
|
+
width: markerSize,
|
|
136
|
+
height: markerSize,
|
|
137
|
+
marginLeft: -markerSize / 2,
|
|
138
|
+
transform: [{
|
|
139
|
+
translateY: markerSize / 2
|
|
140
|
+
}]
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
position: 'absolute',
|
|
145
|
+
top: '50%',
|
|
146
|
+
left: toPercentDimension(percent),
|
|
147
|
+
width: markerSize,
|
|
148
|
+
height: markerSize,
|
|
149
|
+
marginTop: -markerSize / 2,
|
|
150
|
+
transform: [{
|
|
151
|
+
translateX: -markerSize / 2
|
|
152
|
+
}]
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["toPercentDimension","percent","String","SLIDER_MARKER_SIZE","exports","clamp","value","min","max","Math","getThumbTravel","trackSize","_thumbSize","percentToThumbOffset","thumbSize","percentToFillExtent","pointerCoordToRatio","pointerCoord","trackStart","pointerCoordToVerticalRatio","snapToStep","step","stepped","round","valueToPercent","percentToValue","ratio","formatSliderValue","Number","isInteger","toFixed","getMarkerStepValues","decimals","getDecimalPlaces","stepCount","floor","values","Array","from","length","_","index","roundTo","push","n","str","dotIndex","indexOf","factor","percentToMarkerCenterOffset","markerSize","getMarkerPositionStyle","orientation","trackLayout","width","height","offset","position","left","bottom","marginLeft","top","marginTop","transform","translateY","translateX"],"sourceRoot":"../../../src","sources":["slider/utils.ts"],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,SAASA,kBAAkBA,CAACC,OAAe,EAAiB;EAC1D,OAAO,GAAGC,MAAM,CAACD,OAAO,CAAC,GAAG;AAC9B;AAEO,MAAME,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,CAAC;AAE5B,SAASE,KAAKA,CAACC,KAAa,EAAEC,GAAW,EAAEC,GAAW,EAAU;EACrE,OAAOC,IAAI,CAACF,GAAG,CAACC,GAAG,EAAEC,IAAI,CAACD,GAAG,CAACD,GAAG,EAAED,KAAK,CAAC,CAAC;AAC5C;AAEO,SAASI,cAAcA,CAACC,SAAiB,EAAEC,UAAkB,EAAU;EAC5E,OAAOH,IAAI,CAACD,GAAG,CAACG,SAAS,EAAE,CAAC,C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CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.assignRef = assignRef;
|
|
7
|
+
function assignRef(ref, value) {
|
|
8
|
+
if (typeof ref === 'function') {
|
|
9
|
+
ref(value);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (ref) {
|
|
13
|
+
ref.current = value;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=assignRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["assignRef","ref","value","current"],"sourceRoot":"../../../src","sources":["utils/assignRef.ts"],"mappings":";;;;;;AAEO,SAASA,SAASA,CAAIC,GAAoB,EAAEC,KAAe,EAAE;EAClE,IAAI,OAAOD,GAAG,KAAK,UAAU,EAAE;IAC7BA,GAAG,CAACC,KAAK,CAAC;IACV;EACF;EACA,IAAID,GAAG,EAAE;IACPA,GAAG,CAACE,OAAO,GAAGD,KAAK;EACrB;AACF","ignoreList":[]}
|