@hero-design/rn 7.19.0 → 7.20.1
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 +6 -1
- package/.turbo/turbo-build.log +2 -2
- package/es/index.js +612 -242
- package/lib/index.js +612 -241
- package/package.json +4 -4
- package/src/components/Alert/StyledAlert.tsx +5 -5
- package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +140 -19
- package/src/components/Alert/__tests__/index.spec.tsx +21 -0
- package/src/components/Alert/index.tsx +13 -6
- package/src/components/Avatar/StyledAvatar.tsx +2 -1
- package/src/components/Avatar/index.tsx +2 -1
- package/src/components/Box/StyledBox.tsx +54 -0
- package/src/components/Box/__tests__/__snapshots__/index.spec.tsx.snap +605 -0
- package/src/components/Box/__tests__/helpers.spec.ts +14 -0
- package/src/components/Box/__tests__/index.spec.tsx +155 -0
- package/src/components/Box/config.ts +201 -0
- package/src/components/Box/helpers.ts +10 -0
- package/src/components/Box/index.tsx +13 -0
- package/src/components/Box/types.ts +38 -0
- package/src/components/Calendar/__tests__/index.spec.tsx +13 -17
- package/src/components/Card/DataCard/StyledDataCard.tsx +8 -2
- package/src/components/Card/DataCard/__tests__/StyledDataCard.spec.tsx +1 -0
- package/src/components/Card/DataCard/__tests__/__snapshots__/StyledDataCard.spec.tsx.snap +16 -0
- package/src/components/Card/DataCard/index.tsx +1 -1
- package/src/components/Card/StyledCard.tsx +12 -19
- package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +147 -0
- package/src/components/Card/__tests__/index.spec.tsx +18 -0
- package/src/components/Card/index.tsx +6 -1
- package/src/components/Drawer/DragableDrawer/helpers.ts +3 -4
- package/src/components/FAB/ActionGroup/index.tsx +6 -8
- package/src/components/RichTextEditor/EditorToolbar.tsx +19 -18
- package/src/components/RichTextEditor/RichTextEditor.tsx +7 -2
- package/src/components/RichTextEditor/StyledRichTextEditor.ts +0 -2
- package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +11 -12
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +2 -10
- package/src/components/RichTextEditor/constants.ts +0 -11
- package/src/components/RichTextEditor/index.tsx +0 -3
- package/src/components/RichTextEditor/types.ts +9 -0
- package/src/components/SectionHeading/__tests__/__snapshots__/StyledHeading.spec.tsx.snap +1 -1
- package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +22 -20
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +22 -20
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
- package/src/components/Spinner/AnimatedSpinner.tsx +7 -7
- package/src/components/Spinner/StyledSpinner.tsx +24 -19
- package/src/components/Spinner/__tests__/AnimatedSpinner.spec.tsx +1 -1
- package/src/components/Spinner/__tests__/StyledSpinner.spec.tsx +32 -16
- package/src/components/Spinner/__tests__/__snapshots__/AnimatedSpinner.spec.tsx.snap +14 -12
- package/src/components/Spinner/__tests__/__snapshots__/StyledSpinner.spec.tsx.snap +273 -31
- package/src/components/Spinner/__tests__/__snapshots__/index.spec.tsx.snap +14 -12
- package/src/components/Spinner/index.tsx +10 -2
- package/src/components/Tabs/ScrollableTabs.tsx +9 -4
- package/src/components/Tabs/StyledScrollableTabs.tsx +6 -5
- package/src/components/Tabs/StyledTabs.tsx +6 -0
- package/src/components/Tabs/TabWithBadge.tsx +68 -0
- package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +13 -0
- package/src/components/Tabs/__tests__/TabWithBadge.spec.tsx +48 -0
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +205 -43
- package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +165 -0
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +135 -34
- package/src/components/Tabs/__tests__/index.spec.tsx +12 -0
- package/src/components/Tabs/index.tsx +11 -4
- package/src/components/Tag/StyledTag.tsx +1 -11
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +4 -4
- package/src/components/Tag/index.tsx +2 -2
- package/src/components/TextInput/__tests__/index.spec.tsx +10 -14
- package/src/components/Toast/StyledToast.tsx +13 -7
- package/src/components/Toast/Toast.tsx +34 -9
- package/src/components/Toast/ToastProvider.tsx +15 -12
- package/src/components/Toast/__tests__/Toast.spec.tsx +17 -0
- package/src/components/Toast/__tests__/__snapshots__/Toast.spec.tsx.snap +299 -19
- package/src/components/Toast/types.ts +15 -1
- package/src/components/Typography/Text/StyledText.tsx +7 -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 +7 -1
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +76 -23
- package/src/theme/components/.eslintrc.json +10 -0
- package/src/theme/components/alert.ts +5 -1
- package/src/theme/components/avatar.ts +2 -0
- package/src/theme/components/card.ts +6 -7
- package/src/theme/components/sectionHeading.ts +1 -1
- package/src/theme/components/spinner.ts +19 -7
- package/src/theme/components/tabs.ts +3 -2
- package/src/theme/components/tag.ts +13 -13
- package/src/theme/components/toast.ts +17 -3
- package/src/theme/components/typography.ts +2 -0
- package/src/theme/global/colors/swag.ts +23 -0
- package/src/theme/global/colors/types.ts +23 -0
- package/src/theme/global/colors/work.ts +5 -0
- package/src/types.ts +0 -2
- package/tsconfig.json +4 -15
- package/types/components/Accordion/StyledAccordion.d.ts +14 -14
- package/types/components/Alert/StyledAlert.d.ts +16 -16
- package/types/components/Alert/index.d.ts +1 -1
- package/types/components/Avatar/StyledAvatar.d.ts +16 -16
- package/types/components/Avatar/index.d.ts +2 -2
- package/types/components/Badge/StyledBadge.d.ts +7 -7
- package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +21 -21
- package/types/components/BottomSheet/Header.d.ts +1 -1
- package/types/components/BottomSheet/StyledBottomSheet.d.ts +19 -19
- package/types/components/Box/StyledBox.d.ts +15 -0
- package/types/components/Box/__tests__/helpers.spec.d.ts +1 -0
- package/types/components/Box/__tests__/index.spec.d.ts +1 -0
- package/types/components/Box/config.d.ts +170 -0
- package/types/components/Box/helpers.d.ts +1 -0
- package/types/components/Box/index.d.ts +5 -0
- package/types/components/Box/types.d.ts +31 -0
- package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +7 -7
- package/types/components/Button/StyledButton.d.ts +16 -16
- package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +8 -8
- package/types/components/Calendar/StyledCalendar.d.ts +25 -25
- package/types/components/Calendar/helpers.d.ts +2 -2
- package/types/components/Card/DataCard/StyledDataCard.d.ts +7 -7
- package/types/components/Card/DataCard/index.d.ts +1 -1
- package/types/components/Card/StyledCard.d.ts +7 -6
- package/types/components/Card/index.d.ts +5 -1
- package/types/components/Checkbox/StyledCheckbox.d.ts +10 -10
- package/types/components/Collapse/StyledCollapse.d.ts +8 -8
- package/types/components/ContentNavigator/StyledContentNavigator.d.ts +5 -5
- package/types/components/DatePicker/StyledDatePicker.d.ts +3 -3
- package/types/components/Divider/StyledDivider.d.ts +5 -5
- package/types/components/Drawer/StyledDrawer.d.ts +19 -19
- package/types/components/Empty/StyledEmpty.d.ts +12 -12
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +11 -11
- package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +7 -7
- package/types/components/FAB/StyledFAB.d.ts +8 -8
- package/types/components/Icon/HeroIcon/index.d.ts +3 -3
- package/types/components/List/StyledBasicListItem.d.ts +14 -14
- package/types/components/List/StyledListItem.d.ts +23 -23
- package/types/components/PinInput/StyledPinInput.d.ts +30 -30
- package/types/components/Progress/StyledProgressBar.d.ts +5 -5
- package/types/components/Progress/StyledProgressCircle.d.ts +18 -18
- package/types/components/Radio/StyledRadio.d.ts +9 -9
- package/types/components/RichTextEditor/EditorToolbar.d.ts +2 -2
- package/types/components/RichTextEditor/MentionList.d.ts +1 -1
- package/types/components/RichTextEditor/RichTextEditor.d.ts +4 -0
- package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +6 -6
- package/types/components/RichTextEditor/StyledToolbar.d.ts +9 -9
- package/types/components/RichTextEditor/constants.d.ts +0 -10
- package/types/components/RichTextEditor/index.d.ts +2 -4
- package/types/components/RichTextEditor/types.d.ts +1 -0
- package/types/components/SectionHeading/StyledHeading.d.ts +9 -9
- package/types/components/Select/MultiSelect/Option.d.ts +1 -1
- package/types/components/Select/SingleSelect/Option.d.ts +1 -1
- package/types/components/Select/StyledSelect.d.ts +11 -11
- package/types/components/Select/helpers.d.ts +1 -1
- package/types/components/Spinner/AnimatedSpinner.d.ts +3 -1
- package/types/components/Spinner/StyledSpinner.d.ts +14 -12
- package/types/components/Spinner/index.d.ts +5 -1
- package/types/components/Switch/StyledSwitch.d.ts +5 -5
- package/types/components/Tabs/StyledScrollableTabs.d.ts +24 -22
- package/types/components/Tabs/StyledTabs.d.ts +26 -20
- package/types/components/Tabs/TabWithBadge.d.ts +17 -0
- package/types/components/Tabs/__tests__/TabWithBadge.spec.d.ts +1 -0
- package/types/components/Tabs/index.d.ts +3 -1
- package/types/components/Tag/StyledTag.d.ts +6 -6
- package/types/components/Tag/index.d.ts +1 -1
- package/types/components/TextInput/StyledTextInput.d.ts +44 -44
- package/types/components/TextInput/index.d.ts +5 -5
- package/types/components/TimePicker/StyledTimePicker.d.ts +3 -3
- package/types/components/Toast/StyledToast.d.ts +19 -18
- package/types/components/Toast/types.d.ts +2 -1
- package/types/components/Toolbar/StyledToolbar.d.ts +9 -9
- package/types/components/Typography/Text/StyledText.d.ts +4 -4
- package/types/components/Typography/Text/index.d.ts +1 -1
- package/types/index.d.ts +2 -1
- package/types/testHelpers/renderWithTheme.d.ts +1 -1
- package/types/theme/ThemeSwitcher.d.ts +1 -1
- package/types/theme/components/alert.d.ts +5 -1
- package/types/theme/components/avatar.d.ts +2 -0
- package/types/theme/components/card.d.ts +6 -7
- package/types/theme/components/spinner.d.ts +17 -5
- package/types/theme/components/tabs.d.ts +1 -0
- package/types/theme/components/tag.d.ts +2 -2
- package/types/theme/components/toast.d.ts +18 -2
- package/types/theme/components/typography.d.ts +2 -0
- package/types/theme/global/colors/types.d.ts +17 -0
- package/types/theme/global/index.d.ts +17 -0
- package/types/types.d.ts +1 -2
- package/types/utils/hooks.d.ts +1 -1
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
4
4
|
import Card from '..';
|
|
5
|
+
import Typography from '../../Typography';
|
|
5
6
|
|
|
6
7
|
describe('Card', () => {
|
|
7
8
|
it('renders basic card', () => {
|
|
@@ -27,4 +28,21 @@ describe('Card', () => {
|
|
|
27
28
|
expect(queryAllByTestId('child-view')).toHaveLength(1);
|
|
28
29
|
expect(queryAllByTestId('data-card-indicator')).toHaveLength(1);
|
|
29
30
|
});
|
|
31
|
+
|
|
32
|
+
it.each`
|
|
33
|
+
intent
|
|
34
|
+
${undefined}
|
|
35
|
+
${'primary'}
|
|
36
|
+
${'success'}
|
|
37
|
+
${'info'}
|
|
38
|
+
`('renders correctly when intent is $intent', ({ intent }) => {
|
|
39
|
+
const { toJSON, getByText } = renderWithTheme(
|
|
40
|
+
<Card intent={intent}>
|
|
41
|
+
<Typography.Text>Card Content</Typography.Text>
|
|
42
|
+
</Card>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
expect(getByText('Card Content')).toBeDefined();
|
|
46
|
+
expect(toJSON()).toMatchSnapshot();
|
|
47
|
+
});
|
|
30
48
|
});
|
|
@@ -9,6 +9,10 @@ interface CardProps extends ViewProps {
|
|
|
9
9
|
* Card's content.
|
|
10
10
|
*/
|
|
11
11
|
children?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Visual intent color to apply to card.
|
|
14
|
+
*/
|
|
15
|
+
intent?: 'primary' | 'success' | 'warning';
|
|
12
16
|
/**
|
|
13
17
|
* Card type.
|
|
14
18
|
* This is now deprecated. If you want to use "data" variant, please use Card.Data instead.
|
|
@@ -27,10 +31,11 @@ interface CardProps extends ViewProps {
|
|
|
27
31
|
|
|
28
32
|
const Card = ({
|
|
29
33
|
variant = 'basic',
|
|
34
|
+
intent,
|
|
30
35
|
children,
|
|
31
36
|
...nativeProps
|
|
32
37
|
}: CardProps): JSX.Element => (
|
|
33
|
-
<StyledCard {...nativeProps} themeVariant={variant}>
|
|
38
|
+
<StyledCard {...nativeProps} themeVariant={variant} themeIntent={intent}>
|
|
34
39
|
{variant === 'data' && <LeftDataCard testID="data-card-indicator" />}
|
|
35
40
|
{children}
|
|
36
41
|
</StyledCard>
|
|
@@ -17,10 +17,9 @@ export const calculateSnapPointsData = (
|
|
|
17
17
|
snapPoints: number[]
|
|
18
18
|
): SnapPointsData => {
|
|
19
19
|
const filteredSnapPoints = snapPoints.filter(value => value >= minimumHeight);
|
|
20
|
-
const snapPointsOffsetValues = [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
].map(value => getOffset(height, value));
|
|
20
|
+
const snapPointsOffsetValues = [minimumHeight, ...filteredSnapPoints].map(
|
|
21
|
+
value => getOffset(height, value)
|
|
22
|
+
);
|
|
24
23
|
const uniqSnapPointOffsetValues = Array.from(
|
|
25
24
|
new Set([...snapPointsOffsetValues, 0])
|
|
26
25
|
);
|
|
@@ -97,19 +97,17 @@ const ActionGroup = ({
|
|
|
97
97
|
outputRange: [400, 0],
|
|
98
98
|
}
|
|
99
99
|
);
|
|
100
|
-
const interpolatedBackdropOpacityAnimation =
|
|
101
|
-
{
|
|
100
|
+
const interpolatedBackdropOpacityAnimation =
|
|
101
|
+
tranlateXAnimation.current.interpolate({
|
|
102
102
|
inputRange: [0, 1],
|
|
103
103
|
outputRange: [0, 0.9],
|
|
104
|
-
}
|
|
105
|
-
);
|
|
104
|
+
});
|
|
106
105
|
|
|
107
|
-
const interpolatedActionGroupOpacityAnimation =
|
|
108
|
-
{
|
|
106
|
+
const interpolatedActionGroupOpacityAnimation =
|
|
107
|
+
tranlateXAnimation.current.interpolate({
|
|
109
108
|
inputRange: [0, 1],
|
|
110
109
|
outputRange: [0, 1],
|
|
111
|
-
}
|
|
112
|
-
);
|
|
110
|
+
});
|
|
113
111
|
|
|
114
112
|
return (
|
|
115
113
|
<StyledContainer testID={testID} pointerEvents="box-none" style={style}>
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import type { ComponentType } from 'react';
|
|
3
3
|
import Icon from '../Icon';
|
|
4
|
-
import {
|
|
4
|
+
import { ToolbarEvents } from './constants';
|
|
5
5
|
import { emitter } from './EditorEvent';
|
|
6
6
|
import {
|
|
7
7
|
StyledSeparator,
|
|
8
8
|
StyledToolbar,
|
|
9
9
|
StyledToolbarButton,
|
|
10
10
|
} from './StyledToolbar';
|
|
11
|
+
import { ToolbarButtonName } from './types';
|
|
11
12
|
import * as Events from './utils/events';
|
|
12
13
|
import type { IconProps } from '../Icon';
|
|
13
14
|
|
|
@@ -35,34 +36,34 @@ interface ButtonConfig {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
const buttonConfigs: Partial<Record<ToolbarButtonName, ButtonConfig>> = {
|
|
38
|
-
|
|
39
|
+
bold: {
|
|
39
40
|
icon: 'format-bold',
|
|
40
41
|
eventName: ToolbarEvents.Bold,
|
|
41
42
|
},
|
|
42
|
-
|
|
43
|
+
italic: {
|
|
43
44
|
icon: 'format-italic',
|
|
44
45
|
eventName: ToolbarEvents.Italic,
|
|
45
46
|
},
|
|
46
|
-
|
|
47
|
+
underline: {
|
|
47
48
|
icon: 'format-underlined',
|
|
48
49
|
eventName: ToolbarEvents.Underline,
|
|
49
50
|
},
|
|
50
|
-
|
|
51
|
+
bulletedList: {
|
|
51
52
|
icon: 'format-list-bulleted',
|
|
52
53
|
eventName: ToolbarEvents.BulletedList,
|
|
53
54
|
standalone: true,
|
|
54
55
|
},
|
|
55
|
-
|
|
56
|
+
numberedList: {
|
|
56
57
|
icon: 'format-list-numbered',
|
|
57
58
|
eventName: ToolbarEvents.NumberedList,
|
|
58
59
|
standalone: true,
|
|
59
60
|
},
|
|
60
|
-
|
|
61
|
+
headingOne: {
|
|
61
62
|
icon: 'format-heading1',
|
|
62
63
|
eventName: ToolbarEvents.HeadingOne,
|
|
63
64
|
standalone: true,
|
|
64
65
|
},
|
|
65
|
-
|
|
66
|
+
headingTwo: {
|
|
66
67
|
icon: 'format-heading2',
|
|
67
68
|
eventName: ToolbarEvents.HeadingTwo,
|
|
68
69
|
standalone: true,
|
|
@@ -70,15 +71,15 @@ const buttonConfigs: Partial<Record<ToolbarButtonName, ButtonConfig>> = {
|
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
const defaultButtons: ToolbarButtonName[] = [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
'bold',
|
|
75
|
+
'italic',
|
|
76
|
+
'underline',
|
|
77
|
+
'|',
|
|
78
|
+
'bulletedList',
|
|
79
|
+
'numberedList',
|
|
80
|
+
'|',
|
|
81
|
+
'headingOne',
|
|
82
|
+
'headingTwo',
|
|
82
83
|
];
|
|
83
84
|
|
|
84
85
|
export interface EditorToolbarProps {
|
|
@@ -180,7 +181,7 @@ const EditorToolbar = ({
|
|
|
180
181
|
const toolbarButtons = useMemo(
|
|
181
182
|
() =>
|
|
182
183
|
toolbarButtonArray.map(button => {
|
|
183
|
-
if (button.buttonName ===
|
|
184
|
+
if (button.buttonName === '|') {
|
|
184
185
|
return <StyledSeparator key={button.id} />;
|
|
185
186
|
}
|
|
186
187
|
const config = buttonConfigs[button.buttonName];
|
|
@@ -51,6 +51,10 @@ export type EditorValue = {
|
|
|
51
51
|
}[];
|
|
52
52
|
|
|
53
53
|
export interface RichTextEditorProps {
|
|
54
|
+
/**
|
|
55
|
+
* If true, the editor will be focused when the user enters the screen
|
|
56
|
+
*/
|
|
57
|
+
autoFocus?: boolean;
|
|
54
58
|
/**
|
|
55
59
|
* Error message
|
|
56
60
|
*/
|
|
@@ -110,6 +114,7 @@ const defaultValue: EditorValue = [
|
|
|
110
114
|
];
|
|
111
115
|
|
|
112
116
|
const RichTextEditor: ComponentType<RichTextEditorProps> = ({
|
|
117
|
+
autoFocus = true,
|
|
113
118
|
name,
|
|
114
119
|
placeholder = '',
|
|
115
120
|
onChange = noop,
|
|
@@ -191,7 +196,7 @@ const RichTextEditor: ComponentType<RichTextEditorProps> = ({
|
|
|
191
196
|
placeholder: "${placeholder}",
|
|
192
197
|
initialValue: ${initialValueString},
|
|
193
198
|
isAndroid: ${isAndroid ? 'true' : 'false'},
|
|
194
|
-
autoFocus:
|
|
199
|
+
autoFocus: ${autoFocus},
|
|
195
200
|
style: {
|
|
196
201
|
padding: '0 !important',
|
|
197
202
|
fontSize: ${theme.__hd__.richTextEditor.fontSizes.editor}
|
|
@@ -305,7 +310,7 @@ const RichTextEditor: ComponentType<RichTextEditorProps> = ({
|
|
|
305
310
|
);
|
|
306
311
|
|
|
307
312
|
return (
|
|
308
|
-
<StyledContainer
|
|
313
|
+
<StyledContainer testID={testID}>
|
|
309
314
|
<StyledTextInputContainer>
|
|
310
315
|
<StyledBorderBackDrop themeVariant={variant} />
|
|
311
316
|
{(isFocused || (label && !isEmptyValue)) && (
|
|
@@ -14,7 +14,5 @@ export const StyledWebView = styled(WebView)<{
|
|
|
14
14
|
backgroundColor: 'transparent',
|
|
15
15
|
textAlignVertical: 'center',
|
|
16
16
|
fontSize: theme.__hd__.textInput.fontSizes.text,
|
|
17
|
-
alignSelf: 'stretch',
|
|
18
|
-
flexGrow: 2,
|
|
19
17
|
marginHorizontal: theme.__hd__.textInput.space.inputHorizontalMargin,
|
|
20
18
|
}));
|
|
@@ -94,10 +94,13 @@ describe('RichTextEditor', () => {
|
|
|
94
94
|
Events.on(EditorEventEmitter, 'rich-text-editor/editor-focus', () => {
|
|
95
95
|
emittedEvents.push('called');
|
|
96
96
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
|
|
98
|
+
act(() => {
|
|
99
|
+
onMessageOfLatestRendering({
|
|
100
|
+
nativeEvent: {
|
|
101
|
+
data: '{"type": "@hero-editor/webview/editor-focus", "data" : {}}',
|
|
102
|
+
},
|
|
103
|
+
});
|
|
101
104
|
});
|
|
102
105
|
expect(emittedEvents).toMatchObject(['called']);
|
|
103
106
|
});
|
|
@@ -126,8 +129,7 @@ describe('RichTextEditor', () => {
|
|
|
126
129
|
});
|
|
127
130
|
onMessageOfLatestRendering({
|
|
128
131
|
nativeEvent: {
|
|
129
|
-
data:
|
|
130
|
-
'{"type": "@hero-editor/webview/mention-search", "data" : {}}',
|
|
132
|
+
data: '{"type": "@hero-editor/webview/mention-search", "data" : {}}',
|
|
131
133
|
},
|
|
132
134
|
});
|
|
133
135
|
expect(emittedEvents).toMatchObject(['called']);
|
|
@@ -142,8 +144,7 @@ describe('RichTextEditor', () => {
|
|
|
142
144
|
it('should call onChange', () => {
|
|
143
145
|
onMessageOfLatestRendering({
|
|
144
146
|
nativeEvent: {
|
|
145
|
-
data:
|
|
146
|
-
'{"type": "@hero-editor/webview/editor-change", "data" : { "value": "text"}}',
|
|
147
|
+
data: '{"type": "@hero-editor/webview/editor-change", "data" : { "value": "text"}}',
|
|
147
148
|
},
|
|
148
149
|
});
|
|
149
150
|
expect(onChangeMock).lastCalledWith('text');
|
|
@@ -158,8 +159,7 @@ describe('RichTextEditor', () => {
|
|
|
158
159
|
it('should call onCursorChange', () => {
|
|
159
160
|
onMessageOfLatestRendering({
|
|
160
161
|
nativeEvent: {
|
|
161
|
-
data:
|
|
162
|
-
'{"type": "@hero-editor/webview/cursor-change", "data" : { "position": 32}}',
|
|
162
|
+
data: '{"type": "@hero-editor/webview/cursor-change", "data" : { "position": 32}}',
|
|
163
163
|
},
|
|
164
164
|
});
|
|
165
165
|
expect(onCursorChangeMock).lastCalledWith({ position: 32 });
|
|
@@ -171,8 +171,7 @@ describe('RichTextEditor', () => {
|
|
|
171
171
|
act(() => {
|
|
172
172
|
onMessageOfLatestRendering({
|
|
173
173
|
nativeEvent: {
|
|
174
|
-
data:
|
|
175
|
-
'{"type": "@hero-editor/webview/editor-layout", "data" : { "width": 320, "height": 480}}',
|
|
174
|
+
data: '{"type": "@hero-editor/webview/editor-layout", "data" : { "width": 320, "height": 480}}',
|
|
176
175
|
},
|
|
177
176
|
});
|
|
178
177
|
});
|
|
@@ -8,9 +8,7 @@ exports[`RichTextEditor onMessage recevied event editor-layout should update hei
|
|
|
8
8
|
"marginVertical": 8,
|
|
9
9
|
"width": "100%",
|
|
10
10
|
},
|
|
11
|
-
|
|
12
|
-
"backgroundColor": "yellow",
|
|
13
|
-
},
|
|
11
|
+
undefined,
|
|
14
12
|
]
|
|
15
13
|
}
|
|
16
14
|
>
|
|
@@ -163,9 +161,7 @@ exports[`RichTextEditor onMessage recevied event editor-layout should update hei
|
|
|
163
161
|
style={
|
|
164
162
|
Array [
|
|
165
163
|
Object {
|
|
166
|
-
"alignSelf": "stretch",
|
|
167
164
|
"backgroundColor": "transparent",
|
|
168
|
-
"flexGrow": 2,
|
|
169
165
|
"fontSize": 14,
|
|
170
166
|
"height": 480,
|
|
171
167
|
"marginHorizontal": 8,
|
|
@@ -272,9 +268,7 @@ exports[`RichTextEditor should render correctly 1`] = `
|
|
|
272
268
|
"marginVertical": 8,
|
|
273
269
|
"width": "100%",
|
|
274
270
|
},
|
|
275
|
-
|
|
276
|
-
"backgroundColor": "yellow",
|
|
277
|
-
},
|
|
271
|
+
undefined,
|
|
278
272
|
]
|
|
279
273
|
}
|
|
280
274
|
>
|
|
@@ -426,9 +420,7 @@ exports[`RichTextEditor should render correctly 1`] = `
|
|
|
426
420
|
style={
|
|
427
421
|
Array [
|
|
428
422
|
Object {
|
|
429
|
-
"alignSelf": "stretch",
|
|
430
423
|
"backgroundColor": "transparent",
|
|
431
|
-
"flexGrow": 2,
|
|
432
424
|
"fontSize": 14,
|
|
433
425
|
"height": undefined,
|
|
434
426
|
"marginHorizontal": 8,
|
|
@@ -7,14 +7,3 @@ export enum ToolbarEvents {
|
|
|
7
7
|
HeadingOne = 'heading-one',
|
|
8
8
|
HeadingTwo = 'heading-two',
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
export enum ToolbarButtonName {
|
|
12
|
-
Bold = 'bold',
|
|
13
|
-
Italic = 'italic',
|
|
14
|
-
Underline = 'underline',
|
|
15
|
-
BulletedList = 'bulletedList',
|
|
16
|
-
NumberedList = 'numberedList',
|
|
17
|
-
HeadingOne = 'headingOne',
|
|
18
|
-
HeadingTwo = 'headingTwo',
|
|
19
|
-
Seperator = '|',
|
|
20
|
-
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ToolbarButtonName } from './constants';
|
|
2
1
|
import Toolbar from './EditorToolbar';
|
|
3
2
|
import MentionList from './MentionList';
|
|
4
3
|
import RichTextEditor from './RichTextEditor';
|
|
@@ -6,8 +5,6 @@ import type { RichTextEditorProps, RichTextEditorRef } from './RichTextEditor';
|
|
|
6
5
|
|
|
7
6
|
export type { RichTextEditorProps, RichTextEditorRef };
|
|
8
7
|
|
|
9
|
-
export { ToolbarButtonName };
|
|
10
|
-
|
|
11
8
|
export default Object.assign(RichTextEditor, {
|
|
12
9
|
MentionList,
|
|
13
10
|
Toolbar,
|
|
@@ -6,7 +6,7 @@ exports[`SectionHeading allows to customise the icon 1`] = `
|
|
|
6
6
|
Array [
|
|
7
7
|
Object {
|
|
8
8
|
"alignContent": "center",
|
|
9
|
-
"backgroundColor": "#
|
|
9
|
+
"backgroundColor": "#f6f6f7",
|
|
10
10
|
"display": "flex",
|
|
11
11
|
"flexDirection": "row",
|
|
12
12
|
"justifyContent": "space-between",
|
|
@@ -83,7 +83,7 @@ exports[`SectionHeading render icon correctly 1`] = `
|
|
|
83
83
|
Array [
|
|
84
84
|
Object {
|
|
85
85
|
"alignContent": "center",
|
|
86
|
-
"backgroundColor": "#
|
|
86
|
+
"backgroundColor": "#f6f6f7",
|
|
87
87
|
"display": "flex",
|
|
88
88
|
"flexDirection": "row",
|
|
89
89
|
"justifyContent": "space-between",
|
|
@@ -161,7 +161,7 @@ exports[`SectionHeading render right children correctly 1`] = `
|
|
|
161
161
|
Array [
|
|
162
162
|
Object {
|
|
163
163
|
"alignContent": "center",
|
|
164
|
-
"backgroundColor": "#
|
|
164
|
+
"backgroundColor": "#f6f6f7",
|
|
165
165
|
"display": "flex",
|
|
166
166
|
"flexDirection": "row",
|
|
167
167
|
"justifyContent": "space-between",
|
|
@@ -227,7 +227,7 @@ exports[`SectionHeading renders correctly 1`] = `
|
|
|
227
227
|
Array [
|
|
228
228
|
Object {
|
|
229
229
|
"alignContent": "center",
|
|
230
|
-
"backgroundColor": "#
|
|
230
|
+
"backgroundColor": "#f6f6f7",
|
|
231
231
|
"display": "flex",
|
|
232
232
|
"flexDirection": "row",
|
|
233
233
|
"justifyContent": "space-between",
|
|
@@ -74,7 +74,7 @@ exports[`OptionList render isLoading correctly 1`] = `
|
|
|
74
74
|
Array [
|
|
75
75
|
Object {
|
|
76
76
|
"alignContent": "center",
|
|
77
|
-
"backgroundColor": "#
|
|
77
|
+
"backgroundColor": "#f6f6f7",
|
|
78
78
|
"display": "flex",
|
|
79
79
|
"flexDirection": "row",
|
|
80
80
|
"justifyContent": "space-between",
|
|
@@ -323,7 +323,7 @@ exports[`OptionList render isLoading correctly 1`] = `
|
|
|
323
323
|
Array [
|
|
324
324
|
Object {
|
|
325
325
|
"alignContent": "center",
|
|
326
|
-
"backgroundColor": "#
|
|
326
|
+
"backgroundColor": "#f6f6f7",
|
|
327
327
|
"display": "flex",
|
|
328
328
|
"flexDirection": "row",
|
|
329
329
|
"justifyContent": "space-between",
|
|
@@ -713,6 +713,7 @@ exports[`OptionList render isLoading correctly 1`] = `
|
|
|
713
713
|
]
|
|
714
714
|
}
|
|
715
715
|
themePosition="top"
|
|
716
|
+
themeSize="medium"
|
|
716
717
|
>
|
|
717
718
|
<View
|
|
718
719
|
collapsable={false}
|
|
@@ -720,16 +721,16 @@ exports[`OptionList render isLoading correctly 1`] = `
|
|
|
720
721
|
style={
|
|
721
722
|
Array [
|
|
722
723
|
Object {
|
|
723
|
-
"backgroundColor": "#
|
|
724
|
-
"borderRadius":
|
|
724
|
+
"backgroundColor": "#795e90",
|
|
725
|
+
"borderRadius": 999,
|
|
725
726
|
"height": 16,
|
|
726
|
-
"opacity": 1,
|
|
727
727
|
"width": 16,
|
|
728
728
|
},
|
|
729
729
|
Object {},
|
|
730
730
|
]
|
|
731
731
|
}
|
|
732
732
|
themePosition="topLeft"
|
|
733
|
+
themeSize="medium"
|
|
733
734
|
/>
|
|
734
735
|
<View
|
|
735
736
|
collapsable={false}
|
|
@@ -737,17 +738,17 @@ exports[`OptionList render isLoading correctly 1`] = `
|
|
|
737
738
|
style={
|
|
738
739
|
Array [
|
|
739
740
|
Object {
|
|
740
|
-
"backgroundColor": "#
|
|
741
|
-
"borderRadius":
|
|
741
|
+
"backgroundColor": "#a08cb0",
|
|
742
|
+
"borderRadius": 999,
|
|
742
743
|
"height": 16,
|
|
743
744
|
"marginLeft": 8,
|
|
744
|
-
"opacity": 0.7,
|
|
745
745
|
"width": 16,
|
|
746
746
|
},
|
|
747
747
|
Object {},
|
|
748
748
|
]
|
|
749
749
|
}
|
|
750
750
|
themePosition="topRight"
|
|
751
|
+
themeSize="medium"
|
|
751
752
|
/>
|
|
752
753
|
</View>
|
|
753
754
|
<View
|
|
@@ -763,6 +764,7 @@ exports[`OptionList render isLoading correctly 1`] = `
|
|
|
763
764
|
]
|
|
764
765
|
}
|
|
765
766
|
themePosition="bottom"
|
|
767
|
+
themeSize="medium"
|
|
766
768
|
>
|
|
767
769
|
<View
|
|
768
770
|
collapsable={false}
|
|
@@ -770,16 +772,16 @@ exports[`OptionList render isLoading correctly 1`] = `
|
|
|
770
772
|
style={
|
|
771
773
|
Array [
|
|
772
774
|
Object {
|
|
773
|
-
"backgroundColor": "#
|
|
774
|
-
"borderRadius":
|
|
775
|
+
"backgroundColor": "#d9d1df",
|
|
776
|
+
"borderRadius": 999,
|
|
775
777
|
"height": 16,
|
|
776
|
-
"opacity": 0.5,
|
|
777
778
|
"width": 16,
|
|
778
779
|
},
|
|
779
780
|
Object {},
|
|
780
781
|
]
|
|
781
782
|
}
|
|
782
783
|
themePosition="bottomLeft"
|
|
784
|
+
themeSize="medium"
|
|
783
785
|
/>
|
|
784
786
|
<View
|
|
785
787
|
collapsable={false}
|
|
@@ -787,17 +789,17 @@ exports[`OptionList render isLoading correctly 1`] = `
|
|
|
787
789
|
style={
|
|
788
790
|
Array [
|
|
789
791
|
Object {
|
|
790
|
-
"backgroundColor": "#
|
|
791
|
-
"borderRadius":
|
|
792
|
+
"backgroundColor": "#ece8ef",
|
|
793
|
+
"borderRadius": 999,
|
|
792
794
|
"height": 16,
|
|
793
795
|
"marginLeft": 8,
|
|
794
|
-
"opacity": 0.3,
|
|
795
796
|
"width": 16,
|
|
796
797
|
},
|
|
797
798
|
Object {},
|
|
798
799
|
]
|
|
799
800
|
}
|
|
800
801
|
themePosition="bottomRight"
|
|
802
|
+
themeSize="medium"
|
|
801
803
|
/>
|
|
802
804
|
</View>
|
|
803
805
|
</View>
|
|
@@ -871,7 +873,7 @@ exports[`OptionList renders correctly 1`] = `
|
|
|
871
873
|
Array [
|
|
872
874
|
Object {
|
|
873
875
|
"alignContent": "center",
|
|
874
|
-
"backgroundColor": "#
|
|
876
|
+
"backgroundColor": "#f6f6f7",
|
|
875
877
|
"display": "flex",
|
|
876
878
|
"flexDirection": "row",
|
|
877
879
|
"justifyContent": "space-between",
|
|
@@ -1120,7 +1122,7 @@ exports[`OptionList renders correctly 1`] = `
|
|
|
1120
1122
|
Array [
|
|
1121
1123
|
Object {
|
|
1122
1124
|
"alignContent": "center",
|
|
1123
|
-
"backgroundColor": "#
|
|
1125
|
+
"backgroundColor": "#f6f6f7",
|
|
1124
1126
|
"display": "flex",
|
|
1125
1127
|
"flexDirection": "row",
|
|
1126
1128
|
"justifyContent": "space-between",
|
|
@@ -1518,7 +1520,7 @@ exports[`OptionList trigger onPress correctly on changing selection 1`] = `
|
|
|
1518
1520
|
Array [
|
|
1519
1521
|
Object {
|
|
1520
1522
|
"alignContent": "center",
|
|
1521
|
-
"backgroundColor": "#
|
|
1523
|
+
"backgroundColor": "#f6f6f7",
|
|
1522
1524
|
"display": "flex",
|
|
1523
1525
|
"flexDirection": "row",
|
|
1524
1526
|
"justifyContent": "space-between",
|
|
@@ -1767,7 +1769,7 @@ exports[`OptionList trigger onPress correctly on changing selection 1`] = `
|
|
|
1767
1769
|
Array [
|
|
1768
1770
|
Object {
|
|
1769
1771
|
"alignContent": "center",
|
|
1770
|
-
"backgroundColor": "#
|
|
1772
|
+
"backgroundColor": "#f6f6f7",
|
|
1771
1773
|
"display": "flex",
|
|
1772
1774
|
"flexDirection": "row",
|
|
1773
1775
|
"justifyContent": "space-between",
|
|
@@ -2190,7 +2192,7 @@ exports[`OptionList trigger onPress correctly on select additional value 1`] = `
|
|
|
2190
2192
|
Array [
|
|
2191
2193
|
Object {
|
|
2192
2194
|
"alignContent": "center",
|
|
2193
|
-
"backgroundColor": "#
|
|
2195
|
+
"backgroundColor": "#f6f6f7",
|
|
2194
2196
|
"display": "flex",
|
|
2195
2197
|
"flexDirection": "row",
|
|
2196
2198
|
"justifyContent": "space-between",
|
|
@@ -2439,7 +2441,7 @@ exports[`OptionList trigger onPress correctly on select additional value 1`] = `
|
|
|
2439
2441
|
Array [
|
|
2440
2442
|
Object {
|
|
2441
2443
|
"alignContent": "center",
|
|
2442
|
-
"backgroundColor": "#
|
|
2444
|
+
"backgroundColor": "#f6f6f7",
|
|
2443
2445
|
"display": "flex",
|
|
2444
2446
|
"flexDirection": "row",
|
|
2445
2447
|
"justifyContent": "space-between",
|
|
@@ -450,7 +450,7 @@ Array [
|
|
|
450
450
|
Array [
|
|
451
451
|
Object {
|
|
452
452
|
"alignContent": "center",
|
|
453
|
-
"backgroundColor": "#
|
|
453
|
+
"backgroundColor": "#f6f6f7",
|
|
454
454
|
"display": "flex",
|
|
455
455
|
"flexDirection": "row",
|
|
456
456
|
"justifyContent": "space-between",
|
|
@@ -853,7 +853,7 @@ Array [
|
|
|
853
853
|
Array [
|
|
854
854
|
Object {
|
|
855
855
|
"alignContent": "center",
|
|
856
|
-
"backgroundColor": "#
|
|
856
|
+
"backgroundColor": "#f6f6f7",
|
|
857
857
|
"display": "flex",
|
|
858
858
|
"flexDirection": "row",
|
|
859
859
|
"justifyContent": "space-between",
|
|
@@ -6337,7 +6337,7 @@ Array [
|
|
|
6337
6337
|
Array [
|
|
6338
6338
|
Object {
|
|
6339
6339
|
"alignContent": "center",
|
|
6340
|
-
"backgroundColor": "#
|
|
6340
|
+
"backgroundColor": "#f6f6f7",
|
|
6341
6341
|
"display": "flex",
|
|
6342
6342
|
"flexDirection": "row",
|
|
6343
6343
|
"justifyContent": "space-between",
|
|
@@ -6561,7 +6561,7 @@ Array [
|
|
|
6561
6561
|
Array [
|
|
6562
6562
|
Object {
|
|
6563
6563
|
"alignContent": "center",
|
|
6564
|
-
"backgroundColor": "#
|
|
6564
|
+
"backgroundColor": "#f6f6f7",
|
|
6565
6565
|
"display": "flex",
|
|
6566
6566
|
"flexDirection": "row",
|
|
6567
6567
|
"justifyContent": "space-between",
|