@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.
- package/.turbo/turbo-build.log +3 -3
- package/CHANGELOG.md +12 -0
- package/es/index.js +1764 -1372
- package/jest.config.js +1 -1
- package/lib/index.js +1764 -1372
- package/package.json +2 -2
- package/src/components/Accordion/AccordionItem.tsx +1 -1
- package/src/components/AnimatedScroller/AnimatedScrollable.tsx +1 -1
- package/src/components/AnimatedScroller/SectionListWithFAB.tsx +1 -1
- package/src/components/Box/StyledBox.tsx +1 -1
- package/src/components/Button/UtilityButton/index.tsx +1 -1
- package/src/components/Calendar/CalendarRange.tsx +1 -1
- package/src/components/Calendar/CalendarRowItem.tsx +2 -2
- package/src/components/Calendar/index.tsx +1 -1
- package/src/components/Carousel/index.tsx +1 -1
- package/src/components/Chart/Line/Line.tsx +3 -4
- package/src/components/Chart/index.tsx +0 -2
- package/src/components/Chart/shared/ChartHeader.tsx +1 -1
- package/src/components/Chart/shared/hooks/useColorScale.ts +2 -2
- package/src/components/Chart/shared/hooks/useGenerateTicks.ts +2 -2
- package/src/components/Chart/shared/hooks/useScaleBandX.ts +3 -3
- package/src/components/Chart/shared/hooks/useScaleLinearY.ts +3 -4
- package/src/components/Chart/types.ts +0 -8
- package/src/components/Checkbox/utils.ts +1 -1
- package/src/components/Chip/index.tsx +1 -1
- package/src/components/DatePicker/hooks/__tests__/useFormatDate.spec.ts +7 -5
- package/src/components/DatePicker/hooks/useFormatDate.ts +1 -1
- package/src/components/DatePicker/types.ts +1 -1
- package/src/components/FloatingIsland/index.tsx +1 -1
- package/src/components/Illustration/index.tsx +1 -1
- package/src/components/List/BasicListItem.tsx +1 -1
- package/src/components/List/StyledListItem.tsx +2 -2
- package/src/components/LocaleProvider/__tests__/utils.specs.ts +1 -2
- package/src/components/LocaleProvider/index.tsx +1 -1
- package/src/components/LocaleProvider/utils.ts +2 -3
- package/src/components/Portal/index.tsx +1 -1
- package/src/components/Portal/types.tsx +2 -2
- package/src/components/Radio/Radio.tsx +1 -1
- package/src/components/Rate/index.tsx +2 -2
- package/src/components/RefreshControl/index.tsx +1 -1
- package/src/components/RichTextEditor/RichTextEditor.tsx +6 -6
- 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 +1 -13
- package/src/components/Search/SearchOneLine.tsx +1 -1
- package/src/components/Search/StyledSearch.tsx +1 -1
- package/src/components/SectionHeading/index.tsx +1 -1
- package/src/components/Select/helpers.tsx +1 -18
- package/src/components/Skeleton/index.tsx +1 -1
- package/src/components/Slider/RangeSlider.tsx +1 -1
- package/src/components/StatusScreens/Success/index.tsx +1 -1
- package/src/components/Tabs/ScrollableTabsHeader/ScrollableTabsHeader.tsx +1 -1
- package/src/components/Tabs/StyledTabs.tsx +0 -5
- package/src/components/Tabs/TabWithBadge.tsx +2 -2
- package/src/components/TextInput/index.tsx +3 -3
- package/src/components/TimePicker/TimePickerAndroid.tsx +1 -1
- package/src/components/TimePicker/TimePickerIOS.tsx +1 -1
- package/src/components/TimePicker/types.ts +1 -1
- package/src/components/Toast/ToastContext.ts +1 -1
- package/src/components/Toolbar/index.tsx +1 -1
- package/src/components/Typography/Label/index.tsx +1 -1
- package/src/theme/global/colors/swagSystemPalette.ts +1 -1
- package/src/theme/global/colors/types.ts +1 -1
- package/src/theme/global/shadows/index.ts +0 -3
- package/src/theme/global/shadows/types.ts +1 -1
- package/src/theme/global/sizes.ts +1 -0
- package/src/theme/global/typography.ts +2 -1
- package/src/utils/scale.ts +2 -2
- package/types/components/Accordion/AccordionItem.d.ts +1 -1
- package/types/components/AnimatedScroller/AnimatedScrollable.d.ts +1 -1
- package/types/components/AnimatedScroller/SectionListWithFAB.d.ts +1 -1
- package/types/components/Box/StyledBox.d.ts +0 -5
- package/types/components/Button/UtilityButton/index.d.ts +1 -1
- package/types/components/Calendar/CalendarRowItem.d.ts +1 -2
- package/types/components/Carousel/index.d.ts +0 -1
- package/types/components/Chart/index.d.ts +0 -3
- package/types/components/Chart/shared/ChartHeader.d.ts +1 -1
- package/types/components/Chart/shared/hooks/useScaleBandX.d.ts +2 -3
- package/types/components/Chart/shared/hooks/useScaleLinearY.d.ts +2 -3
- package/types/components/Chart/types.d.ts +1 -7
- package/types/components/Checkbox/utils.d.ts +2 -1
- package/types/components/Chip/index.d.ts +1 -1
- package/types/components/DatePicker/types.d.ts +1 -1
- package/types/components/FloatingIsland/index.d.ts +1 -1
- package/types/components/Illustration/index.d.ts +1 -1
- package/types/components/List/BasicListItem.d.ts +1 -1
- package/types/components/List/StyledListItem.d.ts +2 -2
- package/types/components/LocaleProvider/utils.d.ts +1 -1
- package/types/components/Portal/index.d.ts +1 -1
- package/types/components/Portal/types.d.ts +3 -2
- package/types/components/Radio/Radio.d.ts +1 -1
- package/types/components/Rate/index.d.ts +2 -2
- package/types/components/RefreshControl/index.d.ts +1 -1
- package/types/components/RichTextEditor/RichTextEditor.d.ts +2 -6
- 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 +2 -3
- package/types/components/Search/SearchOneLine.d.ts +1 -1
- package/types/components/Search/StyledSearch.d.ts +2 -1
- package/types/components/SectionHeading/index.d.ts +1 -1
- package/types/components/Select/helpers.d.ts +2 -2
- package/types/components/Skeleton/index.d.ts +1 -1
- package/types/components/Slider/RangeSlider.d.ts +1 -1
- package/types/components/StatusScreens/Success/index.d.ts +1 -1
- package/types/components/Tabs/ScrollableTabsHeader/ScrollableTabsHeader.d.ts +1 -1
- package/types/components/Tabs/StyledTabs.d.ts +1 -7
- package/types/components/Tabs/TabWithBadge.d.ts +2 -2
- package/types/components/TextInput/index.d.ts +2 -3
- package/types/components/TimePicker/types.d.ts +1 -1
- package/types/components/Toast/ToastContext.d.ts +2 -1
- package/types/components/Toolbar/index.d.ts +1 -1
- package/types/components/Typography/Label/index.d.ts +1 -1
- package/types/theme/components/alert.d.ts +10 -1
- package/types/theme/components/bottomNavigation.d.ts +10 -1
- package/types/theme/components/chip.d.ts +10 -1
- package/types/theme/components/fab.d.ts +10 -1
- package/types/theme/components/floatingIsland.d.ts +10 -1
- package/types/theme/components/list.d.ts +10 -1
- package/types/theme/components/search.d.ts +10 -1
- package/types/theme/components/segmentedControl.d.ts +10 -1
- package/types/theme/components/slider.d.ts +10 -1
- package/types/theme/components/toast.d.ts +10 -1
- package/types/theme/global/colors/swagSystemPalette.d.ts +1 -1
- package/types/theme/global/colors/types.d.ts +2 -1
- package/types/theme/global/index.d.ts +1 -1
- package/types/theme/global/shadows/index.d.ts +0 -2
- package/types/theme/global/shadows/types.d.ts +2 -1
- package/types/theme/global/typography.d.ts +1 -1
- package/types/utils/scale.d.ts +0 -2
- package/.cursor/rules/performance-optimization.mdc +0 -64
- package/.cursor/rules/rn-rules.mdc +0 -165
- 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
|
+
"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": "^
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
62
|
+
.curve(curveBasis),
|
|
64
63
|
[xScale, yScale, labels]
|
|
65
64
|
);
|
|
66
65
|
|
|
@@ -5,7 +5,7 @@ import { StyledChartHeader } from '../StyledChart';
|
|
|
5
5
|
import type { HeaderConfig } from '../types';
|
|
6
6
|
import Box from '../../Box';
|
|
7
7
|
|
|
8
|
-
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
2
|
+
import { scaleBand } from 'd3';
|
|
3
3
|
|
|
4
|
-
|
|
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
|
-
() =>
|
|
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
|
|
2
|
+
import { scaleLinear } from 'd3';
|
|
3
3
|
|
|
4
|
-
|
|
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
|
-
|
|
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,
|
|
@@ -14,7 +14,7 @@ type DeprecatedVariant = 'outlined' | 'filled';
|
|
|
14
14
|
|
|
15
15
|
type ValidVariant = 'selection' | 'filter' | 'compact' | 'compact-outlined';
|
|
16
16
|
|
|
17
|
-
|
|
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
|
|
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
|
|
12
|
-
return
|
|
13
|
-
|
|
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', () => {
|
|
@@ -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/
|
|
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
|
-
|
|
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
|
-
|
|
11
|
+
interface IllustrationProps {
|
|
12
12
|
/**
|
|
13
13
|
* The name of the illustration to display
|
|
14
14
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TouchableHighlight, View } from 'react-native';
|
|
2
2
|
import styled from '@emotion/native';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type Variant = 'full-width' | 'card';
|
|
5
|
+
type LeadingStatusIntent =
|
|
6
6
|
| 'success'
|
|
7
7
|
| 'warning'
|
|
8
8
|
| 'danger'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
|
-
import setDefaultOptions from 'date-fns
|
|
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
|
|
2
|
-
import
|
|
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
|
-
|
|
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
|
-
|
|
17
|
+
interface RegisterHostAction {
|
|
18
18
|
type: ACTIONS;
|
|
19
19
|
hostName: string;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
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
|
-
|
|
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
|
-
|
|
7
|
+
interface RateOption<T extends string | number> {
|
|
8
8
|
value: T;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
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
|
-
|
|
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
|
|
32
|
+
import RichTextEditorInput from './RichTextEditorInput';
|
|
33
33
|
import type {
|
|
34
|
-
|
|
34
|
+
RichTextEditorInputProps,
|
|
35
35
|
RichTextEditorRef,
|
|
36
|
-
} from './
|
|
36
|
+
} from './RichTextEditorInput';
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
type EditorValue = {
|
|
39
39
|
type: string;
|
|
40
40
|
children: any;
|
|
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
|
});
|
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
import type { EventEmitter } from 'events';
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
21
|
+
type SearchOneLineHandles = Pick<
|
|
22
22
|
RNTextInput,
|
|
23
23
|
'focus' | 'clear' | 'blur' | 'isFocused' | 'setNativeProps'
|
|
24
24
|
>;
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import type { IconName, IconProps } from '../Icon';
|
|
12
12
|
import { useDeprecation } from '../../utils/hooks';
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
interface SectionHeadingProps extends ViewProps {
|
|
15
15
|
/**
|
|
16
16
|
* Heading text.
|
|
17
17
|
*/
|