@widergy/mobile-ui 1.27.1 → 1.28.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.
Files changed (25) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/lib/components/MultipleFilePicker/components/Picker/index.js +66 -74
  3. package/lib/components/MultipleFilePicker/components/Picker/styles.js +26 -34
  4. package/lib/components/MultipleFilePicker/components/UploadedFiles/index.js +27 -129
  5. package/lib/components/MultipleFilePicker/components/UploadedFiles/styles.js +8 -57
  6. package/lib/components/MultipleFilePicker/constants.js +0 -14
  7. package/lib/components/MultipleFilePicker/index.js +196 -147
  8. package/lib/components/MultipleFilePicker/propTypes.js +15 -11
  9. package/lib/components/MultipleFilePicker/styles.js +9 -0
  10. package/lib/components/MultipleFilePicker/utils.js +22 -51
  11. package/package.json +1 -1
  12. package/lib/components/MultipleFilePicker/components/Input/README.md +0 -77
  13. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/constants.js +0 -2
  14. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/index.js +0 -19
  15. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/propTypes.js +0 -8
  16. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/styles.js +0 -11
  17. package/lib/components/MultipleFilePicker/components/Input/components/Title/index.js +0 -78
  18. package/lib/components/MultipleFilePicker/components/Input/components/Title/propTypes.js +0 -14
  19. package/lib/components/MultipleFilePicker/components/Input/components/Title/styles.js +0 -42
  20. package/lib/components/MultipleFilePicker/components/Input/components/Underline/index.js +0 -80
  21. package/lib/components/MultipleFilePicker/components/Input/components/Underline/styles.js +0 -39
  22. package/lib/components/MultipleFilePicker/components/Input/constants.js +0 -2
  23. package/lib/components/MultipleFilePicker/components/Input/index.js +0 -299
  24. package/lib/components/MultipleFilePicker/components/Input/propTypes.js +0 -43
  25. package/lib/components/MultipleFilePicker/components/Input/styles.js +0 -47
