@hero-design/rn 7.22.1 → 7.22.3
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 +2 -2
- package/es/index.js +309 -284
- package/lib/index.js +309 -284
- package/package.json +4 -4
- package/src/components/Accordion/AccordionItem.tsx +1 -1
- package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +8 -8
- package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +12 -12
- package/src/components/Avatar/__tests__/__snapshots__/StyledAvatar.spec.tsx.snap +3 -3
- package/src/components/Avatar/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/components/BottomNavigation/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +2 -2
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +6 -6
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +24 -24
- package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +6 -6
- package/src/components/Card/DataCard/__tests__/__snapshots__/StyledDataCard.spec.tsx.snap +3 -3
- package/src/components/Card/DataCard/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +1 -1
- package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +1 -1
- package/src/components/Checkbox/__tests__/__snapshots__/StyledCheckbox.spec.tsx.snap +2 -2
- package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +5 -5
- package/src/components/ContentNavigator/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +4 -18
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +5 -19
- package/src/components/Drawer/__tests__/__snapshots__/index.spec.tsx.snap +3 -3
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +10 -10
- package/src/components/Icon/HeroIcon/index.tsx +2 -0
- package/src/components/Icon/__tests__/__snapshots__/index.spec.tsx.snap +1 -1
- package/src/components/Icon/index.tsx +1 -0
- package/src/components/List/StyledBasicListItem.tsx +1 -0
- package/src/components/List/__tests__/BasicListItem.spec.tsx +37 -13
- package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +163 -2
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +12 -12
- package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +6 -2
- package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +4 -4
- package/src/components/PinInput/__tests__/__snapshots__/PinCell.spec.tsx.snap +6 -6
- package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +21 -21
- package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +5 -5
- package/src/components/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +3 -1
- package/src/components/Radio/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +4 -1
- package/src/components/RichTextEditor/RichTextEditor.tsx +1 -3
- package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +1 -1
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +10 -38
- package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +1 -1
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +2 -1
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +25 -9
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +66 -108
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +2 -1
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +24 -8
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +57 -99
- package/src/components/Select/__tests__/__snapshots__/StyledSelect.spec.tsx.snap +1 -1
- package/src/components/Slider/__tests__/__snapshots__/index.spec.tsx.snap +3 -3
- package/src/components/Spinner/StyledSpinner.tsx +8 -4
- package/src/components/Spinner/__tests__/__snapshots__/AnimatedSpinner.spec.tsx.snap +8 -4
- package/src/components/Spinner/__tests__/__snapshots__/StyledSpinner.spec.tsx.snap +32 -16
- package/src/components/Spinner/__tests__/__snapshots__/index.spec.tsx.snap +8 -4
- package/src/components/Switch/__tests__/__snapshots__/StyledSwitch.spec.tsx.snap +3 -3
- package/src/components/Tabs/ScrollableTabs.tsx +2 -5
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +1 -1
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +1 -1
- package/src/components/TextInput/StyledTextInput.tsx +11 -16
- package/src/components/TextInput/__tests__/StyledTextInput.spec.tsx +3 -3
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +28 -46
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +67 -249
- package/src/components/TextInput/index.tsx +27 -27
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +4 -18
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +5 -19
- package/src/components/Toast/ToastProvider.tsx +2 -4
- package/src/components/Toast/__tests__/index.spec.tsx +138 -0
- package/src/components/Toolbar/ToolbarItem.tsx +1 -1
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +12 -12
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +6 -6
- package/src/components/Typography/Text/StyledText.tsx +1 -0
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +3 -3
- package/src/components/Typography/Text/index.tsx +1 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +93 -84
- package/src/theme/components/accordion.ts +1 -1
- package/src/theme/components/alert.ts +4 -4
- package/src/theme/components/avatar.ts +2 -2
- package/src/theme/components/badge.ts +6 -6
- package/src/theme/components/bottomNavigation.ts +2 -2
- package/src/theme/components/bottomSheet.ts +3 -3
- package/src/theme/components/button.ts +20 -20
- package/src/theme/components/calendar.ts +4 -4
- package/src/theme/components/card.ts +5 -5
- package/src/theme/components/checkbox.ts +1 -1
- package/src/theme/components/divider.ts +1 -1
- package/src/theme/components/drawer.ts +4 -4
- package/src/theme/components/empty.ts +3 -4
- package/src/theme/components/fab.ts +7 -7
- package/src/theme/components/icon.ts +4 -3
- package/src/theme/components/list.ts +8 -6
- package/src/theme/components/pinInput.ts +4 -4
- package/src/theme/components/progress.ts +3 -3
- package/src/theme/components/richTextEditor.ts +3 -3
- package/src/theme/components/sectionHeading.ts +1 -1
- package/src/theme/components/select.ts +1 -1
- package/src/theme/components/slider.ts +3 -3
- package/src/theme/components/spinner.ts +1 -4
- package/src/theme/components/switch.ts +7 -7
- package/src/theme/components/tabs.ts +5 -5
- package/src/theme/components/tag.ts +12 -12
- package/src/theme/components/textInput.ts +38 -38
- package/src/theme/components/toast.ts +6 -6
- package/src/theme/components/toolbar.ts +3 -2
- package/src/theme/components/typography.ts +4 -3
- package/src/theme/global/colors/global.ts +32 -0
- package/src/theme/global/colors/legacySystemPalette.ts +53 -0
- package/src/theme/global/colors/swag.ts +21 -34
- package/src/theme/global/colors/types.ts +46 -26
- package/src/theme/global/colors/work.ts +10 -9
- package/types/components/Icon/HeroIcon/index.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/TextInput/StyledTextInput.d.ts +3 -9
- package/types/components/TextInput/index.d.ts +4 -4
- package/types/components/Toast/__tests__/index.spec.d.ts +1 -0
- package/types/components/Toolbar/ToolbarItem.d.ts +1 -1
- package/types/components/Typography/Text/StyledText.d.ts +1 -1
- package/types/components/Typography/Text/index.d.ts +1 -1
- package/types/theme/components/empty.d.ts +0 -1
- package/types/theme/components/icon.d.ts +1 -0
- package/types/theme/components/list.d.ts +1 -0
- package/types/theme/components/spinner.d.ts +1 -4
- package/types/theme/components/toolbar.d.ts +1 -0
- package/types/theme/components/typography.d.ts +1 -0
- package/types/theme/global/colors/global.d.ts +3 -0
- package/types/theme/global/colors/legacySystemPalette.d.ts +3 -0
- package/types/theme/global/colors/types.d.ts +41 -20
- package/types/theme/global/index.d.ts +28 -19
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { StyleSheet } from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
3
|
import type {
|
|
4
4
|
TextInputProps as NativeTextInputProps,
|
|
5
5
|
StyleProp,
|
|
6
6
|
ViewStyle,
|
|
7
7
|
TextStyle,
|
|
8
|
-
} from
|
|
8
|
+
} from 'react-native';
|
|
9
9
|
import {
|
|
10
10
|
StyledTextInputContainer,
|
|
11
11
|
StyledLabel,
|
|
@@ -22,13 +22,12 @@ import {
|
|
|
22
22
|
StyledTextInputAndLabelContainer,
|
|
23
23
|
StyledLabelContainerInsideTextInput,
|
|
24
24
|
StyledErrorAndHelpTextContainer,
|
|
25
|
-
StyledBorderBackDrop,
|
|
26
25
|
StyledErrorAndMaxLengthContainer,
|
|
27
|
-
} from
|
|
28
|
-
import Icon from
|
|
29
|
-
import { useTheme } from
|
|
30
|
-
import type { Variant } from
|
|
31
|
-
import type { IconName } from
|
|
26
|
+
} from './StyledTextInput';
|
|
27
|
+
import Icon from '../Icon';
|
|
28
|
+
import { useTheme } from '../../theme';
|
|
29
|
+
import type { Variant } from './StyledTextInput';
|
|
30
|
+
import type { IconName } from '../Icon';
|
|
32
31
|
|
|
33
32
|
export interface TextInputProps extends NativeTextInputProps {
|
|
34
33
|
/**
|
|
@@ -114,21 +113,21 @@ export const getVariant = ({
|
|
|
114
113
|
isEmptyValue?: boolean;
|
|
115
114
|
}): Variant => {
|
|
116
115
|
if (disabled) {
|
|
117
|
-
return
|
|
116
|
+
return 'disabled';
|
|
118
117
|
}
|
|
119
118
|
if (error) {
|
|
120
|
-
return
|
|
119
|
+
return 'error';
|
|
121
120
|
}
|
|
122
121
|
if (!editable || loading) {
|
|
123
|
-
return
|
|
122
|
+
return 'readonly';
|
|
124
123
|
}
|
|
125
124
|
if (isFocused) {
|
|
126
|
-
return
|
|
125
|
+
return 'focused';
|
|
127
126
|
}
|
|
128
127
|
if (!isEmptyValue) {
|
|
129
|
-
return
|
|
128
|
+
return 'filled';
|
|
130
129
|
}
|
|
131
|
-
return
|
|
130
|
+
return 'default';
|
|
132
131
|
};
|
|
133
132
|
|
|
134
133
|
const TextInput = ({
|
|
@@ -151,9 +150,9 @@ const TextInput = ({
|
|
|
151
150
|
renderInputValue,
|
|
152
151
|
...nativeProps
|
|
153
152
|
}: TextInputProps): JSX.Element => {
|
|
154
|
-
const displayText = (value !== undefined ? value : defaultValue) ??
|
|
153
|
+
const displayText = (value !== undefined ? value : defaultValue) ?? '';
|
|
155
154
|
const isEmptyValue = displayText.length === 0;
|
|
156
|
-
const actualSuffix = loading ?
|
|
155
|
+
const actualSuffix = loading ? 'loading' : suffix;
|
|
157
156
|
|
|
158
157
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
159
158
|
|
|
@@ -175,9 +174,9 @@ const TextInput = ({
|
|
|
175
174
|
{ color: theme.__hd__.textInput.colors.text },
|
|
176
175
|
textStyle,
|
|
177
176
|
]),
|
|
178
|
-
testID:
|
|
177
|
+
testID: 'text-input',
|
|
179
178
|
accessibilityState: {
|
|
180
|
-
disabled: variant ===
|
|
179
|
+
disabled: variant === 'disabled' || variant === 'readonly',
|
|
181
180
|
},
|
|
182
181
|
// @ts-ignore
|
|
183
182
|
accessibilityLabelledBy,
|
|
@@ -197,18 +196,19 @@ const TextInput = ({
|
|
|
197
196
|
nativeProps.onChangeText?.(text);
|
|
198
197
|
},
|
|
199
198
|
defaultValue,
|
|
200
|
-
placeholder: variant ===
|
|
199
|
+
placeholder: variant === 'focused' ? nativeProps.placeholder : undefined,
|
|
201
200
|
};
|
|
202
201
|
|
|
203
202
|
return (
|
|
204
203
|
<StyledContainer
|
|
205
204
|
pointerEvents={
|
|
206
|
-
variant ===
|
|
205
|
+
variant === 'disabled' || variant === 'readonly' ? 'none' : 'auto'
|
|
207
206
|
}
|
|
208
207
|
testID={testID}
|
|
208
|
+
style={style}
|
|
209
|
+
themeVariant={variant}
|
|
209
210
|
>
|
|
210
211
|
<StyledTextInputContainer>
|
|
211
|
-
<StyledBorderBackDrop themeVariant={variant} style={style} />
|
|
212
212
|
{(isFocused || (label && !isEmptyValue)) && (
|
|
213
213
|
<StyledLabelContainer pointerEvents="none">
|
|
214
214
|
{required && (
|
|
@@ -228,9 +228,9 @@ const TextInput = ({
|
|
|
228
228
|
)}
|
|
229
229
|
</StyledLabelContainer>
|
|
230
230
|
)}
|
|
231
|
-
{typeof prefix ===
|
|
231
|
+
{typeof prefix === 'string' ? (
|
|
232
232
|
<Icon
|
|
233
|
-
intent={variant ===
|
|
233
|
+
intent={variant === 'disabled' ? 'disabled-text' : 'text'}
|
|
234
234
|
testID="input-prefix"
|
|
235
235
|
icon={prefix}
|
|
236
236
|
size="xsmall"
|
|
@@ -264,12 +264,12 @@ const TextInput = ({
|
|
|
264
264
|
<StyledTextInput {...nativeInputProps} />
|
|
265
265
|
)}
|
|
266
266
|
</StyledTextInputAndLabelContainer>
|
|
267
|
-
{typeof actualSuffix ===
|
|
267
|
+
{typeof actualSuffix === 'string' ? (
|
|
268
268
|
<Icon
|
|
269
|
-
intent={variant ===
|
|
269
|
+
intent={variant === 'disabled' ? 'disabled-text' : 'text'}
|
|
270
270
|
testID="input-suffix"
|
|
271
271
|
icon={actualSuffix}
|
|
272
|
-
spin={actualSuffix ===
|
|
272
|
+
spin={actualSuffix === 'loading'}
|
|
273
273
|
size="xsmall"
|
|
274
274
|
/>
|
|
275
275
|
) : (
|
|
@@ -26,12 +26,16 @@ exports[`TimePickerAndroid renders correctly 1`] = `
|
|
|
26
26
|
style={
|
|
27
27
|
Array [
|
|
28
28
|
Object {
|
|
29
|
+
"borderColor": "#001f23",
|
|
30
|
+
"borderRadius": 8,
|
|
31
|
+
"borderWidth": 1,
|
|
29
32
|
"marginVertical": 8,
|
|
30
33
|
"width": "100%",
|
|
31
34
|
},
|
|
32
35
|
undefined,
|
|
33
36
|
]
|
|
34
37
|
}
|
|
38
|
+
themeVariant="filled"
|
|
35
39
|
>
|
|
36
40
|
<View
|
|
37
41
|
style={
|
|
@@ -45,24 +49,6 @@ exports[`TimePickerAndroid renders correctly 1`] = `
|
|
|
45
49
|
]
|
|
46
50
|
}
|
|
47
51
|
>
|
|
48
|
-
<View
|
|
49
|
-
style={
|
|
50
|
-
Array [
|
|
51
|
-
Object {
|
|
52
|
-
"borderColor": "#001f23",
|
|
53
|
-
"borderRadius": 8,
|
|
54
|
-
"borderWidth": 1,
|
|
55
|
-
"bottom": 0,
|
|
56
|
-
"left": 0,
|
|
57
|
-
"position": "absolute",
|
|
58
|
-
"right": 0,
|
|
59
|
-
"top": 0,
|
|
60
|
-
},
|
|
61
|
-
undefined,
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
themeVariant="filled"
|
|
65
|
-
/>
|
|
66
52
|
<View
|
|
67
53
|
pointerEvents="none"
|
|
68
54
|
style={
|
|
@@ -26,12 +26,16 @@ exports[`TimePickerIOS renders correctly 1`] = `
|
|
|
26
26
|
style={
|
|
27
27
|
Array [
|
|
28
28
|
Object {
|
|
29
|
+
"borderColor": "#001f23",
|
|
30
|
+
"borderRadius": 8,
|
|
31
|
+
"borderWidth": 1,
|
|
29
32
|
"marginVertical": 8,
|
|
30
33
|
"width": "100%",
|
|
31
34
|
},
|
|
32
35
|
undefined,
|
|
33
36
|
]
|
|
34
37
|
}
|
|
38
|
+
themeVariant="filled"
|
|
35
39
|
>
|
|
36
40
|
<View
|
|
37
41
|
style={
|
|
@@ -45,24 +49,6 @@ exports[`TimePickerIOS renders correctly 1`] = `
|
|
|
45
49
|
]
|
|
46
50
|
}
|
|
47
51
|
>
|
|
48
|
-
<View
|
|
49
|
-
style={
|
|
50
|
-
Array [
|
|
51
|
-
Object {
|
|
52
|
-
"borderColor": "#001f23",
|
|
53
|
-
"borderRadius": 8,
|
|
54
|
-
"borderWidth": 1,
|
|
55
|
-
"bottom": 0,
|
|
56
|
-
"left": 0,
|
|
57
|
-
"position": "absolute",
|
|
58
|
-
"right": 0,
|
|
59
|
-
"top": 0,
|
|
60
|
-
},
|
|
61
|
-
undefined,
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
themeVariant="filled"
|
|
65
|
-
/>
|
|
66
52
|
<View
|
|
67
53
|
pointerEvents="none"
|
|
68
54
|
style={
|
|
@@ -502,7 +488,7 @@ exports[`TimePickerIOS renders correctly 1`] = `
|
|
|
502
488
|
style={
|
|
503
489
|
Array [
|
|
504
490
|
Object {
|
|
505
|
-
"color": "#
|
|
491
|
+
"color": "#001f23",
|
|
506
492
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
507
493
|
"fontSize": 16,
|
|
508
494
|
"letterSpacing": 0.48,
|
|
@@ -20,9 +20,7 @@ const ToastProvider = ({
|
|
|
20
20
|
position = 'top',
|
|
21
21
|
}: ToastProviderProps) => {
|
|
22
22
|
const toastRef = useRef<ToastControllerContextType>(null);
|
|
23
|
-
const [refState, setRefState] = useState<ToastControllerContextType>(
|
|
24
|
-
{} as ToastControllerContextType
|
|
25
|
-
);
|
|
23
|
+
const [refState, setRefState] = useState<ToastControllerContextType>(null);
|
|
26
24
|
|
|
27
25
|
useEffect(() => {
|
|
28
26
|
if (toastRef.current) {
|
|
@@ -38,7 +36,7 @@ const ToastProvider = ({
|
|
|
38
36
|
return (
|
|
39
37
|
<ToastContext.Provider value={refState}>
|
|
40
38
|
<View style={{ flex: 1 }}>
|
|
41
|
-
{children}
|
|
39
|
+
{refState ? children : null}
|
|
42
40
|
<ToastConfigContext.Provider value={config}>
|
|
43
41
|
<ToastContainer
|
|
44
42
|
ref={toastRef}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { fireEvent, waitFor } from '@testing-library/react-native';
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { Button, View } from 'react-native';
|
|
4
|
+
import Toast from '..';
|
|
5
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
6
|
+
|
|
7
|
+
describe('Toast', () => {
|
|
8
|
+
it(`"show" Toast when called correctly`, async () => {
|
|
9
|
+
const Component = () => {
|
|
10
|
+
const toast = Toast.useToast();
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
toast.show({
|
|
14
|
+
content: 'Your timesheet has been deleted.',
|
|
15
|
+
intent: 'warning',
|
|
16
|
+
variant: 'round',
|
|
17
|
+
duration: 50,
|
|
18
|
+
});
|
|
19
|
+
}, []);
|
|
20
|
+
|
|
21
|
+
return <View>Hello world</View>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const { queryByText } = renderWithTheme(
|
|
25
|
+
<Toast.Provider>
|
|
26
|
+
<Component />
|
|
27
|
+
</Toast.Provider>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
expect(queryByText('Your timesheet has been deleted.')).toBeTruthy();
|
|
31
|
+
await waitFor(() =>
|
|
32
|
+
expect(queryByText('Your timesheet has been deleted.')).toBeFalsy()
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it(`"show" Toast when called correctly`, async () => {
|
|
37
|
+
const Component = () => {
|
|
38
|
+
const toast = Toast.useToast();
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<View>
|
|
42
|
+
<Button
|
|
43
|
+
title="Show Toast"
|
|
44
|
+
onPress={() =>
|
|
45
|
+
toast.show({
|
|
46
|
+
content: 'Your timesheet has been deleted.',
|
|
47
|
+
intent: 'warning',
|
|
48
|
+
variant: 'round',
|
|
49
|
+
duration: 50,
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
/>
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const { queryByText } = renderWithTheme(
|
|
58
|
+
<Toast.Provider>
|
|
59
|
+
<Component />
|
|
60
|
+
</Toast.Provider>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
fireEvent.press(queryByText('Show Toast'));
|
|
64
|
+
expect(queryByText('Your timesheet has been deleted.')).toBeTruthy();
|
|
65
|
+
await waitFor(() =>
|
|
66
|
+
expect(queryByText('Your timesheet has been deleted.')).toBeFalsy()
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it(`"hide" method works correctly`, () => {
|
|
71
|
+
const Component = () => {
|
|
72
|
+
const toast = Toast.useToast();
|
|
73
|
+
const [id, setId] = useState(null);
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
const toastId = toast.show({
|
|
77
|
+
content: 'Your timesheet has been deleted.',
|
|
78
|
+
intent: 'warning',
|
|
79
|
+
variant: 'round',
|
|
80
|
+
});
|
|
81
|
+
setId(toastId);
|
|
82
|
+
}, []);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<View>
|
|
86
|
+
<Button title="Hide Toast" onPress={() => toast.hide(id)} />
|
|
87
|
+
</View>
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const { queryByText } = renderWithTheme(
|
|
92
|
+
<Toast.Provider>
|
|
93
|
+
<Component />
|
|
94
|
+
</Toast.Provider>
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
expect(queryByText('Your timesheet has been deleted.')).toBeTruthy();
|
|
98
|
+
fireEvent.press(queryByText('Hide Toast'));
|
|
99
|
+
expect(queryByText('Your timesheet has been deleted.')).toBeFalsy();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it(`"clearAll" method works correctly`, () => {
|
|
103
|
+
const Component = () => {
|
|
104
|
+
const toast = Toast.useToast();
|
|
105
|
+
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
toast.show({
|
|
108
|
+
content: 'Your timesheet has been deleted.',
|
|
109
|
+
intent: 'warning',
|
|
110
|
+
variant: 'round',
|
|
111
|
+
});
|
|
112
|
+
toast.show({
|
|
113
|
+
content: 'No more timesheet available.',
|
|
114
|
+
intent: 'warning',
|
|
115
|
+
variant: 'round',
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<View>
|
|
121
|
+
<Button title="Clear all Toast" onPress={() => toast.clearAll()} />
|
|
122
|
+
</View>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const { queryByText } = renderWithTheme(
|
|
127
|
+
<Toast.Provider displayType="stack">
|
|
128
|
+
<Component />
|
|
129
|
+
</Toast.Provider>
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
expect(queryByText('Your timesheet has been deleted.')).toBeTruthy();
|
|
133
|
+
expect(queryByText('No more timesheet available.')).toBeTruthy();
|
|
134
|
+
fireEvent.press(queryByText('Clear all Toast'));
|
|
135
|
+
expect(queryByText('Your timesheet has been deleted.')).toBeFalsy();
|
|
136
|
+
expect(queryByText('No more timesheet available.')).toBeFalsy();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -8,7 +8,7 @@ export interface ToolbarItemProps {
|
|
|
8
8
|
/**
|
|
9
9
|
* Visual intent of the toolbar item.
|
|
10
10
|
*/
|
|
11
|
-
intent?: 'primary' | 'info' | 'success' | 'danger' | 'warning';
|
|
11
|
+
intent?: 'primary' | 'secondary' | 'info' | 'success' | 'danger' | 'warning';
|
|
12
12
|
/**
|
|
13
13
|
* Icon of the toolbar item.
|
|
14
14
|
*/
|
|
@@ -41,7 +41,7 @@ exports[`ToolbarGroup renders correctly with when align is center 1`] = `
|
|
|
41
41
|
style={
|
|
42
42
|
Array [
|
|
43
43
|
Object {
|
|
44
|
-
"color": "#
|
|
44
|
+
"color": "#001f23",
|
|
45
45
|
"fontSize": 24,
|
|
46
46
|
},
|
|
47
47
|
undefined,
|
|
@@ -55,7 +55,7 @@ exports[`ToolbarGroup renders correctly with when align is center 1`] = `
|
|
|
55
55
|
style={
|
|
56
56
|
Array [
|
|
57
57
|
Object {
|
|
58
|
-
"color": "#
|
|
58
|
+
"color": "#001f23",
|
|
59
59
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
60
60
|
"fontSize": 12,
|
|
61
61
|
"letterSpacing": 0.36,
|
|
@@ -97,7 +97,7 @@ exports[`ToolbarGroup renders correctly with when align is center 1`] = `
|
|
|
97
97
|
style={
|
|
98
98
|
Array [
|
|
99
99
|
Object {
|
|
100
|
-
"color": "#
|
|
100
|
+
"color": "#001f23",
|
|
101
101
|
"fontSize": 24,
|
|
102
102
|
},
|
|
103
103
|
undefined,
|
|
@@ -111,7 +111,7 @@ exports[`ToolbarGroup renders correctly with when align is center 1`] = `
|
|
|
111
111
|
style={
|
|
112
112
|
Array [
|
|
113
113
|
Object {
|
|
114
|
-
"color": "#
|
|
114
|
+
"color": "#001f23",
|
|
115
115
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
116
116
|
"fontSize": 12,
|
|
117
117
|
"letterSpacing": 0.36,
|
|
@@ -171,7 +171,7 @@ exports[`ToolbarGroup renders correctly with when align is left 1`] = `
|
|
|
171
171
|
style={
|
|
172
172
|
Array [
|
|
173
173
|
Object {
|
|
174
|
-
"color": "#
|
|
174
|
+
"color": "#001f23",
|
|
175
175
|
"fontSize": 24,
|
|
176
176
|
},
|
|
177
177
|
undefined,
|
|
@@ -185,7 +185,7 @@ exports[`ToolbarGroup renders correctly with when align is left 1`] = `
|
|
|
185
185
|
style={
|
|
186
186
|
Array [
|
|
187
187
|
Object {
|
|
188
|
-
"color": "#
|
|
188
|
+
"color": "#001f23",
|
|
189
189
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
190
190
|
"fontSize": 12,
|
|
191
191
|
"letterSpacing": 0.36,
|
|
@@ -227,7 +227,7 @@ exports[`ToolbarGroup renders correctly with when align is left 1`] = `
|
|
|
227
227
|
style={
|
|
228
228
|
Array [
|
|
229
229
|
Object {
|
|
230
|
-
"color": "#
|
|
230
|
+
"color": "#001f23",
|
|
231
231
|
"fontSize": 24,
|
|
232
232
|
},
|
|
233
233
|
undefined,
|
|
@@ -241,7 +241,7 @@ exports[`ToolbarGroup renders correctly with when align is left 1`] = `
|
|
|
241
241
|
style={
|
|
242
242
|
Array [
|
|
243
243
|
Object {
|
|
244
|
-
"color": "#
|
|
244
|
+
"color": "#001f23",
|
|
245
245
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
246
246
|
"fontSize": 12,
|
|
247
247
|
"letterSpacing": 0.36,
|
|
@@ -301,7 +301,7 @@ exports[`ToolbarGroup renders correctly with when align is right 1`] = `
|
|
|
301
301
|
style={
|
|
302
302
|
Array [
|
|
303
303
|
Object {
|
|
304
|
-
"color": "#
|
|
304
|
+
"color": "#001f23",
|
|
305
305
|
"fontSize": 24,
|
|
306
306
|
},
|
|
307
307
|
undefined,
|
|
@@ -315,7 +315,7 @@ exports[`ToolbarGroup renders correctly with when align is right 1`] = `
|
|
|
315
315
|
style={
|
|
316
316
|
Array [
|
|
317
317
|
Object {
|
|
318
|
-
"color": "#
|
|
318
|
+
"color": "#001f23",
|
|
319
319
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
320
320
|
"fontSize": 12,
|
|
321
321
|
"letterSpacing": 0.36,
|
|
@@ -357,7 +357,7 @@ exports[`ToolbarGroup renders correctly with when align is right 1`] = `
|
|
|
357
357
|
style={
|
|
358
358
|
Array [
|
|
359
359
|
Object {
|
|
360
|
-
"color": "#
|
|
360
|
+
"color": "#001f23",
|
|
361
361
|
"fontSize": 24,
|
|
362
362
|
},
|
|
363
363
|
undefined,
|
|
@@ -371,7 +371,7 @@ exports[`ToolbarGroup renders correctly with when align is right 1`] = `
|
|
|
371
371
|
style={
|
|
372
372
|
Array [
|
|
373
373
|
Object {
|
|
374
|
-
"color": "#
|
|
374
|
+
"color": "#001f23",
|
|
375
375
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
376
376
|
"fontSize": 12,
|
|
377
377
|
"letterSpacing": 0.36,
|
|
@@ -27,7 +27,7 @@ exports[`ToolbarItems renders correctly when disabled 1`] = `
|
|
|
27
27
|
style={
|
|
28
28
|
Array [
|
|
29
29
|
Object {
|
|
30
|
-
"color": "#
|
|
30
|
+
"color": "#4d6265",
|
|
31
31
|
"fontSize": 24,
|
|
32
32
|
},
|
|
33
33
|
undefined,
|
|
@@ -41,7 +41,7 @@ exports[`ToolbarItems renders correctly when disabled 1`] = `
|
|
|
41
41
|
style={
|
|
42
42
|
Array [
|
|
43
43
|
Object {
|
|
44
|
-
"color": "#
|
|
44
|
+
"color": "#4d6265",
|
|
45
45
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
46
46
|
"fontSize": 12,
|
|
47
47
|
"letterSpacing": 0.36,
|
|
@@ -145,7 +145,7 @@ exports[`ToolbarItems renders correctly when intent is info 1`] = `
|
|
|
145
145
|
style={
|
|
146
146
|
Array [
|
|
147
147
|
Object {
|
|
148
|
-
"color": "#
|
|
148
|
+
"color": "#b5c3fd",
|
|
149
149
|
"fontSize": 24,
|
|
150
150
|
},
|
|
151
151
|
undefined,
|
|
@@ -159,7 +159,7 @@ exports[`ToolbarItems renders correctly when intent is info 1`] = `
|
|
|
159
159
|
style={
|
|
160
160
|
Array [
|
|
161
161
|
Object {
|
|
162
|
-
"color": "#
|
|
162
|
+
"color": "#b5c3fd",
|
|
163
163
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
164
164
|
"fontSize": 12,
|
|
165
165
|
"letterSpacing": 0.36,
|
|
@@ -204,7 +204,7 @@ exports[`ToolbarItems renders correctly when intent is primary 1`] = `
|
|
|
204
204
|
style={
|
|
205
205
|
Array [
|
|
206
206
|
Object {
|
|
207
|
-
"color": "#
|
|
207
|
+
"color": "#001f23",
|
|
208
208
|
"fontSize": 24,
|
|
209
209
|
},
|
|
210
210
|
undefined,
|
|
@@ -218,7 +218,7 @@ exports[`ToolbarItems renders correctly when intent is primary 1`] = `
|
|
|
218
218
|
style={
|
|
219
219
|
Array [
|
|
220
220
|
Object {
|
|
221
|
-
"color": "#
|
|
221
|
+
"color": "#001f23",
|
|
222
222
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
223
223
|
"fontSize": 12,
|
|
224
224
|
"letterSpacing": 0.36,
|
|
@@ -49,7 +49,7 @@ exports[`StyledText has info intent style 1`] = `
|
|
|
49
49
|
style={
|
|
50
50
|
Array [
|
|
51
51
|
Object {
|
|
52
|
-
"color": "#
|
|
52
|
+
"color": "#b5c3fd",
|
|
53
53
|
"fontFamily": "BeVietnamPro-Regular",
|
|
54
54
|
"fontSize": 14,
|
|
55
55
|
"letterSpacing": 0.42,
|
|
@@ -159,7 +159,7 @@ exports[`StyledText has primary intent style 1`] = `
|
|
|
159
159
|
style={
|
|
160
160
|
Array [
|
|
161
161
|
Object {
|
|
162
|
-
"color": "#
|
|
162
|
+
"color": "#001f23",
|
|
163
163
|
"fontFamily": "BeVietnamPro-Regular",
|
|
164
164
|
"fontSize": 14,
|
|
165
165
|
"letterSpacing": 0.42,
|
|
@@ -247,7 +247,7 @@ exports[`StyledText has subdued intent style 1`] = `
|
|
|
247
247
|
style={
|
|
248
248
|
Array [
|
|
249
249
|
Object {
|
|
250
|
-
"color": "#
|
|
250
|
+
"color": "#4d6265",
|
|
251
251
|
"fontFamily": "BeVietnamPro-Regular",
|
|
252
252
|
"fontSize": 14,
|
|
253
253
|
"letterSpacing": 0.42,
|