rnnovaui 0.9.7 → 0.9.9
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/package.json +1 -1
- package/src/components/Accordion/UIAccordionContent.js +79 -56
- package/src/components/Tabs/UITabs.js +125 -1275
- package/src/components/Tabs/UITabsContent.js +97 -0
- package/src/components/Tabs/UITabsIndicator.js +40 -0
- package/src/components/Tabs/UITabsList.js +306 -0
- package/src/components/Tabs/UITabsTrigger.js +289 -0
- package/src/components/Tabs/index.js +16 -7
- package/src/components/index.js +4 -4
- package/src/index.js +4 -4
package/package.json
CHANGED
|
@@ -12,24 +12,19 @@ export const UIAccordionContent = memo(function UIAccordionContent({
|
|
|
12
12
|
testID,
|
|
13
13
|
}) {
|
|
14
14
|
const accordion = useUIAccordion();
|
|
15
|
-
|
|
16
15
|
const item = useUIAccordionItem();
|
|
17
16
|
|
|
18
17
|
const [contentHeight, setContentHeight] = useState(0);
|
|
19
18
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const opacityAnimation = useRef(
|
|
23
|
-
new Animated.Value(item.open ? 1 : 0),
|
|
24
|
-
).current;
|
|
19
|
+
const animation = useRef(new Animated.Value(item.open ? 1 : 0)).current;
|
|
25
20
|
|
|
26
21
|
/*
|
|
27
22
|
* ------------------------------------------------
|
|
28
|
-
* MEASURE REAL CONTENT
|
|
23
|
+
* MEASURE REAL CONTENT
|
|
29
24
|
* ------------------------------------------------
|
|
30
25
|
*/
|
|
31
26
|
|
|
32
|
-
const
|
|
27
|
+
const handleMeasureLayout = (event) => {
|
|
33
28
|
const height = Math.ceil(event.nativeEvent.layout.height);
|
|
34
29
|
|
|
35
30
|
if (height > 0 && height !== contentHeight) {
|
|
@@ -39,51 +34,36 @@ export const UIAccordionContent = memo(function UIAccordionContent({
|
|
|
39
34
|
|
|
40
35
|
/*
|
|
41
36
|
* ------------------------------------------------
|
|
42
|
-
*
|
|
37
|
+
* OPEN / CLOSE
|
|
43
38
|
* ------------------------------------------------
|
|
44
39
|
*/
|
|
45
40
|
|
|
46
41
|
useEffect(() => {
|
|
47
|
-
/*
|
|
48
|
-
* If content has not been measured yet,
|
|
49
|
-
* don't try to animate to an unknown height.
|
|
50
|
-
*/
|
|
51
42
|
if (contentHeight <= 0) {
|
|
52
43
|
return;
|
|
53
44
|
}
|
|
54
45
|
|
|
55
46
|
if (!accordion.animated) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
opacityAnimation.setValue(item.open ? 1 : 0);
|
|
47
|
+
animation.setValue(item.open ? 1 : 0);
|
|
59
48
|
|
|
60
49
|
return;
|
|
61
50
|
}
|
|
62
51
|
|
|
63
|
-
Animated.
|
|
64
|
-
|
|
65
|
-
toValue: item.open ? 1 : 0,
|
|
66
|
-
|
|
67
|
-
duration: accordion.animationDuration,
|
|
52
|
+
Animated.timing(animation, {
|
|
53
|
+
toValue: item.open ? 1 : 0,
|
|
68
54
|
|
|
69
|
-
|
|
70
|
-
}),
|
|
55
|
+
duration: accordion.animationDuration,
|
|
71
56
|
|
|
72
|
-
|
|
73
|
-
toValue: item.open ? 1 : 0,
|
|
57
|
+
easing: undefined,
|
|
74
58
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
useNativeDriver: true,
|
|
78
|
-
}),
|
|
79
|
-
]).start();
|
|
59
|
+
useNativeDriver: false,
|
|
60
|
+
}).start();
|
|
80
61
|
}, [
|
|
81
62
|
item.open,
|
|
82
63
|
contentHeight,
|
|
83
64
|
accordion.animated,
|
|
84
65
|
accordion.animationDuration,
|
|
85
|
-
|
|
86
|
-
opacityAnimation,
|
|
66
|
+
animation,
|
|
87
67
|
]);
|
|
88
68
|
|
|
89
69
|
/*
|
|
@@ -92,51 +72,94 @@ export const UIAccordionContent = memo(function UIAccordionContent({
|
|
|
92
72
|
* ------------------------------------------------
|
|
93
73
|
*/
|
|
94
74
|
|
|
95
|
-
const animatedHeight =
|
|
75
|
+
const animatedHeight = animation.interpolate({
|
|
96
76
|
inputRange: [0, 1],
|
|
97
77
|
|
|
98
78
|
outputRange: [0, contentHeight],
|
|
79
|
+
|
|
80
|
+
extrapolate: "clamp",
|
|
99
81
|
});
|
|
100
82
|
|
|
101
83
|
/*
|
|
102
84
|
* ------------------------------------------------
|
|
103
|
-
* CONTENT
|
|
104
|
-
* ------------------------------------------------
|
|
85
|
+
* MEASUREMENT CONTENT
|
|
105
86
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
87
|
+
* This is always rendered.
|
|
88
|
+
*
|
|
89
|
+
* It does NOT participate in normal layout.
|
|
90
|
+
* Therefore it cannot cause accordion shaking.
|
|
91
|
+
* ------------------------------------------------
|
|
108
92
|
*/
|
|
109
93
|
|
|
110
94
|
return (
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
opacity: opacityAnimation,
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
style,
|
|
123
|
-
]}
|
|
124
|
-
>
|
|
125
|
-
<View style={[styles.inner, innerStyle]} onLayout={handleLayout}>
|
|
126
|
-
{children}
|
|
95
|
+
<View style={styles.root}>
|
|
96
|
+
<View pointerEvents="none" style={styles.measureContainer}>
|
|
97
|
+
<View
|
|
98
|
+
style={[styles.measureContent, innerStyle]}
|
|
99
|
+
onLayout={handleMeasureLayout}
|
|
100
|
+
>
|
|
101
|
+
{children}
|
|
102
|
+
</View>
|
|
127
103
|
</View>
|
|
128
|
-
|
|
104
|
+
|
|
105
|
+
<Animated.View
|
|
106
|
+
testID={testID}
|
|
107
|
+
style={[
|
|
108
|
+
styles.animatedContainer,
|
|
109
|
+
|
|
110
|
+
{
|
|
111
|
+
height: animatedHeight,
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
style,
|
|
115
|
+
]}
|
|
116
|
+
>
|
|
117
|
+
<View style={[styles.visibleContent, innerStyle]}>{children}</View>
|
|
118
|
+
</Animated.View>
|
|
119
|
+
</View>
|
|
129
120
|
);
|
|
130
121
|
});
|
|
131
122
|
|
|
132
123
|
const styles = StyleSheet.create({
|
|
133
|
-
|
|
124
|
+
root: {
|
|
125
|
+
width: "100%",
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
/*
|
|
129
|
+
* Hidden measurement layer.
|
|
130
|
+
*
|
|
131
|
+
* It remains available so onLayout can always
|
|
132
|
+
* calculate the real content height.
|
|
133
|
+
*/
|
|
134
|
+
measureContainer: {
|
|
135
|
+
position: "absolute",
|
|
136
|
+
|
|
137
|
+
left: 0,
|
|
138
|
+
right: 0,
|
|
139
|
+
|
|
140
|
+
top: 0,
|
|
141
|
+
|
|
142
|
+
opacity: 0,
|
|
143
|
+
|
|
144
|
+
zIndex: -1,
|
|
145
|
+
|
|
146
|
+
pointerEvents: "none",
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
measureContent: {
|
|
150
|
+
width: "100%",
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
/*
|
|
154
|
+
* Visible animated layer.
|
|
155
|
+
*/
|
|
156
|
+
animatedContainer: {
|
|
134
157
|
width: "100%",
|
|
135
158
|
|
|
136
159
|
overflow: "hidden",
|
|
137
160
|
},
|
|
138
161
|
|
|
139
|
-
|
|
162
|
+
visibleContent: {
|
|
140
163
|
width: "100%",
|
|
141
164
|
},
|
|
142
165
|
});
|