@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.
- package/.eslintrc.json +3 -1
- package/.turbo/turbo-build.log +3 -2
- package/assets/fonts/hero-icons.ttf +0 -0
- package/babel.config.js +16 -0
- package/es/index.js +35840 -16325
- package/lib/assets/fonts/hero-icons.ttf +0 -0
- package/lib/index.js +35847 -16327
- package/package.json +9 -4
- package/rollup.config.js +1 -0
- package/src/components/Accordion/AccordionItem.tsx +50 -0
- package/src/components/Accordion/StyledAccordion.tsx +29 -0
- package/src/components/Accordion/__tests__/AccordionItem.spec.tsx +56 -0
- package/src/components/Accordion/__tests__/StyledAccordion.spec.tsx +17 -0
- package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +529 -0
- package/src/components/Accordion/__tests__/__snapshots__/StyledAccordion.spec.tsx.snap +33 -0
- package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +822 -0
- package/src/components/Accordion/__tests__/index.spec.tsx +54 -0
- package/src/components/Accordion/index.tsx +82 -0
- package/src/components/Accordion/utils.tsx +11 -0
- package/src/components/Button/Button.tsx +64 -60
- package/src/components/Button/IconButton.tsx +1 -1
- package/src/components/Button/StyledButton.tsx +4 -6
- package/src/components/Button/__tests__/StyledButton.spec.tsx +11 -4
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +312 -78
- package/src/components/Calendar/CalendarRowItem.tsx +54 -0
- package/src/components/Calendar/StyledCalendar.tsx +76 -0
- package/src/components/Calendar/__tests__/CalendarRowItem.spec.tsx +76 -0
- package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +411 -0
- package/src/components/Calendar/__tests__/helper.spec.ts +50 -0
- package/src/components/Calendar/__tests__/index.spec.tsx +99 -0
- package/src/components/Calendar/helpers.ts +29 -0
- package/src/components/Calendar/index.tsx +217 -0
- package/src/components/Collapse/index.tsx +13 -15
- package/src/components/ContentNavigator/index.tsx +6 -0
- package/src/components/DatePicker/DatePickerAndroid.tsx +59 -0
- package/src/components/DatePicker/DatePickerIOS.tsx +87 -0
- package/src/components/DatePicker/StyledDatePicker.tsx +8 -0
- package/src/components/DatePicker/__tests__/DatePicker.spec.tsx +34 -0
- package/src/components/DatePicker/__tests__/DatePickerAndroid.spec.tsx +39 -0
- package/src/components/DatePicker/__tests__/DatePickerIOS.spec.tsx +46 -0
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +199 -0
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +513 -0
- package/src/components/DatePicker/index.tsx +15 -0
- package/src/components/DatePicker/types.ts +49 -0
- package/src/components/Empty/StyledEmpty.tsx +47 -0
- package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +66 -0
- package/src/components/Empty/__tests__/index.spec.tsx +17 -0
- package/src/components/Empty/index.tsx +53 -0
- package/src/components/FAB/ActionGroup/ActionItem.tsx +6 -2
- package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +1 -0
- package/src/components/FAB/ActionGroup/StyledActionItem.tsx +7 -1
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +84 -22
- package/src/components/FAB/ActionGroup/index.tsx +8 -1
- package/src/components/Icon/HeroIcon/selection.json +1 -1
- package/src/components/Icon/IconList.ts +13 -0
- package/src/components/List/BasicListItem.tsx +44 -34
- package/src/components/List/ListItem.tsx +67 -58
- package/src/components/List/StyledBasicListItem.tsx +2 -3
- package/src/components/List/StyledListItem.tsx +2 -2
- package/src/components/List/__tests__/StyledBasicListItem.spec.tsx +5 -2
- package/src/components/List/__tests__/StyledListItem.spec.tsx +4 -1
- package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +15 -10
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +52 -32
- package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +128 -48
- package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +132 -52
- package/src/components/RichTextEditor/EditorEvent.ts +7 -0
- package/src/components/RichTextEditor/EditorToolbar.tsx +220 -0
- package/src/components/RichTextEditor/MentionList.tsx +69 -0
- package/src/components/RichTextEditor/RichTextEditor.tsx +396 -0
- package/src/components/RichTextEditor/StyledRichTextEditor.ts +20 -0
- package/src/components/RichTextEditor/StyledToolbar.ts +32 -0
- package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +130 -0
- package/src/components/RichTextEditor/__tests__/MentionList.spec.tsx +109 -0
- package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +245 -0
- package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +324 -0
- package/src/components/RichTextEditor/__tests__/__snapshots__/MentionList.spec.tsx.snap +45 -0
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +526 -0
- package/src/components/RichTextEditor/constants.ts +20 -0
- package/src/components/RichTextEditor/hero-editor.d.ts +8 -0
- package/src/components/RichTextEditor/index.tsx +8 -0
- package/src/components/RichTextEditor/utils/events.ts +31 -0
- package/src/components/RichTextEditor/utils/rnWebView.ts +19 -0
- package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +77 -0
- package/src/components/SectionHeading/__tests__/index.spec.tsx +14 -0
- package/src/components/SectionHeading/index.tsx +16 -9
- package/src/components/Tag/StyledTag.tsx +12 -2
- package/src/components/Tag/__tests__/Tag.spec.tsx +35 -8
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +118 -4
- package/src/components/Tag/index.tsx +9 -2
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +1 -0
- package/src/components/TimePicker/TimePickerIOS.tsx +1 -1
- package/src/components/TimePicker/types.ts +1 -1
- package/src/components/Typography/Text/StyledText.tsx +2 -1
- package/src/components/Typography/Text/__tests__/StyledText.spec.tsx +1 -0
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +22 -0
- package/src/components/Typography/Text/index.tsx +2 -1
- package/src/index.ts +10 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +119 -4
- package/src/theme/components/accordion.ts +19 -0
- package/src/theme/components/button.ts +12 -0
- package/src/theme/components/calendar.ts +34 -0
- package/src/theme/components/card.ts +1 -1
- package/src/theme/components/datePicker.ts +11 -0
- package/src/theme/components/empty.ts +38 -0
- package/src/theme/components/fab.ts +4 -3
- package/src/theme/components/list.ts +1 -0
- package/src/theme/components/pinInput.ts +1 -1
- package/src/theme/components/richTextEditor.ts +34 -0
- package/src/theme/components/tag.ts +8 -2
- package/src/theme/components/typography.ts +1 -0
- package/src/theme/global/borders.ts +6 -6
- package/src/theme/global/colors.ts +5 -1
- package/src/theme/index.ts +15 -0
- package/testUtils/setup.tsx +17 -0
- package/types/components/Accordion/AccordionItem.d.ts +14 -0
- package/types/components/Accordion/StyledAccordion.d.ts +32 -0
- package/types/components/Accordion/__tests__/AccordionItem.spec.d.ts +1 -0
- package/types/components/Accordion/__tests__/StyledAccordion.spec.d.ts +1 -0
- package/types/components/Accordion/__tests__/index.spec.d.ts +1 -0
- package/types/components/Accordion/index.d.ts +38 -0
- package/types/components/Accordion/utils.d.ts +1 -0
- package/types/components/Button/IconButton.d.ts +1 -1
- package/types/components/Button/StyledButton.d.ts +3 -3
- package/types/components/Calendar/CalendarRowItem.d.ts +10 -0
- package/types/components/Calendar/StyledCalendar.d.ts +54 -0
- package/types/components/Calendar/__tests__/CalendarRowItem.spec.d.ts +1 -0
- package/types/components/Calendar/__tests__/helper.spec.d.ts +1 -0
- package/types/components/Calendar/__tests__/index.spec.d.ts +1 -0
- package/types/components/Calendar/helpers.d.ts +3 -0
- package/types/components/Calendar/index.d.ts +40 -0
- package/types/components/Collapse/index.d.ts +1 -1
- package/types/components/ContentNavigator/index.d.ts +5 -1
- package/types/components/DatePicker/DatePickerAndroid.d.ts +3 -0
- package/types/components/DatePicker/DatePickerIOS.d.ts +3 -0
- package/types/components/DatePicker/StyledDatePicker.d.ts +8 -0
- package/types/components/DatePicker/__tests__/DatePicker.spec.d.ts +1 -0
- package/types/components/DatePicker/__tests__/DatePickerAndroid.spec.d.ts +1 -0
- package/types/components/DatePicker/__tests__/DatePickerIOS.spec.d.ts +1 -0
- package/types/components/DatePicker/index.d.ts +3 -0
- package/types/components/DatePicker/types.d.ts +48 -0
- package/types/components/Empty/StyledEmpty.d.ts +31 -0
- package/types/components/Empty/__tests__/index.spec.d.ts +1 -0
- package/types/components/Empty/index.d.ts +26 -0
- package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +6 -1
- package/types/components/FAB/ActionGroup/index.d.ts +6 -1
- package/types/components/FAB/index.d.ts +1 -1
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/components/List/StyledBasicListItem.d.ts +3 -3
- package/types/components/List/StyledListItem.d.ts +3 -3
- package/types/components/RichTextEditor/EditorEvent.d.ts +3 -0
- package/types/components/RichTextEditor/EditorToolbar.d.ts +17 -0
- package/types/components/RichTextEditor/MentionList.d.ts +12 -0
- package/types/components/RichTextEditor/RichTextEditor.d.ts +65 -0
- package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +16 -0
- package/types/components/RichTextEditor/StyledToolbar.d.ts +21 -0
- package/types/components/RichTextEditor/__tests__/EditorToolbar.spec.d.ts +1 -0
- package/types/components/RichTextEditor/__tests__/MentionList.spec.d.ts +1 -0
- package/types/components/RichTextEditor/__tests__/RichTextEditor.spec.d.ts +1 -0
- package/types/components/RichTextEditor/constants.d.ts +19 -0
- package/types/components/RichTextEditor/index.d.ts +5 -0
- package/types/components/RichTextEditor/utils/events.d.ts +8 -0
- package/types/components/RichTextEditor/utils/rnWebView.d.ts +7 -0
- package/types/components/SectionHeading/index.d.ts +2 -2
- package/types/components/Select/MultiSelect/OptionList.d.ts +1 -1
- package/types/components/Select/SingleSelect/OptionList.d.ts +1 -1
- package/types/components/Tag/StyledTag.d.ts +1 -1
- package/types/components/Tag/index.d.ts +1 -1
- package/types/components/TimePicker/types.d.ts +1 -1
- package/types/components/Typography/Text/StyledText.d.ts +1 -1
- package/types/components/Typography/Text/index.d.ts +1 -1
- package/types/index.d.ts +6 -1
- package/types/theme/components/accordion.d.ts +13 -0
- package/types/theme/components/button.d.ts +12 -0
- package/types/theme/components/calendar.d.ts +26 -0
- package/types/theme/components/datePicker.d.ts +6 -0
- package/types/theme/components/empty.d.ts +28 -0
- package/types/theme/components/fab.d.ts +1 -0
- package/types/theme/components/list.d.ts +1 -0
- package/types/theme/components/richTextEditor.d.ts +26 -0
- package/types/theme/components/tag.d.ts +8 -2
- package/types/theme/components/typography.d.ts +1 -0
- package/types/theme/global/colors.d.ts +5 -1
- package/types/theme/global/index.d.ts +5 -1
- package/types/theme/index.d.ts +10 -0
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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[`
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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[`
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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[`
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
115
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
172
|
-
|
|
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
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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,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;
|