related-ui-components 2.7.0 → 2.7.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/lib/module/app.js +11 -8
- package/lib/module/app.js.map +1 -1
- package/lib/module/components/RangeSlider/RangeSlider.js +36 -15
- package/lib/module/components/RangeSlider/RangeSlider.js.map +1 -1
- package/lib/module/components/RangeSlider/SliderLabel.js +3 -6
- package/lib/module/components/RangeSlider/SliderLabel.js.map +1 -1
- package/lib/module/index.js +0 -3
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/app.d.ts.map +1 -1
- package/lib/typescript/src/components/RangeSlider/RangeSlider.d.ts.map +1 -1
- package/lib/typescript/src/components/RangeSlider/SliderLabel.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/app.tsx +5 -4
- package/src/components/RangeSlider/RangeSlider.tsx +49 -25
- package/src/components/RangeSlider/SliderLabel.tsx +9 -15
- package/src/index.ts +0 -3
package/lib/module/app.js
CHANGED
|
@@ -4,8 +4,8 @@ import React, { useState } from "react";
|
|
|
4
4
|
import { SafeAreaView, StyleSheet, StatusBar } from "react-native";
|
|
5
5
|
// Adjust path as needed
|
|
6
6
|
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
7
|
+
import { RangeSlider } from "./components/index.js";
|
|
7
8
|
import { lightTheme, RelatedProvider, useTheme } from "./theme/index.js";
|
|
8
|
-
import PhoneInput from "./components/Input/PhoneInput.js";
|
|
9
9
|
import { BottomSheetStackProvider } from "./contexts/index.js";
|
|
10
10
|
import { SafeAreaProvider } from "react-native-safe-area-context";
|
|
11
11
|
|
|
@@ -63,12 +63,13 @@ const App = () => {
|
|
|
63
63
|
barStyle: "light-content"
|
|
64
64
|
}), /*#__PURE__*/_jsx(SafeAreaView, {
|
|
65
65
|
style: styles.appContainer,
|
|
66
|
-
children: /*#__PURE__*/_jsx(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
children: /*#__PURE__*/_jsx(RangeSlider, {
|
|
67
|
+
initialMinValue: 0,
|
|
68
|
+
initialMaxValue: 100,
|
|
69
|
+
min: 0,
|
|
70
|
+
max: 500,
|
|
71
|
+
sliderWidth: 300,
|
|
72
|
+
onValueChange: console.log
|
|
72
73
|
})
|
|
73
74
|
})]
|
|
74
75
|
})
|
|
@@ -81,7 +82,9 @@ const styles = StyleSheet.create({
|
|
|
81
82
|
appContainer: {
|
|
82
83
|
flex: 1,
|
|
83
84
|
backgroundColor: "grey",
|
|
84
|
-
justifyContent: "center"
|
|
85
|
+
justifyContent: "center",
|
|
86
|
+
// Center the carousel vertically if it's the main content
|
|
87
|
+
alignItems: "center"
|
|
85
88
|
}
|
|
86
89
|
});
|
|
87
90
|
export default App;
|
package/lib/module/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useState","SafeAreaView","StyleSheet","StatusBar","GestureHandlerRootView","lightTheme","RelatedProvider","useTheme","
|
|
1
|
+
{"version":3,"names":["React","useState","SafeAreaView","StyleSheet","StatusBar","GestureHandlerRootView","RangeSlider","lightTheme","RelatedProvider","useTheme","BottomSheetStackProvider","SafeAreaProvider","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DUMMY_DATA","id","image","title","App","theme","departureDate","setDepartureDate","undefined","returnDate","setReturnDate","progress","setProgress","handleAnimate","newProgress","Math","floor","random","children","style","flex","barStyle","styles","appContainer","initialMinValue","initialMaxValue","min","max","sliderWidth","onValueChange","console","log","create","backgroundColor","justifyContent","alignItems"],"sourceRoot":"..\\..\\src","sources":["app.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAeC,QAAQ,QAAQ,OAAO;AAClD,SAASC,YAAY,EAAEC,UAAU,EAAEC,SAAS,QAAkC,cAAc;AACV;AAClF,SAASC,sBAAsB,QAAQ,8BAA8B;AACrE,SAQEC,WAAW,QACN,uBAAc;AACrB,SAASC,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E;QAAE,CAAE;QAAAF,QAAA,eACzCvB,IAAA,CAACL,eAAe;UAACe,KAAK,EAAEhB,UAAW;UAAA6B,QAAA,eACjCrB,KAAA,CAACL,wBAAwB;YAAA0B,QAAA,gBACvBvB,IAAA,CAACT,SAAS;cAACmC,QAAQ,EAAC;YAAe,CAAE,CAAC,eACtC1B,IAAA,CAACX,YAAY;cAACmC,KAAK,EAAEG,MAAM,CAACC,YAAa;cAAAL,QAAA,eAgDvCvB,IAAA,CAACP,WAAW;gBAACoC,eAAe,EAAE,CAAE;gBAACC,eAAe,EAAE,GAAI;gBAACC,GAAG,EAAE,CAAE;gBAACC,GAAG,EAAE,GAAI;gBAACC,WAAW,EAAE,GAAI;gBAACC,aAAa,EAAEC,OAAO,CAACC;cAAI,CAAc;YAAC,CAMzH,CAAC;UAAA,CACS;QAAC,CACZ;MAAC,CACI;IAAC,CACT;EAAC,CACnB,CAAC;AAEP,CAAC;AAED,MAAMT,MAAM,GAAGrC,UAAU,CAAC+C,MAAM,CAAC;EAC/BT,YAAY,EAAE;IACZH,IAAI,EAAE,CAAC;IACPa,eAAe,EAAE,MAAM;IACvBC,cAAc,EAAE,QAAQ;IAAE;IAC1BC,UAAU,EAAC;EACb;AACF,CAAC,CAAC;AAEF,eAAe/B,GAAG","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React, { useCallback, useState } from "react";
|
|
4
|
-
import { StyleSheet, View } from "react-native";
|
|
4
|
+
import { I18nManager, StyleSheet, View } from "react-native";
|
|
5
5
|
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
6
6
|
import Animated, { runOnJS, useAnimatedStyle, useSharedValue } from "react-native-reanimated";
|
|
7
7
|
import { SliderLabels } from "./SliderLabel.js";
|
|
@@ -25,21 +25,28 @@ const RangeSlider = ({
|
|
|
25
25
|
} = useTheme();
|
|
26
26
|
const currTheme = theme || defaultTheme;
|
|
27
27
|
const styles = getStyles(currTheme);
|
|
28
|
+
const isRTL = I18nManager.isRTL;
|
|
28
29
|
|
|
29
30
|
// State for label text values, passed down to the SliderLabels component
|
|
30
31
|
const [leftLabel, setLeftLabel] = useState(initialMinValue.toLocaleString());
|
|
31
32
|
const [rightLabel, setRightLabel] = useState(initialMaxValue.toLocaleString());
|
|
33
|
+
|
|
34
|
+
// These functions correctly map a value to its thumb's CENTER position for both LTR and RTL.
|
|
32
35
|
const valueToPosition = useCallback(value => {
|
|
33
36
|
"worklet";
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
const position = (value - min) / (max - min) * sliderWidth;
|
|
39
|
+
return isRTL ? sliderWidth - position : position;
|
|
40
|
+
}, [min, max, sliderWidth, isRTL]);
|
|
37
41
|
const positionToValue = useCallback(position => {
|
|
38
42
|
"worklet";
|
|
39
43
|
|
|
40
|
-
const
|
|
44
|
+
const pos = isRTL ? sliderWidth - position : position;
|
|
45
|
+
const rawValue = pos / sliderWidth * (max - min) + min;
|
|
41
46
|
return Math.round(rawValue / step) * step;
|
|
42
|
-
}, [min, max, step, sliderWidth]);
|
|
47
|
+
}, [min, max, step, sliderWidth, isRTL]);
|
|
48
|
+
|
|
49
|
+
// 'leftPosition' is for the min value, 'rightPosition' is for the max value.
|
|
43
50
|
const leftPosition = useSharedValue(valueToPosition(initialMinValue));
|
|
44
51
|
const rightPosition = useSharedValue(valueToPosition(initialMaxValue));
|
|
45
52
|
const context = useSharedValue({
|
|
@@ -62,13 +69,17 @@ const RangeSlider = ({
|
|
|
62
69
|
}
|
|
63
70
|
}).onUpdate(e => {
|
|
64
71
|
if (activeThumb.value === null) return;
|
|
72
|
+
|
|
73
|
+
// Invert translation for RTL
|
|
65
74
|
const newPos = context.value.x + e.translationX;
|
|
66
75
|
if (activeThumb.value === "left") {
|
|
67
|
-
|
|
76
|
+
// This is the MINIMUM value thumb
|
|
77
|
+
const clampedPos = isRTL ? Math.min(sliderWidth - THUMB_SIZE / 2, Math.max(newPos, rightPosition.value + THUMB_SIZE)) : Math.max(THUMB_SIZE / 2, Math.min(newPos, rightPosition.value - THUMB_SIZE));
|
|
68
78
|
leftPosition.value = clampedPos;
|
|
69
79
|
runOnJS(setLeftLabel)(positionToValue(clampedPos).toLocaleString());
|
|
70
80
|
} else {
|
|
71
|
-
|
|
81
|
+
// This is the MAXIMUM value thumb
|
|
82
|
+
const clampedPos = isRTL ? Math.max(THUMB_SIZE / 2, Math.min(newPos, leftPosition.value - THUMB_SIZE)) : Math.min(sliderWidth - THUMB_SIZE / 2, Math.max(newPos, leftPosition.value + THUMB_SIZE));
|
|
72
83
|
rightPosition.value = clampedPos;
|
|
73
84
|
runOnJS(setRightLabel)(positionToValue(clampedPos).toLocaleString());
|
|
74
85
|
}
|
|
@@ -82,25 +93,35 @@ const RangeSlider = ({
|
|
|
82
93
|
});
|
|
83
94
|
activeThumb.value = null;
|
|
84
95
|
});
|
|
96
|
+
|
|
97
|
+
// These styles center the thumb on its position value
|
|
85
98
|
const animatedLeftThumbStyle = useAnimatedStyle(() => ({
|
|
86
99
|
transform: [{
|
|
87
|
-
translateX: leftPosition.value
|
|
100
|
+
translateX: leftPosition.value - THUMB_SIZE / 2
|
|
88
101
|
}]
|
|
89
102
|
}));
|
|
90
103
|
const animatedRightThumbStyle = useAnimatedStyle(() => ({
|
|
91
104
|
transform: [{
|
|
92
|
-
translateX: rightPosition.value - THUMB_SIZE
|
|
105
|
+
translateX: rightPosition.value - THUMB_SIZE / 2
|
|
93
106
|
}]
|
|
94
107
|
}));
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
108
|
+
|
|
109
|
+
// This style correctly draws the active rail between the two thumb centers in both LTR and RTL.
|
|
110
|
+
const animatedActiveRailStyle = useAnimatedStyle(() => {
|
|
111
|
+
const start = isRTL ? rightPosition.value : leftPosition.value;
|
|
112
|
+
const end = isRTL ? leftPosition.value : rightPosition.value;
|
|
113
|
+
return {
|
|
114
|
+
left: start,
|
|
115
|
+
width: end - start
|
|
116
|
+
};
|
|
117
|
+
});
|
|
99
118
|
return /*#__PURE__*/_jsxs(View, {
|
|
100
119
|
style: [styles.container, {
|
|
101
120
|
width: sliderWidth
|
|
102
121
|
}],
|
|
103
|
-
children: [/*#__PURE__*/_jsx(SliderLabels
|
|
122
|
+
children: [/*#__PURE__*/_jsx(SliderLabels
|
|
123
|
+
// isRtl={isRTL} // Pass isRTL to SliderLabels so it can adjust accordingly
|
|
124
|
+
, {
|
|
104
125
|
leftValue: leftLabel,
|
|
105
126
|
rightValue: rightLabel,
|
|
106
127
|
leftPosition: leftPosition,
|
|
@@ -134,7 +155,7 @@ const getStyles = theme => StyleSheet.create({
|
|
|
134
155
|
container: {
|
|
135
156
|
height: LABEL_HEIGHT + THUMB_SIZE,
|
|
136
157
|
justifyContent: "center",
|
|
137
|
-
marginTop: LABEL_HEIGHT
|
|
158
|
+
marginTop: LABEL_HEIGHT
|
|
138
159
|
},
|
|
139
160
|
railContainer: {
|
|
140
161
|
justifyContent: "center",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useState","StyleSheet","View","Gesture","GestureDetector","Animated","runOnJS","useAnimatedStyle","useSharedValue","SliderLabels","useTheme","jsx","_jsx","jsxs","_jsxs","THUMB_SIZE","RAIL_HEIGHT","LABEL_HEIGHT","RangeSlider","min","max","step","sliderWidth","initialMinValue","initialMaxValue","onValueChange","theme","defaultTheme","currTheme","styles","getStyles","leftLabel","setLeftLabel","toLocaleString","rightLabel","setRightLabel","valueToPosition","value","positionToValue","
|
|
1
|
+
{"version":3,"names":["React","useCallback","useState","I18nManager","StyleSheet","View","Gesture","GestureDetector","Animated","runOnJS","useAnimatedStyle","useSharedValue","SliderLabels","useTheme","jsx","_jsx","jsxs","_jsxs","THUMB_SIZE","RAIL_HEIGHT","LABEL_HEIGHT","RangeSlider","min","max","step","sliderWidth","initialMinValue","initialMaxValue","onValueChange","theme","defaultTheme","currTheme","styles","getStyles","isRTL","leftLabel","setLeftLabel","toLocaleString","rightLabel","setRightLabel","valueToPosition","value","position","positionToValue","pos","rawValue","Math","round","leftPosition","rightPosition","context","x","activeThumb","panGesture","Pan","onBegin","e","distToLeft","abs","distToRight","onUpdate","newPos","translationX","clampedPos","onEnd","finalLeftValue","finalRightValue","animatedLeftThumbStyle","transform","translateX","animatedRightThumbStyle","animatedActiveRailStyle","start","end","left","width","style","container","children","leftValue","rightValue","thumbSize","gesture","railContainer","rail","activeRail","thumbContainer","thumb","create","height","justifyContent","marginTop","borderRadius","backgroundColor","surface","primary","alignItems","background","borderColor","borderWidth"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/RangeSlider/RangeSlider.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AACpD,SAASC,WAAW,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC5D,SAASC,OAAO,EAAEC,eAAe,QAAQ,8BAA8B;AACvE,OAAOC,QAAQ,IACbC,OAAO,EACPC,gBAAgB,EAChBC,cAAc,QACT,yBAAyB;AAChC,SAASC,YAAY,QAAQ,kBAAe;AAC5C,SAAoBC,QAAQ,QAAQ,sBAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAElD,MAAMC,UAAU,GAAG,EAAE;AACrB,MAAMC,WAAW,GAAG,CAAC;AACrB,MAAMC,YAAY,GAAG,EAAE;AAavB,MAAMC,WAAuC,GAAGA,CAAC;EAC/CC,GAAG;EACHC,GAAG;EACHC,IAAI,GAAG,CAAC;EACRC,WAAW;EACXC,eAAe;EACfC,eAAe;EACfC,aAAa;EACbC;AACF,CAAC,KAAK;EACJ,MAAM;IAAEA,KAAK,EAAEC;EAAa,CAAC,GAAGjB,QAAQ,CAAC,CAAC;EAC1C,MAAMkB,SAAS,GAAGF,KAAK,IAAIC,YAAY;EACvC,MAAME,MAAM,GAAGC,SAAS,CAACF,SAAS,CAAC;EAEnC,MAAMG,K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KAAK,CAACoE,UAAU;IACjCC,WAAW,EAAErE,KAAK,CAACkE,OAAO;IAC1BI,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEJ,eAAe9E,WAAW","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { StyleSheet, Text, View } from "react-native";
|
|
5
|
-
import Animated, { useAnimatedStyle,
|
|
5
|
+
import Animated, { useAnimatedStyle, useSharedValue } from "react-native-reanimated";
|
|
6
6
|
import { useTheme } from "../../theme/index.js";
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
8
|
const LABEL_HEIGHT = 26;
|
|
@@ -20,7 +20,7 @@ const CenteredLabel = ({
|
|
|
20
20
|
const currTheme = theme || defaultTheme;
|
|
21
21
|
const styles = getStyles(currTheme);
|
|
22
22
|
const animatedLabelStyle = useAnimatedStyle(() => {
|
|
23
|
-
const rawCenter = position.value
|
|
23
|
+
const rawCenter = position.value;
|
|
24
24
|
const shifted = rawCenter - labelWidth.value / 2;
|
|
25
25
|
const left = Math.min(Math.max(shifted, 0), sliderWidth - labelWidth.value);
|
|
26
26
|
return {
|
|
@@ -52,9 +52,6 @@ export const SliderLabels = ({
|
|
|
52
52
|
} = useTheme();
|
|
53
53
|
const currTheme = theme || defaultTheme;
|
|
54
54
|
const styles = getStyles(currTheme);
|
|
55
|
-
const rightThumbLeftPosition = useDerivedValue(() => {
|
|
56
|
-
return rightPosition.value - thumbSize;
|
|
57
|
-
});
|
|
58
55
|
return /*#__PURE__*/_jsxs(View, {
|
|
59
56
|
style: styles.wrapper,
|
|
60
57
|
pointerEvents: "none",
|
|
@@ -66,7 +63,7 @@ export const SliderLabels = ({
|
|
|
66
63
|
}), /*#__PURE__*/_jsx(CenteredLabel, {
|
|
67
64
|
value: rightValue,
|
|
68
65
|
thumbSize: thumbSize,
|
|
69
|
-
position:
|
|
66
|
+
position: rightPosition,
|
|
70
67
|
sliderWidth: sliderWidth
|
|
71
68
|
})]
|
|
72
69
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","StyleSheet","Text","View","Animated","useAnimatedStyle","
|
|
1
|
+
{"version":3,"names":["React","StyleSheet","Text","View","Animated","useAnimatedStyle","useSharedValue","useTheme","jsx","_jsx","jsxs","_jsxs","LABEL_HEIGHT","CenteredLabel","value","position","sliderWidth","thumbSize","theme","labelWidth","defaultTheme","currTheme","styles","getStyles","animatedLabelStyle","rawCenter","shifted","left","Math","min","max","style","labelContainer","onLayout","e","nativeEvent","layout","width","children","labelText","SliderLabels","leftValue","rightValue","leftPosition","rightPosition","wrapper","pointerEvents","create","height","top","alignItems","backgroundColor","surface","paddingHorizontal","paddingVertical","borderRadius","color","onSurface","fontSize","fontFamily"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/RangeSlider/SliderLabel.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AACrD,OAAOC,QAAQ,IAEbC,gBAAgB,EAEhBC,cAAc,QACT,yBAAyB;AAChC,SAAoBC,QAAQ,QAAQ,sBAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAElD,MAAMC,YAAY,GAAG,EAAE;AAoBvB,MAAMC,aAA2C,GAAGA,CAAC;EACnDC,KAAK;EACLC,QAAQ;EACRC,WAAW;EACXC,SAAS;EACTC;AACF,CAAC,KAAK;EACJ,MAAMC,UAAU,GAAGb,cAAc,CAAC,CAAC,CAAC;EACpC,MAAM;IAAEY,KAAK,EAAEE;EAAa,CAAC,GAAGb,QAAQ,CAAC,CAAC;EAC1C,MAAMc,SAAS,GAAGH,KAAK,IAAIE,YAAY;EACvC,MAAME,MAAM,GAAGC,SAAS,CAACF,SAAS,CAAC;EAEnC,MAAMG,kBAAkB,GAAGnB,gBAAgB,CAAC,MAAM;IAChD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AAEA;IAAY,CAC1B,CAAC,eACFP,IAAA,CAACI,aAAa;MACZC,KAAK,EAAE4B,UAAW;MAClBzB,SAAS,EAAEA,SAAU;MACrBF,QAAQ,EAAE6B,aAAc;MACxB5B,WAAW,EAAEA;IAAY,CAC1B,CAAC;EAAA,CACE,CAAC;AAEX,CAAC;AAED,MAAMO,SAAS,GAAIL,KAAgB,IACjCjB,UAAU,CAAC8C,MAAM,CAAC;EAChBF,OAAO,EAAE;IACP9B,QAAQ,EAAE,UAAU;IACpBsB,KAAK,EAAE,MAAM;IACbW,MAAM,EAAE;EACV,CAAC;EACDhB,cAAc,EAAE;IACdjB,QAAQ,EAAE,UAAU;IACpBkC,GAAG,EAAE,CAACrC,YAAY,GAAG,CAAC;IACtBsC,UAAU,EAAE;EACd,CAAC;EACDX,SAAS,EAAE;IACTY,eAAe,EAAEjC,KAAK,CAACkC,OAAO;IAC9BC,iBAAiB,EAAE,CAAC;IACpBC,eAAe,EAAE,CAAC;IAClBC,YAAY,EAAE,CAAC;IACfC,KAAK,EAAEtC,KAAK,CAACuC,SAAS;IACtBC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"..\\..\\src","sources":["index.ts"],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"..\\..\\src","sources":["index.ts"],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;;AAEA,cAAc,kBAAS;AACvB,cAAc,uBAAc;AAC5B,cAAc,qBAAY","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/app.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAsDnD,QAAA,MAAM,GAAG,yBAmFR,CAAC;
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/app.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAsDnD,QAAA,MAAM,GAAG,yBAmFR,CAAC;AAWF,eAAe,GAAG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RangeSlider.d.ts","sourceRoot":"","sources":["../../../../../src/components/RangeSlider/RangeSlider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AASrD,OAAO,EAAE,SAAS,EAAY,MAAM,aAAa,CAAC;AAMlD,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"RangeSlider.d.ts","sourceRoot":"","sources":["../../../../../src/components/RangeSlider/RangeSlider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AASrD,OAAO,EAAE,SAAS,EAAY,MAAM,aAAa,CAAC;AAMlD,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC9D,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAyJ3C,CAAC;AAwCF,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderLabel.d.ts","sourceRoot":"","sources":["../../../../../src/components/RangeSlider/SliderLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAiB,EACf,WAAW,EAIZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAY,MAAM,aAAa,CAAC;AAIlD,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"SliderLabel.d.ts","sourceRoot":"","sources":["../../../../../src/components/RangeSlider/SliderLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAiB,EACf,WAAW,EAIZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAY,MAAM,aAAa,CAAC;AAIlD,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AA6CD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA4BpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAQA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/package.json
CHANGED
package/src/app.tsx
CHANGED
|
@@ -66,7 +66,7 @@ const App = () => {
|
|
|
66
66
|
const newProgress = Math.floor(Math.random() * 101);
|
|
67
67
|
setProgress(newProgress);
|
|
68
68
|
};
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
return (
|
|
71
71
|
<>
|
|
72
72
|
<SafeAreaProvider>
|
|
@@ -122,12 +122,12 @@ const App = () => {
|
|
|
122
122
|
{/* <CarRentalForm onSelectionChange={console.log}></CarRentalForm> */}
|
|
123
123
|
{/* <CarouselCardStack data={DUMMY_DATA} /> */}
|
|
124
124
|
{/* <CircularProgressBar variant="steps" totalSteps={4} currentStep={4} size={43} strokeWidth={2} progressColor="#9CA0A3"></CircularProgressBar> */}
|
|
125
|
-
|
|
126
|
-
<PhoneInput
|
|
125
|
+
<RangeSlider initialMinValue={0} initialMaxValue={100} min={0} max={500} sliderWidth={300} onValueChange={console.log}></RangeSlider>
|
|
126
|
+
{/* <PhoneInput
|
|
127
127
|
value=""
|
|
128
128
|
onChangeText={() => {}}
|
|
129
129
|
inputContainerStyle={{ height: 55 }}
|
|
130
|
-
></PhoneInput>
|
|
130
|
+
></PhoneInput> */}
|
|
131
131
|
</SafeAreaView>
|
|
132
132
|
</BottomSheetStackProvider>
|
|
133
133
|
</RelatedProvider>
|
|
@@ -142,6 +142,7 @@ const styles = StyleSheet.create({
|
|
|
142
142
|
flex: 1,
|
|
143
143
|
backgroundColor: "grey",
|
|
144
144
|
justifyContent: "center", // Center the carousel vertically if it's the main content
|
|
145
|
+
alignItems:"center"
|
|
145
146
|
},
|
|
146
147
|
});
|
|
147
148
|
|
|
@@ -21,8 +21,7 @@ interface RangeSliderProps {
|
|
|
21
21
|
initialMinValue: number;
|
|
22
22
|
initialMaxValue: number;
|
|
23
23
|
onValueChange: (values: { min: number; max: number }) => void;
|
|
24
|
-
|
|
25
|
-
theme?: ThemeType
|
|
24
|
+
theme?: ThemeType;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
const RangeSlider: React.FC<RangeSliderProps> = ({
|
|
@@ -33,37 +32,41 @@ const RangeSlider: React.FC<RangeSliderProps> = ({
|
|
|
33
32
|
initialMinValue,
|
|
34
33
|
initialMaxValue,
|
|
35
34
|
onValueChange,
|
|
36
|
-
theme
|
|
35
|
+
theme,
|
|
37
36
|
}) => {
|
|
38
|
-
const { theme: defaultTheme} = useTheme();
|
|
39
|
-
|
|
37
|
+
const { theme: defaultTheme } = useTheme();
|
|
40
38
|
const currTheme = theme || defaultTheme;
|
|
41
|
-
|
|
42
39
|
const styles = getStyles(currTheme);
|
|
43
40
|
|
|
41
|
+
const isRTL = I18nManager.isRTL;
|
|
42
|
+
|
|
44
43
|
// State for label text values, passed down to the SliderLabels component
|
|
45
44
|
const [leftLabel, setLeftLabel] = useState(initialMinValue.toLocaleString());
|
|
46
45
|
const [rightLabel, setRightLabel] = useState(
|
|
47
46
|
initialMaxValue.toLocaleString()
|
|
48
47
|
);
|
|
49
48
|
|
|
49
|
+
// These functions correctly map a value to its thumb's CENTER position for both LTR and RTL.
|
|
50
50
|
const valueToPosition = useCallback(
|
|
51
51
|
(value: number) => {
|
|
52
52
|
"worklet";
|
|
53
|
-
|
|
53
|
+
const position = ((value - min) / (max - min)) * sliderWidth;
|
|
54
|
+
return isRTL ? sliderWidth - position : position;
|
|
54
55
|
},
|
|
55
|
-
[min, max, sliderWidth]
|
|
56
|
+
[min, max, sliderWidth, isRTL]
|
|
56
57
|
);
|
|
57
58
|
|
|
58
59
|
const positionToValue = useCallback(
|
|
59
60
|
(position: number) => {
|
|
60
61
|
"worklet";
|
|
61
|
-
const
|
|
62
|
+
const pos = isRTL ? sliderWidth - position : position;
|
|
63
|
+
const rawValue = (pos / sliderWidth) * (max - min) + min;
|
|
62
64
|
return Math.round(rawValue / step) * step;
|
|
63
65
|
},
|
|
64
|
-
[min, max, step, sliderWidth]
|
|
66
|
+
[min, max, step, sliderWidth, isRTL]
|
|
65
67
|
);
|
|
66
68
|
|
|
69
|
+
// 'leftPosition' is for the min value, 'rightPosition' is for the max value.
|
|
67
70
|
const leftPosition = useSharedValue(valueToPosition(initialMinValue));
|
|
68
71
|
const rightPosition = useSharedValue(valueToPosition(initialMaxValue));
|
|
69
72
|
const context = useSharedValue({ x: 0 });
|
|
@@ -83,20 +86,34 @@ const RangeSlider: React.FC<RangeSliderProps> = ({
|
|
|
83
86
|
})
|
|
84
87
|
.onUpdate((e) => {
|
|
85
88
|
if (activeThumb.value === null) return;
|
|
89
|
+
|
|
90
|
+
// Invert translation for RTL
|
|
86
91
|
const newPos = context.value.x + e.translationX;
|
|
87
92
|
|
|
88
93
|
if (activeThumb.value === "left") {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
Math.min(
|
|
92
|
-
|
|
94
|
+
// This is the MINIMUM value thumb
|
|
95
|
+
const clampedPos = isRTL
|
|
96
|
+
? Math.min(
|
|
97
|
+
sliderWidth - THUMB_SIZE / 2,
|
|
98
|
+
Math.max(newPos, rightPosition.value + THUMB_SIZE)
|
|
99
|
+
)
|
|
100
|
+
: Math.max(
|
|
101
|
+
THUMB_SIZE / 2,
|
|
102
|
+
Math.min(newPos, rightPosition.value - THUMB_SIZE)
|
|
103
|
+
);
|
|
93
104
|
leftPosition.value = clampedPos;
|
|
94
105
|
runOnJS(setLeftLabel)(positionToValue(clampedPos).toLocaleString());
|
|
95
106
|
} else {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
Math.max(
|
|
99
|
-
|
|
107
|
+
// This is the MAXIMUM value thumb
|
|
108
|
+
const clampedPos = isRTL
|
|
109
|
+
? Math.max(
|
|
110
|
+
THUMB_SIZE / 2,
|
|
111
|
+
Math.min(newPos, leftPosition.value - THUMB_SIZE)
|
|
112
|
+
)
|
|
113
|
+
: Math.min(
|
|
114
|
+
sliderWidth - THUMB_SIZE / 2,
|
|
115
|
+
Math.max(newPos, leftPosition.value + THUMB_SIZE)
|
|
116
|
+
);
|
|
100
117
|
rightPosition.value = clampedPos;
|
|
101
118
|
runOnJS(setRightLabel)(positionToValue(clampedPos).toLocaleString());
|
|
102
119
|
}
|
|
@@ -109,22 +126,29 @@ const RangeSlider: React.FC<RangeSliderProps> = ({
|
|
|
109
126
|
activeThumb.value = null;
|
|
110
127
|
});
|
|
111
128
|
|
|
129
|
+
// These styles center the thumb on its position value
|
|
112
130
|
const animatedLeftThumbStyle = useAnimatedStyle(() => ({
|
|
113
|
-
transform: [{ translateX: leftPosition.value }],
|
|
131
|
+
transform: [{ translateX: leftPosition.value - THUMB_SIZE / 2 }],
|
|
114
132
|
}));
|
|
115
133
|
|
|
116
134
|
const animatedRightThumbStyle = useAnimatedStyle(() => ({
|
|
117
|
-
transform: [{ translateX: rightPosition.value - THUMB_SIZE }],
|
|
135
|
+
transform: [{ translateX: rightPosition.value - THUMB_SIZE / 2 }],
|
|
118
136
|
}));
|
|
119
137
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
// This style correctly draws the active rail between the two thumb centers in both LTR and RTL.
|
|
139
|
+
const animatedActiveRailStyle = useAnimatedStyle(() => {
|
|
140
|
+
const start = isRTL ? rightPosition.value : leftPosition.value;
|
|
141
|
+
const end = isRTL ? leftPosition.value : rightPosition.value;
|
|
142
|
+
return {
|
|
143
|
+
left: start,
|
|
144
|
+
width: end - start,
|
|
145
|
+
};
|
|
146
|
+
});
|
|
124
147
|
|
|
125
148
|
return (
|
|
126
149
|
<View style={[styles.container, { width: sliderWidth }]}>
|
|
127
150
|
<SliderLabels
|
|
151
|
+
// isRtl={isRTL} // Pass isRTL to SliderLabels so it can adjust accordingly
|
|
128
152
|
leftValue={leftLabel}
|
|
129
153
|
rightValue={rightLabel}
|
|
130
154
|
leftPosition={leftPosition}
|
|
@@ -160,7 +184,7 @@ const getStyles = (theme: ThemeType) =>
|
|
|
160
184
|
container: {
|
|
161
185
|
height: LABEL_HEIGHT + THUMB_SIZE,
|
|
162
186
|
justifyContent: "center",
|
|
163
|
-
marginTop: LABEL_HEIGHT,
|
|
187
|
+
marginTop: LABEL_HEIGHT,
|
|
164
188
|
},
|
|
165
189
|
railContainer: {
|
|
166
190
|
justifyContent: "center",
|
|
@@ -17,7 +17,7 @@ interface SliderLabelsProps {
|
|
|
17
17
|
rightPosition: SharedValue<number>;
|
|
18
18
|
sliderWidth: number;
|
|
19
19
|
thumbSize: number;
|
|
20
|
-
theme?: ThemeType
|
|
20
|
+
theme?: ThemeType;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
interface CenteredLabelProps {
|
|
@@ -25,8 +25,7 @@ interface CenteredLabelProps {
|
|
|
25
25
|
position: SharedValue<number>;
|
|
26
26
|
sliderWidth: number;
|
|
27
27
|
thumbSize: number;
|
|
28
|
-
theme?: ThemeType
|
|
29
|
-
|
|
28
|
+
theme?: ThemeType;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
const CenteredLabel: React.FC<CenteredLabelProps> = ({
|
|
@@ -34,15 +33,15 @@ const CenteredLabel: React.FC<CenteredLabelProps> = ({
|
|
|
34
33
|
position,
|
|
35
34
|
sliderWidth,
|
|
36
35
|
thumbSize,
|
|
37
|
-
theme
|
|
36
|
+
theme,
|
|
38
37
|
}) => {
|
|
39
38
|
const labelWidth = useSharedValue(0);
|
|
40
|
-
const {theme: defaultTheme} = useTheme();
|
|
39
|
+
const { theme: defaultTheme } = useTheme();
|
|
41
40
|
const currTheme = theme || defaultTheme;
|
|
42
41
|
const styles = getStyles(currTheme);
|
|
43
42
|
|
|
44
43
|
const animatedLabelStyle = useAnimatedStyle(() => {
|
|
45
|
-
const rawCenter = position.value
|
|
44
|
+
const rawCenter = position.value;
|
|
46
45
|
const shifted = rawCenter - labelWidth.value / 2;
|
|
47
46
|
|
|
48
47
|
const left = Math.min(Math.max(shifted, 0), sliderWidth - labelWidth.value);
|
|
@@ -59,9 +58,7 @@ const CenteredLabel: React.FC<CenteredLabelProps> = ({
|
|
|
59
58
|
labelWidth.value = e.nativeEvent.layout.width;
|
|
60
59
|
}}
|
|
61
60
|
>
|
|
62
|
-
<Text style={styles.labelText}>
|
|
63
|
-
{value}
|
|
64
|
-
</Text>
|
|
61
|
+
<Text style={styles.labelText}>{value}</Text>
|
|
65
62
|
</Animated.View>
|
|
66
63
|
);
|
|
67
64
|
};
|
|
@@ -73,14 +70,11 @@ export const SliderLabels: React.FC<SliderLabelsProps> = ({
|
|
|
73
70
|
rightPosition,
|
|
74
71
|
sliderWidth,
|
|
75
72
|
thumbSize,
|
|
76
|
-
theme
|
|
73
|
+
theme,
|
|
77
74
|
}) => {
|
|
78
|
-
const {theme: defaultTheme} = useTheme();
|
|
75
|
+
const { theme: defaultTheme } = useTheme();
|
|
79
76
|
const currTheme = theme || defaultTheme;
|
|
80
77
|
const styles = getStyles(currTheme);
|
|
81
|
-
const rightThumbLeftPosition = useDerivedValue(() => {
|
|
82
|
-
return rightPosition.value - thumbSize;
|
|
83
|
-
});
|
|
84
78
|
return (
|
|
85
79
|
<View style={styles.wrapper} pointerEvents="none">
|
|
86
80
|
<CenteredLabel
|
|
@@ -92,7 +86,7 @@ export const SliderLabels: React.FC<SliderLabelsProps> = ({
|
|
|
92
86
|
<CenteredLabel
|
|
93
87
|
value={rightValue}
|
|
94
88
|
thumbSize={thumbSize}
|
|
95
|
-
position={
|
|
89
|
+
position={rightPosition}
|
|
96
90
|
sliderWidth={sliderWidth}
|
|
97
91
|
/>
|
|
98
92
|
</View>
|