react-native-mantine 0.4.0 → 0.6.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.
- package/README.md +0 -357
- package/lib/commonjs/components/Button/Button.styles.js +5 -46
- package/lib/commonjs/components/Button/Button.styles.js.map +1 -1
- package/lib/commonjs/components/Button/index.js +18 -39
- package/lib/commonjs/components/Button/index.js.map +1 -1
- package/lib/commonjs/components/Chip/index.js.map +1 -1
- package/lib/commonjs/components/CloseButton/index.js +5 -30
- package/lib/commonjs/components/CloseButton/index.js.map +1 -1
- package/lib/commonjs/components/Collapse/index.js +10 -2
- package/lib/commonjs/components/Collapse/index.js.map +1 -1
- package/lib/commonjs/components/Dialog/index.js +51 -8
- package/lib/commonjs/components/Dialog/index.js.map +1 -1
- package/lib/commonjs/components/Drawer/index.js +4 -13
- package/lib/commonjs/components/Drawer/index.js.map +1 -1
- package/lib/commonjs/components/Icon/index.js +53 -0
- package/lib/commonjs/components/Icon/index.js.map +1 -0
- package/lib/commonjs/components/Input/Input.styles.js +2 -204
- package/lib/commonjs/components/Input/Input.styles.js.map +1 -1
- package/lib/commonjs/components/Input/index.js +1 -1
- package/lib/commonjs/components/List/index.js.map +1 -1
- package/lib/commonjs/components/Menu/index.js +11 -10
- package/lib/commonjs/components/Menu/index.js.map +1 -1
- package/lib/commonjs/components/Modal/index.js +10 -16
- package/lib/commonjs/components/Modal/index.js.map +1 -1
- package/lib/commonjs/components/Notification/index.js +12 -5
- package/lib/commonjs/components/Notification/index.js.map +1 -1
- package/lib/commonjs/components/NumberInput/index.js +2 -1
- package/lib/commonjs/components/NumberInput/index.js.map +1 -1
- package/lib/commonjs/components/PasswordInput/index.js +5 -6
- package/lib/commonjs/components/PasswordInput/index.js.map +1 -1
- package/lib/commonjs/components/PinInput/index.js +7 -2
- package/lib/commonjs/components/PinInput/index.js.map +1 -1
- package/lib/commonjs/components/Popover/index.js +8 -7
- package/lib/commonjs/components/Popover/index.js.map +1 -1
- package/lib/commonjs/components/RingProgress/index.js +49 -7
- package/lib/commonjs/components/RingProgress/index.js.map +1 -1
- package/lib/commonjs/components/SegmentedControl/index.js +7 -4
- package/lib/commonjs/components/SegmentedControl/index.js.map +1 -1
- package/lib/commonjs/components/Slider/index.js +28 -3
- package/lib/commonjs/components/Slider/index.js.map +1 -1
- package/lib/commonjs/components/Stepper/index.js.map +1 -1
- package/lib/commonjs/components/Table/index.js +22 -20
- package/lib/commonjs/components/Table/index.js.map +1 -1
- package/lib/commonjs/components/TextInput/index.js +2 -2
- package/lib/commonjs/components/TextInput/index.js.map +1 -1
- package/lib/commonjs/components/Timeline/index.js +12 -5
- package/lib/commonjs/components/Timeline/index.js.map +1 -1
- package/lib/commonjs/components/Tooltip/index.js +12 -11
- package/lib/commonjs/components/Tooltip/index.js.map +1 -1
- package/lib/commonjs/components/TransferList/index.js +3 -8
- package/lib/commonjs/components/TransferList/index.js.map +1 -1
- package/lib/commonjs/components/Transition/index.js +4 -0
- package/lib/commonjs/components/Transition/index.js.map +1 -1
- package/lib/commonjs/components/UnstyledButton/UnstyledButton.js +4 -0
- package/lib/commonjs/components/UnstyledButton/UnstyledButton.js.map +1 -1
- package/lib/commonjs/components/index.js +22 -22
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/hooks/useCachedResources.js +1 -4
- package/lib/commonjs/hooks/useCachedResources.js.map +1 -1
- package/lib/commonjs/theme/functions/attach-functions.js +3 -0
- package/lib/commonjs/theme/functions/attach-functions.js.map +1 -1
- package/lib/commonjs/theme/functions/fns/helpers.js +12 -1
- package/lib/commonjs/theme/functions/fns/helpers.js.map +1 -1
- package/lib/commonjs/theme/functions/fns/index.js +4 -0
- package/lib/commonjs/theme/functions/fns/index.js.map +1 -1
- package/lib/commonjs/theme/functions/fns/rgba.js +50 -0
- package/lib/commonjs/theme/functions/fns/rgba.js.map +1 -0
- package/lib/commonjs/theme/functions/fns/size.js +19 -0
- package/lib/commonjs/theme/functions/fns/size.js.map +1 -0
- package/lib/commonjs/theme/theme-provider.js +6 -8
- package/lib/commonjs/theme/theme-provider.js.map +1 -1
- package/lib/module/components/Button/Button.styles.js +5 -46
- package/lib/module/components/Button/Button.styles.js.map +1 -1
- package/lib/module/components/Button/index.js +18 -39
- package/lib/module/components/Button/index.js.map +1 -1
- package/lib/module/components/Chip/index.js.map +1 -1
- package/lib/module/components/CloseButton/index.js +6 -31
- package/lib/module/components/CloseButton/index.js.map +1 -1
- package/lib/module/components/Collapse/index.js +10 -2
- package/lib/module/components/Collapse/index.js.map +1 -1
- package/lib/module/components/Dialog/index.js +52 -9
- package/lib/module/components/Dialog/index.js.map +1 -1
- package/lib/module/components/Drawer/index.js +4 -13
- package/lib/module/components/Drawer/index.js.map +1 -1
- package/lib/module/components/Icon/index.js +48 -0
- package/lib/module/components/Icon/index.js.map +1 -0
- package/lib/module/components/Input/Input.styles.js +1 -203
- package/lib/module/components/Input/Input.styles.js.map +1 -1
- package/lib/module/components/Input/index.js +1 -1
- package/lib/module/components/Input/index.js.map +1 -1
- package/lib/module/components/List/index.js.map +1 -1
- package/lib/module/components/Menu/index.js +9 -8
- package/lib/module/components/Menu/index.js.map +1 -1
- package/lib/module/components/Modal/index.js +10 -16
- package/lib/module/components/Modal/index.js.map +1 -1
- package/lib/module/components/Notification/index.js +12 -5
- package/lib/module/components/Notification/index.js.map +1 -1
- package/lib/module/components/NumberInput/index.js +2 -1
- package/lib/module/components/NumberInput/index.js.map +1 -1
- package/lib/module/components/PasswordInput/index.js +5 -6
- package/lib/module/components/PasswordInput/index.js.map +1 -1
- package/lib/module/components/PinInput/index.js +7 -2
- package/lib/module/components/PinInput/index.js.map +1 -1
- package/lib/module/components/Popover/index.js +9 -8
- package/lib/module/components/Popover/index.js.map +1 -1
- package/lib/module/components/RingProgress/index.js +51 -9
- package/lib/module/components/RingProgress/index.js.map +1 -1
- package/lib/module/components/SegmentedControl/index.js +7 -4
- package/lib/module/components/SegmentedControl/index.js.map +1 -1
- package/lib/module/components/Slider/index.js +28 -3
- package/lib/module/components/Slider/index.js.map +1 -1
- package/lib/module/components/Stepper/index.js.map +1 -1
- package/lib/module/components/Table/index.js +22 -19
- package/lib/module/components/Table/index.js.map +1 -1
- package/lib/module/components/TextInput/index.js +2 -2
- package/lib/module/components/TextInput/index.js.map +1 -1
- package/lib/module/components/Timeline/index.js +12 -5
- package/lib/module/components/Timeline/index.js.map +1 -1
- package/lib/module/components/Tooltip/index.js +11 -10
- package/lib/module/components/Tooltip/index.js.map +1 -1
- package/lib/module/components/TransferList/index.js +4 -9
- package/lib/module/components/TransferList/index.js.map +1 -1
- package/lib/module/components/Transition/index.js +5 -1
- package/lib/module/components/Transition/index.js.map +1 -1
- package/lib/module/components/UnstyledButton/UnstyledButton.js +4 -0
- package/lib/module/components/UnstyledButton/UnstyledButton.js.map +1 -1
- package/lib/module/components/index.js +1 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/hooks/useCachedResources.js +1 -4
- package/lib/module/hooks/useCachedResources.js.map +1 -1
- package/lib/module/theme/functions/attach-functions.js +3 -0
- package/lib/module/theme/functions/attach-functions.js.map +1 -1
- package/lib/module/theme/functions/fns/helpers.js +10 -0
- package/lib/module/theme/functions/fns/helpers.js.map +1 -1
- package/lib/module/theme/functions/fns/index.js +4 -0
- package/lib/module/theme/functions/fns/index.js.map +1 -1
- package/lib/module/theme/functions/fns/rgba.js +46 -0
- package/lib/module/theme/functions/fns/rgba.js.map +1 -0
- package/lib/module/theme/functions/fns/size.js +15 -0
- package/lib/module/theme/functions/fns/size.js.map +1 -0
- package/lib/module/theme/theme-provider.js +6 -8
- package/lib/module/theme/theme-provider.js.map +1 -1
- package/lib/typescript/commonjs/src/components/Button/Button.styles.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Button/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/components/Button/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/CloseButton/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Collapse/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Dialog/index.d.ts +2 -0
- package/lib/typescript/commonjs/src/components/Dialog/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Drawer/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Icon/index.d.ts +26 -0
- package/lib/typescript/commonjs/src/components/Icon/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/Input/Input.styles.d.ts +7 -0
- package/lib/typescript/commonjs/src/components/Input/Input.styles.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Input/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/Input/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Menu/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Modal/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Notification/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/NumberInput/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/PinInput/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Popover/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/RingProgress/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/SegmentedControl/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Slider/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Stepper/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Table/index.d.ts +16 -7
- package/lib/typescript/commonjs/src/components/Table/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/TextInput/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Timeline/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Tooltip/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/TransferList/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Transition/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/UnstyledButton/UnstyledButton.d.ts +2 -0
- package/lib/typescript/commonjs/src/components/UnstyledButton/UnstyledButton.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/hooks/useCachedResources.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/functions/attach-functions.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/functions/fns/helpers.d.ts +7 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/helpers.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/functions/fns/index.d.ts +7 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/functions/fns/rgba.d.ts +8 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/rgba.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/size.d.ts +6 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/size.d.ts.map +1 -0
- package/lib/typescript/module/src/components/Button/Button.styles.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Button/index.d.ts +1 -0
- package/lib/typescript/module/src/components/Button/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/CloseButton/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Collapse/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Dialog/index.d.ts +2 -0
- package/lib/typescript/module/src/components/Dialog/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Drawer/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Icon/index.d.ts +26 -0
- package/lib/typescript/module/src/components/Icon/index.d.ts.map +1 -0
- package/lib/typescript/module/src/components/Input/Input.styles.d.ts +7 -0
- package/lib/typescript/module/src/components/Input/Input.styles.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Input/index.d.ts +1 -1
- package/lib/typescript/module/src/components/Input/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Menu/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Modal/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Notification/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/NumberInput/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/PinInput/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Popover/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/RingProgress/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/SegmentedControl/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Slider/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Stepper/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Table/index.d.ts +16 -7
- package/lib/typescript/module/src/components/Table/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/TextInput/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Timeline/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Tooltip/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/TransferList/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Transition/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/UnstyledButton/UnstyledButton.d.ts +2 -0
- package/lib/typescript/module/src/components/UnstyledButton/UnstyledButton.d.ts.map +1 -1
- package/lib/typescript/module/src/components/index.d.ts +1 -1
- package/lib/typescript/module/src/components/index.d.ts.map +1 -1
- package/lib/typescript/module/src/hooks/useCachedResources.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/functions/attach-functions.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/functions/fns/helpers.d.ts +7 -0
- package/lib/typescript/module/src/theme/functions/fns/helpers.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/functions/fns/index.d.ts +7 -0
- package/lib/typescript/module/src/theme/functions/fns/index.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/functions/fns/rgba.d.ts +8 -0
- package/lib/typescript/module/src/theme/functions/fns/rgba.d.ts.map +1 -0
- package/lib/typescript/module/src/theme/functions/fns/size.d.ts +6 -0
- package/lib/typescript/module/src/theme/functions/fns/size.d.ts.map +1 -0
- package/package.json +12 -9
- package/src/components/Button/Button.styles.ts +5 -48
- package/src/components/Button/index.tsx +56 -81
- package/src/components/Chip/index.tsx +3 -3
- package/src/components/CloseButton/index.tsx +2 -23
- package/src/components/Collapse/index.tsx +11 -2
- package/src/components/Dialog/index.tsx +54 -9
- package/src/components/Drawer/index.tsx +7 -13
- package/src/components/Icon/index.tsx +74 -0
- package/src/components/Input/Input.styles.ts +1 -202
- package/src/components/Input/index.ts +1 -1
- package/src/components/List/index.tsx +1 -1
- package/src/components/Menu/index.tsx +13 -10
- package/src/components/Modal/index.tsx +11 -16
- package/src/components/Notification/index.tsx +10 -2
- package/src/components/NumberInput/index.tsx +57 -15
- package/src/components/PasswordInput/index.tsx +2 -2
- package/src/components/PinInput/index.tsx +24 -9
- package/src/components/Popover/index.tsx +13 -10
- package/src/components/RingProgress/index.tsx +51 -8
- package/src/components/SegmentedControl/index.tsx +6 -4
- package/src/components/Slider/index.tsx +14 -3
- package/src/components/Stepper/index.tsx +5 -4
- package/src/components/Table/index.tsx +73 -36
- package/src/components/TextInput/index.tsx +93 -66
- package/src/components/Timeline/index.tsx +19 -12
- package/src/components/Tooltip/index.tsx +13 -10
- package/src/components/TransferList/index.tsx +1 -5
- package/src/components/Transition/index.tsx +14 -2
- package/src/components/UnstyledButton/UnstyledButton.tsx +5 -1
- package/src/components/index.tsx +1 -1
- package/src/hooks/useCachedResources.ts +1 -4
- package/src/theme/functions/attach-functions.ts +3 -0
- package/src/theme/functions/fns/helpers.ts +19 -7
- package/src/theme/functions/fns/index.ts +4 -0
- package/src/theme/functions/fns/rgba.ts +45 -0
- package/src/theme/functions/fns/size.ts +14 -0
- package/src/theme/theme-provider.tsx +6 -6
- package/src/theme/types/MantineStyleSystem.ts +0 -53
- package/lib/commonjs/components/Portal/index.js +0 -69
- package/lib/commonjs/components/Portal/index.js.map +0 -1
- package/lib/module/components/Portal/index.js +0 -62
- package/lib/module/components/Portal/index.js.map +0 -1
- package/lib/typescript/commonjs/src/components/Portal/index.d.ts +0 -10
- package/lib/typescript/commonjs/src/components/Portal/index.d.ts.map +0 -1
- package/lib/typescript/module/src/components/Portal/index.d.ts +0 -10
- package/lib/typescript/module/src/components/Portal/index.d.ts.map +0 -1
- package/src/components/Portal/index.tsx +0 -75
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
1
|
+
import React, { forwardRef, useEffect, useRef } from 'react';
|
|
2
|
+
import { View, Animated } from 'react-native';
|
|
3
3
|
import { BoxView } from '../BoxView';
|
|
4
4
|
import { Text } from '../Text';
|
|
5
5
|
import type { DefaultProps, MantineColor } from '../../theme/types';
|
|
@@ -119,13 +119,41 @@ export const RingProgress = forwardRef<any, RingProgressProps>((props, ref) => {
|
|
|
119
119
|
{ name: 'RingProgress' }
|
|
120
120
|
) as any;
|
|
121
121
|
|
|
122
|
+
// Animation values for each section
|
|
123
|
+
const animatedValues = useRef(
|
|
124
|
+
sections.map(() => new Animated.Value(0))
|
|
125
|
+
).current;
|
|
126
|
+
|
|
127
|
+
// Update animation values when sections change
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
// Ensure we have the right number of animated values
|
|
130
|
+
while (animatedValues.length < sections.length) {
|
|
131
|
+
animatedValues.push(new Animated.Value(0));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Animate each section
|
|
135
|
+
const animations = sections.map((section, index) => {
|
|
136
|
+
const animValue = animatedValues[index];
|
|
137
|
+
if (!animValue) return Animated.timing(new Animated.Value(0), { toValue: 0, duration: 0, useNativeDriver: false });
|
|
138
|
+
|
|
139
|
+
return Animated.timing(animValue, {
|
|
140
|
+
toValue: section.value,
|
|
141
|
+
duration: 1000,
|
|
142
|
+
useNativeDriver: false,
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
Animated.parallel(animations).start();
|
|
147
|
+
}, [sections, animatedValues]);
|
|
148
|
+
|
|
122
149
|
// Calculate total value and normalize sections
|
|
123
|
-
const normalizedSections = sections.map((section) => ({
|
|
150
|
+
const normalizedSections = sections.map((section, index) => ({
|
|
124
151
|
...section,
|
|
125
152
|
percentage: (section.value / 100) * 100,
|
|
153
|
+
animatedValue: animatedValues[index] || new Animated.Value(0),
|
|
126
154
|
}));
|
|
127
155
|
|
|
128
|
-
// Render
|
|
156
|
+
// Render animated ring using borders and transforms
|
|
129
157
|
// Note: This is a basic implementation. For full SVG support, use react-native-svg
|
|
130
158
|
const renderSections = () => {
|
|
131
159
|
let currentAngle = 0;
|
|
@@ -139,10 +167,21 @@ export const RingProgress = forwardRef<any, RingProgressProps>((props, ref) => {
|
|
|
139
167
|
const rotation = currentAngle;
|
|
140
168
|
currentAngle += angle;
|
|
141
169
|
|
|
142
|
-
//
|
|
143
|
-
|
|
170
|
+
// Animate the opacity for a smooth appearance
|
|
171
|
+
const animatedOpacity = section.animatedValue.interpolate({
|
|
172
|
+
inputRange: [0, section.value],
|
|
173
|
+
outputRange: [0, 1],
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Animated scale for smooth growth effect
|
|
177
|
+
const animatedScale = section.animatedValue.interpolate({
|
|
178
|
+
inputRange: [0, section.value],
|
|
179
|
+
outputRange: [0.8, 1],
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Simplified representation - just show colored arcs with animation
|
|
144
183
|
return (
|
|
145
|
-
<View
|
|
184
|
+
<Animated.View
|
|
146
185
|
key={index}
|
|
147
186
|
style={{
|
|
148
187
|
position: 'absolute',
|
|
@@ -152,7 +191,11 @@ export const RingProgress = forwardRef<any, RingProgressProps>((props, ref) => {
|
|
|
152
191
|
borderWidth: thickness,
|
|
153
192
|
borderColor: 'transparent',
|
|
154
193
|
borderTopColor: sectionColor,
|
|
155
|
-
transform: [
|
|
194
|
+
transform: [
|
|
195
|
+
{ rotate: `${rotation}deg` },
|
|
196
|
+
{ scale: animatedScale },
|
|
197
|
+
],
|
|
198
|
+
opacity: animatedOpacity,
|
|
156
199
|
}}
|
|
157
200
|
/>
|
|
158
201
|
);
|
|
@@ -85,19 +85,20 @@ const useStyles = createStyles(
|
|
|
85
85
|
flexDirection: orientation === 'horizontal' ? 'row' : 'column',
|
|
86
86
|
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark?.[6] : theme.colors.gray?.[1],
|
|
87
87
|
borderRadius: theme.fn.radius(radius),
|
|
88
|
-
padding: rem(
|
|
88
|
+
padding: rem(3) as any,
|
|
89
89
|
opacity: disabled ? 0.5 : 1,
|
|
90
90
|
...(fullWidth && { width: '100%' }),
|
|
91
91
|
},
|
|
92
92
|
indicator: {
|
|
93
93
|
position: 'absolute',
|
|
94
94
|
backgroundColor: theme.white,
|
|
95
|
-
borderRadius: theme.fn.radius(radius),
|
|
95
|
+
borderRadius: (theme.fn.radius(radius) as number) - rem(1),
|
|
96
96
|
shadowColor: '#000',
|
|
97
97
|
shadowOffset: { width: 0, height: 1 },
|
|
98
98
|
shadowOpacity: 0.05,
|
|
99
99
|
shadowRadius: 1,
|
|
100
100
|
elevation: 1,
|
|
101
|
+
margin: rem(3) as any,
|
|
101
102
|
...(theme.colorScheme === 'dark' && {
|
|
102
103
|
backgroundColor: theme.colors.dark?.[5],
|
|
103
104
|
}),
|
|
@@ -105,11 +106,11 @@ const useStyles = createStyles(
|
|
|
105
106
|
segment: {
|
|
106
107
|
flex: 1,
|
|
107
108
|
paddingHorizontal: sizeStyles.padding as any,
|
|
108
|
-
paddingVertical:
|
|
109
|
+
paddingVertical: rem(6) as any,
|
|
109
110
|
minHeight: sizeStyles.height as any,
|
|
110
111
|
justifyContent: 'center',
|
|
111
112
|
alignItems: 'center',
|
|
112
|
-
borderRadius: theme.fn.radius(radius),
|
|
113
|
+
borderRadius: (theme.fn.radius(radius) as number) - rem(1),
|
|
113
114
|
zIndex: 1,
|
|
114
115
|
},
|
|
115
116
|
label: {
|
|
@@ -181,6 +182,7 @@ export const SegmentedControl = forwardRef<any, SegmentedControlProps>((props, r
|
|
|
181
182
|
useEffect(() => {
|
|
182
183
|
if (segmentLayouts[activeIndex]) {
|
|
183
184
|
const layout = segmentLayouts[activeIndex];
|
|
185
|
+
// No need to adjust for margin since indicator has its own margin
|
|
184
186
|
|
|
185
187
|
Animated.parallel([
|
|
186
188
|
Animated.timing(indicatorPosition, {
|
|
@@ -247,19 +247,28 @@ export const Slider = forwardRef<any, SliderProps>((props, ref) => {
|
|
|
247
247
|
[trackWidth, min, max]
|
|
248
248
|
);
|
|
249
249
|
|
|
250
|
+
const trackLayoutRef = useRef({ x: 0, y: 0, width: 0, height: 0 });
|
|
251
|
+
|
|
250
252
|
const panResponder = useRef(
|
|
251
253
|
PanResponder.create({
|
|
252
254
|
onStartShouldSetPanResponder: () => !disabled!,
|
|
253
255
|
onMoveShouldSetPanResponder: () => !disabled!,
|
|
254
|
-
onPanResponderGrant: () => {
|
|
256
|
+
onPanResponderGrant: (evt: GestureResponderEvent) => {
|
|
255
257
|
setShowLabel(true);
|
|
256
258
|
Animated.spring(scale, {
|
|
257
259
|
toValue: 1.2,
|
|
258
260
|
useNativeDriver: true,
|
|
259
261
|
}).start();
|
|
262
|
+
|
|
263
|
+
// Handle tap to move slider
|
|
264
|
+
const locationX = evt.nativeEvent.locationX;
|
|
265
|
+
const newValue = getValueFromPosition(locationX);
|
|
266
|
+
updateValue(newValue);
|
|
260
267
|
},
|
|
261
268
|
onPanResponderMove: (_evt: GestureResponderEvent, gestureState: PanResponderGestureState) => {
|
|
262
|
-
|
|
269
|
+
// Calculate position relative to track start
|
|
270
|
+
const relativeX = gestureState.moveX - trackLayoutRef.current.x;
|
|
271
|
+
const newValue = getValueFromPosition(relativeX);
|
|
263
272
|
updateValue(newValue);
|
|
264
273
|
},
|
|
265
274
|
onPanResponderRelease: () => {
|
|
@@ -274,7 +283,9 @@ export const Slider = forwardRef<any, SliderProps>((props, ref) => {
|
|
|
274
283
|
).current;
|
|
275
284
|
|
|
276
285
|
const handleLayout = (event: LayoutChangeEvent) => {
|
|
277
|
-
|
|
286
|
+
const { x, y, width, height } = event.nativeEvent.layout;
|
|
287
|
+
setTrackWidth(width);
|
|
288
|
+
trackLayoutRef.current = { x, y, width, height };
|
|
278
289
|
};
|
|
279
290
|
|
|
280
291
|
const percentage = ((value - min!) / (max! - min!)) * 100;
|
|
@@ -252,10 +252,11 @@ export const Stepper = forwardRef<any, StepperProps>((props, ref) => {
|
|
|
252
252
|
|
|
253
253
|
const childrenArray = React.Children.toArray(children);
|
|
254
254
|
const steps = childrenArray.filter(
|
|
255
|
-
(child)
|
|
255
|
+
(child): child is React.ReactElement<StepProps & { __stepIndex?: number; __isLast?: boolean }> =>
|
|
256
|
+
React.isValidElement(child) && (child.type as any) === Step
|
|
256
257
|
);
|
|
257
258
|
const completedStep = childrenArray.find(
|
|
258
|
-
(child) => React.isValidElement(child) && (child as any)
|
|
259
|
+
(child) => React.isValidElement(child) && (child.type as any) === StepperCompleted
|
|
259
260
|
);
|
|
260
261
|
|
|
261
262
|
const isStepsCompleted = active >= steps.length;
|
|
@@ -275,7 +276,7 @@ export const Stepper = forwardRef<any, StepperProps>((props, ref) => {
|
|
|
275
276
|
<BoxView ref={ref} style={sx(styles.root, style)} {...others}>
|
|
276
277
|
<BoxView style={styles.steps}>
|
|
277
278
|
{steps.map((step, index) => {
|
|
278
|
-
return React.cloneElement(step
|
|
279
|
+
return React.cloneElement<StepProps & { __stepIndex?: number; __isLast?: boolean }>(step, {
|
|
279
280
|
key: index,
|
|
280
281
|
__stepIndex: index,
|
|
281
282
|
__isLast: index === steps.length - 1,
|
|
@@ -286,7 +287,7 @@ export const Stepper = forwardRef<any, StepperProps>((props, ref) => {
|
|
|
286
287
|
<BoxView style={styles.content}>
|
|
287
288
|
{isStepsCompleted
|
|
288
289
|
? completedStep
|
|
289
|
-
: steps[active] &&
|
|
290
|
+
: steps[active] && steps[active].props.children}
|
|
290
291
|
</BoxView>
|
|
291
292
|
</BoxView>
|
|
292
293
|
</StepperContext.Provider>
|
|
@@ -137,12 +137,18 @@ const useTableStyles = createStyles(
|
|
|
137
137
|
borderCollapse: 'collapse' as any,
|
|
138
138
|
...(withBorder && {
|
|
139
139
|
borderWidth: 1,
|
|
140
|
-
borderColor:
|
|
140
|
+
borderColor:
|
|
141
|
+
theme.colorScheme === 'dark'
|
|
142
|
+
? theme.colors.dark?.[4]
|
|
143
|
+
: theme.colors.gray?.[3],
|
|
141
144
|
}),
|
|
142
145
|
},
|
|
143
146
|
caption: {
|
|
144
147
|
fontSize: theme.fontSizes.sm as number,
|
|
145
|
-
color:
|
|
148
|
+
color:
|
|
149
|
+
theme.colorScheme === 'dark'
|
|
150
|
+
? theme.colors.dark?.[2]
|
|
151
|
+
: theme.colors.gray?.[6],
|
|
146
152
|
paddingVertical: theme.spacing.xs,
|
|
147
153
|
textAlign: 'center',
|
|
148
154
|
...(captionSide === 'bottom' && { order: 1 }),
|
|
@@ -153,7 +159,10 @@ const useTableStyles = createStyles(
|
|
|
153
159
|
const useTableHeadStyles = createStyles((theme) => ({
|
|
154
160
|
thead: {
|
|
155
161
|
borderBottomWidth: 1,
|
|
156
|
-
borderBottomColor:
|
|
162
|
+
borderBottomColor:
|
|
163
|
+
theme.colorScheme === 'dark'
|
|
164
|
+
? theme.colors.dark?.[4]
|
|
165
|
+
: theme.colors.gray?.[3],
|
|
157
166
|
},
|
|
158
167
|
}));
|
|
159
168
|
|
|
@@ -171,11 +180,16 @@ const useTableRowStyles = createStyles(
|
|
|
171
180
|
) => ({
|
|
172
181
|
tr: {
|
|
173
182
|
borderBottomWidth: 1,
|
|
174
|
-
borderBottomColor:
|
|
183
|
+
borderBottomColor:
|
|
184
|
+
theme.colorScheme === 'dark'
|
|
185
|
+
? theme.colors.dark?.[4]
|
|
186
|
+
: theme.colors.gray?.[3],
|
|
175
187
|
...(striped &&
|
|
176
188
|
isEven && {
|
|
177
189
|
backgroundColor:
|
|
178
|
-
theme.colorScheme === 'dark'
|
|
190
|
+
theme.colorScheme === 'dark'
|
|
191
|
+
? theme.colors.dark?.[6]
|
|
192
|
+
: theme.colors.gray?.[0],
|
|
179
193
|
}),
|
|
180
194
|
},
|
|
181
195
|
})
|
|
@@ -218,7 +232,9 @@ const useTableCellStyles = createStyles(
|
|
|
218
232
|
...(withColumnBorders && {
|
|
219
233
|
borderRightWidth: 1,
|
|
220
234
|
borderRightColor:
|
|
221
|
-
theme.colorScheme === 'dark'
|
|
235
|
+
theme.colorScheme === 'dark'
|
|
236
|
+
? theme.colors.dark?.[4]
|
|
237
|
+
: theme.colors.gray?.[3],
|
|
222
238
|
}),
|
|
223
239
|
...(isHeader && {
|
|
224
240
|
fontWeight: '600',
|
|
@@ -239,7 +255,7 @@ const defaultProps: Partial<TableProps> = {
|
|
|
239
255
|
captionSide: 'top',
|
|
240
256
|
};
|
|
241
257
|
|
|
242
|
-
|
|
258
|
+
const Table = forwardRef<any, TableProps>((props, ref) => {
|
|
243
259
|
const {
|
|
244
260
|
children,
|
|
245
261
|
horizontalSpacing,
|
|
@@ -255,7 +271,7 @@ export const Table = forwardRef<any, TableProps>((props, ref) => {
|
|
|
255
271
|
...others
|
|
256
272
|
} = useComponentDefaultProps('Table', defaultProps, props);
|
|
257
273
|
|
|
258
|
-
const { styles, sx} = useTableStyles(
|
|
274
|
+
const { styles, sx } = useTableStyles(
|
|
259
275
|
{ withBorder, captionSide },
|
|
260
276
|
{ name: 'Table' }
|
|
261
277
|
) as any;
|
|
@@ -272,7 +288,11 @@ export const Table = forwardRef<any, TableProps>((props, ref) => {
|
|
|
272
288
|
horizontalSpacing: horizontalSpacing!,
|
|
273
289
|
}}
|
|
274
290
|
>
|
|
275
|
-
<ScrollView
|
|
291
|
+
<ScrollView
|
|
292
|
+
horizontal
|
|
293
|
+
style={styles.wrapper}
|
|
294
|
+
showsHorizontalScrollIndicator
|
|
295
|
+
>
|
|
276
296
|
<BoxView ref={ref} style={sx(styles.root, style)} {...others}>
|
|
277
297
|
{caption && <Text style={styles.caption}>{caption}</Text>}
|
|
278
298
|
{children}
|
|
@@ -282,9 +302,9 @@ export const Table = forwardRef<any, TableProps>((props, ref) => {
|
|
|
282
302
|
);
|
|
283
303
|
});
|
|
284
304
|
|
|
285
|
-
|
|
286
|
-
const { children, style, ...others} = props;
|
|
287
|
-
const { styles, sx} = useTableHeadStyles({}, { name: 'Thead' }) as any;
|
|
305
|
+
const Thead = forwardRef<any, TableTheadProps>((props, ref) => {
|
|
306
|
+
const { children, style, ...others } = props;
|
|
307
|
+
const { styles, sx } = useTableHeadStyles({}, { name: 'Thead' }) as any;
|
|
288
308
|
|
|
289
309
|
return (
|
|
290
310
|
<BoxView ref={ref} style={sx(styles.thead, style)} {...others}>
|
|
@@ -293,7 +313,7 @@ export const Thead = forwardRef<any, TableTheadProps>((props, ref) => {
|
|
|
293
313
|
);
|
|
294
314
|
});
|
|
295
315
|
|
|
296
|
-
|
|
316
|
+
const Tbody = forwardRef<any, TableTbodyProps>((props, ref) => {
|
|
297
317
|
const { children, style, ...others } = props;
|
|
298
318
|
|
|
299
319
|
const childrenArray = React.Children.toArray(children);
|
|
@@ -302,16 +322,19 @@ export const Tbody = forwardRef<any, TableTbodyProps>((props, ref) => {
|
|
|
302
322
|
<BoxView ref={ref} style={style} {...others}>
|
|
303
323
|
{childrenArray.map((child, index) => {
|
|
304
324
|
if (!React.isValidElement(child)) return child;
|
|
305
|
-
return React.cloneElement(
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
325
|
+
return React.cloneElement<TableTrProps>(
|
|
326
|
+
child as React.ReactElement<TableTrProps>,
|
|
327
|
+
{
|
|
328
|
+
key: index,
|
|
329
|
+
__index: index,
|
|
330
|
+
}
|
|
331
|
+
);
|
|
309
332
|
})}
|
|
310
333
|
</BoxView>
|
|
311
334
|
);
|
|
312
335
|
});
|
|
313
336
|
|
|
314
|
-
|
|
337
|
+
const Tfoot = forwardRef<any, TableTfootProps>((props, ref) => {
|
|
315
338
|
const { children, style, ...others } = props;
|
|
316
339
|
|
|
317
340
|
return (
|
|
@@ -321,11 +344,11 @@ export const Tfoot = forwardRef<any, TableTfootProps>((props, ref) => {
|
|
|
321
344
|
);
|
|
322
345
|
});
|
|
323
346
|
|
|
324
|
-
|
|
325
|
-
const { children, style, __index, ...others} = props;
|
|
347
|
+
const Tr = forwardRef<any, TableTrProps>((props, ref) => {
|
|
348
|
+
const { children, style, __index, ...others } = props;
|
|
326
349
|
const context = useTableContext();
|
|
327
350
|
|
|
328
|
-
const { styles, sx} = useTableRowStyles(
|
|
351
|
+
const { styles, sx } = useTableRowStyles(
|
|
329
352
|
{
|
|
330
353
|
striped: context?.striped ?? false,
|
|
331
354
|
highlightOnHover: context?.highlightOnHover ?? false,
|
|
@@ -341,11 +364,11 @@ export const Tr = forwardRef<any, TableTrProps>((props, ref) => {
|
|
|
341
364
|
);
|
|
342
365
|
});
|
|
343
366
|
|
|
344
|
-
|
|
345
|
-
const { children, style, ...others} = props;
|
|
367
|
+
const Th = forwardRef<any, TableThProps>((props, ref) => {
|
|
368
|
+
const { children, style, ...others } = props;
|
|
346
369
|
const context = useTableContext();
|
|
347
370
|
|
|
348
|
-
const { styles, sx} = useTableCellStyles(
|
|
371
|
+
const { styles, sx } = useTableCellStyles(
|
|
349
372
|
{
|
|
350
373
|
fontSize: context?.fontSize ?? 'sm',
|
|
351
374
|
verticalSpacing: context?.verticalSpacing ?? 'xs',
|
|
@@ -358,16 +381,16 @@ export const Th = forwardRef<any, TableThProps>((props, ref) => {
|
|
|
358
381
|
|
|
359
382
|
return (
|
|
360
383
|
<BoxView ref={ref} style={sx(styles.cell, style)} {...others}>
|
|
361
|
-
|
|
384
|
+
<Text style={styles.cell}>{children}</Text>)
|
|
362
385
|
</BoxView>
|
|
363
386
|
);
|
|
364
387
|
});
|
|
365
388
|
|
|
366
|
-
|
|
367
|
-
const { children, style, ...others} = props;
|
|
389
|
+
const Td = forwardRef<any, TableTdProps>((props, ref) => {
|
|
390
|
+
const { children, style, ...others } = props;
|
|
368
391
|
const context = useTableContext();
|
|
369
392
|
|
|
370
|
-
const { styles, sx} = useTableCellStyles(
|
|
393
|
+
const { styles, sx } = useTableCellStyles(
|
|
371
394
|
{
|
|
372
395
|
fontSize: context?.fontSize ?? 'sm',
|
|
373
396
|
verticalSpacing: context?.verticalSpacing ?? 'xs',
|
|
@@ -380,7 +403,7 @@ export const Td = forwardRef<any, TableTdProps>((props, ref) => {
|
|
|
380
403
|
|
|
381
404
|
return (
|
|
382
405
|
<BoxView ref={ref} style={sx(styles.cell, style)} {...others}>
|
|
383
|
-
|
|
406
|
+
<Text style={styles.cell}>{children}</Text>
|
|
384
407
|
</BoxView>
|
|
385
408
|
);
|
|
386
409
|
});
|
|
@@ -393,10 +416,24 @@ Tr.displayName = 'Table.Tr';
|
|
|
393
416
|
Th.displayName = 'Table.Th';
|
|
394
417
|
Td.displayName = 'Table.Td';
|
|
395
418
|
|
|
396
|
-
// Attach sub-components
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
419
|
+
// Attach sub-components with proper typing
|
|
420
|
+
interface TableComponent extends React.ForwardRefExoticComponent<
|
|
421
|
+
TableProps & React.RefAttributes<any>
|
|
422
|
+
> {
|
|
423
|
+
Thead: typeof Thead;
|
|
424
|
+
Tbody: typeof Tbody;
|
|
425
|
+
Tfoot: typeof Tfoot;
|
|
426
|
+
Tr: typeof Tr;
|
|
427
|
+
Th: typeof Th;
|
|
428
|
+
Td: typeof Td;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const TableWithSubComponents = Table as TableComponent;
|
|
432
|
+
TableWithSubComponents.Thead = Thead;
|
|
433
|
+
TableWithSubComponents.Tbody = Tbody;
|
|
434
|
+
TableWithSubComponents.Tfoot = Tfoot;
|
|
435
|
+
TableWithSubComponents.Tr = Tr;
|
|
436
|
+
TableWithSubComponents.Th = Th;
|
|
437
|
+
TableWithSubComponents.Td = Td;
|
|
438
|
+
|
|
439
|
+
export { TableWithSubComponents as Table };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
TextInput as RNTextInput,
|
|
4
|
+
type TextInputProps as RNTextInputProps,
|
|
5
|
+
} from 'react-native';
|
|
3
6
|
import { BoxView } from '../BoxView';
|
|
4
7
|
import { Text } from '../Text';
|
|
5
8
|
import type {
|
|
@@ -12,7 +15,8 @@ import { createStyles, getSize } from '../../theme';
|
|
|
12
15
|
import { rem } from '../../theme/utils/rem';
|
|
13
16
|
import { INPUT_SIZES } from '../Input';
|
|
14
17
|
|
|
15
|
-
export interface TextInputProps
|
|
18
|
+
export interface TextInputProps
|
|
19
|
+
extends DefaultProps, Omit<RNTextInputProps, 'style'> {
|
|
16
20
|
/** Input label */
|
|
17
21
|
label?: React.ReactNode;
|
|
18
22
|
|
|
@@ -71,7 +75,10 @@ const useStyles = createStyles(
|
|
|
71
75
|
const getVariantStyles = () => {
|
|
72
76
|
if (variant === 'filled') {
|
|
73
77
|
return {
|
|
74
|
-
backgroundColor:
|
|
78
|
+
backgroundColor:
|
|
79
|
+
theme.colorScheme === 'dark'
|
|
80
|
+
? (theme.colors.dark || [])[5]
|
|
81
|
+
: (theme.colors.gray || [])[1],
|
|
75
82
|
borderWidth: 1,
|
|
76
83
|
borderColor: 'transparent',
|
|
77
84
|
};
|
|
@@ -87,13 +94,20 @@ const useStyles = createStyles(
|
|
|
87
94
|
|
|
88
95
|
// default variant
|
|
89
96
|
return {
|
|
90
|
-
backgroundColor:
|
|
97
|
+
backgroundColor:
|
|
98
|
+
theme.colorScheme === 'dark'
|
|
99
|
+
? (theme.colors.dark || [])[6]
|
|
100
|
+
: theme.white,
|
|
91
101
|
borderWidth: 1,
|
|
92
|
-
borderColor:
|
|
102
|
+
borderColor:
|
|
103
|
+
theme.colorScheme === 'dark'
|
|
104
|
+
? (theme.colors.dark || [])[4]
|
|
105
|
+
: (theme.colors.gray || [])[4],
|
|
93
106
|
};
|
|
94
107
|
};
|
|
95
108
|
|
|
96
|
-
const sizeValue =
|
|
109
|
+
const sizeValue =
|
|
110
|
+
INPUT_SIZES[size as keyof typeof INPUT_SIZES] || INPUT_SIZES.md;
|
|
97
111
|
|
|
98
112
|
return {
|
|
99
113
|
wrapper: {
|
|
@@ -102,7 +116,10 @@ const useStyles = createStyles(
|
|
|
102
116
|
label: {
|
|
103
117
|
fontSize: theme.fontSizes.sm as number,
|
|
104
118
|
fontWeight: '500',
|
|
105
|
-
color:
|
|
119
|
+
color:
|
|
120
|
+
theme.colorScheme === 'dark'
|
|
121
|
+
? (theme.colors.dark || [])[0]
|
|
122
|
+
: theme.black,
|
|
106
123
|
marginBottom: theme.spacing.xs / 2,
|
|
107
124
|
},
|
|
108
125
|
required: {
|
|
@@ -110,7 +127,10 @@ const useStyles = createStyles(
|
|
|
110
127
|
},
|
|
111
128
|
description: {
|
|
112
129
|
fontSize: theme.fontSizes.xs as number,
|
|
113
|
-
color:
|
|
130
|
+
color:
|
|
131
|
+
theme.colorScheme === 'dark'
|
|
132
|
+
? (theme.colors.dark || [])[2]
|
|
133
|
+
: (theme.colors.gray || [])[6],
|
|
114
134
|
marginTop: theme.spacing.xs / 2,
|
|
115
135
|
marginBottom: theme.spacing.xs / 2,
|
|
116
136
|
},
|
|
@@ -123,23 +143,30 @@ const useStyles = createStyles(
|
|
|
123
143
|
position: 'relative',
|
|
124
144
|
},
|
|
125
145
|
input: {
|
|
126
|
-
...theme.fn.fontStyles(),
|
|
127
146
|
height: sizeValue as any,
|
|
128
147
|
fontSize: getSize({ size, sizes: theme.fontSizes }) as any,
|
|
129
148
|
paddingHorizontal: (variant === 'unstyled' ? 0 : rem(12)) as any,
|
|
130
|
-
paddingLeft: (withIcon
|
|
149
|
+
paddingLeft: (withIcon
|
|
150
|
+
? sizeValue
|
|
151
|
+
: variant === 'unstyled'
|
|
152
|
+
? 0
|
|
153
|
+
: rem(12)) as any,
|
|
131
154
|
paddingRight: (withRightSection
|
|
132
155
|
? rem(rightSectionWidth || sizeValue)
|
|
133
156
|
: variant === 'unstyled'
|
|
134
|
-
|
|
135
|
-
|
|
157
|
+
? 0
|
|
158
|
+
: rem(12)) as any,
|
|
136
159
|
borderRadius: theme.fn.radius(radius),
|
|
137
|
-
color:
|
|
160
|
+
color:
|
|
161
|
+
theme.colorScheme === 'dark'
|
|
162
|
+
? (theme.colors.dark || [])[0]
|
|
163
|
+
: theme.black,
|
|
138
164
|
...getVariantStyles(),
|
|
139
165
|
...(invalid && {
|
|
140
166
|
borderColor: (theme.colors.red || [])[6],
|
|
141
167
|
color: (theme.colors.red || [])[6],
|
|
142
168
|
}),
|
|
169
|
+
fontFamily: theme.fontFamilyInput,
|
|
143
170
|
},
|
|
144
171
|
icon: {
|
|
145
172
|
position: 'absolute',
|
|
@@ -171,62 +198,62 @@ const defaultProps: Partial<TextInputProps> = {
|
|
|
171
198
|
required: false,
|
|
172
199
|
};
|
|
173
200
|
|
|
174
|
-
export const TextInput = forwardRef<RNTextInput, TextInputProps>(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
icon,
|
|
182
|
-
rightSection,
|
|
183
|
-
rightSectionWidth,
|
|
184
|
-
required,
|
|
185
|
-
variant,
|
|
186
|
-
style,
|
|
187
|
-
wrapperStyle,
|
|
188
|
-
...others
|
|
189
|
-
} = useComponentDefaultProps('TextInput', defaultProps, props);
|
|
190
|
-
|
|
191
|
-
const { styles, sx} = useStyles(
|
|
192
|
-
{
|
|
201
|
+
export const TextInput = forwardRef<RNTextInput, TextInputProps>(
|
|
202
|
+
(props, ref) => {
|
|
203
|
+
const {
|
|
204
|
+
label,
|
|
205
|
+
description,
|
|
206
|
+
error,
|
|
207
|
+
size,
|
|
193
208
|
radius,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
withRightSection: !!rightSection,
|
|
209
|
+
icon,
|
|
210
|
+
rightSection,
|
|
197
211
|
rightSectionWidth,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
{
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
<BoxView style={styles.rightSectionContainer}>{rightSection}</BoxView>
|
|
212
|
+
required,
|
|
213
|
+
variant,
|
|
214
|
+
style,
|
|
215
|
+
wrapperStyle,
|
|
216
|
+
...others
|
|
217
|
+
} = useComponentDefaultProps('TextInput', defaultProps, props);
|
|
218
|
+
|
|
219
|
+
const { styles, sx } = useStyles(
|
|
220
|
+
{
|
|
221
|
+
radius,
|
|
222
|
+
invalid: !!error,
|
|
223
|
+
withIcon: !!icon,
|
|
224
|
+
withRightSection: !!rightSection,
|
|
225
|
+
rightSectionWidth,
|
|
226
|
+
},
|
|
227
|
+
{ name: 'TextInput', variant, size }
|
|
228
|
+
) as any;
|
|
229
|
+
|
|
230
|
+
return (
|
|
231
|
+
<BoxView style={sx(styles.wrapper, wrapperStyle)}>
|
|
232
|
+
{label && (
|
|
233
|
+
<Text style={styles.label}>
|
|
234
|
+
{label}
|
|
235
|
+
{required && <Text style={styles.required}> *</Text>}
|
|
236
|
+
</Text>
|
|
224
237
|
)}
|
|
225
|
-
</BoxView>
|
|
226
238
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
239
|
+
{description && <Text style={styles.description}>{description}</Text>}
|
|
240
|
+
|
|
241
|
+
<BoxView style={styles.inputWrapper}>
|
|
242
|
+
{icon && <BoxView style={styles.icon}>{icon}</BoxView>}
|
|
243
|
+
|
|
244
|
+
<RNTextInput ref={ref} style={sx(styles.input, style)} {...others} />
|
|
245
|
+
|
|
246
|
+
{rightSection && (
|
|
247
|
+
<BoxView style={styles.rightSectionContainer}>
|
|
248
|
+
{rightSection}
|
|
249
|
+
</BoxView>
|
|
250
|
+
)}
|
|
251
|
+
</BoxView>
|
|
252
|
+
|
|
253
|
+
{error && <Text style={styles.error}>{error}</Text>}
|
|
254
|
+
</BoxView>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
);
|
|
231
258
|
|
|
232
259
|
TextInput.displayName = 'TextInput';
|