@hero-design/rn 8.74.1 → 8.75.0-alpha.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 (41) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/es/index.js +411 -139
  3. package/lib/index.js +411 -138
  4. package/package.json +1 -1
  5. package/src/components/BottomSheet/__tests__/index.spec.tsx +17 -153
  6. package/src/components/BottomSheet/index.tsx +2 -0
  7. package/src/components/Collapse/__tests__/index.spec.tsx +2 -5
  8. package/src/components/FloatingIsland/StyledFloatingIsland.tsx +32 -0
  9. package/src/components/FloatingIsland/__tests__/__snapshots__/index.spec.tsx.snap +561 -0
  10. package/src/components/FloatingIsland/__tests__/index.spec.tsx +67 -0
  11. package/src/components/FloatingIsland/index.tsx +94 -0
  12. package/src/components/Toolbar/StyledToolbar.tsx +50 -1
  13. package/src/components/Toolbar/ToolbarMessage.tsx +169 -0
  14. package/src/components/Toolbar/__tests__/ToolbarMessage.spec.tsx +161 -0
  15. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarMessage.spec.tsx.snap +382 -0
  16. package/src/components/Toolbar/index.tsx +2 -0
  17. package/src/index.ts +2 -0
  18. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +46 -0
  19. package/src/theme/components/floatingIsland.ts +31 -0
  20. package/src/theme/components/toolbar.ts +19 -1
  21. package/src/theme/getTheme.ts +3 -0
  22. package/stats/8.75.0/rn-stats.html +4844 -0
  23. package/types/components/CompoundSearch/CompoundSearchHandler.d.ts +31 -0
  24. package/types/components/CompoundSearch/CompoundSearchTextInput.d.ts +60 -0
  25. package/types/components/CompoundSearch/StyledCompoundSearch.d.ts +40 -0
  26. package/types/components/CompoundSearch/index.d.ts +8 -0
  27. package/types/components/CompoundSearch/utils.d.ts +8 -0
  28. package/types/components/FloatingIsland/SingleLine/StyledSingleLine.d.ts +15 -0
  29. package/types/components/FloatingIsland/SingleLine/index.d.ts +24 -0
  30. package/types/components/FloatingIsland/StyledFloatingIsland.d.ts +19 -0
  31. package/types/components/FloatingIsland/index.d.ts +23 -0
  32. package/types/components/Toolbar/StyledToolbar.d.ts +33 -2
  33. package/types/components/Toolbar/ToolbarMessage.d.ts +59 -0
  34. package/types/components/Toolbar/index.d.ts +1 -0
  35. package/types/index.d.ts +2 -1
  36. package/types/theme/components/compoundSearch.d.ts +36 -0
  37. package/types/theme/components/floatingIsland.d.ts +32 -0
  38. package/types/theme/components/toolbar.d.ts +16 -0
  39. package/types/theme/getTheme.d.ts +2 -0
  40. package/.turbo/turbo-build.log +0 -7
  41. package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +0 -751
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.74.1",
3
+ "version": "8.75.0-alpha.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -3,169 +3,33 @@ import React from 'react';
3
3
  import { Button, Text } from 'react-native';
4
4
  import BottomSheet from '..';
5
5
  import renderWithTheme from '../../../testHelpers/renderWithTheme';
6
- import { setOrientation } from '../../../testHelpers/utils';
7
6
 
8
7
  const Content = () => <Text>Content</Text>;
9
8
 
