@momo-kits/slider 0.73.3-beta.4 → 0.74.2-react-native.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/Label.tsx +33 -0
- package/helpers.ts +35 -0
- package/hooks.tsx +218 -0
- package/index.tsx +438 -0
- package/package.json +11 -10
- package/publish.sh +1 -1
- package/styles.ts +36 -0
- package/DefaultLabel.js +0 -83
- package/DefaultLabel.web.js +0 -83
- package/DefaultMarker.js +0 -67
- package/DefaultMarker.web.js +0 -75
- package/Slider.js +0 -781
- package/Slider.web.js +0 -761
- package/converters.js +0 -80
- package/index.js +0 -3
package/index.tsx
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
memo,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from 'react';
|
|
10
|
+
import {
|
|
11
|
+
Animated,
|
|
12
|
+
GestureResponderEvent,
|
|
13
|
+
PanResponder,
|
|
14
|
+
PanResponderGestureState,
|
|
15
|
+
View,
|
|
16
|
+
ViewProps,
|
|
17
|
+
ViewStyle,
|
|
18
|
+
} from 'react-native';
|
|
19
|
+
|
|
20
|
+
import styles from './styles';
|
|
21
|
+
import {
|
|
22
|
+
useLabelContainerProps,
|
|
23
|
+
useLowHigh,
|
|
24
|
+
useSelectedRail,
|
|
25
|
+
useThumbFollower,
|
|
26
|
+
useWidthLayout,
|
|
27
|
+
} from './hooks';
|
|
28
|
+
import {clamp, getValueForPosition, isLowCloser} from './helpers';
|
|
29
|
+
import {ApplicationContext, Radius, Shadow} from '@momo-kits/foundation';
|
|
30
|
+
|
|
31
|
+
const trueFunc = () => true;
|
|
32
|
+
const falseFunc = () => false;
|
|
33
|
+
|
|
34
|
+
export interface SliderProps extends ViewProps {
|
|
35
|
+
/**
|
|
36
|
+
* Specifies the minimum value permitted for selection in the slider. This value sets the lower
|
|
37
|
+
* bound for the component.
|
|
38
|
+
*/
|
|
39
|
+
min: number;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Specifies the maximum value allowed for selection. This value sets the upper bound for the component.
|
|
43
|
+
*/
|
|
44
|
+
max: number;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Optional. Defines the minimum permitted range between the low and high values of the slider.
|
|
48
|
+
* Particularly useful when 'low' and 'high' values both exist, ensuring a certain spread between them.
|
|
49
|
+
*/
|
|
50
|
+
minRange?: number;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Specifies the interval between individual step values. The slider's handle will move only in these increments.
|
|
54
|
+
*/
|
|
55
|
+
step: number;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Optional. Represents the initial lower value of the range when the component is used as a range slider.
|
|
59
|
+
* This value is part of the selected range, between 'min' and 'high'.
|
|
60
|
+
*/
|
|
61
|
+
low?: number;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Optional. Represents the initial upper value of the range when used as a range slider.
|
|
65
|
+
* This value is part of the selected range, between 'low' and 'max'.
|
|
66
|
+
*/
|
|
67
|
+
high?: number;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Optional. If `true`, allows the label to extend beyond the width of the Slider component itself,
|
|
71
|
+
* rather than being clipped at the component boundaries. Defaults to `false` if not provided.
|
|
72
|
+
*/
|
|
73
|
+
allowLabelOverflow?: boolean;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Optional. If `true`, disables the range functionality of the slider, turning it into a regular
|
|
77
|
+
* single-value slider. Defaults to `false` if not provided.
|
|
78
|
+
*/
|
|
79
|
+
disableRange?: boolean;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Optional. If `true`, the 'high' handle of the slider will be disabled and cannot be moved.
|
|
83
|
+
* Useful for setting a maximum limit that users cannot increase. Defaults to `false` if not provided.
|
|
84
|
+
*/
|
|
85
|
+
disabledHigh?: boolean;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Optional. If `true`, the 'low' handle of the slider will be disabled and cannot be moved.
|
|
89
|
+
* Useful for setting a minimum limit that users cannot decrease. Defaults to `false` if not provided.
|
|
90
|
+
*/
|
|
91
|
+
disabledLow?: boolean;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Optional. If `true`, labels will be displayed in a floating manner above the slider handles,
|
|
95
|
+
* typically used to display the current value. Defaults to `false` if not provided.
|
|
96
|
+
*/
|
|
97
|
+
floatingLabel?: boolean;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Optional. A callback function triggered when the slider value changes, either by the user or programmatically.
|
|
101
|
+
* It receives the new low and high values of the slider, as well as a boolean indicating if the change was made by the user.
|
|
102
|
+
*/
|
|
103
|
+
onValueChanged?: (low: number, high: number, byUser: boolean) => void;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Optional. A callback function triggered when the user starts touching the slider's draggable area.
|
|
107
|
+
* It receives the current low and high values of the slider.
|
|
108
|
+
*/
|
|
109
|
+
onSliderTouchStart?: (low: number, high: number) => void;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Optional. A callback function triggered when the user releases the slider's draggable area.
|
|
113
|
+
* It receives the current low and high values of the slider.
|
|
114
|
+
*/
|
|
115
|
+
onSliderTouchEnd?: (low: number, high: number) => void;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const Slider: React.FC<SliderProps> = memo(({
|
|
119
|
+
min,
|
|
120
|
+
max,
|
|
121
|
+
minRange = 0,
|
|
122
|
+
step,
|
|
123
|
+
low: lowProp,
|
|
124
|
+
high: highProp,
|
|
125
|
+
floatingLabel = false,
|
|
126
|
+
allowLabelOverflow = false,
|
|
127
|
+
disableRange = false,
|
|
128
|
+
disabledHigh = false,
|
|
129
|
+
disabledLow = false,
|
|
130
|
+
onValueChanged,
|
|
131
|
+
onSliderTouchStart,
|
|
132
|
+
onSliderTouchEnd,
|
|
133
|
+
...restProps
|
|
134
|
+
}) => {
|
|
135
|
+
const {theme} = useContext(ApplicationContext);
|
|
136
|
+
|
|
137
|
+
const {inPropsRef, inPropsRefPrev, setLow, setHigh} = useLowHigh(
|
|
138
|
+
lowProp,
|
|
139
|
+
disableRange ? max : highProp,
|
|
140
|
+
min,
|
|
141
|
+
max,
|
|
142
|
+
step,
|
|
143
|
+
);
|
|
144
|
+
const lowThumbXRef = useRef(new Animated.Value(0));
|
|
145
|
+
const highThumbXRef = useRef(new Animated.Value(0));
|
|
146
|
+
const pointerX = useRef(new Animated.Value(0)).current;
|
|
147
|
+
const {current: lowThumbX} = lowThumbXRef;
|
|
148
|
+
const {current: highThumbX} = highThumbXRef;
|
|
149
|
+
|
|
150
|
+
const gestureStateRef = useRef({isLow: true, lastValue: 0, lastPosition: 0});
|
|
151
|
+
const [isPressed, setPressed] = useState(false);
|
|
152
|
+
|
|
153
|
+
const containerWidthRef = useRef(0);
|
|
154
|
+
const [thumbWidth, setThumbWidth] = useState(0);
|
|
155
|
+
|
|
156
|
+
const [selectedRailStyle, updateSelectedRail] = useSelectedRail(
|
|
157
|
+
inPropsRef,
|
|
158
|
+
containerWidthRef,
|
|
159
|
+
thumbWidth,
|
|
160
|
+
disableRange,
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
const updateThumbs = useCallback(() => {
|
|
164
|
+
const {current: containerWidth} = containerWidthRef;
|
|
165
|
+
if (!thumbWidth || !containerWidth) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const {low, high} = inPropsRef.current;
|
|
169
|
+
if (!disableRange) {
|
|
170
|
+
const {current: highThumbX} = highThumbXRef;
|
|
171
|
+
const highPosition =
|
|
172
|
+
((high - min) / (max - min)) * (containerWidth - thumbWidth);
|
|
173
|
+
highThumbX.setValue(highPosition);
|
|
174
|
+
}
|
|
175
|
+
const {current: lowThumbX} = lowThumbXRef;
|
|
176
|
+
const lowPosition =
|
|
177
|
+
((low - min) / (max - min)) * (containerWidth - thumbWidth);
|
|
178
|
+
lowThumbX.setValue(lowPosition);
|
|
179
|
+
typeof updateSelectedRail === 'function' && updateSelectedRail();
|
|
180
|
+
onValueChanged?.(low, high, false);
|
|
181
|
+
}, [
|
|
182
|
+
disableRange,
|
|
183
|
+
inPropsRef,
|
|
184
|
+
max,
|
|
185
|
+
min,
|
|
186
|
+
onValueChanged,
|
|
187
|
+
thumbWidth,
|
|
188
|
+
updateSelectedRail,
|
|
189
|
+
]);
|
|
190
|
+
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
const {lowPrev, highPrev} = inPropsRefPrev;
|
|
193
|
+
if (
|
|
194
|
+
(lowProp !== undefined && lowProp !== lowPrev) ||
|
|
195
|
+
(highProp !== undefined && highProp !== highPrev)
|
|
196
|
+
) {
|
|
197
|
+
updateThumbs();
|
|
198
|
+
}
|
|
199
|
+
}, [highProp, inPropsRefPrev.lowPrev, inPropsRefPrev.highPrev, lowProp]);
|
|
200
|
+
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
updateThumbs();
|
|
203
|
+
}, [updateThumbs]);
|
|
204
|
+
|
|
205
|
+
const handleContainerLayout = useWidthLayout(containerWidthRef, updateThumbs);
|
|
206
|
+
const handleThumbLayout = useCallback(
|
|
207
|
+
({nativeEvent}) => {
|
|
208
|
+
const {
|
|
209
|
+
layout: {width},
|
|
210
|
+
} = nativeEvent;
|
|
211
|
+
if (thumbWidth !== width) {
|
|
212
|
+
setThumbWidth(width);
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
[thumbWidth],
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
const lowStyles = useMemo(() => {
|
|
219
|
+
return {transform: [{translateX: lowThumbX}]};
|
|
220
|
+
}, [lowThumbX]);
|
|
221
|
+
|
|
222
|
+
const highStyles = useMemo(() => {
|
|
223
|
+
return disableRange
|
|
224
|
+
? null
|
|
225
|
+
: [styles.highThumbContainer, {transform: [{translateX: highThumbX}]}];
|
|
226
|
+
}, [disableRange, highThumbX]);
|
|
227
|
+
|
|
228
|
+
const railContainerStyles = useMemo(() => {
|
|
229
|
+
return [styles.railsContainer, {marginHorizontal: thumbWidth / 2}];
|
|
230
|
+
}, [thumbWidth]);
|
|
231
|
+
|
|
232
|
+
const [labelView, labelUpdate] = useThumbFollower(
|
|
233
|
+
containerWidthRef,
|
|
234
|
+
gestureStateRef,
|
|
235
|
+
isPressed,
|
|
236
|
+
allowLabelOverflow,
|
|
237
|
+
disabledLow,
|
|
238
|
+
disabledHigh,
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
const renderThumb = (name: string) => {
|
|
242
|
+
const isDisabled =
|
|
243
|
+
(name === 'low' && disabledLow) || (name === 'high' && disabledHigh);
|
|
244
|
+
|
|
245
|
+
const thumbColor = isDisabled
|
|
246
|
+
? theme.colors.text.disable
|
|
247
|
+
: theme.colors.primary;
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<View
|
|
251
|
+
style={[
|
|
252
|
+
Shadow.Light,
|
|
253
|
+
{
|
|
254
|
+
width: 20,
|
|
255
|
+
height: 20,
|
|
256
|
+
borderRadius: Radius.M,
|
|
257
|
+
borderWidth: 4,
|
|
258
|
+
borderColor: theme.colors.background.surface,
|
|
259
|
+
backgroundColor: thumbColor,
|
|
260
|
+
},
|
|
261
|
+
]}
|
|
262
|
+
/>
|
|
263
|
+
);
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const lowThumb = renderThumb('low');
|
|
267
|
+
const highThumb = renderThumb('high');
|
|
268
|
+
|
|
269
|
+
const labelContainerProps = useLabelContainerProps(floatingLabel);
|
|
270
|
+
|
|
271
|
+
const {panHandlers} = useMemo(
|
|
272
|
+
() =>
|
|
273
|
+
PanResponder.create({
|
|
274
|
+
onStartShouldSetPanResponderCapture: falseFunc,
|
|
275
|
+
onMoveShouldSetPanResponderCapture: falseFunc,
|
|
276
|
+
onPanResponderTerminationRequest: falseFunc,
|
|
277
|
+
onPanResponderTerminate: trueFunc,
|
|
278
|
+
onShouldBlockNativeResponder: trueFunc,
|
|
279
|
+
|
|
280
|
+
onMoveShouldSetPanResponder: (
|
|
281
|
+
evt: GestureResponderEvent,
|
|
282
|
+
gestureState: PanResponderGestureState,
|
|
283
|
+
) => Math.abs(gestureState.dx) > 2 * Math.abs(gestureState.dy),
|
|
284
|
+
|
|
285
|
+
onPanResponderGrant: ({nativeEvent}, gestureState) => {
|
|
286
|
+
const {numberActiveTouches} = gestureState;
|
|
287
|
+
if (numberActiveTouches > 1) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
setPressed(true);
|
|
291
|
+
const {current: lowThumbX} = lowThumbXRef;
|
|
292
|
+
const {current: highThumbX} = highThumbXRef;
|
|
293
|
+
const {locationX: downX, pageX} = nativeEvent;
|
|
294
|
+
const containerX = pageX - downX;
|
|
295
|
+
|
|
296
|
+
const {low, high, min, max} = inPropsRef.current;
|
|
297
|
+
onSliderTouchStart?.(low, high);
|
|
298
|
+
const containerWidth = containerWidthRef.current;
|
|
299
|
+
|
|
300
|
+
const lowPosition =
|
|
301
|
+
thumbWidth / 2 +
|
|
302
|
+
((low - min) / (max - min)) * (containerWidth - thumbWidth);
|
|
303
|
+
const highPosition =
|
|
304
|
+
thumbWidth / 2 +
|
|
305
|
+
((high - min) / (max - min)) * (containerWidth - thumbWidth);
|
|
306
|
+
|
|
307
|
+
const isLow =
|
|
308
|
+
disableRange || isLowCloser(downX, lowPosition, highPosition);
|
|
309
|
+
gestureStateRef.current.isLow = isLow;
|
|
310
|
+
|
|
311
|
+
if ((isLow && disabledLow) || (!isLow && disabledHigh)) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const handlePositionChange = (positionInView: number) => {
|
|
316
|
+
const {low, high, min, max, step} = inPropsRef.current;
|
|
317
|
+
const minValue = isLow ? min : low + minRange;
|
|
318
|
+
const maxValue = isLow ? high - minRange : max;
|
|
319
|
+
const value = clamp(
|
|
320
|
+
getValueForPosition(
|
|
321
|
+
positionInView,
|
|
322
|
+
containerWidth,
|
|
323
|
+
thumbWidth,
|
|
324
|
+
min,
|
|
325
|
+
max,
|
|
326
|
+
step,
|
|
327
|
+
),
|
|
328
|
+
minValue,
|
|
329
|
+
maxValue,
|
|
330
|
+
);
|
|
331
|
+
if (gestureStateRef.current.lastValue === value) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const availableSpace = containerWidth - thumbWidth;
|
|
335
|
+
const absolutePosition =
|
|
336
|
+
((value - min) / (max - min)) * availableSpace;
|
|
337
|
+
gestureStateRef.current.lastValue = value;
|
|
338
|
+
gestureStateRef.current.lastPosition =
|
|
339
|
+
absolutePosition + thumbWidth / 2;
|
|
340
|
+
(isLow ? lowThumbX : highThumbX).setValue(absolutePosition);
|
|
341
|
+
onValueChanged?.(isLow ? value : low, isLow ? high : value, true);
|
|
342
|
+
(isLow ? setLow : setHigh)(value);
|
|
343
|
+
labelUpdate &&
|
|
344
|
+
typeof labelUpdate === 'function' &&
|
|
345
|
+
labelUpdate(gestureStateRef.current.lastPosition, value);
|
|
346
|
+
|
|
347
|
+
typeof updateSelectedRail === 'function' && updateSelectedRail();
|
|
348
|
+
};
|
|
349
|
+
handlePositionChange(downX);
|
|
350
|
+
pointerX.removeAllListeners();
|
|
351
|
+
pointerX.addListener(({value: pointerPosition}) => {
|
|
352
|
+
const positionInView = pointerPosition - containerX;
|
|
353
|
+
handlePositionChange(positionInView);
|
|
354
|
+
});
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
onPanResponderMove: (evt, gestureState) => {
|
|
358
|
+
if (gestureStateRef.current.isLow ? disabledLow : disabledHigh) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
Animated.event([null, {moveX: pointerX}], {
|
|
363
|
+
useNativeDriver: false,
|
|
364
|
+
})(evt, gestureState);
|
|
365
|
+
},
|
|
366
|
+
|
|
367
|
+
onPanResponderRelease: () => {
|
|
368
|
+
setPressed(false);
|
|
369
|
+
const {low, high} = inPropsRef.current;
|
|
370
|
+
if (
|
|
371
|
+
(gestureStateRef.current.isLow && disabledLow) ||
|
|
372
|
+
(!gestureStateRef.current.isLow && disabledHigh)
|
|
373
|
+
) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
onSliderTouchEnd?.(low, high);
|
|
377
|
+
},
|
|
378
|
+
}),
|
|
379
|
+
[
|
|
380
|
+
pointerX,
|
|
381
|
+
inPropsRef,
|
|
382
|
+
thumbWidth,
|
|
383
|
+
disableRange,
|
|
384
|
+
onValueChanged,
|
|
385
|
+
disabledHigh,
|
|
386
|
+
disabledLow,
|
|
387
|
+
setLow,
|
|
388
|
+
setHigh,
|
|
389
|
+
labelUpdate,
|
|
390
|
+
updateSelectedRail,
|
|
391
|
+
],
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
const renderTrack = (color: string) => {
|
|
395
|
+
return (
|
|
396
|
+
<View
|
|
397
|
+
style={{
|
|
398
|
+
width: '100%',
|
|
399
|
+
height: 4,
|
|
400
|
+
borderRadius: Radius.L,
|
|
401
|
+
backgroundColor: color,
|
|
402
|
+
}}
|
|
403
|
+
/>
|
|
404
|
+
);
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
const trackColor =
|
|
408
|
+
disabledHigh && disabledLow
|
|
409
|
+
? theme.colors.text.disable
|
|
410
|
+
: theme.colors.primary;
|
|
411
|
+
|
|
412
|
+
return (
|
|
413
|
+
<View {...restProps}>
|
|
414
|
+
<View {...labelContainerProps}>{labelView}</View>
|
|
415
|
+
<View onLayout={handleContainerLayout} style={styles.controlsContainer}>
|
|
416
|
+
<View style={railContainerStyles}>
|
|
417
|
+
{renderTrack(theme.colors.background.default)}
|
|
418
|
+
<Animated.View style={selectedRailStyle as ViewStyle}>
|
|
419
|
+
{renderTrack(trackColor)}
|
|
420
|
+
</Animated.View>
|
|
421
|
+
</View>
|
|
422
|
+
<Animated.View style={lowStyles} onLayout={handleThumbLayout}>
|
|
423
|
+
{lowThumb}
|
|
424
|
+
</Animated.View>
|
|
425
|
+
{!disableRange && (
|
|
426
|
+
<Animated.View style={highStyles}>{highThumb}</Animated.View>
|
|
427
|
+
)}
|
|
428
|
+
<View
|
|
429
|
+
{...panHandlers}
|
|
430
|
+
style={styles.touchableArea}
|
|
431
|
+
collapsable={false}
|
|
432
|
+
/>
|
|
433
|
+
</View>
|
|
434
|
+
</View>
|
|
435
|
+
);
|
|
436
|
+
})
|
|
437
|
+
|
|
438
|
+
export {Slider};
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/slider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.2-react-native.1",
|
|
4
4
|
"private": false,
|
|
5
|
-
"main": "index.
|
|
6
|
-
"dependencies": {},
|
|
5
|
+
"main": "index.tsx",
|
|
7
6
|
"peerDependencies": {
|
|
8
|
-
"@momo-kits/
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"react-native": ">=0.55"
|
|
7
|
+
"@momo-kits/foundation": "latest",
|
|
8
|
+
"react": "*",
|
|
9
|
+
"react-native": "*",
|
|
10
|
+
"prop-types": "15.7.2"
|
|
13
11
|
},
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@momo-platform/versions": "4.1.11"
|
|
14
|
+
},
|
|
15
|
+
"license": "MoMo",
|
|
16
|
+
"dependencies": {}
|
|
16
17
|
}
|
package/publish.sh
CHANGED
|
@@ -26,4 +26,4 @@ cd ..
|
|
|
26
26
|
rm -rf dist
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
##curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/
|
|
29
|
+
##curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/slider new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/slider"}'
|
package/styles.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {I18nManager, StyleSheet} from 'react-native';
|
|
2
|
+
import {Colors, Radius, Spacing} from '@momo-kits/foundation';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
controlsContainer: {
|
|
6
|
+
flexDirection: 'row',
|
|
7
|
+
justifyContent: I18nManager.isRTL ? 'flex-end' : 'flex-start',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
},
|
|
10
|
+
highThumbContainer: {
|
|
11
|
+
position: 'absolute',
|
|
12
|
+
},
|
|
13
|
+
railsContainer: {
|
|
14
|
+
...StyleSheet.absoluteFillObject,
|
|
15
|
+
flexDirection: 'row',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
},
|
|
18
|
+
labelFixedContainer: {
|
|
19
|
+
alignItems: I18nManager.isRTL ? 'flex-end' : 'flex-start',
|
|
20
|
+
},
|
|
21
|
+
labelFloatingContainer: {
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
left: 0,
|
|
24
|
+
right: 0,
|
|
25
|
+
alignItems: I18nManager.isRTL ? 'flex-end' : 'flex-start',
|
|
26
|
+
},
|
|
27
|
+
touchableArea: {
|
|
28
|
+
...StyleSheet.absoluteFillObject,
|
|
29
|
+
},
|
|
30
|
+
label: {
|
|
31
|
+
backgroundColor: Colors.black_01,
|
|
32
|
+
paddingVertical: Spacing.XXS,
|
|
33
|
+
paddingHorizontal: Spacing.XS,
|
|
34
|
+
borderRadius: Radius.XS,
|
|
35
|
+
},
|
|
36
|
+
});
|
package/DefaultLabel.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import {View, StyleSheet} from 'react-native';
|
|
4
|
-
import {Text} from '@momo-kits/core-v2';
|
|
5
|
-
|
|
6
|
-
const sliderRadius = 3;
|
|
7
|
-
const width = 50;
|
|
8
|
-
|
|
9
|
-
export default class DefaultLabel extends React.Component {
|
|
10
|
-
render() {
|
|
11
|
-
const {
|
|
12
|
-
oneMarkerValue,
|
|
13
|
-
twoMarkerValue,
|
|
14
|
-
oneMarkerLeftPosition,
|
|
15
|
-
twoMarkerLeftPosition,
|
|
16
|
-
oneMarkerPressed,
|
|
17
|
-
twoMarkerPressed,
|
|
18
|
-
} = this.props;
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<View style={{position: 'relative'}}>
|
|
22
|
-
{Number.isFinite(oneMarkerLeftPosition) &&
|
|
23
|
-
Number.isFinite(oneMarkerValue) && (
|
|
24
|
-
<View
|
|
25
|
-
style={[
|
|
26
|
-
styles.sliderLabel,
|
|
27
|
-
{
|
|
28
|
-
left: oneMarkerLeftPosition - width / 2 + sliderRadius,
|
|
29
|
-
},
|
|
30
|
-
oneMarkerPressed && styles.markerPressed,
|
|
31
|
-
]}>
|
|
32
|
-
<Text style={styles.sliderLabelText}>{oneMarkerValue}</Text>
|
|
33
|
-
</View>
|
|
34
|
-
)}
|
|
35
|
-
|
|
36
|
-
{Number.isFinite(twoMarkerLeftPosition) &&
|
|
37
|
-
Number.isFinite(twoMarkerValue) && (
|
|
38
|
-
<View
|
|
39
|
-
style={[
|
|
40
|
-
styles.sliderLabel,
|
|
41
|
-
{
|
|
42
|
-
left: twoMarkerLeftPosition - width / 2 + sliderRadius,
|
|
43
|
-
},
|
|
44
|
-
twoMarkerPressed && styles.markerPressed,
|
|
45
|
-
]}>
|
|
46
|
-
<Text style={styles.sliderLabelText}>{twoMarkerValue}</Text>
|
|
47
|
-
</View>
|
|
48
|
-
)}
|
|
49
|
-
</View>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const styles = StyleSheet.create({
|
|
55
|
-
sliderLabel: {
|
|
56
|
-
position: 'absolute',
|
|
57
|
-
bottom: 0,
|
|
58
|
-
minWidth: width,
|
|
59
|
-
padding: 8,
|
|
60
|
-
backgroundColor: '#f1f1f1',
|
|
61
|
-
},
|
|
62
|
-
sliderLabelText: {
|
|
63
|
-
alignItems: 'center',
|
|
64
|
-
textAlign: 'center',
|
|
65
|
-
fontStyle: 'normal',
|
|
66
|
-
// fontSize: 11,
|
|
67
|
-
},
|
|
68
|
-
markerPressed: {
|
|
69
|
-
borderWidth: 2,
|
|
70
|
-
borderColor: '#999',
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
DefaultLabel.propTypes = {
|
|
75
|
-
oneMarkerValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
76
|
-
twoMarkerValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
77
|
-
|
|
78
|
-
oneMarkerLeftPosition: PropTypes.number,
|
|
79
|
-
twoMarkerLeftPosition: PropTypes.number,
|
|
80
|
-
|
|
81
|
-
oneMarkerPressed: PropTypes.bool,
|
|
82
|
-
twoMarkerPressed: PropTypes.bool,
|
|
83
|
-
};
|
package/DefaultLabel.web.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import {View, StyleSheet} from 'react-native';
|
|
4
|
-
import Text from '../../core/components/typography';
|
|
5
|
-
|
|
6
|
-
const sliderRadius = 3;
|
|
7
|
-
const width = 50;
|
|
8
|
-
|
|
9
|
-
export default class DefaultLabel extends React.Component {
|
|
10
|
-
render() {
|
|
11
|
-
const {
|
|
12
|
-
oneMarkerValue,
|
|
13
|
-
twoMarkerValue,
|
|
14
|
-
oneMarkerLeftPosition,
|
|
15
|
-
twoMarkerLeftPosition,
|
|
16
|
-
oneMarkerPressed,
|
|
17
|
-
twoMarkerPressed,
|
|
18
|
-
} = this.props;
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<View style={{position: 'relative'}}>
|
|
22
|
-
{Number.isFinite(oneMarkerLeftPosition) &&
|
|
23
|
-
Number.isFinite(oneMarkerValue) && (
|
|
24
|
-
<View
|
|
25
|
-
style={[
|
|
26
|
-
styles.sliderLabel,
|
|
27
|
-
{
|
|
28
|
-
left: oneMarkerLeftPosition - width / 2 + sliderRadius,
|
|
29
|
-
},
|
|
30
|
-
oneMarkerPressed && styles.markerPressed,
|
|
31
|
-
]}>
|
|
32
|
-
<Text style={styles.sliderLabelText}>{oneMarkerValue}</Text>
|
|
33
|
-
</View>
|
|
34
|
-
)}
|
|
35
|
-
|
|
36
|
-
{Number.isFinite(twoMarkerLeftPosition) &&
|
|
37
|
-
Number.isFinite(twoMarkerValue) && (
|
|
38
|
-
<View
|
|
39
|
-
style={[
|
|
40
|
-
styles.sliderLabel,
|
|
41
|
-
{
|
|
42
|
-
left: twoMarkerLeftPosition - width / 2 + sliderRadius,
|
|
43
|
-
},
|
|
44
|
-
twoMarkerPressed && styles.markerPressed,
|
|
45
|
-
]}>
|
|
46
|
-
<Text style={styles.sliderLabelText}>{twoMarkerValue}</Text>
|
|
47
|
-
</View>
|
|
48
|
-
)}
|
|
49
|
-
</View>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const styles = StyleSheet.create({
|
|
55
|
-
sliderLabel: {
|
|
56
|
-
position: 'absolute',
|
|
57
|
-
bottom: 0,
|
|
58
|
-
minWidth: width,
|
|
59
|
-
padding: 8,
|
|
60
|
-
backgroundColor: '#f1f1f1',
|
|
61
|
-
},
|
|
62
|
-
sliderLabelText: {
|
|
63
|
-
alignItems: 'center',
|
|
64
|
-
textAlign: 'center',
|
|
65
|
-
fontStyle: 'normal',
|
|
66
|
-
// fontSize: 11,
|
|
67
|
-
},
|
|
68
|
-
markerPressed: {
|
|
69
|
-
borderWidth: 2,
|
|
70
|
-
borderColor: '#999',
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
DefaultLabel.propTypes = {
|
|
75
|
-
oneMarkerValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
76
|
-
twoMarkerValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
77
|
-
|
|
78
|
-
oneMarkerLeftPosition: PropTypes.number,
|
|
79
|
-
twoMarkerLeftPosition: PropTypes.number,
|
|
80
|
-
|
|
81
|
-
oneMarkerPressed: PropTypes.bool,
|
|
82
|
-
twoMarkerPressed: PropTypes.bool,
|
|
83
|
-
};
|