@hero-design/rn 7.20.1 → 7.22.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 (132) hide show
  1. package/.eslintrc.js +11 -0
  2. package/.turbo/turbo-build.log +9 -9
  3. package/babel.config.js +1 -1
  4. package/es/index.js +714 -471
  5. package/lib/index.js +720 -474
  6. package/package.json +9 -15
  7. package/rollup.config.js +1 -0
  8. package/src/components/BottomNavigation/__tests__/index.spec.tsx +1 -1
  9. package/src/components/BottomNavigation/index.tsx +3 -3
  10. package/src/components/BottomSheet/index.tsx +6 -1
  11. package/src/components/Box/helpers.ts +1 -1
  12. package/src/components/Calendar/index.tsx +9 -9
  13. package/src/components/Checkbox/__tests__/__snapshots__/StyledCheckbox.spec.tsx.snap +4 -4
  14. package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +13 -13
  15. package/src/components/Collapse/index.tsx +1 -1
  16. package/src/components/Drawer/DragableDrawer/helpers.ts +7 -3
  17. package/src/components/Empty/StyledEmpty.tsx +1 -9
  18. package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +58 -5
  19. package/src/components/Empty/__tests__/index.spec.tsx +13 -0
  20. package/src/components/Empty/index.tsx +38 -18
  21. package/src/components/FAB/ActionGroup/index.tsx +1 -1
  22. package/src/components/Icon/HeroIcon/selection.json +7029 -1
  23. package/src/components/Image/__tests__/__snapshots__/index.spec.tsx.snap +81 -0
  24. package/src/components/Image/__tests__/index.spec.tsx +29 -0
  25. package/src/components/Image/index.tsx +46 -0
  26. package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +5 -5
  27. package/src/components/PinInput/index.tsx +1 -1
  28. package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +60 -60
  29. package/src/components/RichTextEditor/EditorToolbar.tsx +3 -3
  30. package/src/components/RichTextEditor/RichTextEditor.tsx +5 -5
  31. package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +2 -2
  32. package/src/components/RichTextEditor/__tests__/MentionList.spec.tsx +1 -1
  33. package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +2 -2
  34. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +2 -2
  35. package/src/components/Select/MultiSelect/OptionList.tsx +5 -7
  36. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +21 -0
  37. package/src/components/Select/MultiSelect/index.tsx +35 -5
  38. package/src/components/Select/SingleSelect/OptionList.tsx +4 -5
  39. package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +16 -0
  40. package/src/components/Select/SingleSelect/index.tsx +36 -6
  41. package/src/components/Select/StyledOptionList.tsx +3 -9
  42. package/src/components/Select/helpers.tsx +4 -4
  43. package/src/components/Slider/__tests__/__snapshots__/index.spec.tsx.snap +43 -0
  44. package/src/components/Slider/__tests__/index.spec.tsx +33 -0
  45. package/src/components/Slider/index.tsx +89 -0
  46. package/src/components/Switch/SelectorSwitch/Option.tsx +67 -0
  47. package/src/components/Switch/SelectorSwitch/StyledSelectorSwitch.tsx +25 -0
  48. package/src/components/Switch/SelectorSwitch/__tests__/Option.spec.tsx +61 -0
  49. package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +195 -0
  50. package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +121 -0
  51. package/src/components/Switch/SelectorSwitch/__tests__/index.spec.tsx +62 -0
  52. package/src/components/Switch/SelectorSwitch/index.tsx +60 -0
  53. package/src/components/Switch/StyledSwitch.tsx +4 -4
  54. package/src/components/Switch/__tests__/__snapshots__/StyledSwitch.spec.tsx.snap +10 -10
  55. package/src/components/Switch/__tests__/__snapshots__/index.spec.tsx.snap +8 -8
  56. package/src/components/Switch/index.tsx +9 -5
  57. package/src/components/Tabs/ScrollableTabs.tsx +12 -5
  58. package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +1 -1
  59. package/src/components/Tabs/__tests__/index.spec.tsx +1 -1
  60. package/src/components/Tabs/index.tsx +13 -6
  61. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +3 -1
  62. package/src/components/TextInput/__tests__/index.spec.tsx +114 -112
  63. package/src/components/TextInput/index.tsx +64 -59
  64. package/src/components/Toast/ToastContainer.tsx +6 -6
  65. package/src/index.ts +4 -0
  66. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +70 -23
  67. package/src/theme/components/alert.ts +1 -2
  68. package/src/theme/components/avatar.ts +8 -8
  69. package/src/theme/components/badge.ts +4 -4
  70. package/src/theme/components/bottomNavigation.ts +1 -1
  71. package/src/theme/components/bottomSheet.ts +2 -3
  72. package/src/theme/components/calendar.ts +9 -7
  73. package/src/theme/components/card.ts +1 -1
  74. package/src/theme/components/checkbox.ts +2 -5
  75. package/src/theme/components/datePicker.ts +3 -3
  76. package/src/theme/components/drawer.ts +2 -3
  77. package/src/theme/components/empty.ts +3 -8
  78. package/src/theme/components/fab.ts +2 -2
  79. package/src/theme/components/image.ts +12 -0
  80. package/src/theme/components/pinInput.ts +3 -3
  81. package/src/theme/components/progress.ts +2 -3
  82. package/src/theme/components/radio.ts +7 -3
  83. package/src/theme/components/richTextEditor.ts +4 -4
  84. package/src/theme/components/slider.ts +13 -0
  85. package/src/theme/components/switch.ts +28 -17
  86. package/src/theme/components/tabs.ts +1 -1
  87. package/src/theme/components/timePicker.ts +3 -3
  88. package/src/theme/components/toast.ts +1 -2
  89. package/src/theme/getTheme.ts +9 -2
  90. package/src/theme/global/colors/swag.ts +2 -0
  91. package/src/theme/global/colors/types.ts +2 -0
  92. package/src/theme/global/index.ts +3 -0
  93. package/src/theme/global/scale.ts +3 -0
  94. package/src/theme/global/sizes.ts +29 -0
  95. package/testUtils/setup.tsx +15 -1
  96. package/tsconfig.json +1 -1
  97. package/types/components/BottomSheet/index.d.ts +5 -1
  98. package/types/components/Empty/StyledEmpty.d.ts +1 -7
  99. package/types/components/Empty/index.d.ts +8 -2
  100. package/types/components/Image/__tests__/index.spec.d.ts +1 -0
  101. package/types/components/Image/index.d.ts +17 -0
  102. package/types/components/Select/MultiSelect/OptionList.d.ts +5 -2
  103. package/types/components/Select/MultiSelect/index.d.ts +7 -1
  104. package/types/components/Select/SingleSelect/OptionList.d.ts +5 -2
  105. package/types/components/Select/SingleSelect/index.d.ts +8 -2
  106. package/types/components/Select/StyledOptionList.d.ts +4 -3
  107. package/types/components/Select/index.d.ts +1 -1
  108. package/types/components/Slider/__tests__/index.spec.d.ts +1 -0
  109. package/types/components/Slider/index.d.ts +52 -0
  110. package/types/components/Switch/SelectorSwitch/Option.d.ts +10 -0
  111. package/types/components/Switch/SelectorSwitch/StyledSelectorSwitch.d.ts +19 -0
  112. package/types/components/Switch/SelectorSwitch/__tests__/Option.spec.d.ts +1 -0
  113. package/types/components/Switch/SelectorSwitch/__tests__/index.spec.d.ts +1 -0
  114. package/types/components/Switch/SelectorSwitch/index.d.ts +37 -0
  115. package/types/components/Switch/index.d.ts +5 -3
  116. package/types/components/Tabs/ScrollableTabs.d.ts +1 -1
  117. package/types/components/Tabs/index.d.ts +2 -2
  118. package/types/components/TextInput/index.d.ts +6 -5
  119. package/types/index.d.ts +3 -1
  120. package/types/theme/components/datePicker.d.ts +2 -1
  121. package/types/theme/components/empty.d.ts +2 -5
  122. package/types/theme/components/image.d.ts +8 -0
  123. package/types/theme/components/slider.d.ts +9 -0
  124. package/types/theme/components/switch.d.ts +27 -12
  125. package/types/theme/components/timePicker.d.ts +2 -1
  126. package/types/theme/getTheme.d.ts +4 -0
  127. package/types/theme/global/colors/types.d.ts +2 -0
  128. package/types/theme/global/index.d.ts +3 -0
  129. package/types/theme/global/scale.d.ts +1 -0
  130. package/types/theme/global/sizes.d.ts +14 -0
  131. package/.eslintrc.json +0 -61
  132. package/.prettierrc.json +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "7.20.1",