@@ -1,78 +0,0 @@
1
- import React, { Component } from 'react';
2
- import { Animated, View } from 'react-native';
3
-
4
- import Label from '../../../../../Label';
5
- import { DURATION } from '../../constants';
6
-
7
- import propTypes from './propTypes';
8
- import styles, { getLabelStyle } from './styles';
9
-
10
- class Title extends Component {
11
- constructor(props) {
12
- super(props);
13
-
14
- this.state = {
15
- translate: new Animated.Value(props.active ? 1 : 0),
16
- width: 0
17
- };
18
- }
19
-
20
- componentDidUpdate(prevProps) {
21
- const { active } = this.props;
22
- if (!prevProps.active && active) this.translate(1);
23
- else if (prevProps.active && !active) this.translate(0);
24
- }
25
-
26
- handleLayout = ({
27
- nativeEvent: {
28
- layout: { width }
29
- }
30
- }) =>
31
- this.setState({
32
- width
33
- });
34
-
35
- translate = toValue => {
36
- const { onAnimationEnd } = this.props;
37
- const { translate } = this.state;
38
- Animated.timing(translate, {
39
- toValue,
40
- duration: DURATION
41
- }).start(onAnimationEnd);
42
- };
43
-
44
- render() {
45
- const {
46
- active,
47
- activeColor,
48
- children,
49
- disabled,
50
- error,
51
- errorColor,
52
- focused,
53
- fontSize,
54
- inactiveColor,
55
- withValueColor
56
- } = this.props;
57
- const { translate, width } = this.state;
58
- const color =
59
- (active && !error && (focused ? activeColor : withValueColor || inactiveColor)) ||
60
- (error && errorColor) ||
61
- inactiveColor;
62
- const labelStyle = getLabelStyle(translate, width, fontSize);
63
-
64
- return (
65
- <View style={styles.container}>
66
- <Animated.View onLayout={this.handleLayout} style={[styles.label, labelStyle]}>
67
- <Label color={color} disabled={disabled} error={error && !errorColor} style={{ fontSize }}>
68
- {children}
69
- </Label>
70
- </Animated.View>
71
- </View>
72
- );
73
- }
74
- }
75
-
76
- Title.propTypes = propTypes;
77
-
78
- export default Title;
@@ -1,14 +0,0 @@
1
- import { bool, func, number, string } from 'prop-types';
2
-
3
- export default {
4
- active: bool,
5
- activeColor: string,
6
- disabled: bool,
7
- error: bool,
8
- errorColor: string,
9
- focused: bool,
10
- fontSize: number,
11
- inactiveColor: string,
12
- onAnimationEnd: func,
13
- withValueColor: string
14
- };
@@ -1,42 +0,0 @@
1
- import { StyleSheet } from 'react-native';
2
-
3
- import { RATIO } from '../../constants';
4
-
5
- export const getLabelStyle = (translate, width, fontSize) => ({
6
- transform: [
7
- {
8
- translateY: translate.interpolate({
9
- inputRange: [0, 1],
10
- outputRange: [fontSize / (2 - RATIO), -fontSize / 3]
11
- })
12
- },
13
- {
14
- translateX: translate.interpolate({
15
- inputRange: [0, 1],
16
- outputRange: [0, (-width * (1 - RATIO)) / 2]
17
- })
18
- },
19
- {
20
- scale: translate.interpolate({
21
- inputRange: [0, 1],
22
- outputRange: [1, RATIO]
23
- })
24
- }
25
- ]
26
- });
27
-
28
- const styles = StyleSheet.create({
29
- container: {
30
- ...StyleSheet.absoluteFillObject,
31
- flex: 1,
32
- alignItems: 'flex-start',
33
- justifyContent: 'flex-start'
34
- },
35
- label: {
36
- textAlignVertical: 'top',
37
- justifyContent: 'flex-start',
38
- alignItems: 'flex-start'
39
- }
40
- });
41
-
42
- export default styles;
@@ -1,80 +0,0 @@
1
- import React, { Component } from 'react';
2
- import { Animated, PixelRatio, View } from 'react-native';
3
- import PropTypes from 'prop-types';
4
-
5
- import { withTheme, themeType } from '../../../../../../theming';
6
- import { DURATION } from '../../constants';
7
-
8
- import styles, { getAnimatedStyles, getUnderlineBaseStyle } from './styles';
9
-
10
- class Underline extends Component {
11
- constructor(props) {
12
- super(props);
13
- this.state = {
14
- color: new Animated.Value(props.error ? 0 : 1),
15
- scale: new Animated.Value(0)
16
- };
17
- }
18
-
19
- componentDidMount() {
20
- const { active } = this.props;
21
- const { scale } = this.state;
22
-
23
- if (active) {
24
- scale.setValue(1);
25
- }
26
- }
27
-
28
- componentDidUpdate(prevProps) {
29
- const { active, error } = this.props;
30
-
31
- if (prevProps.active && !active) this.scale(0);
32
- else if (!prevProps.active && active) this.scale(1);
33
- if (error && !prevProps.error) this.color(0);
34
- else if (!error && prevProps.error) this.color(1);
35
- }
36
-
37
- color = toValue => {
38
- const { color } = this.state;
39
- Animated.timing(color, {
40
- duration: 115,
41
- toValue
42
- }).start();
43
- };
44
-
45
- scale = toValue => {
46
- const { scale } = this.state;
47
- Animated.timing(scale, {
48
- toValue,
49
- duration: DURATION
50
- }).start();
51
- };
52
-
53
- render() {
54
- const { activeColor, errorColor, inactiveColor, height, theme, disabled } = this.props;
55
- const { color, scale } = this.state;
56
-
57
- const animatedStyle = getAnimatedStyles(color, scale, theme, activeColor, errorColor);
58
- const baseUnderlineStyle = getUnderlineBaseStyle(theme, disabled, inactiveColor);
59
-
60
- return (
61
- <View style={[styles.baseSytle, { height: PixelRatio.roundToNearestPixel(height) }]}>
62
- <View style={[styles.expand, baseUnderlineStyle]} />
63
- <Animated.View style={[styles.absolute, animatedStyle]} />
64
- </View>
65
- );
66
- }
67
- }
68
-
69
- Underline.propTypes = {
70
- activeColor: PropTypes.string,
71
- error: PropTypes.bool,
72
- errorColor: PropTypes.string,
73
- inactiveColor: PropTypes.string,
74
- height: PropTypes.number,
75
- theme: themeType,
76
- disabled: PropTypes.bool,
77
- active: PropTypes.bool
78
- };
79
-
80
- export default withTheme(Underline);
@@ -1,39 +0,0 @@
1
- import { StyleSheet } from 'react-native';
2
-
3
- const styles = StyleSheet.create({
4
- baseSytle: {
5
- position: 'absolute',
6
- bottom: 0,
7
- left: 0,
8
- right: 0
9
- },
10
- expand: {
11
- flex: 1
12
- },
13
- absolute: {
14
- ...StyleSheet.absoluteFillObject
15
- }
16
- });
17
-
18
- export const getAnimatedStyles = (color, value, theme, activeColor, errorColor) => ({
19
- backgroundColor: color.interpolate({
20
- inputRange: [0, 1],
21
- outputRange: [errorColor || theme.colors.error, activeColor || theme.colors.primary]
22
- }),
23
- transform: [
24
- { scaleX: value },
25
- {
26
- scaleY: value.interpolate({
27
- inputRange: [0, 1],
28
- outputRange: [1, 2]
29
- })
30
- }
31
- ],
32
- opacity: value
33
- });
34
-
35
- export const getUnderlineBaseStyle = (theme, disabled, inactiveColor) => ({
36
- backgroundColor: disabled ? theme.colors.disabled : inactiveColor
37
- });
38
-
39
- export default styles;
@@ -1,2 +0,0 @@
1
- export const DURATION = 200;
2
- export const RATIO = 0.8;
@@ -1,299 +0,0 @@
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);
@@ -1,43 +0,0 @@
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
- };
@@ -1,47 +0,0 @@
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
- });