@hero-design/rn 8.112.2 → 8.112.4
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/CHANGELOG.md +12 -0
- package/es/index.js +6 -13
- package/lib/index.js +6 -13
- package/package.json +1 -8
- package/src/components/Box/StyledBox.tsx +1 -1
- package/src/components/Calendar/CalendarRowItem.tsx +1 -1
- package/src/components/Carousel/index.tsx +1 -1
- package/src/components/PinInput/StyledPinInput.tsx +1 -0
- package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
- package/src/components/RichTextEditor/RichTextEditor.tsx +5 -5
- package/src/components/RichTextEditor/{BaseRichTextEditor.tsx → RichTextEditorInput.tsx} +4 -4
- package/src/components/RichTextEditor/StyledRichTextEditor.ts +0 -5
- package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +19 -4
- package/src/components/RichTextEditor/index.tsx +3 -3
- package/src/components/RichTextEditor/utils/events.ts +0 -12
- package/src/components/Select/helpers.tsx +0 -17
- package/src/components/Tabs/StyledTabs.tsx +0 -5
- package/src/components/TextInput/index.tsx +1 -1
- package/src/theme/global/colors/swagSystemPalette.ts +1 -1
- package/src/utils/scale.ts +2 -2
- package/stats/8.112.2/rn-stats.html +1 -1
- package/types/components/Box/StyledBox.d.ts +0 -5
- package/types/components/Calendar/CalendarRowItem.d.ts +0 -1
- package/types/components/Carousel/index.d.ts +0 -1
- package/types/components/RichTextEditor/RichTextEditor.d.ts +2 -2
- package/types/components/RichTextEditor/{BaseRichTextEditor.d.ts → RichTextEditorInput.d.ts} +3 -3
- package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +0 -7
- package/types/components/RichTextEditor/index.d.ts +2 -2
- package/types/components/RichTextEditor/utils/events.d.ts +0 -2
- package/types/components/Select/helpers.d.ts +0 -1
- package/types/components/Tabs/StyledTabs.d.ts +1 -7
- package/types/components/TextInput/index.d.ts +0 -1
- package/types/theme/global/colors/swagSystemPalette.d.ts +1 -1
- package/types/utils/scale.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.112.
|
|
3
|
+
"version": "8.112.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -58,15 +58,9 @@
|
|
|
58
58
|
"@hero-design/eslint-plugin": "9.2.1",
|
|
59
59
|
"@hero-design/react-native-month-year-picker": "^8.43.2",
|
|
60
60
|
"@ptomasroos/react-native-multi-slider": "^2.2.2",
|
|
61
|
-
"@react-native-community/cli": "15.0.1",
|
|
62
|
-
"@react-native-community/cli-platform-android": "15.0.1",
|
|
63
|
-
"@react-native-community/cli-platform-ios": "15.0.1",
|
|
64
61
|
"@react-native-community/datetimepicker": "8.2.0",
|
|
65
62
|
"@react-native-community/slider": "^4.5.1",
|
|
66
63
|
"@react-native/babel-preset": "0.77.3",
|
|
67
|
-
"@react-native/eslint-config": "0.77.3",
|
|
68
|
-
"@react-native/metro-config": "0.77.3",
|
|
69
|
-
"@react-native/typescript-config": "0.77.3",
|
|
70
64
|
"@rollup/plugin-babel": "^6.0.4",
|
|
71
65
|
"@rollup/plugin-commonjs": "^28.0.1",
|
|
72
66
|
"@rollup/plugin-json": "^6.1.0",
|
|
@@ -83,7 +77,6 @@
|
|
|
83
77
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
84
78
|
"@typescript-eslint/eslint-plugin": "^5.12.1",
|
|
85
79
|
"babel-plugin-inline-import": "^3.0.0",
|
|
86
|
-
"config-tsconfig": "8.42.5",
|
|
87
80
|
"core-js": "^3.33.0",
|
|
88
81
|
"eslint": "^8.56.0",
|
|
89
82
|
"eslint-config-hd": "8.42.5",
|
|
@@ -6,7 +6,7 @@ import { pick } from '../../utils/helpers';
|
|
|
6
6
|
import type { ConfigType } from './config';
|
|
7
7
|
import config, { flexPropsKey } from './config';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const getThemeValue = (
|
|
10
10
|
theme: Theme,
|
|
11
11
|
key: keyof StyleProps,
|
|
12
12
|
props: StyleProps
|
|
@@ -61,7 +61,7 @@ interface CarouselProps extends ViewProps {
|
|
|
61
61
|
pageControlPosition?: 'top' | 'bottom';
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
function useStateFromProp<T>(
|
|
65
65
|
initialValue: T
|
|
66
66
|
): [T, Dispatch<SetStateAction<T>>] {
|
|
67
67
|
const [value, setValue] = useState(initialValue);
|
|
@@ -73,6 +73,7 @@ export const StyledHiddenInput = styled(TextInput)<{ themePinLength: number }>(
|
|
|
73
73
|
right: 0,
|
|
74
74
|
width: themePinLength * cellWidth + (themePinLength - 1) * spacerWidth,
|
|
75
75
|
height: '100%',
|
|
76
|
+
minHeight: 1, // workaround fix the issue https://employmenthero.atlassian.net/browse/PS-2042
|
|
76
77
|
fontSize: theme.__hd__.pinInput.fontSizes.hiddenInputText,
|
|
77
78
|
letterSpacing: theme.__hd__.pinInput.space.hiddenInputText,
|
|
78
79
|
paddingHorizontal:
|
|
@@ -276,6 +276,7 @@ exports[`rendering renders correctly 1`] = `
|
|
|
276
276
|
"height": "100%",
|
|
277
277
|
"left": 0,
|
|
278
278
|
"letterSpacing": 4,
|
|
279
|
+
"minHeight": 1,
|
|
279
280
|
"opacity": 0.01001,
|
|
280
281
|
"paddingHorizontal": 8,
|
|
281
282
|
"position": "absolute",
|
|
@@ -590,6 +591,7 @@ exports[`rendering renders correctly when disabled 1`] = `
|
|
|
590
591
|
"height": "100%",
|
|
591
592
|
"left": 0,
|
|
592
593
|
"letterSpacing": 4,
|
|
594
|
+
"minHeight": 1,
|
|
593
595
|
"opacity": 0.01001,
|
|
594
596
|
"paddingHorizontal": 8,
|
|
595
597
|
"position": "absolute",
|
|
@@ -1037,6 +1039,7 @@ exports[`rendering renders correctly when length is 6 and secure is false 1`] =
|
|
|
1037
1039
|
"height": "100%",
|
|
1038
1040
|
"left": 0,
|
|
1039
1041
|
"letterSpacing": 4,
|
|
1042
|
+
"minHeight": 1,
|
|
1040
1043
|
"opacity": 0.01001,
|
|
1041
1044
|
"paddingHorizontal": 8,
|
|
1042
1045
|
"position": "absolute",
|
|
@@ -1405,6 +1408,7 @@ exports[`rendering renders correctly when there is error 1`] = `
|
|
|
1405
1408
|
"height": "100%",
|
|
1406
1409
|
"left": 0,
|
|
1407
1410
|
"letterSpacing": 4,
|
|
1411
|
+
"minHeight": 1,
|
|
1408
1412
|
"opacity": 0.01001,
|
|
1409
1413
|
"paddingHorizontal": 8,
|
|
1410
1414
|
"position": "absolute",
|
|
@@ -1720,6 +1724,7 @@ exports[`rendering renders correctly with textContentType and autoComplete 1`] =
|
|
|
1720
1724
|
"height": "100%",
|
|
1721
1725
|
"left": 0,
|
|
1722
1726
|
"letterSpacing": 4,
|
|
1727
|
+
"minHeight": 1,
|
|
1723
1728
|
"opacity": 0.01001,
|
|
1724
1729
|
"paddingHorizontal": 8,
|
|
1725
1730
|
"position": "absolute",
|
|
@@ -29,11 +29,11 @@ import {
|
|
|
29
29
|
} from '../TextInput/StyledTextInput';
|
|
30
30
|
import { LABEL_ANIMATION_DURATION } from '../TextInput';
|
|
31
31
|
import Typography from '../Typography';
|
|
32
|
-
import
|
|
32
|
+
import RichTextEditorInput from './RichTextEditorInput';
|
|
33
33
|
import type {
|
|
34
|
-
|
|
34
|
+
RichTextEditorInputProps,
|
|
35
35
|
RichTextEditorRef,
|
|
36
|
-
} from './
|
|
36
|
+
} from './RichTextEditorInput';
|
|
37
37
|
|
|
38
38
|
export type EditorValue = {
|
|
39
39
|
type: string;
|
|
@@ -41,7 +41,7 @@ export type EditorValue = {
|
|
|
41
41
|
}[];
|
|
42
42
|
|
|
43
43
|
export interface RichTextEditorProps
|
|
44
|
-
extends Omit<
|
|
44
|
+
extends Omit<RichTextEditorInputProps, 'editorRef'> {
|
|
45
45
|
/**
|
|
46
46
|
* Field label
|
|
47
47
|
*/
|
|
@@ -189,7 +189,7 @@ const RichTextEditor = ({
|
|
|
189
189
|
<StyledBorderBackDrop themeState={state} themeFocused={isFocused} />
|
|
190
190
|
|
|
191
191
|
<StyledTextInputAndLabelContainer>
|
|
192
|
-
<
|
|
192
|
+
<RichTextEditorInput
|
|
193
193
|
name={name}
|
|
194
194
|
value={value}
|
|
195
195
|
style={[
|
|
@@ -34,7 +34,7 @@ export type EditorValue = {
|
|
|
34
34
|
children: any;
|
|
35
35
|
}[];
|
|
36
36
|
|
|
37
|
-
export interface
|
|
37
|
+
export interface RichTextEditorInputProps {
|
|
38
38
|
/**
|
|
39
39
|
* If true, the editor will be focused when the user enters the screen
|
|
40
40
|
*/
|
|
@@ -92,7 +92,7 @@ const defaultValue: EditorValue = [
|
|
|
92
92
|
},
|
|
93
93
|
];
|
|
94
94
|
|
|
95
|
-
const
|
|
95
|
+
const RichTextEditorInput = ({
|
|
96
96
|
autoFocus = true,
|
|
97
97
|
name,
|
|
98
98
|
placeholder = '',
|
|
@@ -104,7 +104,7 @@ const BaseRichTextEditor = ({
|
|
|
104
104
|
value = defaultValue,
|
|
105
105
|
onFocus,
|
|
106
106
|
onBlur,
|
|
107
|
-
}:
|
|
107
|
+
}: RichTextEditorInputProps): ReactElement => {
|
|
108
108
|
const theme = useTheme();
|
|
109
109
|
|
|
110
110
|
const webview = useRef<WebView | null>(null);
|
|
@@ -321,4 +321,4 @@ const BaseRichTextEditor = ({
|
|
|
321
321
|
);
|
|
322
322
|
};
|
|
323
323
|
|
|
324
|
-
export default
|
|
324
|
+
export default RichTextEditorInput;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import styled from '@emotion/native';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
2
|
import { WebView } from 'react-native-webview';
|
|
4
3
|
|
|
5
|
-
export const StyledWrapper = styled(View)(({ theme }) => ({
|
|
6
|
-
marginBottom: theme.__hd__.richTextEditor.space.wrapperMarginBottom,
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
4
|
export const StyledWebView = styled(WebView)(({ theme }) => ({
|
|
10
5
|
minHeight: theme.__hd__.richTextEditor.sizes.editorMinHeight,
|
|
11
6
|
backgroundColor: 'transparent',
|
|
@@ -10,7 +10,7 @@ import RichTextEditor from '../RichTextEditor';
|
|
|
10
10
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
11
11
|
import { theme } from '../../../index';
|
|
12
12
|
import HeroDesignProvider from '../../HeroDesignProvider';
|
|
13
|
-
import type { RichTextEditorRef } from '../
|
|
13
|
+
import type { RichTextEditorRef } from '../RichTextEditorInput';
|
|
14
14
|
|
|
15
15
|
type OnMessageCallback = (event: {
|
|
16
16
|
nativeEvent: { data: string };
|
|
@@ -53,12 +53,13 @@ jest.mock('../utils/rnWebView', () => {
|
|
|
53
53
|
},
|
|
54
54
|
postMessageMock,
|
|
55
55
|
onMessageOfLatestRendering: WebView.onMessageOfLatestRendering,
|
|
56
|
+
requestBlurEditor: jest.fn(),
|
|
56
57
|
};
|
|
57
58
|
});
|
|
58
59
|
|
|
59
60
|
/* eslint-disable */
|
|
60
61
|
/// @ts-ignore
|
|
61
|
-
import { postMessageMock } from '../utils/rnWebView';
|
|
62
|
+
import { postMessageMock, requestBlurEditor } from '../utils/rnWebView';
|
|
62
63
|
/* eslint-enable */
|
|
63
64
|
|
|
64
65
|
describe('RichTextEditor', () => {
|
|
@@ -241,8 +242,6 @@ describe('RichTextEditor', () => {
|
|
|
241
242
|
label="Rich Text Editor"
|
|
242
243
|
onChange={jest.fn()}
|
|
243
244
|
onCursorChange={jest.fn()}
|
|
244
|
-
error="this is error"
|
|
245
|
-
style={{ backgroundColor: 'yellow' }}
|
|
246
245
|
ref={ref}
|
|
247
246
|
/>
|
|
248
247
|
);
|
|
@@ -286,6 +285,22 @@ describe('RichTextEditor', () => {
|
|
|
286
285
|
type: '@hero-editor/webview/editor-read-only',
|
|
287
286
|
});
|
|
288
287
|
});
|
|
288
|
+
|
|
289
|
+
it('should post correct message when request blur', () => {
|
|
290
|
+
act(() => {
|
|
291
|
+
onMessageOfLatestRendering({
|
|
292
|
+
nativeEvent: {
|
|
293
|
+
data: '{"type": "@hero-editor/webview/editor-focus", "data" : {}}',
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
act(() => {
|
|
299
|
+
ref.current?.requestBlur();
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
expect(requestBlurEditor).toHaveBeenCalled();
|
|
303
|
+
});
|
|
289
304
|
});
|
|
290
305
|
|
|
291
306
|
describe('postMessageToWebview', () => {
|
|
@@ -4,8 +4,8 @@ import RichTextEditor from './RichTextEditor';
|
|
|
4
4
|
import { EditorEvents, ToolbarEvents } from './constants';
|
|
5
5
|
import useRichTextEditorEvents from './hooks/useRichTextEditorEvents';
|
|
6
6
|
import type { RichTextEditorProps } from './RichTextEditor';
|
|
7
|
-
import
|
|
8
|
-
import type { RichTextEditorRef } from './
|
|
7
|
+
import RichTextEditorInput from './RichTextEditorInput';
|
|
8
|
+
import type { RichTextEditorRef } from './RichTextEditorInput';
|
|
9
9
|
|
|
10
10
|
export type { RichTextEditorProps, RichTextEditorRef };
|
|
11
11
|
|
|
@@ -15,5 +15,5 @@ export default Object.assign(RichTextEditor, {
|
|
|
15
15
|
EditorEvents,
|
|
16
16
|
ToolbarEvents,
|
|
17
17
|
useRichTextEditorEvents,
|
|
18
|
-
Base:
|
|
18
|
+
Base: RichTextEditorInput,
|
|
19
19
|
});
|
|
@@ -4,21 +4,9 @@ export interface Listener<T> {
|
|
|
4
4
|
(data: T): void;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export const off = <T>(
|
|
8
|
-
emitter: EventEmitter,
|
|
9
|
-
eventName: string,
|
|
10
|
-
listener: Listener<T>
|
|
11
|
-
) => {
|
|
12
|
-
emitter.off(eventName, listener);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
7
|
export const emit = <T>(emitter: EventEmitter, eventName: string, data: T) =>
|
|
16
8
|
emitter.emit(eventName, data);
|
|
17
9
|
|
|
18
|
-
export const setMaxListeners = (emitter: EventEmitter, n: number) => {
|
|
19
|
-
emitter.setMaxListeners(n);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
10
|
export const on = <T>(
|
|
23
11
|
emitter: EventEmitter,
|
|
24
12
|
eventName: string,
|
|
@@ -4,23 +4,6 @@ import type {
|
|
|
4
4
|
SelectOptionType,
|
|
5
5
|
} from './types';
|
|
6
6
|
|
|
7
|
-
export const getKey = <V, T extends SelectOptionType<V>>(
|
|
8
|
-
option: T,
|
|
9
|
-
index: number,
|
|
10
|
-
keyExtractor?: (opt: T, i?: number) => string
|
|
11
|
-
) => {
|
|
12
|
-
let key: React.Key = '';
|
|
13
|
-
if (keyExtractor !== undefined) {
|
|
14
|
-
key = keyExtractor(option, index);
|
|
15
|
-
} else if (option.key !== undefined) {
|
|
16
|
-
key = option.key;
|
|
17
|
-
} else {
|
|
18
|
-
key = index;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return key;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
7
|
export const isSections = <V, T extends SelectOptionType<V>>(
|
|
25
8
|
options: CombinedOptionsType<V, T>
|
|
26
9
|
): options is SectionData<V, T>[] => {
|
|
@@ -25,10 +25,6 @@ const HeaderTabItem = styled(View)(({ theme }) => ({
|
|
|
25
25
|
paddingVertical: theme.__hd__.tabs.space.itemVerticalPadding,
|
|
26
26
|
}));
|
|
27
27
|
|
|
28
|
-
const TabScreen = styled(View)({
|
|
29
|
-
flex: 1,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
28
|
const StyledIndicator = styled(Animated.View)<{ themeWidth: number }>(
|
|
33
29
|
({ theme, themeWidth }) => ({
|
|
34
30
|
width: themeWidth,
|
|
@@ -49,7 +45,6 @@ export {
|
|
|
49
45
|
HeaderTabWrapper,
|
|
50
46
|
HeaderTab,
|
|
51
47
|
HeaderTabItem,
|
|
52
|
-
TabScreen,
|
|
53
48
|
StyledIndicator,
|
|
54
49
|
StyledBadgeWrapper,
|
|
55
50
|
};
|
|
@@ -305,7 +305,7 @@ export const renderMaxLengthMessage = ({
|
|
|
305
305
|
);
|
|
306
306
|
};
|
|
307
307
|
|
|
308
|
-
|
|
308
|
+
const getDisplayText = (value?: string, defaultValue?: string) => {
|
|
309
309
|
return (value !== undefined ? value : defaultValue) ?? '';
|
|
310
310
|
};
|
|
311
311
|
|
package/src/utils/scale.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Dimensions, Platform } from 'react-native';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const BASE_WIDTH = 390; // Based on iPhone 13's viewport size
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const horizontalScale = (size: number) => {
|
|
6
6
|
if (Platform.OS === 'web') {
|
|
7
7
|
return size;
|
|
8
8
|
}
|