@hero-design/rn 8.27.0 → 8.27.2
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 +1 -1
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +319 -311
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +319 -311
- package/package.json +5 -5
- package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +6 -6
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +2 -2
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +2 -2
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +2 -2
- package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +3 -17
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +1065 -557
- package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +15 -9
- package/src/components/FAB/ActionGroup/index.tsx +35 -97
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +1 -0
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +10 -10
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +10 -10
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +10 -10
- package/src/components/TextInput/index.tsx +1 -1
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +2 -2
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +2 -2
- package/src/components/Toolbar/StyledToolbar.tsx +23 -2
- package/src/components/Toolbar/ToolbarGroup.tsx +3 -4
- package/src/components/Toolbar/ToolbarItem.tsx +75 -19
- package/src/components/Toolbar/__tests__/ToolbarItem.spec.tsx +39 -22
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +318 -186
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +280 -135
- package/src/components/Typography/Text/StyledText.tsx +2 -1
- package/src/components/Typography/Text/index.tsx +2 -1
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +11 -2
- package/src/theme/components/fab.ts +0 -1
- package/src/theme/components/toolbar.ts +14 -2
- package/src/theme/components/typography.ts +1 -0
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +1 -7
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/components/Toolbar/StyledToolbar.d.ts +11 -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/fab.d.ts +0 -1
- package/types/theme/components/toolbar.d.ts +9 -0
- package/types/theme/components/typography.d.ts +1 -0
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { ToolbarGroupWrapper } from './StyledToolbar';
|
|
3
3
|
import ToolbarItem from './ToolbarItem';
|
|
4
4
|
import type { ToolbarItemProps } from './ToolbarItem';
|
|
5
|
+
import { useDeprecation } from '../../utils/hooks';
|
|
5
6
|
|
|
6
7
|
export interface ToolbarGroupProps {
|
|
7
8
|
/**
|
|
@@ -15,9 +16,8 @@ export interface ToolbarGroupProps {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
const ToolbarGroup = ({ align = 'right', items = [] }: ToolbarGroupProps) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const maxWidth = items.length > 0 ? `${100 / items.length}%` : undefined;
|
|
19
|
+
useDeprecation("Toolbar's align prop is deprecated", align !== 'right');
|
|
20
|
+
|
|
21
21
|
return (
|
|
22
22
|
<ToolbarGroupWrapper align={align}>
|
|
23
23
|
{items.map(({ label, icon, onPress, disabled, intent }) => (
|
|
@@ -28,7 +28,6 @@ const ToolbarGroup = ({ align = 'right', items = [] }: ToolbarGroupProps) => {
|
|
|
28
28
|
intent={intent}
|
|
29
29
|
onPress={onPress}
|
|
30
30
|
disabled={disabled}
|
|
31
|
-
style={{ maxWidth }}
|
|
32
31
|
/>
|
|
33
32
|
))}
|
|
34
33
|
</ToolbarGroupWrapper>
|
|
@@ -2,7 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
3
|
import Icon from '../Icon';
|
|
4
4
|
import Typography from '../Typography';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
IconButtonLabel,
|
|
7
|
+
IconButtonWrapper,
|
|
8
|
+
ToolbarItemWrapper,
|
|
9
|
+
} from './StyledToolbar';
|
|
6
10
|
import type { IconName } from '../Icon';
|
|
7
11
|
|
|
8
12
|
export interface ToolbarItemProps {
|
|
@@ -33,35 +37,87 @@ export interface ToolbarItemProps {
|
|
|
33
37
|
style?: StyleProp<ViewStyle>;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
icon
|
|
38
|
-
label
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}:
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
type IconItemProps = {
|
|
41
|
+
icon: IconName;
|
|
42
|
+
label?: string;
|
|
43
|
+
intent?: ToolbarItemProps['intent'];
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const IconItem = ({ icon, intent, disabled, label }: IconItemProps) => {
|
|
48
|
+
return (
|
|
49
|
+
<IconButtonWrapper>
|
|
46
50
|
<Icon
|
|
47
51
|
icon={icon}
|
|
48
|
-
size=
|
|
52
|
+
size="medium"
|
|
49
53
|
intent={disabled ? 'disabled-text' : intent}
|
|
50
54
|
testID={`toolbar-item-icon-${icon}`}
|
|
51
55
|
/>
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
{label ? (
|
|
57
|
+
<IconButtonLabel
|
|
58
|
+
fontSize="large"
|
|
59
|
+
fontWeight="semi-bold"
|
|
60
|
+
intent={disabled ? 'subdued' : intent}
|
|
61
|
+
allowFontScaling={false}
|
|
62
|
+
numberOfLines={1}
|
|
63
|
+
>
|
|
64
|
+
{label}
|
|
65
|
+
</IconButtonLabel>
|
|
66
|
+
) : null}
|
|
67
|
+
</IconButtonWrapper>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type ToolbarItemContentProps = {
|
|
72
|
+
icon?: IconName;
|
|
73
|
+
label?: string;
|
|
74
|
+
intent?: ToolbarItemProps['intent'];
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
};
|
|
77
|
+
const ToolbarItemContent = ({
|
|
78
|
+
icon,
|
|
79
|
+
label,
|
|
80
|
+
intent = 'primary',
|
|
81
|
+
disabled = false,
|
|
82
|
+
}: ToolbarItemContentProps): JSX.Element | null => {
|
|
83
|
+
if (icon) {
|
|
84
|
+
return (
|
|
85
|
+
<IconItem icon={icon} intent={intent} disabled={disabled} label={label} />
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (label) {
|
|
89
|
+
return (
|
|
54
90
|
<Typography.Text
|
|
55
|
-
fontSize=
|
|
91
|
+
fontSize="large"
|
|
56
92
|
fontWeight="semi-bold"
|
|
57
|
-
intent={disabled ? '
|
|
93
|
+
intent={disabled ? 'disabled' : intent}
|
|
58
94
|
allowFontScaling={false}
|
|
59
95
|
numberOfLines={1}
|
|
60
96
|
>
|
|
61
97
|
{label}
|
|
62
98
|
</Typography.Text>
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
};
|
|
103
|
+
const ToolbarItem = ({
|
|
104
|
+
icon,
|
|
105
|
+
label,
|
|
106
|
+
onPress,
|
|
107
|
+
intent = 'primary',
|
|
108
|
+
disabled = false,
|
|
109
|
+
style,
|
|
110
|
+
}: ToolbarItemProps) => {
|
|
111
|
+
return (
|
|
112
|
+
<ToolbarItemWrapper onPress={onPress} disabled={disabled} style={style}>
|
|
113
|
+
<ToolbarItemContent
|
|
114
|
+
icon={icon}
|
|
115
|
+
label={label}
|
|
116
|
+
intent={intent}
|
|
117
|
+
disabled={disabled}
|
|
118
|
+
/>
|
|
119
|
+
</ToolbarItemWrapper>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
66
122
|
|
|
67
123
|
export default ToolbarItem;
|
|
@@ -5,30 +5,47 @@ import ToolbarItem from '../ToolbarItem';
|
|
|
5
5
|
|
|
6
6
|
describe('ToolbarItems', () => {
|
|
7
7
|
it.each`
|
|
8
|
-
intent
|
|
9
|
-
${'primary'}
|
|
10
|
-
${'
|
|
11
|
-
${'
|
|
12
|
-
${'
|
|
13
|
-
${'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
intent | icon | label | disabled
|
|
9
|
+
${'primary'} | ${'ai-outlined'} | ${'Try again'} | ${false}
|
|
10
|
+
${'primary'} | ${'ai-outlined'} | ${undefined} | ${false}
|
|
11
|
+
${'primary'} | ${'ai-outlined'} | ${'Try again'} | ${true}
|
|
12
|
+
${'info'} | ${undefined} | ${'Save'} | ${false}
|
|
13
|
+
${'success'} | ${undefined} | ${'Save'} | ${false}
|
|
14
|
+
${'danger'} | ${undefined} | ${'Discard'} | ${false}
|
|
15
|
+
${'warning'} | ${undefined} | ${'Warning'} | ${false}
|
|
16
|
+
`(
|
|
17
|
+
'renders correctly when intent is $intent, icon is $icon, label is $label and disabled is $disabled',
|
|
18
|
+
({ intent, icon, label, disabled }) => {
|
|
19
|
+
const onPress = jest.fn();
|
|
20
|
+
const { toJSON, getByText, getByTestId } = renderWithTheme(
|
|
21
|
+
<ToolbarItem
|
|
22
|
+
label={label}
|
|
23
|
+
intent={intent}
|
|
24
|
+
icon={icon}
|
|
25
|
+
onPress={onPress}
|
|
26
|
+
disabled={disabled}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
expect(toJSON()).toMatchSnapshot();
|
|
31
|
+
if (icon) {
|
|
32
|
+
expect(getByTestId(`toolbar-item-icon-${icon}`)).toBeDefined();
|
|
33
|
+
}
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
if (label) {
|
|
36
|
+
expect(getByText(label)).toBeDefined();
|
|
37
|
+
fireEvent.press(getByText(label));
|
|
38
|
+
if (disabled) {
|
|
39
|
+
expect(onPress).not.toBeCalled();
|
|
40
|
+
} else {
|
|
41
|
+
expect(onPress).toBeCalled();
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
fireEvent.press(getByTestId(`toolbar-item-icon-${icon}`));
|
|
45
|
+
expect(onPress).toBeCalled();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
);
|
|
32
49
|
|
|
33
50
|
it('renders correctly when disabled', () => {
|
|
34
51
|
const onPress = jest.fn();
|