@bigbinary/neetoui-rn 0.0.268 → 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 +2 -3
- 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,139 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from "react";
|
|
2
|
-
import { Keyboard, StatusBar } from "react-native";
|
|
3
|
-
|
|
4
|
-
import PropTypes from "prop-types";
|
|
5
|
-
import {
|
|
6
|
-
SafeAreaView,
|
|
7
|
-
useSafeAreaInsets,
|
|
8
|
-
} from "react-native-safe-area-context";
|
|
9
|
-
import { ThemeContext } from "styled-components/native";
|
|
10
|
-
|
|
11
|
-
import { Container } from "@components";
|
|
12
|
-
|
|
13
|
-
import { useKeyboard } from "../hooks/useKeyboard";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
*ParentView wraps the children with SafeAreaView.
|
|
17
|
-
*
|
|
18
|
-
* ## Usage
|
|
19
|
-
* ```js
|
|
20
|
-
* import * as React from "react";
|
|
21
|
-
* import { moderateScale } from "react-native-size-matters";
|
|
22
|
-
* import { Typography, ParentView } from "@bigbinary/neetoui-rn";
|
|
23
|
-
*
|
|
24
|
-
*export default function Main() {
|
|
25
|
-
* return (
|
|
26
|
-
* <ParentView>
|
|
27
|
-
* <Typography> This is wrapped in ParentView</Typography>
|
|
28
|
-
* </ParentView>
|
|
29
|
-
* );
|
|
30
|
-
*}
|
|
31
|
-
*
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
export const ParentView = ({
|
|
36
|
-
barStyle = "light-content",
|
|
37
|
-
children,
|
|
38
|
-
backgroundColor,
|
|
39
|
-
bg,
|
|
40
|
-
topInset = true,
|
|
41
|
-
rightInset = true,
|
|
42
|
-
leftInset = true,
|
|
43
|
-
bottomInset = true,
|
|
44
|
-
shouldDismissKeyboardOnTap = true,
|
|
45
|
-
...rest
|
|
46
|
-
}) => {
|
|
47
|
-
const theme = useContext(ThemeContext);
|
|
48
|
-
const keyboardHeight = useKeyboard();
|
|
49
|
-
|
|
50
|
-
const safeAreaViewProps = {
|
|
51
|
-
edges: [
|
|
52
|
-
...(topInset ? ["top"] : []),
|
|
53
|
-
...(rightInset ? ["right"] : []),
|
|
54
|
-
...(leftInset ? ["left"] : []),
|
|
55
|
-
],
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const newBackgroundColor =
|
|
59
|
-
backgroundColor || bg || theme.colors.background.parentView;
|
|
60
|
-
|
|
61
|
-
const statusBarColors = {
|
|
62
|
-
default: theme.colors.background.white,
|
|
63
|
-
"dark-content": theme.colors.background.white,
|
|
64
|
-
"light-content": theme.colors.background.base,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const statusBarColor =
|
|
68
|
-
statusBarColors[barStyle] || statusBarColors["default"];
|
|
69
|
-
|
|
70
|
-
const insets = useSafeAreaInsets();
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<SafeAreaView
|
|
74
|
-
flex={1}
|
|
75
|
-
{...safeAreaViewProps}
|
|
76
|
-
style={{ backgroundColor: statusBarColor }}
|
|
77
|
-
>
|
|
78
|
-
<StatusBar backgroundColor={statusBarColor} barStyle={barStyle} />
|
|
79
|
-
<Container
|
|
80
|
-
{...(shouldDismissKeyboardOnTap
|
|
81
|
-
? {
|
|
82
|
-
onTouchStart: e => {
|
|
83
|
-
if (
|
|
84
|
-
keyboardHeight &&
|
|
85
|
-
e?.target?._internalFiberInstanceHandleDEV?.elementType?.indexOf(
|
|
86
|
-
"TextInput"
|
|
87
|
-
) === -1
|
|
88
|
-
) {
|
|
89
|
-
Keyboard.dismiss();
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
}
|
|
93
|
-
: {})}
|
|
94
|
-
backgroundColor={newBackgroundColor}
|
|
95
|
-
flex={1}
|
|
96
|
-
{...rest}
|
|
97
|
-
{...(bottomInset && { pb: insets.bottom })}
|
|
98
|
-
>
|
|
99
|
-
{children}
|
|
100
|
-
</Container>
|
|
101
|
-
</SafeAreaView>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
ParentView.propTypes = {
|
|
106
|
-
/**
|
|
107
|
-
* Sets the color of the status bar text.
|
|
108
|
-
*/
|
|
109
|
-
barStyle: PropTypes.string,
|
|
110
|
-
children: PropTypes.node,
|
|
111
|
-
/**
|
|
112
|
-
* Sets the background color
|
|
113
|
-
*/
|
|
114
|
-
backgroundColor: PropTypes.string,
|
|
115
|
-
/**
|
|
116
|
-
* Sets the background color
|
|
117
|
-
*/
|
|
118
|
-
bg: PropTypes.string,
|
|
119
|
-
/**
|
|
120
|
-
* Sets Top Inset
|
|
121
|
-
*/
|
|
122
|
-
topInset: PropTypes.bool,
|
|
123
|
-
/**
|
|
124
|
-
* Sets Right Inset
|
|
125
|
-
*/
|
|
126
|
-
rightInset: PropTypes.bool,
|
|
127
|
-
/**
|
|
128
|
-
* Sets Left Inset
|
|
129
|
-
*/
|
|
130
|
-
leftInset: PropTypes.bool,
|
|
131
|
-
/**
|
|
132
|
-
* Sets Bottom Inset
|
|
133
|
-
*/
|
|
134
|
-
bottomInset: PropTypes.bool,
|
|
135
|
-
/**
|
|
136
|
-
* Dismiss keyboard on tap
|
|
137
|
-
*/
|
|
138
|
-
shouldDismissKeyboardOnTap: PropTypes.bool,
|
|
139
|
-
};
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from "react";
|
|
2
|
-
import { StyleSheet } from "react-native";
|
|
3
|
-
|
|
4
|
-
import PropTypes from "prop-types";
|
|
5
|
-
import OriginalPopover from "react-native-popover-view";
|
|
6
|
-
import { moderateScale } from "react-native-size-matters";
|
|
7
|
-
import styled from "styled-components/native";
|
|
8
|
-
import { flexbox, space, border, color, layout } from "styled-system";
|
|
9
|
-
|
|
10
|
-
import { Typography, Divider } from "@components";
|
|
11
|
-
|
|
12
|
-
export const TouchableOpacity = styled.TouchableOpacity`
|
|
13
|
-
${space}
|
|
14
|
-
${border}
|
|
15
|
-
${color}
|
|
16
|
-
${flexbox}
|
|
17
|
-
${layout}
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
const PopOverItem = ({
|
|
21
|
-
item,
|
|
22
|
-
onPress,
|
|
23
|
-
fontFamily,
|
|
24
|
-
fontSize,
|
|
25
|
-
shouldShowDivider,
|
|
26
|
-
}) => {
|
|
27
|
-
const { Icon, label, labelProps } = item;
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<>
|
|
31
|
-
<TouchableOpacity
|
|
32
|
-
alignItems="center"
|
|
33
|
-
flexDirection="row"
|
|
34
|
-
p={moderateScale(2)}
|
|
35
|
-
px={moderateScale(8)}
|
|
36
|
-
py={moderateScale(8)}
|
|
37
|
-
onPress={onPress}
|
|
38
|
-
>
|
|
39
|
-
<Icon />
|
|
40
|
-
<Typography
|
|
41
|
-
fontColor="font.primary"
|
|
42
|
-
fontFamily={fontFamily}
|
|
43
|
-
fontSize={fontSize}
|
|
44
|
-
px={moderateScale(2)}
|
|
45
|
-
{...labelProps}
|
|
46
|
-
>
|
|
47
|
-
{label}
|
|
48
|
-
</Typography>
|
|
49
|
-
</TouchableOpacity>
|
|
50
|
-
{shouldShowDivider && (
|
|
51
|
-
<Divider backgroundColor="background.grey200" mx={moderateScale(8)} />
|
|
52
|
-
)}
|
|
53
|
-
</>
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
PopOverItem.propTypes = {
|
|
58
|
-
shouldShowDivider: PropTypes.bool,
|
|
59
|
-
item: PropTypes.object,
|
|
60
|
-
onPress: PropTypes.func,
|
|
61
|
-
fontFamily: PropTypes.string,
|
|
62
|
-
fontSize: PropTypes.oneOfType([
|
|
63
|
-
PropTypes.number,
|
|
64
|
-
PropTypes.oneOf([
|
|
65
|
-
"3xs",
|
|
66
|
-
"2xs",
|
|
67
|
-
"xs",
|
|
68
|
-
"s",
|
|
69
|
-
"m",
|
|
70
|
-
"l",
|
|
71
|
-
"xl",
|
|
72
|
-
"2xl",
|
|
73
|
-
"3xl",
|
|
74
|
-
"4xl",
|
|
75
|
-
"5xl",
|
|
76
|
-
]),
|
|
77
|
-
]),
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
* A Lightweight Popover component over [react-native-popover-view](https://www.npmjs.com/package/react-native-popover-view) which can be rendered with array of data or with custom body.
|
|
83
|
-
*
|
|
84
|
-
* <div class="screenshots">
|
|
85
|
-
* <img src="screenshots/popover/popover.png" />
|
|
86
|
-
* </div>
|
|
87
|
-
*
|
|
88
|
-
* ## Usage
|
|
89
|
-
* ```js
|
|
90
|
-
* import * as React from 'react';
|
|
91
|
-
* import { Text } from "react-native";
|
|
92
|
-
* import { Container, Button, Popover } from '@bigbinary/neetoui-rn';
|
|
93
|
-
* import { ThemeContext } from "styled-components/native";
|
|
94
|
-
*
|
|
95
|
-
* export default function Main(){
|
|
96
|
-
* const theme = useContext(ThemeContext);
|
|
97
|
-
* const data = [
|
|
98
|
-
* {
|
|
99
|
-
* label: "Search Product",
|
|
100
|
-
* Icon: () => {
|
|
101
|
-
* return (
|
|
102
|
-
* <Icon
|
|
103
|
-
* name="ri-search-line"
|
|
104
|
-
* size={moderateScale(20)}
|
|
105
|
-
* color={theme.colors.background.grey800}
|
|
106
|
-
* />
|
|
107
|
-
* );
|
|
108
|
-
* },
|
|
109
|
-
* onPress: () => {
|
|
110
|
-
* alert("Clicked here");
|
|
111
|
-
* },
|
|
112
|
-
* },
|
|
113
|
-
* {
|
|
114
|
-
* label: "Create Product",
|
|
115
|
-
* Icon: () => {
|
|
116
|
-
* return (
|
|
117
|
-
* <Icon
|
|
118
|
-
* name="ri-search-line"
|
|
119
|
-
* size={moderateScale(20)}
|
|
120
|
-
* color={theme.colors.background.grey800}
|
|
121
|
-
* />
|
|
122
|
-
* );
|
|
123
|
-
* },
|
|
124
|
-
* onPress: () => {
|
|
125
|
-
* alert("Clicked here");
|
|
126
|
-
* },
|
|
127
|
-
* },
|
|
128
|
-
* ];
|
|
129
|
-
*
|
|
130
|
-
* return (
|
|
131
|
-
* <Container flex={1} alignItems="center" justifyContent="center">
|
|
132
|
-
* <Container p={moderateScale(2)}>
|
|
133
|
-
* <Popover data={data} from={<Button label="With Data" />} />
|
|
134
|
-
* </Container>
|
|
135
|
-
* <Container p={moderateScale(2)}>
|
|
136
|
-
* <Popover from={<Button label="With Custom Popup Content" />}>
|
|
137
|
-
*
|
|
138
|
-
* <Container bg="background.white" flex={1}>
|
|
139
|
-
* <Text>This is the contents of the popover</Text>
|
|
140
|
-
* </Container>
|
|
141
|
-
* </Popover>
|
|
142
|
-
* </Container>
|
|
143
|
-
*
|
|
144
|
-
* <Container p={moderateScale(2)}>
|
|
145
|
-
* <Popover
|
|
146
|
-
* data={data}
|
|
147
|
-
* from={<Button label="With Custom Popup Content and data" />}
|
|
148
|
-
* >
|
|
149
|
-
* <Container bg="background.white" flex={1}>
|
|
150
|
-
* <Text>This is the contents of the popover</Text>
|
|
151
|
-
* </Container>
|
|
152
|
-
* </Popover>
|
|
153
|
-
* </Container>
|
|
154
|
-
* </Container>
|
|
155
|
-
* );
|
|
156
|
-
* }
|
|
157
|
-
* ```
|
|
158
|
-
*/
|
|
159
|
-
|
|
160
|
-
export const Popover = ({
|
|
161
|
-
children,
|
|
162
|
-
data,
|
|
163
|
-
fontFamily = null,
|
|
164
|
-
fontSize = "l",
|
|
165
|
-
...rest
|
|
166
|
-
}) => {
|
|
167
|
-
const popoverRef = useRef();
|
|
168
|
-
const onPressItemRef = useRef(() => {});
|
|
169
|
-
|
|
170
|
-
return (
|
|
171
|
-
<OriginalPopover
|
|
172
|
-
popoverStyle={styles.popoverStyle}
|
|
173
|
-
ref={popoverRef}
|
|
174
|
-
onCloseComplete={() => onPressItemRef.current()}
|
|
175
|
-
onOpenStart={() => {
|
|
176
|
-
onPressItemRef.current = () => {};
|
|
177
|
-
}}
|
|
178
|
-
{...rest}
|
|
179
|
-
>
|
|
180
|
-
{data?.map((item, index) => (
|
|
181
|
-
<PopOverItem
|
|
182
|
-
fontFamily={fontFamily}
|
|
183
|
-
fontSize={fontSize}
|
|
184
|
-
item={item}
|
|
185
|
-
key={index}
|
|
186
|
-
shouldShowDivider={index !== data.length - 1}
|
|
187
|
-
onPress={() => {
|
|
188
|
-
popoverRef?.current?.setState({ isVisible: false });
|
|
189
|
-
onPressItemRef.current = item.onPress;
|
|
190
|
-
}}
|
|
191
|
-
/>
|
|
192
|
-
))}
|
|
193
|
-
{children}
|
|
194
|
-
</OriginalPopover>
|
|
195
|
-
);
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
Popover.propTypes = {
|
|
199
|
-
children: PropTypes.node,
|
|
200
|
-
/**
|
|
201
|
-
* Data should be array of
|
|
202
|
-
* {
|
|
203
|
-
* label: "This would be label of button",
|
|
204
|
-
* Icon: "Icon to be shown prior to label",
|
|
205
|
-
* onPress: "Handler to be called onPress"
|
|
206
|
-
* }.
|
|
207
|
-
*/
|
|
208
|
-
data: PropTypes.array,
|
|
209
|
-
fontFamily: PropTypes.string,
|
|
210
|
-
fontSize: PropTypes.oneOfType([
|
|
211
|
-
PropTypes.number,
|
|
212
|
-
PropTypes.oneOf(["xs", "s", "m", "l", "xl", "xxl"]),
|
|
213
|
-
]),
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
const styles = StyleSheet.create({
|
|
217
|
-
popoverStyle: {
|
|
218
|
-
borderRadius: moderateScale(10),
|
|
219
|
-
padding: moderateScale(5),
|
|
220
|
-
},
|
|
221
|
-
});
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from "react";
|
|
2
|
-
|
|
3
|
-
import { Radio, RadioInactive } from "@bigbinary/neeto-icons-rn";
|
|
4
|
-
import Proptypes from "prop-types";
|
|
5
|
-
import { moderateScale } from "react-native-size-matters";
|
|
6
|
-
import { ThemeContext } from "styled-components/native";
|
|
7
|
-
|
|
8
|
-
import { Typography, Touchable } from "@components";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* <div class="screenshots">
|
|
13
|
-
* <img src="screenshots/radioButton/radioButton.png" />
|
|
14
|
-
* </div>
|
|
15
|
-
*
|
|
16
|
-
* This component supports below props categories from [styled-system ](/styled-system).
|
|
17
|
-
* <ul>
|
|
18
|
-
* <li>flexbox</li>
|
|
19
|
-
* <li>space</li>
|
|
20
|
-
* <li>border</li>
|
|
21
|
-
* <li>layout</li>
|
|
22
|
-
* <li>color</li>
|
|
23
|
-
* <li>buttonStyle</li>
|
|
24
|
-
* </ul>
|
|
25
|
-
*
|
|
26
|
-
* ## Usage
|
|
27
|
-
* ```js
|
|
28
|
-
* import * as React from "react";
|
|
29
|
-
* import { moderateScale } from "react-native-size-matters";
|
|
30
|
-
* import { Container, RadioButton } from "@bigbinary/neetoui-rn";
|
|
31
|
-
*
|
|
32
|
-
* export default function Main() {
|
|
33
|
-
* const [selected1, setSelected1] = useState(true);
|
|
34
|
-
* const [selected2, setSelected2] = useState(false);
|
|
35
|
-
*
|
|
36
|
-
* return (
|
|
37
|
-
* <Container>
|
|
38
|
-
* <RadioButton
|
|
39
|
-
* mt={moderateScale(2)}
|
|
40
|
-
* selected={selected1}
|
|
41
|
-
* onSelect={() => setSelected1(prev => !prev)}
|
|
42
|
-
* label={`Radio button marked as ${!selected1 ? "un" : ""}selected`}
|
|
43
|
-
* />
|
|
44
|
-
* <RadioButton
|
|
45
|
-
* mt={moderateScale(3)}
|
|
46
|
-
* selected={selected2}
|
|
47
|
-
* onSelect={() => setSelected2(prev => !prev)}
|
|
48
|
-
* label={`Radio button marked as ${!selected2 ? "un" : ""}selected`}
|
|
49
|
-
* />
|
|
50
|
-
* <RadioButton mt={moderateScale(3)} disabled label="Disabled Radio button" />
|
|
51
|
-
* </Container>
|
|
52
|
-
* );
|
|
53
|
-
* }
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
export const RadioButton = ({
|
|
59
|
-
selected,
|
|
60
|
-
onSelect,
|
|
61
|
-
disabled,
|
|
62
|
-
label,
|
|
63
|
-
selectIconStyle,
|
|
64
|
-
labelStyle,
|
|
65
|
-
...rest
|
|
66
|
-
}) => {
|
|
67
|
-
const theme = useContext(ThemeContext);
|
|
68
|
-
const disabledProps = {
|
|
69
|
-
borderColor: theme.colors.border.secondary,
|
|
70
|
-
labelProps: {
|
|
71
|
-
color: theme.colors.font.grey400,
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const selectedProps = {
|
|
76
|
-
borderWidth: moderateScale(4),
|
|
77
|
-
borderColor: theme.colors.background.base,
|
|
78
|
-
labelProps: {
|
|
79
|
-
fontFamily: theme.fonts.sf500,
|
|
80
|
-
color: theme.colors.font.primary,
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const unselectedProps = {
|
|
85
|
-
borderWidth: moderateScale(2),
|
|
86
|
-
borderColor: theme.colors.border.secondary,
|
|
87
|
-
labelProps: {
|
|
88
|
-
fontFamily: theme.fonts.sf400,
|
|
89
|
-
color: theme.colors.font.secondary,
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const Icon = selected ? Radio : RadioInactive;
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<Touchable
|
|
97
|
-
alignItems="center"
|
|
98
|
-
disabled={disabled}
|
|
99
|
-
flexDirection="row"
|
|
100
|
-
py={moderateScale(8)}
|
|
101
|
-
onPress={onSelect}
|
|
102
|
-
{...rest}
|
|
103
|
-
>
|
|
104
|
-
<Typography
|
|
105
|
-
color="font.primary"
|
|
106
|
-
flex={1}
|
|
107
|
-
fontSize="m"
|
|
108
|
-
lineHeight={`${moderateScale(22)}px`}
|
|
109
|
-
{...(selected && selectedProps.labelProps)}
|
|
110
|
-
{...(!selected && unselectedProps.labelProps)}
|
|
111
|
-
{...(disabled && disabledProps.labelProps)}
|
|
112
|
-
{...labelStyle}
|
|
113
|
-
>
|
|
114
|
-
{label}
|
|
115
|
-
</Typography>
|
|
116
|
-
<Icon
|
|
117
|
-
color={theme.colors.font.primary}
|
|
118
|
-
size={moderateScale(22)}
|
|
119
|
-
{...selectIconStyle}
|
|
120
|
-
/>
|
|
121
|
-
</Touchable>
|
|
122
|
-
);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
RadioButton.propTypes = {
|
|
126
|
-
/**
|
|
127
|
-
* Whether radio button is selected or not.
|
|
128
|
-
*/
|
|
129
|
-
selected: Proptypes.bool.isRequired,
|
|
130
|
-
/**
|
|
131
|
-
* Function to execute on press.
|
|
132
|
-
*/
|
|
133
|
-
onSelect: Proptypes.func.isRequired,
|
|
134
|
-
/**
|
|
135
|
-
* To disable the component.
|
|
136
|
-
*/
|
|
137
|
-
disabled: Proptypes.bool,
|
|
138
|
-
/**
|
|
139
|
-
* Text label to be shown with radio button.
|
|
140
|
-
*/
|
|
141
|
-
label: Proptypes.string,
|
|
142
|
-
/**
|
|
143
|
-
* Customize radio button style.
|
|
144
|
-
*/
|
|
145
|
-
selectIconStyle: Proptypes.object,
|
|
146
|
-
/**
|
|
147
|
-
* Customize label style.
|
|
148
|
-
*/
|
|
149
|
-
labelStyle: Proptypes.object,
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
RadioButton.defaultProps = {
|
|
153
|
-
selected: false,
|
|
154
|
-
onSelect: () => {},
|
|
155
|
-
};
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import {
|
|
5
|
-
RichEditor,
|
|
6
|
-
RichToolbar,
|
|
7
|
-
actions,
|
|
8
|
-
} from "react-native-pell-rich-editor";
|
|
9
|
-
import styled from "styled-components/native";
|
|
10
|
-
import { space, flexbox, border, layout } from "styled-system";
|
|
11
|
-
|
|
12
|
-
import { Container } from "@components";
|
|
13
|
-
import { useKeyboard } from "@hooks";
|
|
14
|
-
|
|
15
|
-
export const ScrollView = styled.ScrollView.attrs(() => ({
|
|
16
|
-
keyboardShouldPersistTaps: "handled",
|
|
17
|
-
showsVerticalScrollIndicator: true,
|
|
18
|
-
showsHorizontalScrollIndicator: false,
|
|
19
|
-
contentContainerStyle: { flexGrow: 1 },
|
|
20
|
-
}))`
|
|
21
|
-
${space}
|
|
22
|
-
${flexbox}
|
|
23
|
-
${border}
|
|
24
|
-
${layout}
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* RichTextEditor component is wrapper created around react-native-pell-rich-editor. This has dependency on react-native-webview, so make sure to add that as well.
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* <div class="screenshots">
|
|
32
|
-
* <img src="screenshots/rte/rte.png" />
|
|
33
|
-
* </div>
|
|
34
|
-
*
|
|
35
|
-
* ## Usage
|
|
36
|
-
* ```js
|
|
37
|
-
* import * as React from "react";
|
|
38
|
-
* import { moderateScale } from "react-native-size-matters";
|
|
39
|
-
* import { Container, RichTextEditor, theme } from "@bigbinary/neetoui-rn";
|
|
40
|
-
*
|
|
41
|
-
* export default function Main() {
|
|
42
|
-
* const [message, setMessage] = React.useState('');
|
|
43
|
-
*
|
|
44
|
-
* const editorProps = {
|
|
45
|
-
* initialContentHTML: "Rich Text Component...",
|
|
46
|
-
* initialFocus: true,
|
|
47
|
-
* editorStyle: {
|
|
48
|
-
* color: theme.colors.font.grey,
|
|
49
|
-
* },
|
|
50
|
-
* };
|
|
51
|
-
*
|
|
52
|
-
* return (
|
|
53
|
-
* <Container flex={1}>
|
|
54
|
-
* <RichTextEditor
|
|
55
|
-
* onChange={setMessage}
|
|
56
|
-
* toolbarActions={[
|
|
57
|
-
* "keyboard",
|
|
58
|
-
* "setBold",
|
|
59
|
-
* "setItalic",
|
|
60
|
-
* "insertBulletsList",
|
|
61
|
-
* "insertOrderedList",
|
|
62
|
-
* "setStrikethrough",
|
|
63
|
-
* "setUnderline",
|
|
64
|
-
* "undo",
|
|
65
|
-
* "redo",
|
|
66
|
-
* ]}
|
|
67
|
-
* editorProps={editorProps}
|
|
68
|
-
* />
|
|
69
|
-
* </Container>
|
|
70
|
-
* );
|
|
71
|
-
* };
|
|
72
|
-
*
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
export const RichTextEditor = ({
|
|
77
|
-
onChange,
|
|
78
|
-
placeholderText,
|
|
79
|
-
children,
|
|
80
|
-
toolbarActions,
|
|
81
|
-
editorProps,
|
|
82
|
-
toolBarProps,
|
|
83
|
-
...rest
|
|
84
|
-
}) => {
|
|
85
|
-
const richTextRef = useRef();
|
|
86
|
-
const keyboardHeight = useKeyboard();
|
|
87
|
-
const [toolbarVisible, setToolbarVisible] = useState(false);
|
|
88
|
-
const showToolbar = keyboardHeight > 0 && toolbarVisible;
|
|
89
|
-
|
|
90
|
-
const computeToolbarActions = () => {
|
|
91
|
-
const actionItems = [];
|
|
92
|
-
toolbarActions?.map(actionItem => {
|
|
93
|
-
actionItems.push(actions[actionItem]);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
return actionItems;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<ScrollView {...rest?.editorWrapperStyle}>
|
|
101
|
-
{showToolbar && (
|
|
102
|
-
<Container width="100%" {...rest?.toolbarWrapperStyle}>
|
|
103
|
-
<RichToolbar
|
|
104
|
-
actions={computeToolbarActions()}
|
|
105
|
-
editor={richTextRef}
|
|
106
|
-
{...toolBarProps}
|
|
107
|
-
/>
|
|
108
|
-
</Container>
|
|
109
|
-
)}
|
|
110
|
-
<RichEditor
|
|
111
|
-
androidLayerType="software"
|
|
112
|
-
autoCapitalize="sentences"
|
|
113
|
-
placeholder={placeholderText}
|
|
114
|
-
ref={richTextRef}
|
|
115
|
-
useContainer={false}
|
|
116
|
-
onChange={onChange}
|
|
117
|
-
onBlur={() => {
|
|
118
|
-
setToolbarVisible(false);
|
|
119
|
-
editorProps?.onBlurFn();
|
|
120
|
-
}}
|
|
121
|
-
onFocus={() => {
|
|
122
|
-
setToolbarVisible(true);
|
|
123
|
-
editorProps?.onFocusFn();
|
|
124
|
-
}}
|
|
125
|
-
{...editorProps}
|
|
126
|
-
/>
|
|
127
|
-
{children}
|
|
128
|
-
</ScrollView>
|
|
129
|
-
);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
RichTextEditor.defaultProps = {
|
|
133
|
-
editorProps: {},
|
|
134
|
-
toolBarProps: {},
|
|
135
|
-
toolbarWrapperStyle: {},
|
|
136
|
-
placeholderText: "Type here...",
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
RichTextEditor.propTypes = {
|
|
140
|
-
/**
|
|
141
|
-
* Callback that is called when the text input's text changes.
|
|
142
|
-
*/
|
|
143
|
-
onChange: PropTypes.func.isRequired,
|
|
144
|
-
children: PropTypes.node,
|
|
145
|
-
/**
|
|
146
|
-
* Placeholder for the input.
|
|
147
|
-
*/
|
|
148
|
-
placeholderText: PropTypes.string,
|
|
149
|
-
/**
|
|
150
|
-
* An array of actions to be provided by this toolbar. Check react-native-pell-rich-editor for list of supported actions.
|
|
151
|
-
*/
|
|
152
|
-
toolbarActions: PropTypes.array.isRequired,
|
|
153
|
-
/**
|
|
154
|
-
* Object which can be used to pass other supported props by the Editor.
|
|
155
|
-
*/
|
|
156
|
-
editorProps: PropTypes.object,
|
|
157
|
-
/**
|
|
158
|
-
* Object which can be used to pass other supported props by the RichToolbar.
|
|
159
|
-
*/
|
|
160
|
-
toolBarProps: PropTypes.object,
|
|
161
|
-
editorWrapperStyle: PropTypes.object,
|
|
162
|
-
toolbarWrapperStyle: PropTypes.object,
|
|
163
|
-
};
|