@hero-design/rn 8.85.0 → 8.87.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/.turbo/turbo-build.log +8 -2
- package/CHANGELOG.md +18 -0
- package/es/index.js +10763 -8758
- package/lib/index.js +10763 -8758
- package/package.json +2 -2
- package/src/components/Button/Button.tsx +22 -6
- package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +8 -2
- package/src/components/Button/LoadingIndicator/__tests__/StyledLoadingIndicator.spec.tsx +3 -0
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +139 -1
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +408 -3
- package/src/components/Button/LoadingIndicator/__tests__/index.spec.tsx +3 -0
- package/src/components/Button/LoadingIndicator/index.tsx +4 -1
- package/src/components/Button/StyledButton.tsx +95 -5
- package/src/components/Button/__tests__/Button.spec.tsx +12 -0
- package/src/components/Button/__tests__/StyledButton.spec.tsx +10 -0
- package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +1240 -90
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +630 -40
- package/src/components/Carousel/CardCarousel.tsx +7 -2
- package/src/components/Carousel/StyledCardCarousel.tsx +6 -2
- package/src/components/Carousel/__tests__/CardCarousel.spec.tsx +28 -1
- package/src/components/Carousel/__tests__/StyledCardCarousel.spec.tsx +7 -2
- package/src/components/Carousel/__tests__/__snapshots__/CardCarousel.spec.tsx.snap +1799 -1
- package/src/components/Carousel/__tests__/__snapshots__/StyledCardCarousel.spec.tsx.snap +86 -1
- package/src/components/RichTextEditor/RichTextEditor.tsx +30 -1
- package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +59 -0
- package/src/components/RichTextEditor/types.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +10 -1
- package/src/theme/components/button.ts +5 -0
- package/src/theme/components/cardCarousel.ts +5 -1
- package/stats/8.86.0/rn-stats.html +4842 -0
- package/stats/8.87.0/rn-stats.html +4844 -0
- package/stats/8.87.1/rn-stats.html +4842 -0
- package/types/components/Button/Button.d.ts +1 -1
- package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +1 -1
- package/types/components/Button/LoadingIndicator/index.d.ts +1 -1
- package/types/components/Button/StyledButton.d.ts +3 -3
- package/types/components/Carousel/CardCarousel.d.ts +4 -0
- package/types/components/Carousel/StyledCardCarousel.d.ts +2 -0
- package/types/components/RichTextEditor/RichTextEditor.d.ts +4 -0
- package/types/components/RichTextEditor/types.d.ts +1 -0
- package/types/theme/components/button.d.ts +5 -0
- package/types/theme/components/cardCarousel.d.ts +5 -1
|
@@ -50,7 +50,7 @@ exports[`StyledCard should render correctly 1`] = `
|
|
|
50
50
|
</View>
|
|
51
51
|
`;
|
|
52
52
|
|
|
53
|
-
exports[`StyledItemWrapper should render correctly 1`] = `
|
|
53
|
+
exports[`StyledItemWrapper should render correctly with gap=medium 1`] = `
|
|
54
54
|
<View
|
|
55
55
|
style={
|
|
56
56
|
{
|
|
@@ -67,6 +67,91 @@ exports[`StyledItemWrapper should render correctly 1`] = `
|
|
|
67
67
|
undefined,
|
|
68
68
|
]
|
|
69
69
|
}
|
|
70
|
+
themeGap="medium"
|
|
71
|
+
/>
|
|
72
|
+
<View
|
|
73
|
+
pointerEvents="box-none"
|
|
74
|
+
position="bottom"
|
|
75
|
+
style={
|
|
76
|
+
[
|
|
77
|
+
{
|
|
78
|
+
"bottom": 0,
|
|
79
|
+
"elevation": 9999,
|
|
80
|
+
"flexDirection": "column-reverse",
|
|
81
|
+
"left": 0,
|
|
82
|
+
"paddingHorizontal": 24,
|
|
83
|
+
"paddingVertical": 16,
|
|
84
|
+
"position": "absolute",
|
|
85
|
+
"right": 0,
|
|
86
|
+
"top": 0,
|
|
87
|
+
},
|
|
88
|
+
undefined,
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
/>
|
|
92
|
+
</View>
|
|
93
|
+
`;
|
|
94
|
+
|
|
95
|
+
exports[`StyledItemWrapper should render correctly with gap=small 1`] = `
|
|
96
|
+
<View
|
|
97
|
+
style={
|
|
98
|
+
{
|
|
99
|
+
"flex": 1,
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
>
|
|
103
|
+
<View
|
|
104
|
+
style={
|
|
105
|
+
[
|
|
106
|
+
{
|
|
107
|
+
"padding": 4,
|
|
108
|
+
},
|
|
109
|
+
undefined,
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
themeGap="small"
|
|
113
|
+
/>
|
|
114
|
+
<View
|
|
115
|
+
pointerEvents="box-none"
|
|
116
|
+
position="bottom"
|
|
117
|
+
style={
|
|
118
|
+
[
|
|
119
|
+
{
|
|
120
|
+
"bottom": 0,
|
|
121
|
+
"elevation": 9999,
|
|
122
|
+
"flexDirection": "column-reverse",
|
|
123
|
+
"left": 0,
|
|
124
|
+
"paddingHorizontal": 24,
|
|
125
|
+
"paddingVertical": 16,
|
|
126
|
+
"position": "absolute",
|
|
127
|
+
"right": 0,
|
|
128
|
+
"top": 0,
|
|
129
|
+
},
|
|
130
|
+
undefined,
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
/>
|
|
134
|
+
</View>
|
|
135
|
+
`;
|
|
136
|
+
|
|
137
|
+
exports[`StyledItemWrapper should render correctly with gap=xsmall 1`] = `
|
|
138
|
+
<View
|
|
139
|
+
style={
|
|
140
|
+
{
|
|
141
|
+
"flex": 1,
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
>
|
|
145
|
+
<View
|
|
146
|
+
style={
|
|
147
|
+
[
|
|
148
|
+
{
|
|
149
|
+
"padding": 2,
|
|
150
|
+
},
|
|
151
|
+
undefined,
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
themeGap="xsmall"
|
|
70
155
|
/>
|
|
71
156
|
<View
|
|
72
157
|
pointerEvents="box-none"
|
|
@@ -38,9 +38,13 @@ import * as Events from './utils/events';
|
|
|
38
38
|
import { postMessage, requestBlurEditor } from './utils/rnWebView';
|
|
39
39
|
import type { WebViewEventMessage } from './utils/rnWebView';
|
|
40
40
|
import { LABEL_ANIMATION_DURATION } from '../TextInput';
|
|
41
|
+
import { TextUnit } from './types';
|
|
41
42
|
|
|
42
43
|
export interface RichTextEditorRef {
|
|
43
44
|
requestBlur: VoidFunction;
|
|
45
|
+
insertNodes: (nodes: Record<string, unknown>[]) => void;
|
|
46
|
+
deleteBackward: (unit?: TextUnit) => void;
|
|
47
|
+
setReadOnly: (readOnly: boolean) => void;
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
export type EditorValue = {
|
|
@@ -236,7 +240,32 @@ const RichTextEditor: ComponentType<RichTextEditorProps> = ({
|
|
|
236
240
|
}
|
|
237
241
|
}, [isFocused]);
|
|
238
242
|
|
|
239
|
-
|
|
243
|
+
const insertNodes = useCallback((nodes: Record<string, unknown>[]) => {
|
|
244
|
+
postMessageToWebview({
|
|
245
|
+
type: '@hero-editor/webview/editor-insert-nodes',
|
|
246
|
+
data: { nodes },
|
|
247
|
+
});
|
|
248
|
+
}, []);
|
|
249
|
+
|
|
250
|
+
const deleteBackward = useCallback((unit?: TextUnit) => {
|
|
251
|
+
postMessageToWebview({
|
|
252
|
+
type: '@hero-editor/webview/editor-delete-backward',
|
|
253
|
+
data: { unit },
|
|
254
|
+
});
|
|
255
|
+
}, []);
|
|
256
|
+
|
|
257
|
+
const setReadOnly = useCallback((readOnly: boolean) => {
|
|
258
|
+
postMessageToWebview({
|
|
259
|
+
type: '@hero-editor/webview/editor-read-only',
|
|
260
|
+
data: { readOnly },
|
|
261
|
+
});
|
|
262
|
+
}, []);
|
|
263
|
+
|
|
264
|
+
useImperativeHandle(
|
|
265
|
+
forwardedRef,
|
|
266
|
+
() => ({ requestBlur, insertNodes, deleteBackward, setReadOnly }),
|
|
267
|
+
[requestBlur, deleteBackward, insertNodes, setReadOnly]
|
|
268
|
+
);
|
|
240
269
|
|
|
241
270
|
/* Forward events from Toolbar and MentionList to webview */
|
|
242
271
|
useEffect(() => {
|
|
@@ -58,6 +58,7 @@ jest.mock('../utils/rnWebView', () => {
|
|
|
58
58
|
/* eslint-disable */
|
|
59
59
|
/// @ts-ignore
|
|
60
60
|
import { postMessageMock } from '../utils/rnWebView';
|
|
61
|
+
import { RichTextEditorRef } from "../../../../types";
|
|
61
62
|
/* eslint-enable */
|
|
62
63
|
|
|
63
64
|
describe('RichTextEditor', () => {
|
|
@@ -205,6 +206,64 @@ describe('RichTextEditor', () => {
|
|
|
205
206
|
});
|
|
206
207
|
});
|
|
207
208
|
|
|
209
|
+
describe('RichTextEditorRef methods', () => {
|
|
210
|
+
let ref: React.RefObject<RichTextEditorRef>;
|
|
211
|
+
|
|
212
|
+
beforeEach(() => {
|
|
213
|
+
ref = React.createRef<RichTextEditorRef>();
|
|
214
|
+
renderWithTheme(
|
|
215
|
+
<RichTextEditor
|
|
216
|
+
name="rich-text-editor"
|
|
217
|
+
label="Rich Text Editor"
|
|
218
|
+
onChange={jest.fn()}
|
|
219
|
+
onCursorChange={jest.fn()}
|
|
220
|
+
error="this is error"
|
|
221
|
+
style={{ backgroundColor: 'yellow' }}
|
|
222
|
+
ref={ref}
|
|
223
|
+
/>
|
|
224
|
+
);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('should call insertNodes', () => {
|
|
228
|
+
const nodes = [{ text: 'test' }];
|
|
229
|
+
|
|
230
|
+
act(() => {
|
|
231
|
+
ref.current?.insertNodes(nodes);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
expect(postMessageMock).toHaveBeenCalledWith({
|
|
235
|
+
data: { nodes },
|
|
236
|
+
type: '@hero-editor/webview/editor-insert-nodes',
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('should call deleteBackward', () => {
|
|
241
|
+
const unit = 'word';
|
|
242
|
+
|
|
243
|
+
act(() => {
|
|
244
|
+
ref.current?.deleteBackward(unit);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
expect(postMessageMock).toHaveBeenCalledWith({
|
|
248
|
+
data: { unit },
|
|
249
|
+
type: '@hero-editor/webview/editor-delete-backward',
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('should call setReadOnly', () => {
|
|
254
|
+
const readOnly = true;
|
|
255
|
+
|
|
256
|
+
act(() => {
|
|
257
|
+
ref.current?.setReadOnly(readOnly);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
expect(postMessageMock).toHaveBeenCalledWith({
|
|
261
|
+
data: { readOnly },
|
|
262
|
+
type: '@hero-editor/webview/editor-read-only',
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
208
267
|
describe('postMessageToWebview', () => {
|
|
209
268
|
const onChangeMock = jest.fn();
|
|
210
269
|
const onCursorChangeMock = jest.fn();
|
|
@@ -254,22 +254,27 @@ exports[`theme returns correct theme object 1`] = `
|
|
|
254
254
|
"filledDanger": "#fcebe7",
|
|
255
255
|
"filledPrimary": "#33144d",
|
|
256
256
|
"filledSecondary": "#33144d",
|
|
257
|
+
"filledWhite": "#ece8ef",
|
|
257
258
|
"outlineDanger": "#fcebe7",
|
|
259
|
+
"outlineWhite": "#33144d",
|
|
258
260
|
"outlinedPrimary": "#ece8ef",
|
|
259
261
|
"outlinedSecondary": "#ece8ef",
|
|
260
262
|
"textDanger": "#fcebe7",
|
|
261
263
|
"textPrimary": "#ece8ef",
|
|
262
264
|
"textSecondary": "#f6f6f7",
|
|
265
|
+
"textWhite": "#33144d",
|
|
263
266
|
},
|
|
264
267
|
"pressedText": {
|
|
265
268
|
"danger": "#f68282",
|
|
266
269
|
"primary": "#33144d",
|
|
267
270
|
"secondary": "#001f23",
|
|
271
|
+
"white": "#33144d",
|
|
268
272
|
},
|
|
269
273
|
"primary": "#401960",
|
|
270
274
|
"secondary": "#4d6265",
|
|
271
275
|
"textLoadingBackground": "#ece8ef",
|
|
272
276
|
"utilityBackground": "#ffffff",
|
|
277
|
+
"white": "#ffffff",
|
|
273
278
|
},
|
|
274
279
|
"fontSize": {
|
|
275
280
|
"default": 18,
|
|
@@ -361,7 +366,11 @@ exports[`theme returns correct theme object 1`] = `
|
|
|
361
366
|
"card": 8,
|
|
362
367
|
},
|
|
363
368
|
"space": {
|
|
364
|
-
"carouselItemSpacing":
|
|
369
|
+
"carouselItemSpacing": {
|
|
370
|
+
"medium": 8,
|
|
371
|
+
"small": 4,
|
|
372
|
+
"xsmall": 2,
|
|
373
|
+
},
|
|
365
374
|
"contentContainerPaddingHorizontal": 24,
|
|
366
375
|
"pageControlMarginTop": 16,
|
|
367
376
|
},
|
|
@@ -47,6 +47,7 @@ const getButtonTheme = (theme: GlobalTheme) => {
|
|
|
47
47
|
primary: theme.colors.primary,
|
|
48
48
|
secondary: theme.colors.mutedOnDefaultGlobalSurface,
|
|
49
49
|
danger: theme.colors.onErrorSurface,
|
|
50
|
+
white: theme.colors.defaultGlobalSurface,
|
|
50
51
|
defaultText: theme.colors.onDefaultGlobalSurface,
|
|
51
52
|
disabledText: theme.colors.disabledOnDefaultGlobalSurface,
|
|
52
53
|
disabledBorder: theme.colors.disabledOnDefaultGlobalSurface,
|
|
@@ -58,17 +59,21 @@ const getButtonTheme = (theme: GlobalTheme) => {
|
|
|
58
59
|
filledPrimary: theme.colors.pressedSurface,
|
|
59
60
|
filledSecondary: theme.colors.pressedSurface,
|
|
60
61
|
filledDanger: theme.colors.errorSurface,
|
|
62
|
+
filledWhite: theme.colors.highlightedSurface,
|
|
61
63
|
outlinedPrimary: theme.colors.highlightedSurface,
|
|
62
64
|
outlinedSecondary: theme.colors.highlightedSurface,
|
|
63
65
|
outlineDanger: theme.colors.errorSurface,
|
|
66
|
+
outlineWhite: theme.colors.pressedSurface,
|
|
64
67
|
textPrimary: theme.colors.highlightedSurface,
|
|
65
68
|
textSecondary: theme.colors.neutralGlobalSurface,
|
|
66
69
|
textDanger: theme.colors.errorSurface,
|
|
70
|
+
textWhite: theme.colors.pressedSurface,
|
|
67
71
|
},
|
|
68
72
|
pressedText: {
|
|
69
73
|
primary: theme.colors.pressedSurface,
|
|
70
74
|
secondary: theme.colors.onDefaultGlobalSurface,
|
|
71
75
|
danger: theme.colors.mutedError,
|
|
76
|
+
white: theme.colors.pressedSurface,
|
|
72
77
|
},
|
|
73
78
|
};
|
|
74
79
|
|
|
@@ -3,8 +3,12 @@ import type { GlobalTheme } from '../global';
|
|
|
3
3
|
const getCardCarouselTheme = (theme: GlobalTheme) => {
|
|
4
4
|
const space = {
|
|
5
5
|
pageControlMarginTop: theme.space.medium,
|
|
6
|
-
carouselItemSpacing: theme.space.small,
|
|
7
6
|
contentContainerPaddingHorizontal: theme.space.large,
|
|
7
|
+
carouselItemSpacing: {
|
|
8
|
+
xsmall: theme.space.xxsmall,
|
|
9
|
+
small: theme.space.xsmall,
|
|
10
|
+
medium: theme.space.small,
|
|
11
|
+
},
|
|
8
12
|
};
|
|
9
13
|
|
|
10
14
|
const colors = {
|