@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.
- package/lib/commonjs/admonition/index.js +7 -0
- package/lib/commonjs/admonition/index.js.map +1 -1
- package/lib/commonjs/avatar/Avatar.js +2 -18
- package/lib/commonjs/avatar/Avatar.js.map +1 -1
- package/lib/commonjs/bottom-sheet/index.js +16 -6
- package/lib/commonjs/bottom-sheet/index.js.map +1 -1
- package/lib/commonjs/button/Button.js +6 -18
- package/lib/commonjs/button/Button.js.map +1 -1
- package/lib/commonjs/chip/Chip.js +6 -16
- package/lib/commonjs/chip/Chip.js.map +1 -1
- package/lib/commonjs/collapsible/Collapsible.js +28 -20
- package/lib/commonjs/collapsible/Collapsible.js.map +1 -1
- package/lib/commonjs/fill/index.js +7 -5
- package/lib/commonjs/fill/index.js.map +1 -1
- package/lib/commonjs/grid/index.js +9 -6
- package/lib/commonjs/grid/index.js.map +1 -1
- package/lib/commonjs/grouped-buttons/GroupedButtons.js +76 -48
- package/lib/commonjs/grouped-buttons/GroupedButtons.js.map +1 -1
- package/lib/commonjs/hooks/index.js +13 -0
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useInteractionState.js +42 -0
- package/lib/commonjs/hooks/useInteractionState.js.map +1 -1
- package/lib/commonjs/hooks/usePressAnimation.js +44 -0
- package/lib/commonjs/hooks/usePressAnimation.js.map +1 -0
- package/lib/commonjs/icon-circle/index.js +7 -5
- package/lib/commonjs/icon-circle/index.js.map +1 -1
- package/lib/commonjs/icons/{EnveopeOpen.js → EnvelopeOpen.js} +1 -1
- package/lib/commonjs/icons/EnvelopeOpen.js.map +1 -0
- package/lib/commonjs/icons/TEMPLATE.js +3 -2
- package/lib/commonjs/icons/TEMPLATE.js.map +1 -1
- package/lib/commonjs/icons/VerifiedCheck.js +3 -2
- package/lib/commonjs/icons/VerifiedCheck.js.map +1 -1
- package/lib/commonjs/icons/VerifierCheck.js +3 -2
- package/lib/commonjs/icons/VerifierCheck.js.map +1 -1
- package/lib/commonjs/icons/index.js +4 -4
- package/lib/commonjs/icons/index.js.map +1 -1
- package/lib/commonjs/loading/Loading.js +2 -17
- package/lib/commonjs/loading/Loading.js.map +1 -1
- package/lib/commonjs/loading/SpinnerIcon.js +3 -34
- package/lib/commonjs/loading/SpinnerIcon.js.map +1 -1
- package/lib/commonjs/prompt-input/Actions.js +1 -0
- package/lib/commonjs/prompt-input/Actions.js.map +1 -1
- package/lib/commonjs/prompt-input/Attachments.js +1 -0
- package/lib/commonjs/prompt-input/Attachments.js.map +1 -1
- package/lib/commonjs/prompt-input/PromptInput.js +1 -0
- package/lib/commonjs/prompt-input/PromptInput.js.map +1 -1
- package/lib/commonjs/prompt-input/SubmitButton.js +1 -0
- package/lib/commonjs/prompt-input/SubmitButton.js.map +1 -1
- package/lib/commonjs/prompt-input/Textarea.js +1 -0
- package/lib/commonjs/prompt-input/Textarea.js.map +1 -1
- package/lib/commonjs/prompt-input/Textarea.web.js +1 -0
- package/lib/commonjs/prompt-input/Textarea.web.js.map +1 -1
- package/lib/commonjs/search-input/index.js +1 -0
- package/lib/commonjs/search-input/index.js.map +1 -1
- package/lib/commonjs/settings-list/SettingsList.js +10 -11
- package/lib/commonjs/settings-list/SettingsList.js.map +1 -1
- package/lib/commonjs/skeleton/index.js +5 -0
- package/lib/commonjs/skeleton/index.js.map +1 -1
- package/lib/commonjs/switch/Switch.js +43 -28
- package/lib/commonjs/switch/Switch.js.map +1 -1
- package/lib/commonjs/tabs/Tabs.js +6 -15
- package/lib/commonjs/tabs/Tabs.js.map +1 -1
- package/lib/commonjs/typography/index.js +14 -5
- package/lib/commonjs/typography/index.js.map +1 -1
- package/lib/commonjs/utils/lazy-require.js +37 -0
- package/lib/commonjs/utils/lazy-require.js.map +1 -0
- package/lib/module/admonition/index.js +7 -0
- package/lib/module/admonition/index.js.map +1 -1
- package/lib/module/avatar/Avatar.js +2 -18
- package/lib/module/avatar/Avatar.js.map +1 -1
- package/lib/module/bottom-sheet/index.js +16 -6
- package/lib/module/bottom-sheet/index.js.map +1 -1
- package/lib/module/button/Button.js +7 -19
- package/lib/module/button/Button.js.map +1 -1
- package/lib/module/chip/Chip.js +7 -17
- package/lib/module/chip/Chip.js.map +1 -1
- package/lib/module/collapsible/Collapsible.js +30 -22
- package/lib/module/collapsible/Collapsible.js.map +1 -1
- package/lib/module/fill/index.js +5 -3
- package/lib/module/fill/index.js.map +1 -1
- package/lib/module/grid/index.js +9 -5
- package/lib/module/grid/index.js.map +1 -1
- package/lib/module/grouped-buttons/GroupedButtons.js +77 -48
- package/lib/module/grouped-buttons/GroupedButtons.js.map +1 -1
- package/lib/module/hooks/index.js +2 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useInteractionState.js +41 -0
- package/lib/module/hooks/useInteractionState.js.map +1 -1
- package/lib/module/hooks/usePressAnimation.js +41 -0
- package/lib/module/hooks/usePressAnimation.js.map +1 -0
- package/lib/module/icon-circle/index.js +5 -3
- package/lib/module/icon-circle/index.js.map +1 -1
- package/lib/module/icons/{EnveopeOpen.js → EnvelopeOpen.js} +1 -1
- package/lib/module/icons/EnvelopeOpen.js.map +1 -0
- package/lib/module/icons/TEMPLATE.js +3 -2
- package/lib/module/icons/TEMPLATE.js.map +1 -1
- package/lib/module/icons/VerifiedCheck.js +3 -2
- package/lib/module/icons/VerifiedCheck.js.map +1 -1
- package/lib/module/icons/VerifierCheck.js +3 -2
- package/lib/module/icons/VerifierCheck.js.map +1 -1
- package/lib/module/icons/index.js +1 -1
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/loading/Loading.js +2 -17
- package/lib/module/loading/Loading.js.map +1 -1
- package/lib/module/loading/SpinnerIcon.js +3 -34
- package/lib/module/loading/SpinnerIcon.js.map +1 -1
- package/lib/module/prompt-input/Actions.js +1 -0
- package/lib/module/prompt-input/Actions.js.map +1 -1
- package/lib/module/prompt-input/Attachments.js +1 -0
- package/lib/module/prompt-input/Attachments.js.map +1 -1
- package/lib/module/prompt-input/PromptInput.js +1 -0
- package/lib/module/prompt-input/PromptInput.js.map +1 -1
- package/lib/module/prompt-input/SubmitButton.js +1 -0
- package/lib/module/prompt-input/SubmitButton.js.map +1 -1
- package/lib/module/prompt-input/Textarea.js +1 -0
- package/lib/module/prompt-input/Textarea.js.map +1 -1
- package/lib/module/prompt-input/Textarea.web.js +1 -0
- package/lib/module/prompt-input/Textarea.web.js.map +1 -1
- package/lib/module/search-input/index.js +1 -0
- package/lib/module/search-input/index.js.map +1 -1
- package/lib/module/settings-list/SettingsList.js +10 -11
- package/lib/module/settings-list/SettingsList.js.map +1 -1
- package/lib/module/skeleton/index.js +5 -0
- package/lib/module/skeleton/index.js.map +1 -1
- package/lib/module/switch/Switch.js +45 -30
- package/lib/module/switch/Switch.js.map +1 -1
- package/lib/module/tabs/Tabs.js +8 -17
- package/lib/module/tabs/Tabs.js.map +1 -1
- package/lib/module/typography/index.js +12 -3
- package/lib/module/typography/index.js.map +1 -1
- package/lib/module/utils/lazy-require.js +33 -0
- package/lib/module/utils/lazy-require.js.map +1 -0
- package/lib/typescript/commonjs/admonition/index.d.ts +21 -0
- package/lib/typescript/commonjs/admonition/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/commonjs/bottom-sheet/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/button/Button.d.ts.map +1 -1
- package/lib/typescript/commonjs/chip/Chip.d.ts.map +1 -1
- package/lib/typescript/commonjs/collapsible/Collapsible.d.ts.map +1 -1
- package/lib/typescript/commonjs/fill/index.d.ts +2 -2
- package/lib/typescript/commonjs/fill/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/grid/index.d.ts +4 -4
- package/lib/typescript/commonjs/grid/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/grouped-buttons/GroupedButtons.d.ts +9 -5
- package/lib/typescript/commonjs/grouped-buttons/GroupedButtons.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/index.d.ts +2 -1
- package/lib/typescript/commonjs/hooks/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/useInteractionState.d.ts +23 -0
- package/lib/typescript/commonjs/hooks/useInteractionState.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/usePressAnimation.d.ts +16 -0
- package/lib/typescript/commonjs/hooks/usePressAnimation.d.ts.map +1 -0
- package/lib/typescript/commonjs/icon-circle/index.d.ts +4 -4
- package/lib/typescript/commonjs/icon-circle/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/icons/{EnveopeOpen.d.ts → EnvelopeOpen.d.ts} +1 -1
- package/lib/typescript/commonjs/icons/EnvelopeOpen.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/TEMPLATE.d.ts +2 -1
- package/lib/typescript/commonjs/icons/TEMPLATE.d.ts.map +1 -1
- package/lib/typescript/commonjs/icons/VerifiedCheck.d.ts.map +1 -1
- package/lib/typescript/commonjs/icons/VerifierCheck.d.ts.map +1 -1
- package/lib/typescript/commonjs/icons/index.d.ts +1 -1
- package/lib/typescript/commonjs/icons/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/loading/Loading.d.ts.map +1 -1
- package/lib/typescript/commonjs/loading/SpinnerIcon.d.ts.map +1 -1
- package/lib/typescript/commonjs/prompt-input/Actions.d.ts +3 -0
- package/lib/typescript/commonjs/prompt-input/Actions.d.ts.map +1 -1
- package/lib/typescript/commonjs/prompt-input/Attachments.d.ts +3 -0
- package/lib/typescript/commonjs/prompt-input/Attachments.d.ts.map +1 -1
- package/lib/typescript/commonjs/prompt-input/PromptInput.d.ts +3 -0
- package/lib/typescript/commonjs/prompt-input/PromptInput.d.ts.map +1 -1
- package/lib/typescript/commonjs/prompt-input/SubmitButton.d.ts +3 -0
- package/lib/typescript/commonjs/prompt-input/SubmitButton.d.ts.map +1 -1
- package/lib/typescript/commonjs/prompt-input/Textarea.d.ts +3 -0
- package/lib/typescript/commonjs/prompt-input/Textarea.d.ts.map +1 -1
- package/lib/typescript/commonjs/prompt-input/Textarea.web.d.ts +3 -0
- package/lib/typescript/commonjs/prompt-input/Textarea.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/settings-list/SettingsList.d.ts.map +1 -1
- package/lib/typescript/commonjs/skeleton/index.d.ts +15 -0
- package/lib/typescript/commonjs/skeleton/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/switch/Switch.d.ts.map +1 -1
- package/lib/typescript/commonjs/tabs/Tabs.d.ts.map +1 -1
- package/lib/typescript/commonjs/typography/index.d.ts +11 -10
- package/lib/typescript/commonjs/typography/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/lazy-require.d.ts +15 -0
- package/lib/typescript/commonjs/utils/lazy-require.d.ts.map +1 -0
- package/lib/typescript/module/admonition/index.d.ts +21 -0
- package/lib/typescript/module/admonition/index.d.ts.map +1 -1
- package/lib/typescript/module/avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/module/bottom-sheet/index.d.ts.map +1 -1
- package/lib/typescript/module/button/Button.d.ts.map +1 -1
- package/lib/typescript/module/chip/Chip.d.ts.map +1 -1
- package/lib/typescript/module/collapsible/Collapsible.d.ts.map +1 -1
- package/lib/typescript/module/fill/index.d.ts +2 -2
- package/lib/typescript/module/fill/index.d.ts.map +1 -1
- package/lib/typescript/module/grid/index.d.ts +4 -4
- package/lib/typescript/module/grid/index.d.ts.map +1 -1
- package/lib/typescript/module/grouped-buttons/GroupedButtons.d.ts +9 -5
- package/lib/typescript/module/grouped-buttons/GroupedButtons.d.ts.map +1 -1
- package/lib/typescript/module/hooks/index.d.ts +2 -1
- package/lib/typescript/module/hooks/index.d.ts.map +1 -1
- package/lib/typescript/module/hooks/useInteractionState.d.ts +23 -0
- package/lib/typescript/module/hooks/useInteractionState.d.ts.map +1 -1
- package/lib/typescript/module/hooks/usePressAnimation.d.ts +16 -0
- package/lib/typescript/module/hooks/usePressAnimation.d.ts.map +1 -0
- package/lib/typescript/module/icon-circle/index.d.ts +4 -4
- package/lib/typescript/module/icon-circle/index.d.ts.map +1 -1
- package/lib/typescript/module/icons/{EnveopeOpen.d.ts → EnvelopeOpen.d.ts} +1 -1
- package/lib/typescript/module/icons/EnvelopeOpen.d.ts.map +1 -0
- package/lib/typescript/module/icons/TEMPLATE.d.ts +2 -1
- package/lib/typescript/module/icons/TEMPLATE.d.ts.map +1 -1
- package/lib/typescript/module/icons/VerifiedCheck.d.ts.map +1 -1
- package/lib/typescript/module/icons/VerifierCheck.d.ts.map +1 -1
- package/lib/typescript/module/icons/index.d.ts +1 -1
- package/lib/typescript/module/icons/index.d.ts.map +1 -1
- package/lib/typescript/module/loading/Loading.d.ts.map +1 -1
- package/lib/typescript/module/loading/SpinnerIcon.d.ts.map +1 -1
- package/lib/typescript/module/prompt-input/Actions.d.ts +3 -0
- package/lib/typescript/module/prompt-input/Actions.d.ts.map +1 -1
- package/lib/typescript/module/prompt-input/Attachments.d.ts +3 -0
- package/lib/typescript/module/prompt-input/Attachments.d.ts.map +1 -1
- package/lib/typescript/module/prompt-input/PromptInput.d.ts +3 -0
- package/lib/typescript/module/prompt-input/PromptInput.d.ts.map +1 -1
- package/lib/typescript/module/prompt-input/SubmitButton.d.ts +3 -0
- package/lib/typescript/module/prompt-input/SubmitButton.d.ts.map +1 -1
- package/lib/typescript/module/prompt-input/Textarea.d.ts +3 -0
- package/lib/typescript/module/prompt-input/Textarea.d.ts.map +1 -1
- package/lib/typescript/module/prompt-input/Textarea.web.d.ts +3 -0
- package/lib/typescript/module/prompt-input/Textarea.web.d.ts.map +1 -1
- package/lib/typescript/module/settings-list/SettingsList.d.ts.map +1 -1
- package/lib/typescript/module/skeleton/index.d.ts +15 -0
- package/lib/typescript/module/skeleton/index.d.ts.map +1 -1
- package/lib/typescript/module/switch/Switch.d.ts.map +1 -1
- package/lib/typescript/module/tabs/Tabs.d.ts.map +1 -1
- package/lib/typescript/module/typography/index.d.ts +11 -10
- package/lib/typescript/module/typography/index.d.ts.map +1 -1
- package/lib/typescript/module/utils/lazy-require.d.ts +15 -0
- package/lib/typescript/module/utils/lazy-require.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/BloomThemeProvider.test.tsx +3 -3
- package/src/admonition/index.tsx +7 -0
- package/src/avatar/Avatar.tsx +2 -19
- package/src/bottom-sheet/index.tsx +18 -6
- package/src/button/Button.tsx +6 -22
- package/src/chip/Chip.tsx +3 -19
- package/src/collapsible/Collapsible.tsx +34 -25
- package/src/fill/index.tsx +6 -3
- package/src/grid/index.tsx +11 -5
- package/src/grouped-buttons/GroupedButtons.tsx +79 -60
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useInteractionState.ts +21 -0
- package/src/hooks/usePressAnimation.ts +37 -0
- package/src/icon-circle/index.tsx +6 -3
- package/src/icons/TEMPLATE.tsx +2 -2
- package/src/icons/VerifiedCheck.tsx +3 -2
- package/src/icons/VerifierCheck.tsx +3 -2
- package/src/icons/index.ts +1 -1
- package/src/loading/Loading.tsx +2 -18
- package/src/loading/SpinnerIcon.tsx +4 -36
- package/src/prompt-input/Actions.tsx +1 -0
- package/src/prompt-input/Attachments.tsx +1 -0
- package/src/prompt-input/PromptInput.tsx +1 -0
- package/src/prompt-input/SubmitButton.tsx +1 -0
- package/src/prompt-input/Textarea.tsx +1 -0
- package/src/prompt-input/Textarea.web.tsx +1 -0
- package/src/search-input/index.tsx +1 -0
- package/src/settings-list/SettingsList.tsx +12 -8
- package/src/skeleton/index.tsx +5 -0
- package/src/switch/Switch.tsx +45 -23
- package/src/tabs/Tabs.tsx +3 -21
- package/src/typography/index.tsx +14 -4
- package/src/utils/lazy-require.ts +31 -0
- package/lib/commonjs/icons/EnveopeOpen.js.map +0 -1
- package/lib/module/icons/EnveopeOpen.js.map +0 -1
- package/lib/typescript/commonjs/icons/EnveopeOpen.d.ts.map +0 -1
- package/lib/typescript/module/icons/EnveopeOpen.d.ts.map +0 -1
- /package/src/icons/{EnveopeOpen.tsx → EnvelopeOpen.tsx} +0 -0
package/src/switch/Switch.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { memo,
|
|
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
|
-
|
|
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
|
-
}
|
|
29
|
+
}
|
|
26
30
|
|
|
27
|
-
const
|
|
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={
|
|
85
|
+
onPress={handlePress}
|
|
77
86
|
onPressIn={onPressIn}
|
|
78
87
|
onPressOut={onPressOut}
|
|
79
|
-
style={[
|
|
80
|
-
hitSlop={
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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 {
|
|
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 =
|
|
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',
|
package/src/typography/index.tsx
CHANGED
|
@@ -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
|
-
|
|
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
|