@oxyhq/bloom 0.1.32 → 0.1.33

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 (275) hide show
  1. package/lib/commonjs/admonition/index.js +7 -0
  2. package/lib/commonjs/admonition/index.js.map +1 -1
  3. package/lib/commonjs/avatar/Avatar.js +2 -18
  4. package/lib/commonjs/avatar/Avatar.js.map +1 -1
  5. package/lib/commonjs/bottom-sheet/index.js +16 -6
  6. package/lib/commonjs/bottom-sheet/index.js.map +1 -1
  7. package/lib/commonjs/button/Button.js +6 -18
  8. package/lib/commonjs/button/Button.js.map +1 -1
  9. package/lib/commonjs/chip/Chip.js +6 -16
  10. package/lib/commonjs/chip/Chip.js.map +1 -1
  11. package/lib/commonjs/collapsible/Collapsible.js +28 -20
  12. package/lib/commonjs/collapsible/Collapsible.js.map +1 -1
  13. package/lib/commonjs/fill/index.js +7 -5
  14. package/lib/commonjs/fill/index.js.map +1 -1
  15. package/lib/commonjs/grid/index.js +9 -6
  16. package/lib/commonjs/grid/index.js.map +1 -1
  17. package/lib/commonjs/grouped-buttons/GroupedButtons.js +76 -48
  18. package/lib/commonjs/grouped-buttons/GroupedButtons.js.map +1 -1
  19. package/lib/commonjs/hooks/index.js +13 -0
  20. package/lib/commonjs/hooks/index.js.map +1 -1
  21. package/lib/commonjs/hooks/useInteractionState.js +42 -0
  22. package/lib/commonjs/hooks/useInteractionState.js.map +1 -1
  23. package/lib/commonjs/hooks/usePressAnimation.js +44 -0
  24. package/lib/commonjs/hooks/usePressAnimation.js.map +1 -0
  25. package/lib/commonjs/icon-circle/index.js +7 -5
  26. package/lib/commonjs/icon-circle/index.js.map +1 -1
  27. package/lib/commonjs/icons/{EnveopeOpen.js → EnvelopeOpen.js} +1 -1
  28. package/lib/commonjs/icons/EnvelopeOpen.js.map +1 -0
  29. package/lib/commonjs/icons/TEMPLATE.js +3 -2
  30. package/lib/commonjs/icons/TEMPLATE.js.map +1 -1
  31. package/lib/commonjs/icons/VerifiedCheck.js +3 -2
  32. package/lib/commonjs/icons/VerifiedCheck.js.map +1 -1
  33. package/lib/commonjs/icons/VerifierCheck.js +3 -2
  34. package/lib/commonjs/icons/VerifierCheck.js.map +1 -1
  35. package/lib/commonjs/icons/index.js +4 -4
  36. package/lib/commonjs/icons/index.js.map +1 -1
  37. package/lib/commonjs/loading/Loading.js +2 -17
  38. package/lib/commonjs/loading/Loading.js.map +1 -1
  39. package/lib/commonjs/loading/SpinnerIcon.js +3 -34
  40. package/lib/commonjs/loading/SpinnerIcon.js.map +1 -1
  41. package/lib/commonjs/prompt-input/Actions.js +1 -0
  42. package/lib/commonjs/prompt-input/Actions.js.map +1 -1
  43. package/lib/commonjs/prompt-input/Attachments.js +1 -0
  44. package/lib/commonjs/prompt-input/Attachments.js.map +1 -1
  45. package/lib/commonjs/prompt-input/PromptInput.js +1 -0
  46. package/lib/commonjs/prompt-input/PromptInput.js.map +1 -1
  47. package/lib/commonjs/prompt-input/SubmitButton.js +1 -0
  48. package/lib/commonjs/prompt-input/SubmitButton.js.map +1 -1
  49. package/lib/commonjs/prompt-input/Textarea.js +1 -0
  50. package/lib/commonjs/prompt-input/Textarea.js.map +1 -1
  51. package/lib/commonjs/prompt-input/Textarea.web.js +1 -0
  52. package/lib/commonjs/prompt-input/Textarea.web.js.map +1 -1
  53. package/lib/commonjs/search-input/index.js +1 -0
  54. package/lib/commonjs/search-input/index.js.map +1 -1
  55. package/lib/commonjs/settings-list/SettingsList.js +10 -11
  56. package/lib/commonjs/settings-list/SettingsList.js.map +1 -1
  57. package/lib/commonjs/skeleton/index.js +5 -0
  58. package/lib/commonjs/skeleton/index.js.map +1 -1
  59. package/lib/commonjs/switch/Switch.js +43 -28
  60. package/lib/commonjs/switch/Switch.js.map +1 -1
  61. package/lib/commonjs/tabs/Tabs.js +6 -15
  62. package/lib/commonjs/tabs/Tabs.js.map +1 -1
  63. package/lib/commonjs/typography/index.js +14 -5
  64. package/lib/commonjs/typography/index.js.map +1 -1
  65. package/lib/commonjs/utils/lazy-require.js +37 -0
  66. package/lib/commonjs/utils/lazy-require.js.map +1 -0
  67. package/lib/module/admonition/index.js +7 -0
  68. package/lib/module/admonition/index.js.map +1 -1
  69. package/lib/module/avatar/Avatar.js +2 -18
  70. package/lib/module/avatar/Avatar.js.map +1 -1
  71. package/lib/module/bottom-sheet/index.js +16 -6
  72. package/lib/module/bottom-sheet/index.js.map +1 -1
  73. package/lib/module/button/Button.js +7 -19
  74. package/lib/module/button/Button.js.map +1 -1
  75. package/lib/module/chip/Chip.js +7 -17
  76. package/lib/module/chip/Chip.js.map +1 -1
  77. package/lib/module/collapsible/Collapsible.js +30 -22
  78. package/lib/module/collapsible/Collapsible.js.map +1 -1
  79. package/lib/module/fill/index.js +5 -3
  80. package/lib/module/fill/index.js.map +1 -1
  81. package/lib/module/grid/index.js +9 -5
  82. package/lib/module/grid/index.js.map +1 -1
  83. package/lib/module/grouped-buttons/GroupedButtons.js +77 -48
  84. package/lib/module/grouped-buttons/GroupedButtons.js.map +1 -1
  85. package/lib/module/hooks/index.js +2 -1
  86. package/lib/module/hooks/index.js.map +1 -1
  87. package/lib/module/hooks/useInteractionState.js +41 -0
  88. package/lib/module/hooks/useInteractionState.js.map +1 -1
  89. package/lib/module/hooks/usePressAnimation.js +41 -0
  90. package/lib/module/hooks/usePressAnimation.js.map +1 -0
  91. package/lib/module/icon-circle/index.js +5 -3
  92. package/lib/module/icon-circle/index.js.map +1 -1
  93. package/lib/module/icons/{EnveopeOpen.js → EnvelopeOpen.js} +1 -1
  94. package/lib/module/icons/EnvelopeOpen.js.map +1 -0
  95. package/lib/module/icons/TEMPLATE.js +3 -2
  96. package/lib/module/icons/TEMPLATE.js.map +1 -1
  97. package/lib/module/icons/VerifiedCheck.js +3 -2
  98. package/lib/module/icons/VerifiedCheck.js.map +1 -1
  99. package/lib/module/icons/VerifierCheck.js +3 -2
  100. package/lib/module/icons/VerifierCheck.js.map +1 -1
  101. package/lib/module/icons/index.js +1 -1
  102. package/lib/module/icons/index.js.map +1 -1
  103. package/lib/module/loading/Loading.js +2 -17
  104. package/lib/module/loading/Loading.js.map +1 -1
  105. package/lib/module/loading/SpinnerIcon.js +3 -34
  106. package/lib/module/loading/SpinnerIcon.js.map +1 -1
  107. package/lib/module/prompt-input/Actions.js +1 -0
  108. package/lib/module/prompt-input/Actions.js.map +1 -1
  109. package/lib/module/prompt-input/Attachments.js +1 -0
  110. package/lib/module/prompt-input/Attachments.js.map +1 -1
  111. package/lib/module/prompt-input/PromptInput.js +1 -0
  112. package/lib/module/prompt-input/PromptInput.js.map +1 -1
  113. package/lib/module/prompt-input/SubmitButton.js +1 -0
  114. package/lib/module/prompt-input/SubmitButton.js.map +1 -1
  115. package/lib/module/prompt-input/Textarea.js +1 -0
  116. package/lib/module/prompt-input/Textarea.js.map +1 -1
  117. package/lib/module/prompt-input/Textarea.web.js +1 -0
  118. package/lib/module/prompt-input/Textarea.web.js.map +1 -1
  119. package/lib/module/search-input/index.js +1 -0
  120. package/lib/module/search-input/index.js.map +1 -1
  121. package/lib/module/settings-list/SettingsList.js +10 -11
  122. package/lib/module/settings-list/SettingsList.js.map +1 -1
  123. package/lib/module/skeleton/index.js +5 -0
  124. package/lib/module/skeleton/index.js.map +1 -1
  125. package/lib/module/switch/Switch.js +45 -30
  126. package/lib/module/switch/Switch.js.map +1 -1
  127. package/lib/module/tabs/Tabs.js +8 -17
  128. package/lib/module/tabs/Tabs.js.map +1 -1
  129. package/lib/module/typography/index.js +12 -3
  130. package/lib/module/typography/index.js.map +1 -1
  131. package/lib/module/utils/lazy-require.js +33 -0
  132. package/lib/module/utils/lazy-require.js.map +1 -0
  133. package/lib/typescript/commonjs/admonition/index.d.ts +21 -0
  134. package/lib/typescript/commonjs/admonition/index.d.ts.map +1 -1
  135. package/lib/typescript/commonjs/avatar/Avatar.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/bottom-sheet/index.d.ts.map +1 -1
  137. package/lib/typescript/commonjs/button/Button.d.ts.map +1 -1
  138. package/lib/typescript/commonjs/chip/Chip.d.ts.map +1 -1
  139. package/lib/typescript/commonjs/collapsible/Collapsible.d.ts.map +1 -1
  140. package/lib/typescript/commonjs/fill/index.d.ts +2 -2
  141. package/lib/typescript/commonjs/fill/index.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/grid/index.d.ts +4 -4
  143. package/lib/typescript/commonjs/grid/index.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/grouped-buttons/GroupedButtons.d.ts +9 -5
  145. package/lib/typescript/commonjs/grouped-buttons/GroupedButtons.d.ts.map +1 -1
  146. package/lib/typescript/commonjs/hooks/index.d.ts +2 -1
  147. package/lib/typescript/commonjs/hooks/index.d.ts.map +1 -1
  148. package/lib/typescript/commonjs/hooks/useInteractionState.d.ts +23 -0
  149. package/lib/typescript/commonjs/hooks/useInteractionState.d.ts.map +1 -1
  150. package/lib/typescript/commonjs/hooks/usePressAnimation.d.ts +16 -0
  151. package/lib/typescript/commonjs/hooks/usePressAnimation.d.ts.map +1 -0
  152. package/lib/typescript/commonjs/icon-circle/index.d.ts +4 -4
  153. package/lib/typescript/commonjs/icon-circle/index.d.ts.map +1 -1
  154. package/lib/typescript/commonjs/icons/{EnveopeOpen.d.ts → EnvelopeOpen.d.ts} +1 -1
  155. package/lib/typescript/commonjs/icons/EnvelopeOpen.d.ts.map +1 -0
  156. package/lib/typescript/commonjs/icons/TEMPLATE.d.ts +2 -1
  157. package/lib/typescript/commonjs/icons/TEMPLATE.d.ts.map +1 -1
  158. package/lib/typescript/commonjs/icons/VerifiedCheck.d.ts.map +1 -1
  159. package/lib/typescript/commonjs/icons/VerifierCheck.d.ts.map +1 -1
  160. package/lib/typescript/commonjs/icons/index.d.ts +1 -1
  161. package/lib/typescript/commonjs/icons/index.d.ts.map +1 -1
  162. package/lib/typescript/commonjs/loading/Loading.d.ts.map +1 -1
  163. package/lib/typescript/commonjs/loading/SpinnerIcon.d.ts.map +1 -1
  164. package/lib/typescript/commonjs/prompt-input/Actions.d.ts +3 -0
  165. package/lib/typescript/commonjs/prompt-input/Actions.d.ts.map +1 -1
  166. package/lib/typescript/commonjs/prompt-input/Attachments.d.ts +3 -0
  167. package/lib/typescript/commonjs/prompt-input/Attachments.d.ts.map +1 -1
  168. package/lib/typescript/commonjs/prompt-input/PromptInput.d.ts +3 -0
  169. package/lib/typescript/commonjs/prompt-input/PromptInput.d.ts.map +1 -1
  170. package/lib/typescript/commonjs/prompt-input/SubmitButton.d.ts +3 -0
  171. package/lib/typescript/commonjs/prompt-input/SubmitButton.d.ts.map +1 -1
  172. package/lib/typescript/commonjs/prompt-input/Textarea.d.ts +3 -0
  173. package/lib/typescript/commonjs/prompt-input/Textarea.d.ts.map +1 -1
  174. package/lib/typescript/commonjs/prompt-input/Textarea.web.d.ts +3 -0
  175. package/lib/typescript/commonjs/prompt-input/Textarea.web.d.ts.map +1 -1
  176. package/lib/typescript/commonjs/settings-list/SettingsList.d.ts.map +1 -1
  177. package/lib/typescript/commonjs/skeleton/index.d.ts +15 -0
  178. package/lib/typescript/commonjs/skeleton/index.d.ts.map +1 -1
  179. package/lib/typescript/commonjs/switch/Switch.d.ts.map +1 -1
  180. package/lib/typescript/commonjs/tabs/Tabs.d.ts.map +1 -1
  181. package/lib/typescript/commonjs/typography/index.d.ts +11 -10
  182. package/lib/typescript/commonjs/typography/index.d.ts.map +1 -1
  183. package/lib/typescript/commonjs/utils/lazy-require.d.ts +15 -0
  184. package/lib/typescript/commonjs/utils/lazy-require.d.ts.map +1 -0
  185. package/lib/typescript/module/admonition/index.d.ts +21 -0
  186. package/lib/typescript/module/admonition/index.d.ts.map +1 -1
  187. package/lib/typescript/module/avatar/Avatar.d.ts.map +1 -1
  188. package/lib/typescript/module/bottom-sheet/index.d.ts.map +1 -1
  189. package/lib/typescript/module/button/Button.d.ts.map +1 -1
  190. package/lib/typescript/module/chip/Chip.d.ts.map +1 -1
  191. package/lib/typescript/module/collapsible/Collapsible.d.ts.map +1 -1
  192. package/lib/typescript/module/fill/index.d.ts +2 -2
  193. package/lib/typescript/module/fill/index.d.ts.map +1 -1
  194. package/lib/typescript/module/grid/index.d.ts +4 -4
  195. package/lib/typescript/module/grid/index.d.ts.map +1 -1
  196. package/lib/typescript/module/grouped-buttons/GroupedButtons.d.ts +9 -5
  197. package/lib/typescript/module/grouped-buttons/GroupedButtons.d.ts.map +1 -1
  198. package/lib/typescript/module/hooks/index.d.ts +2 -1
  199. package/lib/typescript/module/hooks/index.d.ts.map +1 -1
  200. package/lib/typescript/module/hooks/useInteractionState.d.ts +23 -0
  201. package/lib/typescript/module/hooks/useInteractionState.d.ts.map +1 -1
  202. package/lib/typescript/module/hooks/usePressAnimation.d.ts +16 -0
  203. package/lib/typescript/module/hooks/usePressAnimation.d.ts.map +1 -0
  204. package/lib/typescript/module/icon-circle/index.d.ts +4 -4
  205. package/lib/typescript/module/icon-circle/index.d.ts.map +1 -1
  206. package/lib/typescript/module/icons/{EnveopeOpen.d.ts → EnvelopeOpen.d.ts} +1 -1
  207. package/lib/typescript/module/icons/EnvelopeOpen.d.ts.map +1 -0
  208. package/lib/typescript/module/icons/TEMPLATE.d.ts +2 -1
  209. package/lib/typescript/module/icons/TEMPLATE.d.ts.map +1 -1
  210. package/lib/typescript/module/icons/VerifiedCheck.d.ts.map +1 -1
  211. package/lib/typescript/module/icons/VerifierCheck.d.ts.map +1 -1
  212. package/lib/typescript/module/icons/index.d.ts +1 -1
  213. package/lib/typescript/module/icons/index.d.ts.map +1 -1
  214. package/lib/typescript/module/loading/Loading.d.ts.map +1 -1
  215. package/lib/typescript/module/loading/SpinnerIcon.d.ts.map +1 -1
  216. package/lib/typescript/module/prompt-input/Actions.d.ts +3 -0
  217. package/lib/typescript/module/prompt-input/Actions.d.ts.map +1 -1
  218. package/lib/typescript/module/prompt-input/Attachments.d.ts +3 -0
  219. package/lib/typescript/module/prompt-input/Attachments.d.ts.map +1 -1
  220. package/lib/typescript/module/prompt-input/PromptInput.d.ts +3 -0
  221. package/lib/typescript/module/prompt-input/PromptInput.d.ts.map +1 -1
  222. package/lib/typescript/module/prompt-input/SubmitButton.d.ts +3 -0
  223. package/lib/typescript/module/prompt-input/SubmitButton.d.ts.map +1 -1
  224. package/lib/typescript/module/prompt-input/Textarea.d.ts +3 -0
  225. package/lib/typescript/module/prompt-input/Textarea.d.ts.map +1 -1
  226. package/lib/typescript/module/prompt-input/Textarea.web.d.ts +3 -0
  227. package/lib/typescript/module/prompt-input/Textarea.web.d.ts.map +1 -1
  228. package/lib/typescript/module/settings-list/SettingsList.d.ts.map +1 -1
  229. package/lib/typescript/module/skeleton/index.d.ts +15 -0
  230. package/lib/typescript/module/skeleton/index.d.ts.map +1 -1
  231. package/lib/typescript/module/switch/Switch.d.ts.map +1 -1
  232. package/lib/typescript/module/tabs/Tabs.d.ts.map +1 -1
  233. package/lib/typescript/module/typography/index.d.ts +11 -10
  234. package/lib/typescript/module/typography/index.d.ts.map +1 -1
  235. package/lib/typescript/module/utils/lazy-require.d.ts +15 -0
  236. package/lib/typescript/module/utils/lazy-require.d.ts.map +1 -0
  237. package/package.json +1 -1
  238. package/src/__tests__/BloomThemeProvider.test.tsx +3 -3
  239. package/src/admonition/index.tsx +7 -0
  240. package/src/avatar/Avatar.tsx +2 -19
  241. package/src/bottom-sheet/index.tsx +18 -6
  242. package/src/button/Button.tsx +6 -22
  243. package/src/chip/Chip.tsx +3 -19
  244. package/src/collapsible/Collapsible.tsx +34 -25
  245. package/src/fill/index.tsx +6 -3
  246. package/src/grid/index.tsx +11 -5
  247. package/src/grouped-buttons/GroupedButtons.tsx +79 -60
  248. package/src/hooks/index.ts +2 -1
  249. package/src/hooks/useInteractionState.ts +21 -0
  250. package/src/hooks/usePressAnimation.ts +37 -0
  251. package/src/icon-circle/index.tsx +6 -3
  252. package/src/icons/TEMPLATE.tsx +2 -2
  253. package/src/icons/VerifiedCheck.tsx +3 -2
  254. package/src/icons/VerifierCheck.tsx +3 -2
  255. package/src/icons/index.ts +1 -1
  256. package/src/loading/Loading.tsx +2 -18
  257. package/src/loading/SpinnerIcon.tsx +4 -36
  258. package/src/prompt-input/Actions.tsx +1 -0
  259. package/src/prompt-input/Attachments.tsx +1 -0
  260. package/src/prompt-input/PromptInput.tsx +1 -0
  261. package/src/prompt-input/SubmitButton.tsx +1 -0
  262. package/src/prompt-input/Textarea.tsx +1 -0
  263. package/src/prompt-input/Textarea.web.tsx +1 -0
  264. package/src/search-input/index.tsx +1 -0
  265. package/src/settings-list/SettingsList.tsx +12 -8
  266. package/src/skeleton/index.tsx +5 -0
  267. package/src/switch/Switch.tsx +45 -23
  268. package/src/tabs/Tabs.tsx +3 -21
  269. package/src/typography/index.tsx +14 -4
  270. package/src/utils/lazy-require.ts +31 -0
  271. package/lib/commonjs/icons/EnveopeOpen.js.map +0 -1
  272. package/lib/module/icons/EnveopeOpen.js.map +0 -1
  273. package/lib/typescript/commonjs/icons/EnveopeOpen.d.ts.map +0 -1
  274. package/lib/typescript/module/icons/EnveopeOpen.d.ts.map +0 -1
  275. /package/src/icons/{EnveopeOpen.tsx → EnvelopeOpen.tsx} +0 -0
