@nexara/nativeflow 0.1.1 → 0.1.2

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.
Files changed (235) hide show
  1. package/lib/commonjs/components/Button/Button.js +50 -37
  2. package/lib/commonjs/components/Button/Button.js.map +1 -1
  3. package/lib/commonjs/components/CheckBox/CheckBox.js +39 -29
  4. package/lib/commonjs/components/CheckBox/CheckBox.js.map +1 -1
  5. package/lib/commonjs/components/Dialog/Dialog.js +52 -48
  6. package/lib/commonjs/components/Dialog/Dialog.js.map +1 -1
  7. package/lib/commonjs/components/Dialog/DialogBody.js +6 -8
  8. package/lib/commonjs/components/Dialog/DialogBody.js.map +1 -1
  9. package/lib/commonjs/components/Dialog/DialogDescription.js +4 -7
  10. package/lib/commonjs/components/Dialog/DialogDescription.js.map +1 -1
  11. package/lib/commonjs/components/Dialog/DialogFoot.js +13 -13
  12. package/lib/commonjs/components/Dialog/DialogFoot.js.map +1 -1
  13. package/lib/commonjs/components/Dialog/DialogHead.js +17 -16
  14. package/lib/commonjs/components/Dialog/DialogHead.js.map +1 -1
  15. package/lib/commonjs/components/Divider/Divider.js +5 -8
  16. package/lib/commonjs/components/Divider/Divider.js.map +1 -1
  17. package/lib/commonjs/components/Header/Header.js.map +1 -1
  18. package/lib/commonjs/components/Icon/Icon.js +9 -5
  19. package/lib/commonjs/components/Icon/Icon.js.map +1 -1
  20. package/lib/commonjs/components/Link/Link.js +13 -15
  21. package/lib/commonjs/components/Link/Link.js.map +1 -1
  22. package/lib/commonjs/components/Menu/Menu.js +51 -54
  23. package/lib/commonjs/components/Menu/Menu.js.map +1 -1
  24. package/lib/commonjs/components/Menu/MenuItem.js +0 -2
  25. package/lib/commonjs/components/Menu/MenuItem.js.map +1 -1
  26. package/lib/commonjs/components/Portal/Portal.js +1 -1
  27. package/lib/commonjs/components/Portal/Portal.js.map +1 -1
  28. package/lib/commonjs/components/Progress/Progress.js +25 -15
  29. package/lib/commonjs/components/Progress/Progress.js.map +1 -1
  30. package/lib/commonjs/components/Stack/HStack.js +9 -11
  31. package/lib/commonjs/components/Stack/HStack.js.map +1 -1
  32. package/lib/commonjs/components/Stack/VStack.js +4 -2
  33. package/lib/commonjs/components/Stack/VStack.js.map +1 -1
  34. package/lib/commonjs/components/StyledComponents/StyledText.js +12 -13
  35. package/lib/commonjs/components/StyledComponents/StyledText.js.map +1 -1
  36. package/lib/commonjs/components/StyledComponents/StyledView.js +14 -14
  37. package/lib/commonjs/components/StyledComponents/StyledView.js.map +1 -1
  38. package/lib/commonjs/components/Switch/Switch.js +2 -2
  39. package/lib/commonjs/components/Switch/Switch.js.map +1 -1
  40. package/lib/commonjs/components/UserInput/UserInput.js +29 -32
  41. package/lib/commonjs/components/UserInput/UserInput.js.map +1 -1
  42. package/lib/commonjs/helpers/LightenColorShades.js +18 -5
  43. package/lib/commonjs/helpers/LightenColorShades.js.map +1 -1
  44. package/lib/commonjs/helpers/ResponsiveCalculations.js +30 -4
  45. package/lib/commonjs/helpers/ResponsiveCalculations.js.map +1 -1
  46. package/lib/commonjs/helpers/index.js +16 -0
  47. package/lib/commonjs/helpers/index.js.map +1 -1
  48. package/lib/commonjs/index.js +5 -4
  49. package/lib/commonjs/index.js.map +2 -1
  50. package/lib/commonjs/themes/LightTheme.js +1 -3
  51. package/lib/commonjs/themes/LightTheme.js.map +1 -1
  52. package/lib/commonjs/types/index.js +11 -0
  53. package/lib/commonjs/types/index.js.map +1 -1
  54. package/lib/commonjs/types/progress.type.js +2 -0
  55. package/lib/commonjs/types/progress.type.js.map +1 -0
  56. package/lib/module/components/Button/Button.js +50 -37
  57. package/lib/module/components/Button/Button.js.map +1 -1
  58. package/lib/module/components/CheckBox/CheckBox.js +41 -31
  59. package/lib/module/components/CheckBox/CheckBox.js.map +1 -1
  60. package/lib/module/components/Dialog/Dialog.js +52 -48
  61. package/lib/module/components/Dialog/Dialog.js.map +1 -1
  62. package/lib/module/components/Dialog/DialogBody.js +7 -9
  63. package/lib/module/components/Dialog/DialogBody.js.map +1 -1
  64. package/lib/module/components/Dialog/DialogDescription.js +5 -8
  65. package/lib/module/components/Dialog/DialogDescription.js.map +1 -1
  66. package/lib/module/components/Dialog/DialogFoot.js +13 -13
  67. package/lib/module/components/Dialog/DialogFoot.js.map +1 -1
  68. package/lib/module/components/Dialog/DialogHead.js +17 -16
  69. package/lib/module/components/Dialog/DialogHead.js.map +1 -1
  70. package/lib/module/components/Divider/Divider.js +5 -8
  71. package/lib/module/components/Divider/Divider.js.map +1 -1
  72. package/lib/module/components/Header/Header.js.map +1 -1
  73. package/lib/module/components/Icon/Icon.js +7 -4
  74. package/lib/module/components/Icon/Icon.js.map +1 -1
  75. package/lib/module/components/Link/Link.js +14 -16
  76. package/lib/module/components/Link/Link.js.map +1 -1
  77. package/lib/module/components/Menu/Menu.js +51 -54
  78. package/lib/module/components/Menu/Menu.js.map +1 -1
  79. package/lib/module/components/Menu/MenuItem.js +0 -2
  80. package/lib/module/components/Menu/MenuItem.js.map +1 -1
  81. package/lib/module/components/Portal/Portal.js +1 -1
  82. package/lib/module/components/Portal/Portal.js.map +1 -1
  83. package/lib/module/components/Progress/Progress.js +26 -16
  84. package/lib/module/components/Progress/Progress.js.map +1 -1
  85. package/lib/module/components/Stack/HStack.js +10 -12
  86. package/lib/module/components/Stack/HStack.js.map +1 -1
  87. package/lib/module/components/Stack/VStack.js +4 -2
  88. package/lib/module/components/Stack/VStack.js.map +1 -1
  89. package/lib/module/components/StyledComponents/StyledText.js +13 -14
  90. package/lib/module/components/StyledComponents/StyledText.js.map +1 -1
  91. package/lib/module/components/StyledComponents/StyledView.js +15 -15
  92. package/lib/module/components/StyledComponents/StyledView.js.map +1 -1
  93. package/lib/module/components/Switch/Switch.js +2 -2
  94. package/lib/module/components/Switch/Switch.js.map +1 -1
  95. package/lib/module/components/UserInput/UserInput.js +30 -35
  96. package/lib/module/components/UserInput/UserInput.js.map +1 -1
  97. package/lib/module/helpers/LightenColorShades.js +18 -5
  98. package/lib/module/helpers/LightenColorShades.js.map +1 -1
  99. package/lib/module/helpers/ResponsiveCalculations.js +28 -3
  100. package/lib/module/helpers/ResponsiveCalculations.js.map +1 -1
  101. package/lib/module/helpers/index.js +1 -0
  102. package/lib/module/helpers/index.js.map +1 -1
  103. package/lib/module/index.js +2 -4
  104. package/lib/module/index.js.map +1 -2
  105. package/lib/module/themes/LightTheme.js +1 -2
  106. package/lib/module/themes/LightTheme.js.map +1 -1
  107. package/lib/module/types/index.js +1 -0
  108. package/lib/module/types/index.js.map +1 -1
  109. package/lib/module/types/progress.type.js +2 -0
  110. package/lib/module/types/progress.type.js.map +1 -0
  111. package/lib/typescript/commonjs/src/components/Button/Button.d.ts.map +1 -1
  112. package/lib/typescript/commonjs/src/components/CheckBox/CheckBox.d.ts.map +1 -1
  113. package/lib/typescript/commonjs/src/components/Dialog/Dialog.d.ts.map +1 -1
  114. package/lib/typescript/commonjs/src/components/Dialog/DialogBody.d.ts.map +1 -1
  115. package/lib/typescript/commonjs/src/components/Dialog/DialogFoot.d.ts.map +1 -1
  116. package/lib/typescript/commonjs/src/components/Dialog/DialogHead.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/src/components/Divider/Divider.d.ts.map +1 -1
  118. package/lib/typescript/commonjs/src/components/Header/Header.d.ts +1 -0
  119. package/lib/typescript/commonjs/src/components/Header/Header.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/src/components/Icon/Icon.d.ts +1 -0
  121. package/lib/typescript/commonjs/src/components/Icon/Icon.d.ts.map +1 -1
  122. package/lib/typescript/commonjs/src/components/Link/Link.d.ts +4 -0
  123. package/lib/typescript/commonjs/src/components/Link/Link.d.ts.map +1 -1
  124. package/lib/typescript/commonjs/src/components/Menu/Menu.d.ts.map +1 -1
  125. package/lib/typescript/commonjs/src/components/Menu/MenuItem.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/src/components/Portal/Portal.d.ts +1 -1
  127. package/lib/typescript/commonjs/src/components/Portal/Portal.d.ts.map +1 -1
  128. package/lib/typescript/commonjs/src/components/Progress/Progress.d.ts +1 -12
  129. package/lib/typescript/commonjs/src/components/Progress/Progress.d.ts.map +1 -1
  130. package/lib/typescript/commonjs/src/components/Stack/HStack.d.ts.map +1 -1
  131. package/lib/typescript/commonjs/src/components/Stack/VStack.d.ts.map +1 -1
  132. package/lib/typescript/commonjs/src/components/StyledComponents/StyledText.d.ts.map +1 -1
  133. package/lib/typescript/commonjs/src/components/StyledComponents/StyledView.d.ts.map +1 -1
  134. package/lib/typescript/commonjs/src/components/UserInput/UserInput.d.ts +1 -34
  135. package/lib/typescript/commonjs/src/components/UserInput/UserInput.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/src/helpers/LightenColorShades.d.ts +1 -1
  137. package/lib/typescript/commonjs/src/helpers/LightenColorShades.d.ts.map +1 -1
  138. package/lib/typescript/commonjs/src/helpers/ResponsiveCalculations.d.ts +1 -0
  139. package/lib/typescript/commonjs/src/helpers/ResponsiveCalculations.d.ts.map +1 -1
  140. package/lib/typescript/commonjs/src/helpers/index.d.ts +1 -0
  141. package/lib/typescript/commonjs/src/helpers/index.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/src/themes/LightTheme.d.ts.map +1 -1
  143. package/lib/typescript/commonjs/src/types/button.type.d.ts +1 -0
  144. package/lib/typescript/commonjs/src/types/button.type.d.ts.map +1 -1
  145. package/lib/typescript/commonjs/src/types/dialog.type.d.ts +0 -2
  146. package/lib/typescript/commonjs/src/types/dialog.type.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/src/types/index.d.ts +1 -0
  148. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/src/types/progress.type.d.ts +13 -0
  150. package/lib/typescript/commonjs/src/types/progress.type.d.ts.map +1 -0
  151. package/lib/typescript/commonjs/src/types/stack.type.d.ts +14 -3
  152. package/lib/typescript/commonjs/src/types/stack.type.d.ts.map +1 -1
  153. package/lib/typescript/commonjs/src/types/styledComponents.type.d.ts +7 -1
  154. package/lib/typescript/commonjs/src/types/styledComponents.type.d.ts.map +1 -1
  155. package/lib/typescript/commonjs/src/types/userInput.type.d.ts +6 -1
  156. package/lib/typescript/commonjs/src/types/userInput.type.d.ts.map +1 -1
  157. package/lib/typescript/module/src/components/Button/Button.d.ts.map +1 -1
  158. package/lib/typescript/module/src/components/CheckBox/CheckBox.d.ts.map +1 -1
  159. package/lib/typescript/module/src/components/Dialog/Dialog.d.ts.map +1 -1
  160. package/lib/typescript/module/src/components/Dialog/DialogBody.d.ts.map +1 -1
  161. package/lib/typescript/module/src/components/Dialog/DialogFoot.d.ts.map +1 -1
  162. package/lib/typescript/module/src/components/Dialog/DialogHead.d.ts.map +1 -1
  163. package/lib/typescript/module/src/components/Divider/Divider.d.ts.map +1 -1
  164. package/lib/typescript/module/src/components/Header/Header.d.ts +1 -0
  165. package/lib/typescript/module/src/components/Header/Header.d.ts.map +1 -1
  166. package/lib/typescript/module/src/components/Icon/Icon.d.ts +1 -0
  167. package/lib/typescript/module/src/components/Icon/Icon.d.ts.map +1 -1
  168. package/lib/typescript/module/src/components/Link/Link.d.ts +4 -0
  169. package/lib/typescript/module/src/components/Link/Link.d.ts.map +1 -1
  170. package/lib/typescript/module/src/components/Menu/Menu.d.ts.map +1 -1
  171. package/lib/typescript/module/src/components/Menu/MenuItem.d.ts.map +1 -1
  172. package/lib/typescript/module/src/components/Portal/Portal.d.ts +1 -1
  173. package/lib/typescript/module/src/components/Portal/Portal.d.ts.map +1 -1
  174. package/lib/typescript/module/src/components/Progress/Progress.d.ts +1 -12
  175. package/lib/typescript/module/src/components/Progress/Progress.d.ts.map +1 -1
  176. package/lib/typescript/module/src/components/Stack/HStack.d.ts.map +1 -1
  177. package/lib/typescript/module/src/components/Stack/VStack.d.ts.map +1 -1
  178. package/lib/typescript/module/src/components/StyledComponents/StyledText.d.ts.map +1 -1
  179. package/lib/typescript/module/src/components/StyledComponents/StyledView.d.ts.map +1 -1
  180. package/lib/typescript/module/src/components/UserInput/UserInput.d.ts +1 -34
  181. package/lib/typescript/module/src/components/UserInput/UserInput.d.ts.map +1 -1
  182. package/lib/typescript/module/src/helpers/LightenColorShades.d.ts +1 -1
  183. package/lib/typescript/module/src/helpers/LightenColorShades.d.ts.map +1 -1
  184. package/lib/typescript/module/src/helpers/ResponsiveCalculations.d.ts +1 -0
  185. package/lib/typescript/module/src/helpers/ResponsiveCalculations.d.ts.map +1 -1
  186. package/lib/typescript/module/src/helpers/index.d.ts +1 -0
  187. package/lib/typescript/module/src/helpers/index.d.ts.map +1 -1
  188. package/lib/typescript/module/src/themes/LightTheme.d.ts.map +1 -1
  189. package/lib/typescript/module/src/types/button.type.d.ts +1 -0
  190. package/lib/typescript/module/src/types/button.type.d.ts.map +1 -1
  191. package/lib/typescript/module/src/types/dialog.type.d.ts +0 -2
  192. package/lib/typescript/module/src/types/dialog.type.d.ts.map +1 -1
  193. package/lib/typescript/module/src/types/index.d.ts +1 -0
  194. package/lib/typescript/module/src/types/index.d.ts.map +1 -1
  195. package/lib/typescript/module/src/types/progress.type.d.ts +13 -0
  196. package/lib/typescript/module/src/types/progress.type.d.ts.map +1 -0
  197. package/lib/typescript/module/src/types/stack.type.d.ts +14 -3
  198. package/lib/typescript/module/src/types/stack.type.d.ts.map +1 -1
  199. package/lib/typescript/module/src/types/styledComponents.type.d.ts +7 -1
  200. package/lib/typescript/module/src/types/styledComponents.type.d.ts.map +1 -1
  201. package/lib/typescript/module/src/types/userInput.type.d.ts +6 -1
  202. package/lib/typescript/module/src/types/userInput.type.d.ts.map +1 -1
  203. package/package.json +2 -2
  204. package/src/components/Button/Button.tsx +111 -76
  205. package/src/components/CheckBox/CheckBox.tsx +61 -49
  206. package/src/components/Dialog/Dialog.tsx +54 -51
  207. package/src/components/Dialog/DialogBody.tsx +7 -9
  208. package/src/components/Dialog/DialogDescription.tsx +9 -9
  209. package/src/components/Dialog/DialogFoot.tsx +15 -13
  210. package/src/components/Dialog/DialogHead.tsx +20 -17
  211. package/src/components/Divider/Divider.tsx +5 -9
  212. package/src/components/Header/Header.tsx +1 -0
  213. package/src/components/Icon/Icon.tsx +9 -4
  214. package/src/components/Link/Link.tsx +24 -7
  215. package/src/components/Menu/Menu.tsx +50 -50
  216. package/src/components/Menu/MenuItem.tsx +0 -2
  217. package/src/components/Portal/Portal.tsx +2 -2
  218. package/src/components/Progress/Progress.tsx +32 -35
  219. package/src/components/Stack/HStack.tsx +12 -12
  220. package/src/components/Stack/VStack.tsx +5 -2
  221. package/src/components/StyledComponents/StyledText.tsx +3 -5
  222. package/src/components/StyledComponents/StyledView.tsx +6 -2
  223. package/src/components/Switch/Switch.tsx +2 -2
  224. package/src/components/UserInput/UserInput.tsx +43 -37
  225. package/src/helpers/LightenColorShades.ts +26 -6
  226. package/src/helpers/ResponsiveCalculations.ts +28 -3
  227. package/src/helpers/index.ts +2 -1
  228. package/src/themes/LightTheme.ts +1 -2
  229. package/src/types/button.type.ts +1 -0
  230. package/src/types/dialog.type.ts +0 -3
  231. package/src/types/index.ts +2 -1
  232. package/src/types/progress.type.ts +16 -0
  233. package/src/types/stack.type.ts +16 -3
  234. package/src/types/styledComponents.type.ts +8 -1
  235. package/src/types/userInput.type.ts +7 -1
