@hero-design/rn 7.13.0 → 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 (155) 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 +26957 -7622
  6. package/lib/assets/fonts/hero-icons.ttf +0 -0
  7. package/lib/index.js +26963 -7624
  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/IconButton.tsx +1 -1
  21. package/src/components/Calendar/CalendarRowItem.tsx +54 -0
  22. package/src/components/Calendar/StyledCalendar.tsx +76 -0
  23. package/src/components/Calendar/__tests__/CalendarRowItem.spec.tsx +76 -0
  24. package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +411 -0
  25. package/src/components/Calendar/__tests__/helper.spec.ts +50 -0
  26. package/src/components/Calendar/__tests__/index.spec.tsx +99 -0
  27. package/src/components/Calendar/helpers.ts +29 -0
  28. package/src/components/Calendar/index.tsx +217 -0
  29. package/src/components/Collapse/index.tsx +13 -15
  30. package/src/components/ContentNavigator/index.tsx +6 -0
  31. package/src/components/Empty/StyledEmpty.tsx +47 -0
  32. package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +66 -0
  33. package/src/components/Empty/__tests__/index.spec.tsx +17 -0
  34. package/src/components/Empty/index.tsx +53 -0
  35. package/src/components/FAB/ActionGroup/ActionItem.tsx +6 -2
  36. package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +1 -0
  37. package/src/components/FAB/ActionGroup/StyledActionItem.tsx +7 -1
  38. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +84 -22
  39. package/src/components/FAB/ActionGroup/index.tsx +8 -1
  40. package/src/components/Icon/HeroIcon/selection.json +1 -1
  41. package/src/components/Icon/IconList.ts +13 -0
  42. package/src/components/List/BasicListItem.tsx +44 -34
  43. package/src/components/List/ListItem.tsx +67 -58
  44. package/src/components/List/StyledBasicListItem.tsx +2 -3
  45. package/src/components/List/StyledListItem.tsx +2 -2
  46. package/src/components/List/__tests__/StyledBasicListItem.spec.tsx +5 -2
  47. package/src/components/List/__tests__/StyledListItem.spec.tsx +4 -1
  48. package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +15 -10
  49. package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +52 -32
  50. package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +128 -48
  51. package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +132 -52
  52. package/src/components/RichTextEditor/EditorEvent.ts +7 -0
  53. package/src/components/RichTextEditor/EditorToolbar.tsx +220 -0
  54. package/src/components/RichTextEditor/MentionList.tsx +69 -0
  55. package/src/components/RichTextEditor/RichTextEditor.tsx +396 -0
  56. package/src/components/RichTextEditor/StyledRichTextEditor.ts +20 -0
  57. package/src/components/RichTextEditor/StyledToolbar.ts +32 -0
  58. package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +130 -0
  59. package/src/components/RichTextEditor/__tests__/MentionList.spec.tsx +109 -0
  60. package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +245 -0
  61. package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +324 -0
  62. package/src/components/RichTextEditor/__tests__/__snapshots__/MentionList.spec.tsx.snap +45 -0
  63. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +526 -0
  64. package/src/components/RichTextEditor/constants.ts +20 -0
  65. package/src/components/RichTextEditor/hero-editor.d.ts +8 -0
  66. package/src/components/RichTextEditor/index.tsx +8 -0
  67. package/src/components/RichTextEditor/utils/events.ts +31 -0
  68. package/src/components/RichTextEditor/utils/rnWebView.ts +19 -0
  69. package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +77 -0
  70. package/src/components/SectionHeading/__tests__/index.spec.tsx +14 -0
  71. package/src/components/SectionHeading/index.tsx +16 -9
  72. package/src/components/Tag/StyledTag.tsx +12 -2
  73. package/src/components/Tag/__tests__/Tag.spec.tsx +35 -8
  74. package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +118 -4
  75. package/src/components/Tag/index.tsx +9 -2
  76. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +1 -0
  77. package/src/components/Typography/Text/StyledText.tsx +2 -1
  78. package/src/components/Typography/Text/__tests__/StyledText.spec.tsx +1 -0
  79. package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +22 -0
  80. package/src/components/Typography/Text/index.tsx +2 -1
  81. package/src/index.ts +8 -0
  82. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +101 -4
  83. package/src/theme/components/accordion.ts +19 -0
  84. package/src/theme/components/calendar.ts +34 -0
  85. package/src/theme/components/card.ts +1 -1
  86. package/src/theme/components/empty.ts +38 -0
  87. package/src/theme/components/fab.ts +4 -3
  88. package/src/theme/components/list.ts +1 -0
  89. package/src/theme/components/pinInput.ts +1 -1
  90. package/src/theme/components/richTextEditor.ts +34 -0
  91. package/src/theme/components/tag.ts +8 -2
  92. package/src/theme/components/typography.ts +1 -0
  93. package/src/theme/global/borders.ts +6 -6
  94. package/src/theme/global/colors.ts +4 -1
  95. package/src/theme/index.ts +12 -0
  96. package/testUtils/setup.tsx +17 -0
  97. package/types/components/Accordion/AccordionItem.d.ts +14 -0
  98. package/types/components/Accordion/StyledAccordion.d.ts +32 -0
  99. package/types/components/Accordion/__tests__/AccordionItem.spec.d.ts +1 -0
  100. package/types/components/Accordion/__tests__/StyledAccordion.spec.d.ts +1 -0
  101. package/types/components/Accordion/__tests__/index.spec.d.ts +1 -0
  102. package/types/components/Accordion/index.d.ts +38 -0
  103. package/types/components/Accordion/utils.d.ts +1 -0
  104. package/types/components/Button/IconButton.d.ts +1 -1
  105. package/types/components/Calendar/CalendarRowItem.d.ts +10 -0
  106. package/types/components/Calendar/StyledCalendar.d.ts +54 -0
  107. package/types/components/Calendar/__tests__/CalendarRowItem.spec.d.ts +1 -0
  108. package/types/components/Calendar/__tests__/helper.spec.d.ts +1 -0
  109. package/types/components/Calendar/__tests__/index.spec.d.ts +1 -0
  110. package/types/components/Calendar/helpers.d.ts +3 -0
  111. package/types/components/Calendar/index.d.ts +40 -0
  112. package/types/components/Collapse/index.d.ts +1 -1
  113. package/types/components/ContentNavigator/index.d.ts +5 -1
  114. package/types/components/Empty/StyledEmpty.d.ts +31 -0
  115. package/types/components/Empty/__tests__/index.spec.d.ts +1 -0
  116. package/types/components/Empty/index.d.ts +26 -0
  117. package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +6 -1
  118. package/types/components/FAB/ActionGroup/index.d.ts +6 -1
  119. package/types/components/FAB/index.d.ts +1 -1
  120. package/types/components/Icon/IconList.d.ts +1 -1
  121. package/types/components/Icon/utils.d.ts +1 -1
  122. package/types/components/List/StyledBasicListItem.d.ts +3 -3
  123. package/types/components/List/StyledListItem.d.ts +3 -3
  124. package/types/components/RichTextEditor/EditorEvent.d.ts +3 -0
  125. package/types/components/RichTextEditor/EditorToolbar.d.ts +17 -0
  126. package/types/components/RichTextEditor/MentionList.d.ts +12 -0
  127. package/types/components/RichTextEditor/RichTextEditor.d.ts +65 -0
  128. package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +16 -0
  129. package/types/components/RichTextEditor/StyledToolbar.d.ts +21 -0
  130. package/types/components/RichTextEditor/__tests__/EditorToolbar.spec.d.ts +1 -0
  131. package/types/components/RichTextEditor/__tests__/MentionList.spec.d.ts +1 -0
  132. package/types/components/RichTextEditor/__tests__/RichTextEditor.spec.d.ts +1 -0
  133. package/types/components/RichTextEditor/constants.d.ts +19 -0
  134. package/types/components/RichTextEditor/index.d.ts +5 -0
  135. package/types/components/RichTextEditor/utils/events.d.ts +8 -0
  136. package/types/components/RichTextEditor/utils/rnWebView.d.ts +7 -0
  137. package/types/components/SectionHeading/index.d.ts +2 -2
  138. package/types/components/Select/MultiSelect/OptionList.d.ts +1 -1
  139. package/types/components/Select/SingleSelect/OptionList.d.ts +1 -1
  140. package/types/components/Tag/StyledTag.d.ts +1 -1
  141. package/types/components/Tag/index.d.ts +1 -1
  142. package/types/components/Typography/Text/StyledText.d.ts +1 -1
  143. package/types/components/Typography/Text/index.d.ts +1 -1
  144. package/types/index.d.ts +5 -1
  145. package/types/theme/components/accordion.d.ts +13 -0
  146. package/types/theme/components/calendar.d.ts +26 -0
  147. package/types/theme/components/empty.d.ts +28 -0
  148. package/types/theme/components/fab.d.ts +1 -0
  149. package/types/theme/components/list.d.ts +1 -0
  150. package/types/theme/components/richTextEditor.d.ts +26 -0
  151. package/types/theme/components/tag.d.ts +8 -2
  152. package/types/theme/components/typography.d.ts +1 -0
  153. package/types/theme/global/colors.d.ts +4 -1
  154. package/types/theme/global/index.d.ts +4 -1
  155. package/types/theme/index.d.ts +8 -0
