vpt-sebraeds 0.0.66 → 0.0.67
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useRef, useMemo } from 'react';
|
|
1
|
+
import React, { useState, useRef, useMemo, useEffect } from 'react';
|
|
2
2
|
import { View, StyleSheet, Platform, PanResponder, LayoutChangeEvent } from 'react-native';
|
|
3
3
|
import SEText from '../SEText';
|
|
4
4
|
|
|
@@ -61,11 +61,16 @@ const RangeSlider: React.FC<RangeSliderProps> = ({
|
|
|
61
61
|
style,
|
|
62
62
|
}) => {
|
|
63
63
|
const [currentValue, setCurrentValue] = useState(value);
|
|
64
|
+
const [layoutWidth, setLayoutWidth] = useState(0);
|
|
64
65
|
const sliderRef = useRef<View>(null);
|
|
65
66
|
const sliderLayoutRef = useRef({ x: 0, width: 0 });
|
|
66
67
|
const thumbSize = 24;
|
|
67
68
|
const trackHeight = 8;
|
|
68
69
|
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
setCurrentValue(value);
|
|
72
|
+
}, [value]);
|
|
73
|
+
|
|
69
74
|
const updateValue = (pageX: number) => {
|
|
70
75
|
const { x, width } = sliderLayoutRef.current;
|
|
71
76
|
if (width <= 0) return;
|
|
@@ -85,6 +90,7 @@ const RangeSlider: React.FC<RangeSliderProps> = ({
|
|
|
85
90
|
const onLayout = (event: LayoutChangeEvent) => {
|
|
86
91
|
const { width } = event.nativeEvent.layout;
|
|
87
92
|
sliderLayoutRef.current.width = width;
|
|
93
|
+
setLayoutWidth(width);
|
|
88
94
|
|
|
89
95
|
// Mede a posição absoluta na tela
|
|
90
96
|
if (sliderRef.current) {
|
|
@@ -115,8 +121,8 @@ const RangeSlider: React.FC<RangeSliderProps> = ({
|
|
|
115
121
|
[disabled, minimumValue, maximumValue, step, onValueChange]);
|
|
116
122
|
|
|
117
123
|
// Calcula a posição do thumb
|
|
118
|
-
const sliderWidth =
|
|
119
|
-
const thumbPosition = sliderWidth > 0
|
|
124
|
+
const sliderWidth = layoutWidth;
|
|
125
|
+
const thumbPosition = sliderWidth > 0
|
|
120
126
|
? ((currentValue - minimumValue) / (maximumValue - minimumValue)) * (sliderWidth - thumbSize)
|
|
121
127
|
: 0;
|
|
122
128
|
|
|
@@ -35,7 +35,7 @@ function SEText({
|
|
|
35
35
|
const styleFont = {
|
|
36
36
|
regular:
|
|
37
37
|
Platform.OS === 'ios'
|
|
38
|
-
? { fontFamily: 'Nunito Sans 10pt Regular', fontWeight: '
|
|
38
|
+
? { fontFamily: 'Nunito Sans 10pt Regular', fontWeight: '400' }
|
|
39
39
|
: { fontFamily: 'NunitoSans_10pt-Regular' },
|
|
40
40
|
bold:
|
|
41
41
|
Platform.OS === 'ios'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/RangeSlider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/RangeSlider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAIpE,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAExC;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAExC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA6I3C,CAAC;AA8DF,eAAe,WAAW,CAAC"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import React, { useState, useRef, useMemo } from 'react';
|
|
1
|
+
import React, { useState, useRef, useMemo, useEffect } from 'react';
|
|
2
2
|
import { View, StyleSheet, PanResponder } from 'react-native';
|
|
3
3
|
import SEText from '../SEText';
|
|
4
4
|
const RangeSlider = ({ label, value = 0, minimumValue = 0, maximumValue = 1000000, step = 1000, onValueChange, formatValue, disabled = false, style, }) => {
|
|
5
5
|
const [currentValue, setCurrentValue] = useState(value);
|
|
6
|
+
const [layoutWidth, setLayoutWidth] = useState(0);
|
|
6
7
|
const sliderRef = useRef(null);
|
|
7
8
|
const sliderLayoutRef = useRef({ x: 0, width: 0 });
|
|
8
9
|
const thumbSize = 24;
|
|
9
10
|
const trackHeight = 8;
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
setCurrentValue(value);
|
|
13
|
+
}, [value]);
|
|
10
14
|
const updateValue = (pageX) => {
|
|
11
15
|
const { x, width } = sliderLayoutRef.current;
|
|
12
16
|
if (width <= 0)
|
|
@@ -24,6 +28,7 @@ const RangeSlider = ({ label, value = 0, minimumValue = 0, maximumValue = 100000
|
|
|
24
28
|
const onLayout = (event) => {
|
|
25
29
|
const { width } = event.nativeEvent.layout;
|
|
26
30
|
sliderLayoutRef.current.width = width;
|
|
31
|
+
setLayoutWidth(width);
|
|
27
32
|
// Mede a posição absoluta na tela
|
|
28
33
|
if (sliderRef.current) {
|
|
29
34
|
sliderRef.current.measureInWindow((x) => {
|
|
@@ -49,7 +54,7 @@ const RangeSlider = ({ label, value = 0, minimumValue = 0, maximumValue = 100000
|
|
|
49
54
|
onPanResponderRelease: () => { },
|
|
50
55
|
}), [disabled, minimumValue, maximumValue, step, onValueChange]);
|
|
51
56
|
// Calcula a posição do thumb
|
|
52
|
-
const sliderWidth =
|
|
57
|
+
const sliderWidth = layoutWidth;
|
|
53
58
|
const thumbPosition = sliderWidth > 0
|
|
54
59
|
? ((currentValue - minimumValue) / (maximumValue - minimumValue)) * (sliderWidth - thumbSize)
|
|
55
60
|
: 0;
|
|
@@ -9,7 +9,7 @@ function SEText({ children, style, bold = false, semiBold = false, center = fals
|
|
|
9
9
|
color = colors.SE_BROWN_1, size = null, lineHeight = null, justify = false, limit = null, type = null, mt = null, mb = null, ml = null, mr = null, pt = null, pb = null, pr = null, pl = null, ...rest }) {
|
|
10
10
|
const styleFont = {
|
|
11
11
|
regular: Platform.OS === 'ios'
|
|
12
|
-
? { fontFamily: 'Nunito Sans 10pt Regular', fontWeight: '
|
|
12
|
+
? { fontFamily: 'Nunito Sans 10pt Regular', fontWeight: '400' }
|
|
13
13
|
: { fontFamily: 'NunitoSans_10pt-Regular' },
|
|
14
14
|
bold: Platform.OS === 'ios'
|
|
15
15
|
? { fontFamily: 'Nunito Sans 10pt Bold', fontWeight: '700' }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vpt-sebraeds",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.67",
|
|
4
4
|
"description": "Biblioteca de componentes React Native do Sebrae",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -121,4 +121,4 @@
|
|
|
121
121
|
"react-native-web": "^0.20.0"
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
}
|
|
124
|
+
}
|