sapo-components-ui-rn 1.0.0

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 (215) hide show
  1. package/README.md +69 -0
  2. package/dist/assets/error.png +0 -0
  3. package/dist/assets/icon-checkbox-active.svg +4 -0
  4. package/dist/assets/icon-checkbox.svg +3 -0
  5. package/dist/assets/image_default.png +0 -0
  6. package/dist/assets/images/error.png +0 -0
  7. package/dist/assets/images/image_default.png +0 -0
  8. package/dist/assets/images/info.png +0 -0
  9. package/dist/assets/images/success.png +0 -0
  10. package/dist/assets/images/warning.png +0 -0
  11. package/dist/assets/info.png +0 -0
  12. package/dist/assets/success.png +0 -0
  13. package/dist/assets/svg/icon-checkbox-active.svg +4 -0
  14. package/dist/assets/svg/icon-checkbox.svg +3 -0
  15. package/dist/assets/warning.png +0 -0
  16. package/dist/components/ActivityIndicator.d.ts +28 -0
  17. package/dist/components/Avatar/index.d.ts +17 -0
  18. package/dist/components/Badge/index.d.ts +13 -0
  19. package/dist/components/Button/index.d.ts +23 -0
  20. package/dist/components/ButtonIcon/index.d.ts +18 -0
  21. package/dist/components/Checkbox/index.d.ts +14 -0
  22. package/dist/components/ChipBar/index.d.ts +16 -0
  23. package/dist/components/CountingDot/index.d.ts +13 -0
  24. package/dist/components/FloatingButton/index.d.ts +17 -0
  25. package/dist/components/Icon/index.d.ts +17 -0
  26. package/dist/components/IconSvg/index.d.ts +12 -0
  27. package/dist/components/Image/index.d.ts +14 -0
  28. package/dist/components/ProgressBar.d.ts +42 -0
  29. package/dist/components/RadioButton/index.d.ts +13 -0
  30. package/dist/components/ScaleButton/index.d.ts +4 -0
  31. package/dist/components/SelectionField/index.d.ts +24 -0
  32. package/dist/components/Spacer/index.d.ts +9 -0
  33. package/dist/components/Switch/Switch.d.ts +47 -0
  34. package/dist/components/Switch/utils.d.ts +14 -0
  35. package/dist/components/Text/index.d.ts +14 -0
  36. package/dist/components/TextInput/Addons/Outline.d.ts +15 -0
  37. package/dist/components/TextInput/Addons/Underline.d.ts +19 -0
  38. package/dist/components/TextInput/Adornment/TextInputAdornment.d.ts +43 -0
  39. package/dist/components/TextInput/Adornment/TextInputAffix.d.ts +72 -0
  40. package/dist/components/TextInput/Adornment/enums.d.ts +12 -0
  41. package/dist/components/TextInput/Adornment/types.d.ts +11 -0
  42. package/dist/components/TextInput/Adornment/utils.d.ts +11 -0
  43. package/dist/components/TextInput/Label/InputLabel.d.ts +4 -0
  44. package/dist/components/TextInput/Label/LabelBackground.d.ts +4 -0
  45. package/dist/components/TextInput/TextInput.d.ts +171 -0
  46. package/dist/components/TextInput/TextInputDefault.d.ts +4 -0
  47. package/dist/components/TextInput/TextInputFlat.d.ts +4 -0
  48. package/dist/components/TextInput/constants.d.ts +31 -0
  49. package/dist/components/TextInput/helpers.d.ts +95 -0
  50. package/dist/components/TextInput/types.d.ts +154 -0
  51. package/dist/components/Toast/ToastProvider.d.ts +21 -0
  52. package/dist/components/Toast/index.d.ts +3 -0
  53. package/dist/components/Typography/AnimatedText.d.ts +34 -0
  54. package/dist/components/Typography/StyledText.d.ts +12 -0
  55. package/dist/components/Typography/Text.d.ts +35 -0
  56. package/dist/components/Typography/types.d.ts +2 -0
  57. package/dist/components/View/index.d.ts +38 -0
  58. package/dist/components/ViewVisibleAnimated/index.d.ts +25 -0
  59. package/dist/constants.d.ts +1 -0
  60. package/dist/core/theming.d.ts +43 -0
  61. package/dist/icons/IconArrowDown.d.ts +4 -0
  62. package/dist/icons/IconCheckbox.d.ts +4 -0
  63. package/dist/icons/IconCheckboxActive.d.ts +4 -0
  64. package/dist/icons/IconClearText.d.ts +4 -0
  65. package/dist/icons/IconRadio.d.ts +4 -0
  66. package/dist/icons/IconRadioActive.d.ts +4 -0
  67. package/dist/icons/IconRadioDisable.d.ts +4 -0
  68. package/dist/index.d.ts +33 -0
  69. package/dist/index.esm.js +6758 -0
  70. package/dist/index.esm.js.map +1 -0
  71. package/dist/index.js +6823 -0
  72. package/dist/index.js.map +1 -0
  73. package/dist/styles/fonts.d.ts +78 -0
  74. package/dist/styles/overlay.d.ts +3 -0
  75. package/dist/styles/shadow.d.ts +18 -0
  76. package/dist/styles/themes/DarkTheme.d.ts +2 -0
  77. package/dist/styles/themes/LightTheme.d.ts +2 -0
  78. package/dist/styles/themes/index.d.ts +2 -0
  79. package/dist/styles/themes/tokens.d.ts +830 -0
  80. package/dist/theme/blue.d.ts +14 -0
  81. package/dist/theme/colors.d.ts +99 -0
  82. package/dist/theme/container-styles.d.ts +124 -0
  83. package/dist/theme/dimensions.d.ts +36 -0
  84. package/dist/theme/green.d.ts +15 -0
  85. package/dist/theme/icon.d.ts +5 -0
  86. package/dist/theme/ink.d.ts +11 -0
  87. package/dist/theme/orange.d.ts +14 -0
  88. package/dist/theme/purple.d.ts +6 -0
  89. package/dist/theme/red.d.ts +15 -0
  90. package/dist/theme/themes.d.ts +277 -0
  91. package/dist/theme/white.d.ts +10 -0
  92. package/dist/theme/yellow.d.ts +15 -0
  93. package/dist/types/index.d.ts +65 -0
  94. package/dist/types.d.ts +220 -0
  95. package/dist/utils/BackHandler/BackHandler.d.ts +9 -0
  96. package/dist/utils/BackHandler/BackHandler.native.d.ts +2 -0
  97. package/dist/utils/addEventListener.d.ts +12 -0
  98. package/dist/utils/forwardRef.d.ts +11 -0
  99. package/dist/utils/function-utils.d.ts +12 -0
  100. package/dist/utils/getContrastingColor.d.ts +2 -0
  101. package/dist/utils/hasTouchHandler.d.ts +5 -0
  102. package/dist/utils/roundLayoutSize.d.ts +1 -0
  103. package/dist/utils/splitStyles.d.ts +19 -0
  104. package/dist/utils/toast-manager.d.ts +21 -0
  105. package/dist/utils/useAnimatedValue.d.ts +2 -0
  106. package/dist/utils/useAnimatedValueArray.d.ts +2 -0
  107. package/dist/utils/useIsKeyboardShown.d.ts +6 -0
  108. package/dist/utils/useLayout.d.ts +6 -0
  109. package/dist/utils/useLazyRef.d.ts +2 -0
  110. package/package.json +104 -0
  111. package/src/.DS_Store +0 -0
  112. package/src/assets/images/error.png +0 -0
  113. package/src/assets/images/image_default.png +0 -0
  114. package/src/assets/images/info.png +0 -0
  115. package/src/assets/images/success.png +0 -0
  116. package/src/assets/images/warning.png +0 -0
  117. package/src/assets/svg/icon-checkbox-active.svg +4 -0
  118. package/src/assets/svg/icon-checkbox.svg +3 -0
  119. package/src/babel/.eslintrc +7 -0
  120. package/src/babel/index.js +63 -0
  121. package/src/components/.DS_Store +0 -0
  122. package/src/components/ActivityIndicator.tsx +238 -0
  123. package/src/components/Avatar/index.tsx +102 -0
  124. package/src/components/Badge/index.tsx +55 -0
  125. package/src/components/Button/index.tsx +162 -0
  126. package/src/components/ButtonIcon/index.tsx +98 -0
  127. package/src/components/Checkbox/index.tsx +107 -0
  128. package/src/components/ChipBar/index.tsx +112 -0
  129. package/src/components/CountingDot/index.tsx +63 -0
  130. package/src/components/FloatingButton/index.tsx +99 -0
  131. package/src/components/Icon/index.tsx +135 -0
  132. package/src/components/IconSvg/index.tsx +42 -0
  133. package/src/components/Image/index.tsx +127 -0
  134. package/src/components/ProgressBar.tsx +272 -0
  135. package/src/components/RadioButton/index.tsx +105 -0
  136. package/src/components/ScaleButton/index.tsx +17 -0
  137. package/src/components/SelectionField/index.tsx +166 -0
  138. package/src/components/Spacer/index.tsx +19 -0
  139. package/src/components/Switch/Switch.tsx +110 -0
  140. package/src/components/Switch/utils.ts +96 -0
  141. package/src/components/Text/index.tsx +69 -0
  142. package/src/components/TextInput/.DS_Store +0 -0
  143. package/src/components/TextInput/Addons/Outline.tsx +62 -0
  144. package/src/components/TextInput/Addons/Underline.tsx +71 -0
  145. package/src/components/TextInput/Adornment/TextInputAdornment.tsx +191 -0
  146. package/src/components/TextInput/Adornment/TextInputAffix.tsx +212 -0
  147. package/src/components/TextInput/Adornment/enums.tsx +12 -0
  148. package/src/components/TextInput/Adornment/types.tsx +11 -0
  149. package/src/components/TextInput/Adornment/utils.ts +39 -0
  150. package/src/components/TextInput/Label/InputLabel.tsx +216 -0
  151. package/src/components/TextInput/Label/LabelBackground.tsx +100 -0
  152. package/src/components/TextInput/TextInput.tsx +564 -0
  153. package/src/components/TextInput/TextInputDefault.tsx +187 -0
  154. package/src/components/TextInput/TextInputFlat.tsx +452 -0
  155. package/src/components/TextInput/constants.tsx +48 -0
  156. package/src/components/TextInput/helpers.tsx +546 -0
  157. package/src/components/TextInput/types.tsx +155 -0
  158. package/src/components/Toast/ToastProvider.tsx +69 -0
  159. package/src/components/Toast/index.tsx +239 -0
  160. package/src/components/Typography/AnimatedText.tsx +84 -0
  161. package/src/components/Typography/StyledText.tsx +53 -0
  162. package/src/components/Typography/Text.tsx +189 -0
  163. package/src/components/Typography/types.tsx +5 -0
  164. package/src/components/View/index.tsx +175 -0
  165. package/src/components/ViewVisibleAnimated/index.tsx +199 -0
  166. package/src/constants.tsx +16 -0
  167. package/src/core/theming.tsx +144 -0
  168. package/src/icons/IconArrowDown.tsx +14 -0
  169. package/src/icons/IconCheckbox.tsx +20 -0
  170. package/src/icons/IconCheckboxActive.tsx +18 -0
  171. package/src/icons/IconClearText.tsx +14 -0
  172. package/src/icons/IconRadio.tsx +11 -0
  173. package/src/icons/IconRadioActive.tsx +12 -0
  174. package/src/icons/IconRadioDisable.tsx +12 -0
  175. package/src/index.ts +51 -0
  176. package/src/index.tsx +50 -0
  177. package/src/styles/fonts.tsx +89 -0
  178. package/src/styles/overlay.tsx +69 -0
  179. package/src/styles/shadow.tsx +47 -0
  180. package/src/styles/themes/DarkTheme.tsx +157 -0
  181. package/src/styles/themes/LightTheme.tsx +160 -0
  182. package/src/styles/themes/index.ts +3 -0
  183. package/src/styles/themes/tokens.tsx +481 -0
  184. package/src/theme/blue.ts +25 -0
  185. package/src/theme/colors.ts +21 -0
  186. package/src/theme/container-styles.tsx +126 -0
  187. package/src/theme/dimensions.ts +44 -0
  188. package/src/theme/green.ts +27 -0
  189. package/src/theme/icon.ts +7 -0
  190. package/src/theme/ink.ts +18 -0
  191. package/src/theme/orange.ts +24 -0
  192. package/src/theme/purple.ts +8 -0
  193. package/src/theme/red.ts +26 -0
  194. package/src/theme/themes.tsx +287 -0
  195. package/src/theme/white.ts +16 -0
  196. package/src/theme/yellow.ts +26 -0
  197. package/src/types/index.ts +71 -0
  198. package/src/types/svg.d.ts +5 -0
  199. package/src/types.ts +259 -0
  200. package/src/types.tsx +284 -0
  201. package/src/utils/BackHandler/BackHandler.native.tsx +3 -0
  202. package/src/utils/BackHandler/BackHandler.tsx +11 -0
  203. package/src/utils/addEventListener.tsx +56 -0
  204. package/src/utils/forwardRef.tsx +23 -0
  205. package/src/utils/function-utils.tsx +108 -0
  206. package/src/utils/getContrastingColor.tsx +15 -0
  207. package/src/utils/hasTouchHandler.tsx +23 -0
  208. package/src/utils/roundLayoutSize.ts +2 -0
  209. package/src/utils/splitStyles.ts +60 -0
  210. package/src/utils/toast-manager.tsx +46 -0
  211. package/src/utils/useAnimatedValue.tsx +9 -0
  212. package/src/utils/useAnimatedValueArray.tsx +13 -0
  213. package/src/utils/useIsKeyboardShown.tsx +55 -0
  214. package/src/utils/useLayout.tsx +29 -0
  215. package/src/utils/useLazyRef.tsx +11 -0
