@widergy/mobile-ui 1.5.0 → 1.7.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/CHANGELOG.md +39 -0
- package/lib/components/MultipleFilePicker/components/Input/README.md +77 -0
- package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/constants.js +2 -0
- package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/index.js +27 -0
- package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/propTypes.js +8 -0
- package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/styles.js +15 -0
- package/lib/components/MultipleFilePicker/components/Input/components/Title/index.js +78 -0
- package/lib/components/MultipleFilePicker/components/Input/components/Title/propTypes.js +14 -0
- package/lib/components/MultipleFilePicker/components/Input/components/Title/styles.js +42 -0
- package/lib/components/MultipleFilePicker/components/Input/components/Underline/index.js +80 -0
- package/lib/components/MultipleFilePicker/components/Input/components/Underline/styles.js +39 -0
- package/lib/components/MultipleFilePicker/components/Input/constants.js +2 -0
- package/lib/components/MultipleFilePicker/components/Input/index.js +299 -0
- package/lib/components/MultipleFilePicker/components/Input/propTypes.js +43 -0
- package/lib/components/MultipleFilePicker/components/Input/styles.js +47 -0
- package/lib/components/MultipleFilePicker/components/Picker/index.js +95 -0
- package/lib/components/MultipleFilePicker/components/Picker/styles.js +47 -0
- package/lib/components/MultipleFilePicker/components/UploadedFiles/index.js +140 -0
- package/lib/components/MultipleFilePicker/components/UploadedFiles/styles.js +65 -0
- package/lib/components/MultipleFilePicker/components/UploadedFiles/utils.js +6 -0
- package/lib/components/MultipleFilePicker/constants.js +18 -0
- package/lib/components/MultipleFilePicker/index.js +162 -0
- package/lib/components/MultipleFilePicker/propTypes.js +17 -0
- package/lib/components/MultipleFilePicker/utils.js +41 -0
- package/lib/index.js +1 -0
- package/lib/utils/analyticsUtils/index.js +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import React, { PureComponent, createRef } from 'react';
|
|
2
|
+
import { TextInput, Text, TouchableWithoutFeedback, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import CaptionLabel from '../../../CaptionLabel';
|
|
5
|
+
import Icon from '../../../Icon';
|
|
6
|
+
import IconButton from '../../../IconButton';
|
|
7
|
+
import { DEFAULT_ICON_SIZE } from '../../../Icon/constants';
|
|
8
|
+
import { withTheme } from '../../../../theming';
|
|
9
|
+
import UTTooltip from '../../../UTTooltip';
|
|
10
|
+
import { ICON_MARGIN } from '../../../IconButton/styles';
|
|
11
|
+
|
|
12
|
+
import ShowPassword from './components/ShowPassword';
|
|
13
|
+
import Title from './components/Title';
|
|
14
|
+
import Underline from './components/Underline';
|
|
15
|
+
import propTypes from './propTypes';
|
|
16
|
+
import styles, { INPUT_ICON_MARGIN } from './styles';
|
|
17
|
+
import { RATIO } from './constants';
|
|
18
|
+
|
|
19
|
+
class Input extends PureComponent {
|
|
20
|
+
constructor(props) {
|
|
21
|
+
super(props);
|
|
22
|
+
|
|
23
|
+
this.state = {
|
|
24
|
+
focused: false,
|
|
25
|
+
passwordVisible: false,
|
|
26
|
+
showPlaceholder: false
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
this.textInput = createRef();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getContainerStyle() {
|
|
33
|
+
const { backgroundColor, theme, containerButtonPadding, containerPadding, maxWidth, minHeight } =
|
|
34
|
+
this.props;
|
|
35
|
+
return {
|
|
36
|
+
backgroundColor: backgroundColor || theme.colors.inputBackground,
|
|
37
|
+
paddingHorizontal: containerButtonPadding || containerPadding,
|
|
38
|
+
paddingVertical: containerPadding,
|
|
39
|
+
maxWidth,
|
|
40
|
+
minHeight
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getCaptionStyle = () => {
|
|
45
|
+
const { iconSize, leadingIcon, trailingIcon } = this.props;
|
|
46
|
+
const marginLeft = leadingIcon ? 2 * INPUT_ICON_MARGIN + iconSize : INPUT_ICON_MARGIN;
|
|
47
|
+
const marginRight = trailingIcon ? 2 * INPUT_ICON_MARGIN + iconSize : INPUT_ICON_MARGIN;
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
marginLeft,
|
|
51
|
+
marginRight
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
getInputStyle() {
|
|
56
|
+
const { textStyles, theme, disabledTextStyles } = this.props;
|
|
57
|
+
const additionalStyle = { flex: 1 };
|
|
58
|
+
|
|
59
|
+
return [
|
|
60
|
+
{
|
|
61
|
+
fontSize: theme.fonts.fontSizes.base,
|
|
62
|
+
fontFamily: theme.fonts.fontFamily,
|
|
63
|
+
color: theme.fonts.fontColor
|
|
64
|
+
},
|
|
65
|
+
textStyles,
|
|
66
|
+
this.isDisabled() && disabledTextStyles,
|
|
67
|
+
additionalStyle
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getPaddingStyle() {
|
|
72
|
+
const { theme } = this.props;
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
paddingBottom: theme.fonts.fontSizes.base * (1 - RATIO),
|
|
76
|
+
paddingTop: theme.fonts.fontSizes.base * RATIO
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
isDisabled = () => {
|
|
81
|
+
const { disabled, editable } = this.props;
|
|
82
|
+
|
|
83
|
+
return !editable || disabled;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
composeRefs = ref => {
|
|
87
|
+
const { inputRef } = this.props;
|
|
88
|
+
if (inputRef) {
|
|
89
|
+
if (typeof inputRef === 'function') inputRef(ref);
|
|
90
|
+
else inputRef.current = ref;
|
|
91
|
+
}
|
|
92
|
+
this.textInput.current = ref;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
handleFocus = event => {
|
|
96
|
+
const { onFocus } = this.props;
|
|
97
|
+
this.setState({ focused: true });
|
|
98
|
+
if (onFocus) {
|
|
99
|
+
onFocus(event);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
focus = () => {
|
|
104
|
+
if (this.textInput && this.textInput.current) {
|
|
105
|
+
this.textInput.current.focus();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
togglePasswordVisibility = () =>
|
|
110
|
+
this.setState(state => ({
|
|
111
|
+
passwordVisible: !state.passwordVisible
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
toggleShowPlaceholder = () =>
|
|
115
|
+
this.setState(state => ({
|
|
116
|
+
showPlaceholder: !state.showPlaceholder
|
|
117
|
+
}));
|
|
118
|
+
|
|
119
|
+
handleBlur = event => {
|
|
120
|
+
const { onBlur } = this.props;
|
|
121
|
+
|
|
122
|
+
this.setState({ focused: false });
|
|
123
|
+
if (onBlur) {
|
|
124
|
+
onBlur(event);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
render() {
|
|
129
|
+
const { focused, passwordVisible, showPlaceholder } = this.state;
|
|
130
|
+
const {
|
|
131
|
+
activeColor,
|
|
132
|
+
backgroundColor,
|
|
133
|
+
caption,
|
|
134
|
+
captionProps,
|
|
135
|
+
containerStyle,
|
|
136
|
+
error,
|
|
137
|
+
errorColor,
|
|
138
|
+
fileSize,
|
|
139
|
+
iconColor,
|
|
140
|
+
iconSize,
|
|
141
|
+
inactiveColor,
|
|
142
|
+
leadingIcon,
|
|
143
|
+
multiline,
|
|
144
|
+
onChange,
|
|
145
|
+
onSubmit,
|
|
146
|
+
placeholder,
|
|
147
|
+
placeholderTextColor,
|
|
148
|
+
secureTextEntry,
|
|
149
|
+
showEye,
|
|
150
|
+
textStyles,
|
|
151
|
+
theme,
|
|
152
|
+
title,
|
|
153
|
+
trailingIcon,
|
|
154
|
+
underlineHeight,
|
|
155
|
+
value,
|
|
156
|
+
withValueColor,
|
|
157
|
+
textColor,
|
|
158
|
+
titleActiveColor,
|
|
159
|
+
tooltip,
|
|
160
|
+
tooltipProps,
|
|
161
|
+
tooltipIconProps,
|
|
162
|
+
...textInputProps
|
|
163
|
+
} = this.props;
|
|
164
|
+
|
|
165
|
+
const placeholderText = !title || (focused && showPlaceholder) ? placeholder : '';
|
|
166
|
+
const hasError = !!error;
|
|
167
|
+
const hasValue = !!value;
|
|
168
|
+
const active = hasError || focused;
|
|
169
|
+
const finalActiveColor = activeColor || theme.colors.primary;
|
|
170
|
+
const finalTitleActiveColor = titleActiveColor || finalActiveColor;
|
|
171
|
+
const finalInactiveColor = inactiveColor || theme.fonts.fontColor;
|
|
172
|
+
const paddingStyle = this.getPaddingStyle();
|
|
173
|
+
const inputStyle = !textStyles ? styles.input : {};
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<View style={[styles.root, { minHeight: theme.fonts.fontSizes.base * (2 + RATIO) }, containerStyle]}>
|
|
177
|
+
<View style={styles.withTooltipContainer}>
|
|
178
|
+
<TouchableWithoutFeedback disabled={this.isDisabled()} onPress={this.focus}>
|
|
179
|
+
<View style={[styles.container, this.getContainerStyle(), containerStyle]}>
|
|
180
|
+
<View>
|
|
181
|
+
{trailingIcon && (
|
|
182
|
+
<Icon
|
|
183
|
+
color={iconColor}
|
|
184
|
+
size={iconSize}
|
|
185
|
+
width={iconSize}
|
|
186
|
+
height={iconSize}
|
|
187
|
+
style={[styles.trailingIcon, paddingStyle.paddingTop]}
|
|
188
|
+
{...trailingIcon}
|
|
189
|
+
/>
|
|
190
|
+
)}
|
|
191
|
+
</View>
|
|
192
|
+
<View style={[styles.innerContainer]}>
|
|
193
|
+
<TextInput
|
|
194
|
+
{...textInputProps}
|
|
195
|
+
allowFontScaling={false}
|
|
196
|
+
editable={!this.isDisabled()}
|
|
197
|
+
multiline={multiline}
|
|
198
|
+
onBlur={this.handleBlur}
|
|
199
|
+
onFocus={this.handleFocus}
|
|
200
|
+
onSubmitEditing={onSubmit}
|
|
201
|
+
onChangeText={onChange}
|
|
202
|
+
placeholder={placeholderText}
|
|
203
|
+
placeholderTextColor={placeholderTextColor}
|
|
204
|
+
ref={this.composeRefs}
|
|
205
|
+
secureTextEntry={secureTextEntry && !passwordVisible}
|
|
206
|
+
underlineColorAndroid="transparent"
|
|
207
|
+
style={[inputStyle, this.getInputStyle(), { color: textColor }]}
|
|
208
|
+
value={value}
|
|
209
|
+
/>
|
|
210
|
+
{fileSize && <Text style={styles.sizeText}>{fileSize}</Text>}
|
|
211
|
+
<Title
|
|
212
|
+
active={focused || hasValue}
|
|
213
|
+
activeColor={finalTitleActiveColor}
|
|
214
|
+
disabled={this.isDisabled()}
|
|
215
|
+
error={hasError}
|
|
216
|
+
errorColor={errorColor}
|
|
217
|
+
focused={focused}
|
|
218
|
+
fontSize={theme.fonts.fontSizes.base}
|
|
219
|
+
inactiveColor={finalInactiveColor}
|
|
220
|
+
onAnimationEnd={this.toggleShowPlaceholder}
|
|
221
|
+
withValueColor={withValueColor}
|
|
222
|
+
>
|
|
223
|
+
{title}
|
|
224
|
+
</Title>
|
|
225
|
+
</View>
|
|
226
|
+
<View style={{ paddingBottom: paddingStyle.paddingBottom }}>
|
|
227
|
+
{secureTextEntry && showEye && (
|
|
228
|
+
<ShowPassword
|
|
229
|
+
color={iconColor}
|
|
230
|
+
onShowPassword={this.togglePasswordVisibility}
|
|
231
|
+
passwordVisible={passwordVisible}
|
|
232
|
+
size={iconSize}
|
|
233
|
+
/>
|
|
234
|
+
)}
|
|
235
|
+
</View>
|
|
236
|
+
<View>
|
|
237
|
+
{leadingIcon && (
|
|
238
|
+
<IconButton
|
|
239
|
+
color={iconColor}
|
|
240
|
+
size={iconSize}
|
|
241
|
+
width={iconSize}
|
|
242
|
+
height={iconSize}
|
|
243
|
+
style={paddingStyle.paddingTop}
|
|
244
|
+
{...leadingIcon}
|
|
245
|
+
/>
|
|
246
|
+
)}
|
|
247
|
+
</View>
|
|
248
|
+
<Underline
|
|
249
|
+
active={active}
|
|
250
|
+
activeColor={activeColor}
|
|
251
|
+
disabled={this.isDisabled()}
|
|
252
|
+
error={hasError}
|
|
253
|
+
errorColor={errorColor}
|
|
254
|
+
height={underlineHeight}
|
|
255
|
+
inactiveColor={(hasValue && withValueColor) || finalInactiveColor}
|
|
256
|
+
/>
|
|
257
|
+
</View>
|
|
258
|
+
</TouchableWithoutFeedback>
|
|
259
|
+
{!!tooltip && (
|
|
260
|
+
<View
|
|
261
|
+
style={{
|
|
262
|
+
...styles.tooltipContainer,
|
|
263
|
+
height: ICON_MARGIN + iconSize,
|
|
264
|
+
paddingBottom: paddingStyle.paddingBottom,
|
|
265
|
+
marginBottom: underlineHeight
|
|
266
|
+
}}
|
|
267
|
+
>
|
|
268
|
+
<UTTooltip content={tooltip} position="left" {...tooltipProps}>
|
|
269
|
+
<Icon name="questioncircleo" type="antdesign" size={25} {...tooltipIconProps} />
|
|
270
|
+
</UTTooltip>
|
|
271
|
+
</View>
|
|
272
|
+
)}
|
|
273
|
+
</View>
|
|
274
|
+
|
|
275
|
+
<CaptionLabel
|
|
276
|
+
color={activeColor}
|
|
277
|
+
error={error}
|
|
278
|
+
errorColor={errorColor}
|
|
279
|
+
style={this.getCaptionStyle()}
|
|
280
|
+
{...captionProps}
|
|
281
|
+
>
|
|
282
|
+
{caption}
|
|
283
|
+
</CaptionLabel>
|
|
284
|
+
</View>
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
Input.propTypes = propTypes;
|
|
290
|
+
|
|
291
|
+
Input.defaultProps = {
|
|
292
|
+
autoCorrect: false,
|
|
293
|
+
editable: true,
|
|
294
|
+
iconSize: DEFAULT_ICON_SIZE,
|
|
295
|
+
underlineHeight: 1,
|
|
296
|
+
defaultContainerPadding: INPUT_ICON_MARGIN
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
export default withTheme(Input);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
2
|
+
import { bool, func, instanceOf, number, oneOfType, shape, string } from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import captionPropTypes from '../../../CaptionLabel/propTypes';
|
|
5
|
+
import iconPropTypes from '../../../Icon/propTypes';
|
|
6
|
+
import iconButtonPropTypes from '../../../IconButton/propTypes';
|
|
7
|
+
import { themeType } from '../../../../theming';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
activeColor: string,
|
|
11
|
+
autoCorrect: bool,
|
|
12
|
+
backgroundColor: string,
|
|
13
|
+
caption: string,
|
|
14
|
+
captionProps: shape(captionPropTypes),
|
|
15
|
+
containerStyle: ViewPropTypes.style,
|
|
16
|
+
containerPadding: number,
|
|
17
|
+
disabled: bool,
|
|
18
|
+
editable: bool,
|
|
19
|
+
disabledTextStyles: ViewPropTypes.style,
|
|
20
|
+
titleActiveColor: string,
|
|
21
|
+
error: oneOfType([bool, string]),
|
|
22
|
+
errorColor: string,
|
|
23
|
+
iconColor: string,
|
|
24
|
+
iconSize: number,
|
|
25
|
+
inactiveColor: string,
|
|
26
|
+
inputRef: oneOfType([func, instanceOf(Object)]),
|
|
27
|
+
leadingIcon: shape(iconPropTypes),
|
|
28
|
+
multiline: bool,
|
|
29
|
+
onBlur: func,
|
|
30
|
+
onChange: func,
|
|
31
|
+
onFocus: func,
|
|
32
|
+
onSubmit: func,
|
|
33
|
+
placeholder: string,
|
|
34
|
+
secureTextEntry: bool,
|
|
35
|
+
showEye: bool,
|
|
36
|
+
textStyles: ViewPropTypes.style,
|
|
37
|
+
title: string,
|
|
38
|
+
theme: themeType,
|
|
39
|
+
trailingIcon: shape(iconButtonPropTypes),
|
|
40
|
+
underlineHeight: number,
|
|
41
|
+
value: string,
|
|
42
|
+
withValueColor: string
|
|
43
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
portraitModerateHorizontalScale,
|
|
5
|
+
portraitModerateVerticalScale
|
|
6
|
+
} from '../../../../utils/portraitScalingUtils';
|
|
7
|
+
|
|
8
|
+
export const INPUT_ICON_MARGIN = portraitModerateHorizontalScale(5);
|
|
9
|
+
|
|
10
|
+
export default StyleSheet.create({
|
|
11
|
+
root: {
|
|
12
|
+
flex: 1
|
|
13
|
+
},
|
|
14
|
+
container: {
|
|
15
|
+
flex: 1,
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
borderTopLeftRadius: 3,
|
|
18
|
+
borderTopRightRadius: 3,
|
|
19
|
+
flexDirection: 'row',
|
|
20
|
+
paddingTop: portraitModerateVerticalScale(4)
|
|
21
|
+
},
|
|
22
|
+
innerContainer: {
|
|
23
|
+
flex: 1,
|
|
24
|
+
justifyContent: 'flex-start'
|
|
25
|
+
},
|
|
26
|
+
input: {
|
|
27
|
+
flex: 1,
|
|
28
|
+
padding: 0,
|
|
29
|
+
textAlignVertical: 'top'
|
|
30
|
+
},
|
|
31
|
+
leadingIcon: {
|
|
32
|
+
paddingBottom: INPUT_ICON_MARGIN
|
|
33
|
+
},
|
|
34
|
+
sizeText: { paddingHorizontal: 8, paddingVertical: 0 },
|
|
35
|
+
trailingIcon: {
|
|
36
|
+
marginBottom: 1 / INPUT_ICON_MARGIN,
|
|
37
|
+
marginRight: 1 / INPUT_ICON_MARGIN
|
|
38
|
+
},
|
|
39
|
+
withTooltipContainer: {
|
|
40
|
+
flexDirection: 'row'
|
|
41
|
+
},
|
|
42
|
+
tooltipContainer: {
|
|
43
|
+
alignSelf: 'flex-end',
|
|
44
|
+
justifyContent: 'center',
|
|
45
|
+
paddingLeft: 10
|
|
46
|
+
}
|
|
47
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import { ImagePropTypes, ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
3
|
+
import { Text, View } from 'react-native';
|
|
4
|
+
import { arrayOf, string, bool, oneOfType, shape, func } from 'prop-types';
|
|
5
|
+
|
|
6
|
+
import Label from '../../../Label';
|
|
7
|
+
import Touchable from '../../../Touchable';
|
|
8
|
+
import Input from '../Input';
|
|
9
|
+
import { withTheme, themeType } from '../../../../theming';
|
|
10
|
+
|
|
11
|
+
import styles from './styles';
|
|
12
|
+
|
|
13
|
+
const Picker = ({
|
|
14
|
+
icon,
|
|
15
|
+
error,
|
|
16
|
+
onAdd,
|
|
17
|
+
filePlaceholder,
|
|
18
|
+
uploadedFiles,
|
|
19
|
+
helpText,
|
|
20
|
+
pickerText,
|
|
21
|
+
showButton,
|
|
22
|
+
title,
|
|
23
|
+
theme,
|
|
24
|
+
withMarkdownTitle,
|
|
25
|
+
markdownStyles,
|
|
26
|
+
disabled = false,
|
|
27
|
+
UploadIcon
|
|
28
|
+
}) => (
|
|
29
|
+
<>
|
|
30
|
+
{!!title && (
|
|
31
|
+
<Label
|
|
32
|
+
useMarkdown={withMarkdownTitle}
|
|
33
|
+
{...theme.forms.fieldsTitleProps}
|
|
34
|
+
markdownStyles={markdownStyles}
|
|
35
|
+
>
|
|
36
|
+
{title}
|
|
37
|
+
</Label>
|
|
38
|
+
)}
|
|
39
|
+
<View style={[styles.fieldInput, { borderColor: theme.picker.accentColor }]}>
|
|
40
|
+
<UploadIcon height={64} width={64} fill={theme.picker.trashIconColor} />
|
|
41
|
+
<Touchable borderless style={styles.touchable} disabled={disabled} onPress={onAdd}>
|
|
42
|
+
<Input
|
|
43
|
+
backgroundColor={theme.picker.inputBackgroundColor}
|
|
44
|
+
maxWidth={styles.containerInput.width}
|
|
45
|
+
minHeight={styles.containerInput.height}
|
|
46
|
+
value={uploadedFiles}
|
|
47
|
+
editable={false}
|
|
48
|
+
placeholder={filePlaceholder}
|
|
49
|
+
placeholderTextColor={theme.picker.buttonTextColor}
|
|
50
|
+
disabledTextStyles={{ color: theme.colors.disabled }}
|
|
51
|
+
trailingIcon={
|
|
52
|
+
showButton && {
|
|
53
|
+
name: icon,
|
|
54
|
+
color: theme.picker.buttonTextColor,
|
|
55
|
+
onPress: onAdd,
|
|
56
|
+
type: 'feather',
|
|
57
|
+
disabled
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
error={error}
|
|
61
|
+
containerStyle={styles.containerStyle}
|
|
62
|
+
containerPadding={18}
|
|
63
|
+
textStyles={styles.textStyles}
|
|
64
|
+
underlineHeight={0}
|
|
65
|
+
/>
|
|
66
|
+
</Touchable>
|
|
67
|
+
<Text style={styles.pickerText}>{pickerText}</Text>
|
|
68
|
+
</View>
|
|
69
|
+
<Text style={styles.helpText}>{helpText}</Text>
|
|
70
|
+
</>
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
Picker.propTypes = {
|
|
74
|
+
icon: string.isRequired,
|
|
75
|
+
error: oneOfType([string, bool]),
|
|
76
|
+
onAdd: func.isRequired,
|
|
77
|
+
onDelete: func.isRequired,
|
|
78
|
+
filePlaceholder: string,
|
|
79
|
+
uploadedFiles: arrayOf(string),
|
|
80
|
+
title: string,
|
|
81
|
+
showButton: bool,
|
|
82
|
+
theme: themeType,
|
|
83
|
+
withMarkdownTitle: bool,
|
|
84
|
+
markdownStyles: shape({ ViewPropTypes }),
|
|
85
|
+
disabled: bool,
|
|
86
|
+
helpText: string,
|
|
87
|
+
pickerText: string,
|
|
88
|
+
UploadIcon: ImagePropTypes
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
Picker.defaultProps = {
|
|
92
|
+
showButton: true
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default withTheme(Picker);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { portraitVerticalScale } from '../../../../utils/portraitScalingUtils';
|
|
4
|
+
|
|
5
|
+
export default StyleSheet.create({
|
|
6
|
+
container: {
|
|
7
|
+
flexDirection: 'row'
|
|
8
|
+
},
|
|
9
|
+
containerInput: {
|
|
10
|
+
height: '100%',
|
|
11
|
+
width: '100%'
|
|
12
|
+
},
|
|
13
|
+
containerStyle: {
|
|
14
|
+
flex: 1
|
|
15
|
+
},
|
|
16
|
+
fieldInput: {
|
|
17
|
+
flex: 1,
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
borderRadius: 5,
|
|
20
|
+
borderStyle: 'dashed',
|
|
21
|
+
borderWidth: 1,
|
|
22
|
+
height: 'auto',
|
|
23
|
+
marginVertical: 10,
|
|
24
|
+
paddingBottom: portraitVerticalScale(24),
|
|
25
|
+
paddingTop: portraitVerticalScale(16),
|
|
26
|
+
width: '100%'
|
|
27
|
+
},
|
|
28
|
+
pickerText: {
|
|
29
|
+
textAlign: 'center'
|
|
30
|
+
},
|
|
31
|
+
helpText: {
|
|
32
|
+
textAlign: 'center',
|
|
33
|
+
marginBottom: 10
|
|
34
|
+
},
|
|
35
|
+
textStyles: {
|
|
36
|
+
flex: 1,
|
|
37
|
+
padding: 0,
|
|
38
|
+
textAlignVertical: 'center',
|
|
39
|
+
margin: 5
|
|
40
|
+
},
|
|
41
|
+
touchable: {
|
|
42
|
+
borderRadius: 4,
|
|
43
|
+
margin: 7,
|
|
44
|
+
height: 38,
|
|
45
|
+
width: '50%'
|
|
46
|
+
}
|
|
47
|
+
});
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
3
|
+
import { Text, View } from 'react-native';
|
|
4
|
+
import { string, bool, oneOfType, shape, func, arrayOf } from 'prop-types';
|
|
5
|
+
|
|
6
|
+
import { withTheme, themeType } from '../../../../theming';
|
|
7
|
+
import Touchable from '../../../Touchable';
|
|
8
|
+
import Input from '../Input';
|
|
9
|
+
import Label from '../../../Label';
|
|
10
|
+
|
|
11
|
+
import { bytesFormater } from './utils';
|
|
12
|
+
import styles from './styles';
|
|
13
|
+
|
|
14
|
+
const UploadedFiles = ({
|
|
15
|
+
disabled = false,
|
|
16
|
+
error,
|
|
17
|
+
filePlaceholder,
|
|
18
|
+
helpText,
|
|
19
|
+
icon,
|
|
20
|
+
markdownStyles,
|
|
21
|
+
onAdd,
|
|
22
|
+
onDelete,
|
|
23
|
+
pickerText,
|
|
24
|
+
showButton,
|
|
25
|
+
theme,
|
|
26
|
+
title,
|
|
27
|
+
uploadedFiles,
|
|
28
|
+
withMarkdownTitle
|
|
29
|
+
}) => (
|
|
30
|
+
<>
|
|
31
|
+
{!!title && (
|
|
32
|
+
<Label
|
|
33
|
+
useMarkdown={withMarkdownTitle}
|
|
34
|
+
{...theme.forms.fieldsTitleProps}
|
|
35
|
+
markdownStyles={markdownStyles}
|
|
36
|
+
>
|
|
37
|
+
{title}
|
|
38
|
+
</Label>
|
|
39
|
+
)}
|
|
40
|
+
<View style={[styles.fieldInput, { borderColor: theme.picker.accentColor }]}>
|
|
41
|
+
{uploadedFiles.map((file, index) => {
|
|
42
|
+
return (
|
|
43
|
+
<Touchable
|
|
44
|
+
key={`${file.name}-${Math.random()}`}
|
|
45
|
+
borderless
|
|
46
|
+
style={styles.touchable}
|
|
47
|
+
disabled={disabled}
|
|
48
|
+
>
|
|
49
|
+
<Input
|
|
50
|
+
backgroundColor="transparent"
|
|
51
|
+
maxWidth={styles.containerInput.width}
|
|
52
|
+
minHeight={styles.containerInput.height}
|
|
53
|
+
value={file.name}
|
|
54
|
+
editable={false}
|
|
55
|
+
fileSize={bytesFormater(file.size)}
|
|
56
|
+
placeholder={filePlaceholder}
|
|
57
|
+
disabledTextStyles={{ color: theme.colors.disabled }}
|
|
58
|
+
trailingIcon={
|
|
59
|
+
showButton && {
|
|
60
|
+
name: 'check',
|
|
61
|
+
color: theme.picker.accentColor,
|
|
62
|
+
type: 'feather',
|
|
63
|
+
disabled
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
leadingIcon={
|
|
67
|
+
showButton && {
|
|
68
|
+
name: 'trash-2',
|
|
69
|
+
color: theme.picker.trashIconColor,
|
|
70
|
+
type: 'feather',
|
|
71
|
+
onPress: () => onDelete(index),
|
|
72
|
+
disabled
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
error={error}
|
|
76
|
+
containerStyle={styles.containerStyle}
|
|
77
|
+
textStyles={styles.textStyles}
|
|
78
|
+
containerPadding={styles.containerPadding.padding}
|
|
79
|
+
underlineHeight={0}
|
|
80
|
+
iconSize={32}
|
|
81
|
+
textColor={theme.picker.dark05}
|
|
82
|
+
/>
|
|
83
|
+
</Touchable>
|
|
84
|
+
);
|
|
85
|
+
})}
|
|
86
|
+
<Touchable borderless style={styles.uploadTouchable} disabled={disabled} onPress={onAdd}>
|
|
87
|
+
<Input
|
|
88
|
+
backgroundColor={theme.picker.inputBackgroundColor}
|
|
89
|
+
maxWidth={styles.containerInput.width}
|
|
90
|
+
minHeight={38}
|
|
91
|
+
value={uploadedFiles}
|
|
92
|
+
editable={false}
|
|
93
|
+
placeholder={filePlaceholder}
|
|
94
|
+
placeholderTextColor={theme.picker.buttonTextColor}
|
|
95
|
+
disabledTextStyles={{ color: theme.colors.disabled }}
|
|
96
|
+
trailingIcon={
|
|
97
|
+
showButton && {
|
|
98
|
+
name: icon,
|
|
99
|
+
type: 'feather',
|
|
100
|
+
color: theme.picker.buttonTextColor,
|
|
101
|
+
onPress: onAdd,
|
|
102
|
+
disabled
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
error={error}
|
|
106
|
+
textStyles={styles.textButtonStyles}
|
|
107
|
+
containerButtonPadding={styles.containerButtonPadding.padding}
|
|
108
|
+
containerPadding={styles.containerPadding.padding}
|
|
109
|
+
underlineHeight={0}
|
|
110
|
+
iconSize={20}
|
|
111
|
+
/>
|
|
112
|
+
</Touchable>
|
|
113
|
+
<Text style={styles.pickerText}>{pickerText}</Text>
|
|
114
|
+
</View>
|
|
115
|
+
<Text style={styles.helpText}>{helpText}</Text>
|
|
116
|
+
</>
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
UploadedFiles.propTypes = {
|
|
120
|
+
icon: string.isRequired,
|
|
121
|
+
error: oneOfType([string, bool]),
|
|
122
|
+
onAdd: func.isRequired,
|
|
123
|
+
onDelete: func.isRequired,
|
|
124
|
+
filePlaceholder: string,
|
|
125
|
+
uploadedFiles: arrayOf(string),
|
|
126
|
+
title: string,
|
|
127
|
+
showButton: bool,
|
|
128
|
+
theme: themeType,
|
|
129
|
+
withMarkdownTitle: bool,
|
|
130
|
+
markdownStyles: shape({ ViewPropTypes }),
|
|
131
|
+
disabled: bool,
|
|
132
|
+
helpText: string,
|
|
133
|
+
pickerText: string
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
UploadedFiles.defaultProps = {
|
|
137
|
+
showButton: true
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export default withTheme(UploadedFiles);
|