@hero-design/rn 7.21.0 → 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 (58) 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 +357 -247
  5. package/lib/index.js +361 -251
  6. package/package.json +7 -15
  7. package/src/components/BottomNavigation/__tests__/index.spec.tsx +1 -1
  8. package/src/components/BottomNavigation/index.tsx +3 -3
  9. package/src/components/Box/helpers.ts +1 -1
  10. package/src/components/Calendar/index.tsx +9 -9
  11. package/src/components/Collapse/index.tsx +1 -1
  12. package/src/components/Drawer/DragableDrawer/helpers.ts +7 -3
  13. package/src/components/FAB/ActionGroup/index.tsx +1 -1
  14. package/src/components/Icon/HeroIcon/selection.json +7029 -1
  15. package/src/components/PinInput/index.tsx +1 -1
  16. package/src/components/RichTextEditor/EditorToolbar.tsx +3 -3
  17. package/src/components/RichTextEditor/RichTextEditor.tsx +5 -5
  18. package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +2 -2
  19. package/src/components/RichTextEditor/__tests__/MentionList.spec.tsx +1 -1
  20. package/src/components/Select/MultiSelect/OptionList.tsx +1 -1
  21. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +1 -1
  22. package/src/components/Select/MultiSelect/index.tsx +3 -3
  23. package/src/components/Select/SingleSelect/index.tsx +3 -3
  24. package/src/components/Select/helpers.tsx +4 -4
  25. package/src/components/Slider/index.tsx +1 -1
  26. package/src/components/Switch/SelectorSwitch/Option.tsx +67 -0
  27. package/src/components/Switch/SelectorSwitch/StyledSelectorSwitch.tsx +25 -0
  28. package/src/components/Switch/SelectorSwitch/__tests__/Option.spec.tsx +61 -0
  29. package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +195 -0
  30. package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +121 -0
  31. package/src/components/Switch/SelectorSwitch/__tests__/index.spec.tsx +62 -0
  32. package/src/components/Switch/SelectorSwitch/index.tsx +60 -0
  33. package/src/components/Switch/index.tsx +4 -1
  34. package/src/components/Tabs/ScrollableTabs.tsx +12 -5
  35. package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +1 -1
  36. package/src/components/Tabs/__tests__/index.spec.tsx +1 -1
  37. package/src/components/Tabs/index.tsx +13 -6
  38. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +3 -1
  39. package/src/components/TextInput/__tests__/index.spec.tsx +114 -112
  40. package/src/components/TextInput/index.tsx +29 -30
  41. package/src/components/Toast/ToastContainer.tsx +6 -6
  42. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +14 -12
  43. package/src/theme/components/switch.ts +14 -18
  44. package/testUtils/setup.tsx +1 -1
  45. package/tsconfig.json +1 -1
  46. package/types/components/Slider/index.d.ts +1 -1
  47. package/types/components/Switch/SelectorSwitch/Option.d.ts +10 -0
  48. package/types/components/Switch/SelectorSwitch/StyledSelectorSwitch.d.ts +19 -0
  49. package/types/components/Switch/SelectorSwitch/__tests__/Option.spec.d.ts +1 -0
  50. package/types/components/Switch/SelectorSwitch/__tests__/index.spec.d.ts +1 -0
  51. package/types/components/Switch/SelectorSwitch/index.d.ts +37 -0
  52. package/types/components/Switch/index.d.ts +5 -3
  53. package/types/components/Tabs/ScrollableTabs.d.ts +1 -1
  54. package/types/components/Tabs/index.d.ts +2 -2
  55. package/types/components/TextInput/index.d.ts +4 -4
  56. package/types/theme/components/switch.d.ts +14 -12
  57. package/.eslintrc.json +0 -62
  58. package/.prettierrc.json +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "7.21.0",
3
+ "version": "7.22.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.21.0",
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"
@@ -56,19 +56,9 @@
56
56
  "@types/react": "^17.0.39",
57
57
  "@types/react-native": "^0.67.7",
58
58
  "@types/react-native-vector-icons": "^6.4.10",
59
- "@typescript-eslint/eslint-plugin": "^5.12.1",
60
- "@typescript-eslint/parser": "^5.12.1",
61
59
  "babel-plugin-inline-import": "^3.0.0",
62
- "eslint": "^8.9.0",
63
- "eslint-config-airbnb": "^19.0.4",
64
- "eslint-config-prettier": "^8.5.0",
65
- "eslint-plugin-import": "^2.25.4",
66
- "eslint-plugin-jsx-a11y": "^6.5.1",
67
- "eslint-plugin-prettier": "^4.0.0",
68
- "eslint-plugin-react": "^7.28.0",
69
- "eslint-plugin-react-hooks": "^4.3.0",
60
+ "eslint-config-hd": "7.22.0",
70
61
  "jest": "^27.3.1",
71
- "prettier": "^2.5.1",
72
62
  "react": "17.0.2",
73
63
  "react-native": "0.65.1",
74
64
  "react-native-pager-view": "^5.4.25",
@@ -79,6 +69,8 @@
79
69
  "rollup": "^2.68.0",
80
70
  "rollup-plugin-copy": "^3.4.0",
81
71
  "rollup-plugin-flow": "^1.1.1",
82
- "ts-jest": "^27.0.7"
83
- }
72
+ "ts-jest": "^27.0.7",
73
+ "prettier-config-hd": "7.22.0"
74
+ },
75
+ "prettier": "prettier-config-hd"
84
76
  }
@@ -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);
@@ -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()}
@@ -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];
@@ -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>