@hero-design/rn 8.112.3 → 8.112.5

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 (135) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/CHANGELOG.md +12 -0
  3. package/es/index.js +1764 -1372
  4. package/jest.config.js +1 -1
  5. package/lib/index.js +1764 -1372
  6. package/package.json +2 -2
  7. package/src/components/Accordion/AccordionItem.tsx +1 -1
  8. package/src/components/AnimatedScroller/AnimatedScrollable.tsx +1 -1
  9. package/src/components/AnimatedScroller/SectionListWithFAB.tsx +1 -1
  10. package/src/components/Box/StyledBox.tsx +1 -1
  11. package/src/components/Button/UtilityButton/index.tsx +1 -1
  12. package/src/components/Calendar/CalendarRange.tsx +1 -1
  13. package/src/components/Calendar/CalendarRowItem.tsx +2 -2
  14. package/src/components/Calendar/index.tsx +1 -1
  15. package/src/components/Carousel/index.tsx +1 -1
  16. package/src/components/Chart/Line/Line.tsx +3 -4
  17. package/src/components/Chart/index.tsx +0 -2
  18. package/src/components/Chart/shared/ChartHeader.tsx +1 -1
  19. package/src/components/Chart/shared/hooks/useColorScale.ts +2 -2
  20. package/src/components/Chart/shared/hooks/useGenerateTicks.ts +2 -2
  21. package/src/components/Chart/shared/hooks/useScaleBandX.ts +3 -3
  22. package/src/components/Chart/shared/hooks/useScaleLinearY.ts +3 -4
  23. package/src/components/Chart/types.ts +0 -8
  24. package/src/components/Checkbox/utils.ts +1 -1
  25. package/src/components/Chip/index.tsx +1 -1
  26. package/src/components/DatePicker/hooks/__tests__/useFormatDate.spec.ts +7 -5
  27. package/src/components/DatePicker/hooks/useFormatDate.ts +1 -1
  28. package/src/components/DatePicker/types.ts +1 -1
  29. package/src/components/FloatingIsland/index.tsx +1 -1
  30. package/src/components/Illustration/index.tsx +1 -1
  31. package/src/components/List/BasicListItem.tsx +1 -1
  32. package/src/components/List/StyledListItem.tsx +2 -2
  33. package/src/components/LocaleProvider/__tests__/utils.specs.ts +1 -2
  34. package/src/components/LocaleProvider/index.tsx +1 -1
  35. package/src/components/LocaleProvider/utils.ts +2 -3
  36. package/src/components/Portal/index.tsx +1 -1
  37. package/src/components/Portal/types.tsx +2 -2
  38. package/src/components/Radio/Radio.tsx +1 -1
  39. package/src/components/Rate/index.tsx +2 -2
  40. package/src/components/RefreshControl/index.tsx +1 -1
  41. package/src/components/RichTextEditor/RichTextEditor.tsx +6 -6
  42. package/src/components/RichTextEditor/{BaseRichTextEditor.tsx → RichTextEditorInput.tsx} +4 -4
  43. package/src/components/RichTextEditor/StyledRichTextEditor.ts +0 -5
  44. package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +19 -4
  45. package/src/components/RichTextEditor/index.tsx +3 -3
  46. package/src/components/RichTextEditor/utils/events.ts +1 -13
  47. package/src/components/Search/SearchOneLine.tsx +1 -1
  48. package/src/components/Search/StyledSearch.tsx +1 -1
  49. package/src/components/SectionHeading/index.tsx +1 -1
  50. package/src/components/Select/helpers.tsx +1 -18
  51. package/src/components/Skeleton/index.tsx +1 -1
  52. package/src/components/Slider/RangeSlider.tsx +1 -1
  53. package/src/components/StatusScreens/Success/index.tsx +1 -1
  54. package/src/components/Tabs/ScrollableTabsHeader/ScrollableTabsHeader.tsx +1 -1
  55. package/src/components/Tabs/StyledTabs.tsx +0 -5
  56. package/src/components/Tabs/TabWithBadge.tsx +2 -2
  57. package/src/components/TextInput/index.tsx +3 -3
  58. package/src/components/TimePicker/TimePickerAndroid.tsx +1 -1
  59. package/src/components/TimePicker/TimePickerIOS.tsx +1 -1
  60. package/src/components/TimePicker/types.ts +1 -1
  61. package/src/components/Toast/ToastContext.ts +1 -1
  62. package/src/components/Toolbar/index.tsx +1 -1
  63. package/src/components/Typography/Label/index.tsx +1 -1
  64. package/src/theme/global/colors/swagSystemPalette.ts +1 -1
  65. package/src/theme/global/colors/types.ts +1 -1
  66. package/src/theme/global/shadows/index.ts +0 -3
  67. package/src/theme/global/shadows/types.ts +1 -1
  68. package/src/theme/global/sizes.ts +1 -0
  69. package/src/theme/global/typography.ts +2 -1
  70. package/src/utils/scale.ts +2 -2
  71. package/types/components/Accordion/AccordionItem.d.ts +1 -1
  72. package/types/components/AnimatedScroller/AnimatedScrollable.d.ts +1 -1
  73. package/types/components/AnimatedScroller/SectionListWithFAB.d.ts +1 -1
  74. package/types/components/Box/StyledBox.d.ts +0 -5
  75. package/types/components/Button/UtilityButton/index.d.ts +1 -1
  76. package/types/components/Calendar/CalendarRowItem.d.ts +1 -2
  77. package/types/components/Carousel/index.d.ts +0 -1
  78. package/types/components/Chart/index.d.ts +0 -3
  79. package/types/components/Chart/shared/ChartHeader.d.ts +1 -1
  80. package/types/components/Chart/shared/hooks/useScaleBandX.d.ts +2 -3
  81. package/types/components/Chart/shared/hooks/useScaleLinearY.d.ts +2 -3
  82. package/types/components/Chart/types.d.ts +1 -7
  83. package/types/components/Checkbox/utils.d.ts +2 -1
  84. package/types/components/Chip/index.d.ts +1 -1
  85. package/types/components/DatePicker/types.d.ts +1 -1
  86. package/types/components/FloatingIsland/index.d.ts +1 -1
  87. package/types/components/Illustration/index.d.ts +1 -1
  88. package/types/components/List/BasicListItem.d.ts +1 -1
  89. package/types/components/List/StyledListItem.d.ts +2 -2
  90. package/types/components/LocaleProvider/utils.d.ts +1 -1
  91. package/types/components/Portal/index.d.ts +1 -1
  92. package/types/components/Portal/types.d.ts +3 -2
  93. package/types/components/Radio/Radio.d.ts +1 -1
  94. package/types/components/Rate/index.d.ts +2 -2
  95. package/types/components/RefreshControl/index.d.ts +1 -1
  96. package/types/components/RichTextEditor/RichTextEditor.d.ts +2 -6
  97. package/types/components/RichTextEditor/{BaseRichTextEditor.d.ts → RichTextEditorInput.d.ts} +3 -3
  98. package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +0 -7
  99. package/types/components/RichTextEditor/index.d.ts +2 -2
  100. package/types/components/RichTextEditor/utils/events.d.ts +2 -3
  101. package/types/components/Search/SearchOneLine.d.ts +1 -1
  102. package/types/components/Search/StyledSearch.d.ts +2 -1
  103. package/types/components/SectionHeading/index.d.ts +1 -1
  104. package/types/components/Select/helpers.d.ts +2 -2
  105. package/types/components/Skeleton/index.d.ts +1 -1
  106. package/types/components/Slider/RangeSlider.d.ts +1 -1
  107. package/types/components/StatusScreens/Success/index.d.ts +1 -1
  108. package/types/components/Tabs/ScrollableTabsHeader/ScrollableTabsHeader.d.ts +1 -1
  109. package/types/components/Tabs/StyledTabs.d.ts +1 -7
  110. package/types/components/Tabs/TabWithBadge.d.ts +2 -2
  111. package/types/components/TextInput/index.d.ts +2 -3
  112. package/types/components/TimePicker/types.d.ts +1 -1
  113. package/types/components/Toast/ToastContext.d.ts +2 -1
  114. package/types/components/Toolbar/index.d.ts +1 -1
  115. package/types/components/Typography/Label/index.d.ts +1 -1
  116. package/types/theme/components/alert.d.ts +10 -1
  117. package/types/theme/components/bottomNavigation.d.ts +10 -1
  118. package/types/theme/components/chip.d.ts +10 -1
  119. package/types/theme/components/fab.d.ts +10 -1
  120. package/types/theme/components/floatingIsland.d.ts +10 -1
  121. package/types/theme/components/list.d.ts +10 -1
  122. package/types/theme/components/search.d.ts +10 -1
  123. package/types/theme/components/segmentedControl.d.ts +10 -1
  124. package/types/theme/components/slider.d.ts +10 -1
  125. package/types/theme/components/toast.d.ts +10 -1
  126. package/types/theme/global/colors/swagSystemPalette.d.ts +1 -1
  127. package/types/theme/global/colors/types.d.ts +2 -1
  128. package/types/theme/global/index.d.ts +1 -1
  129. package/types/theme/global/shadows/index.d.ts +0 -2
  130. package/types/theme/global/shadows/types.d.ts +2 -1
  131. package/types/theme/global/typography.d.ts +1 -1
  132. package/types/utils/scale.d.ts +0 -2
  133. package/.cursor/rules/performance-optimization.mdc +0 -64
  134. package/.cursor/rules/rn-rules.mdc +0 -165
  135. package/.cursor/rules/testing-rules.mdc +0 -114
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.5",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -23,7 +23,7 @@
23
23
  "@emotion/react": "^11.9.3",