3
+ "version": "7.22.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -20,13 +20,14 @@
20
20
  "dependencies": {
21
21
  "@emotion/native": "^11.9.3",
22
22
  "@emotion/react": "^11.9.3",
23
- "@hero-design/colors": "7.20.1",
23
+ "@hero-design/colors": "7.22.0",
24
24
  "date-fns": "^2.16.1",
25
25
  "events": "^3.2.0",
26
26
  "hero-editor": "^1.9.9"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@react-native-community/datetimepicker": "^3.5.2",
30
+ "@react-native-community/slider": "4.1.12",
30
31
  "react": "17.0.2",
31
32
  "react-native": "0.65.1",
32
33
  "react-native-pager-view": "^5.4.25",
@@ -42,6 +43,7 @@
42
43
  "@babel/runtime": "^7.18.9",
43
44
  "@emotion/jest": "^11.9.3",
44
45
  "@react-native-community/datetimepicker": "^3.5.2",
46
+ "@react-native-community/slider": "4.1.12",
45
47
  "@rollup/plugin-babel": "^5.3.1",
46
48
  "@rollup/plugin-commonjs": "^21.0.1",
47
49
  "@rollup/plugin-json": "^4.1.0",
@@ -54,19 +56,9 @@
54
56
  "@types/react": "^17.0.39",
55
57
  "@types/react-native": "^0.67.7",
56
58
  "@types/react-native-vector-icons": "^6.4.10",
57
- "@typescript-eslint/eslint-plugin": "^5.12.1",
58
- "@typescript-eslint/parser": "^5.12.1",
59
59
  "babel-plugin-inline-import": "^3.0.0",
60
- "eslint": "^8.9.0",
61
- "eslint-config-airbnb": "^19.0.4",
62
- "eslint-config-prettier": "^8.5.0",
63
- "eslint-plugin-import": "^2.25.4",
64
- "eslint-plugin-jsx-a11y": "^6.5.1",
65
- "eslint-plugin-prettier": "^4.0.0",
66
- "eslint-plugin-react": "^7.28.0",
67
- "eslint-plugin-react-hooks": "^4.3.0",
60
+ "eslint-config-hd": "7.22.0",
68
61
  "jest": "^27.3.1",
69
- "prettier": "^2.5.1",
70
62
  "react": "17.0.2",
71
63
  "react-native": "0.65.1",
72
64
  "react-native-pager-view": "^5.4.25",
@@ -77,6 +69,8 @@
77
69
  "rollup": "^2.68.0",
78
70
  "rollup-plugin-copy": "^3.4.0",
79
71
  "rollup-plugin-flow": "^1.1.1",
80
- "ts-jest": "^27.0.7"
81
- }
72
+ "ts-jest": "^27.0.7",
73
+ "prettier-config-hd": "7.22.0"
74
+ },
75
+ "prettier": "prettier-config-hd"
82
76
  }
