@hero-design/rn 8.42.4 → 8.43.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.
Files changed (50) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +11 -0
  3. package/assets/fonts/hero-icons-mobile.ttf +0 -0
  4. package/es/index.js +670 -499
  5. package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
  6. package/lib/index.js +1109 -937
  7. package/package.json +1 -1
  8. package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +197 -211
  9. package/src/components/BottomSheet/index.tsx +1 -1
  10. package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +6 -10
  11. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +0 -20
  12. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +0 -70
  13. package/src/components/Button/StyledButton.tsx +4 -0
  14. package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +16 -42
  15. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +10 -0
  16. package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +3 -0
  17. package/src/components/Carousel/__tests__/index.spec.tsx +8 -10
  18. package/src/components/Chip/StyledChip.tsx +121 -0
  19. package/src/components/Chip/__tests__/__snapshots__/index.spec.tsx.snap +943 -0
  20. package/src/components/Chip/__tests__/index.spec.tsx +136 -0
  21. package/src/components/Chip/index.tsx +82 -0
  22. package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +12 -0
  23. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +417 -399
  24. package/src/components/Error/__tests__/index.spec.tsx +9 -6
  25. package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
  26. package/src/components/Icon/IconList.ts +1 -0
  27. package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +8 -10
  28. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +367 -451
  29. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +7 -10
  30. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +357 -419
  31. package/src/components/Success/__tests__/index.spec.tsx +9 -6
  32. package/src/components/Tabs/__tests__/SceneView.spec.tsx +19 -23
  33. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +417 -399
  34. package/src/index.ts +2 -0
  35. package/src/testHelpers/renderWithTheme.tsx +1 -7
  36. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +38 -1
  37. package/src/theme/components/button.ts +0 -1
  38. package/src/theme/components/chip.ts +47 -0
  39. package/src/theme/getTheme.ts +3 -0
  40. package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +3 -3
  41. package/types/components/Chip/StyledChip.d.ts +31 -0
  42. package/types/components/Chip/index.d.ts +26 -0
  43. package/types/components/Icon/IconList.d.ts +1 -1
  44. package/types/components/Icon/index.d.ts +1 -1
  45. package/types/components/Icon/utils.d.ts +1 -1
  46. package/types/index.d.ts +2 -1
  47. package/types/theme/components/button.d.ts +0 -1
  48. package/types/theme/components/chip.d.ts +40 -0
  49. package/types/theme/getTheme.d.ts +2 -0
  50. package/.turbo/turbo-publish:npm.log +0 -0
