@bigbinary/neetoui-rn 0.0.269 → 0.0.270
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/package.json +1 -2
- package/src/components/Accordion.jsx +0 -266
- package/src/components/ActionIcon.jsx +0 -76
- package/src/components/Alert.jsx +0 -262
- package/src/components/AnimatedImage.jsx +0 -140
- package/src/components/Avatar.jsx +0 -144
- package/src/components/Badge.jsx +0 -97
- package/src/components/BottomSheet.jsx +0 -487
- package/src/components/BottomTabBar.jsx +0 -232
- package/src/components/Button.jsx +0 -275
- package/src/components/ButtonGroup.jsx +0 -120
- package/src/components/Calendar.jsx +0 -128
- package/src/components/Card.jsx +0 -90
- package/src/components/Carousel.jsx +0 -116
- package/src/components/ChatInput/AttachmentsView.jsx +0 -51
- package/src/components/ChatInput/Badge.jsx +0 -24
- package/src/components/ChatInput/ChatInput.jsx +0 -564
- package/src/components/ChatInput/EmailFields.jsx +0 -122
- package/src/components/ChatInput/IconButton.jsx +0 -34
- package/src/components/ChatInput/MentionsInputWrapper.jsx +0 -155
- package/src/components/CheckBox.jsx +0 -150
- package/src/components/Chip.jsx +0 -180
- package/src/components/Container.jsx +0 -31
- package/src/components/Divider.jsx +0 -79
- package/src/components/FAB.jsx +0 -113
- package/src/components/FlashList.jsx +0 -189
- package/src/components/FlatList.js +0 -10
- package/src/components/Input.jsx +0 -357
- package/src/components/InputEmailChip.jsx +0 -246
- package/src/components/LineLoader.jsx +0 -46
- package/src/components/ListItem.jsx +0 -68
- package/src/components/Loader.jsx +0 -122
- package/src/components/MultiSelect.jsx +0 -631
- package/src/components/NotificationIcon.jsx +0 -38
- package/src/components/NotificationPreferenceList.jsx +0 -208
- package/src/components/OnBoarding.jsx +0 -134
- package/src/components/OrganizationItem.jsx +0 -110
- package/src/components/OtpInputs.jsx +0 -194
- package/src/components/ParentView.jsx +0 -139
- package/src/components/Popover.jsx +0 -221
- package/src/components/RadioButton.jsx +0 -155
- package/src/components/RichTextEditor.jsx +0 -163
- package/src/components/Ripple.jsx +0 -281
- package/src/components/ScrollView.js +0 -14
- package/src/components/SearchBar.jsx +0 -207
- package/src/components/SegmentedTopBar/Indicator.jsx +0 -77
- package/src/components/SegmentedTopBar/Tab.jsx +0 -37
- package/src/components/SegmentedTopBar/index.jsx +0 -128
- package/src/components/SocialButton.jsx +0 -106
- package/src/components/Toast.jsx +0 -195
- package/src/components/ToggleSwitch.jsx +0 -112
- package/src/components/TopBar.jsx +0 -147
- package/src/components/Touchable.jsx +0 -133
- package/src/components/TouchableWithoutFeedback.jsx +0 -51
- package/src/components/Typography.jsx +0 -93
- package/src/components/index.js +0 -45
- package/src/config/index.js +0 -1
- package/src/config/toasterConfig.jsx +0 -142
- package/src/contexts/index.js +0 -3
- package/src/hooks/index.js +0 -3
- package/src/hooks/useDebounce.js +0 -17
- package/src/hooks/useKeyboard.js +0 -33
- package/src/hooks/useRefreshByUser.js +0 -20
- package/src/index.js +0 -2
- package/src/theme/index.js +0 -181
- package/src/utils/utils.js +0 -56
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import { moderateScale } from "react-native-size-matters";
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
Container,
|
|
8
|
-
Typography,
|
|
9
|
-
Divider,
|
|
10
|
-
ToggleSwitch,
|
|
11
|
-
Loader,
|
|
12
|
-
} from "@components";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* Buttons are touchable elements used to interact with the screen and to trigger an action.
|
|
17
|
-
*
|
|
18
|
-
* <div class="screenshots">
|
|
19
|
-
* <img src="screenshots/notificationPreferenceList/notificationPreferenceList.png" />
|
|
20
|
-
* </div>
|
|
21
|
-
*
|
|
22
|
-
* ## Usage
|
|
23
|
-
* ```js
|
|
24
|
-
* import * as React from 'react';
|
|
25
|
-
* import { Container, NotificationPreferenceList } from '@bigbinary/neetoui-rn';
|
|
26
|
-
*
|
|
27
|
-
* export default function Main() {
|
|
28
|
-
* const [data, setData] = useState([]);
|
|
29
|
-
*
|
|
30
|
-
* const handleSwitch = (item, index) => {
|
|
31
|
-
* setData(prevData => {
|
|
32
|
-
* const newData = [...prevData];
|
|
33
|
-
* newData[index].enabled = !newData[index].enabled;
|
|
34
|
-
* return newData;
|
|
35
|
-
* });
|
|
36
|
-
* };
|
|
37
|
-
|
|
38
|
-
* useEffect(() => {
|
|
39
|
-
* setData([
|
|
40
|
-
* {
|
|
41
|
-
* label: "Preference 1",
|
|
42
|
-
* enabled: true,
|
|
43
|
-
* onSwitch: handleSwitch,
|
|
44
|
-
* },
|
|
45
|
-
* {
|
|
46
|
-
* label: "Preference 2",
|
|
47
|
-
* enabled: true,
|
|
48
|
-
* onSwitch: handleSwitch,
|
|
49
|
-
* },
|
|
50
|
-
* {
|
|
51
|
-
* label: "Preference 3",
|
|
52
|
-
* enabled: false,
|
|
53
|
-
* onSwitch: handleSwitch,
|
|
54
|
-
* },
|
|
55
|
-
* {
|
|
56
|
-
* label: "Preference 4",
|
|
57
|
-
* enabled: false,
|
|
58
|
-
* onSwitch: handleSwitch,
|
|
59
|
-
* },
|
|
60
|
-
* {
|
|
61
|
-
* label: "Preference 5",
|
|
62
|
-
* enabled: false,
|
|
63
|
-
* onSwitch: handleSwitch,
|
|
64
|
-
* LeftIcon: () => (
|
|
65
|
-
* <Icon
|
|
66
|
-
* name="ri-notification-2-line"
|
|
67
|
-
* size={moderateScale(20)}
|
|
68
|
-
* color={theme.colors.font.secondary}
|
|
69
|
-
* />
|
|
70
|
-
* ),
|
|
71
|
-
* },
|
|
72
|
-
* ]);
|
|
73
|
-
* }, []);
|
|
74
|
-
|
|
75
|
-
* return (
|
|
76
|
-
* <Container flex={1} alignItems="center" justifyContent="center">
|
|
77
|
-
* {data && <NotificationPreferenceList data={data} />}
|
|
78
|
-
* </Container>
|
|
79
|
-
* );
|
|
80
|
-
* }
|
|
81
|
-
* ```
|
|
82
|
-
*
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
const lineHeight = moderateScale(22);
|
|
86
|
-
export const NotificationPreferenceList = ({
|
|
87
|
-
isLoading,
|
|
88
|
-
data,
|
|
89
|
-
itemWrapperProps,
|
|
90
|
-
itemContainerProps,
|
|
91
|
-
labelContainerProps,
|
|
92
|
-
labelProps,
|
|
93
|
-
title,
|
|
94
|
-
titleProps,
|
|
95
|
-
...rest
|
|
96
|
-
}) => (
|
|
97
|
-
<Container width="100%">
|
|
98
|
-
<Container
|
|
99
|
-
alignItems="center"
|
|
100
|
-
flexDirection="row"
|
|
101
|
-
pb={moderateScale(8)}
|
|
102
|
-
pt={moderateScale(20)}
|
|
103
|
-
>
|
|
104
|
-
{!!title && (
|
|
105
|
-
<Typography
|
|
106
|
-
color="font.grey600"
|
|
107
|
-
fontSize="m"
|
|
108
|
-
lineHeight={`${lineHeight}px`}
|
|
109
|
-
{...titleProps}
|
|
110
|
-
>
|
|
111
|
-
{title}
|
|
112
|
-
</Typography>
|
|
113
|
-
)}
|
|
114
|
-
{isLoading && (
|
|
115
|
-
<Container
|
|
116
|
-
height={lineHeight}
|
|
117
|
-
justifyContent="center"
|
|
118
|
-
mx={moderateScale(8)}
|
|
119
|
-
>
|
|
120
|
-
<Loader />
|
|
121
|
-
</Container>
|
|
122
|
-
)}
|
|
123
|
-
</Container>
|
|
124
|
-
<Container
|
|
125
|
-
bg="background.secondary"
|
|
126
|
-
borderRadius={moderateScale(8)}
|
|
127
|
-
{...rest}
|
|
128
|
-
>
|
|
129
|
-
{data?.map((item, index) => {
|
|
130
|
-
const { label, enabled, onSwitch, LeftIcon } = item;
|
|
131
|
-
const isLastItem = index === data.length - 1;
|
|
132
|
-
|
|
133
|
-
return (
|
|
134
|
-
<Container key={index} px={moderateScale(16)} {...itemWrapperProps}>
|
|
135
|
-
<Container
|
|
136
|
-
alignItems="center"
|
|
137
|
-
flexDirection="row"
|
|
138
|
-
justifyContent="space-between"
|
|
139
|
-
py={moderateScale(12)}
|
|
140
|
-
{...itemContainerProps}
|
|
141
|
-
>
|
|
142
|
-
<Container
|
|
143
|
-
alignItems="center"
|
|
144
|
-
flex={1}
|
|
145
|
-
flexDirection="row"
|
|
146
|
-
{...labelContainerProps}
|
|
147
|
-
>
|
|
148
|
-
{LeftIcon && (
|
|
149
|
-
<Container mr={moderateScale(8)}>
|
|
150
|
-
<LeftIcon />
|
|
151
|
-
</Container>
|
|
152
|
-
)}
|
|
153
|
-
<Typography
|
|
154
|
-
flex={1}
|
|
155
|
-
fontSize="l"
|
|
156
|
-
mr={moderateScale(8)}
|
|
157
|
-
{...labelProps}
|
|
158
|
-
>
|
|
159
|
-
{label}
|
|
160
|
-
</Typography>
|
|
161
|
-
</Container>
|
|
162
|
-
<ToggleSwitch
|
|
163
|
-
value={enabled}
|
|
164
|
-
onValueChange={() => onSwitch(item, index)}
|
|
165
|
-
/>
|
|
166
|
-
</Container>
|
|
167
|
-
{!isLastItem && <Divider bg="background.grey300" />}
|
|
168
|
-
</Container>
|
|
169
|
-
);
|
|
170
|
-
})}
|
|
171
|
-
</Container>
|
|
172
|
-
</Container>
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
NotificationPreferenceList.propTypes = {
|
|
176
|
-
/**
|
|
177
|
-
* Array of preference list
|
|
178
|
-
*/
|
|
179
|
-
data: PropTypes.array.isRequired,
|
|
180
|
-
/**
|
|
181
|
-
* Customize outer container for each item
|
|
182
|
-
*/
|
|
183
|
-
itemWrapperProps: PropTypes.object,
|
|
184
|
-
/**
|
|
185
|
-
* Customize inner container for each item
|
|
186
|
-
*/
|
|
187
|
-
itemContainerProps: PropTypes.object,
|
|
188
|
-
/**
|
|
189
|
-
* Customize container for each item label
|
|
190
|
-
*/
|
|
191
|
-
labelContainerProps: PropTypes.object,
|
|
192
|
-
/**
|
|
193
|
-
* Customize item label
|
|
194
|
-
*/
|
|
195
|
-
labelProps: PropTypes.object,
|
|
196
|
-
/**
|
|
197
|
-
* Title value.
|
|
198
|
-
*/
|
|
199
|
-
title: PropTypes.string,
|
|
200
|
-
/**
|
|
201
|
-
* Customize title style.
|
|
202
|
-
*/
|
|
203
|
-
titleProps: PropTypes.string,
|
|
204
|
-
/**
|
|
205
|
-
* Show loader
|
|
206
|
-
*/
|
|
207
|
-
isLoading: PropTypes.bool,
|
|
208
|
-
};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
|
-
import { moderateScale } from "react-native-size-matters";
|
|
6
|
-
|
|
7
|
-
import { Button, Carousel, Container, Typography } from "@components";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* <div class="screenshots">
|
|
12
|
-
* <img src="screenshots/onboarding/onboarding.png" />
|
|
13
|
-
* </div>
|
|
14
|
-
*
|
|
15
|
-
* This component supports below props categories from [styled-system ](/styled-system).
|
|
16
|
-
* <ul>
|
|
17
|
-
* <li>flexbox</li>
|
|
18
|
-
* <li>space</li>
|
|
19
|
-
* <li>border</li>
|
|
20
|
-
* <li>layout</li>
|
|
21
|
-
* <li>color</li>
|
|
22
|
-
* <li>buttonStyle</li>
|
|
23
|
-
* </ul>
|
|
24
|
-
*
|
|
25
|
-
* ## Usage
|
|
26
|
-
* ```js
|
|
27
|
-
* import * as React from "react";
|
|
28
|
-
* import { moderateScale } from "react-native-size-matters";
|
|
29
|
-
* import { OnBoarding } from "@bigbinary/neetoui-rn";
|
|
30
|
-
*
|
|
31
|
-
* export default function Main() {
|
|
32
|
-
*
|
|
33
|
-
* return (
|
|
34
|
-
* <OnBoarding
|
|
35
|
-
* appLogo={Neeto}
|
|
36
|
-
* slides={[
|
|
37
|
-
* {title: "Welcome to neetoInovice", description: "Enter your daily ...", illustration:""},
|
|
38
|
-
* {title: "", description: "", illustration:""}
|
|
39
|
-
* ]}
|
|
40
|
-
* onComplete={() =>{ console.log("Completed");}}
|
|
41
|
-
* />
|
|
42
|
-
* );
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
export const OnBoarding = ({
|
|
49
|
-
appLogo: AppLogo,
|
|
50
|
-
slides,
|
|
51
|
-
onComplete,
|
|
52
|
-
logoWidth = moderateScale(150),
|
|
53
|
-
}) => {
|
|
54
|
-
const [activeIndex, setActiveIndex] = useState(0);
|
|
55
|
-
const onBoardingRef = useRef();
|
|
56
|
-
const { bottom } = useSafeAreaInsets();
|
|
57
|
-
|
|
58
|
-
const handleOnPress = () => {
|
|
59
|
-
if (activeIndex !== slides.length - 1) {
|
|
60
|
-
onBoardingRef.current.snapToNext();
|
|
61
|
-
setActiveIndex(onBoardingRef.current._activeItem);
|
|
62
|
-
} else onComplete();
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const renderItem = ({ item }) => (
|
|
66
|
-
<Container flex={1} justifyContent="space-between">
|
|
67
|
-
<Container
|
|
68
|
-
alignItems="center"
|
|
69
|
-
flex={1}
|
|
70
|
-
justifyContent="center"
|
|
71
|
-
mx={moderateScale(24)}
|
|
72
|
-
my={moderateScale(12)}
|
|
73
|
-
>
|
|
74
|
-
{item.illustration}
|
|
75
|
-
</Container>
|
|
76
|
-
<Container
|
|
77
|
-
alignItems="center"
|
|
78
|
-
mx={moderateScale(24)}
|
|
79
|
-
my={moderateScale(12)}
|
|
80
|
-
>
|
|
81
|
-
<Typography
|
|
82
|
-
color="font.grey800"
|
|
83
|
-
fontFamily="sf700"
|
|
84
|
-
fontSize="4xl"
|
|
85
|
-
textAlign="center"
|
|
86
|
-
>
|
|
87
|
-
{item.title}
|
|
88
|
-
</Typography>
|
|
89
|
-
<Typography
|
|
90
|
-
color="font.grey500"
|
|
91
|
-
fontFamily="sf400"
|
|
92
|
-
fontSize="l"
|
|
93
|
-
textAlign="center"
|
|
94
|
-
>
|
|
95
|
-
{item.description}
|
|
96
|
-
</Typography>
|
|
97
|
-
</Container>
|
|
98
|
-
</Container>
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<Container bg="background.white" flex={1}>
|
|
103
|
-
<Container alignItems="center">
|
|
104
|
-
<AppLogo width={logoWidth} />
|
|
105
|
-
</Container>
|
|
106
|
-
<Container alignItems="center" flex={1}>
|
|
107
|
-
<Carousel
|
|
108
|
-
carouselRef={onBoardingRef}
|
|
109
|
-
itemArray={slides}
|
|
110
|
-
renderItem={renderItem}
|
|
111
|
-
onSnapToItem={index => {
|
|
112
|
-
setActiveIndex(index);
|
|
113
|
-
}}
|
|
114
|
-
/>
|
|
115
|
-
</Container>
|
|
116
|
-
<Container
|
|
117
|
-
mb={bottom === 0 ? moderateScale(16) : 0}
|
|
118
|
-
mx={moderateScale(24)}
|
|
119
|
-
>
|
|
120
|
-
<Button
|
|
121
|
-
label={activeIndex !== slides.length - 1 ? "Next" : "Get Started"}
|
|
122
|
-
onPress={handleOnPress}
|
|
123
|
-
/>
|
|
124
|
-
</Container>
|
|
125
|
-
</Container>
|
|
126
|
-
);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
OnBoarding.propTypes = {
|
|
130
|
-
appLogo: PropTypes.func.isRequired,
|
|
131
|
-
slides: PropTypes.array.isRequired,
|
|
132
|
-
onComplete: PropTypes.func.isRequired,
|
|
133
|
-
logoWidth: PropTypes.number,
|
|
134
|
-
};
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Linking } from "react-native";
|
|
3
|
-
|
|
4
|
-
import PropTypes from "prop-types";
|
|
5
|
-
import { moderateScale } from "react-native-size-matters";
|
|
6
|
-
|
|
7
|
-
import { Container, Typography } from "@components";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* Buttons are touchable elements used to interact with the screen and to trigger an action.
|
|
12
|
-
*
|
|
13
|
-
* <div class="screenshots">
|
|
14
|
-
* <img src="screenshots/organizationItem/organizationItem.png" />
|
|
15
|
-
* </div>
|
|
16
|
-
*
|
|
17
|
-
* ## Usage
|
|
18
|
-
* ```js
|
|
19
|
-
* import * as React from 'react';
|
|
20
|
-
* import { OrganizationItem } from '@bigbinary/neetoui-rn';
|
|
21
|
-
*
|
|
22
|
-
* export default function Main() {
|
|
23
|
-
* return (
|
|
24
|
-
* <OrganizationItem name="BigBinary Solutions Pvt. Ltd." />
|
|
25
|
-
* );
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
export const OrganizationItem = ({
|
|
32
|
-
label,
|
|
33
|
-
labelContainerProps,
|
|
34
|
-
labelProps,
|
|
35
|
-
name,
|
|
36
|
-
nameProps,
|
|
37
|
-
subdomain,
|
|
38
|
-
subdomainProps,
|
|
39
|
-
...rest
|
|
40
|
-
}) => (
|
|
41
|
-
<Container
|
|
42
|
-
bg="background.secondary"
|
|
43
|
-
borderRadius={moderateScale(6)}
|
|
44
|
-
justifyContent="space-between"
|
|
45
|
-
px={moderateScale(12)}
|
|
46
|
-
py={moderateScale(12)}
|
|
47
|
-
width="100%"
|
|
48
|
-
{...rest}
|
|
49
|
-
>
|
|
50
|
-
<Container alignItems="center" flexDirection="row" {...labelContainerProps}>
|
|
51
|
-
<Typography
|
|
52
|
-
color="font.grey800"
|
|
53
|
-
fontFamily="sf500"
|
|
54
|
-
fontSize="s"
|
|
55
|
-
{...labelProps}
|
|
56
|
-
>
|
|
57
|
-
{label || "Organization"}
|
|
58
|
-
</Typography>
|
|
59
|
-
</Container>
|
|
60
|
-
<Typography
|
|
61
|
-
color="font.grey"
|
|
62
|
-
fontFamily="sf500"
|
|
63
|
-
fontSize="m"
|
|
64
|
-
mt="8px"
|
|
65
|
-
{...nameProps}
|
|
66
|
-
>
|
|
67
|
-
{name}
|
|
68
|
-
</Typography>
|
|
69
|
-
<Typography
|
|
70
|
-
color="font.grey"
|
|
71
|
-
fontFamily="sf500"
|
|
72
|
-
fontSize="m"
|
|
73
|
-
onPress={() => Linking.openURL(`https://${subdomain}`)}
|
|
74
|
-
{...subdomainProps}
|
|
75
|
-
>
|
|
76
|
-
{subdomain}
|
|
77
|
-
</Typography>
|
|
78
|
-
</Container>
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
OrganizationItem.propTypes = {
|
|
82
|
-
/**
|
|
83
|
-
* Organization label
|
|
84
|
-
*/
|
|
85
|
-
label: PropTypes.string,
|
|
86
|
-
/**
|
|
87
|
-
* Customize label container
|
|
88
|
-
*/
|
|
89
|
-
labelContainerProps: PropTypes.object,
|
|
90
|
-
/**
|
|
91
|
-
* Customize label
|
|
92
|
-
*/
|
|
93
|
-
labelProps: PropTypes.object,
|
|
94
|
-
/**
|
|
95
|
-
* Organization name
|
|
96
|
-
*/
|
|
97
|
-
name: PropTypes.string.isRequired,
|
|
98
|
-
/**
|
|
99
|
-
* Customize name
|
|
100
|
-
*/
|
|
101
|
-
nameProps: PropTypes.object,
|
|
102
|
-
/**
|
|
103
|
-
* Subdomain
|
|
104
|
-
*/
|
|
105
|
-
subdomain: PropTypes.string.isRequired,
|
|
106
|
-
/**
|
|
107
|
-
* Customize Subdomain
|
|
108
|
-
*/
|
|
109
|
-
subdomainProps: PropTypes.object,
|
|
110
|
-
};
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
2
|
-
import { InteractionManager, Keyboard } from "react-native";
|
|
3
|
-
|
|
4
|
-
import PropTypes from "prop-types";
|
|
5
|
-
import { moderateScale } from "react-native-size-matters";
|
|
6
|
-
import styled from "styled-components/native";
|
|
7
|
-
import {
|
|
8
|
-
flexbox,
|
|
9
|
-
space,
|
|
10
|
-
border,
|
|
11
|
-
buttonStyle,
|
|
12
|
-
typography,
|
|
13
|
-
color,
|
|
14
|
-
} from "styled-system";
|
|
15
|
-
|
|
16
|
-
import { Container, Typography } from "@components";
|
|
17
|
-
|
|
18
|
-
import { theme } from "../theme";
|
|
19
|
-
|
|
20
|
-
const TextInput = styled.TextInput`
|
|
21
|
-
${flexbox}
|
|
22
|
-
${space}
|
|
23
|
-
${border}
|
|
24
|
-
${buttonStyle}
|
|
25
|
-
${typography}
|
|
26
|
-
${color}
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
const styles = {
|
|
30
|
-
inputStyles: {
|
|
31
|
-
fontSize: 0,
|
|
32
|
-
backgroundColor: "transparent",
|
|
33
|
-
color: "transparent",
|
|
34
|
-
width: "100%",
|
|
35
|
-
height: "100%",
|
|
36
|
-
position: "absolute",
|
|
37
|
-
},
|
|
38
|
-
defaultContainerStyles: {
|
|
39
|
-
margin: moderateScale(2),
|
|
40
|
-
borderRadius: moderateScale(8),
|
|
41
|
-
backgroundColor: theme.colors.background.white,
|
|
42
|
-
justifyContent: "center",
|
|
43
|
-
alignItems: "center",
|
|
44
|
-
minHeight: moderateScale(42),
|
|
45
|
-
minWidth: moderateScale(42),
|
|
46
|
-
},
|
|
47
|
-
defaultTextStyles: {
|
|
48
|
-
fontSize: theme.fontSizes.xl,
|
|
49
|
-
fontFamily: theme.fonts.sf700,
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
55
|
-
* One-Time password input component.
|
|
56
|
-
*
|
|
57
|
-
* <div class="screenshots">
|
|
58
|
-
* <img src="screenshots/otp/otp.png" />
|
|
59
|
-
* </div>
|
|
60
|
-
*
|
|
61
|
-
* ## Usage
|
|
62
|
-
* ```js
|
|
63
|
-
* import * as React from 'react';
|
|
64
|
-
* import { Container, OtpInputs, Typography} from '@bigbinary/neetoui-rn';
|
|
65
|
-
*
|
|
66
|
-
* export default function Main() {
|
|
67
|
-
* const [code, setCode] = useState("");
|
|
68
|
-
* return (
|
|
69
|
-
* <Container flex={1} justifyContent="center" alignItems="center">
|
|
70
|
-
* <OtpInputs code={code} numberOfInputs={6} handleChange={setCode} />
|
|
71
|
-
* <Typography py={moderateScale(10)} fontSize="xl">
|
|
72
|
-
* {`Your entered OTP is ${code}`}
|
|
73
|
-
* </Typography>
|
|
74
|
-
* </Container>
|
|
75
|
-
* );
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
export const OtpInputs = ({
|
|
80
|
-
handleChange = () => {},
|
|
81
|
-
numberOfInputs = 4,
|
|
82
|
-
error = false,
|
|
83
|
-
code = "",
|
|
84
|
-
containerStyles,
|
|
85
|
-
textStyles,
|
|
86
|
-
}) => {
|
|
87
|
-
const inputRef = React.useRef();
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
// Must run after animations for keyboard to automatically open
|
|
90
|
-
InteractionManager.runAfterInteractions(() => {
|
|
91
|
-
if (inputRef?.current) {
|
|
92
|
-
inputRef.current.focus();
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}, [inputRef]);
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<Container>
|
|
99
|
-
<Container
|
|
100
|
-
alignItems="center"
|
|
101
|
-
flexDirection="row"
|
|
102
|
-
justifyContent="center"
|
|
103
|
-
onTouchEnd={() => {
|
|
104
|
-
Keyboard.dismiss();
|
|
105
|
-
inputRef && inputRef.current.focus();
|
|
106
|
-
}}
|
|
107
|
-
>
|
|
108
|
-
{Array(numberOfInputs)
|
|
109
|
-
.fill()
|
|
110
|
-
.map((_number, index) => (
|
|
111
|
-
<Container
|
|
112
|
-
key={index}
|
|
113
|
-
borderColor={
|
|
114
|
-
code.length - 1 === index
|
|
115
|
-
? theme.colors.border.purple500
|
|
116
|
-
: theme.colors.border.secondary
|
|
117
|
-
}
|
|
118
|
-
borderWidth={
|
|
119
|
-
code.length - 1 === index
|
|
120
|
-
? moderateScale(1.5)
|
|
121
|
-
: moderateScale(1)
|
|
122
|
-
}
|
|
123
|
-
{...styles.defaultContainerStyles}
|
|
124
|
-
{...containerStyles}
|
|
125
|
-
>
|
|
126
|
-
<Typography
|
|
127
|
-
accessibilityLabel="otp"
|
|
128
|
-
color={
|
|
129
|
-
error ? theme.colors.font.danger : theme.colors.font.purple500
|
|
130
|
-
}
|
|
131
|
-
{...styles.defaultTextStyles}
|
|
132
|
-
{...textStyles}
|
|
133
|
-
>
|
|
134
|
-
{code[index] || ""}
|
|
135
|
-
</Typography>
|
|
136
|
-
</Container>
|
|
137
|
-
))}
|
|
138
|
-
<TextInput
|
|
139
|
-
autoFocus
|
|
140
|
-
keyboardType="phone-pad"
|
|
141
|
-
ref={inputRef}
|
|
142
|
-
selectionColor="transparent"
|
|
143
|
-
value={code || ""}
|
|
144
|
-
onChangeText={value => {
|
|
145
|
-
if (!isNaN(value)) {
|
|
146
|
-
if (value.length <= numberOfInputs) {
|
|
147
|
-
handleChange && handleChange(value);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (value.length >= numberOfInputs) {
|
|
151
|
-
return Keyboard.dismiss();
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return null;
|
|
156
|
-
}}
|
|
157
|
-
{...styles.inputStyles}
|
|
158
|
-
/>
|
|
159
|
-
</Container>
|
|
160
|
-
</Container>
|
|
161
|
-
);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
OtpInputs.defaultProps = {
|
|
165
|
-
containerStyles: {},
|
|
166
|
-
textStyles: {},
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
OtpInputs.propTypes = {
|
|
170
|
-
/**
|
|
171
|
-
* This would be OTP code.
|
|
172
|
-
*/
|
|
173
|
-
code: PropTypes.string.isRequired,
|
|
174
|
-
/**
|
|
175
|
-
* Number of Input Fields.
|
|
176
|
-
*/
|
|
177
|
-
numberOfInputs: PropTypes.number.isRequired,
|
|
178
|
-
/**
|
|
179
|
-
* Callback called when code is changed.
|
|
180
|
-
*/
|
|
181
|
-
handleChange: PropTypes.func.isRequired,
|
|
182
|
-
/**
|
|
183
|
-
* If true, code will be shown in red color.
|
|
184
|
-
*/
|
|
185
|
-
error: PropTypes.bool,
|
|
186
|
-
/**
|
|
187
|
-
* To change the styles of main container.
|
|
188
|
-
*/
|
|
189
|
-
containerStyles: PropTypes.object,
|
|
190
|
-
/**
|
|
191
|
-
* To change the styles of OTP text.
|
|
192
|
-
*/
|
|
193
|
-
textStyles: PropTypes.object,
|
|
194
|
-
};
|