@@ -1,11 +1,9 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`ListItemContainer renders correctly themeSelected false themeDisabled false 1`] = `
3
+ exports[`StyledListItemContainer renders correctly themeSelected false themeDisabled false 1`] = `
4
4
  <View
5
5
  accessible={true}
6
- collapsable={false}
7
6
  focusable={false}
8
- nativeID="animatedComponent"
9
7
  onClick={[Function]}
10
8
  onResponderGrant={[Function]}
11
9
  onResponderMove={[Function]}
@@ -14,24 +12,44 @@ exports[`ListItemContainer renders correctly themeSelected false themeDisabled f
14
12
  onResponderTerminationRequest={[Function]}
15
13
  onStartShouldSetResponder={[Function]}
16
14
  style={
17
- Object {
18
- "alignItems": "center",
19
- "backgroundColor": "#ffffff",
20
- "flex": 1,
21
- "flexDirection": "row",
22
- "opacity": 1,
23
- "padding": 16,
24
- }
15
+ Array [
16
+ Object {
17
+ "alignItems": "center",
18
+ "backgroundColor": "#ffffff",
19
+ "flexDirection": "row",
20
+ "opacity": 1,
21
+ "padding": 16,
22
+ },
23
+ undefined,
24
+ ]
25
25
  }
26
- />
26
+ >
27
+ <Text
28
+ style={
29
+ Array [
30
+ Object {
31
+ "color": "#292a2b",
32
+ "fontFamily": "BeVietnamPro-Regular",
33
+ "fontSize": 14,
34
+ "letterSpacing": 0.42,
35
+ "lineHeight": 22,
36
+ },
37
+ undefined,
38
+ ]
39
+ }
40
+ themeFontSize="medium"
41
+ themeFontWeight="regular"
42
+ themeIntent="body"
43
+ >
44
+ StyledListItemContainer
45
+ </Text>
46
+ </View>
27
47
  `;
28
48
 
29
- exports[`ListItemContainer renders correctly themeSelected false themeDisabled true 1`] = `
49
+ exports[`StyledListItemContainer renders correctly themeSelected false themeDisabled true 1`] = `
30
50
  <View
31
51
  accessible={true}
32
- collapsable={false}
33
52
  focusable={false}
34
- nativeID="animatedComponent"
35
53
  onClick={[Function]}
36
54
  onResponderGrant={[Function]}
37
55
  onResponderMove={[Function]}
@@ -40,24 +58,44 @@ exports[`ListItemContainer renders correctly themeSelected false themeDisabled t
40
58
  onResponderTerminationRequest={[Function]}
41
59
  onStartShouldSetResponder={[Function]}
42
60
  style={
43
- Object {
44
- "alignItems": "center",
45
- "backgroundColor": "#ffffff",
46
- "flex": 1,
47
- "flexDirection": "row",
48
- "opacity": 0.38,
49
- "padding": 16,
50
- }
61
+ Array [
62
+ Object {
63
+ "alignItems": "center",
64
+ "backgroundColor": "#ffffff",
65
+ "flexDirection": "row",
66
+ "opacity": 0.38,
67
+ "padding": 16,
68
+ },
69
+ undefined,
70
+ ]
51
71
  }
52
- />
72
+ >
73
+ <Text
74
+ style={
75
+ Array [
76
+ Object {
77
+ "color": "#292a2b",
78
+ "fontFamily": "BeVietnamPro-Regular",
79
+ "fontSize": 14,
80
+ "letterSpacing": 0.42,
81
+ "lineHeight": 22,
82
+ },
83
+ undefined,
84
+ ]
85
+ }
86
+ themeFontSize="medium"
87
+ themeFontWeight="regular"
88
+ themeIntent="body"
89
+ >
90
+ StyledListItemContainer
91
+ </Text>
92
+ </View>
53
93
  `;
54
94
 
55
- exports[`ListItemContainer renders correctly themeSelected true themeDisabled false 1`] = `
95
+ exports[`StyledListItemContainer renders correctly themeSelected true themeDisabled false 1`] = `
56
96
  <View
57
97
  accessible={true}
58
- collapsable={false}
59
98
  focusable={false}
60
- nativeID="animatedComponent"
61
99
  onClick={[Function]}
62
100
  onResponderGrant={[Function]}
63
101
  onResponderMove={[Function]}
@@ -66,24 +104,44 @@ exports[`ListItemContainer renders correctly themeSelected true themeDisabled fa
66
104
  onResponderTerminationRequest={[Function]}
67
105
  onStartShouldSetResponder={[Function]}
68
106
  style={
69
- Object {
70
- "alignItems": "center",
71
- "backgroundColor": "#f1e9fb",
72
- "flex": 1,
73
- "flexDirection": "row",
74
- "opacity": 1,
75
- "padding": 16,
76
- }
107
+ Array [
108
+ Object {
109
+ "alignItems": "center",
110
+ "backgroundColor": "#f1e9fb",
111
+ "flexDirection": "row",
112
+ "opacity": 1,
113
+ "padding": 16,
114
+ },
115
+ undefined,
116
+ ]
77
117
  }
78
- />
118
+ >
119
+ <Text
120
+ style={
121
+ Array [
122
+ Object {
123
+ "color": "#292a2b",
124
+ "fontFamily": "BeVietnamPro-Regular",
125
+ "fontSize": 14,
126
+ "letterSpacing": 0.42,
127
+ "lineHeight": 22,
128
+ },
129
+ undefined,
130
+ ]
131
+ }
132
+ themeFontSize="medium"
133
+ themeFontWeight="regular"
134
+ themeIntent="body"
135
+ >
136
+ StyledListItemContainer
137
+ </Text>
138
+ </View>
79
139
  `;
80
140
 
81
- exports[`ListItemContainer renders correctly themeSelected true themeDisabled true 1`] = `
141
+ exports[`StyledListItemContainer renders correctly themeSelected true themeDisabled true 1`] = `
82
142
  <View
83
143
  accessible={true}
84
- collapsable={false}
85
144
  focusable={false}
86
- nativeID="animatedComponent"
87
145
  onClick={[Function]}
88
146
  onResponderGrant={[Function]}
89
147
  onResponderMove={[Function]}
@@ -92,14 +150,36 @@ exports[`ListItemContainer renders correctly themeSelected true themeDisabled tr
92
150
  onResponderTerminationRequest={[Function]}
93
151
  onStartShouldSetResponder={[Function]}
94
152
  style={
95
- Object {
96
- "alignItems": "center",
97
- "backgroundColor": "#f1e9fb",
98
- "flex": 1,
99
- "flexDirection": "row",
100
- "opacity": 0.38,
101
- "padding": 16,
102
- }
153
+ Array [
154
+ Object {
155
+ "alignItems": "center",
156
+ "backgroundColor": "#f1e9fb",
157
+ "flexDirection": "row",
158
+ "opacity": 0.38,
159
+ "padding": 16,
160
+ },
161
+ undefined,
162
+ ]
103
163
  }
104
- />
164
+ >
165
+ <Text
166
+ style={
167
+ Array [
168
+ Object {
169
+ "color": "#292a2b",
170
+ "fontFamily": "BeVietnamPro-Regular",
171
+ "fontSize": 14,
172
+ "letterSpacing": 0.42,
173
+ "lineHeight": 22,
174
+ },
175
+ undefined,
176
+ ]
177
+ }
178
+ themeFontSize="medium"
179
+ themeFontWeight="regular"
180
+ themeIntent="body"
181
+ >
182
+ StyledListItemContainer
183
+ </Text>
184
+ </View>
105
185
  `;
@@ -88,9 +88,7 @@ exports[`LeadingStatus renders correctly themeLeadingStausIntent warning 1`] = `
88
88
  exports[`ListItemContainer renders correctly themeSelected false themeVariant card 1`] = `
89
89
  <View
90
90
  accessible={true}
91
- collapsable={false}
92
91
  focusable={false}
93
- nativeID="animatedComponent"
94
92
  onClick={[Function]}
95
93
  onResponderGrant={[Function]}
96
94
  onResponderMove={[Function]}
@@ -99,31 +97,51 @@ exports[`ListItemContainer renders correctly themeSelected false themeVariant ca
99
97
  onResponderTerminationRequest={[Function]}
100
98
  onStartShouldSetResponder={[Function]}
101
99
  style={
102
- Object {
103
- "alignItems": "center",
104
- "backgroundColor": "#ffffff",
105
- "borderRadius": 8,
106
- "flexDirection": "row",
107
- "opacity": 1,
108
- "padding": 16,
109
- "shadowColor": "#dadbde",
110
- "shadowOffset": Object {
111
- "height": 2,
112
- "width": 0,
100
+ Array [
101
+ Object {
102
+ "alignItems": "center",
103
+ "backgroundColor": "#ffffff",
104
+ "borderRadius": 8,
105
+ "flexDirection": "row",
106
+ "padding": 16,
107
+ "shadowColor": "#dadbde",
108
+ "shadowOffset": Object {
109
+ "height": 2,
110
+ "width": 0,
111
+ },
112
+ "shadowOpacity": 1,
113
+ "shadowRadius": 4,
113
114
  },
114
- "shadowOpacity": 1,
115
- "shadowRadius": 4,
116
- }
115
+ undefined,
116
+ ]
117
117
  }
118
- />
118
+ >
119
+ <Text
120
+ style={
121
+ Array [
122
+ Object {
123
+ "color": "#292a2b",
124
+ "fontFamily": "BeVietnamPro-Regular",
125
+ "fontSize": 14,
126
+ "letterSpacing": 0.42,
127
+ "lineHeight": 22,
128
+ },
129
+ undefined,
130
+ ]
131
+ }
132
+ themeFontSize="medium"
133
+ themeFontWeight="regular"
134
+ themeIntent="body"
135
+ >
136
+ StyledListItemContainer
137
+ </Text>
138
+ </View>
119
139
  `;
120
140
 
121
141
  exports[`ListItemContainer renders correctly themeSelected false themeVariant full-width 1`] = `
122
142
  <View
123
143
  accessible={true}
124
- collapsable={false}
125
144
  focusable={false}
126
- nativeID="animatedComponent"
127
145
  onClick={[Function]}
128
146
  onResponderGrant={[Function]}
129
147
  onResponderMove={[Function]}
@@ -132,22 +150,42 @@ exports[`ListItemContainer renders correctly themeSelected false themeVariant fu
132
150
  onResponderTerminationRequest={[Function]}
133
151
  onStartShouldSetResponder={[Function]}
134
152
  style={
135
- Object {
136
- "backgroundColor": "#ffffff",
137
- "flexDirection": "row",
138
- "opacity": 1,
139
- "padding": 16,
140
- }
153
+ Array [
154
+ Object {
155
+ "backgroundColor": "#ffffff",
156
+ "flexDirection": "row",
157
+ "padding": 16,
158
+ },
159
+ undefined,
160
+ ]
141
161
  }
142
- />
162
+ >
163
+ <Text
164
+ style={
165
+ Array [
166
+ Object {
167
+ "color": "#292a2b",
168
+ "fontFamily": "BeVietnamPro-Regular",
169
+ "fontSize": 14,
170
+ "letterSpacing": 0.42,
171
+ "lineHeight": 22,
172
+ },
173
+ undefined,
174
+ ]
175
+ }
176
+ themeFontSize="medium"
177
+ themeFontWeight="regular"
178
+ themeIntent="body"
179
+ >
180
+ StyledListItemContainer
181
+ </Text>
182
+ </View>
143
183
  `;
144
184
 
145
185
  exports[`ListItemContainer renders correctly themeSelected true themeVariant card 1`] = `
146
186
  <View
147
187
  accessible={true}
148
- collapsable={false}
149
188
  focusable={false}
150
- nativeID="animatedComponent"
151
189
  onClick={[Function]}
152
190
  onResponderGrant={[Function]}
153
191
  onResponderMove={[Function]}
@@ -156,31 +194,51 @@ exports[`ListItemContainer renders correctly themeSelected true themeVariant car
156
194
  onResponderTerminationRequest={[Function]}
157
195
  onStartShouldSetResponder={[Function]}
158
196
  style={
159
- Object {
160
- "alignItems": "center",
161
- "backgroundColor": "#f1e9fb",
162
- "borderRadius": 8,
163
- "flexDirection": "row",
164
- "opacity": 1,
165
- "padding": 16,
166
- "shadowColor": "#dadbde",
167
- "shadowOffset": Object {
168
- "height": 2,
169
- "width": 0,
197
+ Array [
198
+ Object {
199
+ "alignItems": "center",
200
+ "backgroundColor": "#f1e9fb",
201
+ "borderRadius": 8,
202
+ "flexDirection": "row",
203
+ "padding": 16,
204
+ "shadowColor": "#dadbde",
205
+ "shadowOffset": Object {
206
+ "height": 2,
207
+ "width": 0,
208
+ },
209
+ "shadowOpacity": 1,
210
+ "shadowRadius": 4,
170
211
  },
171
- "shadowOpacity": 1,
172
- "shadowRadius": 4,
173
- }
212
+ undefined,
213
+ ]
174
214
  }
175
- />
215
+ >
216
+ <Text
217
+ style={
218
+ Array [
219
+ Object {
220
+ "color": "#292a2b",
221
+ "fontFamily": "BeVietnamPro-Regular",
222
+ "fontSize": 14,
223
+ "letterSpacing": 0.42,
224
+ "lineHeight": 22,
225
+ },
226
+ undefined,
227
+ ]
228
+ }
229
+ themeFontSize="medium"
230
+ themeFontWeight="regular"
231
+ themeIntent="body"
232
+ >
233
+ StyledListItemContainer
234
+ </Text>
235
+ </View>
176
236
  `;
177
237
 
178
238
  exports[`ListItemContainer renders correctly themeSelected true themeVariant full-width 1`] = `
179
239
  <View
180
240
  accessible={true}
181
- collapsable={false}
182
241
  focusable={false}
183
- nativeID="animatedComponent"
184
242
  onClick={[Function]}
185
243
  onResponderGrant={[Function]}
186
244
  onResponderMove={[Function]}
@@ -189,12 +247,34 @@ exports[`ListItemContainer renders correctly themeSelected true themeVariant ful
189
247
  onResponderTerminationRequest={[Function]}
190
248
  onStartShouldSetResponder={[Function]}
191
249
  style={
192
- Object {
193
- "backgroundColor": "#f1e9fb",
194
- "flexDirection": "row",
195
- "opacity": 1,
196
- "padding": 16,
197
- }
250
+ Array [
251
+ Object {
252
+ "backgroundColor": "#f1e9fb",
253
+ "flexDirection": "row",
254
+ "padding": 16,
255
+ },
256
+ undefined,
257
+ ]
198
258
  }
199
- />
259
+ >
260
+ <Text
261
+ style={
262
+ Array [
263
+ Object {
264
+ "color": "#292a2b",
265
+ "fontFamily": "BeVietnamPro-Regular",
266
+ "fontSize": 14,
267
+ "letterSpacing": 0.42,
268
+ "lineHeight": 22,
269
+ },
270
+ undefined,
271
+ ]
272
+ }
273
+ themeFontSize="medium"
274
+ themeFontWeight="regular"
275
+ themeIntent="body"
276
+ >
277
+ StyledListItemContainer
278
+ </Text>
279
+ </View>
200
280
  `;
@@ -0,0 +1,7 @@
1
+ import { EventEmitter } from 'events';
2
+
3
+ const emitter = new EventEmitter();
4
+
5
+ emitter.setMaxListeners(20);
6
+
7
+ export { emitter };
@@ -0,0 +1,220 @@
1
+ import React, {
2
+ ComponentType,
3
+ useCallback,
4
+ useEffect,
5
+ useMemo,
6
+ useState,
7
+ } from 'react';
8
+ import Icon, { IconProps } from '../Icon';
9
+ import { ToolbarButtonName, ToolbarEvents } from './constants';
10
+ import { emitter } from './EditorEvent';
11
+ import {
12
+ StyledSeparator,
13
+ StyledToolbar,
14
+ StyledToolbarButton,
15
+ } from './StyledToolbar';
16
+ import * as Events from './utils/events';
17
+
18
+ type ToolbarButtonProps = {
19
+ icon: IconProps['icon'];
20
+ onPress: () => void;
21
+ testID?: string;
22
+ selected: boolean;
23
+ };
24
+ const ToolbarButton: ComponentType<ToolbarButtonProps> = ({
25
+ icon,
26
+ onPress,
27
+ testID,
28
+ selected,
29
+ }: ToolbarButtonProps) => (
30
+ <StyledToolbarButton selected={selected} onPress={onPress} testID={testID}>
31
+ <Icon size="small" icon={icon} />
32
+ </StyledToolbarButton>
33
+ );
34
+
35
+ interface ButtonConfig {
36
+ icon: IconProps['icon'];
37
+ eventName: ToolbarEvents;
38
+ standalone?: boolean;
39
+ }
40
+
41
+ const buttonConfigs: Partial<Record<ToolbarButtonName, ButtonConfig>> = {
42
+ [ToolbarButtonName.Bold]: {
43
+ icon: 'format-bold',
44
+ eventName: ToolbarEvents.Bold,
45
+ },
46
+ [ToolbarButtonName.Italic]: {
47
+ icon: 'format-italic',
48
+ eventName: ToolbarEvents.Italic,
49
+ },
50
+ [ToolbarButtonName.Underline]: {
51
+ icon: 'format-underlined',
52
+ eventName: ToolbarEvents.Underline,
53
+ },
54
+ [ToolbarButtonName.BulletedList]: {
55
+ icon: 'format-list-bulleted',
56
+ eventName: ToolbarEvents.BulletedList,
57
+ standalone: true,
58
+ },
59
+ [ToolbarButtonName.NumberedList]: {
60
+ icon: 'format-list-numbered',
61
+ eventName: ToolbarEvents.NumberedList,
62
+ standalone: true,
63
+ },
64
+ [ToolbarButtonName.HeadingOne]: {
65
+ icon: 'format-heading1',
66
+ eventName: ToolbarEvents.HeadingOne,
67
+ standalone: true,
68
+ },
69
+ [ToolbarButtonName.HeadingTwo]: {
70
+ icon: 'format-heading2',
71
+ eventName: ToolbarEvents.HeadingTwo,
72
+ standalone: true,
73
+ },
74
+ };
75
+
76
+ const defaultButtons: ToolbarButtonName[] = [
77
+ ToolbarButtonName.Bold,
78
+ ToolbarButtonName.Italic,
79
+ ToolbarButtonName.Underline,
80
+ ToolbarButtonName.Seperator,
81
+ ToolbarButtonName.BulletedList,
82
+ ToolbarButtonName.NumberedList,
83
+ ToolbarButtonName.Seperator,
84
+ ToolbarButtonName.HeadingOne,
85
+ ToolbarButtonName.HeadingTwo,
86
+ ];
87
+
88
+ export interface EditorToolbarProps {
89
+ /**
90
+ * List of buttons to display in toolbar
91
+ */
92
+ buttons?: ToolbarButtonName[];
93
+ /**
94
+ * Unique name used to communicate with webview, should be the same with the RichTextEditor component it used with
95
+ */
96
+ name: string;
97
+ /**
98
+ * Testing ID of the component
99
+ */
100
+ testID?: string;
101
+ }
102
+
103
+ type ButtonType = {
104
+ id: number;
105
+ buttonName: ToolbarButtonName;
106
+ selected: boolean;
107
+ };
108
+
109
+ const EditorToolbar = ({
110
+ name,
111
+ buttons = defaultButtons,
112
+ testID,
113
+ }: EditorToolbarProps) => {
114
+ const [show, setShow] = useState(false);
115
+
116
+ const initialToolbarButtonArray: ButtonType[] = buttons.map(
117
+ (button, index) => ({
118
+ id: index + 1,
119
+ buttonName: button,
120
+ selected: false,
121
+ })
122
+ );
123
+
124
+ const [toolbarButtonArray, setToolbarButtonArray] = useState<ButtonType[]>(
125
+ initialToolbarButtonArray
126
+ );
127
+
128
+ const normalizeEventName = useCallback(
129
+ (event: string): string => `${name}/${event}`,
130
+ [name]
131
+ );
132
+
133
+ useEffect(() => {
134
+ const removeFocusListener = Events.on(
135
+ emitter,
136
+ normalizeEventName('editor-focus'),
137
+ () => setShow(true)
138
+ );
139
+
140
+ const removeBlurListener = Events.on(
141
+ emitter,
142
+ normalizeEventName('editor-blur'),
143
+ () => setShow(false)
144
+ );
145
+
146
+ return () => {
147
+ removeFocusListener();
148
+ removeBlurListener();
149
+ };
150
+ }, []);
151
+
152
+ const toggleToolbarButton = useCallback(
153
+ ({ buttonName: currentButtonName, selected: prevSelected }: ButtonType) => {
154
+ const currentButtonConfig = buttonConfigs[currentButtonName];
155
+ const isStandalone =
156
+ currentButtonConfig && currentButtonConfig.standalone;
157
+
158
+ setToolbarButtonArray(prevState =>
159
+ prevState.map(updatingButton => {
160
+ if (updatingButton.buttonName === currentButtonName) {
161
+ return {
162
+ ...updatingButton,
163
+ selected: !prevSelected,
164
+ };
165
+ }
166
+
167
+ const updatingButtonConfig = buttonConfigs[updatingButton.buttonName];
168
+ const shouldToggleOff =
169
+ !prevSelected &&
170
+ isStandalone &&
171
+ updatingButtonConfig &&
172
+ updatingButtonConfig.standalone;
173
+
174
+ return {
175
+ ...updatingButton,
176
+ selected: shouldToggleOff ? false : updatingButton.selected,
177
+ };
178
+ })
179
+ );
180
+ },
181
+ []
182
+ );
183
+
184
+ const toolbarButtons = useMemo(
185
+ () =>
186
+ toolbarButtonArray.map(button => {
187
+ if (button.buttonName === ToolbarButtonName.Seperator) {
188
+ return <StyledSeparator key={button.id} />;
189
+ }
190
+ const config = buttonConfigs[button.buttonName];
191
+ if (config) {
192
+ return (
193
+ <ToolbarButton
194
+ key={button.id}
195
+ testID={config.icon}
196
+ icon={config.icon}
197
+ onPress={() => {
198
+ toggleToolbarButton(button);
199
+ Events.emit(
200
+ emitter,
201
+ normalizeEventName(config.eventName),
202
+ null
203
+ );
204
+ }}
205
+ selected={button.selected}
206
+ />
207
+ );
208
+ }
209
+ return null;
210
+ }),
211
+ [toolbarButtonArray]
212
+ );
213
+
214
+ if (show) {
215
+ return <StyledToolbar testID={testID}>{toolbarButtons}</StyledToolbar>;
216
+ }
217
+ return null;
218
+ };
219
+
220
+ export default EditorToolbar;