@hero-design/rn 7.17.1 → 7.18.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 (79) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/es/index.js +3680 -3449
  3. package/lib/index.js +3684 -3451
  4. package/package.json +2 -2
  5. package/src/components/BottomNavigation/index.tsx +1 -1
  6. package/src/components/Button/Button.tsx +1 -0
  7. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +2 -2
  8. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +6 -6
  9. package/src/components/Button/UtilityButton/{styled.tsx → StyledUtilityButton.tsx} +2 -2
  10. package/src/components/Button/UtilityButton/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
  11. package/src/components/Button/UtilityButton/index.tsx +5 -1
  12. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +14 -14
  13. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +1 -0
  14. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +1 -0
  15. package/src/components/Drawer/DragableDrawer/__tests__/__snapshots__/index.spec.tsx.snap +99 -0
  16. package/src/components/Drawer/DragableDrawer/__tests__/helpers.spec.ts +39 -0
  17. package/src/components/Drawer/DragableDrawer/__tests__/index.spec.tsx +24 -0
  18. package/src/components/Drawer/DragableDrawer/helpers.ts +43 -0
  19. package/src/components/Drawer/DragableDrawer/index.tsx +205 -0
  20. package/src/components/Drawer/StyledDrawer.tsx +70 -26
  21. package/src/components/Drawer/index.tsx +4 -1
  22. package/src/components/Empty/StyledEmpty.tsx +4 -3
  23. package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
  24. package/src/components/Empty/index.tsx +2 -2
  25. package/src/components/FAB/ActionGroup/index.tsx +1 -1
  26. package/src/components/List/ListItem.tsx +1 -1
  27. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +2 -0
  28. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
  29. package/src/components/Select/MultiSelect/index.tsx +1 -4
  30. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
  31. package/src/components/Select/SingleSelect/index.tsx +2 -6
  32. package/src/components/Tabs/ScrollableTabs.tsx +1 -1
  33. package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +8 -0
  34. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +79 -0
  35. package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +79 -0
  36. package/src/components/Tabs/__tests__/index.spec.tsx +8 -0
  37. package/src/components/Tabs/index.tsx +8 -3
  38. package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +1 -1
  39. package/src/components/TextInput/StyledTextInput.tsx +1 -0
  40. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +13 -0
  41. package/src/components/TextInput/index.tsx +2 -2
  42. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +1 -0
  43. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +1 -0
  44. package/src/index.ts +9 -1
  45. package/src/theme/ThemeProvider.ts +19 -0
  46. package/src/theme/ThemeSwitcher.tsx +27 -0
  47. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +25 -12
  48. package/src/theme/components/button.ts +9 -8
  49. package/src/theme/components/drawer.ts +14 -2
  50. package/src/theme/components/empty.ts +3 -2
  51. package/src/theme/getTheme.ts +129 -0
  52. package/src/theme/global/{colors.ts → colors/swag.ts} +8 -5
  53. package/src/theme/global/colors/types.ts +45 -0
  54. package/src/theme/global/colors/work.ts +14 -0
  55. package/src/theme/global/index.ts +6 -2
  56. package/src/theme/index.ts +16 -143
  57. package/src/utils/scale.ts +4 -1
  58. package/types/components/Button/Button.d.ts +1 -0
  59. package/types/components/Button/UtilityButton/{styled.d.ts → StyledUtilityButton.d.ts} +0 -0
  60. package/types/components/Drawer/DragableDrawer/__tests__/helpers.spec.d.ts +1 -0
  61. package/types/components/Drawer/DragableDrawer/__tests__/index.spec.d.ts +1 -0
  62. package/types/components/Drawer/DragableDrawer/helpers.d.ts +8 -0
  63. package/types/components/Drawer/DragableDrawer/index.d.ts +33 -0
  64. package/types/components/Drawer/StyledDrawer.d.ts +34 -4
  65. package/types/components/Drawer/index.d.ts +4 -2
  66. package/types/components/Empty/index.d.ts +1 -1
  67. package/types/components/Icon/utils.d.ts +1 -1
  68. package/types/index.d.ts +2 -2
  69. package/types/theme/ThemeProvider.d.ts +12 -0
  70. package/types/theme/ThemeSwitcher.d.ts +7 -0
  71. package/types/theme/components/button.d.ts +1 -1
  72. package/types/theme/components/drawer.d.ts +9 -0
  73. package/types/theme/components/empty.d.ts +3 -2
  74. package/types/theme/getTheme.d.ts +74 -0
  75. package/types/theme/global/colors/swag.d.ts +3 -0
  76. package/types/theme/global/{colors.d.ts → colors/types.d.ts} +4 -3
  77. package/types/theme/global/colors/work.d.ts +3 -0
  78. package/types/theme/global/index.d.ts +7 -2
  79. package/types/theme/index.d.ts +7 -84
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "7.17.1",
3
+ "version": "7.18.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "@emotion/native": "^11.9.3",
22
22
  "@emotion/react": "^11.9.3",