@@ -1,7 +1,6 @@
1
1
  import React, { useState, useRef, useCallback, useEffect, } from "react";
2
- import { StyleSheet, Pressable, View, ScrollView } from "react-native";
2
+ import { StyleSheet, Pressable, View, ScrollView, Animated } from "react-native";
3
3
  import { StyledView } from "../StyledComponents";
4
- import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
5
4
  import Portal from "../Portal/Portal";
6
5
  import { positionCalculations } from "./calculations";
7
6
  import type { menuLayoutTypes, anchorLayoutTypes } from "./calculations";
@@ -19,20 +18,20 @@ const Menu: React.FC<MenuProps> = ({
19
18
  style,
20
19
  children
21
20
  }) => {
22
-
23
21
  const [isVisible, setIsVisible] = useState<boolean>(false);
24
22
  const anchorLayoutRef = useRef<anchorLayoutTypes>({ pageY: 0, pageX: 0, height: 0, width: 0 });
25
23
  const menuLayoutRef = useRef<menuLayoutTypes>({ height: 0, width: 0 });
26
24
  const buttonRef = useRef<View | null>(null);
27
- const scaleSharedValue = useSharedValue(0.5);
25
+ const animatedScaleRef = useRef(new Animated.Value(1)).current;
26
+
28
27
  const positions = (useCallback(() => (positionCalculations(anchorLayoutRef.current, menuLayoutRef.current, placement)), [menuLayoutRef, anchorLayoutRef, placement]))();
29
28
 
30
29
  useEffect(() => {
31
- if ((disableBuiltInState && isOpen) || isVisible) {
32
- scaleSharedValue.value = withTiming(1, { duration: 150 });
33
- } else {
34
- scaleSharedValue.value = 0;
35
- }
30
+ Animated.timing(animatedScaleRef, {
31
+ toValue: (disableBuiltInState && isOpen) || isVisible ? 1 : 0,
32
+ duration: 150,
33
+ useNativeDriver: true,
34
+ }).start();
36
35
  }, [isOpen, isVisible]);
37
36
 
38
37
  const measureLayout = useCallback(() => {
@@ -63,14 +62,17 @@ const Menu: React.FC<MenuProps> = ({
63
62
 
64
63
  const renderChildren = (useCallback(() => {
65
64
  return (<ScrollView>
66
- {React.Children?.toArray(children).map((e) => {
67
- return React.cloneElement(e as React.ReactElement, {
68
- onPress: () => {
69
- (e as React.ReactElement)?.props?.onPress?.();
70
- onSelect?.((e as React.ReactElement)?.props?.name);
71
- onClose();
72
- }
73
- });
65
+ {React.Children?.toArray(children).map((child) => {
66
+ if (React.isValidElement<{ onPress: () => void; name: string; }>(child)) {
67
+ return React.cloneElement(child, {
68
+ onPress: () => {
69
+ (child)?.props?.onPress?.();
70
+ onSelect?.((child)?.props?.name);
71
+ onClose();
72
+ }
73
+ });
74
+ }
75
+ return null;
74
76
  })}
75
77
  </ScrollView>)
76
78
 
@@ -79,34 +81,15 @@ const Menu: React.FC<MenuProps> = ({
79
81
  const scale: number = disableBuiltInState ? Number(isOpen) : Number(isVisible);
80
82
  const pointerEvent = (isVisible && !disableBuiltInState) || (isOpen && disableBuiltInState) ? 'auto' : 'none';
81
83
 
82
- const STYLES = StyleSheet.create({
83
- CONTAINER: {
84
- // width: horizontalScale(130),
85
- shadowColor: "#000",
86
- backgroundColor: '#fff',
87
- shadowOffset: {
88
- width: 0,
89
- height: 2,
90
- },
91
- shadowOpacity: 0.23,
92
- shadowRadius: 2.62,
93
- elevation: 4,
94
- position: 'absolute',
95
- left: positions.left,
96
- top: positions.top,
97
- borderRadius: 5,
98
- maxHeight: 400,
99
- minWidth: horizontalScale(150),
100
- paddingVertical: verticalScale(5)
101
- }
102
- });
84
+ const dynamicStyles = {
85
+ left: positions.left,
86
+ top: positions.top,
87
+ };
103
88
 
104
- const menuAnimatedStyle = useAnimatedStyle(() => {
105
- return {
106
- transform: [{ scale: scaleSharedValue.value }],
107
- opacity: scaleSharedValue.value
108
- }
109
- });
89
+ const menuAnimatedStyle = {
90
+ transform: [{ scale: animatedScaleRef }],
91
+ opacity: animatedScaleRef
92
+ };
110
93
 
111
94
  return (<>
112
95
 
@@ -119,7 +102,7 @@ const Menu: React.FC<MenuProps> = ({
119
102
  onPress={onClose}>
120
103
  <Animated.View
121
104
  onStartShouldSetResponder={() => true}
122
- style={[STYLES.CONTAINER, menuAnimatedStyle, style]}
105
+ style={[STYLES.MENU_CONT, dynamicStyles, menuAnimatedStyle, style]}
123
106
  onLayout={({ nativeEvent: { layout: { height, width } } }) => menuLayoutRef.current = { width, height }}
124
107
  >
125
108
  {renderChildren}
@@ -127,13 +110,30 @@ const Menu: React.FC<MenuProps> = ({
127
110
  </Pressable>
128
111
  </Portal>
129
112
 
130
- <StyledView alignItems='flex-start'>
131
- <View ref={buttonRef} onLayout={measureLayout}>
132
- {anchor && React.cloneElement(anchor, { onPress: onOpen })}
133
- </View>
113
+ <StyledView alignItems='flex-start' ref={buttonRef} onLayout={measureLayout}>
114
+ {anchor && React.isValidElement<{ onPress: () => void }>(anchor) && React.cloneElement(anchor, { onPress: onOpen })}
134
115
  </StyledView>
135
116
 
136
117
  </>)
137
118
  }
138
119
  export default Menu;
139
- export type { MenuProps };
120
+ export type { MenuProps };
121
+
122
+ const STYLES = StyleSheet.create({
123
+ MENU_CONT: {
124
+ shadowColor: "#000",
125
+ backgroundColor: '#fff',
126
+ shadowOffset: {
127
+ width: 0,
128
+ height: 2,
129
+ },
130
+ shadowOpacity: 0.23,
131
+ shadowRadius: 2.62,
132
+ elevation: 4,
133
+ position: 'absolute',
134
+ borderRadius: 5,
135
+ maxHeight: 400,
136
+ minWidth: horizontalScale(150),
137
+ paddingVertical: verticalScale(5)
138
+ }
139
+ });
@@ -5,8 +5,6 @@ import { horizontalScale, moderateScale, verticalScale } from "../../helpers/Res
5
5
  import type { MenuItemProps } from "../../types";
6
6
 
7
7
  const MenuItem: React.FC<MenuItemProps> = ({
8
- // paddingV = 12,
9
- // paddingH = 12,
10
8
  paddingV = 11,
11
9
  paddingH = 17,
12
10
  gap = 12,
@@ -3,13 +3,13 @@ import PortalContext from "./PortalContext";
3
3
 
4
4
  interface PortalProps {
5
5
  children: React.ReactNode,
6
- name: string
6
+ name?: string
7
7
  }
8
8
  const Portal: React.FC<PortalProps> = ({ children, name }) => {
9
9
  const { addComponent, removeComponent } = useContext(PortalContext);
10
10
 
11
11
  useEffect(() => {
12
- const uniqueId = name ?? Math.random() * 50;
12
+ const uniqueId = name ?? `${Math.random() * 50}`;
13
13
  addComponent({ name: uniqueId, component: children });
14
14
  return () => removeComponent(uniqueId);
15
15
  }, [children, name]);
@@ -1,33 +1,16 @@
1
- import React, { useEffect, useRef } from 'react';
1
+ import React, { useEffect, useMemo, useRef } from 'react';
2
2
  import { Animated, StyleSheet } from "react-native";
3
3
  import { moderateScale, verticalScale, } from "../../helpers/ResponsiveCalculations";
4
4
  import { StyledView } from '../StyledComponents';
5
5
  import { useTheme } from '../../hooks';
6
-
7
-
8
- type ProgressProps = {
9
- /** Current progress value (0-100) */
10
- value?: number;
11
-
12
- /** Thickness of the progress bar */
13
- thickness?: number;
14
-
15
- /** Border radius of the progress bar */
16
- br?: number;
17
-
18
- /** Background color of the track (unfilled part) */
19
- trackColor?: string;
20
-
21
- /** Color of the progress (filled part) */
22
- color?: string;
23
- }
6
+ import type { ProgressProps } from '../../types';
24
7
 
25
8
  const Progress: React.FC<ProgressProps> = ({
26
9
  value = 50,
27
10
  thickness = 5,
28
11
  br = 100,
29
12
  trackColor = '#E8E8E8',
30
- color,
13
+ progressColor,
31
14
  }) => {
32
15
 
33
16
  const animatedWidth = useRef(new Animated.Value(value)).current;
@@ -35,35 +18,49 @@ const Progress: React.FC<ProgressProps> = ({
35
18
 
36
19
  useEffect(() => {
37
20
  Animated.timing(animatedWidth, {
38
- toValue: value,
21
+ toValue: value / 100,
39
22
  duration: 1000,
40
- useNativeDriver: false,
23
+ useNativeDriver: true,
41
24
  }).start();
42
25
  }, [value]);
43
26
 
44
- const STYLES = StyleSheet.create({
27
+ const dynamicStyles = useMemo(() => ({
45
28
  TRACK: {
46
29
  backgroundColor: trackColor,
47
30
  borderRadius: moderateScale(br),
48
- overflow: 'hidden'
31
+ height: verticalScale(thickness),
49
32
  },
50
33
  TRACK_ITEM: {
51
- backgroundColor: color ?? theme?.colors.primary,
52
- height: verticalScale(thickness),
53
- borderRadius: moderateScale(br)
34
+ backgroundColor: progressColor ?? theme?.colors.primary,
35
+ borderRadius: moderateScale(br),
54
36
  }
55
- });
37
+ }), [br, trackColor, thickness, progressColor, theme]);
38
+
39
+ const animatedViewStyle = {
40
+ transform: [{ scaleX: animatedWidth }],
41
+ transformOrigin: 'left'
42
+ }
56
43
 
57
44
  return (<>
58
- <StyledView style={STYLES.TRACK}>
59
- <Animated.View style={[STYLES.TRACK_ITEM, {
60
- width: animatedWidth.interpolate({
61
- inputRange: [0, 100],
62
- outputRange: ['0%', '100%'],
63
- })
64
- }]} />
45
+ <StyledView
46
+ style={[STYLES.TRACK, dynamicStyles.TRACK]}
47
+ >
48
+ <Animated.View
49
+ style={[STYLES.TRACK_ITEM, dynamicStyles.TRACK_ITEM, animatedViewStyle]}
50
+ />
65
51
  </StyledView>
66
52
  </>);
67
53
  };
68
54
  export default Progress;
69
55
  export type { ProgressProps };
56
+
57
+ const STYLES = StyleSheet.create({
58
+ TRACK: {
59
+ overflow: 'hidden',
60
+ width: '100%',
61
+ },
62
+ TRACK_ITEM: {
63
+ width: "100%",
64
+ height: '100%'
65
+ }
66
+ });
@@ -1,6 +1,7 @@
1
1
  import React, { useMemo } from "react";
2
- import { StyleSheet, View } from "react-native";
2
+ import { View } from "react-native";
3
3
  import { horizontalScale } from "../../helpers/ResponsiveCalculations";
4
+ import type { ViewStyle } from 'react-native';
4
5
  import type { HStackProps } from "../../types";
5
6
 
6
7
  const HStack: React.FC<HStackProps> = ({
@@ -8,26 +9,25 @@ const HStack: React.FC<HStackProps> = ({
8
9
  align = 'center',
9
10
  fWrap = 'wrap',
10
11
  gap = 10,
11
- containerStyle,
12
+ style,
12
13
  children,
14
+ ref,
13
15
  ...rest
14
16
  }) => {
15
17
  const calculatedGap: number = useMemo(() => horizontalScale(gap), [gap]);
16
- const viewProps = {
18
+
19
+ const viewProps: ViewStyle = {
17
20
  gap: calculatedGap,
21
+ flexDirection: 'row',
22
+ justifyContent: justify,
23
+ alignItems: align,
24
+ flexWrap: fWrap,
18
25
  };
19
- const STYLES = StyleSheet.create({
20
- HSTACK: {
21
- flexDirection: 'row',
22
- justifyContent: justify,
23
- alignItems: align,
24
- flexWrap: fWrap,
25
- }
26
- });
27
26
 
28
27
  return (<>
29
28
  <View
30
- style={[viewProps, STYLES.HSTACK, containerStyle]}
29
+ style={[viewProps, style]}
30
+ ref={ref}
31
31
  {...rest}
32
32
  >
33
33
  {children}
@@ -7,11 +7,13 @@ const VStack: React.FC<VStackProps> = ({
7
7
  children,
8
8
  align,
9
9
  gap = 10,
10
- containerStyle,
10
+ style,
11
+ ref,
11
12
  ...rest
12
13
  }) => {
13
14
 
14
15
  const calculatedGap: number = useMemo(() => horizontalScale(gap), [gap]);
16
+
15
17
  const viewProps = {
16
18
  flexDirection: 'column',
17
19
  alignItems: align,
@@ -20,7 +22,8 @@ const VStack: React.FC<VStackProps> = ({
20
22
  return (<>
21
23
  <View
22
24
  {...viewProps}
23
- style={containerStyle}
25
+ style={style}
26
+ ref={ref}
24
27
  {...rest}
25
28
  >
26
29
  {children}
@@ -18,12 +18,10 @@ const StyledText: React.FC<StyledTextProps> = ({
18
18
  secondary,
19
19
  ...props
20
20
  }) => {
21
-
22
21
  const { colors, typography: { variantSizes } }: any = useTheme();
23
-
24
- return (<>
22
+ return (
25
23
  <Text
26
- allowFontScaling={false}
24
+ // allowFontScaling={false}
27
25
  style={[{
28
26
  fontSize: responsiveFontSize(fs ?? variantSizes[variant]),
29
27
  fontFamily: ff ?? '',
@@ -37,7 +35,7 @@ const StyledText: React.FC<StyledTextProps> = ({
37
35
  >
38
36
  {children}
39
37
  </Text>
40
- </>);
38
+ );
41
39
  };
42
40
 
43
41
  export default StyledText;
@@ -15,10 +15,13 @@ const StyledView: React.FC<StyledViewProps> = ({
15
15
  w,
16
16
  children,
17
17
  style,
18
+ ref,
18
19
  ...rest
19
20
  }) => {
21
+
20
22
  const theme = useTheme(themeBg);
21
- return (<>
23
+
24
+ return (
22
25
  <View
23
26
  style={[{
24
27
  flex: f,
@@ -31,11 +34,12 @@ const StyledView: React.FC<StyledViewProps> = ({
31
34
  },
32
35
  style
33
36
  ]}
37
+ ref={ref}
34
38
  {...rest}
35
39
  >
36
40
  {children}
37
41
  </View>
38
- </>);
42
+ );
39
43
  };
40
44
 
41
45
  export default StyledView;
@@ -17,12 +17,12 @@ const Switch: React.FC<SwitchProps> = ({
17
17
  }) => {
18
18
 
19
19
  const theme: any = useTheme();
20
- const switchColor = disabled ? '#808080' : color ?? theme.colors.switchColor;
20
+ const switchColor = disabled ? '#808080' : color ?? theme.colors.primary;
21
21
 
22
22
  return (<>
23
23
  <NativeSwitch
24
24
  value={checked}
25
- trackColor={{ true: LightenColorShades(activeTrackColor ?? switchColor, 90), false: LightenColorShades(inactiveTrackColor, 60) }}
25
+ trackColor={{ true: LightenColorShades(activeTrackColor ?? switchColor, 50), false: LightenColorShades(inactiveTrackColor, 60) }}
26
26
  thumbColor={switchColor}
27
27
  onValueChange={onChange}
28
28
  style={{ transform: [{ scaleX: moderateScale(size) }, { scaleY: moderateScale(size) }] }}
@@ -1,12 +1,13 @@
1
- import { forwardRef, useMemo } from 'react';
2
- import { TextInput, StyleSheet } from 'react-native';
1
+ import { useMemo } from 'react';
2
+ import { TextInput, StyleSheet, type ViewStyle } from 'react-native';
3
+ import type { TextStyle } from 'react-native';
3
4
  import { responsiveFontSize, verticalScale, horizontalScale } from '../../helpers/ResponsiveCalculations';
4
5
  import { useTheme } from '../../hooks';
5
6
  import { StyledText, StyledView } from '../StyledComponents';
6
7
  import type { UserInputProps } from '../../types';
7
8
  import generateColors from './generateColors';
8
9
 
9
- const UserInput = forwardRef<TextInput, UserInputProps>(({
10
+ const UserInput: React.FC<UserInputProps> = ({
10
11
  variant = 'standard',
11
12
  label,
12
13
  bg,
@@ -32,8 +33,9 @@ const UserInput = forwardRef<TextInput, UserInputProps>(({
32
33
  renderLeftIcon,
33
34
  renderRightIcon,
34
35
  styles,
36
+ ref,
35
37
  ...props
36
- }, ref) => {
38
+ }) => {
37
39
 
38
40
  const theme: any = useTheme();
39
41
 
@@ -43,50 +45,44 @@ const UserInput = forwardRef<TextInput, UserInputProps>(({
43
45
  computedLabelColor
44
46
  } = useMemo(() => generateColors(theme, isError, cursorColor, placeholderColor, labelColor), [theme, isError, cursorColor, placeholderColor, labelColor]);
45
47
 
46
- const STYLES = StyleSheet.create({
48
+ const dynamicStyles = {
47
49
  INPUT_CONT: {
48
- flexDirection: 'row',
49
- alignItems: multiline ? 'flex-start' : 'center',
50
+ alignItems: multiline ? 'flex-start' : 'center' as ViewStyle['alignItems'],
50
51
  backgroundColor: disabled ? theme.colors.disable : bg ?? theme.colors.inputBgColor,
51
52
  borderColor: isError ? theme.colors.error : strokeColor ?? theme.colors.outline,
52
53
  borderWidth: variant === 'standard' ? 0 : stroke,
53
54
  borderBottomWidth: stroke,
54
- paddingHorizontal: horizontalScale(14),
55
55
  borderRadius: verticalScale(br),
56
- gap: horizontalScale(10),
57
- height: multiline ? 'auto' : verticalScale(48),
58
- paddingVertical: multiline ? horizontalScale(10) : 'auto',
56
+ height: multiline ? undefined : verticalScale(48),
57
+ paddingVertical: multiline ? horizontalScale(10) : undefined,
59
58
  },
60
59
  INPUT: {
61
60
  color: disabled ? theme.colors.textDisable : isError ? theme.colors.error : inputTextColor ?? theme.colors.textPrimary,
62
61
  fontSize: responsiveFontSize(inputFs),
63
- textAlignVertical: multiline ? 'top' : 'center',
64
- minHeight: multiline ? 100 : 'auto',
65
- maxHeight: multiline ? 150 : 'auto',
66
- padding: 0,
67
- flex: 1,
62
+ textAlignVertical: (multiline ? 'top' : 'center') as TextStyle['textAlignVertical'],
63
+ minHeight: multiline ? 100 : undefined,
64
+ maxHeight: multiline ? 150 : undefined,
68
65
  },
69
66
  ERROR_HELPER_TEXT: {
70
67
  color: theme.colors.error,
71
- paddingHorizontal: 5
72
68
  }
73
- });
69
+ };
74
70
 
75
71
  return (<>
76
- <StyledView gap={verticalScale(5)} style={styles?.mainContainer}>
72
+ <StyledView gap={verticalScale(5)} style={styles?.mainContainer} w='100%'>
77
73
  {
78
74
  label &&
79
75
  <StyledText variant={textVariant?.label} fs={labelFs} color={computedLabelColor} style={styles?.label}>{label}</StyledText>
80
76
  }
81
77
  <StyledView
82
- style={[STYLES.INPUT_CONT, styles?.inputContainer]}
78
+ style={[STYLES.INPUT_CONT, dynamicStyles.INPUT_CONT, styles?.inputContainer]}
83
79
  >
84
80
  {
85
81
  renderLeftIcon
86
82
  }
87
83
  <TextInput
88
84
  ref={ref}
89
- style={[STYLES.INPUT, styles?.input]}
85
+ style={[STYLES.INPUT, dynamicStyles.INPUT, styles?.input]}
90
86
  placeholder={placeholder}
91
87
  placeholderTextColor={computedPlaceholderColor}
92
88
  editable={!disabled}
@@ -100,25 +96,35 @@ const UserInput = forwardRef<TextInput, UserInputProps>(({
100
96
  </StyledView>
101
97
  {
102
98
  (isError && helperText) &&
103
- <StyledText variant={textVariant?.helperText} fs={helperTextFS} style={[STYLES.ERROR_HELPER_TEXT, styles?.helperText]}>{helperText}</StyledText>
99
+ <StyledText
100
+ variant={textVariant?.helperText}
101
+ fs={helperTextFS}
102
+ style={[
103
+ STYLES.ERROR_HELPER_TEXT,
104
+ dynamicStyles.ERROR_HELPER_TEXT,
105
+ styles?.helperText
106
+ ]}
107
+ >
108
+ {helperText}
109
+ </StyledText>
104
110
  }
105
111
  </StyledView>
106
112
  </>)
107
- });
113
+ };
108
114
  export default UserInput;
109
115
  export type { UserInputProps };
110
116
 
111
- // const STYLES = StyleSheet.create({
112
- // INPUT_CONT: {
113
- // flexDirection: 'row',
114
- // paddingHorizontal: horizontalScale(14),
115
- // gap: horizontalScale(10),
116
- // },
117
- // INPUT: {
118
- // padding: 0,
119
- // flex: 1,
120
- // },
121
- // ERROR_HELPER_TEXT: {
122
- // paddingHorizontal: 5
123
- // }
124
- // });
117
+ const STYLES = StyleSheet.create({
118
+ INPUT_CONT: {
119
+ flexDirection: 'row',
120
+ paddingHorizontal: horizontalScale(14),
121
+ gap: horizontalScale(10),
122
+ },
123
+ INPUT: {
124
+ padding: 0,
125
+ flex: 1,
126
+ },
127
+ ERROR_HELPER_TEXT: {
128
+ paddingHorizontal: 5
129
+ }
130
+ });
@@ -1,7 +1,27 @@
1
- const LightenColorShades = (hex:string, amount: number)=> {
2
- let r = Math.min(255, parseInt(hex.slice(1, 3), 16) + amount);
3
- let g = Math.min(255, parseInt(hex.slice(3, 5), 16) + amount);
4
- let b = Math.min(255, parseInt(hex.slice(5, 7), 16) + amount);
5
- return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`;
6
- }
1
+ const LightenColorShades = (color: string, amount: number): string => {
2
+ if (color.startsWith("#")) {
3
+ color = color.slice(1);
4
+ }
5
+ if (color.length === 3) {
6
+ color = color.split("").map(c => c + c).join("");
7
+ }
8
+ if (color.length !== 6) {
9
+ throw new Error("Invalid HEX color.");
10
+ }
11
+
12
+ const getValidColorValue = (start: number): number => {
13
+ const value = parseInt(color.slice(start, start + 2), 16);
14
+ return Number.isNaN(value) ? 0 : Math.min(255, Math.max(0, value + amount));
15
+ };
16
+
17
+ const r: number = getValidColorValue(0);
18
+ const g: number = getValidColorValue(2);
19
+ const b: number = getValidColorValue(4);
20
+
21
+ return `#${((1 << 24) + (r << 16) + (g << 8) + b)
22
+ .toString(16)
23
+ .slice(1)
24
+ .toUpperCase()}`;
25
+ };
26
+
7
27
  export default LightenColorShades;
@@ -13,7 +13,11 @@ const guidelineBaseWidth = 350;
13
13
  const guidelineBaseHeight = 680;
14
14
  const [shortDimension, longDimension] = SCREEN_WIDTH < SCREEN_HEIGHT ? [SCREEN_WIDTH, SCREEN_HEIGHT] : [SCREEN_HEIGHT, SCREEN_WIDTH];
15
15
 
16
+ const scalingCache = new Map<'hScale' | 'vScale' | 'fs', object>();
16
17
 
18
+ export const fun = () => {
19
+ return scalingCache
20
+ }
17
21
  const checkIsPhone = (size: number): number => {
18
22
  if (SCREEN_WIDTH <= 430 && SCREEN_WIDTH >= 375) {
19
23
  return size;
@@ -24,11 +28,18 @@ export const horizontalScale = (size: number): number => {
24
28
  if (checkIsPhone(size)) {
25
29
  return size;
26
30
  }
31
+ const hScaleCache: any = scalingCache.get('hScale') || {};
32
+ if (hScaleCache?.[size]) {
33
+ return hScaleCache?.[size];
34
+ }
27
35
  const slowDownRate = SCREEN_WIDTH < 375 ? 2 : 0.40;
28
36
  let scale = (shortDimension / guidelineBaseHeight);
29
37
  scale = 1 + (scale - 1) * slowDownRate;
30
38
  let adjustedSize = size * Math.max(scale, 0.80);
31
- return Math.floor(PixelRatio.roundToNearestPixel(adjustedSize));
39
+ const finalSize = Math.floor(PixelRatio.roundToNearestPixel(adjustedSize));
40
+ hScaleCache[size] = finalSize;
41
+ scalingCache.set('hScale', hScaleCache)
42
+ return finalSize;
32
43
  }
33
44
 
34
45
 
@@ -36,11 +47,18 @@ export const verticalScale = (size: number): number => {
36
47
  if (checkIsPhone(size)) {
37
48
  return size;
38
49
  }
50
+ const vScaleCache: any = scalingCache.get('vScale') || {};
51
+ if (vScaleCache?.[size]) {
52
+ return vScaleCache?.[size];
53
+ }
39
54
  const slowDownRate = SCREEN_WIDTH < 375 ? 2 : 0.40;
40
55
  let scale = (longDimension / guidelineBaseHeight);
41
56
  scale = 1 + (scale - 1) * slowDownRate;
42
57
  let adjustedSize = size * Math.max(scale, 0.80);
43
- return Math.floor(PixelRatio.roundToNearestPixel(adjustedSize));
58
+ const finalSize = Math.floor(PixelRatio.roundToNearestPixel(adjustedSize));
59
+ vScaleCache[size] = finalSize;
60
+ scalingCache.set('vScale', vScaleCache)
61
+ return finalSize;
44
62
  }
45
63
 
46
64
 
@@ -63,13 +81,20 @@ export const responsiveFontSize = (fontSize: number): number => {
63
81
  if (checkIsPhone(fontSize)) {
64
82
  return fontSize;
65
83
  }
84
+ const fsCache: any = scalingCache.get('fs') || {};
85
+ if (fsCache?.[fontSize]) {
86
+ return fsCache?.[fontSize];
87
+ }
66
88
  const slowDownRate = SCREEN_WIDTH < 375 ? 2 : 0.20
67
89
  const screenDiagonal = Math.sqrt(SCREEN_WIDTH ** 2 + SCREEN_HEIGHT ** 2);
68
90
  const baseScreenDiagonal = Math.sqrt(360 ** 2 + 640 ** 2);
69
91
  let scale = screenDiagonal / baseScreenDiagonal;
70
92
  scale = 1 + (scale - 1) * slowDownRate;
71
93
  let adjustedFontSize = fontSize * Math.max(scale, 0.85);
72
- return Math.floor(PixelRatio.roundToNearestPixel(adjustedFontSize))
94
+ const finalSize = Math.floor(PixelRatio.roundToNearestPixel(adjustedFontSize));
95
+ fsCache[fontSize] = finalSize;
96
+ scalingCache.set('vScale', fsCache)
97
+ return finalSize;
73
98
  };
74
99
 
75
100