@@ -1,5 +1,5 @@
1
- import React, { memo, useEffect, useRef } from 'react';
2
- import { Pressable, Animated } from 'react-native';
1
+ import React, { memo, useCallback, useRef } from 'react';
2
+ import { Pressable, Animated, StyleSheet } from 'react-native';
3
3
 
4
4
  import { useTheme } from '../theme/use-theme';
5
5
  import { animation } from '../styles/tokens';
@@ -16,30 +16,39 @@ const SwitchComponent = React.forwardRef<React.ElementRef<typeof Pressable>, Swi
16
16
  const anim = useRef(new Animated.Value(value ? 1 : 0)).current;
17
17
  const pressAnim = useRef(new Animated.Value(0)).current;
18
18
 
19
- useEffect(() => {
19
+ // Track last value to detect external changes and animate accordingly.
20
+ // This avoids useEffect while still handling controlled value changes.
21
+ const prevValueRef = useRef(value);
22
+ if (prevValueRef.current !== value) {
23
+ prevValueRef.current = value;
20
24
  Animated.spring(anim, {
21
25
  toValue: value ? 1 : 0,
22
26
  useNativeDriver: false,
23
27
  ...animation.spring.gentle,
24
28
  }).start();
25
- }, [value, anim]);
29
+ }
26
30
 
