@widergy/mobile-ui 1.9.0 → 1.10.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.
- package/CHANGELOG.md +14 -0
- package/lib/components/UTAutocomplete/index.js +3 -0
- package/lib/components/UTLabel/constants.js +51 -0
- package/lib/components/UTLabel/index.js +55 -0
- package/lib/components/UTLabel/theme.js +27 -0
- package/lib/components/UTLabel/utils.js +5 -0
- package/lib/components/UTMenu/components/ListView/index.js +2 -1
- package/lib/components/UTMenu/index.js +6 -4
- package/lib/index.js +1 -0
- package/lib/theming/DefaultTheme.js +88 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.10.1](https://github.com/widergy/mobile-ui/compare/v1.10.0...v1.10.1) (2024-05-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add UTLabel component ([#285](https://github.com/widergy/mobile-ui/issues/285)) ([e530d86](https://github.com/widergy/mobile-ui/commit/e530d86d864f6ef08c7cee661ed40a22be744170))
|
|
7
|
+
|
|
8
|
+
# [1.10.0](https://github.com/widergy/mobile-ui/compare/v1.9.0...v1.10.0) (2024-05-20)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* autocomplete empty list component ([#287](https://github.com/widergy/mobile-ui/issues/287)) ([a90a0b2](https://github.com/widergy/mobile-ui/commit/a90a0b2fd85e4171d08fc012447b18b522bae6f8))
|
|
14
|
+
|
|
1
15
|
# [1.9.0](https://github.com/widergy/mobile-ui/compare/v1.8.3...v1.9.0) (2024-05-17)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -18,6 +18,7 @@ const UTAutocomplete = ({
|
|
|
18
18
|
variant,
|
|
19
19
|
autoCompletePlaceholder,
|
|
20
20
|
MenuOptionComponent,
|
|
21
|
+
ListEmptyComponent,
|
|
21
22
|
filterOptions,
|
|
22
23
|
persistSelectedOption = false
|
|
23
24
|
}) => {
|
|
@@ -49,6 +50,7 @@ const UTAutocomplete = ({
|
|
|
49
50
|
autoCompletePlaceholder={autoCompletePlaceholder}
|
|
50
51
|
maxHeight={WINDOW_HEIGHT * 0.25}
|
|
51
52
|
MenuOptionComponent={MenuOptionComponent}
|
|
53
|
+
ListEmptyComponent={ListEmptyComponent}
|
|
52
54
|
filterOptions={filterOptions}
|
|
53
55
|
>
|
|
54
56
|
<UTTextInput
|
|
@@ -87,6 +89,7 @@ UTAutocomplete.propTypes = {
|
|
|
87
89
|
variant: string,
|
|
88
90
|
autoCompletePlaceholder: string,
|
|
89
91
|
MenuOptionComponent: element,
|
|
92
|
+
ListEmptyComponent: element,
|
|
90
93
|
filterOptions: bool,
|
|
91
94
|
persistSelectedOption: bool
|
|
92
95
|
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export const SHADES = {
|
|
2
|
+
shade01: '01',
|
|
3
|
+
shade02: '02',
|
|
4
|
+
shade03: '03',
|
|
5
|
+
shade04: '04',
|
|
6
|
+
shade05: '05'
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const VARIANTS_SIZES = {
|
|
10
|
+
title1: 30,
|
|
11
|
+
title2: 24,
|
|
12
|
+
title3: 22,
|
|
13
|
+
subtitle1: 18,
|
|
14
|
+
subtitle2: 16,
|
|
15
|
+
body: 16,
|
|
16
|
+
small: 14,
|
|
17
|
+
xsmall: 13,
|
|
18
|
+
th: 16,
|
|
19
|
+
td: 16
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const WEIGHTS = {
|
|
23
|
+
thin: 100,
|
|
24
|
+
extralight: 200,
|
|
25
|
+
light: 300,
|
|
26
|
+
regular: 400,
|
|
27
|
+
medium: 500,
|
|
28
|
+
semibold: 600,
|
|
29
|
+
bold: 700,
|
|
30
|
+
extrabold: 800,
|
|
31
|
+
black: 900
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const COLOR_THEMES = {
|
|
35
|
+
dark: 'dark',
|
|
36
|
+
gray: 'gray',
|
|
37
|
+
light: 'light',
|
|
38
|
+
success: 'success',
|
|
39
|
+
error: 'error',
|
|
40
|
+
warning: 'warning',
|
|
41
|
+
information: 'information'
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const DEFAULT_PROPS = {
|
|
45
|
+
colorTheme: 'dark',
|
|
46
|
+
field: {},
|
|
47
|
+
className: {},
|
|
48
|
+
variant: 'body',
|
|
49
|
+
weight: 'regular',
|
|
50
|
+
withMarkdown: false
|
|
51
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* eslint-disable react/no-children-prop */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Text } from 'react-native';
|
|
4
|
+
import Markdown from 'react-native-markdown-display';
|
|
5
|
+
import { any, bool, func, object, objectOf, string } from 'prop-types';
|
|
6
|
+
|
|
7
|
+
import { themeType, withTheme } from '../../theming';
|
|
8
|
+
|
|
9
|
+
import { DEFAULT_PROPS } from './constants';
|
|
10
|
+
import { retrieveStyle } from './theme';
|
|
11
|
+
import { markdownFormat } from './utils';
|
|
12
|
+
|
|
13
|
+
const UTLabel = ({
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
|
+
colorTheme,
|
|
17
|
+
field,
|
|
18
|
+
markdownRenderers,
|
|
19
|
+
shade,
|
|
20
|
+
theme,
|
|
21
|
+
variant,
|
|
22
|
+
weight,
|
|
23
|
+
withMarkdown
|
|
24
|
+
}) => {
|
|
25
|
+
if (!children) return null;
|
|
26
|
+
|
|
27
|
+
const themeStyles = retrieveStyle({ colorTheme, field, shade, theme, variant, weight });
|
|
28
|
+
const labelStyles = [themeStyles, className];
|
|
29
|
+
|
|
30
|
+
const LabelRenderer = withMarkdown ? Markdown : Text;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<LabelRenderer style={withMarkdown ? { body: labelStyles } : labelStyles} rules={markdownRenderers}>
|
|
34
|
+
{withMarkdown ? markdownFormat(children) : children}
|
|
35
|
+
</LabelRenderer>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
UTLabel.defaultProps = DEFAULT_PROPS;
|
|
40
|
+
|
|
41
|
+
UTLabel.propTypes = {
|
|
42
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
43
|
+
className: object,
|
|
44
|
+
colorTheme: string,
|
|
45
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
46
|
+
field: any,
|
|
47
|
+
markdownRenderers: objectOf(func),
|
|
48
|
+
shade: string,
|
|
49
|
+
theme: themeType,
|
|
50
|
+
variant: string,
|
|
51
|
+
weight: string,
|
|
52
|
+
withMarkdown: bool
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default withTheme(UTLabel);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { COLOR_THEMES, DEFAULT_PROPS, SHADES, VARIANTS_SIZES, WEIGHTS } from './constants';
|
|
2
|
+
|
|
3
|
+
const getDefaultColorShade = colorTheme =>
|
|
4
|
+
colorTheme === COLOR_THEMES.gray
|
|
5
|
+
? SHADES.shade04
|
|
6
|
+
: colorTheme === COLOR_THEMES.light
|
|
7
|
+
? SHADES.shade01
|
|
8
|
+
: SHADES.shade05;
|
|
9
|
+
|
|
10
|
+
const variantsColorTheme = (colorTheme, shade, theme) => {
|
|
11
|
+
const colorThemeDefinition =
|
|
12
|
+
theme.Palette[colorTheme] || theme.Palette.actions[colorTheme] || theme.Palette[DEFAULT_PROPS.colorTheme];
|
|
13
|
+
const colorShade = Object.values(SHADES).includes(shade) ? shade : getDefaultColorShade(colorTheme);
|
|
14
|
+
return colorThemeDefinition[colorShade] || '#000';
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const retrieveStyle = ({ colorTheme, field, shade, theme, variant, weight }) => ({
|
|
18
|
+
color: variantsColorTheme(
|
|
19
|
+
field?.configuration?.colorTheme ?? colorTheme,
|
|
20
|
+
field?.configuration?.shade ?? shade,
|
|
21
|
+
theme
|
|
22
|
+
),
|
|
23
|
+
fontFamily: theme.fonts.fontFamily,
|
|
24
|
+
fontSize: VARIANTS_SIZES[field?.configuration?.variant ?? variant] || VARIANTS_SIZES[DEFAULT_PROPS.variant],
|
|
25
|
+
fontWeight: WEIGHTS[field?.configuration?.weight ?? weight] || WEIGHTS[DEFAULT_PROPS.weight],
|
|
26
|
+
margin: 0
|
|
27
|
+
});
|
|
@@ -46,7 +46,7 @@ class ListView extends PureComponent {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
render() {
|
|
49
|
-
const { filteredOptions, ItemSeparatorComponent } = this.props;
|
|
49
|
+
const { filteredOptions, ItemSeparatorComponent, ListEmptyComponent } = this.props;
|
|
50
50
|
const { style } = this.state;
|
|
51
51
|
|
|
52
52
|
return (
|
|
@@ -57,6 +57,7 @@ class ListView extends PureComponent {
|
|
|
57
57
|
keyboardShouldPersistTaps="always"
|
|
58
58
|
renderItem={this.renderItem}
|
|
59
59
|
ItemSeparatorComponent={ItemSeparatorComponent}
|
|
60
|
+
ListEmptyComponent={ListEmptyComponent}
|
|
60
61
|
/>
|
|
61
62
|
);
|
|
62
63
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
1
|
+
import React, { Fragment, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { Dimensions, Keyboard, KeyboardAvoidingView, Modal, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import useKeyboardHeight from '../../hooks/useKeyboardHeight';
|
|
@@ -24,6 +24,7 @@ const UTMenu = ({
|
|
|
24
24
|
styles: propStyles,
|
|
25
25
|
MenuOptionComponent = MenuOption,
|
|
26
26
|
ItemSeparatorComponent,
|
|
27
|
+
ListEmptyComponent,
|
|
27
28
|
maxHeight,
|
|
28
29
|
isMultiple,
|
|
29
30
|
autoCompletePlaceholder,
|
|
@@ -102,11 +103,11 @@ const UTMenu = ({
|
|
|
102
103
|
|
|
103
104
|
const handleQueryChange = value => {
|
|
104
105
|
setQuery(value);
|
|
105
|
-
onQueryChange(value);
|
|
106
|
+
onQueryChange?.(value);
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
return (
|
|
109
|
-
|
|
110
|
+
<Fragment>
|
|
110
111
|
<TouchableOpacity
|
|
111
112
|
disabled={disabled}
|
|
112
113
|
onPress={isOpen ? closeMenu : openMenu}
|
|
@@ -153,6 +154,7 @@ const UTMenu = ({
|
|
|
153
154
|
usableWindowHeight={usableWindowHeight}
|
|
154
155
|
filteredOptions={filteredOptions}
|
|
155
156
|
ItemSeparatorComponent={ItemSeparatorComponent}
|
|
157
|
+
ListEmptyComponent={ListEmptyComponent}
|
|
156
158
|
MenuOptionComponent={MenuOptionComponent}
|
|
157
159
|
handleOptionPress={handleOptionPress}
|
|
158
160
|
onPress={onPress}
|
|
@@ -164,7 +166,7 @@ const UTMenu = ({
|
|
|
164
166
|
</KeyboardAvoidingView>
|
|
165
167
|
</View>
|
|
166
168
|
</Modal>
|
|
167
|
-
|
|
169
|
+
</Fragment>
|
|
168
170
|
);
|
|
169
171
|
};
|
|
170
172
|
|
package/lib/index.js
CHANGED
|
@@ -59,6 +59,7 @@ export { default as Loading } from './components/Loading';
|
|
|
59
59
|
export { default as UTLoading } from './components/UTLoading';
|
|
60
60
|
// Text
|
|
61
61
|
export { default as Label } from './components/Label';
|
|
62
|
+
export { default as UTLabel } from './components/UTLabel';
|
|
62
63
|
export { default as TransitionText } from './components/TransitionText';
|
|
63
64
|
// Theming
|
|
64
65
|
export * from './theming';
|
|
@@ -113,6 +113,94 @@ const DefaultTheme = {
|
|
|
113
113
|
iconSize: 15
|
|
114
114
|
},
|
|
115
115
|
passwordIcons: {}
|
|
116
|
+
},
|
|
117
|
+
Palette: {
|
|
118
|
+
dark: {
|
|
119
|
+
'01': '#575757',
|
|
120
|
+
'02': '#4A4A4A',
|
|
121
|
+
'03': '#3D3D3D',
|
|
122
|
+
'04': '#313130',
|
|
123
|
+
'05': '#0F0F0F'
|
|
124
|
+
},
|
|
125
|
+
gray: {
|
|
126
|
+
'01': '#BDBDBD',
|
|
127
|
+
'02': '#B0B0B0',
|
|
128
|
+
'03': '#969696',
|
|
129
|
+
'04': '#787878',
|
|
130
|
+
'05': '#646464'
|
|
131
|
+
},
|
|
132
|
+
light: {
|
|
133
|
+
'01': '#FFFFFF',
|
|
134
|
+
'02': '#FCFBFA',
|
|
135
|
+
'03': '#F6F6F5',
|
|
136
|
+
'04': '#E7E7E7',
|
|
137
|
+
'05': '#C9C9C9'
|
|
138
|
+
},
|
|
139
|
+
success: {
|
|
140
|
+
'01': '#EEF9E6',
|
|
141
|
+
'02': '#D3F0C0',
|
|
142
|
+
'03': '#80D249',
|
|
143
|
+
'04': '#3F8411',
|
|
144
|
+
'05': '#245702'
|
|
145
|
+
},
|
|
146
|
+
error: {
|
|
147
|
+
'01': '#FFF0EB',
|
|
148
|
+
'02': '#FED9CE',
|
|
149
|
+
'03': '#FD906F',
|
|
150
|
+
'04': '#D03607',
|
|
151
|
+
'05': '#852001'
|
|
152
|
+
},
|
|
153
|
+
warning: {
|
|
154
|
+
'01': '#FFF9E6',
|
|
155
|
+
'02': '#FFEFC1',
|
|
156
|
+
'03': '#FED24F',
|
|
157
|
+
'04': '#A86600',
|
|
158
|
+
'05': '#6F4708'
|
|
159
|
+
},
|
|
160
|
+
information: {
|
|
161
|
+
'01': '#EBFAFD',
|
|
162
|
+
'02': '#CEF3FB',
|
|
163
|
+
'03': '#6BDBF3',
|
|
164
|
+
'04': '#037C96',
|
|
165
|
+
'05': '#025F73'
|
|
166
|
+
},
|
|
167
|
+
actions: {
|
|
168
|
+
accent: {
|
|
169
|
+
'01': '#E7F0EE',
|
|
170
|
+
'02': '#C3D9D5',
|
|
171
|
+
'03': '#4A8D83',
|
|
172
|
+
'04': '#0D6759',
|
|
173
|
+
'05': '#0D6759'
|
|
174
|
+
},
|
|
175
|
+
neutral: {
|
|
176
|
+
'01': '#E8ECED',
|
|
177
|
+
'02': '#C6D0D3',
|
|
178
|
+
'03': '#54737B',
|
|
179
|
+
'04': '#1B444F',
|
|
180
|
+
'05': '#1B444F'
|
|
181
|
+
},
|
|
182
|
+
error: {
|
|
183
|
+
'01': '#FFEBEE',
|
|
184
|
+
'02': '#FECED5',
|
|
185
|
+
'03': '#FD6F85',
|
|
186
|
+
'04': '#E80C2C',
|
|
187
|
+
'05': '#A0041B'
|
|
188
|
+
},
|
|
189
|
+
success: {
|
|
190
|
+
'01': '#EEF9E6',
|
|
191
|
+
'02': '#D3F0C0',
|
|
192
|
+
'03': '#80D249',
|
|
193
|
+
'04': '#3F8411',
|
|
194
|
+
'05': '#245702'
|
|
195
|
+
},
|
|
196
|
+
negative: {
|
|
197
|
+
'01': 'rgba(255, 255, 255, 0.1)',
|
|
198
|
+
'02': 'rgba(255, 255, 255, 0.25)',
|
|
199
|
+
'03': 'rgba(255, 255, 255, 0.5)',
|
|
200
|
+
'04': '#FFFFFF',
|
|
201
|
+
'05': '#FFFFFF'
|
|
202
|
+
}
|
|
203
|
+
}
|
|
116
204
|
}
|
|
117
205
|
};
|
|
118
206
|
|
package/package.json
CHANGED