@widergy/mobile-ui 1.27.1 → 1.28.1

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 (27) hide show
  1. package/CHANGELOG.md +14 -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/lib/components/UTBaseInputField/index.js +4 -2
  12. package/lib/components/UTBaseInputField/theme.js +7 -4
  13. package/package.json +1 -1
  14. package/lib/components/MultipleFilePicker/components/Input/README.md +0 -77
  15. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/constants.js +0 -2
  16. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/index.js +0 -19
  17. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/propTypes.js +0 -8
  18. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/styles.js +0 -11
  19. package/lib/components/MultipleFilePicker/components/Input/components/Title/index.js +0 -78
  20. package/lib/components/MultipleFilePicker/components/Input/components/Title/propTypes.js +0 -14
  21. package/lib/components/MultipleFilePicker/components/Input/components/Title/styles.js +0 -42
  22. package/lib/components/MultipleFilePicker/components/Input/components/Underline/index.js +0 -80
  23. package/lib/components/MultipleFilePicker/components/Input/components/Underline/styles.js +0 -39
  24. package/lib/components/MultipleFilePicker/components/Input/constants.js +0 -2
  25. package/lib/components/MultipleFilePicker/components/Input/index.js +0 -299
  26. package/lib/components/MultipleFilePicker/components/Input/propTypes.js +0 -43
  27. package/lib/components/MultipleFilePicker/components/Input/styles.js +0 -47
@@ -1,77 +0,0 @@
1
- # Input
2
-
3
- ## Input
4
-
5
- Material Text Input with Title and Underline.
6
-
7
- ### Props
8
-
9
-
10
- | NAME | TYPE | REQUIRED | DESCRIPTION | DEFAULT VALUE |
11
- | --- | --- | --- | --- | --- |
12
- | [TextInput](https://facebook.github.io/react-native/docs/textinput#props) props. | TextInput props | No | | - |
13
- | activeColor | string | No | The color the input will have when active. If this prop is not specified, the color defaults to `theme.colors.primary`. | - |
14
- | backgroundColor | string | No | Background color for the input. Defaults to `theme.colors.inputBackground`. | - |
15
- | caption | string | No | Helper text to show below the input if no error is present. | - |
16
- | captionProps | CaptionType | No | Additional props for caption. | - |
17
- | containerStyle | ViewStyle | No | Style for the outer container of the input. | - |
18
- | disabled | bool | No | If `true` sets all styles to disabled and disables interactions with the input. | - |
19
- | error | string | No | Error to display instead of the caption. Also sets colors to the error color. | - |
20
- | errorColor | string | No | The color that errors will be displayed in. Defaults to `theme.colors.error`. | - |
21
- | iconSize | number | No | The size that applies to all icons. | DEFAULT ICON SIZE |
22
- | inactiveColor | string | No | The color the input will have when inactive. If this prop is not specified, the color defaults to `theme.fonts.fontColor`. | - |
23
- | inputRef | func | No | A way to pass a `ref` from outside the component to the input. | - |
24
- | leadingIcon | IconType | No | Icon to display on the left side. | - |
25
- | showEye | bool | No | Show eye icon to show `secureTextEntry` text if that prop is enabled. | - |
26
- | textStyles | TextStyle | No | Style for the input. | - |
27
- | title | string | No | Input title to show when the input is not active. Will float to the top once it is active. | - |
28
- | trailingIcon | IconButtonType | No | Icon button to display on the right side. | - |
29
- | underlineHeight | number | No | The underline component height (reminder: underline is scaled twice as big when active). | `portraitVerticalScale(1)` |
30
- | withValueColor | string | No | The color of the title when it has values, but is not focused. | - |
31
-
32
-
33
- #### Example
34
- ```js
35
- import React, { PureComponent } from 'react';
36
- import { Input } from '@widergy/mobile-ui';
37
-
38
- class InputShowcase extends PureComponent {
39
- state = {
40
- value: '',
41
- error: ''
42
- };
43
-
44
- changeValue = value => this.setState({ value });
45
-
46
- handleBlur = () => {
47
- const { value } = this.state;
48
- this.validate(value);
49
- };
50
-
51
- handleFocus = () => {
52
- this.setState({ error: '' });
53
- };
54
-
55
- validate = text => {
56
- const error =
57
- text && text.length < 5 ? 'Debe tener más de 5 caracteres y este mensaje es de dos líneas' : '';
58
-
59
- this.setState({ error });
60
- };
61
-
62
- render() {
63
- return (
64
- <Input
65
- {...this.state}
66
- {...this.props}
67
- onBlur={this.handleBlur}
68
- onFocus={this.handleFocus}
69
- onChange={this.changeValue}
70
- onSubmit={this.validate}
71
- containerStyle={styles.input}
72
- />
73
- );
74
- }
75
- }
76
-
77
- ```
@@ -1,2 +0,0 @@
1
- export const VISIBILITY = 'eye';
2
- export const VISIBILITY_OFF = 'eye-off';
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- import { View } from 'react-native';
3
-
4
- import UTButton from '../../../../../UTButton';
5
-
6
- import propTypes from './propTypes';
7
- import styles from './styles';
8
-
9
- const ShowPassword = ({ onShowPassword, passwordVisible }) => (
10
- <View style={styles.container}>
11
- <UTButton Icon={passwordVisible ? 'IconEye' : 'IconEyeOff'} onPress={onShowPassword} variant="text" />
12
- </View>
13
- );
14
-
15
- ShowPassword.displayName = 'ShowPassword';
16
-
17
- ShowPassword.propTypes = propTypes;
18
-
19
- export default ShowPassword;
@@ -1,8 +0,0 @@
1
- import { bool, func, number, string } from 'prop-types';
2
-
3
- export default {
4
- color: string,
5
- onShowPassword: func.isRequired,
6
- passwordVisible: bool.isRequired,
7
- size: number
8
- };
@@ -1,11 +0,0 @@
1
- import { StyleSheet } from 'react-native';
2
-
3
- import { INPUT_ICON_MARGIN } from '../../styles';
4
-
5
- export default StyleSheet.create({
6
- container: {
7
- alignItems: 'flex-end',
8
- flexDirection: 'row',
9
- marginLeft: INPUT_ICON_MARGIN
10
- }
11
- });
@@ -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);