27
- const onPressIn = () => {
31
+ const handlePress = useCallback(() => {
32
+ if (disabled) return;
33
+ onValueChange(!value);
34
+ }, [disabled, value, onValueChange]);
35
+
36
+ const onPressIn = useCallback(() => {
28
37
  if (disabled) return;
29
38
  Animated.spring(pressAnim, {
30
39
  toValue: 1,
31
40
  useNativeDriver: false,
32
41
  ...animation.spring.snappy,
33
42
  }).start();
34
- };
43
+ }, [disabled, pressAnim]);
35
44
 
36
- const onPressOut = () => {
45
+ const onPressOut = useCallback(() => {
37
46
  Animated.spring(pressAnim, {
38
47
  toValue: 0,
39
48
  useNativeDriver: false,
40
49
  ...animation.spring.gentle,
41
50
  }).start();
42
- };
51
+ }, [pressAnim]);
43
52
 
44
53
  const track = TRACK[size];
45
54
  const thumb = THUMB[size];
@@ -73,11 +82,11 @@ const SwitchComponent = React.forwardRef<React.ElementRef<typeof Pressable>, Swi
73
82
  role="switch"
74
83
  aria-checked={value}
75
84
  accessibilityState={{ checked: value, disabled }}
76
- onPress={() => !disabled && onValueChange(!value)}
85
+ onPress={handlePress}
77
86
  onPressIn={onPressIn}
