@hero-design/rn 8.55.1-rc2.3 → 8.56.0
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 +1 -1
- package/CHANGELOG.md +5 -34
- package/es/index.js +5385 -4937
- package/lib/index.js +5390 -4939
- package/package.json +8 -8
- package/sonar-project.properties +1 -0
- package/src/components/AnimatedScroller/AnimatedFAB.tsx +105 -0
- package/src/components/AnimatedScroller/AnimatedScrollable.tsx +55 -0
- package/src/components/AnimatedScroller/FlatListWithFAB.tsx +23 -0
- package/src/components/AnimatedScroller/ScrollViewWithFAB.tsx +21 -0
- package/src/components/AnimatedScroller/SectionListWithFAB.tsx +26 -0
- package/src/components/AnimatedScroller/index.tsx +5 -0
- package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +26 -833
- package/src/components/Carousel/__tests__/index.spec.tsx +9 -3
- package/src/components/Carousel/index.tsx +19 -6
- package/src/components/FAB/FAB.tsx +6 -6
- package/src/index.ts +8 -0
- package/types/components/Accordion/StyledAccordion.d.ts +5 -5
- package/types/components/Alert/StyledAlert.d.ts +5 -5
- package/types/components/AnimatedScroller/AnimatedFAB.d.ts +10 -0
- package/types/components/AnimatedScroller/AnimatedScrollable.d.ts +16 -0
- package/types/components/AnimatedScroller/FlatListWithFAB.d.ts +12 -0
- package/types/components/AnimatedScroller/ScrollViewWithFAB.d.ts +12 -0
- package/types/components/AnimatedScroller/SectionListWithFAB.d.ts +12 -0
- package/types/components/AnimatedScroller/index.d.ts +4 -0
- package/types/components/Attachment/StyledAttachment.d.ts +4 -4
- package/types/components/Avatar/AvatarStack/StyledAvatarStack.d.ts +3 -3
- package/types/components/Avatar/StyledAvatar.d.ts +4 -4
- package/types/components/Badge/StyledBadge.d.ts +3 -3
- package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +7 -7
- package/types/components/BottomSheet/StyledBottomSheet.d.ts +8 -8
- package/types/components/Box/StyledBox.d.ts +1 -1
- package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +2 -2
- package/types/components/Button/StyledButton.d.ts +5 -5
- package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +3 -3
- package/types/components/Calendar/StyledCalendar.d.ts +9 -9
- package/types/components/Card/DataCard/StyledDataCard.d.ts +2 -2
- package/types/components/Card/StyledCard.d.ts +1 -1
- package/types/components/Carousel/StyledCardCarousel.d.ts +4 -4
- package/types/components/Carousel/StyledCarousel.d.ts +9 -9
- package/types/components/Checkbox/StyledCheckbox.d.ts +5 -5
- package/types/components/Chip/StyledChip.d.ts +4 -4
- package/types/components/Collapse/StyledCollapse.d.ts +3 -3
- package/types/components/ContentNavigator/StyledContentNavigator.d.ts +1 -1
- package/types/components/DatePicker/StyledDatePicker.d.ts +1 -1
- package/types/components/Divider/StyledDivider.d.ts +1 -1
- package/types/components/Drawer/StyledDrawer.d.ts +7 -7
- package/types/components/Empty/StyledEmpty.d.ts +3 -3
- package/types/components/Error/StyledError.d.ts +10 -10
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +5 -5
- package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +3 -3
- package/types/components/FAB/StyledFAB.d.ts +4 -4
- package/types/components/Icon/HeroIcon/index.d.ts +1 -1
- package/types/components/List/StyledBasicListItem.d.ts +4 -4
- package/types/components/List/StyledListItem.d.ts +7 -7
- package/types/components/PageControl/StyledPageControl.d.ts +2 -2
- package/types/components/PinInput/StyledPinInput.d.ts +10 -10
- package/types/components/Progress/StyledProgressBar.d.ts +2 -2
- package/types/components/Progress/StyledProgressCircle.d.ts +6 -6
- package/types/components/Radio/StyledRadio.d.ts +3 -3
- package/types/components/Rate/StyledRate.d.ts +2 -2
- package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +2 -2
- package/types/components/RichTextEditor/StyledToolbar.d.ts +3 -3
- package/types/components/SectionHeading/StyledHeading.d.ts +3 -3
- package/types/components/Select/StyledSelect.d.ts +3 -3
- package/types/components/Skeleton/StyledSkeleton.d.ts +2 -2
- package/types/components/Spinner/StyledSpinner.d.ts +4 -4
- package/types/components/Success/StyledSuccess.d.ts +9 -9
- package/types/components/Swipeable/StyledSwipeable.d.ts +1 -1
- package/types/components/Switch/SelectorSwitch/StyledSelectorSwitch.d.ts +4 -4
- package/types/components/Switch/StyledSwitch.d.ts +2 -2
- package/types/components/Tabs/StyledScrollableTabs.d.ts +8 -8
- package/types/components/Tabs/StyledTabs.d.ts +8 -8
- package/types/components/Tag/StyledTag.d.ts +2 -2
- package/types/components/TextInput/StyledTextInput.d.ts +13 -13
- package/types/components/TimePicker/StyledTimePicker.d.ts +1 -1
- package/types/components/Toast/StyledToast.d.ts +6 -6
- package/types/components/Toolbar/StyledToolbar.d.ts +5 -5
- package/types/components/Typography/Body/StyledBody.d.ts +1 -1
- package/types/components/Typography/Caption/StyledCaption.d.ts +1 -1
- package/types/components/Typography/Label/StyledLabel.d.ts +1 -1
- package/types/components/Typography/Text/StyledText.d.ts +1 -1
- package/types/components/Typography/Title/StyledTitle.d.ts +1 -1
- package/types/index.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.56.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type-check": "tsc --noEmit",
|
|
11
11
|
"test": "jest --runInBand",
|
|
12
12
|
"test:watch": "jest --runInBand --watch",
|
|
13
|
-
"test:ci": "jest --c=jest-ci.config.js --i --logHeapUsage",
|
|
13
|
+
"test:ci": "jest --c=jest-ci.config.js --i --logHeapUsage --coverage && cat ./coverage/lcov.info",
|
|
14
14
|
"build:js": "rollup -c",
|
|
15
15
|
"build:types": "tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json",
|
|
16
16
|
"build": "yarn build:js && yarn build:types",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"@emotion/native": "^11.9.3",
|
|
23
23
|
"@emotion/primitives-core": "11.0.0",
|
|
24
24
|
"@emotion/react": "^11.9.3",
|
|
25
|
-
"@hero-design/colors": "8.42.
|
|
25
|
+
"@hero-design/colors": "8.42.5",
|
|
26
26
|
"date-fns": "^2.16.1",
|
|
27
27
|
"events": "^3.2.0",
|
|
28
28
|
"hero-editor": "^1.9.21",
|
|
29
29
|
"nanoid": "^4.0.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@hero-design/react-native-month-year-picker": "^8.42.
|
|
32
|
+
"@hero-design/react-native-month-year-picker": "^8.42.6",
|
|
33
33
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
34
34
|
"@react-native-community/slider": "4.4.3",
|
|
35
35
|
"react": "18.2.0",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@babel/preset-typescript": "^7.20.0",
|
|
49
49
|
"@babel/runtime": "^7.20.0",
|
|
50
50
|
"@emotion/jest": "^11.11.0",
|
|
51
|
-
"@hero-design/eslint-plugin": "9.0.
|
|
52
|
-
"@hero-design/react-native-month-year-picker": "^8.42.
|
|
51
|
+
"@hero-design/eslint-plugin": "9.0.0",
|
|
52
|
+
"@hero-design/react-native-month-year-picker": "^8.42.6",
|
|
53
53
|
"@react-native-community/datetimepicker": "3.5.2",
|
|
54
54
|
"@react-native-community/slider": "4.4.3",
|
|
55
55
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -66,12 +66,12 @@
|
|
|
66
66
|
"babel-plugin-inline-import": "^3.0.0",
|
|
67
67
|
"core-js": "^3.33.0",
|
|
68
68
|
"eslint": "^8.56.0",
|
|
69
|
-
"eslint-config-hd": "8.42.
|
|
69
|
+
"eslint-config-hd": "8.42.4",
|
|
70
70
|
"eslint-plugin-import": "^2.27.5",
|
|
71
71
|
"jest": "^29.2.1",
|
|
72
72
|
"jest-environment-jsdom": "^29.2.1",
|
|
73
73
|
"jest-junit": "^16.0.0",
|
|
74
|
-
"prettier-config-hd": "8.42.
|
|
74
|
+
"prettier-config-hd": "8.42.4",
|
|
75
75
|
"react": "18.2.0",
|
|
76
76
|
"react-native": "0.71.14",
|
|
77
77
|
"react-native-gesture-handler": "~2.5.0",
|
package/sonar-project.properties
CHANGED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import FAB from '../FAB';
|
|
4
|
+
import ActionGroup, {
|
|
5
|
+
ActionGroupHandles,
|
|
6
|
+
ActionGroupProps,
|
|
7
|
+
} from '../FAB/ActionGroup';
|
|
8
|
+
import { FABHandles, FABProps } from '../FAB/FAB';
|
|
9
|
+
|
|
10
|
+
const COLLAPSE_BREAKPOINT = 10;
|
|
11
|
+
const SHOW_AND_HIDE_BREAKPOINT = 200;
|
|
12
|
+
const REF_ACTIONS_BY_COMPONENT = {
|
|
13
|
+
FAB: {
|
|
14
|
+
show: 'show',
|
|
15
|
+
hide: 'hide',
|
|
16
|
+
collapse: 'collapse',
|
|
17
|
+
},
|
|
18
|
+
ActionGroup: {
|
|
19
|
+
show: 'showFAB',
|
|
20
|
+
hide: 'hideFAB',
|
|
21
|
+
collapse: 'collapseFAB',
|
|
22
|
+
},
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
interface AnimatedFABProps {
|
|
26
|
+
fabProps: FABProps | ActionGroupProps;
|
|
27
|
+
contentOffsetY: Animated.Value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const AnimatedFAB = ({ fabProps, contentOffsetY }: AnimatedFABProps) => {
|
|
31
|
+
const component = 'items' in fabProps ? 'ActionGroup' : 'FAB';
|
|
32
|
+
const [currentScrollDirection, setCurrentScrollDirection] = React.useState<
|
|
33
|
+
'up' | 'down'
|
|
34
|
+
>('down');
|
|
35
|
+
const [lastScrollY, setLastScrollY] = React.useState(0);
|
|
36
|
+
const [fabState, setFabState] = React.useState<'show' | 'hide' | 'collapse'>(
|
|
37
|
+
'show'
|
|
38
|
+
);
|
|
39
|
+
const [remainingScrollOffset, setRemainingScrollOffset] = React.useState(
|
|
40
|
+
SHOW_AND_HIDE_BREAKPOINT
|
|
41
|
+
);
|
|
42
|
+
const ref = React.useRef<FABHandles & ActionGroupHandles>(null);
|
|
43
|
+
|
|
44
|
+
const animateFab = React.useCallback(
|
|
45
|
+
(newState: 'show' | 'hide' | 'collapse') => {
|
|
46
|
+
if (fabState !== newState) {
|
|
47
|
+
if (newState === 'show') {
|
|
48
|
+
ref.current?.[REF_ACTIONS_BY_COMPONENT[component].show]();
|
|
49
|
+
} else if (newState === 'hide') {
|
|
50
|
+
ref.current?.[REF_ACTIONS_BY_COMPONENT[component].hide]();
|
|
51
|
+
} else {
|
|
52
|
+
ref.current?.[REF_ACTIONS_BY_COMPONENT[component].collapse]();
|
|
53
|
+
}
|
|
54
|
+
setFabState(newState);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
[fabState, component]
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// Listen to ScrollView's contentOffsetY value
|
|
61
|
+
contentOffsetY.addListener(({ value }) => {
|
|
62
|
+
if (value < 0) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const newScrollDirection = value > lastScrollY ? 'down' : 'up';
|
|
67
|
+
const isScrollingDown = newScrollDirection === 'down';
|
|
68
|
+
|
|
69
|
+
if (newScrollDirection !== currentScrollDirection || lastScrollY === 0) {
|
|
70
|
+
setLastScrollY(value);
|
|
71
|
+
setCurrentScrollDirection(newScrollDirection);
|
|
72
|
+
}
|
|
73
|
+
const offsetFromLastDirection = Math.abs(value - lastScrollY);
|
|
74
|
+
const offsetDiff = Math.round(
|
|
75
|
+
Math.max(remainingScrollOffset - offsetFromLastDirection, 0)
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
if (remainingScrollOffset > 0) {
|
|
79
|
+
if (offsetDiff === SHOW_AND_HIDE_BREAKPOINT) {
|
|
80
|
+
animateFab(isScrollingDown ? 'show' : 'hide');
|
|
81
|
+
} else if (
|
|
82
|
+
offsetDiff <= SHOW_AND_HIDE_BREAKPOINT &&
|
|
83
|
+
offsetDiff > COLLAPSE_BREAKPOINT
|
|
84
|
+
) {
|
|
85
|
+
animateFab('collapse');
|
|
86
|
+
} else if (offsetDiff <= COLLAPSE_BREAKPOINT) {
|
|
87
|
+
animateFab(isScrollingDown ? 'hide' : 'show');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
setRemainingScrollOffset(offsetDiff);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
React.useEffect(() => {
|
|
95
|
+
setRemainingScrollOffset(SHOW_AND_HIDE_BREAKPOINT);
|
|
96
|
+
}, [currentScrollDirection]);
|
|
97
|
+
|
|
98
|
+
return component === 'FAB' ? (
|
|
99
|
+
<FAB ref={ref} {...(fabProps as FABProps)} />
|
|
100
|
+
) : (
|
|
101
|
+
<ActionGroup ref={ref} {...(fabProps as ActionGroupHandles)} />
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export default AnimatedFAB;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
FlatListProps,
|
|
5
|
+
ScrollViewProps as RnScrollViewProps,
|
|
6
|
+
SectionListProps,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
import { FABProps } from '../FAB/FAB';
|
|
9
|
+
import AnimatedFAB from './AnimatedFAB';
|
|
10
|
+
import { ActionGroupProps } from '../FAB/ActionGroup';
|
|
11
|
+
|
|
12
|
+
export interface AnimatedScrollerProps<T> {
|
|
13
|
+
/**
|
|
14
|
+
* Scroll component, it can be ScrollView, FlatList or SectionList.
|
|
15
|
+
*/
|
|
16
|
+
ScrollComponent: React.ReactElement<
|
|
17
|
+
RnScrollViewProps | FlatListProps<T> | SectionListProps<T>
|
|
18
|
+
>;
|
|
19
|
+
/**
|
|
20
|
+
* FAB or FAB.ActionGroup props.
|
|
21
|
+
*/
|
|
22
|
+
fabProps: FABProps | ActionGroupProps;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function AnimatedScroller<T>({
|
|
26
|
+
ScrollComponent,
|
|
27
|
+
fabProps,
|
|
28
|
+
}: AnimatedScrollerProps<T>) {
|
|
29
|
+
const contentOffsetY = React.useRef(new Animated.Value(0)).current;
|
|
30
|
+
|
|
31
|
+
// Common props for all ScrollView, FlatList and SectionList.
|
|
32
|
+
const { onScroll, scrollEventThrottle } = ScrollComponent.props;
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<>
|
|
36
|
+
{React.cloneElement(ScrollComponent, {
|
|
37
|
+
...ScrollComponent.props,
|
|
38
|
+
scrollEventThrottle: scrollEventThrottle || 100,
|
|
39
|
+
onScroll: Animated.event(
|
|
40
|
+
[{ nativeEvent: { contentOffset: { y: contentOffsetY } } }],
|
|
41
|
+
{
|
|
42
|
+
useNativeDriver: false,
|
|
43
|
+
listener: onScroll,
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
})}
|
|
47
|
+
|
|
48
|
+
{!!fabProps && (
|
|
49
|
+
<AnimatedFAB fabProps={fabProps} contentOffsetY={contentOffsetY} />
|
|
50
|
+
)}
|
|
51
|
+
</>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default AnimatedScroller;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FlatList, FlatListProps } from 'react-native';
|
|
3
|
+
import { FABProps } from '../FAB/FAB';
|
|
4
|
+
import AnimatedScroller from './AnimatedScrollable';
|
|
5
|
+
import { ActionGroupProps } from '../FAB/ActionGroup';
|
|
6
|
+
|
|
7
|
+
export interface FlatListWithFABProps<T> extends FlatListProps<T> {
|
|
8
|
+
/**
|
|
9
|
+
* FAB or FAB.ActionGroup props props.
|
|
10
|
+
*/
|
|
11
|
+
fabProps: FABProps | ActionGroupProps;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function FlatListWithFAB<T>({ fabProps, ...props }: FlatListWithFABProps<T>) {
|
|
15
|
+
return (
|
|
16
|
+
<AnimatedScroller
|
|
17
|
+
ScrollComponent={<FlatList {...props} />}
|
|
18
|
+
fabProps={fabProps}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default FlatListWithFAB;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollView, ScrollViewProps } from 'react-native';
|
|
3
|
+
import AnimatedScroller from './AnimatedScrollable';
|
|
4
|
+
import { ActionGroupProps } from '../FAB/ActionGroup';
|
|
5
|
+
import { FABProps } from '../FAB/FAB';
|
|
6
|
+
|
|
7
|
+
export interface ScrollViewWithFABProps extends ScrollViewProps {
|
|
8
|
+
/**
|
|
9
|
+
* FAB or FAB.ActionGroup props props.
|
|
10
|
+
*/
|
|
11
|
+
fabProps: FABProps | ActionGroupProps;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const ScrollViewWithFAB = ({ fabProps, ...props }: ScrollViewWithFABProps) => (
|
|
15
|
+
<AnimatedScroller
|
|
16
|
+
ScrollComponent={<ScrollView {...props} />}
|
|
17
|
+
fabProps={fabProps}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export default ScrollViewWithFAB;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SectionList, SectionListProps } from 'react-native';
|
|
3
|
+
import AnimatedScroller from './AnimatedScrollable';
|
|
4
|
+
import { ActionGroupProps } from '../FAB/ActionGroup';
|
|
5
|
+
import { FABProps } from '../FAB/FAB';
|
|
6
|
+
|
|
7
|
+
export interface SectionListWithFABProps<T> extends SectionListProps<T> {
|
|
8
|
+
/**
|
|
9
|
+
* FAB or FAB.ActionGroup props props.
|
|
10
|
+
*/
|
|
11
|
+
fabProps: FABProps | ActionGroupProps;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function SectionListWithFAB<T>({
|
|
15
|
+
fabProps,
|
|
16
|
+
...props
|
|
17
|
+
}: SectionListWithFABProps<T>) {
|
|
18
|
+
return (
|
|
19
|
+
<AnimatedScroller
|
|
20
|
+
ScrollComponent={<SectionList {...props} />}
|
|
21
|
+
fabProps={fabProps}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default SectionListWithFAB;
|