@@ -0,0 +1,136 @@
1
+ import React from 'react';
2
+ import { fireEvent } from '@testing-library/react-native';
3
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
4
+ import Chip from '..';
5
+
6
+ describe('Chip', () => {
7
+ it.each`
8
+ selected
9
+ ${true}
10
+ ${false}
11
+ `('renders correctly when selected is $selected', ({ selected }) => {
12
+ const { getByText, toJSON } = renderWithTheme(
13
+ <Chip label="Cover my bills" selected={selected} />
14
+ );
15
+
16
+ expect(getByText('Cover my bills')).toBeTruthy();
17
+ expect(toJSON()).toMatchSnapshot();
18
+ });
19
+
20
+ it('renders correctly with default icon', () => {
21
+ const ChipWithoutIcon = () => {
22
+ const [selected, setSelected] = React.useState(false);
23
+
24
+ return (
25
+ <Chip
26
+ label="Cover my bills"
27
+ testID="chip"
28
+ selected={selected}
29
+ onPress={() => setSelected(!selected)}
30
+ />
31
+ );
32
+ };
33
+
34
+ const { getByTestId, queryByTestId, toJSON } = renderWithTheme(
35
+ <ChipWithoutIcon />
36
+ );
37
+
38
+ expect(queryByTestId('chip-icon-checkmark')).toBeFalsy();
39
+ expect(toJSON()).toMatchSnapshot();
40
+
41
+ fireEvent.press(getByTestId('chip'));
42
+
43
+ expect(getByTestId('chip-icon-checkmark')).toBeTruthy();
44
+ expect(toJSON()).toMatchSnapshot();
45
+ });
46
+
47
+ it('does not render icon when variant is outlined', () => {
48
+ const ChipWithIcon = () => {
49
+ const [selected, setSelected] = React.useState(false);
50
+
51
+ return (
52
+ <Chip
53
+ label="Cover my bills"
54
+ testID="chip"
55
+ icon="charging-station-outlined"
56
+ selected={selected}
57
+ variant="outlined"
58
+ onPress={() => setSelected(!selected)}
59
+ />
60
+ );
61
+ };
62
+
63
+ const { getByTestId, toJSON, queryByTestId } = renderWithTheme(
64
+ <ChipWithIcon />
65
+ );
66
+
67
+ expect(queryByTestId('chip-icon-charging-station-outlined')).toBeFalsy();
68
+ expect(toJSON()).toMatchSnapshot();
69
+
70
+ fireEvent.press(getByTestId('chip'));
71
+
72
+ expect(queryByTestId('chip-icon-charging-station-outlined')).toBeFalsy();
73
+ expect(toJSON()).toMatchSnapshot();
74
+ });
75
+
76
+ it('renders correctly with custom icon', () => {
77
+ const ChipWithIcon = () => {
78
+ const [selected, setSelected] = React.useState(false);
79
+
80
+ return (
81
+ <Chip
82
+ label="Cover my bills"
83
+ testID="chip"
84
+ icon="charging-station-outlined"
85
+ selected={selected}
86
+ variant="filled"
87
+ onPress={() => setSelected(!selected)}
88
+ />
89
+ );
90
+ };
91
+
92
+ const { getByTestId, toJSON } = renderWithTheme(<ChipWithIcon />);
93
+
94
+ expect(getByTestId('chip-icon-charging-station-outlined')).toBeTruthy();
95
+ expect(toJSON()).toMatchSnapshot();
96
+
97
+ fireEvent.press(getByTestId('chip'));
98
+
99
+ expect(getByTestId('chip-icon-charging-station-outlined')).toBeTruthy();
100
+ expect(toJSON()).toMatchSnapshot();
101
+ });
102
+
103
+ it.each`
104
+ variant | selected
105
+ ${'filled'} | ${true}
106
+ ${'filled'} | ${false}
107
+ ${'outlined'} | ${true}
108
+ ${'outlined'} | ${false}
109
+ `(
110
+ 'renders correctly with variant $variant and selected $selected',
111
+ ({ variant, selected }) => {
112
+ const { toJSON } = renderWithTheme(
113
+ <Chip
114
+ label="Cover my bills"
115
+ testID="chip"
116
+ variant={variant}
117
+ selected={selected}
118
+ />
119
+ );
120
+
121
+ expect(toJSON()).toMatchSnapshot();
122
+ }
123
+ );
124
+
125
+ it('calls onPress when pressed', () => {
126
+ const onPress = jest.fn();
127
+
128
+ const { getByTestId } = renderWithTheme(
129
+ <Chip label="Cover my bills" testID="chip" onPress={onPress} />
130
+ );
131
+
132
+ fireEvent.press(getByTestId('chip'));
133
+
134
+ expect(onPress).toHaveBeenCalledTimes(1);
135
+ });
136
+ });
@@ -0,0 +1,82 @@
1
+ import React from 'react';
2
+ import { ViewProps } from 'react-native';
3
+ import { IconName } from '../Icon';
4
+ import {
5
+ StyledChipWrapper,
6
+ StyledIcon,
7
+ StyledIconWrapper,
8
+ StyledLabel,
9
+ } from './StyledChip';
10
+
11
+ export interface ChipProps extends ViewProps {
12
+ /**
13
+ * The label of the chip.
14
+ */
15
+ label: string;
16
+ /**
17
+ * Variant of the chip.
18
+ */
19
+ variant?: 'outlined' | 'filled';
20
+ /**
21
+ * Whether the chip is selected.
22
+ */
23
+ selected?: boolean;
24
+ /**
25
+ * Icon of the chip. Usable only with `variant="filled"`.
26
+ */
27
+ icon?: IconName;
28
+ /**
29
+ * Callback when the chip is pressed.
30
+ */
31
+ onPress?: () => void;
32
+ }
33
+
34
+ const Chip = ({
35
+ label,
36
+ variant = 'outlined',
37
+ selected = false,
38
+ icon,
39
+ onPress,
40
+ ...otherProps
41
+ }: ChipProps) => {
42
+ const internalIcon = React.useMemo(() => {
43
+ if (icon && variant === 'filled') {
44
+ return icon;
45
+ }
46
+ if (selected) {
47
+ return 'checkmark';
48
+ }
49
+ return undefined;
50
+ }, [icon, selected, variant]);
51
+
52
+ return (
53
+ <StyledChipWrapper
54
+ onPress={onPress}
55
+ themeVariant={variant}
56
+ themeSelected={selected}
57
+ {...otherProps}
58
+ >
59
+ {internalIcon && (
60
+ <StyledIconWrapper>
61
+ <StyledIcon
62
+ size="xsmall"
63
+ icon={internalIcon}
64
+ themeSelected={selected}
65
+ themeVariant={variant}
66
+ testID={`chip-icon-${internalIcon}`}
67
+ />
68
+ </StyledIconWrapper>
69
+ )}
70
+
71
+ <StyledLabel
72
+ variant="small"
73
+ themeVariant={variant}
74
+ themeSelected={selected}
75
+ >
76
+ {label}
77
+ </StyledLabel>
78
+ </StyledChipWrapper>
79
+ );
80
+ };
81
+
82
+ export default Chip;
@@ -443,6 +443,12 @@ exports[`DatePicker renders DatePickerIOS when OS is iOS 1`] = `
443
443
  </View>
444
444
  </View>
445
445
  </View>
446
+ <Modal
447
+ hardwareAccelerated={false}
448
+ onRequestClose={[Function]}
449
+ transparent={true}
450
+ visible={false}
451
+ />
446
452
  </View>
447
453
  `;
448
454
 
@@ -666,5 +672,11 @@ exports[`DatePicker renders variant Calendar 1`] = `
666
672
  </View>
667
673
  </View>
668
674
  </View>
675
+ <Modal
676
+ hardwareAccelerated={false}
677
+ onRequestClose={[Function]}
678
+ transparent={true}
679
+ visible={false}
680
+ />
669
681
  </View>
670
682
  `;