78
87
  onPressOut={onPressOut}
79
- style={[{ opacity: disabled ? 0.4 : 1 }, style]}
80
- hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
88
+ style={[disabled && styles.disabled, style]}
89
+ hitSlop={HIT_SLOP}
81
90
  testID={testID}
82
91
  >
83
92
  <Animated.View
@@ -91,18 +100,15 @@ const SwitchComponent = React.forwardRef<React.ElementRef<typeof Pressable>, Swi
91
100
  }}
92
101
  >
93
102
  <Animated.View
94
- style={{
95
- width: thumb,
96
- height: thumbHeight,
97
- borderRadius: thumbRadius,
98
- backgroundColor: '#fff',
99
- transform: [{ translateX: thumbX }],
100
- shadowColor: '#000',
101
- shadowOffset: { width: 0, height: 2 },
102
- shadowOpacity: 0.15,
103
- shadowRadius: 3,
104
- elevation: 3,
105
- }}
103
+ style={[
104
+ styles.thumb,
105
+ {
106
+ width: thumb,
107
+ height: thumbHeight,
108
+ borderRadius: thumbRadius,
109
+ transform: [{ translateX: thumbX }],
110
+ },
111
+ ]}
106
112
  />
107
113
  </Animated.View>
108
114
  </Pressable>
