@hero-design/rn 7.22.3 → 7.23.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/.turbo/turbo-build.log +3 -3
- package/es/index.js +2124 -1638
- package/lib/index.js +2124 -1636
- package/package.json +6 -6
- package/src/components/Box/StyledBox.tsx +1 -2
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +18 -4
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +18 -4
- package/src/components/RefreshControl/__tests__/__snapshots__/index.spec.tsx.snap +69 -0
- package/src/components/RefreshControl/__tests__/index.spec.tsx +55 -0
- package/src/components/RefreshControl/index.tsx +23 -0
- package/src/components/RichTextEditor/MentionList.tsx +25 -4
- package/src/components/RichTextEditor/RichTextEditor.tsx +3 -1
- package/src/components/RichTextEditor/__tests__/MentionList.spec.tsx +6 -6
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +36 -8
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +90 -20
- package/src/components/Select/MultiSelect/index.tsx +1 -1
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +90 -20
- package/src/components/Select/SingleSelect/index.tsx +1 -1
- package/src/components/Select/types.ts +1 -3
- package/src/components/TextInput/StyledTextInput.tsx +16 -11
- package/src/components/TextInput/__tests__/StyledTextInput.spec.tsx +3 -3
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +36 -18
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +234 -52
- package/src/components/TextInput/index.tsx +21 -4
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +18 -4
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +18 -4
- package/src/index.ts +4 -0
- package/src/theme/ThemeSwitcher.tsx +9 -2
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +9 -3
- package/src/theme/components/refreshControl.ts +11 -0
- package/src/theme/components/richTextEditor.ts +6 -5
- package/src/theme/getTheme.ts +3 -0
- package/src/theme/global/colors/jobs.ts +18 -0
- package/src/theme/global/index.ts +8 -1
- package/src/theme/index.ts +6 -1
- package/src/utils/__tests__/helpers.spec.ts +27 -0
- package/src/utils/helpers.ts +21 -0
- package/tsconfig.prod.json +4 -0
- package/types/components/RefreshControl/index.d.ts +5 -0
- package/types/components/RichTextEditor/MentionList.d.ts +7 -3
- package/types/components/RichTextEditor/index.d.ts +1 -1
- package/types/components/Select/types.d.ts +1 -3
- package/types/components/TextInput/StyledTextInput.d.ts +9 -3
- package/types/index.d.ts +3 -2
- package/types/theme/ThemeSwitcher.d.ts +1 -1
- package/types/theme/components/refreshControl.d.ts +7 -0
- package/types/theme/components/richTextEditor.d.ts +4 -3
- package/types/theme/getTheme.d.ts +2 -0
- package/types/theme/global/colors/jobs.d.ts +3 -0
- package/types/theme/global/index.d.ts +2 -1
- package/types/theme/index.d.ts +2 -2
- package/types/utils/helpers.d.ts +2 -0
- package/src/components/Box/__tests__/helpers.spec.ts +0 -14
- package/src/components/Box/helpers.ts +0 -10
- package/types/components/Accordion/__tests__/AccordionItem.spec.d.ts +0 -1
- package/types/components/Accordion/__tests__/StyledAccordion.spec.d.ts +0 -1
- package/types/components/Accordion/__tests__/index.spec.d.ts +0 -1
- package/types/components/Alert/__tests__/index.spec.d.ts +0 -1
- package/types/components/Avatar/__tests__/StyledAvatar.spec.d.ts +0 -1
- package/types/components/Avatar/__tests__/index.spec.d.ts +0 -1
- package/types/components/Badge/__tests__/Badge.spec.d.ts +0 -1
- package/types/components/Badge/__tests__/Status.spec.d.ts +0 -1
- package/types/components/BottomNavigation/__tests__/index.spec.d.ts +0 -1
- package/types/components/BottomSheet/__tests__/index.spec.d.ts +0 -1
- package/types/components/Box/__tests__/helpers.spec.d.ts +0 -1
- package/types/components/Box/__tests__/index.spec.d.ts +0 -1
- package/types/components/Box/helpers.d.ts +0 -1
- package/types/components/Button/LoadingIndicator/__tests__/StyledLoadingIndicator.spec.d.ts +0 -1
- package/types/components/Button/LoadingIndicator/__tests__/index.spec.d.ts +0 -1
- package/types/components/Button/UtilityButton/__tests__/index.spec.d.ts +0 -1
- package/types/components/Button/__tests__/Button.spec.d.ts +0 -1
- package/types/components/Button/__tests__/IconButton.spec.d.ts +0 -1
- package/types/components/Button/__tests__/StyledButton.spec.d.ts +0 -1
- package/types/components/Calendar/__tests__/CalendarRowItem.spec.d.ts +0 -1
- package/types/components/Calendar/__tests__/helper.spec.d.ts +0 -1
- package/types/components/Calendar/__tests__/index.spec.d.ts +0 -1
- package/types/components/Card/DataCard/__tests__/StyledDataCard.spec.d.ts +0 -1
- package/types/components/Card/DataCard/__tests__/index.spec.d.ts +0 -1
- package/types/components/Card/__tests__/StyledCard.spec.d.ts +0 -1
- package/types/components/Card/__tests__/index.spec.d.ts +0 -1
- package/types/components/Checkbox/__tests__/StyledCheckbox.spec.d.ts +0 -1
- package/types/components/Checkbox/__tests__/index.spec.d.ts +0 -1
- package/types/components/Collapse/__tests__/StyledCollapse.spec.d.ts +0 -1
- package/types/components/Collapse/__tests__/index.spec.d.ts +0 -1
- package/types/components/ContentNavigator/__tests__/StyledContentNavigator.spec.d.ts +0 -1
- package/types/components/ContentNavigator/__tests__/index.spec.d.ts +0 -1
- package/types/components/DatePicker/__tests__/DatePicker.spec.d.ts +0 -1
- package/types/components/DatePicker/__tests__/DatePickerAndroid.spec.d.ts +0 -1
- package/types/components/DatePicker/__tests__/DatePickerIOS.spec.d.ts +0 -1
- package/types/components/Divider/__tests__/StyledDivider.spec.d.ts +0 -1
- package/types/components/Drawer/DragableDrawer/__tests__/helpers.spec.d.ts +0 -1
- package/types/components/Drawer/DragableDrawer/__tests__/index.spec.d.ts +0 -1
- package/types/components/Drawer/__tests__/index.spec.d.ts +0 -1
- package/types/components/Empty/__tests__/index.spec.d.ts +0 -1
- package/types/components/FAB/ActionGroup/__tests__/index.spec.d.ts +0 -1
- package/types/components/FAB/__tests__/AnimatedFABIcon.spec.d.ts +0 -1
- package/types/components/FAB/__tests__/StyledFAB.spec.d.ts +0 -1
- package/types/components/FAB/__tests__/index.spec.d.ts +0 -1
- package/types/components/Icon/__tests__/index.spec.d.ts +0 -1
- package/types/components/Image/__tests__/index.spec.d.ts +0 -1
- package/types/components/List/__tests__/BasicListItem.spec.d.ts +0 -1
- package/types/components/List/__tests__/ListItem.spec.d.ts +0 -1
- package/types/components/List/__tests__/StyledBasicListItem.spec.d.ts +0 -1
- package/types/components/List/__tests__/StyledListItem.spec.d.ts +0 -1
- package/types/components/PinInput/__tests__/PinCell.spec.d.ts +0 -1
- package/types/components/PinInput/__tests__/StyledPinInput.spec.d.ts +0 -1
- package/types/components/PinInput/__tests__/index.spec.d.ts +0 -1
- package/types/components/Radio/__tests__/Radio.spec.d.ts +0 -1
- package/types/components/Radio/__tests__/RadioGroup.spec.d.ts +0 -1
- package/types/components/RichTextEditor/__tests__/EditorToolbar.spec.d.ts +0 -1
- package/types/components/RichTextEditor/__tests__/MentionList.spec.d.ts +0 -1
- package/types/components/RichTextEditor/__tests__/RichTextEditor.spec.d.ts +0 -1
- package/types/components/SectionHeading/__tests__/StyledHeading.spec.d.ts +0 -1
- package/types/components/SectionHeading/__tests__/index.spec.d.ts +0 -1
- package/types/components/Select/MultiSelect/__tests__/Option.spec.d.ts +0 -1
- package/types/components/Select/MultiSelect/__tests__/OptionList.spec.d.ts +0 -1
- package/types/components/Select/MultiSelect/__tests__/index.spec.d.ts +0 -1
- package/types/components/Select/SingleSelect/__tests__/Option.spec.d.ts +0 -1
- package/types/components/Select/SingleSelect/__tests__/OptionList.spec.d.ts +0 -1
- package/types/components/Select/SingleSelect/__tests__/index.spec.d.ts +0 -1
- package/types/components/Select/__tests__/StyledSelect.spec.d.ts +0 -1
- package/types/components/Select/__tests__/helpers.spec.d.ts +0 -1
- package/types/components/Slider/__tests__/index.spec.d.ts +0 -1
- package/types/components/Spinner/__tests__/AnimatedSpinner.spec.d.ts +0 -1
- package/types/components/Spinner/__tests__/StyledSpinner.spec.d.ts +0 -1
- package/types/components/Spinner/__tests__/index.spec.d.ts +0 -1
- package/types/components/Switch/SelectorSwitch/__tests__/Option.spec.d.ts +0 -1
- package/types/components/Switch/SelectorSwitch/__tests__/index.spec.d.ts +0 -1
- package/types/components/Switch/__tests__/StyledSwitch.spec.d.ts +0 -1
- package/types/components/Switch/__tests__/index.spec.d.ts +0 -1
- package/types/components/Tabs/__tests__/ScrollableTabs.spec.d.ts +0 -1
- package/types/components/Tabs/__tests__/TabWithBadge.spec.d.ts +0 -1
- package/types/components/Tabs/__tests__/index.spec.d.ts +0 -1
- package/types/components/Tag/__tests__/Tag.spec.d.ts +0 -1
- package/types/components/TextInput/__tests__/StyledTextInput.spec.d.ts +0 -1
- package/types/components/TextInput/__tests__/index.spec.d.ts +0 -1
- package/types/components/TimePicker/__tests__/TimePicker.spec.d.ts +0 -1
- package/types/components/TimePicker/__tests__/TimePickerAndroid.spec.d.ts +0 -1
- package/types/components/TimePicker/__tests__/TimePickerIOS.spec.d.ts +0 -1
- package/types/components/Toast/__tests__/Toast.spec.d.ts +0 -1
- package/types/components/Toast/__tests__/ToastContainer.spec.d.ts +0 -1
- package/types/components/Toast/__tests__/index.spec.d.ts +0 -1
- package/types/components/Toolbar/__tests__/ToolbarGroup.spec.d.ts +0 -1
- package/types/components/Toolbar/__tests__/ToolbarItem.spec.d.ts +0 -1
- package/types/components/Typography/Text/__tests__/StyledText.spec.d.ts +0 -1
- package/types/components/Typography/Text/__tests__/index.spec.d.ts +0 -1
- package/types/theme/__tests__/index.spec.d.ts +0 -1
- package/types/utils/__tests__/scale.spec.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.23.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"test:watch": "jest --runInBand --watch",
|
|
13
13
|
"test:ci": "jest --runInBand --logHeapUsage",
|
|
14
14
|
"build:js": "rollup -c",
|
|
15
|
-
"build:types": "tsc --noEmit false --emitDeclarationOnly",
|
|
15
|
+
"build:types": "tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json",
|
|
16
16
|
"build": "yarn build:js && yarn build:types",
|
|
17
17
|
"build:watch": "yarn build:js -w & yarn build:types -w",
|
|
18
18
|
"publish:npm": "yarn publish --access public"
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@emotion/native": "^11.9.3",
|
|
22
22
|
"@emotion/react": "^11.9.3",
|
|
23
|
-
"@hero-design/colors": "7.
|
|
23
|
+
"@hero-design/colors": "7.23.0",
|
|
24
24
|
"date-fns": "^2.16.1",
|
|
25
25
|
"events": "^3.2.0",
|
|
26
|
-
"hero-editor": "^1.9.
|
|
26
|
+
"hero-editor": "^1.9.12"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@types/react-native": "^0.67.7",
|
|
58
58
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
59
59
|
"babel-plugin-inline-import": "^3.0.0",
|
|
60
|
-
"eslint-config-hd": "7.
|
|
60
|
+
"eslint-config-hd": "7.23.0",
|
|
61
61
|
"jest": "^27.3.1",
|
|
62
62
|
"react": "17.0.2",
|
|
63
63
|
"react-native": "0.65.1",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"rollup-plugin-copy": "^3.4.0",
|
|
71
71
|
"rollup-plugin-flow": "^1.1.1",
|
|
72
72
|
"ts-jest": "^27.0.7",
|
|
73
|
-
"prettier-config-hd": "7.
|
|
73
|
+
"prettier-config-hd": "7.23.0"
|
|
74
74
|
},
|
|
75
75
|
"prettier": "prettier-config-hd"
|
|
76
76
|
}
|
|
@@ -2,9 +2,8 @@ import styled from '@emotion/native';
|
|
|
2
2
|
import { Theme } from '@emotion/react';
|
|
3
3
|
import { View } from 'react-native';
|
|
4
4
|
import { StyleProps, ThemeScale } from './types';
|
|
5
|
-
|
|
5
|
+
import { pick } from '../../utils/helpers';
|
|
6
6
|
import config, { ConfigType, flexPropsKey } from './config';
|
|
7
|
-
import { pick } from './helpers';
|
|
8
7
|
|
|
9
8
|
export const getThemeValue = (
|
|
10
9
|
theme: Theme,
|
|
@@ -26,16 +26,12 @@ exports[`DatePickerAndroid renders correctly 1`] = `
|
|
|
26
26
|
style={
|
|
27
27
|
Array [
|
|
28
28
|
Object {
|
|
29
|
-
"borderColor": "#001f23",
|
|
30
|
-
"borderRadius": 8,
|
|
31
|
-
"borderWidth": 1,
|
|
32
29
|
"marginVertical": 8,
|
|
33
30
|
"width": "100%",
|
|
34
31
|
},
|
|
35
32
|
undefined,
|
|
36
33
|
]
|
|
37
34
|
}
|
|
38
|
-
themeVariant="filled"
|
|
39
35
|
>
|
|
40
36
|
<View
|
|
41
37
|
style={
|
|
@@ -49,6 +45,24 @@ exports[`DatePickerAndroid renders correctly 1`] = `
|
|
|
49
45
|
]
|
|
50
46
|
}
|
|
51
47
|
>
|
|
48
|
+
<View
|
|
49
|
+
style={
|
|
50
|
+
Array [
|
|
51
|
+
Object {
|
|
52
|
+
"borderColor": "#001f23",
|
|
53
|
+
"borderRadius": 8,
|
|
54
|
+
"borderWidth": 1,
|
|
55
|
+
"bottom": 0,
|
|
56
|
+
"left": 0,
|
|
57
|
+
"position": "absolute",
|
|
58
|
+
"right": 0,
|
|
59
|
+
"top": 0,
|
|
60
|
+
},
|
|
61
|
+
undefined,
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
themeVariant="filled"
|
|
65
|
+
/>
|
|
52
66
|
<View
|
|
53
67
|
pointerEvents="none"
|
|
54
68
|
style={
|
|
@@ -26,16 +26,12 @@ exports[`DatePickerIOS renders correctly 1`] = `
|
|
|
26
26
|
style={
|
|
27
27
|
Array [
|
|
28
28
|
Object {
|
|
29
|
-
"borderColor": "#001f23",
|
|
30
|
-
"borderRadius": 8,
|
|
31
|
-
"borderWidth": 1,
|
|
32
29
|
"marginVertical": 8,
|
|
33
30
|
"width": "100%",
|
|
34
31
|
},
|
|
35
32
|
undefined,
|
|
36
33
|
]
|
|
37
34
|
}
|
|
38
|
-
themeVariant="filled"
|
|
39
35
|
>
|
|
40
36
|
<View
|
|
41
37
|
style={
|
|
@@ -49,6 +45,24 @@ exports[`DatePickerIOS renders correctly 1`] = `
|
|
|
49
45
|
]
|
|
50
46
|
}
|
|
51
47
|
>
|
|
48
|
+
<View
|
|
49
|
+
style={
|
|
50
|
+
Array [
|
|
51
|
+
Object {
|
|
52
|
+
"borderColor": "#001f23",
|
|
53
|
+
"borderRadius": 8,
|
|
54
|
+
"borderWidth": 1,
|
|
55
|
+
"bottom": 0,
|
|
56
|
+
"left": 0,
|
|
57
|
+
"position": "absolute",
|
|
58
|
+
"right": 0,
|
|
59
|
+
"top": 0,
|
|
60
|
+
},
|
|
61
|
+
undefined,
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
themeVariant="filled"
|
|
65
|
+
/>
|
|
52
66
|
<View
|
|
53
67
|
pointerEvents="none"
|
|
54
68
|
style={
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`RefreshControl render correctly with props 1`] = `
|
|
4
|
+
<RCTScrollView
|
|
5
|
+
contentContainerStyle={
|
|
6
|
+
Object {
|
|
7
|
+
"flex": 1,
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
refreshControl={
|
|
11
|
+
<RefreshControl
|
|
12
|
+
onRefresh={[MockFunction]}
|
|
13
|
+
progressViewOffset={100}
|
|
14
|
+
refreshing={true}
|
|
15
|
+
/>
|
|
16
|
+
}
|
|
17
|
+
>
|
|
18
|
+
<RCTRefreshControl />
|
|
19
|
+
<View>
|
|
20
|
+
<Text>
|
|
21
|
+
Pull down to see RefreshControl indicator
|
|
22
|
+
</Text>
|
|
23
|
+
</View>
|
|
24
|
+
</RCTScrollView>
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
exports[`RefreshControl renders correctly when refreshing is false 1`] = `
|
|
28
|
+
<RCTScrollView
|
|
29
|
+
contentContainerStyle={
|
|
30
|
+
Object {
|
|
31
|
+
"flex": 1,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
refreshControl={
|
|
35
|
+
<RefreshControl
|
|
36
|
+
refreshing={false}
|
|
37
|
+
/>
|
|
38
|
+
}
|
|
39
|
+
>
|
|
40
|
+
<RCTRefreshControl />
|
|
41
|
+
<View>
|
|
42
|
+
<Text>
|
|
43
|
+
Pull down to see RefreshControl indicator
|
|
44
|
+
</Text>
|
|
45
|
+
</View>
|
|
46
|
+
</RCTScrollView>
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
exports[`RefreshControl renders correctly when refreshing is true 1`] = `
|
|
50
|
+
<RCTScrollView
|
|
51
|
+
contentContainerStyle={
|
|
52
|
+
Object {
|
|
53
|
+
"flex": 1,
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
refreshControl={
|
|
57
|
+
<RefreshControl
|
|
58
|
+
refreshing={true}
|
|
59
|
+
/>
|
|
60
|
+
}
|
|
61
|
+
>
|
|
62
|
+
<RCTRefreshControl />
|
|
63
|
+
<View>
|
|
64
|
+
<Text>
|
|
65
|
+
Pull down to see RefreshControl indicator
|
|
66
|
+
</Text>
|
|
67
|
+
</View>
|
|
68
|
+
</RCTScrollView>
|
|
69
|
+
`;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
import { ScrollView, Text } from 'react-native';
|
|
3
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
4
|
+
import RefreshControl from '..';
|
|
5
|
+
|
|
6
|
+
const ExampleList = ({
|
|
7
|
+
refreshControl,
|
|
8
|
+
}: {
|
|
9
|
+
refreshControl: ReactElement;
|
|
10
|
+
}): ReactElement => {
|
|
11
|
+
return (
|
|
12
|
+
<ScrollView
|
|
13
|
+
contentContainerStyle={{
|
|
14
|
+
flex: 1,
|
|
15
|
+
}}
|
|
16
|
+
refreshControl={refreshControl}
|
|
17
|
+
>
|
|
18
|
+
<Text>
|
|
19
|
+
Pull down to see RefreshControl indicator
|
|
20
|
+
</Text>
|
|
21
|
+
</ScrollView>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe('RefreshControl', () => {
|
|
26
|
+
it.each`
|
|
27
|
+
refreshing
|
|
28
|
+
${true}
|
|
29
|
+
${false}
|
|
30
|
+
`('renders correctly when refreshing is $refreshing', ({ refreshing }) => {
|
|
31
|
+
const { toJSON } = renderWithTheme(
|
|
32
|
+
<ExampleList
|
|
33
|
+
refreshControl={<RefreshControl refreshing={refreshing} />}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
expect(toJSON()).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('render correctly with props', () => {
|
|
41
|
+
const { toJSON } = renderWithTheme(
|
|
42
|
+
<ExampleList
|
|
43
|
+
refreshControl={
|
|
44
|
+
<RefreshControl
|
|
45
|
+
refreshing
|
|
46
|
+
progressViewOffset={100}
|
|
47
|
+
onRefresh={jest.fn()}
|
|
48
|
+
/>
|
|
49
|
+
}
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
expect(toJSON()).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
RefreshControl as NativeRefreshControl,
|
|
4
|
+
RefreshControlProps as NativeRefreshControlProps,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
import { useTheme } from '../../theme';
|
|
7
|
+
|
|
8
|
+
export interface RefreshControlProps
|
|
9
|
+
extends Omit<NativeRefreshControlProps, 'colors' | 'tintColor'> {}
|
|
10
|
+
|
|
11
|
+
const RefreshControl = ({ ...props }: RefreshControlProps) => {
|
|
12
|
+
const theme = useTheme();
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<NativeRefreshControl
|
|
16
|
+
{...props}
|
|
17
|
+
colors={[theme.__hd__.refreshControl.colors.indicator]}
|
|
18
|
+
tintColor={theme.__hd__.refreshControl.colors.indicator}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default RefreshControl;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useTheme } from '@emotion/react';
|
|
1
2
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
3
|
import { View } from 'react-native';
|
|
3
4
|
import { emitter } from './EditorEvent';
|
|
@@ -5,7 +6,12 @@ import * as Events from './utils/events';
|
|
|
5
6
|
|
|
6
7
|
const isEmptyString = (s: string | null): boolean => !s || s.length === 0;
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
interface OnSelectOptionsType<TMetaData> {
|
|
10
|
+
highlighted: boolean;
|
|
11
|
+
meta?: TMetaData;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface MentionListProps<TMetaData = unknown> {
|
|
9
15
|
/**
|
|
10
16
|
* Unique name used to communicate with webview, should be the same with the RichTextEditor component it used with
|
|
11
17
|
*/
|
|
@@ -15,17 +21,19 @@ export interface MentionListProps {
|
|
|
15
21
|
*/
|
|
16
22
|
render: (
|
|
17
23
|
searchText: string,
|
|
18
|
-
onSelect: (id: string, name: string) => void
|
|
24
|
+
onSelect: (id: string, name: string, options?: OnSelectOptionsType<TMetaData>) => void
|
|
19
25
|
) => JSX.Element;
|
|
20
26
|
}
|
|
21
27
|
|
|
22
|
-
const MentionList = ({ name: eventPrefix, render }: MentionListProps) => {
|
|
28
|
+
const MentionList = <TMetaData, >({ name: eventPrefix, render }: MentionListProps<TMetaData>) => {
|
|
29
|
+
const theme = useTheme();
|
|
23
30
|
const [search, setSearch] = useState<string>('');
|
|
24
31
|
const [target, setTarget] = useState<string | null>(null);
|
|
25
32
|
const normalizeEventName = useCallback(
|
|
26
33
|
(event: string) => `${eventPrefix}/${event}`,
|
|
27
34
|
[eventPrefix]
|
|
28
35
|
);
|
|
36
|
+
|
|
29
37
|
useEffect(() => {
|
|
30
38
|
const removeMentionSearchListener = Events.on(
|
|
31
39
|
emitter,
|
|
@@ -53,11 +61,24 @@ const MentionList = ({ name: eventPrefix, render }: MentionListProps) => {
|
|
|
53
61
|
|
|
54
62
|
return (
|
|
55
63
|
<View>
|
|
56
|
-
{render(search, (id, name) => {
|
|
64
|
+
{render(search, (id, name, options = { highlighted: false }) => {
|
|
65
|
+
const { highlighted, meta } = options;
|
|
66
|
+
|
|
67
|
+
const highlightStyle = {
|
|
68
|
+
color: theme.colors.secondary,
|
|
69
|
+
borderRadius: theme.__hd__.richTextEditor.radii.mention,
|
|
70
|
+
padding: highlighted ? theme.__hd__.richTextEditor.space.mention : 0,
|
|
71
|
+
background: highlighted ? theme.colors.lightHighlightedSurface : 'transparent',
|
|
72
|
+
marginTop: theme.space.xxsmall,
|
|
73
|
+
marginBottom: theme.space.xxsmall,
|
|
74
|
+
display: 'inline-flex',
|
|
75
|
+
};
|
|
57
76
|
const data = {
|
|
58
77
|
id,
|
|
59
78
|
name,
|
|
60
79
|
target,
|
|
80
|
+
meta,
|
|
81
|
+
style: highlightStyle,
|
|
61
82
|
};
|
|
62
83
|
|
|
63
84
|
Events.emit(emitter, normalizeEventName('mention-apply'), data);
|
|
@@ -20,6 +20,7 @@ import Icon from '../Icon';
|
|
|
20
20
|
import {
|
|
21
21
|
StyledAsteriskLabel,
|
|
22
22
|
StyledAsteriskLabelInsideTextInput,
|
|
23
|
+
StyledBorderBackDrop,
|
|
23
24
|
StyledContainer,
|
|
24
25
|
StyledError,
|
|
25
26
|
StyledErrorAndHelpTextContainer,
|
|
@@ -309,8 +310,9 @@ const RichTextEditor: ComponentType<RichTextEditorProps> = ({
|
|
|
309
310
|
);
|
|
310
311
|
|
|
311
312
|
return (
|
|
312
|
-
<StyledContainer testID={testID}
|
|
313
|
+
<StyledContainer testID={testID}>
|
|
313
314
|
<StyledTextInputContainer>
|
|
315
|
+
<StyledBorderBackDrop themeVariant={variant} />
|
|
314
316
|
{(isFocused || (label && !isEmptyValue)) && (
|
|
315
317
|
<StyledLabelContainer pointerEvents="none">
|
|
316
318
|
{required && (
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { FlatList, Text } from 'react-native';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import { act, fireEvent, render } from '@testing-library/react-native';
|
|
5
1
|
import type { RenderAPI } from '@testing-library/react-native';
|
|
6
|
-
import
|
|
2
|
+
import { act, fireEvent, render } from '@testing-library/react-native';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { FlatList, Text } from 'react-native';
|
|
5
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
7
6
|
import { emitter as editorEventEmitter } from '../EditorEvent';
|
|
7
|
+
import MentionList from '../MentionList';
|
|
8
8
|
import * as Events from '../utils/events';
|
|
9
9
|
|
|
10
10
|
const SuggestionListData: Array<{ id: string; name: string }> = [
|
|
@@ -56,7 +56,7 @@ describe('MentionList', () => {
|
|
|
56
56
|
let wrapper: RenderAPI;
|
|
57
57
|
|
|
58
58
|
beforeEach(() => {
|
|
59
|
-
wrapper =
|
|
59
|
+
wrapper = renderWithTheme(
|
|
60
60
|
<MentionList
|
|
61
61
|
name="give-shout-out"
|
|
62
62
|
render={(
|
|
@@ -5,16 +5,12 @@ exports[`RichTextEditor onMessage recevied event editor-layout should update hei
|
|
|
5
5
|
style={
|
|
6
6
|
Array [
|
|
7
7
|
Object {
|
|
8
|
-
"borderColor": "#f46363",
|
|
9
|
-
"borderRadius": 8,
|
|
10
|
-
"borderWidth": 1,
|
|
11
8
|
"marginVertical": 8,
|
|
12
9
|
"width": "100%",
|
|
13
10
|
},
|
|
14
11
|
undefined,
|
|
15
12
|
]
|
|
16
13
|
}
|
|
17
|
-
themeVariant="error"
|
|
18
14
|
>
|
|
19
15
|
<View
|
|
20
16
|
style={
|
|
@@ -28,6 +24,24 @@ exports[`RichTextEditor onMessage recevied event editor-layout should update hei
|
|
|
28
24
|
]
|
|
29
25
|
}
|
|
30
26
|
>
|
|
27
|
+
<View
|
|
28
|
+
style={
|
|
29
|
+
Array [
|
|
30
|
+
Object {
|
|
31
|
+
"borderColor": "#f46363",
|
|
32
|
+
"borderRadius": 8,
|
|
33
|
+
"borderWidth": 1,
|
|
34
|
+
"bottom": 0,
|
|
35
|
+
"left": 0,
|
|
36
|
+
"position": "absolute",
|
|
37
|
+
"right": 0,
|
|
38
|
+
"top": 0,
|
|
39
|
+
},
|
|
40
|
+
undefined,
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
themeVariant="error"
|
|
44
|
+
/>
|
|
31
45
|
<View
|
|
32
46
|
style={
|
|
33
47
|
Array [
|
|
@@ -251,16 +265,12 @@ exports[`RichTextEditor should render correctly 1`] = `
|
|
|
251
265
|
style={
|
|
252
266
|
Array [
|
|
253
267
|
Object {
|
|
254
|
-
"borderColor": "#f46363",
|
|
255
|
-
"borderRadius": 8,
|
|
256
|
-
"borderWidth": 1,
|
|
257
268
|
"marginVertical": 8,
|
|
258
269
|
"width": "100%",
|
|
259
270
|
},
|
|
260
271
|
undefined,
|
|
261
272
|
]
|
|
262
273
|
}
|
|
263
|
-
themeVariant="error"
|
|
264
274
|
>
|
|
265
275
|
<View
|
|
266
276
|
style={
|
|
@@ -274,6 +284,24 @@ exports[`RichTextEditor should render correctly 1`] = `
|
|
|
274
284
|
]
|
|
275
285
|
}
|
|
276
286
|
>
|
|
287
|
+
<View
|
|
288
|
+
style={
|
|
289
|
+
Array [
|
|
290
|
+
Object {
|
|
291
|
+
"borderColor": "#f46363",
|
|
292
|
+
"borderRadius": 8,
|
|
293
|
+
"borderWidth": 1,
|
|
294
|
+
"bottom": 0,
|
|
295
|
+
"left": 0,
|
|
296
|
+
"position": "absolute",
|
|
297
|
+
"right": 0,
|
|
298
|
+
"top": 0,
|
|
299
|
+
},
|
|
300
|
+
undefined,
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
themeVariant="error"
|
|
304
|
+
/>
|
|
277
305
|
<View
|
|
278
306
|
style={
|
|
279
307
|
Array [
|
|
@@ -29,16 +29,12 @@ Array [
|
|
|
29
29
|
style={
|
|
30
30
|
Array [
|
|
31
31
|
Object {
|
|
32
|
-
"borderColor": "#001f23",
|
|
33
|
-
"borderRadius": 8,
|
|
34
|
-
"borderWidth": 1,
|
|
35
32
|
"marginVertical": 8,
|
|
36
33
|
"width": "100%",
|
|
37
34
|
},
|
|
38
35
|
undefined,
|
|
39
36
|
]
|
|
40
37
|
}
|
|
41
|
-
themeVariant="default"
|
|
42
38
|
>
|
|
43
39
|
<View
|
|
44
40
|
style={
|
|
@@ -52,6 +48,24 @@ Array [
|
|
|
52
48
|
]
|
|
53
49
|
}
|
|
54
50
|
>
|
|
51
|
+
<View
|
|
52
|
+
style={
|
|
53
|
+
Array [
|
|
54
|
+
Object {
|
|
55
|
+
"borderColor": "#001f23",
|
|
56
|
+
"borderRadius": 8,
|
|
57
|
+
"borderWidth": 1,
|
|
58
|
+
"bottom": 0,
|
|
59
|
+
"left": 0,
|
|
60
|
+
"position": "absolute",
|
|
61
|
+
"right": 0,
|
|
62
|
+
"top": 0,
|
|
63
|
+
},
|
|
64
|
+
undefined,
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
themeVariant="default"
|
|
68
|
+
/>
|
|
55
69
|
<View
|
|
56
70
|
style={
|
|
57
71
|
Array [
|
|
@@ -1364,16 +1378,12 @@ Array [
|
|
|
1364
1378
|
style={
|
|
1365
1379
|
Array [
|
|
1366
1380
|
Object {
|
|
1367
|
-
"borderColor": "#001f23",
|
|
1368
|
-
"borderRadius": 8,
|
|
1369
|
-
"borderWidth": 1,
|
|
1370
1381
|
"marginVertical": 8,
|
|
1371
1382
|
"width": "100%",
|
|
1372
1383
|
},
|
|
1373
1384
|
undefined,
|
|
1374
1385
|
]
|
|
1375
1386
|
}
|
|
1376
|
-
themeVariant="filled"
|
|
1377
1387
|
>
|
|
1378
1388
|
<View
|
|
1379
1389
|
style={
|
|
@@ -1387,6 +1397,24 @@ Array [
|
|
|
1387
1397
|
]
|
|
1388
1398
|
}
|
|
1389
1399
|
>
|
|
1400
|
+
<View
|
|
1401
|
+
style={
|
|
1402
|
+
Array [
|
|
1403
|
+
Object {
|
|
1404
|
+
"borderColor": "#001f23",
|
|
1405
|
+
"borderRadius": 8,
|
|
1406
|
+
"borderWidth": 1,
|
|
1407
|
+
"bottom": 0,
|
|
1408
|
+
"left": 0,
|
|
1409
|
+
"position": "absolute",
|
|
1410
|
+
"right": 0,
|
|
1411
|
+
"top": 0,
|
|
1412
|
+
},
|
|
1413
|
+
undefined,
|
|
1414
|
+
]
|
|
1415
|
+
}
|
|
1416
|
+
themeVariant="filled"
|
|
1417
|
+
/>
|
|
1390
1418
|
<View
|
|
1391
1419
|
pointerEvents="none"
|
|
1392
1420
|
style={
|
|
@@ -2895,16 +2923,12 @@ Array [
|
|
|
2895
2923
|
style={
|
|
2896
2924
|
Array [
|
|
2897
2925
|
Object {
|
|
2898
|
-
"borderColor": "#001f23",
|
|
2899
|
-
"borderRadius": 8,
|
|
2900
|
-
"borderWidth": 1,
|
|
2901
2926
|
"marginVertical": 8,
|
|
2902
2927
|
"width": "100%",
|
|
2903
2928
|
},
|
|
2904
2929
|
undefined,
|
|
2905
2930
|
]
|
|
2906
2931
|
}
|
|
2907
|
-
themeVariant="filled"
|
|
2908
2932
|
>
|
|
2909
2933
|
<View
|
|
2910
2934
|
style={
|
|
@@ -2918,6 +2942,24 @@ Array [
|
|
|
2918
2942
|
]
|
|
2919
2943
|
}
|
|
2920
2944
|
>
|
|
2945
|
+
<View
|
|
2946
|
+
style={
|
|
2947
|
+
Array [
|
|
2948
|
+
Object {
|
|
2949
|
+
"borderColor": "#001f23",
|
|
2950
|
+
"borderRadius": 8,
|
|
2951
|
+
"borderWidth": 1,
|
|
2952
|
+
"bottom": 0,
|
|
2953
|
+
"left": 0,
|
|
2954
|
+
"position": "absolute",
|
|
2955
|
+
"right": 0,
|
|
2956
|
+
"top": 0,
|
|
2957
|
+
},
|
|
2958
|
+
undefined,
|
|
2959
|
+
]
|
|
2960
|
+
}
|
|
2961
|
+
themeVariant="filled"
|
|
2962
|
+
/>
|
|
2921
2963
|
<View
|
|
2922
2964
|
pointerEvents="none"
|
|
2923
2965
|
style={
|
|
@@ -4421,16 +4463,12 @@ Array [
|
|
|
4421
4463
|
style={
|
|
4422
4464
|
Array [
|
|
4423
4465
|
Object {
|
|
4424
|
-
"borderColor": "#808f91",
|
|
4425
|
-
"borderRadius": 8,
|
|
4426
|
-
"borderWidth": 1,
|
|
4427
4466
|
"marginVertical": 8,
|
|
4428
4467
|
"width": "100%",
|
|
4429
4468
|
},
|
|
4430
4469
|
undefined,
|
|
4431
4470
|
]
|
|
4432
4471
|
}
|
|
4433
|
-
themeVariant="readonly"
|
|
4434
4472
|
>
|
|
4435
4473
|
<View
|
|
4436
4474
|
style={
|
|
@@ -4444,6 +4482,24 @@ Array [
|
|
|
4444
4482
|
]
|
|
4445
4483
|
}
|
|
4446
4484
|
>
|
|
4485
|
+
<View
|
|
4486
|
+
style={
|
|
4487
|
+
Array [
|
|
4488
|
+
Object {
|
|
4489
|
+
"borderColor": "#808f91",
|
|
4490
|
+
"borderRadius": 8,
|
|
4491
|
+
"borderWidth": 1,
|
|
4492
|
+
"bottom": 0,
|
|
4493
|
+
"left": 0,
|
|
4494
|
+
"position": "absolute",
|
|
4495
|
+
"right": 0,
|
|
4496
|
+
"top": 0,
|
|
4497
|
+
},
|
|
4498
|
+
undefined,
|
|
4499
|
+
]
|
|
4500
|
+
}
|
|
4501
|
+
themeVariant="readonly"
|
|
4502
|
+
/>
|
|
4447
4503
|
<View
|
|
4448
4504
|
pointerEvents="none"
|
|
4449
4505
|
style={
|
|
@@ -5966,16 +6022,12 @@ Array [
|
|
|
5966
6022
|
style={
|
|
5967
6023
|
Array [
|
|
5968
6024
|
Object {
|
|
5969
|
-
"borderColor": "#001f23",
|
|
5970
|
-
"borderRadius": 8,
|
|
5971
|
-
"borderWidth": 1,
|
|
5972
6025
|
"marginVertical": 8,
|
|
5973
6026
|
"width": "100%",
|
|
5974
6027
|
},
|
|
5975
6028
|
undefined,
|
|
5976
6029
|
]
|
|
5977
6030
|
}
|
|
5978
|
-
themeVariant="filled"
|
|
5979
6031
|
>
|
|
5980
6032
|
<View
|
|
5981
6033
|
style={
|
|
@@ -5989,6 +6041,24 @@ Array [
|
|
|
5989
6041
|
]
|
|
5990
6042
|
}
|
|
5991
6043
|
>
|
|
6044
|
+
<View
|
|
6045
|
+
style={
|
|
6046
|
+
Array [
|
|
6047
|
+
Object {
|
|
6048
|
+
"borderColor": "#001f23",
|
|
6049
|
+
"borderRadius": 8,
|
|
6050
|
+
"borderWidth": 1,
|
|
6051
|
+
"bottom": 0,
|
|
6052
|
+
"left": 0,
|
|
6053
|
+
"position": "absolute",
|
|
6054
|
+
"right": 0,
|
|
6055
|
+
"top": 0,
|
|
6056
|
+
},
|
|
6057
|
+
undefined,
|
|
6058
|
+
]
|
|
6059
|
+
}
|
|
6060
|
+
themeVariant="filled"
|
|
6061
|
+
/>
|
|
5992
6062
|
<View
|
|
5993
6063
|
pointerEvents="none"
|
|
5994
6064
|
style={
|