package/rollup.config.js CHANGED
@@ -28,6 +28,7 @@ export default {
28
28
  'react-native',
29
29
  'react-native-safe-area-context',
30
30
  '@react-native-community/datetimepicker',
31
+ '@react-native-community/slider',
31
32
  'react-native-webview',
32
33
  'react-native-pager-view',
33
34
  'react-native-vector-icons',
@@ -52,7 +52,7 @@ const TestComponent = (
52
52
  {...props}
53
53
  tabs={tabs}
54
54
  selectedTabKey={selectedTabKey}
55
- onTabPress={newTabKey => setSelectedTabKey(newTabKey)}
55
+ onTabPress={(newTabKey) => setSelectedTabKey(newTabKey)}
56
56
  />
57
57
  </SafeAreaProvider>
58
58
  );
@@ -80,13 +80,13 @@ const BottomNavigation = ({
80
80
 
81
81
  if (!loaded.includes(selectedTabKey)) {
82
82
  // Set the current tab to be loaded if it was not loaded before
83
- setLoaded(loadedState => [...loadedState, selectedTabKey]);
83
+ setLoaded((loadedState) => [...loadedState, selectedTabKey]);
84
84
  }
85
85
 
86
86
  return (
87
87
  <BottomNavigationContainer {...nativeProps}>
88
88
  <ContentWrapper>
89
- {tabs.map(tab => {
89
+ {tabs.map((tab) => {
90
90
  const { key, component, testID } = tab;
91
91
  const active = selectedTabKey === key;
92
92
 
@@ -123,7 +123,7 @@ const BottomNavigation = ({
123
123
  </ContentWrapper>
124
124
  <BottomBarWrapper themeInsets={insets}>
125
125
  <BottomBar>
126
- {tabs.map(tab => {
126
+ {tabs.map((tab) => {
127
127
  const { key, icon, title, testID } = tab;
128
128
  const active = selectedTabKey === key;
129
129
  const inactiveIcon = getInactiveIcon(icon);
@@ -27,6 +27,10 @@ interface BottomSheetProps {
27
27
  * Bottom sheet's content.
28
28
  */
29
29
  children?: ReactNode;
30
+ /**
31
+ * Callback is called when the Bottom Sheet finishes running animation.
32
+ */
33
+ onAnimationEnd?: () => void;
30
34
  /**
31
35
  * Callback is called when the Bottom Sheet is opened.
32
36
  */
@@ -67,6 +71,7 @@ const BottomSheet = ({
67
71
  header,
68
72
  footer,
69
73
  children,
74
+ onAnimationEnd,
70
75
  onOpen,
71
76
  onRequestClose,
72
77
  onDismiss,
@@ -109,7 +114,7 @@ const BottomSheet = ({
109
114
  useNativeDriver: true,
110
115
  });
111
116
 
112
- animation.start();
117
+ animation.start(onAnimationEnd);
113
118
 
114
119
  return () => animation.stop();
115
120
  }, [open]);
@@ -1,6 +1,6 @@
1
1
  export const pick = (keys: Array<string>, props: Record<string, any>) =>
2
2
  keys
3
- .filter(key => key in props)
3
+ .filter((key) => key in props)
4
4
  .reduce(
5
5
  (result, cur) => ({
6
6
  ...result,
@@ -101,7 +101,7 @@ const Calendar = ({
101
101
  const lastDayIndexOfCurrentMonth = lastDateOfMonth.getDate();
102
102
  const lastDayIndexOfPreviousMonth = lastDateOfPreviousMonth.getDate();
103
103
 
104
- const daysOfPreviousMonth = initArray(firstDayWeekIndexOfMonth, index => {
104
+ const daysOfPreviousMonth = initArray(firstDayWeekIndexOfMonth, (index) => {
105
105
  const reversedIndex = firstDayWeekIndexOfMonth - index - 1;
106
106
  const count = lastDayIndexOfPreviousMonth - reversedIndex;
107
107
  return getValidDate(
@@ -111,7 +111,7 @@ const Calendar = ({
111
111
  );
112
112
  });
113
113
 
114
- const daysOfCurrentMonth = initArray(lastDayIndexOfCurrentMonth, index =>
114
+ const daysOfCurrentMonth = initArray(lastDayIndexOfCurrentMonth, (index) =>
115
115
  getValidDate(
116
116
  new Date(currentYear, currentMonth, index + 1),
117
117
  minDate,
@@ -122,7 +122,7 @@ const Calendar = ({
122
122
  const daysOfNextMonth = initArray(
123
123
  TOTAL_DATES_ITEMS -
124
124
  (daysOfPreviousMonth.length + daysOfCurrentMonth.length),
125
- index =>
125
+ (index) =>
126
126
  getValidDate(
127
127
  new Date(currentYear, currentMonth + 1, index + 1),
128
128
  minDate,
@@ -133,13 +133,13 @@ const Calendar = ({
133
133
  const disablePrevButton =
134
134
  minDate === undefined
135
135
  ? false
136
- : !daysOfPreviousMonth.some(date => date !== undefined) &&
136
+ : !daysOfPreviousMonth.some((date) => date !== undefined) &&
137
137
  minDate >= firstDateOfMonth;
138
138
 
139
139
  const disableNextButton =
140
140
  maxDate === undefined
141
141
  ? false
142
- : !daysOfNextMonth.some(date => date !== undefined) ||
142
+ : !daysOfNextMonth.some((date) => date !== undefined) ||
143
143
  maxDate <= lastDateOfMonth;
144
144
 
145
145
  return (
@@ -156,7 +156,7 @@ const Calendar = ({
156
156
  />
157
157
  </StyledCalendarHeader>
158
158
  <StyledCalendarRow>
159
- {DAYS_OF_WEEK.map(day => (
159
+ {DAYS_OF_WEEK.map((day) => (
160
160
  <StyledCalendarRowItem key={day}>
161
161
  <StyledCalendarDayNameCell>
162
162
  <Typography.Text>{day}</Typography.Text>
@@ -165,7 +165,7 @@ const Calendar = ({
165
165
  ))}
166
166
  </StyledCalendarRow>
167
167
  <StyledCalendarRow>
168
- {daysOfPreviousMonth.map(date =>
168
+ {daysOfPreviousMonth.map((date) =>
169
169
  date ? (
170
170
  <CalendarRowItem
171
171
  key={date.toDateString()}
@@ -180,7 +180,7 @@ const Calendar = ({
180
180
  <StyledDisabledCalendarRowItem testID="calendar-disabled-cell" />
181
181
  )
182
182
  )}
183
- {daysOfCurrentMonth.map(date =>
183
+ {daysOfCurrentMonth.map((date) =>
184
184
  date ? (
185
185
  <CalendarRowItem
186
186
  key={date.toDateString()}
@@ -194,7 +194,7 @@ const Calendar = ({
194
194
  <StyledDisabledCalendarRowItem testID="calendar-disabled-cell" />
195
195
  )
196
196
  )}
197
- {daysOfNextMonth.map(date =>
197
+ {daysOfNextMonth.map((date) =>
198
198
  date ? (
199
199
  <CalendarRowItem
200
200
  key={date.toDateString()}
@@ -9,10 +9,10 @@ exports[`StyledCheckbox renders correctly when disabled is false 1`] = `
9
9
  "borderRadius": 4,
10
10
  "borderWidth": 2,
11
11
  "flexDirection": "row",
12
- "height": 20,
12
+ "height": 24,
13
13
  "justifyContent": "center",
14
14
  "overflow": "hidden",
15
- "width": 20,
15
+ "width": 24,
16
16
  },
17
17
  undefined,
18
18
  ]
@@ -30,10 +30,10 @@ exports[`StyledCheckbox renders correctly when disabled is true 1`] = `
30
30
  "borderRadius": 4,
31
31
  "borderWidth": 2,
32
32
  "flexDirection": "row",
33
- "height": 20,
33
+ "height": 24,
34
34
  "justifyContent": "center",
35
35
  "overflow": "hidden",
36
- "width": 20,
36
+ "width": 24,
37
37
  },
38
38
  undefined,
39
39
  ]
@@ -28,10 +28,10 @@ exports[`Checkbox renders correctly when checked is false and there is no descri
28
28
  "borderRadius": 4,
29
29
  "borderWidth": 2,
30
30
  "flexDirection": "row",
31
- "height": 20,
31
+ "height": 24,
32
32
  "justifyContent": "center",
33
33
  "overflow": "hidden",
34
- "width": 20,
34
+ "width": 24,
35
35
  },
36
36
  undefined,
37
37
  ]
@@ -69,10 +69,10 @@ exports[`Checkbox renders correctly when checked is true and there is no descrip
69
69
  "borderRadius": 4,
70
70
  "borderWidth": 2,
71
71
  "flexDirection": "row",
72
- "height": 20,
72
+ "height": 24,
73
73
  "justifyContent": "center",
74
74
  "overflow": "hidden",
75
- "width": 20,
75
+ "width": 24,
76
76
  },
77
77
  undefined,
78
78
  ]
@@ -90,7 +90,7 @@ exports[`Checkbox renders correctly when checked is true and there is no descrip
90
90
  Array [
91
91
  Object {
92
92
  "position": "absolute",
93
- "top": -3,
93
+ "top": 0,
94
94
  },
95
95
  undefined,
96
96
  ],
@@ -157,10 +157,10 @@ exports[`Checkbox renders correctly when disabled is false, withBorder is false
157
157
  "borderRadius": 4,
158
158
  "borderWidth": 2,
159
159
  "flexDirection": "row",
160
- "height": 20,
160
+ "height": 24,
161
161
  "justifyContent": "center",
162
162
  "overflow": "hidden",
163
- "width": 20,
163
+ "width": 24,
164
164
  },
165
165
  undefined,
166
166
  ]
@@ -227,10 +227,10 @@ exports[`Checkbox renders correctly when disabled is false, withBorder is true 1
227
227
  "borderRadius": 4,
228
228
  "borderWidth": 2,
229
229
  "flexDirection": "row",
230
- "height": 20,
230
+ "height": 24,
231
231
  "justifyContent": "center",
232
232
  "overflow": "hidden",
233
- "width": 20,
233
+ "width": 24,
234
234
  },
235
235
  undefined,
236
236
  ]
@@ -293,10 +293,10 @@ exports[`Checkbox renders correctly when disabled is true, withBorder is false 1
293
293
  "borderRadius": 4,
294
294
  "borderWidth": 2,
295
295
  "flexDirection": "row",
296
- "height": 20,
296
+ "height": 24,
297
297
  "justifyContent": "center",
298
298
  "overflow": "hidden",
299
- "width": 20,
299
+ "width": 24,
300
300
  },
301
301
  undefined,
302
302
  ]
@@ -363,10 +363,10 @@ exports[`Checkbox renders correctly when disabled is true, withBorder is true 1`
363
363
  "borderRadius": 4,
364
364
  "borderWidth": 2,
365
365
  "flexDirection": "row",
366
- "height": 20,
366
+ "height": 24,
367
367
  "justifyContent": "center",
368
368
  "overflow": "hidden",
369
- "width": 20,
369
+ "width": 24,
370
370
  },
371
371
  undefined,
372
372
  ]
@@ -60,7 +60,7 @@ const Collapse = ({ open = false, children, testID, style }: CollapseProps) => {
60
60
  >
61
61
  <StyledHiddenWrapper>
62
62
  <StyledChildWrapper
63
- onLayout={event => fetchMaxHeight(event.nativeEvent.layout)}
63
+ onLayout={(event) => fetchMaxHeight(event.nativeEvent.layout)}
64
64
  style={style}
65
65
  >
66
66
  {children}
@@ -16,9 +16,11 @@ export const calculateSnapPointsData = (
16
16
  height: number,
17
17
  snapPoints: number[]
18
18
  ): SnapPointsData => {
19
- const filteredSnapPoints = snapPoints.filter(value => value >= minimumHeight);
19
+ const filteredSnapPoints = snapPoints.filter(
20
+ (value) => value >= minimumHeight
21
+ );
20
22
  const snapPointsOffsetValues = [minimumHeight, ...filteredSnapPoints].map(
21
- value => getOffset(height, value)
23
+ (value) => getOffset(height, value)
22
24
  );
23
25
  const uniqSnapPointOffsetValues = Array.from(
24
26
  new Set([...snapPointsOffsetValues, 0])
@@ -35,7 +37,9 @@ export const calculateAnimatedToValue = (
35
37
  position: number,
36
38
  heightSnapPoints: number[]
37
39
  ) => {
38
- const distances = heightSnapPoints.map(height => Math.abs(position - height));
40
+ const distances = heightSnapPoints.map((height) =>
41
+ Math.abs(position - height)
42
+ );
39
43
 
40
44
  const minIndex = distances.indexOf(Math.min(...distances));
41
45
  return heightSnapPoints[minIndex];
@@ -12,14 +12,6 @@ const StyledWrapper = styled(View)(({ theme }) => ({
12
12
  padding: theme.__hd__.empty.space.wrapperPadding,
13
13
  }));
14
14
 
15
- const StyledIllustration = styled(View)(({ theme }) => ({
16
- height: theme.__hd__.empty.sizes.illustration,
17
- width: theme.__hd__.empty.sizes.illustration,
18
- borderRadius: theme.__hd__.empty.radii.illustration,
19
- backgroundColor: theme.__hd__.empty.colors.illustrationBackground,
20
- marginBottom: theme.__hd__.empty.space.illustrationMargin,
21
- }));
22
-
23
15
  const StyledTitle = styled(Text)<{ themeVariant: ThemeVariant }>(
24
16
  ({ theme, themeVariant }) => ({
25
17
  fontFamily: theme.__hd__.empty.fonts.title,
@@ -45,4 +37,4 @@ const StyledDescription = styled(Text)<{ themeVariant: ThemeVariant }>(
45
37
  })
46
38
  );
47
39
 
48
- export { StyledWrapper, StyledIllustration, StyledTitle, StyledDescription };
40
+ export { StyledWrapper, StyledTitle, StyledDescription };
@@ -16,15 +16,68 @@ exports[`Empty renders empty state content correctly 1`] = `
16
16
  ]
17
17
  }
18
18
  >
19
- <View
19
+ <Text
20
+ style={
21
+ Array [
22
+ Object {
23
+ "color": "#001f23",
24
+ "fontFamily": "BeVietnamPro-SemiBold",
25
+ "fontSize": 28,
26
+ "marginBottom": 16,
27
+ "textAlign": "center",
28
+ },
29
+ undefined,
30
+ ]
31
+ }
32
+ themeVariant="light"
33
+ >
34
+ You have no notification at this time
35
+ </Text>
36
+ <Text
37
+ style={
38
+ Array [
39
+ Object {
40
+ "color": "#4d6265",
41
+ "fontFamily": "BeVietnamPro-Light",
42
+ "fontSize": 16,
43
+ "textAlign": "center",
44
+ },
45
+ undefined,
46
+ ]
47
+ }
48
+ themeVariant="light"
49
+ >
50
+ We'll notify you later.
51
+ </Text>
52
+ </View>
53
+ `;
54
+
55
+ exports[`Empty renders empty state with image correctly 1`] = `
56
+ <View
57
+ style={
58
+ Array [
59
+ Object {
60
+ "alignItems": "center",
61
+ "display": "flex",
62
+ "flex": 1,
63
+ "flexDirection": "column",
64
+ "justifyContent": "center",
65
+ "padding": 16,
66
+ },
67
+ undefined,
68
+ ]
69
+ }
70
+ >
71
+ <Image
72
+ source={
73
+ Object {
74
+ "uri": "path_to_image",
75
+ }
76
+ }
20
77
  style={
21
78
  Array [
22
79
  Object {
23
- "backgroundColor": "#ccced1",
24
- "borderRadius": 999,
25
- "height": 168,
26
80
  "marginBottom": 24,
27
- "width": 168,
28
81
  },
29
82
  undefined,
30
83
  ]
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { Image } from 'react-native';
2
3
 
3
4
  import renderWithTheme from '../../../testHelpers/renderWithTheme';
4
5
  import Empty from '..';
@@ -14,4 +15,16 @@ describe('Empty', () => {
14
15
 
15
16
  expect(toJSON()).toMatchSnapshot();
16
17
  });
18
+
19
+ it('renders empty state with image correctly', () => {
20
+ const { toJSON } = renderWithTheme(
21
+ <Empty
22
+ image={<Image source={{ uri: 'path_to_image' }} />}
23
+ title="You have no notification at this time"
24
+ description="We'll notify you later."
25
+ />
26
+ );
27
+
28
+ expect(toJSON()).toMatchSnapshot();
29
+ });
17
30
  });
@@ -1,13 +1,20 @@
1
1
  import React from 'react';
2
- import type { StyleProp, ViewStyle } from 'react-native';
3
- import {
4
- StyledWrapper,
5
- StyledIllustration,
6
- StyledTitle,
7
- StyledDescription,
8
- } from './StyledEmpty';
2
+ import type { ReactElement } from 'react';
3
+ import type {
4
+ StyleProp,
5
+ ViewStyle,
6
+ ImageProps as RNImageProps,
7
+ } from 'react-native';
8
+
9
+ import { useTheme } from '../../theme';
10
+ import { ImageProps } from '../Image';
11
+ import { StyledWrapper, StyledTitle, StyledDescription } from './StyledEmpty';
9
12
 
10
13
  interface EmptyProps {
14
+ /**
15
+ * Image to be displayed.
16
+ */
17
+ image?: ReactElement<ImageProps | RNImageProps>;
11
18
  /**
12
19
  * Empty's title.
13
20
  */
@@ -32,21 +39,34 @@ interface EmptyProps {
32
39
  }
33
40
 
34
41
  const Empty = ({
42
+ image,
35
43
  title,
36
44
  description,
37
45
  style,
38
46
  testID,
39
47
  variant = 'light',
40
- }: EmptyProps): JSX.Element => (
41
- <StyledWrapper style={style} testID={testID}>
42
- <StyledIllustration />
43
- <StyledTitle themeVariant={variant}>{title}</StyledTitle>
44
- {!!description && (
45
- <StyledDescription themeVariant={variant}>
46
- {description}
47
- </StyledDescription>
48
- )}
49
- </StyledWrapper>
50
- );
48
+ }: EmptyProps): JSX.Element => {
49
+ const theme = useTheme();
50
+ return (
51
+ <StyledWrapper style={style} testID={testID}>
52
+ {image !== undefined &&
53
+ React.cloneElement(image, {
54
+ ...image.props,
55
+ style: [
56
+ {
57
+ marginBottom: theme.__hd__.empty.space.imageMargin,
58
+ },
59
+ image.props.style,
60
+ ],
61
+ })}
62
+ <StyledTitle themeVariant={variant}>{title}</StyledTitle>
63
+ {!!description && (
64
+ <StyledDescription themeVariant={variant}>
65
+ {description}
66
+ </StyledDescription>
67
+ )}
68
+ </StyledWrapper>
69
+ );
70
+ };
51
71
 
52
72
  export default Empty;
@@ -21,7 +21,7 @@ const ActionItemsListComponent = ({
21
21
  items,
22
22
  }: ActionItemsContainerProps) => (
23
23
  <View style={style}>
24
- {items?.map(itemProp => (
24
+ {items?.map((itemProp) => (
25
25
  <ActionItem key={itemProp.icon} {...itemProp} />
26
26
  ))}
27
27
  </View>