@@ -0,0 +1,175 @@
1
+ import React from "react";
2
+ import {
3
+ StyleSheet,
4
+ TouchableOpacity,
5
+ View,
6
+ StyleProp,
7
+ ViewStyle,
8
+ } from "react-native";
9
+
10
+ interface ViewProps {
11
+ row?: boolean;
12
+ full?: boolean;
13
+ justifyCenter?: boolean;
14
+ justifyBetween?: boolean;
15
+ alignCenter?: boolean;
16
+ center?: boolean;
17
+ gap?: number;
18
+ color?: any;
19
+ backgroundColor?: any;
20
+ width?: number | `${number}%`;
21
+ height?: number | `${number}%`;
22
+ onPress?: () => void;
23
+ padding?: number;
24
+ paddingHorizontal?: number;
25
+ paddingVertical?: number;
26
+ disabled?: boolean;
27
+ activeOpacity?: number;
28
+ paddingBottom?: number;
29
+ marginHorizontal?: number;
30
+ marginVertical?: number;
31
+ paddingLeft?: number;
32
+ paddingRight?: number;
33
+ paddingTop?: number;
34
+ style?: StyleProp<ViewStyle>;
35
+ children?: React.ReactNode;
36
+ alignEnd?: boolean;
37
+ wrap?: boolean;
38
+ borderBottomWidth?: number;
39
+ borderBottomColor?: string;
40
+ borderRadius?: number;
41
+ borderWidth?: number;
42
+ borderColor?: string;
43
+ }
44
+ const ViewCustom = ({
45
+ row,
46
+ full,
47
+ justifyCenter,
48
+ justifyBetween,
49
+ alignCenter,
50
+ center,
51
+ color,
52
+ backgroundColor,
53
+ width,
54
+ height,
55
+ padding,
56
+ paddingHorizontal,
57
+ paddingVertical,
58
+ marginHorizontal,
59
+ marginVertical,
60
+ paddingLeft,
61
+ paddingRight,
62
+ paddingTop,
63
+ alignEnd,
64
+ wrap,
65
+ borderBottomWidth,
66
+ borderBottomColor,
67
+ borderRadius,
68
+ borderWidth,
69
+ borderColor,
70
+ style,
71
+ onPress,
72
+ activeOpacity,
73
+ children,
74
+ }: ViewProps) => {
75
+ const getStyle = () => {
76
+ const styleCustom: any = {};
77
+
78
+ if (row) {
79
+ styleCustom.flexDirection = "row";
80
+ }
81
+ if (full) {
82
+ styleCustom.flex = 1;
83
+ }
84
+ if (justifyCenter) {
85
+ styleCustom.justifyContent = "center";
86
+ }
87
+ if (justifyBetween) {
88
+ styleCustom.justifyContent = "space-between";
89
+ }
90
+ if (alignCenter) {
91
+ styleCustom.alignItems = "center";
92
+ }
93
+ if (center) {
94
+ styleCustom.justifyContent = "center";
95
+ styleCustom.alignItems = "center";
96
+ }
97
+ if (color) {
98
+ styleCustom.color = color;
99
+ }
100
+ if (backgroundColor) {
101
+ styleCustom.backgroundColor = backgroundColor;
102
+ }
103
+ if (width) {
104
+ styleCustom.width = width;
105
+ }
106
+ if (height) {
107
+ styleCustom.height = height;
108
+ }
109
+ if (padding) {
110
+ styleCustom.padding = padding;
111
+ }
112
+ if (paddingHorizontal) {
113
+ styleCustom.paddingHorizontal = paddingHorizontal;
114
+ }
115
+ if (paddingVertical) {
116
+ styleCustom.paddingVertical = paddingVertical;
117
+ }
118
+ if (marginHorizontal) {
119
+ styleCustom.marginHorizontal = marginHorizontal;
120
+ }
121
+
122
+ if (marginVertical) {
123
+ styleCustom.marginVertical = marginVertical;
124
+ }
125
+
126
+ if (paddingLeft) {
127
+ styleCustom.paddingLeft = paddingLeft;
128
+ }
129
+ if (paddingTop) {
130
+ styleCustom.paddingTop = paddingTop;
131
+ }
132
+
133
+ if (paddingRight) {
134
+ styleCustom.paddingRight = paddingRight;
135
+ }
136
+ if (alignEnd) {
137
+ styleCustom.alignItems = "flex-end";
138
+ }
139
+ if (wrap) {
140
+ styleCustom.flexWrap = "wrap";
141
+ }
142
+ if (borderBottomWidth) {
143
+ styleCustom.borderBottomWidth = borderBottomWidth;
144
+ }
145
+ if (borderBottomColor) {
146
+ styleCustom.borderBottomColor = borderBottomColor;
147
+ }
148
+ if (borderRadius) {
149
+ styleCustom.borderRadius = borderRadius;
150
+ }
151
+ if (borderWidth) {
152
+ styleCustom.borderWidth = borderWidth;
153
+ }
154
+ if (borderColor) {
155
+ styleCustom.borderColor = borderColor;
156
+ }
157
+
158
+ return StyleSheet.create({ styleCustom }).styleCustom;
159
+ };
160
+
161
+ const defaultStyle = getStyle();
162
+ const Component = onPress ? TouchableOpacity : View;
163
+
164
+ return (
165
+ <Component
166
+ activeOpacity={activeOpacity}
167
+ onPress={onPress}
168
+ style={[defaultStyle, style]}
169
+ >
170
+ {children}
171
+ </Component>
172
+ );
173
+ };
174
+
175
+ export default React.memo(ViewCustom);
@@ -0,0 +1,199 @@
1
+ import React, {
2
+ useRef,
3
+ useEffect,
4
+ useImperativeHandle,
5
+ useState,
6
+ ForwardedRef,
7
+ } from "react";
8
+ import { Animated, ViewStyle, StyleProp } from "react-native";
9
+
10
+ export type ViewVisibleAnimatedProps = {
11
+ scaleEnable?: boolean;
12
+ translateEnable?: boolean;
13
+ autoHide?: boolean;
14
+ onShowDone?: () => void;
15
+ onDone?: () => void;
16
+ onShowStart?: () => void;
17
+ style?: StyleProp<ViewStyle>;
18
+ delay?: number;
19
+ duration?: number;
20
+ timeout?: number;
21
+ autoShow?: boolean;
22
+ pointerEvents?: "box-none" | "none" | "box-only" | "auto";
23
+ scaleType?: "in" | "out";
24
+ renderHiddenContent?: React.ReactNode;
25
+ children?: React.ReactNode;
26
+ disableHiddenContent?: boolean;
27
+ };
28
+
29
+ const ViewVisibleAnimated = React.memo(
30
+ React.forwardRef(
31
+ (
32
+ {
33
+ onShowStart,
34
+ onShowDone,
35
+ onDone,
36
+ style,
37
+ children,
38
+ autoHide = false,
39
+ scaleEnable = true,
40
+ translateEnable = true,
41
+ delay = 100,
42
+ duration = 250,
43
+ timeout = 1000,
44
+ autoShow = true,
45
+ pointerEvents = "auto",
46
+ scaleType = "in",
47
+ renderHiddenContent = null,
48
+ disableHiddenContent = false,
49
+ }: ViewVisibleAnimatedProps,
50
+ ref: ForwardedRef<{ show: () => void; hide: () => void }>
51
+ ) => {
52
+ useImperativeHandle(ref, () => ({
53
+ hide,
54
+ show,
55
+ }));
56
+
57
+ const visibleAnimation = useRef(new Animated.Value(0)).current;
58
+ const translateAnimation = useRef(new Animated.Value(0)).current;
59
+ const scaleAnimation = useRef(
60
+ new Animated.Value(scaleType === "in" ? 0 : 3)
61
+ ).current;
62
+
63
+ const [visible, setVisible] = useState(false);
64
+ let TIME_OUT: NodeJS.Timeout | null = null;
65
+
66
+ useEffect(() => {
67
+ if (autoShow) {
68
+ TIME_OUT = setTimeout(() => {
69
+ show();
70
+ }, delay);
71
+ }
72
+ return () => {
73
+ if (TIME_OUT) clearTimeout(TIME_OUT);
74
+ };
75
+ }, []);
76
+
77
+ const show = (
78
+ callback?: () => void,
79
+ durationShow: number = delay
80
+ ): void => {
81
+ handleShow({ callback, durationShow });
82
+ };
83
+
84
+ const handleShow = ({
85
+ callback,
86
+ durationShow,
87
+ position = "top",
88
+ }: {
89
+ callback?: () => void;
90
+ durationShow: number;
91
+ position?: "top" | "bottom";
92
+ }) => {
93
+ if (TIME_OUT) clearTimeout(TIME_OUT);
94
+ TIME_OUT = setTimeout(() => {
95
+ onShowStart?.();
96
+ showAnimation(callback, position);
97
+ }, durationShow);
98
+ };
99
+
100
+ const showAnimation = (
101
+ callback?: () => void,
102
+ position: "top" | "bottom" = "bottom"
103
+ ) => {
104
+ setVisible(true);
105
+ translateAnimation.setValue(position === "bottom" ? 100 : -100);
106
+
107
+ Animated.parallel([
108
+ Animated.timing(scaleAnimation, {
109
+ toValue: 1,
110
+ duration,
111
+ useNativeDriver: true,
112
+ }),
113
+ Animated.timing(visibleAnimation, {
114
+ toValue: 1,
115
+ duration,
116
+ useNativeDriver: true,
117
+ }),
118
+ Animated.timing(translateAnimation, {
119
+ toValue: 0,
120
+ duration,
121
+ useNativeDriver: true,
122
+ }),
123
+ ]).start(() => {
124
+ callback?.();
125
+ onShowDone?.();
126
+ if (autoHide) {
127
+ TIME_OUT = setTimeout(() => {
128
+ hide(onDone);
129
+ }, timeout);
130
+ }
131
+ });
132
+ };
133
+
134
+ const hide = (
135
+ callback?: () => void,
136
+ durationHide: number = duration
137
+ ): void => {
138
+ handleHide({ callback, durationHide });
139
+ };
140
+
141
+ const handleHide = ({
142
+ durationHide,
143
+ callback,
144
+ position = "bottom",
145
+ }: {
146
+ durationHide: number;
147
+ callback?: () => void;
148
+ position?: "top" | "bottom";
149
+ }) => {
150
+ Animated.parallel([
151
+ Animated.timing(scaleAnimation, {
152
+ toValue: scaleType === "in" ? 0 : 3,
153
+ duration: durationHide,
154
+ useNativeDriver: true,
155
+ }),
156
+ Animated.timing(visibleAnimation, {
157
+ toValue: 0,
158
+ duration: durationHide,
159
+ useNativeDriver: true,
160
+ }),
161
+ Animated.timing(translateAnimation, {
162
+ toValue: position === "bottom" ? 300 : -300,
163
+ duration: durationHide,
164
+ useNativeDriver: true,
165
+ }),
166
+ ]).start(() => {
167
+ setVisible(false);
168
+ callback?.();
169
+ });
170
+ };
171
+
172
+ return (
173
+ <Animated.View
174
+ style={[
175
+ style,
176
+ {
177
+ opacity: visibleAnimation,
178
+ transform: [
179
+ { scale: scaleEnable ? scaleAnimation : 1 },
180
+ {
181
+ translateY: translateEnable ? translateAnimation : 0,
182
+ },
183
+ ],
184
+ },
185
+ ]}
186
+ pointerEvents={visible ? pointerEvents : "none"}
187
+ >
188
+ {disableHiddenContent
189
+ ? children
190
+ : visible
191
+ ? children
192
+ : renderHiddenContent}
193
+ </Animated.View>
194
+ );
195
+ }
196
+ )
197
+ );
198
+
199
+ export default ViewVisibleAnimated;
@@ -0,0 +1,16 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+
3
+ // Use the existence of expo-constants as a heuristic for determining if the
4
+ // status bar is translucent on Android. This should be replaced in the future
5
+ // with react-native-safe-area-context.
6
+ const estimatedStatusBarHeight =
7
+ NativeModules.NativeUnimoduleProxy?.modulesConstants?.ExponentConstants
8
+ ?.statusBarHeight ?? 0;
9
+
10
+ export const APPROX_STATUSBAR_HEIGHT = Platform.select({
11
+ android: estimatedStatusBarHeight,
12
+ ios:
13
+ typeof Platform.Version === 'number' && Platform.Version < 11
14
+ ? estimatedStatusBarHeight
15
+ : 0,
16
+ });
@@ -0,0 +1,144 @@
1
+ import type { ComponentType } from "react";
2
+ import React from "react";
3
+ import { useColorScheme } from "react-native";
4
+
5
+ import { $DeepPartial, createTheming } from "@callstack/react-theme-provider";
6
+
7
+ import { DarkTheme, LightTheme } from "../styles/themes";
8
+ import type { InternalTheme, AppTheme, NavigationTheme } from "../types";
9
+
10
+ export const DefaultTheme = LightTheme;
11
+
12
+ const {
13
+ ThemeProvider: BaseThemeProvider,
14
+ withTheme,
15
+ useTheme: useAppTheme,
16
+ } = createTheming<unknown>(LightTheme);
17
+
18
+ export const ThemeProvider = ({ children }: { children: React.ReactNode }) => {
19
+ const colorScheme = useColorScheme();
20
+ const isDark = colorScheme === "dark";
21
+ const theme = isDark ? DarkTheme : LightTheme;
22
+
23
+ return <BaseThemeProvider theme={theme}>{children}</BaseThemeProvider>;
24
+ };
25
+
26
+ export function useTheme<T = AppTheme>(overrides?: $DeepPartial<T>) {
27
+ return useAppTheme<T>(overrides);
28
+ }
29
+
30
+ export const useInternalTheme = () => {
31
+ const colorScheme = useColorScheme();
32
+ const isDark = colorScheme === "dark";
33
+ const theme = getTheme(isDark);
34
+
35
+ return theme;
36
+ };
37
+
38
+ export const withInternalTheme = <Props extends { theme: InternalTheme }, C>(
39
+ WrappedComponent: ComponentType<Props & { theme: InternalTheme }> & C
40
+ ) => withTheme<Props, C>(WrappedComponent);
41
+
42
+ export const defaultThemesByVersion = {
43
+ light: LightTheme,
44
+ dark: DarkTheme,
45
+ };
46
+
47
+ export const getTheme = <Scheme extends boolean = false>(
48
+ isDark: Scheme = false as Scheme
49
+ ): (typeof defaultThemesByVersion)[Scheme extends true ? "dark" : "light"] => {
50
+ const scheme = isDark ? "dark" : "light";
51
+
52
+ return defaultThemesByVersion[scheme];
53
+ };
54
+
55
+ // eslint-disable-next-line no-redeclare
56
+ export function adaptNavigationTheme(themes: {
57
+ reactNavigationLight: NavigationTheme;
58
+ materialLight?: AppTheme;
59
+ }): {
60
+ LightTheme: NavigationTheme;
61
+ };
62
+ // eslint-disable-next-line no-redeclare
63
+ export function adaptNavigationTheme(themes: {
64
+ reactNavigationDark: NavigationTheme;
65
+ materialDark?: AppTheme;
66
+ }): {
67
+ DarkTheme: NavigationTheme;
68
+ };
69
+ // eslint-disable-next-line no-redeclare
70
+ export function adaptNavigationTheme(themes: {
71
+ reactNavigationLight: NavigationTheme;
72
+ reactNavigationDark: NavigationTheme;
73
+ materialLight?: AppTheme;
74
+ materialDark?: AppTheme;
75
+ }): { LightTheme: NavigationTheme; DarkTheme: NavigationTheme };
76
+ // eslint-disable-next-line no-redeclare
77
+ export function adaptNavigationTheme(themes: any) {
78
+ const {
79
+ reactNavigationLight,
80
+ reactNavigationDark,
81
+ materialLight,
82
+ materialDark,
83
+ } = themes;
84
+
85
+ const getAdaptedTheme = (
86
+ navigationTheme: NavigationTheme,
87
+ AppTheme: AppTheme
88
+ ) => {
89
+ return {
90
+ ...navigationTheme,
91
+ colors: {
92
+ ...navigationTheme.colors,
93
+ primary: AppTheme.colors.surfaceBrandDefault,
94
+ background: AppTheme.colors.backgroundPrimary,
95
+ card: AppTheme.colors.elevation.level2,
96
+ text: AppTheme.colors.backgroundPrimary,
97
+ border: AppTheme.colors.borderPrimaryDefault,
98
+ notification: AppTheme.colors.surfaceErrorDefault,
99
+ },
100
+ };
101
+ };
102
+
103
+ const AppThemes = {
104
+ light: materialLight || LightTheme,
105
+ dark: materialDark || DarkTheme,
106
+ };
107
+
108
+ if (reactNavigationLight && reactNavigationDark) {
109
+ const modes = ["light", "dark"] as const;
110
+
111
+ const NavigationThemes = {
112
+ light: reactNavigationLight,
113
+ dark: reactNavigationDark,
114
+ };
115
+
116
+ const { light: adaptedLight, dark: adaptedDark } = modes.reduce(
117
+ (prev, curr) => {
118
+ return {
119
+ ...prev,
120
+ [curr]: getAdaptedTheme(NavigationThemes[curr], AppThemes[curr]),
121
+ };
122
+ },
123
+ {
124
+ light: reactNavigationLight,
125
+ dark: reactNavigationDark,
126
+ }
127
+ );
128
+
129
+ return {
130
+ LightTheme: adaptedLight,
131
+ DarkTheme: adaptedDark,
132
+ };
133
+ }
134
+
135
+ if (reactNavigationDark) {
136
+ return {
137
+ DarkTheme: getAdaptedTheme(reactNavigationDark, AppThemes.dark),
138
+ };
139
+ }
140
+
141
+ return {
142
+ LightTheme: getAdaptedTheme(reactNavigationLight, AppThemes.light),
143
+ };
144
+ }
@@ -0,0 +1,14 @@
1
+ import * as React from "react";
2
+ import Svg, { Path } from "react-native-svg";
3
+ import { SvgProps } from "react-native-svg";
4
+
5
+ const IconArrowDown = (props: SvgProps) => (
6
+ <Svg width={24} height={24} viewBox="0 0 24 24" fill="none" {...props}>
7
+ <Path
8
+ d="M18.0107 9.70166L12 15.7124L5.98926 9.70166L7.40332 8.2876L12 12.8843L16.5967 8.2876L18.0107 9.70166Z"
9
+ fill="currentColor"
10
+ />
11
+ </Svg>
12
+ );
13
+
14
+ export default IconArrowDown;
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ import Svg, { Rect } from "react-native-svg";
3
+ import { SvgProps } from "react-native-svg";
4
+
5
+ const IconCheckbox = (props: SvgProps) => (
6
+ <Svg width={24} height={24} viewBox="0 0 24 24" fill="none" {...props}>
7
+ <Rect
8
+ x={2.75}
9
+ y={2.75}
10
+ width={18.5}
11
+ height={18.5}
12
+ rx={5.25}
13
+ fill="currentColor"
14
+ stroke="#A1A5AB"
15
+ strokeWidth={1.5}
16
+ />
17
+ </Svg>
18
+ );
19
+
20
+ export default IconCheckbox;
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import Svg, { Rect, Path } from "react-native-svg";
3
+ import { SvgProps } from "react-native-svg";
4
+
5
+ const IconCheckboxActive = (props: SvgProps) => (
6
+ <Svg width={24} height={24} viewBox="0 0 24 24" fill="none" {...props}>
7
+ <Rect x={2} y={2} width={20} height={20} rx={6} fill="currentColor" />
8
+ <Path
9
+ d="M17.7745 8.32544L10.4245 15.6751L6.74951 12.0004"
10
+ stroke="white"
11
+ strokeWidth={2}
12
+ strokeLinecap="round"
13
+ strokeLinejoin="round"
14
+ />
15
+ </Svg>
16
+ );
17
+
18
+ export default IconCheckboxActive;
@@ -0,0 +1,14 @@
1
+ import * as React from "react";
2
+ import Svg, { Path } from "react-native-svg";
3
+ import { SvgProps } from "react-native-svg";
4
+
5
+ const IconClearText = (props: SvgProps) => (
6
+ <Svg width={24} height={24} viewBox="0 0 24 24" fill="none" {...props}>
7
+ <Path
8
+ d="M12 2.00043C17.53 2.00043 22 6.47046 22 12.0004C21.9997 17.5302 17.5298 22.0004 12 22.0004C6.47016 22.0004 2.00026 17.5302 2 12.0004C2.00004 6.47046 6.47003 2.00043 12 2.00043ZM12 10.5903L9.41016 8.00043L8 9.40961L10.5898 12.0004L8 14.5903L9.41016 16.0004L12 13.4096L14.5898 16.0004L16 14.5903L13.4102 12.0004L16 9.40961L14.5898 8.00043L12 10.5903Z"
9
+ fill="currentColor"
10
+ />
11
+ </Svg>
12
+ );
13
+
14
+ export default IconClearText;
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ import Svg, { Circle } from "react-native-svg";
3
+ import { SvgProps } from "react-native-svg";
4
+
5
+ const IconRadio = (props: SvgProps) => (
6
+ <Svg width={24} height={24} viewBox="0 0 24 24" fill="none" {...props}>
7
+ <Circle cx={12} cy={12} r={9.25} stroke="#A1A5AB" strokeWidth={1.5} />
8
+ </Svg>
9
+ );
10
+
11
+ export default IconRadio;
@@ -0,0 +1,12 @@
1
+ import * as React from "react";
2
+ import Svg, { Circle } from "react-native-svg";
3
+ import { SvgProps } from "react-native-svg";
4
+
5
+ const IconRadioActive = (props: SvgProps) => (
6
+ <Svg width={24} height={24} viewBox="0 0 24 24" fill="none" {...props}>
7
+ <Circle cx={12} cy={12} r={9.25} stroke="currentColor" strokeWidth={1.5} />
8
+ <Circle cx={12} cy={12} r={6} fill="currentColor" />
9
+ </Svg>
10
+ );
11
+
12
+ export default IconRadioActive;
@@ -0,0 +1,12 @@
1
+ import * as React from "react";
2
+ import Svg, { Circle } from "react-native-svg";
3
+ import { SvgProps } from "react-native-svg";
4
+
5
+ const IconRadioDisable = (props: SvgProps) => (
6
+ <Svg width={24} height={24} viewBox="0 0 24 24" fill="none" {...props}>
7
+ <Circle cx={12} cy={12} r={9.25} stroke="#E5E7EB" strokeWidth={1.5} />
8
+ <Circle cx={12} cy={12} r={6} fill="#F3F4F6" />
9
+ </Svg>
10
+ );
11
+
12
+ export default IconRadioDisable;
package/src/index.ts ADDED
@@ -0,0 +1,51 @@
1
+ export { ThemeColors } from "./styles/themes/tokens";
2
+ export { CONSTANTS } from "./styles/themes/tokens";
3
+ export {
4
+ useTheme,
5
+ ThemeProvider,
6
+ DefaultTheme,
7
+ adaptNavigationTheme,
8
+ } from "./core/theming";
9
+ export * from "./styles/themes";
10
+
11
+ export { default as shadow } from "./styles/shadow";
12
+ export { default as overlay } from "./styles/overlay";
13
+ export { default as configureFonts } from "./styles/fonts";
14
+ export { default as ActivityIndicator } from "./components/ActivityIndicator";
15
+ export { default as ProgressBar } from "./components/ProgressBar";
16
+ export { default as Switch } from "./components/Switch/Switch";
17
+ export { default as TextInput } from "./components/TextInput/TextInput";
18
+ export { default as Button } from "./components/Button";
19
+ export { default as ButtonIcon } from "./components/ButtonIcon";
20
+ export { default as FloatingButton } from "./components/FloatingButton";
21
+ export { default as Text } from "./components/Text";
22
+ export { default as Toast } from "./components/Toast";
23
+ export { default as View } from "./components/View";
24
+ export { default as Spacer } from "./components/Spacer";
25
+ export { default as Image } from "./components/Image";
26
+ export { default as Badge } from "./components/Badge";
27
+ export { default as CountingDot } from "./components/CountingDot";
28
+ export { default as ChipBar } from "./components/ChipBar";
29
+ export { default as Checkbox } from "./components/Checkbox";
30
+ export { default as RadioButton } from "./components/RadioButton";
31
+ export { default as Avatar } from "./components/Avatar";
32
+ export { default as SelectionField } from "./components/SelectionField";
33
+
34
+ // Types
35
+ export type { Props as ActivityIndicatorProps } from "./components/ActivityIndicator";
36
+ export type { Props as SwitchProps } from "./components/Switch/Switch";
37
+ export type { Props as TextInputProps } from "./components/TextInput/TextInput";
38
+ export type { Props as TextInputAffixProps } from "./components/TextInput/Adornment/TextInputAffix";
39
+
40
+ export type {
41
+ AppTheme,
42
+ ThemeBase,
43
+ MD3Elevation,
44
+ MD3TypescaleKey,
45
+ } from "./types";
46
+
47
+ // Toast Manager
48
+ export * from "./utils/toast-manager";
49
+
50
+ // Toast Provider
51
+ export { default as ToastProvider } from "./components/Toast/ToastProvider";