@hero-design/rn 8.112.3 → 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.
Files changed (32) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/CHANGELOG.md +6 -0
  3. package/es/index.js +4 -13
  4. package/lib/index.js +4 -13
  5. package/package.json +1 -1
  6. package/src/components/Box/StyledBox.tsx +1 -1
  7. package/src/components/Calendar/CalendarRowItem.tsx +1 -1
  8. package/src/components/Carousel/index.tsx +1 -1
  9. package/src/components/RichTextEditor/RichTextEditor.tsx +5 -5
  10. package/src/components/RichTextEditor/{BaseRichTextEditor.tsx → RichTextEditorInput.tsx} +4 -4
  11. package/src/components/RichTextEditor/StyledRichTextEditor.ts +0 -5
  12. package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +19 -4
  13. package/src/components/RichTextEditor/index.tsx +3 -3
  14. package/src/components/RichTextEditor/utils/events.ts +0 -12
  15. package/src/components/Select/helpers.tsx +0 -17
  16. package/src/components/Tabs/StyledTabs.tsx +0 -5
  17. package/src/components/TextInput/index.tsx +1 -1
  18. package/src/theme/global/colors/swagSystemPalette.ts +1 -1
  19. package/src/utils/scale.ts +2 -2
  20. package/types/components/Box/StyledBox.d.ts +0 -5
  21. package/types/components/Calendar/CalendarRowItem.d.ts +0 -1
  22. package/types/components/Carousel/index.d.ts +0 -1
  23. package/types/components/RichTextEditor/RichTextEditor.d.ts +2 -2
  24. package/types/components/RichTextEditor/{BaseRichTextEditor.d.ts → RichTextEditorInput.d.ts} +3 -3
  25. package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +0 -7
  26. package/types/components/RichTextEditor/index.d.ts +2 -2
  27. package/types/components/RichTextEditor/utils/events.d.ts +0 -2
  28. package/types/components/Select/helpers.d.ts +0 -1
  29. package/types/components/Tabs/StyledTabs.d.ts +1 -7
  30. package/types/components/TextInput/index.d.ts +0 -1
  31. package/types/theme/global/colors/swagSystemPalette.d.ts +1 -1
  32. 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",