24
24
  "@hero-design/colors": "8.47.0",
25
25
  "d3": "^7.8.5",
26
- "date-fns": "^2.30.0",
26
+ "date-fns": "^4.1.0",
27
27
  "hero-editor": "^1.17.0",
28
28
  "nanoid": "^5.0.9"
29
29
  },
@@ -10,7 +10,7 @@ import Typography from '../Typography';
10
10
  import Icon from '../Icon';
11
11
  import type { Variant } from './StyledAccordion';
12
12
 
13
- export type AccordionItemProps = {
13
+ type AccordionItemProps = {
14
14
  header: string | ReactElement;
15
15
  content: ReactElement;
16
16
  open?: boolean;
@@ -9,7 +9,7 @@ import type { ActionGroupProps } from '../FAB/ActionGroup';
9
9
  import type { FABProps } from '../FAB/FAB';
10
10
  import AnimatedFAB from './AnimatedFAB';
11
11
 
12
- export interface AnimatedScrollerProps<T> {
12
+ interface AnimatedScrollerProps<T> {
13
13
  /**
14
14
  * Scroll component, it can be ScrollView, FlatList or SectionList.
15
15
  */
@@ -5,7 +5,7 @@ import AnimatedScroller from './AnimatedScrollable';
5
5
  import type { ActionGroupProps } from '../FAB/ActionGroup';
6
6
  import type { FABProps } from '../FAB/FAB';
7
7
 
8
- export interface SectionListWithFABProps<T> extends SectionListProps<T> {
8
+ interface SectionListWithFABProps<T> extends SectionListProps<T> {
9
9
  /**
10
10
  * FAB or FAB.ActionGroup props props.
11
11
  */
@@ -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
@@ -9,7 +9,7 @@ import {
9
9
  } from './StyledUtilityButton';
10
10
  import type { IconName } from '../../Icon';
11
11
 
12
- export interface UtilityButtonProps extends ViewProps {
12
+ interface UtilityButtonProps extends ViewProps {
13
13
  /**
14
14
  * Places an icon within the button, before the button's text
15
15
  */
@@ -2,7 +2,7 @@ import {
2
2
  MonthYearPickerDialogueAndroid,
3
3
  MonthYearPickerViewIOS,
4
4
  } from '@hero-design/react-native-month-year-picker';
5
- import format from 'date-fns/fp/format';
5
+ import { format } from 'date-fns/fp';
6
6
  import React, { useState } from 'react';
7
7
  import { Platform, TouchableOpacity } from 'react-native';
8
8
  import { useTheme } from '../../theme';
@@ -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
@@ -18,7 +18,7 @@ export const getCellVariant = (
18
18
  return 'default';
19
19
  };
20
20
 
21
- export interface CalendarRowItemProps {
21
+ interface CalendarRowItemProps {
22
22
  date?: Date;
23
23
  onPress?: () => void;
24
24
  isCurrent?: boolean;
@@ -2,7 +2,7 @@ import {
2
2
  MonthYearPickerDialogueAndroid,
3
3
  MonthYearPickerViewIOS,
4
4
  } from '@hero-design/react-native-month-year-picker';
5
- import format from 'date-fns/fp/format';
5
+ import { format } from 'date-fns/fp';
6
6
  import React, { useState } from 'react';
7
7
  import { Platform, TouchableOpacity } from 'react-native';
8
8
  import { useTheme } from '../../theme';
@@ -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);
@@ -1,5 +1,5 @@
1
- import * as d3 from 'd3';
2
1
  import React, { useMemo } from 'react';
2
+ import { line, curveBasis } from 'd3';
3
3
  import { Path } from 'react-native-svg';
4
4
  import { DEFAULT_LINE_STROKE_WIDTH } from '../shared/constants';
5
5
  import useScaleBandX from '../shared/hooks/useScaleBandX';
@@ -56,11 +56,10 @@ const Line = ({
56
56
  // Create line generator with proper curve
57
57
  const lineGenerator = useMemo(
58
58
  () =>
59
- d3
60
- .line<DataValue>()
59
+ line<DataValue>()
61
60
  .x((_, i) => (xScale(labels[i]) ?? 0) + xScale.bandwidth() / 2)
62
61
  .y((d) => yScale(d ?? 0))
63
- .curve(d3.curveBasis),
62
+ .curve(curveBasis),
64
63
  [xScale, yScale, labels]
65
64
  );
66
65
 
@@ -8,6 +8,4 @@ const Chart = {
8
8
  SelectAction,
9
9
  };
10
10
 
11
- export type { LineChart, ColumnChart };
12
-
13
11
  export default Chart;
@@ -5,7 +5,7 @@ import { StyledChartHeader } from '../StyledChart';
5
5
  import type { HeaderConfig } from '../types';
6
6
  import Box from '../../Box';
7
7
 
8
- export type ChartHeaderProps = HeaderConfig & {
8
+ type ChartHeaderProps = HeaderConfig & {
9
9
  onLayout?: (event: LayoutChangeEvent) => void;
10
10
  };
11
11
 
@@ -1,5 +1,5 @@
1
1
  import { useMemo } from 'react';
2
- import * as d3 from 'd3';
2
+ import { scaleOrdinal } from 'd3';
3
3
  import { mobileVisualisationPalette } from '@hero-design/colors';
4
4
 
5
5
  // Only use colors that are not maasstrichtBlue
@@ -20,6 +20,6 @@ export default function useColorScale(
20
20
  return useMemo(() => {
21
21
  const palette =
22
22
  customColors && customColors.length > 0 ? customColors : DEFAULT_COLORS;
23
- return d3.scaleOrdinal<string, string>().domain(labels).range(palette);
23
+ return scaleOrdinal<string, string>().domain(labels).range(palette);
24
24
  }, [labels, customColors]);
25
25
  }
@@ -1,5 +1,5 @@
1
1
  import { useMemo } from 'react';
2
- import * as d3 from 'd3';
2
+ import { range } from 'd3';
3
3
 
4
4
  const useGenerateTicks = ({
5
5
  maxValue,
@@ -14,7 +14,7 @@ const useGenerateTicks = ({
14
14
  const minValueOrZero = minValue || 0;
15
15
 
16
16
  const ticks = useMemo(() => {
17
- const generatedTicks = d3.range(minValueOrZero, maxValueOrZero, step);
17
+ const generatedTicks = range(minValueOrZero, maxValueOrZero, step);
18
18
  if (generatedTicks[generatedTicks.length - 1] !== maxValueOrZero) {
19
19
  generatedTicks.push(maxValueOrZero);
20
20
  }
@@ -1,7 +1,7 @@
1
1
  import { useMemo } from 'react';
2
- import * as d3 from 'd3';
2
+ import { scaleBand } from 'd3';
3
3
 
4
- export type UseScaleBandXProps = {
4
+ type UseScaleBandXProps = {
5
5
  labels: string[];
6
6
  xStart: number;
7
7
  xEnd: number;
@@ -9,7 +9,7 @@ export type UseScaleBandXProps = {
9
9
 
10
10
  const useScaleBandX = ({ labels, xStart, xEnd }: UseScaleBandXProps) => {
11
11
  return useMemo(
12
- () => d3.scaleBand().domain(labels).range([xStart, xEnd]).padding(0.2),
12
+ () => scaleBand().domain(labels).range([xStart, xEnd]).padding(0.2),
13
13
  [labels, xStart, xEnd]
14
14
  );
15
15
  };
@@ -1,7 +1,7 @@
1
1
  import { useMemo } from 'react';
2
- import * as d3 from 'd3';
2
+ import { scaleLinear } from 'd3';
3
3
 
4
- export type UseScaleLinearYProps = {
4
+ type UseScaleLinearYProps = {
5
5
  maxValue: number;
6
6
  minValue: number;
7
7
  yStart: number;
@@ -19,8 +19,7 @@ const useScaleLinearY = ({
19
19
 
20
20
  return useMemo(
21
21
  () =>
22
- d3
23
- .scaleLinear()
22
+ scaleLinear()
24
23
  .domain([minValueOrZero, maxValueOrZero])
25
24
  .range([yEnd, yStart]),
26
25
  [maxValueOrZero, minValueOrZero, yStart, yEnd]
@@ -1,10 +1,3 @@
1
- export type AxisSizeConfig = {
2
- xAxisTextHeight: number;
3
- setXAxisTextHeight: (height: number) => void;
4
- yAxisTextWidth: number;
5
- setYAxisTextWidth: (width: number) => void;
6
- };
7
-
8
1
  /**
9
2
  * Represents a data series for the chart.
10
3
  * @template Data - The type of the data array for the series.
@@ -122,7 +115,6 @@ type StyleConfig = {
122
115
 
123
116
  export type {
124
117
  Series,
125
- TickConfig,
126
118
  XAxisConfig,
127
119
  YAxisConfig,
128
120
  DataValue,
@@ -1,4 +1,4 @@
1
- export type getStateType = {
1
+ type getStateType = {
2
2
  disabled: boolean;
3
3
  readonly: boolean;
4
4
  checked?: boolean;
@@ -14,7 +14,7 @@ type DeprecatedVariant = 'outlined' | 'filled';
14
14
 
15
15
  type ValidVariant = 'selection' | 'filter' | 'compact' | 'compact-outlined';
16
16
 
17
- export interface ChipProps extends ViewProps {
17
+ interface ChipProps extends ViewProps {
18
18
  /**
19
19
  * The label of the chip.
20
20
  */
@@ -1,5 +1,5 @@
1
1
  import { renderHook } from '@testing-library/react-hooks';
2
- import formatDate from 'date-fns/fp/format';
2
+ import { format as formatDate } from 'date-fns/fp';
3
3
  import useFormatDate from '../useFormatDate';
4
4
  import { useDateTimeFormat } from '../../../LocaleProvider/hooks';
5
5
 
@@ -8,10 +8,12 @@ jest.mock('../../../LocaleProvider/hooks', () => ({
8
8
  useDateTimeFormat: jest.fn(),
9
9
  }));
10
10
 
11
- jest.mock('date-fns/fp/format', () => {
12
- return jest.fn((format, date) => {
13
- return `Formatted: ${format}, Date: ${date.toISOString()}`;
14
- });
11
+ jest.mock('date-fns/fp', () => {
12
+ return {
13
+ format: jest.fn((format, date) => {
14
+ return `Formatted: ${format}, Date: ${date.toISOString()}`;
15
+ }),
16
+ };
15
17
  });
16
18
 
17
19
  describe('useFormatDate', () => {
@@ -1,4 +1,4 @@
1
- import formatDate from 'date-fns/fp/format';
1
+ import { format as formatDate } from 'date-fns/fp';
2
2
  import { useDateTimeFormat } from '../../LocaleProvider/hooks';
3
3
  import { getDateFormat } from './utils';
4
4
 
@@ -43,7 +43,7 @@ export interface DatePickerProps {
43
43
  confirmLabel: string;
44
44
  /**
45
45
  * Date format. Default format is dd/MM/yyyy.
46
- * Following date-fns's format (https://date-fns.org/v2.16.1/docs/format).
46
+ * Following date-fns's format (https://date-fns.org/v4.1.0/docs/format).
47
47
  */
48
48
  displayFormat?: string;
49
49
  /**
@@ -9,7 +9,7 @@ import {
9
9
  } from './StyledFloatingIsland';
10
10
  import type { IconName } from '../Icon';
11
11
 
12
- export interface FloatingIslandProps extends ViewProps {
12
+ interface FloatingIslandProps extends ViewProps {
13
13
  /**
14
14
  * Callback that is called when the floating island is pressed.
15
15
  */
@@ -8,7 +8,7 @@ import { Illustrations, type IllustrationName } from './illustrations';
8
8
  export { IllustrationList } from './illustrations';
9
9
  export type { IllustrationName } from './illustrations';
10
10
 
11
- export interface IllustrationProps {
11
+ interface IllustrationProps {
12
12
  /**
13
13
  * The name of the illustration to display
14
14
  */
@@ -11,7 +11,7 @@ import {
11
11
  import type { IconName } from '../Icon';
12
12
  import { useTheme } from '../../theme';
13
13
 
14
- export interface ListItemProps {
14
+ interface ListItemProps {
15
15
  /**
16
16
  * Name of Icon or component to render on the left side of title.
17
17
  */
@@ -1,8 +1,8 @@
1
1
  import { TouchableHighlight, View } from 'react-native';
2
2
  import styled from '@emotion/native';
3
3
 
4
- export type Variant = 'full-width' | 'card';
5
- export type LeadingStatusIntent =
4
+ type Variant = 'full-width' | 'card';
5
+ type LeadingStatusIntent =
6
6
  | 'success'
7
7
  | 'warning'
8
8
  | 'danger'
@@ -1,5 +1,4 @@
1
- import enAU from 'date-fns/locale/en-AU';
2
- import enCA from 'date-fns/locale/en-CA';
1
+ import { enAU, enCA } from 'date-fns/locale';
3
2
  import { getDateFnsLocale } from '../utils';
4
3
 
5
4
  describe('getDateFnsLocale', () => {
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect } from 'react';
2
- import setDefaultOptions from 'date-fns/setDefaultOptions';
2
+ import { setDefaultOptions } from 'date-fns';
3
3
  import { LocaleContext } from './context';
4
4
  import { getDateFnsLocale } from './utils';
5
5
  import type { LocaleValues } from '../../locales/types';
@@ -1,6 +1,5 @@
1
- import enAU from 'date-fns/locale/en-AU';
2
- import enCA from 'date-fns/locale/en-CA';
3
- import type { Locale } from 'date-fns';
1
+ import { enAU, enCA } from 'date-fns/locale';
2
+ import type { Locale } from 'date-fns/locale';
4
3
  import type { LocaleCode } from '../../locales/types';
5
4
 
6
5
  const Locales = {
@@ -11,7 +11,7 @@ import { ThemeProvider, useTheme } from '../../theme';
11
11
 
12
12
  const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789', 10);
13
13
 
14
- export interface PortalProps {
14
+ interface PortalProps {
15
15
  /*
16
16
  * Name of the portal. If name is not provided, a random name will be generated.
17
17
  */
@@ -14,12 +14,12 @@ export interface RemovePortalAction {
14
14
  portalName: string;
15
15
  }
16
16
 
17
- export interface RegisterHostAction {
17
+ interface RegisterHostAction {
18
18
  type: ACTIONS;
19
19
  hostName: string;
20
20
  }
21
21
 
22
- export interface UnregisterHostAction {
22
+ interface UnregisterHostAction {
23
23
  type: ACTIONS;
24
24
  hostName: string;
25
25
  }
@@ -4,7 +4,7 @@ import type { StyleProp, ViewStyle } from 'react-native';
4
4
  import type { IconName } from '../Icon';
5
5
  import { Circle, InnerCircle, StyledRadio } from './StyledRadio';
6
6
 
7
- export interface RadioProps {
7
+ interface RadioProps {
8
8
  /**
9
9
  * Whether the radio is checked.
10
10
  */
@@ -4,11 +4,11 @@ import { Animated, Platform, Pressable } from 'react-native';
4
4
  import Icon from '../Icon';
5
5
  import { StyledIconWrapper, StyledWrapper } from './StyledRate';
6
6
 
7
- export interface RateOption<T extends string | number> {
7
+ interface RateOption<T extends string | number> {
8
8
  value: T;
9
9
  }
10
10
 
11
- export interface RateProps<T extends string | number> extends ViewProps {
11
+ interface RateProps<T extends string | number> extends ViewProps {
12
12
  /**
13
13
  * Options for rate component.
14
14
  */
@@ -3,7 +3,7 @@ import type { RefreshControlProps as NativeRefreshControlProps } from 'react-nat
3
3
  import { RefreshControl as NativeRefreshControl } from 'react-native';
4
4
  import { useTheme } from '../../theme';
5
5
 
6
- export type RefreshControlProps = Omit<
6
+ type RefreshControlProps = Omit<
7
7
  NativeRefreshControlProps,
8
8
  'colors' | 'tintColor'
9
9
  >;
@@ -29,19 +29,19 @@ 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
- export type EditorValue = {
38
+ type EditorValue = {
39
39
  type: string;
40
40
  children: any;
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
  });
@@ -1,24 +1,12 @@
1
1
  import type { EventEmitter } from 'events';
2
2
 
3
- export interface Listener<T> {
3
+ 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,
@@ -18,7 +18,7 @@ import { renderPrefix, renderSuffix } from './utils';
18
18
  import Button from '../Button';
19
19
  import { useTheme } from '../../theme';
20
20
 
21
- export type SearchOneLineHandles = Pick<
21
+ type SearchOneLineHandles = Pick<
22
22
  RNTextInput,
23
23
  'focus' | 'clear' | 'blur' | 'isFocused' | 'setNativeProps'
24
24
  >;
@@ -5,7 +5,7 @@ import Badge from '../Badge';
5
5
 
6
6
  export type State = 'default' | 'filled' | 'disabled' | 'readonly';
7
7
 
8
- export type Variant = 'basic' | 'reversed';
8
+ type Variant = 'basic' | 'reversed';
9
9
 
10
10
  export const StyledContainer = styled(View)(() => ({
11
11
  width: '100%',
@@ -11,7 +11,7 @@ import {
11
11
  import type { IconName, IconProps } from '../Icon';
12
12
  import { useDeprecation } from '../../utils/hooks';
13
13
 
14
- export interface SectionHeadingProps extends ViewProps {
14
+ interface SectionHeadingProps extends ViewProps {
15
15
  /**
16
16
  * Heading text.
17
17
  */