@hero-design/rn 7.12.1 → 7.14.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 (185) hide show
  1. package/.eslintrc.json +3 -1
  2. package/.turbo/turbo-build.log +3 -2
  3. package/assets/fonts/hero-icons.ttf +0 -0
  4. package/babel.config.js +16 -0
  5. package/es/index.js +35840 -16325
  6. package/lib/assets/fonts/hero-icons.ttf +0 -0
  7. package/lib/index.js +35847 -16327
  8. package/package.json +9 -4
  9. package/rollup.config.js +1 -0
  10. package/src/components/Accordion/AccordionItem.tsx +50 -0
  11. package/src/components/Accordion/StyledAccordion.tsx +29 -0
  12. package/src/components/Accordion/__tests__/AccordionItem.spec.tsx +56 -0
  13. package/src/components/Accordion/__tests__/StyledAccordion.spec.tsx +17 -0
  14. package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +529 -0
  15. package/src/components/Accordion/__tests__/__snapshots__/StyledAccordion.spec.tsx.snap +33 -0
  16. package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +822 -0
  17. package/src/components/Accordion/__tests__/index.spec.tsx +54 -0
  18. package/src/components/Accordion/index.tsx +82 -0
  19. package/src/components/Accordion/utils.tsx +11 -0
  20. package/src/components/Button/Button.tsx +64 -60
  21. package/src/components/Button/IconButton.tsx +1 -1
  22. package/src/components/Button/StyledButton.tsx +4 -6
  23. package/src/components/Button/__tests__/StyledButton.spec.tsx +11 -4
  24. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +312 -78
  25. package/src/components/Calendar/CalendarRowItem.tsx +54 -0
  26. package/src/components/Calendar/StyledCalendar.tsx +76 -0
  27. package/src/components/Calendar/__tests__/CalendarRowItem.spec.tsx +76 -0
  28. package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +411 -0
  29. package/src/components/Calendar/__tests__/helper.spec.ts +50 -0
  30. package/src/components/Calendar/__tests__/index.spec.tsx +99 -0
  31. package/src/components/Calendar/helpers.ts +29 -0
  32. package/src/components/Calendar/index.tsx +217 -0
  33. package/src/components/Collapse/index.tsx +13 -15
  34. package/src/components/ContentNavigator/index.tsx +6 -0
  35. package/src/components/DatePicker/DatePickerAndroid.tsx +59 -0
  36. package/src/components/DatePicker/DatePickerIOS.tsx +87 -0
  37. package/src/components/DatePicker/StyledDatePicker.tsx +8 -0
  38. package/src/components/DatePicker/__tests__/DatePicker.spec.tsx +34 -0
  39. package/src/components/DatePicker/__tests__/DatePickerAndroid.spec.tsx +39 -0
  40. package/src/components/DatePicker/__tests__/DatePickerIOS.spec.tsx +46 -0
  41. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +199 -0
  42. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +513 -0
  43. package/src/components/DatePicker/index.tsx +15 -0
  44. package/src/components/DatePicker/types.ts +49 -0
  45. package/src/components/Empty/StyledEmpty.tsx +47 -0
  46. package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +66 -0
  47. package/src/components/Empty/__tests__/index.spec.tsx +17 -0
  48. package/src/components/Empty/index.tsx +53 -0
  49. package/src/components/FAB/ActionGroup/ActionItem.tsx +6 -2
  50. package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +1 -0
  51. package/src/components/FAB/ActionGroup/StyledActionItem.tsx +7 -1
  52. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +84 -22
  53. package/src/components/FAB/ActionGroup/index.tsx +8 -1
  54. package/src/components/Icon/HeroIcon/selection.json +1 -1
  55. package/src/components/Icon/IconList.ts +13 -0
  56. package/src/components/List/BasicListItem.tsx +44 -34
  57. package/src/components/List/ListItem.tsx +67 -58
  58. package/src/components/List/StyledBasicListItem.tsx +2 -3
  59. package/src/components/List/StyledListItem.tsx +2 -2
  60. package/src/components/List/__tests__/StyledBasicListItem.spec.tsx +5 -2
  61. package/src/components/List/__tests__/StyledListItem.spec.tsx +4 -1
  62. package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +15 -10
  63. package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +52 -32
  64. package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +128 -48
  65. package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +132 -52
  66. package/src/components/RichTextEditor/EditorEvent.ts +7 -0
  67. package/src/components/RichTextEditor/EditorToolbar.tsx +220 -0
  68. package/src/components/RichTextEditor/MentionList.tsx +69 -0
  69. package/src/components/RichTextEditor/RichTextEditor.tsx +396 -0
  70. package/src/components/RichTextEditor/StyledRichTextEditor.ts +20 -0
  71. package/src/components/RichTextEditor/StyledToolbar.ts +32 -0
  72. package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +130 -0
  73. package/src/components/RichTextEditor/__tests__/MentionList.spec.tsx +109 -0
  74. package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +245 -0
  75. package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +324 -0
  76. package/src/components/RichTextEditor/__tests__/__snapshots__/MentionList.spec.tsx.snap +45 -0
  77. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +526 -0
  78. package/src/components/RichTextEditor/constants.ts +20 -0
  79. package/src/components/RichTextEditor/hero-editor.d.ts +8 -0
  80. package/src/components/RichTextEditor/index.tsx +8 -0
  81. package/src/components/RichTextEditor/utils/events.ts +31 -0
  82. package/src/components/RichTextEditor/utils/rnWebView.ts +19 -0
  83. package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +77 -0
  84. package/src/components/SectionHeading/__tests__/index.spec.tsx +14 -0
  85. package/src/components/SectionHeading/index.tsx +16 -9
  86. package/src/components/Tag/StyledTag.tsx +12 -2
  87. package/src/components/Tag/__tests__/Tag.spec.tsx +35 -8
  88. package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +118 -4
  89. package/src/components/Tag/index.tsx +9 -2
  90. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +1 -0
  91. package/src/components/TimePicker/TimePickerIOS.tsx +1 -1
  92. package/src/components/TimePicker/types.ts +1 -1
  93. package/src/components/Typography/Text/StyledText.tsx +2 -1
  94. package/src/components/Typography/Text/__tests__/StyledText.spec.tsx +1 -0
  95. package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +22 -0
  96. package/src/components/Typography/Text/index.tsx +2 -1
  97. package/src/index.ts +10 -0
  98. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +119 -4
  99. package/src/theme/components/accordion.ts +19 -0
  100. package/src/theme/components/button.ts +12 -0
  101. package/src/theme/components/calendar.ts +34 -0
  102. package/src/theme/components/card.ts +1 -1
  103. package/src/theme/components/datePicker.ts +11 -0
  104. package/src/theme/components/empty.ts +38 -0
  105. package/src/theme/components/fab.ts +4 -3
  106. package/src/theme/components/list.ts +1 -0
  107. package/src/theme/components/pinInput.ts +1 -1
  108. package/src/theme/components/richTextEditor.ts +34 -0
  109. package/src/theme/components/tag.ts +8 -2
  110. package/src/theme/components/typography.ts +1 -0
  111. package/src/theme/global/borders.ts +6 -6
  112. package/src/theme/global/colors.ts +5 -1
  113. package/src/theme/index.ts +15 -0
  114. package/testUtils/setup.tsx +17 -0
  115. package/types/components/Accordion/AccordionItem.d.ts +14 -0
  116. package/types/components/Accordion/StyledAccordion.d.ts +32 -0
  117. package/types/components/Accordion/__tests__/AccordionItem.spec.d.ts +1 -0
  118. package/types/components/Accordion/__tests__/StyledAccordion.spec.d.ts +1 -0
  119. package/types/components/Accordion/__tests__/index.spec.d.ts +1 -0
  120. package/types/components/Accordion/index.d.ts +38 -0
  121. package/types/components/Accordion/utils.d.ts +1 -0
  122. package/types/components/Button/IconButton.d.ts +1 -1
  123. package/types/components/Button/StyledButton.d.ts +3 -3
  124. package/types/components/Calendar/CalendarRowItem.d.ts +10 -0
  125. package/types/components/Calendar/StyledCalendar.d.ts +54 -0
  126. package/types/components/Calendar/__tests__/CalendarRowItem.spec.d.ts +1 -0
  127. package/types/components/Calendar/__tests__/helper.spec.d.ts +1 -0
  128. package/types/components/Calendar/__tests__/index.spec.d.ts +1 -0
  129. package/types/components/Calendar/helpers.d.ts +3 -0
  130. package/types/components/Calendar/index.d.ts +40 -0
  131. package/types/components/Collapse/index.d.ts +1 -1
  132. package/types/components/ContentNavigator/index.d.ts +5 -1
  133. package/types/components/DatePicker/DatePickerAndroid.d.ts +3 -0
  134. package/types/components/DatePicker/DatePickerIOS.d.ts +3 -0
  135. package/types/components/DatePicker/StyledDatePicker.d.ts +8 -0
  136. package/types/components/DatePicker/__tests__/DatePicker.spec.d.ts +1 -0
  137. package/types/components/DatePicker/__tests__/DatePickerAndroid.spec.d.ts +1 -0
  138. package/types/components/DatePicker/__tests__/DatePickerIOS.spec.d.ts +1 -0
  139. package/types/components/DatePicker/index.d.ts +3 -0
  140. package/types/components/DatePicker/types.d.ts +48 -0
  141. package/types/components/Empty/StyledEmpty.d.ts +31 -0
  142. package/types/components/Empty/__tests__/index.spec.d.ts +1 -0
  143. package/types/components/Empty/index.d.ts +26 -0
  144. package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +6 -1
  145. package/types/components/FAB/ActionGroup/index.d.ts +6 -1
  146. package/types/components/FAB/index.d.ts +1 -1
  147. package/types/components/Icon/IconList.d.ts +1 -1
  148. package/types/components/Icon/utils.d.ts +1 -1
  149. package/types/components/List/StyledBasicListItem.d.ts +3 -3
  150. package/types/components/List/StyledListItem.d.ts +3 -3
  151. package/types/components/RichTextEditor/EditorEvent.d.ts +3 -0
  152. package/types/components/RichTextEditor/EditorToolbar.d.ts +17 -0
  153. package/types/components/RichTextEditor/MentionList.d.ts +12 -0
  154. package/types/components/RichTextEditor/RichTextEditor.d.ts +65 -0
  155. package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +16 -0
  156. package/types/components/RichTextEditor/StyledToolbar.d.ts +21 -0
  157. package/types/components/RichTextEditor/__tests__/EditorToolbar.spec.d.ts +1 -0
  158. package/types/components/RichTextEditor/__tests__/MentionList.spec.d.ts +1 -0
  159. package/types/components/RichTextEditor/__tests__/RichTextEditor.spec.d.ts +1 -0
  160. package/types/components/RichTextEditor/constants.d.ts +19 -0
  161. package/types/components/RichTextEditor/index.d.ts +5 -0
  162. package/types/components/RichTextEditor/utils/events.d.ts +8 -0
  163. package/types/components/RichTextEditor/utils/rnWebView.d.ts +7 -0
  164. package/types/components/SectionHeading/index.d.ts +2 -2
  165. package/types/components/Select/MultiSelect/OptionList.d.ts +1 -1
  166. package/types/components/Select/SingleSelect/OptionList.d.ts +1 -1
  167. package/types/components/Tag/StyledTag.d.ts +1 -1
  168. package/types/components/Tag/index.d.ts +1 -1
  169. package/types/components/TimePicker/types.d.ts +1 -1
  170. package/types/components/Typography/Text/StyledText.d.ts +1 -1
  171. package/types/components/Typography/Text/index.d.ts +1 -1
  172. package/types/index.d.ts +6 -1
  173. package/types/theme/components/accordion.d.ts +13 -0
  174. package/types/theme/components/button.d.ts +12 -0
  175. package/types/theme/components/calendar.d.ts +26 -0
  176. package/types/theme/components/datePicker.d.ts +6 -0
  177. package/types/theme/components/empty.d.ts +28 -0
  178. package/types/theme/components/fab.d.ts +1 -0
  179. package/types/theme/components/list.d.ts +1 -0
  180. package/types/theme/components/richTextEditor.d.ts +26 -0
  181. package/types/theme/components/tag.d.ts +8 -2
  182. package/types/theme/components/typography.d.ts +1 -0
  183. package/types/theme/global/colors.d.ts +5 -1
  184. package/types/theme/global/index.d.ts +5 -1
  185. package/types/theme/index.d.ts +10 -0
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import Typography from '../Typography';
3
+ import {
4
+ StyledCalendarCell,
5
+ StyledCalendarRowItem,
6
+ StyledMark,
7
+ } from './StyledCalendar';
8
+
9
+ const getCellVariant = (
10
+ isSelected: boolean = false,
11
+ isCurrent: boolean = false
12
+ ) => {
13
+ if (isSelected) return 'selected';
14
+ if (isCurrent) return 'current';
15
+
16
+ return 'default';
17
+ };
18
+
19
+ export interface CalendarRowItemProps {
20
+ date?: Date;
21
+ onPress?: () => void;
22
+ isCurrent?: boolean;
23
+ isSelected?: boolean;
24
+ textIntent?: 'body' | 'subdued';
25
+ marked?: boolean;
26
+ }
27
+
28
+ const CalendarRowItem = ({
29
+ date,
30
+ onPress,
31
+ isCurrent,
32
+ isSelected,
33
+ textIntent = 'body',
34
+ marked = false,
35
+ }: CalendarRowItemProps) => (
36
+ <StyledCalendarRowItem testID="calendar-date-cell">
37
+ <StyledCalendarCell
38
+ variant={getCellVariant(isSelected, isCurrent)}
39
+ onPress={onPress}
40
+ >
41
+ <Typography.Text intent={isSelected ? 'inverted' : textIntent}>
42
+ {date ? date.getDate() : ''}
43
+ </Typography.Text>
44
+ {marked ? (
45
+ <StyledMark
46
+ testID="calendar-date-mark"
47
+ variant={isSelected ? 'inverted' : 'primary'}
48
+ />
49
+ ) : null}
50
+ </StyledCalendarCell>
51
+ </StyledCalendarRowItem>
52
+ );
53
+
54
+ export default CalendarRowItem;
@@ -0,0 +1,76 @@
1
+ import styled from '@emotion/native';
2
+ import { TouchableOpacity, View, ViewProps } from 'react-native';
3
+
4
+ const StyledContainer = styled(View)(({ theme }) => ({
5
+ backgroundColor: theme.__hd__.calendar.colors.background,
6
+ }));
7
+
8
+ const StyledCalendarHeader = styled(View)(({ theme }) => ({
9
+ flexDirection: 'row',
10
+ paddingHorizontal: theme.__hd__.calendar.space.headerHorizontalPadding,
11
+ paddingVertical: theme.__hd__.calendar.space.headerVerticalPadding,
12
+ }));
13
+
14
+ const StyledCalendarDayNameCell = styled(View)<ViewProps>(({ theme }) => ({
15
+ width: theme.__hd__.calendar.sizes.cellWidth,
16
+ height: theme.__hd__.calendar.sizes.cellHeight,
17
+ alignItems: 'center',
18
+ justifyContent: 'center',
19
+ }));
20
+
21
+ const StyledCalendarCell = styled(TouchableOpacity)<{
22
+ variant?: 'default' | 'current' | 'selected';
23
+ }>(({ theme, variant = 'default' }) => ({
24
+ borderColor: theme.__hd__.calendar.colors.border,
25
+ borderWidth: variant === 'current' ? 1 : 0,
26
+ borderRadius: theme.__hd__.calendar.radii.default,
27
+ alignItems: 'center',
28
+ justifyContent: 'center',
29
+ backgroundColor:
30
+ variant === 'selected' ? theme.__hd__.calendar.colors.primary : undefined,
31
+ width: theme.__hd__.calendar.sizes.cellCircleWidth,
32
+ height: theme.__hd__.calendar.sizes.cellCircleHeight,
33
+ }));
34
+
35
+ const StyledCalendarRow = styled(View)<ViewProps>(({ theme }) => ({
36
+ flexDirection: 'row',
37
+ paddingHorizontal: theme.__hd__.calendar.space.rowVerticalPadding,
38
+ flexWrap: 'wrap',
39
+ }));
40
+
41
+ const StyledCalendarRowItem = styled(View)<ViewProps>(({ theme }) => ({
42
+ flexBasis: `${Math.floor(100.0 / 7.0).toString()}%`,
43
+ alignItems: 'center',
44
+ width: theme.__hd__.calendar.sizes.cellWidth,
45
+ height: theme.__hd__.calendar.sizes.cellHeight,
46
+ justifyContent: 'center',
47
+ }));
48
+
49
+ const StyledDisabledCalendarRowItem = styled(View)<ViewProps>(({ theme }) => ({
50
+ flexBasis: `${Math.floor(100.0 / 7.0).toString()}%`,
51
+ alignItems: 'center',
52
+ width: theme.__hd__.calendar.sizes.cellWidth,
53
+ height: theme.__hd__.calendar.sizes.cellHeight,
54
+ }));
55
+
56
+ const StyledMark = styled(View)<{ variant: 'primary' | 'inverted' }>(
57
+ ({ theme, variant = 'primary' }) => ({
58
+ width: theme.__hd__.calendar.sizes.markWidth,
59
+ height: theme.__hd__.calendar.sizes.markHeight,
60
+ borderRadius: theme.__hd__.calendar.radii.default,
61
+ backgroundColor: theme.__hd__.calendar.colors[variant],
62
+ position: 'absolute',
63
+ bottom: '10%',
64
+ })
65
+ );
66
+
67
+ export {
68
+ StyledContainer,
69
+ StyledCalendarHeader,
70
+ StyledCalendarRow,
71
+ StyledCalendarRowItem,
72
+ StyledDisabledCalendarRowItem,
73
+ StyledCalendarDayNameCell,
74
+ StyledCalendarCell,
75
+ StyledMark,
76
+ };
@@ -0,0 +1,76 @@
1
+ import React from 'react';
2
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
3
+ import CalendarRowItem from '../CalendarRowItem';
4
+
5
+ describe('CalendarRowItem', () => {
6
+ it.each`
7
+ textIntent
8
+ ${'body'}
9
+ ${'subdued'}
10
+ `('renders correctly', ({ textIntent }) => {
11
+ const { toJSON } = renderWithTheme(
12
+ <CalendarRowItem
13
+ date={new Date(2022, 10, 10)}
14
+ onPress={jest.fn()}
15
+ textIntent={textIntent}
16
+ marked
17
+ />
18
+ );
19
+
20
+ expect(toJSON()).toMatchSnapshot();
21
+ });
22
+
23
+ it.each`
24
+ isCurrent
25
+ ${true}
26
+ ${false}
27
+ `(
28
+ 'renders correctly when selected, and is current date equal to $current',
29
+ ({ isCurrent }) => {
30
+ const { toJSON } = renderWithTheme(
31
+ <CalendarRowItem
32
+ date={new Date(2022, 10, 10)}
33
+ onPress={jest.fn()}
34
+ marked
35
+ isSelected
36
+ isCurrent={isCurrent}
37
+ />
38
+ );
39
+
40
+ expect(toJSON()).toMatchSnapshot();
41
+ }
42
+ );
43
+
44
+ it('renders correctly when is current date', () => {
45
+ const { toJSON } = renderWithTheme(
46
+ <CalendarRowItem
47
+ date={new Date(2022, 10, 10)}
48
+ onPress={jest.fn()}
49
+ marked
50
+ isSelected
51
+ />
52
+ );
53
+
54
+ expect(toJSON()).toMatchSnapshot();
55
+ });
56
+
57
+ it('renders mark when date is marked', () => {
58
+ const { queryByTestId } = renderWithTheme(
59
+ <CalendarRowItem
60
+ date={new Date(2022, 10, 10)}
61
+ onPress={jest.fn()}
62
+ marked
63
+ />
64
+ );
65
+
66
+ expect(queryByTestId('calendar-date-mark')).toBeTruthy();
67
+ });
68
+
69
+ it('not renders mark when date is not marked', () => {
70
+ const { queryByTestId } = renderWithTheme(
71
+ <CalendarRowItem date={new Date(2022, 10, 10)} onPress={jest.fn()} />
72
+ );
73
+
74
+ expect(queryByTestId('calendar-date-mark')).toBeNull();
75
+ });
76
+ });
@@ -0,0 +1,411 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`CalendarRowItem renders correctly 1`] = `
4
+ <View
5
+ style={
6
+ Array [
7
+ Object {
8
+ "alignItems": "center",
9
+ "flexBasis": "14%",
10
+ "height": 48,
11
+ "justifyContent": "center",
12
+ "width": 48,
13
+ },
14
+ undefined,
15
+ ]
16
+ }
17
+ testID="calendar-date-cell"
18
+ >
19
+ <View
20
+ accessible={true}
21
+ collapsable={false}
22
+ focusable={true}
23
+ nativeID="animatedComponent"
24
+ onClick={[Function]}
25
+ onResponderGrant={[Function]}
26
+ onResponderMove={[Function]}
27
+ onResponderRelease={[Function]}
28
+ onResponderTerminate={[Function]}
29
+ onResponderTerminationRequest={[Function]}
30
+ onStartShouldSetResponder={[Function]}
31
+ style={
32
+ Object {
33
+ "alignItems": "center",
34
+ "backgroundColor": undefined,
35
+ "borderColor": "#292a2b",
36
+ "borderRadius": 999,
37
+ "borderWidth": 0,
38
+ "height": 44,
39
+ "justifyContent": "center",
40
+ "opacity": 1,
41
+ "width": 44,
42
+ }
43
+ }
44
+ >
45
+ <Text
46
+ style={
47
+ Array [
48
+ Object {
49
+ "color": "#292a2b",
50
+ "fontFamily": "BeVietnamPro-Regular",
51
+ "fontSize": 14,
52
+ "letterSpacing": 0.42,
53
+ "lineHeight": 22,
54
+ },
55
+ undefined,
56
+ ]
57
+ }
58
+ themeFontSize="medium"
59
+ themeFontWeight="regular"
60
+ themeIntent="body"
61
+ >
62
+ 10
63
+ </Text>
64
+ <View
65
+ style={
66
+ Array [
67
+ Object {
68
+ "backgroundColor": "#7622d7",
69
+ "borderRadius": 999,
70
+ "bottom": "10%",
71
+ "height": 4,
72
+ "position": "absolute",
73
+ "width": 4,
74
+ },
75
+ undefined,
76
+ ]
77
+ }
78
+ testID="calendar-date-mark"
79
+ variant="primary"
80
+ />
81
+ </View>
82
+ </View>
83
+ `;
84
+
85
+ exports[`CalendarRowItem renders correctly 2`] = `
86
+ <View
87
+ style={
88
+ Array [
89
+ Object {
90
+ "alignItems": "center",
91
+ "flexBasis": "14%",
92
+ "height": 48,
93
+ "justifyContent": "center",
94
+ "width": 48,
95
+ },
96
+ undefined,
97
+ ]
98
+ }
99
+ testID="calendar-date-cell"
100
+ >
101
+ <View
102
+ accessible={true}
103
+ collapsable={false}
104
+ focusable={true}
105
+ nativeID="animatedComponent"
106
+ onClick={[Function]}
107
+ onResponderGrant={[Function]}
108
+ onResponderMove={[Function]}
109
+ onResponderRelease={[Function]}
110
+ onResponderTerminate={[Function]}
111
+ onResponderTerminationRequest={[Function]}
112
+ onStartShouldSetResponder={[Function]}
113
+ style={
114
+ Object {
115
+ "alignItems": "center",
116
+ "backgroundColor": undefined,
117
+ "borderColor": "#292a2b",
118
+ "borderRadius": 999,
119
+ "borderWidth": 0,
120
+ "height": 44,
121
+ "justifyContent": "center",
122
+ "opacity": 1,
123
+ "width": 44,
124
+ }
125
+ }
126
+ >
127
+ <Text
128
+ style={
129
+ Array [
130
+ Object {
131
+ "color": "#8b8d92",
132
+ "fontFamily": "BeVietnamPro-Regular",
133
+ "fontSize": 14,
134
+ "letterSpacing": 0.42,
135
+ "lineHeight": 22,
136
+ },
137
+ undefined,
138
+ ]
139
+ }
140
+ themeFontSize="medium"
141
+ themeFontWeight="regular"
142
+ themeIntent="subdued"
143
+ >
144
+ 10
145
+ </Text>
146
+ <View
147
+ style={
148
+ Array [
149
+ Object {
150
+ "backgroundColor": "#7622d7",
151
+ "borderRadius": 999,
152
+ "bottom": "10%",
153
+ "height": 4,
154
+ "position": "absolute",
155
+ "width": 4,
156
+ },
157
+ undefined,
158
+ ]
159
+ }
160
+ testID="calendar-date-mark"
161
+ variant="primary"
162
+ />
163
+ </View>
164
+ </View>
165
+ `;
166
+
167
+ exports[`CalendarRowItem renders correctly when is current date 1`] = `
168
+ <View
169
+ style={
170
+ Array [
171
+ Object {
172
+ "alignItems": "center",
173
+ "flexBasis": "14%",
174
+ "height": 48,
175
+ "justifyContent": "center",
176
+ "width": 48,
177
+ },
178
+ undefined,
179
+ ]
180
+ }
181
+ testID="calendar-date-cell"
182
+ >
183
+ <View
184
+ accessible={true}
185
+ collapsable={false}
186
+ focusable={true}
187
+ nativeID="animatedComponent"
188
+ onClick={[Function]}
189
+ onResponderGrant={[Function]}
190
+ onResponderMove={[Function]}
191
+ onResponderRelease={[Function]}
192
+ onResponderTerminate={[Function]}
193
+ onResponderTerminationRequest={[Function]}
194
+ onStartShouldSetResponder={[Function]}
195
+ style={
196
+ Object {
197
+ "alignItems": "center",
198
+ "backgroundColor": "#7622d7",
199
+ "borderColor": "#292a2b",
200
+ "borderRadius": 999,
201
+ "borderWidth": 0,
202
+ "height": 44,
203
+ "justifyContent": "center",
204
+ "opacity": 1,
205
+ "width": 44,
206
+ }
207
+ }
208
+ >
209
+ <Text
210
+ style={
211
+ Array [
212
+ Object {
213
+ "color": "#ffffff",
214
+ "fontFamily": "BeVietnamPro-Regular",
215
+ "fontSize": 14,
216
+ "letterSpacing": 0.42,
217
+ "lineHeight": 22,
218
+ },
219
+ undefined,
220
+ ]
221
+ }
222
+ themeFontSize="medium"
223
+ themeFontWeight="regular"
224
+ themeIntent="inverted"
225
+ >
226
+ 10
227
+ </Text>
228
+ <View
229
+ style={
230
+ Array [
231
+ Object {
232
+ "backgroundColor": "#ffffff",
233
+ "borderRadius": 999,
234
+ "bottom": "10%",
235
+ "height": 4,
236
+ "position": "absolute",
237
+ "width": 4,
238
+ },
239
+ undefined,
240
+ ]
241
+ }
242
+ testID="calendar-date-mark"
243
+ variant="inverted"
244
+ />
245
+ </View>
246
+ </View>
247
+ `;
248
+
249
+ exports[`CalendarRowItem renders correctly when selected, and is current date equal to $current 1`] = `
250
+ <View
251
+ style={
252
+ Array [
253
+ Object {
254
+ "alignItems": "center",
255
+ "flexBasis": "14%",
256
+ "height": 48,
257
+ "justifyContent": "center",
258
+ "width": 48,
259
+ },
260
+ undefined,
261
+ ]
262
+ }
263
+ testID="calendar-date-cell"
264
+ >
265
+ <View
266
+ accessible={true}
267
+ collapsable={false}
268
+ focusable={true}
269
+ nativeID="animatedComponent"
270
+ onClick={[Function]}
271
+ onResponderGrant={[Function]}
272
+ onResponderMove={[Function]}
273
+ onResponderRelease={[Function]}
274
+ onResponderTerminate={[Function]}
275
+ onResponderTerminationRequest={[Function]}
276
+ onStartShouldSetResponder={[Function]}
277
+ style={
278
+ Object {
279
+ "alignItems": "center",
280
+ "backgroundColor": "#7622d7",
281
+ "borderColor": "#292a2b",
282
+ "borderRadius": 999,
283
+ "borderWidth": 0,
284
+ "height": 44,
285
+ "justifyContent": "center",
286
+ "opacity": 1,
287
+ "width": 44,
288
+ }
289
+ }
290
+ >
291
+ <Text
292
+ style={
293
+ Array [
294
+ Object {
295
+ "color": "#ffffff",
296
+ "fontFamily": "BeVietnamPro-Regular",
297
+ "fontSize": 14,
298
+ "letterSpacing": 0.42,
299
+ "lineHeight": 22,
300
+ },
301
+ undefined,
302
+ ]
303
+ }
304
+ themeFontSize="medium"
305
+ themeFontWeight="regular"
306
+ themeIntent="inverted"
307
+ >
308
+ 10
309
+ </Text>
310
+ <View
311
+ style={
312
+ Array [
313
+ Object {
314
+ "backgroundColor": "#ffffff",
315
+ "borderRadius": 999,
316
+ "bottom": "10%",
317
+ "height": 4,
318
+ "position": "absolute",
319
+ "width": 4,
320
+ },
321
+ undefined,
322
+ ]
323
+ }
324
+ testID="calendar-date-mark"
325
+ variant="inverted"
326
+ />
327
+ </View>
328
+ </View>
329
+ `;
330
+
331
+ exports[`CalendarRowItem renders correctly when selected, and is current date equal to $current 2`] = `
332
+ <View
333
+ style={
334
+ Array [
335
+ Object {
336
+ "alignItems": "center",
337
+ "flexBasis": "14%",
338
+ "height": 48,
339
+ "justifyContent": "center",
340
+ "width": 48,
341
+ },
342
+ undefined,
343
+ ]
344
+ }
345
+ testID="calendar-date-cell"
346
+ >
347
+ <View
348
+ accessible={true}
349
+ collapsable={false}
350
+ focusable={true}
351
+ nativeID="animatedComponent"
352
+ onClick={[Function]}
353
+ onResponderGrant={[Function]}
354
+ onResponderMove={[Function]}
355
+ onResponderRelease={[Function]}
356
+ onResponderTerminate={[Function]}
357
+ onResponderTerminationRequest={[Function]}
358
+ onStartShouldSetResponder={[Function]}
359
+ style={
360
+ Object {
361
+ "alignItems": "center",
362
+ "backgroundColor": "#7622d7",
363
+ "borderColor": "#292a2b",
364
+ "borderRadius": 999,
365
+ "borderWidth": 0,
366
+ "height": 44,
367
+ "justifyContent": "center",
368
+ "opacity": 1,
369
+ "width": 44,
370
+ }
371
+ }
372
+ >
373
+ <Text
374
+ style={
375
+ Array [
376
+ Object {
377
+ "color": "#ffffff",
378
+ "fontFamily": "BeVietnamPro-Regular",
379
+ "fontSize": 14,
380
+ "letterSpacing": 0.42,
381
+ "lineHeight": 22,
382
+ },
383
+ undefined,
384
+ ]
385
+ }
386
+ themeFontSize="medium"
387
+ themeFontWeight="regular"
388
+ themeIntent="inverted"
389
+ >
390
+ 10
391
+ </Text>
392
+ <View
393
+ style={
394
+ Array [
395
+ Object {
396
+ "backgroundColor": "#ffffff",
397
+ "borderRadius": 999,
398
+ "bottom": "10%",
399
+ "height": 4,
400
+ "position": "absolute",
401
+ "width": 4,
402
+ },
403
+ undefined,
404
+ ]
405
+ }
406
+ testID="calendar-date-mark"
407
+ variant="inverted"
408
+ />
409
+ </View>
410
+ </View>
411
+ `;
@@ -0,0 +1,50 @@
1
+ import { getValidDate, initArray, isEqDate } from '../helpers';
2
+
3
+ describe('initArray', () => {
4
+ it('returns correct value', () => {
5
+ const transform = (index: number) => `test ${index + 1}`;
6
+ const actual = initArray(5, transform);
7
+ const expected = ['test 1', 'test 2', 'test 3', 'test 4', 'test 5'];
8
+
9
+ expect(actual).toEqual(expected);
10
+ });
11
+ });
12
+
13
+ describe('isEqDate', () => {
14
+ it.each`
15
+ dateA | dateB | expected
16
+ ${undefined} | ${undefined} | ${true}
17
+ ${new Date(2022, 10, 10)} | ${undefined} | ${false}
18
+ ${undefined} | ${new Date(2022, 10, 10)} | ${false}
19
+ ${new Date(2022, 10, 11)} | ${new Date(2022, 10, 10)} | ${false}
20
+ ${new Date(2022, 10, 10)} | ${new Date(2022, 10, 10)} | ${true}
21
+ ${new Date(2022, 10, 10, 5, 12, 3)} | ${new Date(2022, 10, 10, 6, 12, 4)} | ${true}
22
+ `(
23
+ 'returns correct when dateA is $dateA and dateB is $dateB',
24
+ ({ dateA, dateB, expected }) => {
25
+ const actual = isEqDate(dateA, dateB);
26
+ expect(actual).toEqual(expected);
27
+ }
28
+ );
29
+ });
30
+
31
+ describe('getValidDate', () => {
32
+ const date = new Date(2022, 10, 10);
33
+ it.each`
34
+ minDate | maxDate | expected
35
+ ${undefined} | ${undefined} | ${date}
36
+ ${new Date(2022, 10, 8)} | ${undefined} | ${date}
37
+ ${new Date(2022, 10, 15)} | ${undefined} | ${undefined}
38
+ ${undefined} | ${new Date(2022, 10, 11)} | ${date}
39
+ ${undefined} | ${new Date(2022, 10, 8)} | ${undefined}
40
+ ${new Date(2022, 10, 8)} | ${new Date(2022, 10, 11)} | ${date}
41
+ ${new Date(2022, 10, 12)} | ${new Date(2022, 10, 11)} | ${undefined}
42
+ ${new Date(2022, 10, 8)} | ${new Date(2022, 10, 9)} | ${undefined}
43
+ `(
44
+ 'returns correct value when minDate is $minDate and maxDate is $maxDate',
45
+ ({ minDate, maxDate, expected }) => {
46
+ const actual = getValidDate(date, minDate, maxDate);
47
+ expect(actual).toBe(expected);
48
+ }
49
+ );
50
+ });