@hero-design/rn 8.32.0 → 8.33.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 (35) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/es/index.js +165 -55
  3. package/lib/index.js +165 -55
  4. package/package.json +5 -5
  5. package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +2 -1
  6. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +10 -10
  7. package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +6 -6
  8. package/src/components/FAB/ActionGroup/ActionItem.tsx +39 -14
  9. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +982 -819
  10. package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +4 -11
  11. package/src/components/FAB/ActionGroup/index.tsx +119 -93
  12. package/src/components/FAB/AnimatedFABIcon.tsx +3 -5
  13. package/src/components/FAB/FAB.tsx +108 -28
  14. package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +27 -9
  15. package/src/components/FAB/__tests__/index.spec.tsx +22 -2
  16. package/src/components/Select/MultiSelect/Option.tsx +3 -0
  17. package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +1 -0
  18. package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +5 -0
  19. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +1166 -0
  20. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +29 -9
  21. package/src/components/Select/MultiSelect/index.tsx +1 -1
  22. package/src/components/Typography/Text/index.tsx +19 -12
  23. package/src/components/Typography/index.tsx +3 -0
  24. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +1 -0
  25. package/src/theme/components/button.ts +1 -0
  26. package/src/types.ts +4 -0
  27. package/testUtils/setup.tsx +2 -0
  28. package/types/components/FAB/ActionGroup/ActionItem.d.ts +4 -2
  29. package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +1 -1
  30. package/types/components/FAB/ActionGroup/index.d.ts +8 -2
  31. package/types/components/FAB/FAB.d.ts +8 -2
  32. package/types/components/FAB/index.d.ts +3 -2
  33. package/types/components/Typography/index.d.ts +3 -0
  34. package/types/theme/components/button.d.ts +1 -0
  35. package/types/types.d.ts +3 -1
@@ -7,6 +7,7 @@ import List from '../../../List';
7
7
  import Box from '../../../Box';
8
8
  import Button from '../../../Button/Button';
9
9
  import type { ListRenderOptionInfo } from '../../types';
10
+ import theme, { ThemeProvider } from '../../../../theme';
10
11
 