23
- "@hero-design/colors": "7.17.1",
23
+ "@hero-design/colors": "7.18.0",
24
24
  "date-fns": "^2.16.1",
25
25
  "events": "^3.2.0",
26
26
  "hero-editor": "^1.9.9"
@@ -142,7 +142,7 @@ const BottomNavigation = ({
142
142
  intent={active ? 'primary' : 'text'}
143
143
  testID={`hero-icon-${icon}`}
144
144
  />
145
- {title && (
145
+ {!!title && (
146
146
  <StyledBottomBarText
147
147
  fontSize="small"
148
148
  fontWeight="semi-bold"
@@ -60,6 +60,7 @@ export interface ButtonProps {
60
60
  text: ReactChild;
61
61
  /**
62
62
  * Button type.
63
+ * basic-transparent is deprecated and will be removed in the next major release.
63
64
  */
64
65
  variant?: 'basic-transparent' | 'filled' | 'outlined' | 'text';
65
66
  }
@@ -105,7 +105,7 @@ exports[`StyledLoadingIndicator has outlined-primary style 1`] = `
105
105
  style={
106
106
  Array [
107
107
  Object {
108
- "backgroundColor": "#8505a2",
108
+ "backgroundColor": "#001f23",
109
109
  "borderRadius": 8,
110
110
  "height": 12,
111
111
  "marginBottom": 4,
@@ -165,7 +165,7 @@ exports[`StyledLoadingIndicator has text-primary style 1`] = `
165
165
  style={
166
166
  Array [
167
167
  Object {
168
- "backgroundColor": "#8505a2",
168
+ "backgroundColor": "#001f23",
169
169
  "borderRadius": 8,
170
170
  "height": 12,
171
171
  "marginBottom": 4,
@@ -641,7 +641,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is outlined-primar
641
641
  style={
642
642
  Array [
643
643
  Object {
644
- "backgroundColor": "#8505a2",
644
+ "backgroundColor": "#001f23",
645
645
  "borderRadius": 8,
646
646
  "height": 12,
647
647
  "marginBottom": 4,
@@ -675,7 +675,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is outlined-primar
675
675
  style={
676
676
  Array [
677
677
  Object {
678
- "backgroundColor": "#8505a2",
678
+ "backgroundColor": "#001f23",
679
679
  "borderRadius": 8,
680
680
  "height": 12,
681
681
  "marginBottom": 4,
@@ -709,7 +709,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is outlined-primar
709
709
  style={
710
710
  Array [
711
711
  Object {
712
- "backgroundColor": "#8505a2",
712
+ "backgroundColor": "#001f23",
713
713
  "borderRadius": 8,
714
714
  "height": 12,
715
715
  "marginBottom": 4,
@@ -1004,7 +1004,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-primary 1`
1004
1004
  style={
1005
1005
  Array [
1006
1006
  Object {
1007
- "backgroundColor": "#8505a2",
1007
+ "backgroundColor": "#001f23",
1008
1008
  "borderRadius": 8,
1009
1009
  "height": 12,
1010
1010
  "marginBottom": 4,
@@ -1038,7 +1038,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-primary 1`
1038
1038
  style={
1039
1039
  Array [
1040
1040
  Object {
1041
- "backgroundColor": "#8505a2",
1041
+ "backgroundColor": "#001f23",
1042
1042
  "borderRadius": 8,
1043
1043
  "height": 12,
1044
1044
  "marginBottom": 4,
@@ -1072,7 +1072,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-primary 1`
1072
1072
  style={
1073
1073
  Array [
1074
1074
  Object {
1075
- "backgroundColor": "#8505a2",
1075
+ "backgroundColor": "#001f23",
1076
1076
  "borderRadius": 8,
1077
1077
  "height": 12,
1078
1078
  "marginBottom": 4,
@@ -14,12 +14,12 @@ export const ButtonContainer = styled(TouchableOpacity)(({ theme }) => ({
14
14
  }));
15
15
 
16
16
  export const IconWrapper = styled(View)(({ theme }) => ({
17
- paddingRight: theme.__hd__.button.space.utilityIconPadding,
17
+ paddingRight: theme.__hd__.button.space.iconPadding,
18
18
  }));
19
19
 
20
20
  export const ButtonText = styled(Typography.Text)(({ theme }) => ({
21
21
  flexShrink: 1,
22
22
  textAlign: 'center',
23
23
  fontSize: theme.__hd__.button.fontSize.utility,
24
- fontFamily: theme.__hd__.button.fonts.default,
24
+ fontFamily: theme.__hd__.button.fonts.utility,
25
25
  }));
@@ -66,7 +66,7 @@ exports[`UtilityButton snapshot has intent primary style 1`] = `
66
66
  Array [
67
67
  Object {
68
68
  "flexShrink": 1,
69
- "fontFamily": "BeVietnamPro-SemiBold",
69
+ "fontFamily": "BeVietnamPro-Regular",
70
70
  "fontSize": 16,
71
71
  "textAlign": "center",
72
72
  },
@@ -149,7 +149,7 @@ exports[`UtilityButton snapshot has intent text style 1`] = `
149
149
  Array [
150
150
  Object {
151
151
  "flexShrink": 1,
152
- "fontFamily": "BeVietnamPro-SemiBold",
152
+ "fontFamily": "BeVietnamPro-Regular",
153
153
  "fontSize": 16,
154
154
  "textAlign": "center",
155
155
  },
@@ -2,7 +2,11 @@ import React, { ReactChild } from 'react';
2
2
  import { ViewProps } from 'react-native';
3
3
 
4
4
  import Icon, { IconName } from '../../Icon';
5
- import { ButtonContainer, IconWrapper, ButtonText } from './styled';
5
+ import {
6
+ ButtonContainer,
7
+ IconWrapper,
8
+ ButtonText,
9
+ } from './StyledUtilityButton';
6
10
 
7
11
  export interface UtilityButtonProps extends ViewProps {
8
12
  /**
@@ -83,7 +83,7 @@ exports[`StyledButtonContainer has filled-primary style 1`] = `
83
83
  Object {
84
84
  "alignItems": "center",
85
85
  "alignSelf": "stretch",
86
- "backgroundColor": "#8505a2",
86
+ "backgroundColor": "#001f23",
87
87
  "borderRadius": 32,
88
88
  "flexDirection": "row",
89
89
  "justifyContent": "center",
@@ -182,7 +182,7 @@ exports[`StyledButtonContainer has outlined-primary style 1`] = `
182
182
  "alignItems": "center",
183
183
  "alignSelf": "stretch",
184
184
  "backgroundColor": "transparent",
185
- "borderColor": "#8505a2",
185
+ "borderColor": "#001f23",
186
186
  "borderRadius": 32,
187
187
  "borderWidth": 2,
188
188
  "flexDirection": "row",
@@ -316,7 +316,7 @@ exports[`StyledButtonContainer has pressed with the correct variant filled-prima
316
316
  Object {
317
317
  "alignItems": "center",
318
318
  "alignSelf": "stretch",
319
- "backgroundColor": "#c282d1",
319
+ "backgroundColor": "#808f91",
320
320
  "borderRadius": 32,
321
321
  "flexDirection": "row",
322
322
  "justifyContent": "center",
@@ -415,7 +415,7 @@ exports[`StyledButtonContainer has pressed with the correct variant outlined-pri
415
415
  "alignItems": "center",
416
416
  "alignSelf": "stretch",
417
417
  "backgroundColor": "transparent",
418
- "borderColor": "#c282d1",
418
+ "borderColor": "#808f91",
419
419
  "borderRadius": 32,
420
420
  "borderWidth": 2,
421
421
  "flexDirection": "row",
@@ -810,7 +810,7 @@ exports[`StyledButtonIcon has outlined-primary style 1`] = `
810
810
  },
811
811
  Array [
812
812
  Object {
813
- "color": "#8505a2",
813
+ "color": "#001f23",
814
814
  "fontSize": 18,
815
815
  "lineHeight": 24,
816
816
  },
@@ -974,7 +974,7 @@ exports[`StyledButtonIcon has pressed with the correct variant outlined-primary
974
974
  },
975
975
  Array [
976
976
  Object {
977
- "color": "#c282d1",
977
+ "color": "#808f91",
978
978
  "fontSize": 18,
979
979
  "lineHeight": 24,
980
980
  },
@@ -1046,7 +1046,7 @@ exports[`StyledButtonIcon has pressed with the correct variant text-primary styl
1046
1046
  },
1047
1047
  Array [
1048
1048
  Object {
1049
- "color": "#c282d1",
1049
+ "color": "#808f91",
1050
1050
  "fontSize": 16,
1051
1051
  "lineHeight": 24,
1052
1052
  },
@@ -1118,7 +1118,7 @@ exports[`StyledButtonIcon has text-primary style 1`] = `
1118
1118
  },
1119
1119
  Array [
1120
1120
  Object {
1121
- "color": "#8505a2",
1121
+ "color": "#001f23",
1122
1122
  "fontSize": 16,
1123
1123
  "lineHeight": 24,
1124
1124
  },
@@ -1183,7 +1183,7 @@ exports[`StyledButtonIconWrapper has left style 1`] = `
1183
1183
  style={
1184
1184
  Array [
1185
1185
  Object {
1186
- "paddingRight": 8,
1186
+ "paddingRight": 12,
1187
1187
  },
1188
1188
  undefined,
1189
1189
  ]
@@ -1197,7 +1197,7 @@ exports[`StyledButtonIconWrapper has right style 1`] = `
1197
1197
  style={
1198
1198
  Array [
1199
1199
  Object {
1200
- "paddingLeft": 8,
1200
+ "paddingLeft": 12,
1201
1201
  },
1202
1202
  undefined,
1203
1203
  ]
@@ -1384,7 +1384,7 @@ exports[`StyledButtonText has outlined-primary style 1`] = `
1384
1384
  },
1385
1385
  Array [
1386
1386
  Object {
1387
- "color": "#8505a2",
1387
+ "color": "#001f23",
1388
1388
  "flexShrink": 1,
1389
1389
  "fontFamily": "BeVietnamPro-SemiBold",
1390
1390
  "fontSize": 18,
@@ -1621,7 +1621,7 @@ exports[`StyledButtonText has pressed with the correct variant outlined-primary
1621
1621
  },
1622
1622
  Array [
1623
1623
  Object {
1624
- "color": "#c282d1",
1624
+ "color": "#808f91",
1625
1625
  "flexShrink": 1,
1626
1626
  "fontFamily": "BeVietnamPro-SemiBold",
1627
1627
  "fontSize": 18,
@@ -1723,7 +1723,7 @@ exports[`StyledButtonText has pressed with the correct variant text-primary styl
1723
1723
  },
1724
1724
  Array [
1725
1725
  Object {
1726
- "color": "#c282d1",
1726
+ "color": "#808f91",
1727
1727
  "flexShrink": 1,
1728
1728
  "fontFamily": "BeVietnamPro-SemiBold",
1729
1729
  "fontSize": 16,
@@ -1823,7 +1823,7 @@ exports[`StyledButtonText has text-primary style 1`] = `
1823
1823
  },
1824
1824
  Array [
1825
1825
  Object {
1826
- "color": "#8505a2",
1826
+ "color": "#001f23",
1827
1827
  "flexShrink": 1,
1828
1828
  "fontFamily": "BeVietnamPro-SemiBold",
1829
1829
  "fontSize": 16,
@@ -115,6 +115,7 @@ exports[`DatePickerAndroid renders correctly 1`] = `
115
115
  "alignSelf": "stretch",
116
116
  "flexDirection": "row",
117
117
  "flexGrow": 2,
118
+ "flexShrink": 1,
118
119
  },
119
120
  undefined,
120
121
  ]
@@ -115,6 +115,7 @@ exports[`DatePickerIOS renders correctly 1`] = `
115
115
  "alignSelf": "stretch",
116
116
  "flexDirection": "row",
117
117
  "flexGrow": 2,
118
+ "flexShrink": 1,
118
119
  },
119
120
  undefined,
120
121
  ]
@@ -0,0 +1,99 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`DragableDrawer renders correctly 1`] = `
4
+ <View
5
+ enableShadow={true}
6
+ pointerEvents="box-none"
7
+ style={
8
+ Array [
9
+ Object {
10
+ "bottom": 0,
11
+ "elevation": 9999,
12
+ "flexDirection": "column-reverse",
13
+ "left": 0,
14
+ "overflow": "hidden",
15
+ "position": "absolute",
16
+ "right": 0,
17
+ "shadowColor": "#001f23",
18
+ "shadowOffset": Object {
19
+ "height": 3,
20
+ "width": 0,
21
+ },
22
+ "shadowOpacity": 0.27,
23
+ "shadowRadius": 4.65,
24
+ "top": 0,
25
+ "zIndex": 9999,
26
+ },
27
+ undefined,
28
+ ]
29
+ }
30
+ testID="drawer"
31
+ >
32
+ <View
33
+ collapsable={false}
34
+ enableShadow={true}
35
+ nativeID="animatedComponent"
36
+ onLayout={[Function]}
37
+ style={
38
+ Object {
39
+ "backgroundColor": "#ffffff",
40
+ "borderTopLeftRadius": 16,
41
+ "borderTopRightRadius": 16,
42
+ "elevation": 10,
43
+ "maxHeight": "100%",
44
+ "overflow": "hidden",
45
+ "transform": Array [
46
+ Object {
47
+ "scaleY": 0,
48
+ },
49
+ Object {
50
+ "translateY": 0,
51
+ },
52
+ ],
53
+ }
54
+ }
55
+ >
56
+ <View
57
+ onMoveShouldSetResponder={[Function]}
58
+ onMoveShouldSetResponderCapture={[Function]}
59
+ onResponderEnd={[Function]}
60
+ onResponderGrant={[Function]}
61
+ onResponderMove={[Function]}
62
+ onResponderReject={[Function]}
63
+ onResponderRelease={[Function]}
64
+ onResponderStart={[Function]}
65
+ onResponderTerminate={[Function]}
66
+ onResponderTerminationRequest={[Function]}
67
+ onStartShouldSetResponder={[Function]}
68
+ onStartShouldSetResponderCapture={[Function]}
69
+ style={
70
+ Array [
71
+ Object {
72
+ "alignItems": "center",
73
+ "backgroundColor": "#ffffff",
74
+ "paddingVertical": 8,
75
+ },
76
+ undefined,
77
+ ]
78
+ }
79
+ >
80
+ <View
81
+ style={
82
+ Array [
83
+ Object {
84
+ "backgroundColor": "#001f23",
85
+ "borderRadius": 4,
86
+ "height": 4,
87
+ "width": 56,
88
+ },
89
+ undefined,
90
+ ]
91
+ }
92
+ />
93
+ </View>
94
+ <Text>
95
+ Drawer Content
96
+ </Text>
97
+ </View>
98
+ </View>
99
+ `;
@@ -0,0 +1,39 @@
1
+ import {
2
+ calculateAnimatedToValue,
3
+ calculateSnapPointsData,
4
+ getOffset,
5
+ } from '../helpers';
6
+
7
+ describe('calculateSnapPointsData', () => {
8
+ it('returns correct values', () => {
9
+ const actual = calculateSnapPointsData(20, 1000, [10, 30, 40, 80]);
10
+ expect(actual).toEqual({
11
+ list: [800, 700, 600, 200, 0],
12
+ minHeightOffset: 800,
13
+ maxHeightOffset: 0,
14
+ });
15
+ });
16
+ });
17
+
18
+ describe('calculateAnimatedToValue', () => {
19
+ it('returns correct value', () => {
20
+ const actual = calculateAnimatedToValue(350, [800, 500, 300, 0]);
21
+ expect(actual).toEqual(300);
22
+ });
23
+ });
24
+
25
+ describe('getOffset', () => {
26
+ it.each`
27
+ percentage | expected
28
+ ${-2} | ${1000}
29
+ ${0} | ${1000}
30
+ ${150} | ${0}
31
+ ${30} | ${700}
32
+ `(
33
+ 'returns $expected when percentage is $percentage',
34
+ ({ percentage, expected }) => {
35
+ const actual = getOffset(1000, percentage);
36
+ expect(actual).toEqual(expected);
37
+ }
38
+ );
39
+ });
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { Text } from 'react-native';
3
+ import renderWithTheme from '../../../../testHelpers/renderWithTheme';
4
+ import DragableDrawer from '..';
5
+
6
+ describe('DragableDrawer', () => {
7
+ it('renders correctly', () => {
8
+ const { toJSON, getByTestId } = renderWithTheme(
9
+ <DragableDrawer
10
+ initialHeightPercentage={30}
11
+ minimumHeightPercentage={10}
12
+ onExpanded={jest.fn()}
13
+ onCollapsed={jest.fn()}
14
+ snapPoints={[40, 70]}
15
+ testID="drawer"
16
+ >
17
+ <Text>Drawer Content</Text>
18
+ </DragableDrawer>
19
+ );
20
+
21
+ expect(toJSON()).toMatchSnapshot();
22
+ expect(getByTestId('drawer')).toBeTruthy();
23
+ });
24
+ });
@@ -0,0 +1,43 @@
1
+ export const getOffset = (height: number, percentage: number) => {
2
+ if (percentage < 0) return height;
3
+ if (percentage > 100) return 0;
4
+
5
+ return height * ((100 - percentage) / 100);
6
+ };
7
+
8
+ export type SnapPointsData = {
9
+ list: number[];
10
+ minHeightOffset: number;
11
+ maxHeightOffset: number;
12
+ };
13
+
14
+ export const calculateSnapPointsData = (
15
+ minimumHeight: number,
16
+ height: number,
17
+ snapPoints: number[]
18
+ ): SnapPointsData => {
19
+ const filteredSnapPoints = snapPoints.filter(value => value >= minimumHeight);
20
+ const snapPointsOffsetValues = [
21
+ minimumHeight,
22
+ ...filteredSnapPoints,
23
+ ].map(value => getOffset(height, value));
24
+ const uniqSnapPointOffsetValues = Array.from(
25
+ new Set([...snapPointsOffsetValues, 0])
26
+ );
27
+
28
+ return {
29
+ list: uniqSnapPointOffsetValues,
30
+ minHeightOffset: Math.max(...uniqSnapPointOffsetValues), // Furthest from max height
31
+ maxHeightOffset: 0, // Max height
32
+ };
33
+ };
34
+
35
+ export const calculateAnimatedToValue = (
36
+ position: number,
37
+ heightSnapPoints: number[]
38
+ ) => {
39
+ const distances = heightSnapPoints.map(height => Math.abs(position - height));
40
+
41
+ const minIndex = distances.indexOf(Math.min(...distances));
42
+ return heightSnapPoints[minIndex];
43
+ };