@@ -113,3 +119,19 @@ const SwitchComponent = React.forwardRef<React.ElementRef<typeof Pressable>, Swi
113
119
  SwitchComponent.displayName = 'Switch';
114
120
 
115
121
  export const Switch = memo(SwitchComponent);
122
+
123
+ const HIT_SLOP = { top: 8, bottom: 8, left: 8, right: 8 } as const;
124
+
125
+ const styles = StyleSheet.create({
126
+ disabled: {
127
+ opacity: 0.4,
128
+ },
129
+ thumb: {
130
+ backgroundColor: '#fff',
131
+ shadowColor: '#000',
132
+ shadowOffset: { width: 0, height: 2 },
133
+ shadowOpacity: 0.15,
134
+ shadowRadius: 3,
135
+ elevation: 3,
136
+ },
137
+ });
package/src/tabs/Tabs.tsx CHANGED
@@ -3,9 +3,7 @@ import React, {
3
3
  memo,
4
4
  useCallback,
5
5
  useContext,
6
- useEffect,
7
6
  useMemo,
8
- useRef,
9
7
  } from 'react';
10
8
  import {
11
9
  View,
@@ -15,11 +13,11 @@ import {
15
13
  ScrollView,
16
14
  type ViewStyle,
17
15
  type TextStyle,
18
- type LayoutChangeEvent,
19
16
  } from 'react-native';
20
17
 
21
18
  import { useTheme } from '../theme/use-theme';
22
- import { animation, borderRadius, space } from '../styles/tokens';
19
+ import { usePressAnimation } from '../hooks/usePressAnimation';
20
+ import { borderRadius, space } from '../styles/tokens';
23
21
  import type { TabsProps, TabProps, TabPanelProps, TabsVariant } from './types';
24
22
 
25
23
  interface TabsContextValue {
@@ -101,7 +99,7 @@ const TabComponent: React.FC<TabProps> = ({
101
99
  const theme = useTheme();
102
100
  const { value: selectedValue, onValueChange, variant } = useContext(TabsContext);
103
101
  const isSelected = value === selectedValue;
104
- const scaleAnim = useRef(new Animated.Value(1)).current;
102
+ const { scaleAnim, onPressIn, onPressOut } = usePressAnimation(0.97);
105
103
 
106
104
  const handlePress = useCallback(() => {
107
105
  if (!disabled) {
@@ -109,22 +107,6 @@ const TabComponent: React.FC<TabProps> = ({
109
107
  }
110
108
  }, [value, disabled, onValueChange]);
111
109
 
112
- const onPressIn = useCallback(() => {
113
- Animated.spring(scaleAnim, {
114
- toValue: 0.97,
115
- useNativeDriver: true,
116
- ...animation.spring.snappy,
117
- }).start();
118
- }, [scaleAnim]);
119
-
120
- const onPressOut = useCallback(() => {
121
- Animated.spring(scaleAnim, {
122
- toValue: 1,
123
- useNativeDriver: true,
124
- ...animation.spring.gentle,
125
- }).start();
126
- }, [scaleAnim]);
127
-
128
110
  const tabStyle = useMemo((): ViewStyle => {
129
111
  const base: ViewStyle = {
130
112
  flexDirection: 'row',
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { memo } from 'react';
2
2
  import {
3
3
  Text as RNText,
4
4
  type TextProps as RNTextProps,
@@ -14,7 +14,7 @@ export type TextProps = RNTextProps;
14
14
  /**
15
15
  * Base text component with theme-aware default color.
16
16
  */
17
- export function Text({ children, style, ...rest }: TextProps) {
17
+ const TextComponent = function Text({ children, style, ...rest }: TextProps) {
18
18
  const { colors } = useTheme();
19
19
 
20
20
  return (
@@ -24,11 +24,14 @@ export function Text({ children, style, ...rest }: TextProps) {
24
24
  {children}
25
25
  </RNText>
26
26
  );
27
- }
27
+ };
28
+
29
+ export const Text = memo(TextComponent);
30
+ Text.displayName = 'Text';
28
31
 
29
32
  export { Text as Span };
30
33
 
31
- function createHeadingElement({ level }: { level: number }) {
34
+ function createHeadingElement({ level }: { level: number }): React.FC<TextProps> {
32
35
  return function HeadingElement({ style, ...rest }: TextProps) {
33
36
  const extraProps: Record<string, unknown> =
34
37
  Platform.OS === 'web'
@@ -39,11 +42,17 @@ function createHeadingElement({ level }: { level: number }) {
39
42
  }
40
43
 
41
44
  export const H1 = createHeadingElement({ level: 1 });
45
+ H1.displayName = 'H1';
42
46
  export const H2 = createHeadingElement({ level: 2 });
47
+ H2.displayName = 'H2';
43
48
  export const H3 = createHeadingElement({ level: 3 });
49
+ H3.displayName = 'H3';
44
50
  export const H4 = createHeadingElement({ level: 4 });
51
+ H4.displayName = 'H4';
45
52
  export const H5 = createHeadingElement({ level: 5 });
53
+ H5.displayName = 'H5';
46
54
  export const H6 = createHeadingElement({ level: 6 });
55
+ H6.displayName = 'H6';
47
56
 
48
57
  export function P({ style, ...rest }: TextProps) {
49
58
  const extraProps: Record<string, unknown> =
@@ -56,3 +65,4 @@ export function P({ style, ...rest }: TextProps) {
56
65
  />
57
66
  );
58
67
  }
68
+ P.displayName = 'P';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Creates a lazy-loaded module getter that caches the result.
3
+ *
4
+ * Safely handles environments where `require` is not defined (e.g. Vite/browser ESM)
5
+ * and returns `null` when the module is not installed. The result is cached after the
6
+ * first call so subsequent calls are zero-cost.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const getSvg = lazyRequire<typeof import('react-native-svg')>('react-native-svg');
11
+ * const svg = getSvg(); // SvgModuleType | null
12
+ * ```
13
+ */
14
+ export function lazyRequire<T>(moduleName: string): () => T | null {
15
+ let module: T | null = null;
16
+ let resolved = false;
17
+
18
+ return (): T | null => {
19
+ if (!resolved) {
20
+ resolved = true;
21
+ try {
22
+ if (typeof require !== 'undefined') {
23
+ module = require(moduleName);
24
+ }
25
+ } catch {
26
+ module = null;
27
+ }
28
+ }
29
+ return module;
30
+ };
31
+ }
@@ -1 +0,0 @@
1
- {"version":3,"names":["_TEMPLATE","require","Envelope_Open_Stroke2_Corner0_Rounded","exports","createSinglePathSVG","path"],"sourceRoot":"../../../src","sources":["icons/EnveopeOpen.tsx"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,qCAAqC,GAAAC,OAAA,CAAAD,qCAAA,GAAG,IAAAE,6BAAmB,EAAC;EACvEC,IAAI,EAAE;AACR,CAAC,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["createSinglePathSVG","Envelope_Open_Stroke2_Corner0_Rounded","path"],"sourceRoot":"../../../src","sources":["icons/EnveopeOpen.tsx"],"mappings":";;AAAA,SAAQA,mBAAmB,QAAO,eAAY;AAE9C,OAAO,MAAMC,qCAAqC,GAAGD,mBAAmB,CAAC;EACvEE,IAAI,EAAE;AACR,CAAC,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"EnveopeOpen.d.ts","sourceRoot":"","sources":["../../../../src/icons/EnveopeOpen.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,qCAAqC;;;;;oIAEhD,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"EnveopeOpen.d.ts","sourceRoot":"","sources":["../../../../src/icons/EnveopeOpen.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,qCAAqC;;;;;oIAEhD,CAAA"}
File without changes