@hero-design/rn 7.26.0 → 7.27.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/.turbo/turbo-build.log +9 -9
- package/es/index.js +77 -30
- package/lib/index.js +77 -30
- package/package.json +4 -4
- package/src/components/Accordion/index.tsx +1 -1
- package/src/components/Card/index.tsx +18 -7
- package/src/components/Select/MultiSelect/index.tsx +5 -2
- package/src/components/Select/SingleSelect/index.tsx +5 -2
- package/src/components/Select/types.ts +15 -6
- package/src/components/Tabs/ScrollableTabs.tsx +2 -0
- package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +1 -1
- package/src/components/Tabs/__tests__/index.spec.tsx +1 -1
- package/src/components/Tabs/index.tsx +7 -0
- package/src/components/Tag/StyledTag.tsx +42 -11
- package/src/components/Tag/__tests__/Tag.spec.tsx +28 -0
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +135 -0
- package/src/components/Tag/index.tsx +15 -3
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +2 -1
- package/src/theme/components/tag.ts +1 -0
- package/src/theme/components/toolbar.ts +1 -1
- package/src/utils/hooks.ts +18 -1
- package/types/components/Card/index.d.ts +1 -1
- package/types/components/Select/MultiSelect/index.d.ts +1 -1
- package/types/components/Select/SingleSelect/index.d.ts +1 -1
- package/types/components/Select/index.d.ts +1 -1
- package/types/components/Select/types.d.ts +15 -3
- package/types/components/Tabs/ScrollableTabs.d.ts +1 -1
- package/types/components/Tabs/index.d.ts +7 -2
- package/types/components/Tag/StyledTag.d.ts +3 -0
- package/types/components/Tag/index.d.ts +7 -2
- package/types/theme/components/tag.d.ts +1 -0
- package/types/utils/hooks.d.ts +2 -0
- package/src/components/Accordion/utils.tsx +0 -11
- package/types/components/Accordion/utils.d.ts +0 -1
|
@@ -56,6 +56,7 @@ function MultiSelect<V, T extends OptionType<V>>({
|
|
|
56
56
|
inputProps,
|
|
57
57
|
onConfirm,
|
|
58
58
|
onDimiss,
|
|
59
|
+
onDismiss,
|
|
59
60
|
onEndReached,
|
|
60
61
|
onQueryChange,
|
|
61
62
|
options,
|
|
@@ -65,6 +66,7 @@ function MultiSelect<V, T extends OptionType<V>>({
|
|
|
65
66
|
error,
|
|
66
67
|
editable = true,
|
|
67
68
|
disabled = false,
|
|
69
|
+
required,
|
|
68
70
|
numberOfLines,
|
|
69
71
|
style,
|
|
70
72
|
testID,
|
|
@@ -98,6 +100,7 @@ function MultiSelect<V, T extends OptionType<V>>({
|
|
|
98
100
|
}
|
|
99
101
|
<View pointerEvents="none">
|
|
100
102
|
<TextInput
|
|
103
|
+
numberOfLines={numberOfLines}
|
|
101
104
|
{...inputProps}
|
|
102
105
|
label={label}
|
|
103
106
|
value={displayedValue}
|
|
@@ -106,7 +109,7 @@ function MultiSelect<V, T extends OptionType<V>>({
|
|
|
106
109
|
error={error}
|
|
107
110
|
editable={editable}
|
|
108
111
|
disabled={disabled}
|
|
109
|
-
|
|
112
|
+
required={required}
|
|
110
113
|
pointerEvents="none"
|
|
111
114
|
style={style}
|
|
112
115
|
testID={testID}
|
|
@@ -122,7 +125,7 @@ function MultiSelect<V, T extends OptionType<V>>({
|
|
|
122
125
|
<BottomSheet
|
|
123
126
|
open={open}
|
|
124
127
|
onRequestClose={() => setOpen(false)}
|
|
125
|
-
onDismiss={onDimiss}
|
|
128
|
+
onDismiss={onDismiss || onDimiss}
|
|
126
129
|
header={label}
|
|
127
130
|
style={{
|
|
128
131
|
paddingBottom: isKeyboardVisible ? keyboardHeight : 0,
|
|
@@ -41,6 +41,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
41
41
|
inputProps,
|
|
42
42
|
onConfirm,
|
|
43
43
|
onDimiss,
|
|
44
|
+
onDismiss,
|
|
44
45
|
onEndReached,
|
|
45
46
|
onQueryChange,
|
|
46
47
|
options,
|
|
@@ -50,6 +51,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
50
51
|
error,
|
|
51
52
|
editable = true,
|
|
52
53
|
disabled = false,
|
|
54
|
+
required,
|
|
53
55
|
numberOfLines,
|
|
54
56
|
style,
|
|
55
57
|
testID,
|
|
@@ -75,6 +77,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
75
77
|
}
|
|
76
78
|
<View pointerEvents="none">
|
|
77
79
|
<TextInput
|
|
80
|
+
numberOfLines={numberOfLines}
|
|
78
81
|
{...inputProps}
|
|
79
82
|
label={label}
|
|
80
83
|
value={displayedValue}
|
|
@@ -83,7 +86,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
83
86
|
error={error}
|
|
84
87
|
editable={editable}
|
|
85
88
|
disabled={disabled}
|
|
86
|
-
|
|
89
|
+
required={required}
|
|
87
90
|
pointerEvents="none"
|
|
88
91
|
style={style}
|
|
89
92
|
testID={testID}
|
|
@@ -99,7 +102,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
99
102
|
<BottomSheet
|
|
100
103
|
open={open}
|
|
101
104
|
onRequestClose={() => setOpen(false)}
|
|
102
|
-
onDismiss={onDimiss}
|
|
105
|
+
onDismiss={onDismiss || onDimiss}
|
|
103
106
|
header={label}
|
|
104
107
|
style={{
|
|
105
108
|
paddingBottom: isKeyboardVisible ? keyboardHeight : 0,
|
|
@@ -39,10 +39,7 @@ export type SectionListRenderOptionInfo<
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
export interface SelectProps<V, T extends OptionType<V>>
|
|
42
|
-
extends Pick<
|
|
43
|
-
TextInputProps,
|
|
44
|
-
'editable' | 'disabled' | 'numberOfLines' | 'error'
|
|
45
|
-
> {
|
|
42
|
+
extends Pick<TextInputProps, 'editable' | 'disabled' | 'error' | 'required'> {
|
|
46
43
|
/**
|
|
47
44
|
* An array of options to be selected.
|
|
48
45
|
*/
|
|
@@ -67,9 +64,14 @@ export interface SelectProps<V, T extends OptionType<V>>
|
|
|
67
64
|
*/
|
|
68
65
|
onQueryChange?: (value: string) => void;
|
|
69
66
|
/**
|
|
70
|
-
*
|
|
67
|
+
* @deprecated due to typo.
|
|
68
|
+
* Please use onDismiss instead.
|
|
71
69
|
*/
|
|
72
70
|
onDimiss?: () => void;
|
|
71
|
+
/**
|
|
72
|
+
* Event handler when selection dismiss
|
|
73
|
+
*/
|
|
74
|
+
onDismiss?: () => void;
|
|
73
75
|
/**
|
|
74
76
|
* Event handler when end of the list reached
|
|
75
77
|
*/
|
|
@@ -80,8 +82,10 @@ export interface SelectProps<V, T extends OptionType<V>>
|
|
|
80
82
|
loading?: boolean;
|
|
81
83
|
/**
|
|
82
84
|
* Props that are passed to TextInput.
|
|
85
|
+
* Required is deprecated and will be removed in the next major release.
|
|
86
|
+
* Please use the outer required instead.
|
|
83
87
|
*/
|
|
84
|
-
inputProps?: Pick<TextInputProps, 'loading' | 'required'>;
|
|
88
|
+
inputProps?: Pick<TextInputProps, 'loading' | 'required' | 'numberOfLines'>;
|
|
85
89
|
/**
|
|
86
90
|
* Field label.
|
|
87
91
|
*/
|
|
@@ -94,4 +98,9 @@ export interface SelectProps<V, T extends OptionType<V>>
|
|
|
94
98
|
* Testing id of the component.
|
|
95
99
|
*/
|
|
96
100
|
testID?: string;
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated
|
|
103
|
+
* Please use inputProps.numberOfLines instead.
|
|
104
|
+
*/
|
|
105
|
+
numberOfLines?: number;
|
|
97
106
|
}
|
|
@@ -63,6 +63,7 @@ const ScrollableTab = ({
|
|
|
63
63
|
barStyle,
|
|
64
64
|
lazy = false,
|
|
65
65
|
lazyPreloadDistance = 1,
|
|
66
|
+
swipeEnabled = true,
|
|
66
67
|
testID: componentTestID,
|
|
67
68
|
}: TabsProps) => {
|
|
68
69
|
const flatListRef = React.useRef<FlatList>(null);
|
|
@@ -195,6 +196,7 @@ const ScrollableTab = ({
|
|
|
195
196
|
onTabPress(selectedItem.key);
|
|
196
197
|
}
|
|
197
198
|
}}
|
|
199
|
+
scrollEnabled={swipeEnabled}
|
|
198
200
|
>
|
|
199
201
|
{tabs.map((tab, index) => {
|
|
200
202
|
const { key, component, testID } = tab;
|
|
@@ -92,7 +92,7 @@ describe('Tabs.Scroll', () => {
|
|
|
92
92
|
|
|
93
93
|
it('renders correctly with lazy preloaded', () => {
|
|
94
94
|
const { getByText, queryByText, getByTestId } = renderWithTheme(
|
|
95
|
-
<TestTabsComponent lazy lazyPreloadDistance={1} />
|
|
95
|
+
<TestTabsComponent lazy lazyPreloadDistance={1} swipeEnabled={false} />
|
|
96
96
|
);
|
|
97
97
|
|
|
98
98
|
expect(getByText('Work Screen')).toBeDefined();
|
|
@@ -87,7 +87,7 @@ describe('Tabs', () => {
|
|
|
87
87
|
|
|
88
88
|
it('renders correctly with lazy preloaded', () => {
|
|
89
89
|
const { getByText, queryByText } = renderWithTheme(
|
|
90
|
-
<TestTabsComponent lazy lazyPreloadDistance={1} />
|
|
90
|
+
<TestTabsComponent lazy lazyPreloadDistance={1} swipeEnabled={false} />
|
|
91
91
|
);
|
|
92
92
|
|
|
93
93
|
expect(getByText('Work Screen')).toBeDefined();
|
|
@@ -67,6 +67,11 @@ export interface TabsProps extends ViewProps {
|
|
|
67
67
|
* Defaults value is `1`.
|
|
68
68
|
*/
|
|
69
69
|
lazyPreloadDistance?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Boolean indicating whether to enable swipe gestures. Passing `false` will disable swipe gestures, but the user can still switch tabs by pressing the tab bar.
|
|
72
|
+
* Defaults value is `true`.
|
|
73
|
+
*/
|
|
74
|
+
swipeEnabled?: boolean;
|
|
70
75
|
/**
|
|
71
76
|
* Testing id of the component.
|
|
72
77
|
*/
|
|
@@ -105,6 +110,7 @@ const Tabs = ({
|
|
|
105
110
|
barStyle,
|
|
106
111
|
lazy = false,
|
|
107
112
|
lazyPreloadDistance = 1,
|
|
113
|
+
swipeEnabled = true,
|
|
108
114
|
testID: componentTestID,
|
|
109
115
|
}: TabsProps): JSX.Element => {
|
|
110
116
|
const theme = useTheme();
|
|
@@ -207,6 +213,7 @@ const Tabs = ({
|
|
|
207
213
|
useNativeDriver: true,
|
|
208
214
|
}
|
|
209
215
|
)}
|
|
216
|
+
scrollEnabled={swipeEnabled}
|
|
210
217
|
>
|
|
211
218
|
{tabs.map((tab, index) => {
|
|
212
219
|
const { key, component, testID } = tab;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { View, Text } from 'react-native';
|
|
2
2
|
import styled from '@emotion/native';
|
|
3
|
+
import { Theme } from '../../theme';
|
|
3
4
|
|
|
4
5
|
type ThemeIntent =
|
|
5
6
|
| 'default'
|
|
@@ -10,26 +11,56 @@ type ThemeIntent =
|
|
|
10
11
|
| 'danger'
|
|
11
12
|
| 'archived';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
type ThemeVariant = 'filled' | 'outlined';
|
|
15
|
+
|
|
16
|
+
const getFilledStyles = (themeIntent: ThemeIntent, theme: Theme) => ({
|
|
17
|
+
textColor: theme.__hd__.tag.colors.text,
|
|
18
|
+
borderColor: theme.__hd__.tag.colors[`${themeIntent}Background`],
|
|
19
|
+
backgroundColor: theme.__hd__.tag.colors[`${themeIntent}Background`],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const getOutlinedStyles = (themeIntent: ThemeIntent, theme: Theme) => ({
|
|
23
|
+
textColor: theme.__hd__.tag.colors[themeIntent],
|
|
24
|
+
borderColor: theme.__hd__.tag.colors[themeIntent],
|
|
25
|
+
backgroundColor: theme.__hd__.tag.colors[`${themeIntent}Background`],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const StyledView = styled(View)<{
|
|
29
|
+
themeIntent: ThemeIntent;
|
|
30
|
+
themeVariant: ThemeVariant;
|
|
31
|
+
}>(({ themeIntent, themeVariant, theme }) => {
|
|
32
|
+
const { borderColor, backgroundColor } =
|
|
33
|
+
themeVariant === 'filled'
|
|
34
|
+
? getFilledStyles(themeIntent, theme)
|
|
35
|
+
: getOutlinedStyles(themeIntent, theme);
|
|
36
|
+
|
|
37
|
+
return {
|
|
15
38
|
borderWidth: theme.__hd__.tag.borderWidths.default,
|
|
16
39
|
borderRadius: theme.__hd__.tag.radii.default,
|
|
17
40
|
paddingVertical: theme.__hd__.tag.space.verticalPadding,
|
|
18
41
|
paddingHorizontal: theme.__hd__.tag.space.horizontalPadding,
|
|
19
|
-
borderColor
|
|
20
|
-
backgroundColor
|
|
21
|
-
}
|
|
22
|
-
);
|
|
42
|
+
borderColor,
|
|
43
|
+
backgroundColor,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const StyledText = styled(Text)<{
|
|
48
|
+
themeIntent: ThemeIntent;
|
|
49
|
+
themeVariant: ThemeVariant;
|
|
50
|
+
}>(({ themeIntent, themeVariant, theme }) => {
|
|
51
|
+
const { textColor } =
|
|
52
|
+
themeVariant === 'filled'
|
|
53
|
+
? getFilledStyles(themeIntent, theme)
|
|
54
|
+
: getOutlinedStyles(themeIntent, theme);
|
|
23
55
|
|
|
24
|
-
|
|
25
|
-
({ themeIntent, theme }) => ({
|
|
56
|
+
return {
|
|
26
57
|
fontFamily: theme.__hd__.tag.fonts.default,
|
|
27
58
|
fontSize: theme.__hd__.tag.fontSizes.default,
|
|
28
|
-
color:
|
|
59
|
+
color: textColor,
|
|
29
60
|
includeFontPadding: false,
|
|
30
61
|
textAlignVertical: 'center',
|
|
31
62
|
textAlign: 'center',
|
|
32
|
-
}
|
|
33
|
-
);
|
|
63
|
+
};
|
|
64
|
+
});
|
|
34
65
|
|
|
35
66
|
export { StyledView, StyledText };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
3
|
import Tag from '..';
|
|
4
|
+
import Typography from '../../Typography';
|
|
4
5
|
|
|
5
6
|
describe('Tag', () => {
|
|
6
7
|
it('has success style when intent is success', () => {
|
|
@@ -65,4 +66,31 @@ describe('Tag', () => {
|
|
|
65
66
|
expect(toJSON()).toMatchSnapshot();
|
|
66
67
|
expect(getByText('PRIMARY')).toBeDefined();
|
|
67
68
|
});
|
|
69
|
+
|
|
70
|
+
it('renders correctly when variant is filled and intent is warning', () => {
|
|
71
|
+
const { getByText, toJSON } = renderWithTheme(
|
|
72
|
+
<Tag content="WARNING" intent="warning" variant="filled" />
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
expect(toJSON()).toMatchSnapshot();
|
|
76
|
+
expect(getByText('WARNING')).toBeDefined();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('renders correctly when variant is filled and intent is danger', () => {
|
|
80
|
+
const { getByText, toJSON } = renderWithTheme(
|
|
81
|
+
<Tag content="DANGER" intent="danger" variant="filled" />
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(toJSON()).toMatchSnapshot();
|
|
85
|
+
expect(getByText('DANGER')).toBeDefined();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('renders correctly with custom content', () => {
|
|
89
|
+
const { getByText, toJSON } = renderWithTheme(
|
|
90
|
+
<Tag content={<Typography.Text>Custom Content</Typography.Text>} />
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
expect(toJSON()).toMatchSnapshot();
|
|
94
|
+
expect(getByText('Custom Content')).toBeDefined();
|
|
95
|
+
});
|
|
68
96
|
});
|
|
@@ -16,6 +16,7 @@ exports[`Tag has archived style when intent is archived 1`] = `
|
|
|
16
16
|
]
|
|
17
17
|
}
|
|
18
18
|
themeIntent="archived"
|
|
19
|
+
themeVariant="outlined"
|
|
19
20
|
>
|
|
20
21
|
<Text
|
|
21
22
|
style={
|
|
@@ -32,6 +33,7 @@ exports[`Tag has archived style when intent is archived 1`] = `
|
|
|
32
33
|
]
|
|
33
34
|
}
|
|
34
35
|
themeIntent="archived"
|
|
36
|
+
themeVariant="outlined"
|
|
35
37
|
>
|
|
36
38
|
ARCHIVED
|
|
37
39
|
</Text>
|
|
@@ -54,6 +56,7 @@ exports[`Tag has archived style when intent is primary 1`] = `
|
|
|
54
56
|
]
|
|
55
57
|
}
|
|
56
58
|
themeIntent="primary"
|
|
59
|
+
themeVariant="outlined"
|
|
57
60
|
>
|
|
58
61
|
<Text
|
|
59
62
|
style={
|
|
@@ -70,6 +73,7 @@ exports[`Tag has archived style when intent is primary 1`] = `
|
|
|
70
73
|
]
|
|
71
74
|
}
|
|
72
75
|
themeIntent="primary"
|
|
76
|
+
themeVariant="outlined"
|
|
73
77
|
>
|
|
74
78
|
PRIMARY
|
|
75
79
|
</Text>
|
|
@@ -92,6 +96,7 @@ exports[`Tag has danger style when intent is danger 1`] = `
|
|
|
92
96
|
]
|
|
93
97
|
}
|
|
94
98
|
themeIntent="danger"
|
|
99
|
+
themeVariant="outlined"
|
|
95
100
|
>
|
|
96
101
|
<Text
|
|
97
102
|
style={
|
|
@@ -108,6 +113,7 @@ exports[`Tag has danger style when intent is danger 1`] = `
|
|
|
108
113
|
]
|
|
109
114
|
}
|
|
110
115
|
themeIntent="danger"
|
|
116
|
+
themeVariant="outlined"
|
|
111
117
|
>
|
|
112
118
|
DANGER
|
|
113
119
|
</Text>
|
|
@@ -130,6 +136,7 @@ exports[`Tag has default style when intent is default 1`] = `
|
|
|
130
136
|
]
|
|
131
137
|
}
|
|
132
138
|
themeIntent="default"
|
|
139
|
+
themeVariant="outlined"
|
|
133
140
|
>
|
|
134
141
|
<Text
|
|
135
142
|
style={
|
|
@@ -146,6 +153,7 @@ exports[`Tag has default style when intent is default 1`] = `
|
|
|
146
153
|
]
|
|
147
154
|
}
|
|
148
155
|
themeIntent="default"
|
|
156
|
+
themeVariant="outlined"
|
|
149
157
|
>
|
|
150
158
|
DEFAULT
|
|
151
159
|
</Text>
|
|
@@ -168,6 +176,7 @@ exports[`Tag has info style when intent is info 1`] = `
|
|
|
168
176
|
]
|
|
169
177
|
}
|
|
170
178
|
themeIntent="info"
|
|
179
|
+
themeVariant="outlined"
|
|
171
180
|
>
|
|
172
181
|
<Text
|
|
173
182
|
style={
|
|
@@ -184,6 +193,7 @@ exports[`Tag has info style when intent is info 1`] = `
|
|
|
184
193
|
]
|
|
185
194
|
}
|
|
186
195
|
themeIntent="info"
|
|
196
|
+
themeVariant="outlined"
|
|
187
197
|
>
|
|
188
198
|
INFO
|
|
189
199
|
</Text>
|
|
@@ -206,6 +216,7 @@ exports[`Tag has success style when intent is success 1`] = `
|
|
|
206
216
|
]
|
|
207
217
|
}
|
|
208
218
|
themeIntent="success"
|
|
219
|
+
themeVariant="outlined"
|
|
209
220
|
>
|
|
210
221
|
<Text
|
|
211
222
|
style={
|
|
@@ -222,6 +233,7 @@ exports[`Tag has success style when intent is success 1`] = `
|
|
|
222
233
|
]
|
|
223
234
|
}
|
|
224
235
|
themeIntent="success"
|
|
236
|
+
themeVariant="outlined"
|
|
225
237
|
>
|
|
226
238
|
SUCCESS
|
|
227
239
|
</Text>
|
|
@@ -244,6 +256,7 @@ exports[`Tag has warning style when intent is warning 1`] = `
|
|
|
244
256
|
]
|
|
245
257
|
}
|
|
246
258
|
themeIntent="warning"
|
|
259
|
+
themeVariant="outlined"
|
|
247
260
|
>
|
|
248
261
|
<Text
|
|
249
262
|
style={
|
|
@@ -260,8 +273,130 @@ exports[`Tag has warning style when intent is warning 1`] = `
|
|
|
260
273
|
]
|
|
261
274
|
}
|
|
262
275
|
themeIntent="warning"
|
|
276
|
+
themeVariant="outlined"
|
|
263
277
|
>
|
|
264
278
|
WARNING
|
|
265
279
|
</Text>
|
|
266
280
|
</View>
|
|
267
281
|
`;
|
|
282
|
+
|
|
283
|
+
exports[`Tag renders correctly when variant is filled and intent is danger 1`] = `
|
|
284
|
+
<View
|
|
285
|
+
style={
|
|
286
|
+
Array [
|
|
287
|
+
Object {
|
|
288
|
+
"backgroundColor": "#fcebe7",
|
|
289
|
+
"borderColor": "#fcebe7",
|
|
290
|
+
"borderRadius": 4,
|
|
291
|
+
"borderWidth": 1,
|
|
292
|
+
"paddingHorizontal": 8,
|
|
293
|
+
"paddingVertical": 2,
|
|
294
|
+
},
|
|
295
|
+
undefined,
|
|
296
|
+
]
|
|
297
|
+
}
|
|
298
|
+
themeIntent="danger"
|
|
299
|
+
themeVariant="filled"
|
|
300
|
+
>
|
|
301
|
+
<Text
|
|
302
|
+
style={
|
|
303
|
+
Array [
|
|
304
|
+
Object {
|
|
305
|
+
"color": "#001f23",
|
|
306
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
307
|
+
"fontSize": 12,
|
|
308
|
+
"includeFontPadding": false,
|
|
309
|
+
"textAlign": "center",
|
|
310
|
+
"textAlignVertical": "center",
|
|
311
|
+
},
|
|
312
|
+
undefined,
|
|
313
|
+
]
|
|
314
|
+
}
|
|
315
|
+
themeIntent="danger"
|
|
316
|
+
themeVariant="filled"
|
|
317
|
+
>
|
|
318
|
+
DANGER
|
|
319
|
+
</Text>
|
|
320
|
+
</View>
|
|
321
|
+
`;
|
|
322
|
+
|
|
323
|
+
exports[`Tag renders correctly when variant is filled and intent is warning 1`] = `
|
|
324
|
+
<View
|
|
325
|
+
style={
|
|
326
|
+
Array [
|
|
327
|
+
Object {
|
|
328
|
+
"backgroundColor": "#fff6eb",
|
|
329
|
+
"borderColor": "#fff6eb",
|
|
330
|
+
"borderRadius": 4,
|
|
331
|
+
"borderWidth": 1,
|
|
332
|
+
"paddingHorizontal": 8,
|
|
333
|
+
"paddingVertical": 2,
|
|
334
|
+
},
|
|
335
|
+
undefined,
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
themeIntent="warning"
|
|
339
|
+
themeVariant="filled"
|
|
340
|
+
>
|
|
341
|
+
<Text
|
|
342
|
+
style={
|
|
343
|
+
Array [
|
|
344
|
+
Object {
|
|
345
|
+
"color": "#001f23",
|
|
346
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
347
|
+
"fontSize": 12,
|
|
348
|
+
"includeFontPadding": false,
|
|
349
|
+
"textAlign": "center",
|
|
350
|
+
"textAlignVertical": "center",
|
|
351
|
+
},
|
|
352
|
+
undefined,
|
|
353
|
+
]
|
|
354
|
+
}
|
|
355
|
+
themeIntent="warning"
|
|
356
|
+
themeVariant="filled"
|
|
357
|
+
>
|
|
358
|
+
WARNING
|
|
359
|
+
</Text>
|
|
360
|
+
</View>
|
|
361
|
+
`;
|
|
362
|
+
|
|
363
|
+
exports[`Tag renders correctly with custom content 1`] = `
|
|
364
|
+
<View
|
|
365
|
+
style={
|
|
366
|
+
Array [
|
|
367
|
+
Object {
|
|
368
|
+
"backgroundColor": undefined,
|
|
369
|
+
"borderColor": "#401960",
|
|
370
|
+
"borderRadius": 4,
|
|
371
|
+
"borderWidth": 1,
|
|
372
|
+
"paddingHorizontal": 8,
|
|
373
|
+
"paddingVertical": 2,
|
|
374
|
+
},
|
|
375
|
+
undefined,
|
|
376
|
+
]
|
|
377
|
+
}
|
|
378
|
+
themeIntent="primary"
|
|
379
|
+
themeVariant="outlined"
|
|
380
|
+
>
|
|
381
|
+
<Text
|
|
382
|
+
style={
|
|
383
|
+
Array [
|
|
384
|
+
Object {
|
|
385
|
+
"color": "#001f23",
|
|
386
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
387
|
+
"fontSize": 14,
|
|
388
|
+
"letterSpacing": 0.42,
|
|
389
|
+
"lineHeight": 22,
|
|
390
|
+
},
|
|
391
|
+
undefined,
|
|
392
|
+
]
|
|
393
|
+
}
|
|
394
|
+
themeFontSize="medium"
|
|
395
|
+
themeFontWeight="regular"
|
|
396
|
+
themeIntent="body"
|
|
397
|
+
themeTypeface="neutral"
|
|
398
|
+
>
|
|
399
|
+
Custom Content
|
|
400
|
+
</Text>
|
|
401
|
+
</View>
|
|
402
|
+
`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
2
|
import type { StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
3
3
|
import { StyledView, StyledText } from './StyledTag';
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ interface TagProps extends ViewProps {
|
|
|
6
6
|
/**
|
|
7
7
|
* Content of the Tag.
|
|
8
8
|
*/
|
|
9
|
-
content: string;
|
|
9
|
+
content: string | ReactElement;
|
|
10
10
|
/**
|
|
11
11
|
* Visual intent color to apply to Tag.
|
|
12
12
|
*/
|
|
@@ -18,6 +18,10 @@ interface TagProps extends ViewProps {
|
|
|
18
18
|
| 'warning'
|
|
19
19
|
| 'danger'
|
|
20
20
|
| 'archived';
|
|
21
|
+
/**
|
|
22
|
+
* Tag variant.
|
|
23
|
+
*/
|
|
24
|
+
variant?: 'filled' | 'outlined';
|
|
21
25
|
/**
|
|
22
26
|
* Additional style.
|
|
23
27
|
*/
|
|
@@ -30,6 +34,7 @@ interface TagProps extends ViewProps {
|
|
|
30
34
|
|
|
31
35
|
const Tag = ({
|
|
32
36
|
content,
|
|
37
|
+
variant = 'outlined',
|
|
33
38
|
intent = 'primary',
|
|
34
39
|
style,
|
|
35
40
|
testID,
|
|
@@ -38,10 +43,17 @@ const Tag = ({
|
|
|
38
43
|
<StyledView
|
|
39
44
|
{...nativeProps}
|
|
40
45
|
themeIntent={intent}
|
|
46
|
+
themeVariant={variant}
|
|
41
47
|
style={style}
|
|
42
48
|
testID={testID}
|
|
43
49
|
>
|
|
44
|
-
|
|
50
|
+
{typeof content === 'string' ? (
|
|
51
|
+
<StyledText themeIntent={intent} themeVariant={variant}>
|
|
52
|
+
{content}
|
|
53
|
+
</StyledText>
|
|
54
|
+
) : (
|
|
55
|
+
content
|
|
56
|
+
)}
|
|
45
57
|
</StyledView>
|
|
46
58
|
);
|
|
47
59
|
|
|
@@ -766,6 +766,7 @@ Object {
|
|
|
766
766
|
"primaryBackground": undefined,
|
|
767
767
|
"success": "#017d6d",
|
|
768
768
|
"successBackground": "#f0fef4",
|
|
769
|
+
"text": "#001f23",
|
|
769
770
|
"warning": "#ffa234",
|
|
770
771
|
"warningBackground": "#fff6eb",
|
|
771
772
|
},
|
|
@@ -903,7 +904,7 @@ Object {
|
|
|
903
904
|
},
|
|
904
905
|
"colors": Object {
|
|
905
906
|
"background": "#ffffff",
|
|
906
|
-
"border": "#
|
|
907
|
+
"border": "#e8e9ea",
|
|
907
908
|
"danger": "#ffbe71",
|
|
908
909
|
"disabled": "#bfc1c5",
|
|
909
910
|
"error": "#f46363",
|
|
@@ -20,6 +20,7 @@ const getTagTheme = (theme: GlobalTheme) => {
|
|
|
20
20
|
dangerBackground: theme.colors.errorSurface,
|
|
21
21
|
archived: theme.colors.onArchivedSurface,
|
|
22
22
|
archivedBackground: theme.colors.archivedSurface,
|
|
23
|
+
text: theme.colors.onDefaultGlobalSurface,
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
const fonts = {
|
|
@@ -3,7 +3,7 @@ import type { GlobalTheme } from '../global';
|
|
|
3
3
|
const getToolbarTheme = (theme: GlobalTheme) => {
|
|
4
4
|
const colors = {
|
|
5
5
|
background: theme.colors.defaultGlobalSurface,
|
|
6
|
-
border: theme.colors.
|
|
6
|
+
border: theme.colors.secondaryOutline,
|
|
7
7
|
primary: theme.colors.primary,
|
|
8
8
|
secondary: theme.colors.secondary,
|
|
9
9
|
info: theme.colors.info,
|
package/src/utils/hooks.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
// Get previous state value
|
|
4
4
|
export const usePrevious = <T>(value: T) => {
|
|
@@ -8,3 +8,20 @@ export const usePrevious = <T>(value: T) => {
|
|
|
8
8
|
}, [value]);
|
|
9
9
|
return ref.current;
|
|
10
10
|
};
|
|
11
|
+
|
|
12
|
+
export function usePropsOrInternalState<T>(
|
|
13
|
+
initialState: T,
|
|
14
|
+
state: T | undefined,
|
|
15
|
+
setState: ((val: T) => void) | undefined
|
|
16
|
+
): [T, (val: T) => void] {
|
|
17
|
+
const [internalState, setInternalState] = React.useState<T>(initialState);
|
|
18
|
+
|
|
19
|
+
return [state || internalState, setState || setInternalState];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const useDeprecation = (message: string, cond = true) => {
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.warn(message);
|
|
26
|
+
}, [message, cond]);
|
|
27
|
+
};
|
|
@@ -24,7 +24,7 @@ interface CardProps extends ViewProps {
|
|
|
24
24
|
*/
|
|
25
25
|
testID?: string;
|
|
26
26
|
}
|
|
27
|
-
declare const _default: (({ variant, intent, children, ...nativeProps }: CardProps) => JSX.Element) & {
|
|
27
|
+
declare const _default: (({ variant: _variant, intent, children, ...nativeProps }: CardProps) => JSX.Element) & {
|
|
28
28
|
Data: ({ intent, children, ...nativeProps }: import("./DataCard").DataCardProps) => JSX.Element;
|
|
29
29
|
};
|
|
30
30
|
export default _default;
|
|
@@ -22,5 +22,5 @@ export interface MultiSelectProps<V, T extends OptionType<V> = OptionType<V>> ex
|
|
|
22
22
|
*/
|
|
23
23
|
renderSelectedValue?: (selectedValue: V[], inputProps: NativeTextInputProps) => React.ReactNode;
|
|
24
24
|
}
|
|
25
|
-
declare function MultiSelect<V, T extends OptionType<V>>({ footerLabel, label, loading, inputProps, onConfirm, onDimiss, onEndReached, onQueryChange, options, renderOption, renderSelectedValue, query, error, editable, disabled, numberOfLines, style, testID, value, }: MultiSelectProps<V, T>): JSX.Element;
|
|
25
|
+
declare function MultiSelect<V, T extends OptionType<V>>({ footerLabel, label, loading, inputProps, onConfirm, onDimiss, onDismiss, onEndReached, onQueryChange, options, renderOption, renderSelectedValue, query, error, editable, disabled, required, numberOfLines, style, testID, value, }: MultiSelectProps<V, T>): JSX.Element;
|
|
26
26
|
export default MultiSelect;
|
|
@@ -15,5 +15,5 @@ export interface SingleSelectProps<V, T extends OptionType<V> = OptionType<V>> e
|
|
|
15
15
|
*/
|
|
16
16
|
renderSelectedValue?: (selectedValue: V | null, inputProps: NativeTextInputProps) => React.ReactNode;
|
|
17
17
|
}
|
|
18
|
-
declare const SingleSelect: <V, T extends OptionType<V>>({ label, loading, inputProps, onConfirm, onDimiss, onEndReached, onQueryChange, options, renderOption, renderSelectedValue, query, error, editable, disabled, numberOfLines, style, testID, value, }: SingleSelectProps<V, T>) => JSX.Element;
|
|
18
|
+
declare const SingleSelect: <V, T extends OptionType<V>>({ label, loading, inputProps, onConfirm, onDimiss, onDismiss, onEndReached, onQueryChange, options, renderOption, renderSelectedValue, query, error, editable, disabled, required, numberOfLines, style, testID, value, }: SingleSelectProps<V, T>) => JSX.Element;
|
|
19
19
|
export default SingleSelect;
|