@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.
- package/.eslintrc.js +11 -0
- package/.turbo/turbo-build.log +9 -9
- package/babel.config.js +1 -1
- package/es/index.js +714 -471
- package/lib/index.js +720 -474
- package/package.json +9 -15
- package/rollup.config.js +1 -0
- package/src/components/BottomNavigation/__tests__/index.spec.tsx +1 -1
- package/src/components/BottomNavigation/index.tsx +3 -3
- package/src/components/BottomSheet/index.tsx +6 -1
- package/src/components/Box/helpers.ts +1 -1
- package/src/components/Calendar/index.tsx +9 -9
- package/src/components/Checkbox/__tests__/__snapshots__/StyledCheckbox.spec.tsx.snap +4 -4
- package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +13 -13
- package/src/components/Collapse/index.tsx +1 -1
- package/src/components/Drawer/DragableDrawer/helpers.ts +7 -3
- package/src/components/Empty/StyledEmpty.tsx +1 -9
- package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +58 -5
- package/src/components/Empty/__tests__/index.spec.tsx +13 -0
- package/src/components/Empty/index.tsx +38 -18
- package/src/components/FAB/ActionGroup/index.tsx +1 -1
- package/src/components/Icon/HeroIcon/selection.json +7029 -1
- package/src/components/Image/__tests__/__snapshots__/index.spec.tsx.snap +81 -0
- package/src/components/Image/__tests__/index.spec.tsx +29 -0
- package/src/components/Image/index.tsx +46 -0
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +5 -5
- package/src/components/PinInput/index.tsx +1 -1
- package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +60 -60
- package/src/components/RichTextEditor/EditorToolbar.tsx +3 -3
- package/src/components/RichTextEditor/RichTextEditor.tsx +5 -5
- package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +2 -2
- package/src/components/RichTextEditor/__tests__/MentionList.spec.tsx +1 -1
- package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +2 -2
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +2 -2
- package/src/components/Select/MultiSelect/OptionList.tsx +5 -7
- package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +21 -0
- package/src/components/Select/MultiSelect/index.tsx +35 -5
- package/src/components/Select/SingleSelect/OptionList.tsx +4 -5
- package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +16 -0
- package/src/components/Select/SingleSelect/index.tsx +36 -6
- package/src/components/Select/StyledOptionList.tsx +3 -9
- package/src/components/Select/helpers.tsx +4 -4
- package/src/components/Slider/__tests__/__snapshots__/index.spec.tsx.snap +43 -0
- package/src/components/Slider/__tests__/index.spec.tsx +33 -0
- package/src/components/Slider/index.tsx +89 -0
- package/src/components/Switch/SelectorSwitch/Option.tsx +67 -0
- package/src/components/Switch/SelectorSwitch/StyledSelectorSwitch.tsx +25 -0
- package/src/components/Switch/SelectorSwitch/__tests__/Option.spec.tsx +61 -0
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +195 -0
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +121 -0
- package/src/components/Switch/SelectorSwitch/__tests__/index.spec.tsx +62 -0
- package/src/components/Switch/SelectorSwitch/index.tsx +60 -0
- package/src/components/Switch/StyledSwitch.tsx +4 -4
- package/src/components/Switch/__tests__/__snapshots__/StyledSwitch.spec.tsx.snap +10 -10
- package/src/components/Switch/__tests__/__snapshots__/index.spec.tsx.snap +8 -8
- package/src/components/Switch/index.tsx +9 -5
- package/src/components/Tabs/ScrollableTabs.tsx +12 -5
- package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +1 -1
- package/src/components/Tabs/__tests__/index.spec.tsx +1 -1
- package/src/components/Tabs/index.tsx +13 -6
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +3 -1
- package/src/components/TextInput/__tests__/index.spec.tsx +114 -112
- package/src/components/TextInput/index.tsx +64 -59
- package/src/components/Toast/ToastContainer.tsx +6 -6
- package/src/index.ts +4 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +70 -23
- package/src/theme/components/alert.ts +1 -2
- package/src/theme/components/avatar.ts +8 -8
- package/src/theme/components/badge.ts +4 -4
- package/src/theme/components/bottomNavigation.ts +1 -1
- package/src/theme/components/bottomSheet.ts +2 -3
- package/src/theme/components/calendar.ts +9 -7
- package/src/theme/components/card.ts +1 -1
- package/src/theme/components/checkbox.ts +2 -5
- package/src/theme/components/datePicker.ts +3 -3
- package/src/theme/components/drawer.ts +2 -3
- package/src/theme/components/empty.ts +3 -8
- package/src/theme/components/fab.ts +2 -2
- package/src/theme/components/image.ts +12 -0
- package/src/theme/components/pinInput.ts +3 -3
- package/src/theme/components/progress.ts +2 -3
- package/src/theme/components/radio.ts +7 -3
- package/src/theme/components/richTextEditor.ts +4 -4
- package/src/theme/components/slider.ts +13 -0
- package/src/theme/components/switch.ts +28 -17
- package/src/theme/components/tabs.ts +1 -1
- package/src/theme/components/timePicker.ts +3 -3
- package/src/theme/components/toast.ts +1 -2
- package/src/theme/getTheme.ts +9 -2
- package/src/theme/global/colors/swag.ts +2 -0
- package/src/theme/global/colors/types.ts +2 -0
- package/src/theme/global/index.ts +3 -0
- package/src/theme/global/scale.ts +3 -0
- package/src/theme/global/sizes.ts +29 -0
- package/testUtils/setup.tsx +15 -1
- package/tsconfig.json +1 -1
- package/types/components/BottomSheet/index.d.ts +5 -1
- package/types/components/Empty/StyledEmpty.d.ts +1 -7
- package/types/components/Empty/index.d.ts +8 -2
- package/types/components/Image/__tests__/index.spec.d.ts +1 -0
- package/types/components/Image/index.d.ts +17 -0
- package/types/components/Select/MultiSelect/OptionList.d.ts +5 -2
- package/types/components/Select/MultiSelect/index.d.ts +7 -1
- package/types/components/Select/SingleSelect/OptionList.d.ts +5 -2
- package/types/components/Select/SingleSelect/index.d.ts +8 -2
- package/types/components/Select/StyledOptionList.d.ts +4 -3
- package/types/components/Select/index.d.ts +1 -1
- package/types/components/Slider/__tests__/index.spec.d.ts +1 -0
- package/types/components/Slider/index.d.ts +52 -0
- package/types/components/Switch/SelectorSwitch/Option.d.ts +10 -0
- package/types/components/Switch/SelectorSwitch/StyledSelectorSwitch.d.ts +19 -0
- package/types/components/Switch/SelectorSwitch/__tests__/Option.spec.d.ts +1 -0
- package/types/components/Switch/SelectorSwitch/__tests__/index.spec.d.ts +1 -0
- package/types/components/Switch/SelectorSwitch/index.d.ts +37 -0
- package/types/components/Switch/index.d.ts +5 -3
- package/types/components/Tabs/ScrollableTabs.d.ts +1 -1
- package/types/components/Tabs/index.d.ts +2 -2
- package/types/components/TextInput/index.d.ts +6 -5
- package/types/index.d.ts +3 -1
- package/types/theme/components/datePicker.d.ts +2 -1
- package/types/theme/components/empty.d.ts +2 -5
- package/types/theme/components/image.d.ts +8 -0
- package/types/theme/components/slider.d.ts +9 -0
- package/types/theme/components/switch.d.ts +27 -12
- package/types/theme/components/timePicker.d.ts +2 -1
- package/types/theme/getTheme.d.ts +4 -0
- package/types/theme/global/colors/types.d.ts +2 -0
- package/types/theme/global/index.d.ts +3 -0
- package/types/theme/global/scale.d.ts +1 -0
- package/types/theme/global/sizes.d.ts +14 -0
- package/.eslintrc.json +0 -61
- package/.prettierrc.json +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "7.
|
|
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.
|
|
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": "
|
|
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
|
@@ -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]);
|
|
@@ -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":
|
|
12
|
+
"height": 24,
|
|
13
13
|
"justifyContent": "center",
|
|
14
14
|
"overflow": "hidden",
|
|
15
|
-
"width":
|
|
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":
|
|
33
|
+
"height": 24,
|
|
34
34
|
"justifyContent": "center",
|
|
35
35
|
"overflow": "hidden",
|
|
36
|
-
"width":
|
|
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":
|
|
31
|
+
"height": 24,
|
|
32
32
|
"justifyContent": "center",
|
|
33
33
|
"overflow": "hidden",
|
|
34
|
-
"width":
|
|
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":
|
|
72
|
+
"height": 24,
|
|
73
73
|
"justifyContent": "center",
|
|
74
74
|
"overflow": "hidden",
|
|
75
|
-
"width":
|
|
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":
|
|
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":
|
|
160
|
+
"height": 24,
|
|
161
161
|
"justifyContent": "center",
|
|
162
162
|
"overflow": "hidden",
|
|
163
|
-
"width":
|
|
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":
|
|
230
|
+
"height": 24,
|
|
231
231
|
"justifyContent": "center",
|
|
232
232
|
"overflow": "hidden",
|
|
233
|
-
"width":
|
|
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":
|
|
296
|
+
"height": 24,
|
|
297
297
|
"justifyContent": "center",
|
|
298
298
|
"overflow": "hidden",
|
|
299
|
-
"width":
|
|
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":
|
|
366
|
+
"height": 24,
|
|
367
367
|
"justifyContent": "center",
|
|
368
368
|
"overflow": "hidden",
|
|
369
|
-
"width":
|
|
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(
|
|
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 =>
|
|
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,
|
|
40
|
+
export { StyledWrapper, StyledTitle, StyledDescription };
|
|
@@ -16,15 +16,68 @@ exports[`Empty renders empty state content correctly 1`] = `
|
|
|
16
16
|
]
|
|
17
17
|
}
|
|
18
18
|
>
|
|
19
|
-
<
|
|
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 {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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;
|