11
12
  const options = [
12
13
  { text: 'Monday', value: 'mon' },
@@ -132,15 +133,16 @@ describe('rendering', () => {
132
133
  });
133
134
 
134
135
  it('renders correctly when receives sections', () => {
135
- const { queryAllByText, getByText, toJSON, getByTestId } = renderWithTheme(
136
- <MultiSelect
137
- label="Allow notifications"
138
- footerLabel="Confirm"
139
- options={sections}
140
- value={['b1', 'b2']}
141
- onConfirm={jest.fn()}
142
- />
143
- );
136
+ const { queryAllByText, getByText, toJSON, getByTestId, rerender } =
137
+ renderWithTheme(
138
+ <MultiSelect
139
+ label="Allow notifications"
140
+ footerLabel="Confirm"
141
+ options={sections}
142
+ value={['b1', 'b2']}
143
+ onConfirm={jest.fn()}
144
+ />
145
+ );
144
146
  fireEvent.press(getByTestId('text-input'));
145
147
 
146
148
  expect(toJSON()).toMatchSnapshot();
@@ -151,6 +153,24 @@ describe('rendering', () => {
151
153
  expect(getByText('B1')).toBeTruthy();
152
154
  expect(getByText('B2')).toBeTruthy();
153
155
  expect(getByText('Confirm')).toBeDefined();
156
+
157
+ expect(getByTestId('selected-icon-B2')).toBeTruthy();
158
+ expect(getByTestId('selected-icon-B1')).toBeTruthy();
159
+
160
+ // should rerender UI if values are changed
161
+ rerender(
162
+ <ThemeProvider theme={theme}>
163
+ <MultiSelect
164
+ label="Allow notifications"
165
+ footerLabel="Confirm"
166
+ options={sections}
167
+ value={['a', 'a1']}
168
+ onConfirm={jest.fn()}
169
+ />
170
+ </ThemeProvider>
171
+ );
172
+ expect(toJSON()).toMatchSnapshot();
173
+ expect(getByTestId('selected-icon-A1')).toBeTruthy();
154
174
  });
155
175
 
156
176
  it('allows custom renderer', () => {
@@ -84,7 +84,7 @@ function MultiSelect<V, T extends OptionType<V>>({
84
84
 
85
85
  useEffect(() => {
86
86
  setSelectingValue(value);
87
- }, [open]);
87
+ }, [open, value]);
88
88
 
89
89
  return (
90
90
  <>
@@ -6,6 +6,7 @@ import type {
6
6
  TextStyle,
7
7
  } from 'react-native';
8
8
  import { StyledText } from './StyledText';
9
+ import { useDeprecation } from '../../../utils/hooks';
9
10
 
10
11
  export interface TextProps extends NativeTextProps {
11
12
  /**
@@ -69,17 +70,23 @@ const Text = ({
69
70
  typeface = 'neutral',
70
71
  allowFontScaling = false,
71
72
  ...nativeProps
72
- }: TextProps) => (
73
- <StyledText
74
- {...nativeProps}
75
- themeFontSize={fontSize}
76
- themeFontWeight={fontWeight}
77
- themeIntent={intent}
78
- themeTypeface={typeface}
79
- allowFontScaling={allowFontScaling}
80
- >
81
- {children}
82
- </StyledText>
83
- );
73
+ }: TextProps) => {
74
+ useDeprecation(
75
+ 'Typography.Text is deprecated and will be removed in the next major release, please refer to https://design.employmenthero.com/mobile/Components/typography for the appropriate alternatives.'
76
+ );
77
+
78
+ return (
79
+ <StyledText
80
+ {...nativeProps}
81
+ themeFontSize={fontSize}
82
+ themeFontWeight={fontWeight}
83
+ themeIntent={intent}
84
+ themeTypeface={typeface}
85
+ allowFontScaling={allowFontScaling}
86
+ >
87
+ {children}
88
+ </StyledText>
89
+ );
90
+ };
84
91
 
85
92
  export default Text;
@@ -5,6 +5,9 @@ import Title from './Title';
5
5
  import Body from './Body';
6
6
 
7
7
  interface TypographyProps {
8
+ /**
9
+ * @deprecated Typography.Text will be removed in the next major release, please refer to https://design.employmenthero.com/mobile/Components/typography for the appropriate alternatives.
10
+ */
8
11
  Text: typeof Text;
9
12
  Caption: typeof Caption;
10
13
  Label: typeof Label;
@@ -234,6 +234,7 @@ Object {
234
234
  "space": Object {
235
235
  "buttonPadding": 16,
236
236
  "iconPadding": 12,
237
+ "loadingIndicatorWrapperVerticalPadding": 1,
237
238
  "textButtonPadding": 12,
238
239
  "utilityPadding": 8,
239
240
  },
@@ -21,6 +21,7 @@ const getButtonTheme = (theme: GlobalTheme) => {
21
21
  textButtonPadding: theme.space.smallMedium,
22
22
  iconPadding: theme.space.smallMedium,
23
23
  utilityPadding: theme.space.small,
24
+ loadingIndicatorWrapperVerticalPadding: theme.space.xxsmall / 2,
24
25
  };
25
26
 
26
27
  const sizes = {
package/src/types.ts CHANGED
@@ -15,6 +15,8 @@ import type {
15
15
  import { SwipeableProps } from './components/Swipeable';
16
16
  import { TextProps } from './components/Typography/Text';
17
17
  import { CardCarouselHandles } from './components/Carousel/CardCarousel';
18
+ import { FABHandles } from './components/FAB/FAB';
19
+ import { ActionGroupHandles } from './components/FAB/ActionGroup';
18
20
 
19
21
  export type {
20
22
  BottomNavigationTabType,
@@ -32,4 +34,6 @@ export type {
32
34
  TextInputHandles,
33
35
  Theme,
34
36
  CardCarouselHandles,
37
+ FABHandles,
38
+ ActionGroupHandles,
35
39
  };
@@ -11,6 +11,7 @@ jest.mock('react-native', () => {
11
11
  const RN = jest.requireActual('react-native');
12
12
 
13
13
  const mockedAnimatedFunctions = {
14
+ setImmediate: () => jest.fn(),
14
15
  start: () => jest.fn(),
15
16
  stop: () => jest.fn(),
16
17
  _isUsingNativeDriver: () => jest.fn(),
@@ -19,6 +20,7 @@ jest.mock('react-native', () => {
19
20
 
20
21
  RN.Animated.timing = () => mockedAnimatedFunctions;
21
22
  RN.Animated.spring = () => mockedAnimatedFunctions;
23
+ RN.Animated.stagger = () => mockedAnimatedFunctions;
22
24
 
23
25
  return RN;
24
26
  });
@@ -1,5 +1,5 @@
1
1
  import type { ComponentProps } from 'react';
2
- import type { StyleProp, ViewStyle } from 'react-native';
2
+ import { type StyleProp, type ViewStyle } from 'react-native';
3
3
  import Icon from '../../Icon';
4
4
  export interface ActionItemProps {
5
5
  testID?: string;
@@ -8,6 +8,8 @@ export interface ActionItemProps {
8
8
  onPress?: () => void;
9
9
  style?: StyleProp<ViewStyle>;
10
10
  key?: string;
11
+ index: number;
12
+ active?: boolean;
11
13
  }
12
- declare const ActionItem: ({ icon, title, onPress, style, testID, }: ActionItemProps) => JSX.Element;
14
+ declare const ActionItem: ({ icon, title, onPress, style, testID, index, active, }: ActionItemProps) => JSX.Element;
13
15
  export default ActionItem;
@@ -14,7 +14,7 @@ declare const StyledActionGroupContainer: import("@emotion/native").StyledCompon
14
14
  theme?: import("@emotion/react").Theme | undefined;
15
15
  as?: import("react").ElementType<any> | undefined;
16
16
  }, {}, {}>;
17
- declare const StyledFAB: import("@emotion/native").StyledComponent<import("../FAB").FABProps & {
17
+ declare const StyledFAB: import("@emotion/native").StyledComponent<import("../FAB").FABProps & import("react").RefAttributes<import("../FAB").FABHandles> & {
18
18
  theme?: import("@emotion/react").Theme | undefined;
19
19
  as?: import("react").ElementType<any> | undefined;
20
20
  }, {}, {}>;
@@ -1,6 +1,12 @@
1
+ import React from 'react';
1
2
  import type { StyleProp, ViewStyle } from 'react-native';
2
3
  import type { IconName } from '../../Icon';
3
4
  import type { ActionItemProps } from './ActionItem';
5
+ export type ActionGroupHandles = {
6
+ showFAB: () => void;
7
+ collapseFAB: () => void;
8
+ hideFAB: () => void;
9
+ };
4
10
  export interface ActionGroupProps {
5
11
  /**
6
12
  * Title of the action group header.
@@ -29,11 +35,11 @@ export interface ActionGroupProps {
29
35
  /**
30
36
  * Action items of the action group.
31
37
  * */
32
- items?: Array<ActionItemProps>;
38
+ items?: Array<Omit<ActionItemProps, 'index' | 'active'>>;
33
39
  /**
34
40
  * Testing id of the component.
35
41
  */
36
42
  testID?: string;
37
43
  }
38
- declare const ActionGroup: ({ headerTitle, onPress, active, style, items, testID, fabTitle, fabIcon, }: ActionGroupProps) => JSX.Element;
44
+ declare const ActionGroup: React.ForwardRefExoticComponent<ActionGroupProps & React.RefAttributes<ActionGroupHandles>>;
39
45
  export default ActionGroup;
@@ -1,5 +1,11 @@
1
- import type { StyleProp, ViewStyle } from 'react-native';
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
2
3
  import type { IconName } from '../Icon';
4
+ export type FABHandles = {
5
+ show: () => void;
6
+ collapse: () => void;
7
+ hide: () => void;
8
+ };
3
9
  export interface FABProps {
4
10
  /**
5
11
  * Name of the Icon.
@@ -30,5 +36,5 @@ export interface FABProps {
30
36
  */
31
37
  testID?: string;
32
38
  }
33
- declare const FAB: ({ onPress, title, icon, animated, testID, active, style, }: FABProps) => JSX.Element;
39
+ declare const FAB: React.ForwardRefExoticComponent<FABProps & React.RefAttributes<FABHandles>>;
34
40
  export default FAB;
@@ -1,4 +1,5 @@
1
- declare const _default: (({ onPress, title, icon, animated, testID, active, style, }: import("./FAB").FABProps) => JSX.Element) & {
2
- ActionGroup: ({ headerTitle, onPress, active, style, items, testID, fabTitle, fabIcon, }: import("./ActionGroup").ActionGroupProps) => JSX.Element;
1
+ /// <reference types="react" />
2
+ declare const _default: import("react").ForwardRefExoticComponent<import("./FAB").FABProps & import("react").RefAttributes<import("./FAB").FABHandles>> & {
3
+ ActionGroup: import("react").ForwardRefExoticComponent<import("./ActionGroup").ActionGroupProps & import("react").RefAttributes<import("./ActionGroup").ActionGroupHandles>>;
3
4
  };
4
5
  export default _default;
@@ -4,6 +4,9 @@ import Label from './Label';
4
4
  import Title from './Title';
5
5
  import Body from './Body';
6
6
  interface TypographyProps {
7
+ /**
8
+ * @deprecated Typography.Text will be removed in the next major release, please refer to https://design.employmenthero.com/mobile/Components/typography for the appropriate alternatives.
9
+ */
7
10
  Text: typeof Text;
8
11
  Caption: typeof Caption;
9
12
  Label: typeof Label;
@@ -48,6 +48,7 @@ declare const getButtonTheme: (theme: GlobalTheme) => {
48
48
  textButtonPadding: number;
49
49
  iconPadding: number;
50
50
  utilityPadding: number;
51
+ loadingIndicatorWrapperVerticalPadding: number;
51
52
  };
52
53
  };
53
54
  export default getButtonTheme;
package/types/types.d.ts CHANGED
@@ -9,4 +9,6 @@ import type { ListRenderOptionInfo, SectionListRenderOptionInfo } from './compon
9
9
  import { SwipeableProps } from './components/Swipeable';
10
10
  import { TextProps } from './components/Typography/Text';
11
11
  import { CardCarouselHandles } from './components/Carousel/CardCarousel';
12
- export type { BottomNavigationTabType, IconName, SingleSelectProps, MultiSelectProps, ListRenderOptionInfo, SectionListRenderOptionInfo, SwipeableProps, RichTextEditorProps, RichTextEditorRef, TabType, TextInputProps, TextProps, TextInputHandles, Theme, CardCarouselHandles, };
12
+ import { FABHandles } from './components/FAB/FAB';
13
+ import { ActionGroupHandles } from './components/FAB/ActionGroup';
14
+ export type { BottomNavigationTabType, IconName, SingleSelectProps, MultiSelectProps, ListRenderOptionInfo, SectionListRenderOptionInfo, SwipeableProps, RichTextEditorProps, RichTextEditorRef, TabType, TextInputProps, TextProps, TextInputHandles, Theme, CardCarouselHandles, FABHandles, ActionGroupHandles, };