related-ui-components 2.6.6 → 2.6.7
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/components/Input/CountryPickerView.js +7 -3
- package/lib/module/components/Input/CountryPickerView.js.map +1 -1
- package/lib/module/components/Input/PhoneInput.js.map +1 -1
- package/lib/module/components/RangeSlider/RangeSlider.js +19 -98
- package/lib/module/components/RangeSlider/RangeSlider.js.map +1 -1
- package/lib/typescript/src/components/Input/CountryPickerView.d.ts +1 -1
- package/lib/typescript/src/components/Input/CountryPickerView.d.ts.map +1 -1
- package/lib/typescript/src/components/Input/PhoneInput.d.ts.map +1 -1
- package/lib/typescript/src/components/RangeSlider/RangeSlider.d.ts +0 -1
- package/lib/typescript/src/components/RangeSlider/RangeSlider.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Input/CountryPickerView.tsx +10 -3
- package/src/components/Input/PhoneInput.tsx +0 -3
- package/src/components/RangeSlider/RangeSlider.tsx +42 -113
|
@@ -5,7 +5,13 @@ import { Text, View, TouchableOpacity, StyleSheet } from "react-native";
|
|
|
5
5
|
import { BottomSheetFlatList } from "@gorhom/bottom-sheet";
|
|
6
6
|
import { useTheme } from "../../theme/index.js";
|
|
7
7
|
import { iso2ToFlagEmoji } from "../../utils/flags.js";
|
|
8
|
+
import { allCountries } from "country-telephone-data";
|
|
8
9
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const DEFAULT_COUNTRIES = allCountries.map(c => ({
|
|
11
|
+
code: `+${c.dialCode}`,
|
|
12
|
+
iso2: c.iso2,
|
|
13
|
+
name: c.name
|
|
14
|
+
}));
|
|
9
15
|
const CountryRow = /*#__PURE__*/React.memo(({
|
|
10
16
|
item,
|
|
11
17
|
onSelectCountry,
|
|
@@ -32,7 +38,7 @@ const CountryRow = /*#__PURE__*/React.memo(({
|
|
|
32
38
|
});
|
|
33
39
|
});
|
|
34
40
|
const CountryPickerView = ({
|
|
35
|
-
countries,
|
|
41
|
+
countries = DEFAULT_COUNTRIES,
|
|
36
42
|
onSelectCountry,
|
|
37
43
|
listTitle,
|
|
38
44
|
listTitleStyle,
|
|
@@ -42,8 +48,6 @@ const CountryPickerView = ({
|
|
|
42
48
|
const {
|
|
43
49
|
theme
|
|
44
50
|
} = useTheme();
|
|
45
|
-
|
|
46
|
-
// ADDED: Memoize styles to pass them stably to the memoized row component
|
|
47
51
|
const memoizedNameStyle = useMemo(() => [styles.countryName, {
|
|
48
52
|
color: theme.text
|
|
49
53
|
}, countryNameStyle], [theme.text, countryNameStyle]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useMemo","Text","View","TouchableOpacity","StyleSheet","BottomSheetFlatList","useTheme","iso2ToFlagEmoji","jsxs","_jsxs","jsx","_jsx","CountryRow","memo","item","onSelectCountry","nameStyle","codeStyle","handlePress","style","styles","countryRow","onPress","children","flag","
|
|
1
|
+
{"version":3,"names":["React","useCallback","useMemo","Text","View","TouchableOpacity","StyleSheet","BottomSheetFlatList","useTheme","iso2ToFlagEmoji","allCountries","jsxs","_jsxs","jsx","_jsx","DEFAULT_COUNTRIES","map","c","code","dialCode","iso2","name","CountryRow","memo","item","onSelectCountry","nameStyle","codeStyle","handlePress","style","styles","countryRow","onPress","children","flag","countryText","CountryPickerView","countries","listTitle","listTitleStyle","countryNameStyle","countryCodeStyle","theme","memoizedNameStyle","countryName","color","text","memoizedCodeStyle","countryCode","helper","renderCountry","popup","popupTitle","data","keyExtractor","renderItem","contentContainerStyle","paddingBottom","initialNumToRender","maxToRenderPerBatch","create","flex","width","paddingHorizontal","loaderContainer","alignItems","justifyContent","fontSize","fontWeight","marginBottom","paddingTop","flexDirection","paddingVertical","height","marginLeft"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Input/CountryPickerView.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAyBC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACxE,SACEC,IA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AAmB;MAClB8C,IAAI,EAAEhB,SAAU;MAChBiB,YAAY,EAAGrC,CAAU,IAAKA,CAAC,CAACG,IAAK;MACrCmC,UAAU,EAAEL,aAAc;MAC1BM,qBAAqB,EAAE;QAAEC,aAAa,EAAE;MAAG,CAAE;MAC7CC,kBAAkB,EAAE,EAAG;MACvBC,mBAAmB,EAAE;MACrB;IAAA,CACD,CAAC;EAAA,CACE,CAAC;AAEX,CAAC;AAED,MAAM7B,MAAM,GAAGxB,UAAU,CAACsD,MAAM,CAAC;EAC/BT,KAAK,EAAE;IACLU,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,iBAAiB,EAAE;EACrB,CAAC;EACDC,eAAe,EAAE;IACfH,IAAI,EAAE,CAAC;IACPI,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDd,UAAU,EAAE;IACVe,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,KAAK;IACjBC,YAAY,EAAE,EAAE;IAChBC,UAAU,EAAE;EACd,CAAC;EACDvC,UAAU,EAAE;IACVwC,aAAa,EAAE,KAAK;IACpBN,UAAU,EAAE,QAAQ;IACpBO,eAAe,EAAE,EAAE;IAAE;IACrBC,MAAM,EAAE,EAAE,CAAE;EACd,CAAC;EACDvC,IAAI,EAAE;IACJiC,QAAQ,EAAE;EACZ,CAAC;EACDhC,WAAW,EAAE;IACXuC,UAAU,EAAE,EAAE;IACdb,IAAI,EAAE,CAAC,CAAE;EACX,CAAC;EACDjB,WAAW,EAAE;IACXuB,QAAQ,EAAE;EACZ,CAAC;EACDnB,WAAW,EAAE;IACXmB,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAEF,eAAe/B,iBAAiB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","forwardRef","useMemo","useCallback","Text","TouchableOpacity","StyleSheet","CustomInput","useTheme","Ionicons","useBottomSheetStack","allCountries","iso2ToFlagEmoji","CountryPickerView","jsx","_jsx","jsxs","_jsxs","DEFAULT_COUNTRIES","map","c","code","dialCode","iso2","name","PhoneInput","value","onChangeText","selectedCountry","onSelectCountry","countries","containerStyle","inputContainerStyle","inputStyle","label","labelStyle","error","errorStyle","helper","helperStyle","listTitle","listTitleStyle","countryCodeStyle","countryNameStyle","isBottomSheet","rest","ref","theme","push","clear","sel","find","handleCountryPress","openCountryPicker","component","snapPoints","leftIcon","style","styles","selector","backgroundColor","inputBackground","borderRightColor","border","hitSlop","left","top","right","bottom","onPress","activeOpacity","children","flag","color","inputText","size","marginHorizontal","keyboardType","placeholder","create","flexDirection","alignItems","borderRightWidth","paddingHorizontal","fontSize","marginLeft"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Input/PhoneInput.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,OAAO,EAAEC,WAAW,QAAQ,OAAO;AAC/D,SAEEC,IAAI,
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useMemo","useCallback","Text","TouchableOpacity","StyleSheet","CustomInput","useTheme","Ionicons","useBottomSheetStack","allCountries","iso2ToFlagEmoji","CountryPickerView","jsx","_jsx","jsxs","_jsxs","DEFAULT_COUNTRIES","map","c","code","dialCode","iso2","name","PhoneInput","value","onChangeText","selectedCountry","onSelectCountry","countries","containerStyle","inputContainerStyle","inputStyle","label","labelStyle","error","errorStyle","helper","helperStyle","listTitle","listTitleStyle","countryCodeStyle","countryNameStyle","isBottomSheet","rest","ref","theme","push","clear","sel","find","handleCountryPress","openCountryPicker","component","snapPoints","leftIcon","style","styles","selector","backgroundColor","inputBackground","borderRightColor","border","hitSlop","left","top","right","bottom","onPress","activeOpacity","children","flag","color","inputText","size","marginHorizontal","keyboardType","placeholder","create","flexDirection","alignItems","borderRightWidth","paddingHorizontal","fontSize","marginLeft"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Input/PhoneInput.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,OA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B,EAAE,CAAC,CAAE;EACxB,CAAC;EACDX,IAAI,EAAE;IACJY,QAAQ,EAAE,EAAE,CAAE;EAChB,CAAC;EACD/D,IAAI,EAAE;IACJ+D,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEF,eAAe5D,UAAU","ignoreList":[]}
|
|
@@ -1,69 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React, { useCallback, useState } from "react";
|
|
4
|
-
import { StyleSheet, View
|
|
4
|
+
import { 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
|
+
import { SliderLabels } from "./SliderLabel.js";
|
|
7
8
|
import { useTheme } from "../../theme/index.js";
|
|
8
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
const THUMB_SIZE = 28;
|
|
10
11
|
const RAIL_HEIGHT = 6;
|
|
11
12
|
const LABEL_HEIGHT = 26;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Renders the floating labels above the thumbs.
|
|
15
|
-
*/
|
|
16
|
-
const SliderLabels = ({
|
|
17
|
-
leftValue,
|
|
18
|
-
rightValue,
|
|
19
|
-
leftPosition,
|
|
20
|
-
rightPosition,
|
|
21
|
-
sliderWidth,
|
|
22
|
-
isRTL,
|
|
23
|
-
theme
|
|
24
|
-
}) => {
|
|
25
|
-
const styles = getStyles(theme);
|
|
26
|
-
const animatedLeftLabelStyle = useAnimatedStyle(() => {
|
|
27
|
-
const labelWidth = leftValue.length * 8;
|
|
28
|
-
const centeredPosition = leftPosition.value + THUMB_SIZE / 2 - labelWidth / 2;
|
|
29
|
-
const clampedPosition = Math.max(0, Math.min(centeredPosition, sliderWidth - labelWidth));
|
|
30
|
-
return {
|
|
31
|
-
transform: [{
|
|
32
|
-
translateX: clampedPosition
|
|
33
|
-
}]
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
const animatedRightLabelStyle = useAnimatedStyle(() => {
|
|
37
|
-
const labelWidth = rightValue.length * 8;
|
|
38
|
-
const centeredPosition = rightPosition.value + THUMB_SIZE / 2 - labelWidth / 2;
|
|
39
|
-
const clampedPosition = Math.max(0, Math.min(centeredPosition, sliderWidth - labelWidth));
|
|
40
|
-
return {
|
|
41
|
-
transform: [{
|
|
42
|
-
translateX: clampedPosition
|
|
43
|
-
}]
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
const minLabel = isRTL ? rightValue : leftValue;
|
|
47
|
-
const maxLabel = isRTL ? leftValue : rightValue;
|
|
48
|
-
const minStyle = isRTL ? animatedRightLabelStyle : animatedLeftLabelStyle;
|
|
49
|
-
const maxStyle = isRTL ? animatedLeftLabelStyle : animatedRightLabelStyle;
|
|
50
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
51
|
-
style: styles.labelRow,
|
|
52
|
-
children: [/*#__PURE__*/_jsx(Animated.View, {
|
|
53
|
-
style: [styles.labelContainer, minStyle],
|
|
54
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
55
|
-
style: styles.labelText,
|
|
56
|
-
children: minLabel
|
|
57
|
-
})
|
|
58
|
-
}), /*#__PURE__*/_jsx(Animated.View, {
|
|
59
|
-
style: [styles.labelContainer, maxStyle],
|
|
60
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
61
|
-
style: styles.labelText,
|
|
62
|
-
children: maxLabel
|
|
63
|
-
})
|
|
64
|
-
})]
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
13
|
const RangeSlider = ({
|
|
68
14
|
min,
|
|
69
15
|
max,
|
|
@@ -78,38 +24,32 @@ const RangeSlider = ({
|
|
|
78
24
|
theme: defaultTheme
|
|
79
25
|
} = useTheme();
|
|
80
26
|
const currTheme = theme || defaultTheme;
|
|
81
|
-
const isRTL = I18nManager.isRTL;
|
|
82
27
|
const styles = getStyles(currTheme);
|
|
83
|
-
|
|
28
|
+
|
|
29
|
+
// State for label text values, passed down to the SliderLabels component
|
|
30
|
+
const [leftLabel, setLeftLabel] = useState(initialMinValue.toLocaleString());
|
|
31
|
+
const [rightLabel, setRightLabel] = useState(initialMaxValue.toLocaleString());
|
|
84
32
|
const valueToPosition = useCallback(value => {
|
|
85
33
|
"worklet";
|
|
86
34
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}, [min, max, railWidth, isRTL]);
|
|
35
|
+
return (value - min) / (max - min) * sliderWidth;
|
|
36
|
+
}, [min, max, sliderWidth]);
|
|
90
37
|
const positionToValue = useCallback(position => {
|
|
91
38
|
"worklet";
|
|
92
39
|
|
|
93
|
-
const
|
|
94
|
-
const rawValue = isRTL ? max - percentage * (max - min) : percentage * (max - min) + min;
|
|
40
|
+
const rawValue = position / sliderWidth * (max - min) + min;
|
|
95
41
|
return Math.round(rawValue / step) * step;
|
|
96
|
-
}, [min, max, step,
|
|
97
|
-
|
|
98
|
-
// --- Shared Values for Animation ---
|
|
42
|
+
}, [min, max, step, sliderWidth]);
|
|
99
43
|
const leftPosition = useSharedValue(valueToPosition(initialMinValue));
|
|
100
44
|
const rightPosition = useSharedValue(valueToPosition(initialMaxValue));
|
|
101
|
-
const [leftLabel, setLeftLabel] = useState(initialMinValue.toLocaleString());
|
|
102
|
-
const [rightLabel, setRightLabel] = useState(initialMaxValue.toLocaleString());
|
|
103
45
|
const context = useSharedValue({
|
|
104
46
|
x: 0
|
|
105
47
|
});
|
|
106
48
|
const activeThumb = useSharedValue(null);
|
|
107
|
-
|
|
108
|
-
// --- Gesture Handler ---
|
|
109
49
|
const panGesture = Gesture.Pan().onBegin(e => {
|
|
110
50
|
const distToLeft = Math.abs(e.x - leftPosition.value);
|
|
111
51
|
const distToRight = Math.abs(e.x - rightPosition.value);
|
|
112
|
-
if (distToLeft
|
|
52
|
+
if (distToLeft <= distToRight) {
|
|
113
53
|
activeThumb.value = "left";
|
|
114
54
|
context.value = {
|
|
115
55
|
x: leftPosition.value
|
|
@@ -124,11 +64,11 @@ const RangeSlider = ({
|
|
|
124
64
|
if (activeThumb.value === null) return;
|
|
125
65
|
const newPos = context.value.x + e.translationX;
|
|
126
66
|
if (activeThumb.value === "left") {
|
|
127
|
-
const clampedPos = Math.max(0, Math.min(newPos, rightPosition.value));
|
|
67
|
+
const clampedPos = Math.max(0, Math.min(newPos, rightPosition.value - THUMB_SIZE));
|
|
128
68
|
leftPosition.value = clampedPos;
|
|
129
69
|
runOnJS(setLeftLabel)(positionToValue(clampedPos).toLocaleString());
|
|
130
70
|
} else {
|
|
131
|
-
const clampedPos = Math.min(
|
|
71
|
+
const clampedPos = Math.min(sliderWidth, Math.max(newPos, leftPosition.value + THUMB_SIZE));
|
|
132
72
|
rightPosition.value = clampedPos;
|
|
133
73
|
runOnJS(setRightLabel)(positionToValue(clampedPos).toLocaleString());
|
|
134
74
|
}
|
|
@@ -142,8 +82,6 @@ const RangeSlider = ({
|
|
|
142
82
|
});
|
|
143
83
|
activeThumb.value = null;
|
|
144
84
|
});
|
|
145
|
-
|
|
146
|
-
// --- Animated Styles ---
|
|
147
85
|
const animatedLeftThumbStyle = useAnimatedStyle(() => ({
|
|
148
86
|
transform: [{
|
|
149
87
|
translateX: leftPosition.value
|
|
@@ -151,12 +89,12 @@ const RangeSlider = ({
|
|
|
151
89
|
}));
|
|
152
90
|
const animatedRightThumbStyle = useAnimatedStyle(() => ({
|
|
153
91
|
transform: [{
|
|
154
|
-
translateX: rightPosition.value
|
|
92
|
+
translateX: rightPosition.value - THUMB_SIZE
|
|
155
93
|
}]
|
|
156
94
|
}));
|
|
157
95
|
const animatedActiveRailStyle = useAnimatedStyle(() => ({
|
|
158
|
-
left: leftPosition.value
|
|
159
|
-
right:
|
|
96
|
+
left: leftPosition.value,
|
|
97
|
+
right: sliderWidth - rightPosition.value
|
|
160
98
|
}));
|
|
161
99
|
return /*#__PURE__*/_jsxs(View, {
|
|
162
100
|
style: [styles.container, {
|
|
@@ -168,8 +106,7 @@ const RangeSlider = ({
|
|
|
168
106
|
leftPosition: leftPosition,
|
|
169
107
|
rightPosition: rightPosition,
|
|
170
108
|
sliderWidth: sliderWidth,
|
|
171
|
-
|
|
172
|
-
theme: currTheme
|
|
109
|
+
thumbSize: THUMB_SIZE
|
|
173
110
|
}), /*#__PURE__*/_jsx(GestureDetector, {
|
|
174
111
|
gesture: panGesture,
|
|
175
112
|
children: /*#__PURE__*/_jsxs(View, {
|
|
@@ -196,7 +133,8 @@ const RangeSlider = ({
|
|
|
196
133
|
const getStyles = theme => StyleSheet.create({
|
|
197
134
|
container: {
|
|
198
135
|
height: LABEL_HEIGHT + THUMB_SIZE,
|
|
199
|
-
justifyContent: "
|
|
136
|
+
justifyContent: "center",
|
|
137
|
+
marginTop: LABEL_HEIGHT // Add margin to prevent label cutoff
|
|
200
138
|
},
|
|
201
139
|
railContainer: {
|
|
202
140
|
justifyContent: "center",
|
|
@@ -226,23 +164,6 @@ const getStyles = theme => StyleSheet.create({
|
|
|
226
164
|
backgroundColor: theme.background,
|
|
227
165
|
borderColor: theme.primary,
|
|
228
166
|
borderWidth: 5
|
|
229
|
-
},
|
|
230
|
-
labelRow: {
|
|
231
|
-
position: "absolute",
|
|
232
|
-
top: 0,
|
|
233
|
-
width: "100%"
|
|
234
|
-
},
|
|
235
|
-
labelContainer: {
|
|
236
|
-
position: "absolute",
|
|
237
|
-
backgroundColor: theme.primary,
|
|
238
|
-
borderRadius: 4,
|
|
239
|
-
paddingVertical: 4,
|
|
240
|
-
paddingHorizontal: 8,
|
|
241
|
-
height: LABEL_HEIGHT
|
|
242
|
-
},
|
|
243
|
-
labelText: {
|
|
244
|
-
color: theme.onPrimary,
|
|
245
|
-
fontSize: 12
|
|
246
167
|
}
|
|
247
168
|
});
|
|
248
169
|
export default RangeSlider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useState","StyleSheet","View","
|
|
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","position","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","left","right","style","container","width","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,SAAsBC,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;AAcvB,MAAMC,WAAuC,GAAGA,CAAC;EAC/CC,GAAG;EACHC,GAAG;EACHC,IAAI,GAAG,CAAC;EACRC,WAAW;EACXC,eAAe;EACfC,eAAe;EAC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AAE;IACbO,cAAc,EAAE,QAAQ;IACxBD,MAAM,EAAEpE;EACV,CAAC;EACD+D,IAAI,EAAE;IACJK,MAAM,EAAEnE,WAAW;IACnBsE,YAAY,EAAEtE,WAAW,GAAG,CAAC;IAC7BuE,eAAe,EAAE7D,KAAK,CAAC8D;EACzB,CAAC;EACDT,UAAU,EAAE;IACVI,MAAM,EAAEnE,WAAW;IACnBuE,eAAe,EAAE7D,KAAK,CAAC+D,OAAO;IAC9BlD,QAAQ,EAAE;EACZ,CAAC;EACDyC,cAAc,EAAE;IACdzC,QAAQ,EAAE,UAAU;IACpBgC,KAAK,EAAExD,UAAU;IACjBoE,MAAM,EAAEpE,UAAU;IAClBqE,cAAc,EAAE,QAAQ;IACxBM,UAAU,EAAE;EACd,CAAC;EACDT,KAAK,EAAE;IACLV,KAAK,EAAExD,UAAU;IACjBoE,MAAM,EAAEpE,UAAU;IAClBuE,YAAY,EAAEvE,UAAU,GAAG,CAAC;IAC5BwE,eAAe,EAAE7D,KAAK,CAACiE,UAAU;IACjCC,WAAW,EAAElE,KAAK,CAAC+D,OAAO;IAC1BI,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEJ,eAAe3E,WAAW","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { StyleProp, TextStyle } from "react-native";
|
|
3
3
|
import { Country } from "./PhoneInput";
|
|
4
4
|
interface CountryPickerViewProps {
|
|
5
|
-
countries
|
|
5
|
+
countries?: Country[];
|
|
6
6
|
onSelectCountry: (c: Country) => void;
|
|
7
7
|
listTitle: string;
|
|
8
8
|
listTitleStyle?: StyleProp<TextStyle>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CountryPickerView.d.ts","sourceRoot":"","sources":["../../../../../src/components/Input/CountryPickerView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AACzE,OAAO,EAOL,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"CountryPickerView.d.ts","sourceRoot":"","sources":["../../../../../src/components/Input/CountryPickerView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AACzE,OAAO,EAOL,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,UAAU,sBAAsB;IAC9B,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;IACtB,eAAe,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,gBAAgB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,gBAAgB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACzC;AAkCD,QAAA,MAAM,iBAAiB,GAAI,gGAOxB,sBAAsB,sBA0CxB,CAAC;AAwCF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/Input/PhoneInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAChE,OAAO,EACL,SAAS,
|
|
1
|
+
{"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/Input/PhoneInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAChE,OAAO,EACL,SAAS,EAIT,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAoB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAQxD,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,eACf,SAAQ,IAAI,CACV,gBAAgB,EACd,UAAU,GACV,WAAW,GACX,kBAAkB,GAClB,cAAc,GACd,OAAO,GACP,sBAAsB,CACzB;IACD,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;IAGtB,gBAAgB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,gBAAgB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAEtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAQD,QAAA,MAAM,UAAU,mFA0Hf,CAAC;AAkBF,eAAe,UAAU,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;
|
|
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;IAE9D,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAgI3C,CAAC;AAwCF,eAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -13,9 +13,11 @@ import { BottomSheetFlashList, BottomSheetFlatList } from "@gorhom/bottom-sheet"
|
|
|
13
13
|
import { useTheme } from "../../theme";
|
|
14
14
|
import { iso2ToFlagEmoji } from "../../utils/flags";
|
|
15
15
|
import { Country } from "./PhoneInput";
|
|
16
|
+
import { allCountries } from "country-telephone-data";
|
|
17
|
+
|
|
16
18
|
|
|
17
19
|
interface CountryPickerViewProps {
|
|
18
|
-
countries
|
|
20
|
+
countries?: Country[];
|
|
19
21
|
onSelectCountry: (c: Country) => void;
|
|
20
22
|
listTitle: string;
|
|
21
23
|
listTitleStyle?: StyleProp<TextStyle>;
|
|
@@ -23,6 +25,12 @@ interface CountryPickerViewProps {
|
|
|
23
25
|
countryCodeStyle?: StyleProp<TextStyle>;
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
const DEFAULT_COUNTRIES: Country[] = allCountries.map((c) => ({
|
|
29
|
+
code: `+${c.dialCode}`,
|
|
30
|
+
iso2: c.iso2,
|
|
31
|
+
name: c.name,
|
|
32
|
+
}));
|
|
33
|
+
|
|
26
34
|
const CountryRow = React.memo(
|
|
27
35
|
({
|
|
28
36
|
item,
|
|
@@ -50,7 +58,7 @@ const CountryRow = React.memo(
|
|
|
50
58
|
);
|
|
51
59
|
|
|
52
60
|
const CountryPickerView = ({
|
|
53
|
-
countries,
|
|
61
|
+
countries = DEFAULT_COUNTRIES,
|
|
54
62
|
onSelectCountry,
|
|
55
63
|
listTitle,
|
|
56
64
|
listTitleStyle,
|
|
@@ -59,7 +67,6 @@ const CountryPickerView = ({
|
|
|
59
67
|
}: CountryPickerViewProps) => {
|
|
60
68
|
const { theme } = useTheme();
|
|
61
69
|
|
|
62
|
-
// ADDED: Memoize styles to pass them stably to the memoized row component
|
|
63
70
|
const memoizedNameStyle = useMemo(
|
|
64
71
|
() => [styles.countryName, { color: theme.text }, countryNameStyle],
|
|
65
72
|
[theme.text, countryNameStyle]
|
|
@@ -2,10 +2,8 @@ import React, { forwardRef, useMemo, useCallback } from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
TextInput,
|
|
4
4
|
Text,
|
|
5
|
-
View,
|
|
6
5
|
TouchableOpacity,
|
|
7
6
|
StyleSheet,
|
|
8
|
-
TextInputProps,
|
|
9
7
|
StyleProp,
|
|
10
8
|
TextStyle,
|
|
11
9
|
} from "react-native";
|
|
@@ -16,7 +14,6 @@ import { useBottomSheetStack } from "../../contexts";
|
|
|
16
14
|
import { allCountries } from "country-telephone-data";
|
|
17
15
|
import { iso2ToFlagEmoji } from "../../utils/flags";
|
|
18
16
|
import CountryPickerView from "./CountryPickerView";
|
|
19
|
-
import { BottomSheetTextInput } from "@gorhom/bottom-sheet";
|
|
20
17
|
|
|
21
18
|
export type Country = {
|
|
22
19
|
code: string;
|
|
@@ -1,79 +1,18 @@
|
|
|
1
1
|
import React, { useCallback, useState } from "react";
|
|
2
|
-
import { StyleSheet, View
|
|
2
|
+
import { I18nManager, StyleSheet, View } from "react-native";
|
|
3
3
|
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
4
4
|
import Animated, {
|
|
5
5
|
runOnJS,
|
|
6
6
|
useAnimatedStyle,
|
|
7
7
|
useSharedValue,
|
|
8
8
|
} from "react-native-reanimated";
|
|
9
|
+
import { SliderLabels } from "./SliderLabel";
|
|
9
10
|
import { ThemeType, useTheme } from "../../theme";
|
|
10
11
|
|
|
11
12
|
const THUMB_SIZE = 28;
|
|
12
13
|
const RAIL_HEIGHT = 6;
|
|
13
14
|
const LABEL_HEIGHT = 26;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Renders the floating labels above the thumbs.
|
|
18
|
-
*/
|
|
19
|
-
const SliderLabels = ({
|
|
20
|
-
leftValue,
|
|
21
|
-
rightValue,
|
|
22
|
-
leftPosition,
|
|
23
|
-
rightPosition,
|
|
24
|
-
sliderWidth,
|
|
25
|
-
isRTL,
|
|
26
|
-
theme,
|
|
27
|
-
}: {
|
|
28
|
-
leftValue: string;
|
|
29
|
-
rightValue: string;
|
|
30
|
-
leftPosition: Animated.SharedValue<number>;
|
|
31
|
-
rightPosition: Animated.SharedValue<number>;
|
|
32
|
-
sliderWidth: number;
|
|
33
|
-
isRTL: boolean;
|
|
34
|
-
theme: ThemeType;
|
|
35
|
-
}) => {
|
|
36
|
-
const styles = getStyles(theme);
|
|
37
|
-
|
|
38
|
-
const animatedLeftLabelStyle = useAnimatedStyle(() => {
|
|
39
|
-
const labelWidth = leftValue.length * 8;
|
|
40
|
-
const centeredPosition =
|
|
41
|
-
leftPosition.value + THUMB_SIZE / 2 - labelWidth / 2;
|
|
42
|
-
const clampedPosition = Math.max(
|
|
43
|
-
0,
|
|
44
|
-
Math.min(centeredPosition, sliderWidth - labelWidth)
|
|
45
|
-
);
|
|
46
|
-
return { transform: [{ translateX: clampedPosition }] };
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const animatedRightLabelStyle = useAnimatedStyle(() => {
|
|
50
|
-
const labelWidth = rightValue.length * 8;
|
|
51
|
-
const centeredPosition =
|
|
52
|
-
rightPosition.value + THUMB_SIZE / 2 - labelWidth / 2;
|
|
53
|
-
const clampedPosition = Math.max(
|
|
54
|
-
0,
|
|
55
|
-
Math.min(centeredPosition, sliderWidth - labelWidth)
|
|
56
|
-
);
|
|
57
|
-
return { transform: [{ translateX: clampedPosition }] };
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const minLabel = isRTL ? rightValue : leftValue;
|
|
61
|
-
const maxLabel = isRTL ? leftValue : rightValue;
|
|
62
|
-
const minStyle = isRTL ? animatedRightLabelStyle : animatedLeftLabelStyle;
|
|
63
|
-
const maxStyle = isRTL ? animatedLeftLabelStyle : animatedRightLabelStyle;
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<View style={styles.labelRow}>
|
|
67
|
-
<Animated.View style={[styles.labelContainer, minStyle]}>
|
|
68
|
-
<Text style={styles.labelText}>{minLabel}</Text>
|
|
69
|
-
</Animated.View>
|
|
70
|
-
<Animated.View style={[styles.labelContainer, maxStyle]}>
|
|
71
|
-
<Text style={styles.labelText}>{maxLabel}</Text>
|
|
72
|
-
</Animated.View>
|
|
73
|
-
</View>
|
|
74
|
-
);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
16
|
interface RangeSliderProps {
|
|
78
17
|
min: number;
|
|
79
18
|
max: number;
|
|
@@ -82,8 +21,8 @@ interface RangeSliderProps {
|
|
|
82
21
|
initialMinValue: number;
|
|
83
22
|
initialMaxValue: number;
|
|
84
23
|
onValueChange: (values: { min: number; max: number }) => void;
|
|
85
|
-
|
|
86
|
-
theme?: ThemeType
|
|
24
|
+
|
|
25
|
+
theme?: ThemeType
|
|
87
26
|
}
|
|
88
27
|
|
|
89
28
|
const RangeSlider: React.FC<RangeSliderProps> = ({
|
|
@@ -94,52 +33,47 @@ const RangeSlider: React.FC<RangeSliderProps> = ({
|
|
|
94
33
|
initialMinValue,
|
|
95
34
|
initialMaxValue,
|
|
96
35
|
onValueChange,
|
|
97
|
-
theme
|
|
36
|
+
theme
|
|
98
37
|
}) => {
|
|
99
|
-
const { theme: defaultTheme
|
|
38
|
+
const { theme: defaultTheme} = useTheme();
|
|
39
|
+
|
|
100
40
|
const currTheme = theme || defaultTheme;
|
|
101
|
-
|
|
41
|
+
|
|
102
42
|
const styles = getStyles(currTheme);
|
|
103
43
|
|
|
104
|
-
|
|
44
|
+
// State for label text values, passed down to the SliderLabels component
|
|
45
|
+
const [leftLabel, setLeftLabel] = useState(initialMinValue.toLocaleString());
|
|
46
|
+
const [rightLabel, setRightLabel] = useState(
|
|
47
|
+
initialMaxValue.toLocaleString()
|
|
48
|
+
);
|
|
105
49
|
|
|
106
50
|
const valueToPosition = useCallback(
|
|
107
51
|
(value: number) => {
|
|
108
52
|
"worklet";
|
|
109
|
-
|
|
110
|
-
return isRTL
|
|
111
|
-
? (1 - percentage) * railWidth
|
|
112
|
-
: percentage * railWidth;
|
|
53
|
+
return ((value - min) / (max - min)) * sliderWidth;
|
|
113
54
|
},
|
|
114
|
-
[min, max,
|
|
55
|
+
[min, max, sliderWidth]
|
|
115
56
|
);
|
|
116
57
|
|
|
117
58
|
const positionToValue = useCallback(
|
|
118
59
|
(position: number) => {
|
|
119
60
|
"worklet";
|
|
120
|
-
const
|
|
121
|
-
const rawValue = isRTL
|
|
122
|
-
? max - percentage * (max - min)
|
|
123
|
-
: percentage * (max - min) + min;
|
|
61
|
+
const rawValue = (position / sliderWidth) * (max - min) + min;
|
|
124
62
|
return Math.round(rawValue / step) * step;
|
|
125
63
|
},
|
|
126
|
-
[min, max, step,
|
|
64
|
+
[min, max, step, sliderWidth]
|
|
127
65
|
);
|
|
128
66
|
|
|
129
|
-
// --- Shared Values for Animation ---
|
|
130
67
|
const leftPosition = useSharedValue(valueToPosition(initialMinValue));
|
|
131
68
|
const rightPosition = useSharedValue(valueToPosition(initialMaxValue));
|
|
132
|
-
const [leftLabel, setLeftLabel] = useState(initialMinValue.toLocaleString());
|
|
133
|
-
const [rightLabel, setRightLabel] = useState(initialMaxValue.toLocaleString());
|
|
134
69
|
const context = useSharedValue({ x: 0 });
|
|
135
70
|
const activeThumb = useSharedValue<"left" | "right" | null>(null);
|
|
136
71
|
|
|
137
|
-
// --- Gesture Handler ---
|
|
138
72
|
const panGesture = Gesture.Pan()
|
|
139
73
|
.onBegin((e) => {
|
|
140
74
|
const distToLeft = Math.abs(e.x - leftPosition.value);
|
|
141
75
|
const distToRight = Math.abs(e.x - rightPosition.value);
|
|
142
|
-
if (distToLeft
|
|
76
|
+
if (distToLeft <= distToRight) {
|
|
143
77
|
activeThumb.value = "left";
|
|
144
78
|
context.value = { x: leftPosition.value };
|
|
145
79
|
} else {
|
|
@@ -152,11 +86,17 @@ const RangeSlider: React.FC<RangeSliderProps> = ({
|
|
|
152
86
|
const newPos = context.value.x + e.translationX;
|
|
153
87
|
|
|
154
88
|
if (activeThumb.value === "left") {
|
|
155
|
-
const clampedPos = Math.max(
|
|
89
|
+
const clampedPos = Math.max(
|
|
90
|
+
0,
|
|
91
|
+
Math.min(newPos, rightPosition.value - THUMB_SIZE)
|
|
92
|
+
);
|
|
156
93
|
leftPosition.value = clampedPos;
|
|
157
94
|
runOnJS(setLeftLabel)(positionToValue(clampedPos).toLocaleString());
|
|
158
95
|
} else {
|
|
159
|
-
const clampedPos = Math.min(
|
|
96
|
+
const clampedPos = Math.min(
|
|
97
|
+
sliderWidth,
|
|
98
|
+
Math.max(newPos, leftPosition.value + THUMB_SIZE)
|
|
99
|
+
);
|
|
160
100
|
rightPosition.value = clampedPos;
|
|
161
101
|
runOnJS(setRightLabel)(positionToValue(clampedPos).toLocaleString());
|
|
162
102
|
}
|
|
@@ -169,18 +109,17 @@ const RangeSlider: React.FC<RangeSliderProps> = ({
|
|
|
169
109
|
activeThumb.value = null;
|
|
170
110
|
});
|
|
171
111
|
|
|
172
|
-
// --- Animated Styles ---
|
|
173
112
|
const animatedLeftThumbStyle = useAnimatedStyle(() => ({
|
|
174
113
|
transform: [{ translateX: leftPosition.value }],
|
|
175
114
|
}));
|
|
176
115
|
|
|
177
116
|
const animatedRightThumbStyle = useAnimatedStyle(() => ({
|
|
178
|
-
transform: [{ translateX: rightPosition.value }],
|
|
117
|
+
transform: [{ translateX: rightPosition.value - THUMB_SIZE }],
|
|
179
118
|
}));
|
|
180
119
|
|
|
181
120
|
const animatedActiveRailStyle = useAnimatedStyle(() => ({
|
|
182
|
-
left: leftPosition.value
|
|
183
|
-
right:
|
|
121
|
+
left: leftPosition.value,
|
|
122
|
+
right: sliderWidth - rightPosition.value,
|
|
184
123
|
}));
|
|
185
124
|
|
|
186
125
|
return (
|
|
@@ -191,17 +130,23 @@ const RangeSlider: React.FC<RangeSliderProps> = ({
|
|
|
191
130
|
leftPosition={leftPosition}
|
|
192
131
|
rightPosition={rightPosition}
|
|
193
132
|
sliderWidth={sliderWidth}
|
|
194
|
-
|
|
195
|
-
theme={currTheme}
|
|
133
|
+
thumbSize={THUMB_SIZE}
|
|
196
134
|
/>
|
|
135
|
+
|
|
197
136
|
<GestureDetector gesture={panGesture}>
|
|
198
137
|
<View style={styles.railContainer}>
|
|
199
138
|
<View style={styles.rail} />
|
|
200
139
|
<Animated.View style={[styles.activeRail, animatedActiveRailStyle]} />
|
|
201
|
-
|
|
140
|
+
|
|
141
|
+
<Animated.View
|
|
142
|
+
style={[styles.thumbContainer, animatedLeftThumbStyle]}
|
|
143
|
+
>
|
|
202
144
|
<View style={styles.thumb} />
|
|
203
145
|
</Animated.View>
|
|
204
|
-
|
|
146
|
+
|
|
147
|
+
<Animated.View
|
|
148
|
+
style={[styles.thumbContainer, animatedRightThumbStyle]}
|
|
149
|
+
>
|
|
205
150
|
<View style={styles.thumb} />
|
|
206
151
|
</Animated.View>
|
|
207
152
|
</View>
|
|
@@ -214,7 +159,8 @@ const getStyles = (theme: ThemeType) =>
|
|
|
214
159
|
StyleSheet.create({
|
|
215
160
|
container: {
|
|
216
161
|
height: LABEL_HEIGHT + THUMB_SIZE,
|
|
217
|
-
justifyContent: "
|
|
162
|
+
justifyContent: "center",
|
|
163
|
+
marginTop: LABEL_HEIGHT, // Add margin to prevent label cutoff
|
|
218
164
|
},
|
|
219
165
|
railContainer: {
|
|
220
166
|
justifyContent: "center",
|
|
@@ -245,23 +191,6 @@ const getStyles = (theme: ThemeType) =>
|
|
|
245
191
|
borderColor: theme.primary,
|
|
246
192
|
borderWidth: 5,
|
|
247
193
|
},
|
|
248
|
-
labelRow: {
|
|
249
|
-
position: "absolute",
|
|
250
|
-
top: 0,
|
|
251
|
-
width: "100%",
|
|
252
|
-
},
|
|
253
|
-
labelContainer: {
|
|
254
|
-
position: "absolute",
|
|
255
|
-
backgroundColor: theme.primary,
|
|
256
|
-
borderRadius: 4,
|
|
257
|
-
paddingVertical: 4,
|
|
258
|
-
paddingHorizontal: 8,
|
|
259
|
-
height: LABEL_HEIGHT,
|
|
260
|
-
},
|
|
261
|
-
labelText: {
|
|
262
|
-
color: theme.onPrimary,
|
|
263
|
-
fontSize: 12,
|
|
264
|
-
},
|
|
265
194
|
});
|
|
266
195
|
|
|
267
|
-
export default RangeSlider;
|
|
196
|
+
export default RangeSlider;
|