3
+ "version": "8.112.4",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -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
- export const getThemeValue = (
9
+ const getThemeValue = (
10
10
  theme: Theme,
11
11
  key: keyof StyleProps,
12
12
  props: StyleProps
@@ -6,7 +6,7 @@ import {
6
6
  StyledMark,
7
7
  } from './StyledCalendar';
8
8
 
9
- export const getCellVariant = (
9
+ const getCellVariant = (
10
10
  isSelected = false,
11
11
  isCurrent = false,
12
12
  isHighlighted = false
@@ -61,7 +61,7 @@ interface CarouselProps extends ViewProps {
61
61
  pageControlPosition?: 'top' | 'bottom';
62
62
  }
63
63
 
64
- export function useStateFromProp<T>(
64
+ function useStateFromProp<T>(
65
65
  initialValue: T
66
66
  ): [T, Dispatch<SetStateAction<T>>] {
67
67
  const [value, setValue] = useState(initialValue);
@@ -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 BaseRichTextEditor from './BaseRichTextEditor';
32
+ import RichTextEditorInput from './RichTextEditorInput';
33
33
  import type {
34
- BaseRichTextEditorProps,
34
+ RichTextEditorInputProps,
35
35
  RichTextEditorRef,
36
- } from './BaseRichTextEditor';
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<BaseRichTextEditorProps, 'editorRef'> {
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
- <BaseRichTextEditor
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 BaseRichTextEditorProps {
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 BaseRichTextEditor = ({
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
- }: BaseRichTextEditorProps): ReactElement => {
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 BaseRichTextEditor;
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 '../BaseRichTextEditor';
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 BaseRichTextEditor from './BaseRichTextEditor';
8
- import type { RichTextEditorRef } from './BaseRichTextEditor';
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: BaseRichTextEditor,
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
- export const getDisplayText = (value?: string, defaultValue?: string) => {
308
+ const getDisplayText = (value?: string, defaultValue?: string) => {
309
309
  return (value !== undefined ? value : defaultValue) ?? '';
310
310
  };
311
311
 
@@ -1,7 +1,7 @@
1
1
  import ehWorkSystemPalette from './ehWork';
2
2
  import type { SystemPalette } from './types';
3
3
 
4
- export const swagSystemPalette: SystemPalette = {
4
+ const swagSystemPalette: SystemPalette = {
5
5
  ...ehWorkSystemPalette,
6
6
  name: 'swagLight',
7
7
  };
@@ -1,8 +1,8 @@
1
1
  import { Dimensions, Platform } from 'react-native';
2
2
 
3
- export const BASE_WIDTH = 390; // Based on iPhone 13's viewport size
3
+ const BASE_WIDTH = 390; // Based on iPhone 13's viewport size
4
4
 
5
- export const horizontalScale = (size: number) => {
5
+ const horizontalScale = (size: number) => {
6
6
  if (Platform.OS === 'web') {
7
7
  return size;
8
8
  }
@@ -1,11 +1,6 @@
1
1
  import type { Theme } from '@emotion/react';
2
2
  import { View } from 'react-native';
3
3
  import type { FlexStyleProps, StyleProps } from './types';
4
- export declare const getThemeValue: (theme: Theme, key: keyof StyleProps, props: StyleProps) => {
5
- [x: string]: string | undefined;
6
- } | {
7
- [x: string]: number;
8
- } | undefined;
9
4
  declare const StyledBox: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
10
5
  theme?: Theme;
11
6
  as?: React.ElementType;
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- export declare const getCellVariant: (isSelected?: boolean, isCurrent?: boolean, isHighlighted?: boolean) => "default" | "highlighted" | "current" | "selected";
3
2
  export interface CalendarRowItemProps {
4
3
  date?: Date;
5
4
  onPress?: () => void;
@@ -40,7 +40,6 @@ interface CarouselProps extends ViewProps {
40
40
  */
41
41
  pageControlPosition?: 'top' | 'bottom';
42
42
  }
43
- export declare function useStateFromProp<T>(initialValue: T): [T, Dispatch<SetStateAction<T>>];
44
43
  declare const _default: (({ items, onItemIndexChange, renderActions, selectedItemIndex, style, shouldShowPagination, testID, pageControlPosition, ...nativeProps }: CarouselProps) => React.JSX.Element) & {
45
44
  Card: React.ForwardRefExoticComponent<Omit<import("./CardCarousel").CardCarouselProps, "ref"> & React.RefAttributes<import("./CardCarousel").CardCarouselHandles>>;
46
45
  };
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
2
  import type { Ref } from 'react';
3
- import type { BaseRichTextEditorProps, RichTextEditorRef } from './BaseRichTextEditor';
3
+ import type { RichTextEditorInputProps, RichTextEditorRef } from './RichTextEditorInput';
4
4
  export type EditorValue = {
5
5
  type: string;
6
6
  children: any;
7
7
  }[];
8
- export interface RichTextEditorProps extends Omit<BaseRichTextEditorProps, 'editorRef'> {
8
+ export interface RichTextEditorProps extends Omit<RichTextEditorInputProps, 'editorRef'> {
9
9
  /**
10
10
  * Field label
11
11
  */
@@ -11,7 +11,7 @@ export type EditorValue = {
11
11
  type: string;
12
12
  children: any;
13
13
  }[];
14
- export interface BaseRichTextEditorProps {
14
+ export interface RichTextEditorInputProps {
15
15
  /**
16
16
  * If true, the editor will be focused when the user enters the screen
17
17
  */
@@ -65,5 +65,5 @@ export interface BaseRichTextEditorProps {
65
65
  */
66
66
  onBlur?: () => void;
67
67
  }
68
- declare const BaseRichTextEditor: ({ autoFocus, name, placeholder, onChange, onCursorChange, style, testID, editorRef, value, onFocus, onBlur, }: BaseRichTextEditorProps) => ReactElement;
69
- export default BaseRichTextEditor;
68
+ declare const RichTextEditorInput: ({ autoFocus, name, placeholder, onChange, onCursorChange, style, testID, editorRef, value, onFocus, onBlur, }: RichTextEditorInputProps) => ReactElement;
69
+ export default RichTextEditorInput;
@@ -1,11 +1,4 @@
1
- import { View } from 'react-native';
2
1
  import { WebView } from 'react-native-webview';
3
- export declare const StyledWrapper: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
4
- theme?: import("@emotion/react").Theme;
5
- as?: React.ElementType;
6
- }, {}, {
7
- ref?: import("react").Ref<View> | undefined;
8
- }>;
9
2
  export declare const StyledWebView: import("@emotion/native").StyledComponent<import("react-native-webview/lib/WebViewTypes").IOSWebViewProps & import("react-native-webview/lib/WebViewTypes").AndroidWebViewProps & import("react-native-webview/lib/WebViewTypes").WindowsWebViewProps & {
10
3
  theme?: import("@emotion/react").Theme;
11
4
  as?: React.ElementType;
@@ -1,6 +1,6 @@
1
1
  import { EditorEvents, ToolbarEvents } from './constants';
2
2
  import type { RichTextEditorProps } from './RichTextEditor';
3
- import type { RichTextEditorRef } from './BaseRichTextEditor';
3
+ import type { RichTextEditorRef } from './RichTextEditorInput';
4
4
  export type { RichTextEditorProps, RichTextEditorRef };
5
5
  declare const _default: import("react").ForwardRefExoticComponent<Omit<RichTextEditorProps, "forwardedRef"> & import("react").RefAttributes<RichTextEditorRef>> & {
6
6
  Toolbar: ({ name, buttons, testID, }: import("./EditorToolbar").EditorToolbarProps) => import("react").JSX.Element | null;
@@ -66,6 +66,6 @@ declare const _default: import("react").ForwardRefExoticComponent<Omit<RichTextE
66
66
  };
67
67
  }[TEventName] : void) => void) => () => void;
68
68
  };
69
- Base: ({ autoFocus, name, placeholder, onChange, onCursorChange, style, testID, editorRef, value, onFocus, onBlur, }: import("./BaseRichTextEditor").BaseRichTextEditorProps) => import("react").ReactElement;
69
+ Base: ({ autoFocus, name, placeholder, onChange, onCursorChange, style, testID, editorRef, value, onFocus, onBlur, }: import("./RichTextEditorInput").RichTextEditorInputProps) => import("react").ReactElement;
70
70
  };
71
71
  export default _default;
@@ -2,7 +2,5 @@ import type { EventEmitter } from 'events';
2
2
  export interface Listener<T> {
3
3
  (data: T): void;
4
4
  }
5
- export declare const off: <T>(emitter: EventEmitter, eventName: string, listener: Listener<T>) => void;
6
5
  export declare const emit: <T>(emitter: EventEmitter, eventName: string, data: T) => boolean;
7
- export declare const setMaxListeners: (emitter: EventEmitter, n: number) => void;
8
6
  export declare const on: <T>(emitter: EventEmitter, eventName: string, listener: Listener<T>) => () => void;
@@ -1,5 +1,4 @@
1
1
  import type { SectionData, CombinedOptionsType, SelectOptionType } from './types';
2
- export declare const getKey: <V, T extends SelectOptionType<V>>(option: T, index: number, keyExtractor?: (opt: T, i?: number) => string) => string | number;
3
2
  export declare const isSections: <V, T extends SelectOptionType<V>>(options: CombinedOptionsType<V, T>) => options is SectionData<V, T>[];
4
3
  export declare const toSections: <V, T extends SelectOptionType<V>>(options: CombinedOptionsType<V, T>) => SectionData<V, T>[];
5
4
  export declare const toFlatOptions: <V, T extends SelectOptionType<V>>(options: CombinedOptionsType<V, T>) => SelectOptionType<V>[];
@@ -30,12 +30,6 @@ declare const HeaderTabItem: import("@emotion/native").StyledComponent<import("r
30
30
  }, {}, {
31
31
  ref?: import("react").Ref<View> | undefined;
32
32
  }>;
33
- declare const TabScreen: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
34
- theme?: import("@emotion/react").Theme;
35
- as?: React.ElementType;
36
- }, {}, {
37
- ref?: import("react").Ref<View> | undefined;
38
- }>;
39
33
  declare const StyledIndicator: import("@emotion/native").StyledComponent<Animated.AnimatedProps<import("react-native").ViewProps & import("react").RefAttributes<View>> & {
40
34
  theme?: import("@emotion/react").Theme;
41
35
  as?: React.ElementType;
@@ -48,4 +42,4 @@ declare const StyledBadgeWrapper: import("@emotion/native").StyledComponent<impo
48
42
  }, {}, {
49
43
  ref?: import("react").Ref<View> | undefined;
50
44
  }>;
51
- export { TabContainer, HeaderTabWrapper, HeaderTab, HeaderTabItem, TabScreen, StyledIndicator, StyledBadgeWrapper, };
45
+ export { TabContainer, HeaderTabWrapper, HeaderTab, HeaderTabItem, StyledIndicator, StyledBadgeWrapper, };
@@ -132,6 +132,5 @@ export declare const renderMaxLengthMessage: ({ maxLength, state, currentLength,
132
132
  maxLength?: number;
133
133
  hideCharacterCount: boolean;
134
134
  }) => false | React.JSX.Element;
135
- export declare const getDisplayText: (value?: string, defaultValue?: string) => string;
136
135
  declare const TextInput: React.ForwardRefExoticComponent<Omit<TextInputProps, "ref"> & React.RefAttributes<TextInputHandles>>;
137
136
  export default TextInput;
@@ -1,3 +1,3 @@
1
1
  import type { SystemPalette } from './types';
2
- export declare const swagSystemPalette: SystemPalette;
2
+ declare const swagSystemPalette: SystemPalette;
3
3
  export default swagSystemPalette;
@@ -1,3 +1 @@
1
- export declare const BASE_WIDTH = 390;
2
- export declare const horizontalScale: (size: number) => number;
3
1
  export declare const scale: (size: number, factor?: number) => number;