10
- describe('BottomSheet', () => {
11
- it('renders correctly with open state', () => {
12
- const { toJSON, getByText } = renderWithTheme(
9
+ const Test = () => {
10
+ const [open, setOpen] = React.useState(false);
11
+ return (
12
+ <>
13
13
  <BottomSheet
14
- open
15
- header="Title"
16
- footer={<Button title="Footer CTA" />}
17
- onRequestClose={jest.fn()}
14
+ header="Header title"
15
+ open={open}
16
+ onRequestClose={() => setOpen(false)}
18
17
  >
19
18
  <Content />
20
19
  </BottomSheet>
21
- );
22
-
23
- expect(toJSON()).toMatchSnapshot();
24
- expect(getByText('Title')).toBeDefined();
25
- expect(getByText('Footer CTA')).toBeDefined();
26
- expect(getByText('Content')).toBeDefined();
27
- });
28
-
29
- it('renders floating BottomSheet correctly', () => {
30
- const { toJSON, getByText } = renderWithTheme(
31
- <BottomSheet
32
- variant="floating"
33
- open
34
- header="Title"
35
- footer={<Button title="Footer CTA" />}
36
- onRequestClose={jest.fn()}
37
- >
38
- <Content />
39
- </BottomSheet>
40
- );
41
-
42
- expect(toJSON()).toMatchSnapshot();
43
- expect(getByText('Title')).toBeDefined();
44
- expect(getByText('Footer CTA')).toBeDefined();
45
- expect(getByText('Content')).toBeDefined();
46
- });
47
-
48
- it('renders correctly with close state', () => {
49
- const { toJSON } = renderWithTheme(
50
- <BottomSheet
51
- open={false}
52
- header="Title"
53
- footer={<Button title="Footer CTA" />}
54
- onRequestClose={jest.fn()}
55
- >
56
- <Content />
57
- </BottomSheet>
58
- );
59
-
60
- expect(toJSON()).toMatchSnapshot();
61
- });
62
-
63
- it('renders correctly with BottomSheet.ScrollView', () => {
64
- const { toJSON } = renderWithTheme(
65
- <BottomSheet
66
- open={false}
67
- header="Title"
68
- footer={<Button title="Footer CTA" />}
69
- onRequestClose={jest.fn()}
70
- >
71
- <BottomSheet.ScrollView>
72
- <Content />
73
- </BottomSheet.ScrollView>
74
- </BottomSheet>
75
- );
20
+ <Button title="test" onPress={() => setOpen(true)} />
21
+ </>
22
+ );
23
+ };
76
24
 
77
- expect(toJSON()).toMatchSnapshot();
78
- });
79
-
80
- it('renders correctly in landscape mode', () => {
81
- const { getByText } = renderWithTheme(
82
- <BottomSheet
83
- open
84
- header="Title"
85
- onRequestClose={jest.fn()}
86
- supportedOrientations={['landscape', 'portrait']}
87
- >
88
- <Content />
89
- </BottomSheet>
90
- );
91
- setOrientation('landscape');
92
- expect(getByText('Title')).toBeDefined();
93
- expect(getByText('Content')).toBeDefined();
94
- });
95
-
96
- describe('Header', () => {
97
- it('renders default header correctly', () => {
98
- const { getByText } = renderWithTheme(
99
- <BottomSheet open header="Title">
100
- <Content />
101
- </BottomSheet>
102
- );
103
-
104
- expect(getByText('Title')).toBeDefined();
105
- expect(getByText('Content')).toBeDefined();
106
- });
107
-
108
- it('renders floating header correctly', () => {
109
- const { getByText } = renderWithTheme(
110
- <BottomSheet open header="Title" variant="floating">
111
- <Content />
112
- </BottomSheet>
113
- );
114
-
115
- expect(getByText('Title')).toBeDefined();
116
- expect(getByText('Content')).toBeDefined();
117
- });
118
-
119
- it('renders custom header correctly', () => {
120
- const { getByText } = renderWithTheme(
121
- <BottomSheet open header={<Text>Custom Title</Text>}>
122
- <Content />
123
- </BottomSheet>
124
- );
125
-
126
- expect(getByText('Custom Title')).toBeDefined();
127
- expect(getByText('Content')).toBeDefined();
128
- });
129
-
130
- it('renders header close button correctly', () => {
131
- const onRequestClose = jest.fn();
132
-
133
- const { getByText, getByTestId } = renderWithTheme(
134
- <BottomSheet open header="Title" onRequestClose={onRequestClose}>
135
- <Content />
136
- </BottomSheet>
137
- );
138
-
139
- expect(getByText('Content')).toBeDefined();
140
- expect(getByTestId('bottom-sheet-close-icon')).toBeDefined();
141
-
142
- // Invoke onRequestClose when pressed
143
- fireEvent.press(getByTestId('bottom-sheet-close-icon'));
144
- expect(onRequestClose).toBeCalled();
145
- });
146
-
147
- it('not render header close button', () => {
148
- const { getByText, queryByTestId } = renderWithTheme(
149
- <BottomSheet open header="Title" showCloseButton={false}>
150
- <Content />
151
- </BottomSheet>
152
- );
25
+ describe('BottomSheet', () => {
26
+ it('test', () => {
27
+ const { getByText, queryByText } = renderWithTheme(<Test />);
153
28
 
154
- expect(queryByTestId('bottom-sheet-close-icon')).toBeNull();
155
- expect(getByText('Content')).toBeDefined();
156
- });
157
- });
29
+ expect(queryByText('Content')).toBeFalsy();
158
30
 
159
- describe('Footer', () => {
160
- it('renders footer correctly', () => {
161
- const { getByText } = renderWithTheme(
162
- <BottomSheet open footer={<Button title="Footer Button" />}>
163
- <Content />
164
- </BottomSheet>
165
- );
31
+ fireEvent.press(getByText('test'));
166
32
 
167
- expect(getByText('Footer Button')).toBeDefined();
168
- expect(getByText('Content')).toBeDefined();
169
- });
33
+ expect(getByText('Content')).toBeVisible();
170
34
  });
171
35
  });
@@ -145,6 +145,8 @@ const BottomSheet = ({
145
145
 
146
146
  onAnimationEnd?.();
147
147
  });
148
+
149
+ return () => animation.stop();
148
150
  }, [open]);
149
151
 
150
152
  const interpolateY = animatedValue.current.interpolate({
@@ -6,14 +6,11 @@ import Collapse from '..';
6
6
  describe('Collapse', () => {
7
7
  it('renders correctly', () => {
8
8
  const wrapper = renderWithTheme(
9
- <Collapse open testID="collapse">
9
+ <Collapse open={false} testID="collapse">
10
10
  <Text>Sample Text</Text>
11
11
  </Collapse>
12
12
  );
13
- expect(wrapper.queryAllByTestId('collapse')).toHaveLength(1);
14
- expect(wrapper.getByText('Sample Text')).toBeDefined();
15
-
16
- expect(wrapper.toJSON()).toMatchSnapshot();
13
+ expect(wrapper.getByText('Sample Text')).not.toBeVisible();
17
14
  });
18
15
 
19
16
  it('should render Sample Text but not visible', () => {
@@ -0,0 +1,32 @@
1
+ import styled from '@emotion/native';
2
+ import Box from '../Box';
3
+ import Icon from '../Icon';
4
+
5
+ const StyledWrapper = styled.TouchableOpacity(({ theme }) => ({
6
+ alignSelf: 'flex-start',
7
+ position: 'absolute',
8
+ left: '50%',
9
+ zIndex: 9999,
10
+ flexDirection: 'row',
11
+ justifyContent: 'center',
12
+ alignItems: 'center',
13
+ padding: theme.__hd__.floatingIsland.space.wrapperPadding,
14
+ borderRadius: theme.__hd__.floatingIsland.radii.wrapper,
15
+ backgroundColor: theme.__hd__.floatingIsland.colors.wrapperBackground,
16
+ top: theme.__hd__.floatingIsland.space.wrapperTop,
17
+ ...theme.__hd__.floatingIsland.shadows.wrapper,
18
+ }));
19
+
20
+ const StyledPrefixWrapper = styled(Box)(({ theme }) => ({
21
+ marginRight: theme.__hd__.floatingIsland.space.prefixMarginRight,
22
+ }));
23
+
24
+ const StyledSuffixWrapper = styled(Box)(({ theme }) => ({
25
+ marginLeft: theme.__hd__.floatingIsland.space.suffixMarginLeft,
26
+ }));
27
+
28
+ const StyledIcon = styled(Icon)(({ theme }) => ({
29
+ padding: theme.__hd__.floatingIsland.space.iconPadding,
30
+ }));
31
+
32
+ export { StyledWrapper, StyledPrefixWrapper, StyledSuffixWrapper, StyledIcon };