@hero-design/rn 8.30.4 → 9.1.0-rc.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/es/index.js +176 -70
- package/lib/index.js +176 -70
- package/package.json +5 -5
- package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +33 -3
- package/src/components/Carousel/index.tsx +5 -18
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +982 -819
- package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +4 -11
- package/src/components/FAB/ActionGroup/index.tsx +142 -98
- package/src/components/FAB/AnimatedFABIcon.tsx +3 -5
- package/src/components/FAB/FAB.tsx +112 -28
- package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +27 -9
- package/src/components/FAB/__tests__/index.spec.tsx +22 -2
- package/src/components/Skeleton/__tests__/__snapshots__/index.spec.tsx.snap +14 -14
- package/src/components/Skeleton/index.tsx +7 -3
- package/src/types.ts +4 -0
- package/testUtils/setup.tsx +2 -0
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +1 -1
- package/types/components/FAB/ActionGroup/index.d.ts +7 -1
- package/types/components/FAB/FAB.d.ts +8 -2
- package/types/components/FAB/index.d.ts +3 -2
- package/types/types.d.ts +3 -1
package/lib/index.js
CHANGED
|
@@ -1025,6 +1025,7 @@ var palette$b = {
|
|
|
1025
1025
|
dodgerBlue: ultramarineBlue$3.base,
|
|
1026
1026
|
dodgerBlueDark15: ultramarineBlue$3.darken15,
|
|
1027
1027
|
dodgerBlueDark30: ultramarineBlue$3.darken30,
|
|
1028
|
+
dodgerBlueDark60: ultramarineBlue$3.darken60,
|
|
1028
1029
|
dodgerBlueLight30: ultramarineBlue$3.lighten30,
|
|
1029
1030
|
dodgerBlueLight45: ultramarineBlue$3.lighten45,
|
|
1030
1031
|
dodgerBlueLight60: ultramarineBlue$3.lighten60,
|
|
@@ -1033,6 +1034,7 @@ var palette$b = {
|
|
|
1033
1034
|
green: green$1.base,
|
|
1034
1035
|
greenDark15: green$1.darken15,
|
|
1035
1036
|
greenDark30: green$1.darken30,
|
|
1037
|
+
greenDark60: green$1.darken60,
|
|
1036
1038
|
greenDark75: green$1.darken75,
|
|
1037
1039
|
greenLight30: green$1.lighten30,
|
|
1038
1040
|
greenLight75: green$1.lighten75,
|
|
@@ -1043,6 +1045,7 @@ var palette$b = {
|
|
|
1043
1045
|
greyDark45: grey$2.darken45,
|
|
1044
1046
|
greyDark60: grey$2.darken60,
|
|
1045
1047
|
greyDark75: grey$2.darken75,
|
|
1048
|
+
greyLight30: grey$2.lighten30,
|
|
1046
1049
|
greyLight45: grey$2.lighten45,
|
|
1047
1050
|
greyLight60: grey$2.lighten60,
|
|
1048
1051
|
greyLight75: grey$2.lighten75,
|
|
@@ -1058,6 +1061,7 @@ var palette$b = {
|
|
|
1058
1061
|
orange: deepSaffron$3.base,
|
|
1059
1062
|
orangeDark15: deepSaffron$3.darken15,
|
|
1060
1063
|
orangeDark30: deepSaffron$3.darken30,
|
|
1064
|
+
orangeDark60: deepSaffron$3.darken60,
|
|
1061
1065
|
orangeDark75: deepSaffron$3.darken75,
|
|
1062
1066
|
orangeLight30: deepSaffron$3.lighten30,
|
|
1063
1067
|
orangeLight75: deepSaffron$3.lighten75,
|
|
@@ -1066,6 +1070,7 @@ var palette$b = {
|
|
|
1066
1070
|
pinkDark15: pink$1.darken15,
|
|
1067
1071
|
pinkDark30: pink$1.darken30,
|
|
1068
1072
|
pinkDark45: pink$1.darken45,
|
|
1073
|
+
pinkDark60: pink$1.darken60,
|
|
1069
1074
|
pinkDark75: pink$1.darken75,
|
|
1070
1075
|
pinkLight30: pink$1.lighten30,
|
|
1071
1076
|
pinkLight45: pink$1.lighten45,
|
|
@@ -1076,6 +1081,7 @@ var palette$b = {
|
|
|
1076
1081
|
red: vermilion$3.base,
|
|
1077
1082
|
redDark15: vermilion$3.darken15,
|
|
1078
1083
|
redDark30: vermilion$3.darken30,
|
|
1084
|
+
redDark60: vermilion$3.darken60,
|
|
1079
1085
|
redDark75: vermilion$3.darken75,
|
|
1080
1086
|
redLight15: vermilion$3.lighten15,
|
|
1081
1087
|
redLight30: vermilion$3.lighten30,
|
|
@@ -1100,6 +1106,7 @@ var palette$b = {
|
|
|
1100
1106
|
violetLight90: violet$2.lighten90,
|
|
1101
1107
|
yellow: yellow$1.base,
|
|
1102
1108
|
yellowDark15: yellow$1.darken15,
|
|
1109
|
+
yellowDark45: yellow$1.darken45,
|
|
1103
1110
|
yellowDark75: yellow$1.darken75,
|
|
1104
1111
|
yellowLight45: yellow$1.lighten45,
|
|
1105
1112
|
yellowLight60: yellow$1.lighten60,
|
|
@@ -11588,18 +11595,12 @@ var Carousel = function Carousel(_ref) {
|
|
|
11588
11595
|
clearTimeout(handle);
|
|
11589
11596
|
};
|
|
11590
11597
|
}, [currentSlideIndex, carouselRef]);
|
|
11591
|
-
var
|
|
11592
|
-
|
|
11593
|
-
|
|
11594
|
-
var
|
|
11595
|
-
/**
|
|
11596
|
-
* By rounding down, we ensure that any partial visibility of the next item does not affect the index value
|
|
11597
|
-
* This helps maintain consistent behavior and aligns with the desired functionality of considering the left-most visible item as the current item.
|
|
11598
|
-
*/
|
|
11599
|
-
var index = Math.floor(scrollPosition / containerWidth);
|
|
11600
|
-
// Call the callback function with the current index
|
|
11598
|
+
var visibleSlideChanged = React.useCallback(function (_ref2) {
|
|
11599
|
+
var viewableItems = _ref2.viewableItems;
|
|
11600
|
+
if (!viewableItems || viewableItems && !viewableItems.length) return;
|
|
11601
|
+
var index = viewableItems[0].index;
|
|
11601
11602
|
internalOnItemIndexChange(index);
|
|
11602
|
-
};
|
|
11603
|
+
}, []);
|
|
11603
11604
|
var viewConfig = React.useRef({
|
|
11604
11605
|
viewAreaCoveragePercentThreshold: 50
|
|
11605
11606
|
}).current;
|
|
@@ -11616,7 +11617,7 @@ var Carousel = function Carousel(_ref) {
|
|
|
11616
11617
|
pagingEnabled: true,
|
|
11617
11618
|
bounces: false,
|
|
11618
11619
|
data: items,
|
|
11619
|
-
|
|
11620
|
+
onViewableItemsChanged: visibleSlideChanged,
|
|
11620
11621
|
viewabilityConfig: viewConfig,
|
|
11621
11622
|
scrollEventThrottle: 32,
|
|
11622
11623
|
ref: carouselRef,
|
|
@@ -11629,8 +11630,8 @@ var Carousel = function Carousel(_ref) {
|
|
|
11629
11630
|
}], {
|
|
11630
11631
|
useNativeDriver: false
|
|
11631
11632
|
}),
|
|
11632
|
-
renderItem: function renderItem(
|
|
11633
|
-
var item =
|
|
11633
|
+
renderItem: function renderItem(_ref3) {
|
|
11634
|
+
var item = _ref3.item;
|
|
11634
11635
|
if (!item) return null;
|
|
11635
11636
|
var image = item.image,
|
|
11636
11637
|
heading = item.heading,
|
|
@@ -13010,11 +13011,9 @@ var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
|
|
|
13010
13011
|
iconProps = _objectWithoutProperties(_ref, _excluded$c);
|
|
13011
13012
|
var rotateAnimation = React.useRef(new reactNative.Animated.Value(active ? 1 : 0));
|
|
13012
13013
|
React.useEffect(function () {
|
|
13013
|
-
var animation = reactNative.Animated.
|
|
13014
|
+
var animation = reactNative.Animated.spring(rotateAnimation.current, {
|
|
13014
13015
|
toValue: active ? 1 : 0,
|
|
13015
|
-
useNativeDriver: reactNative.Platform.OS === 'ios' || reactNative.Platform.OS === 'android'
|
|
13016
|
-
easing: reactNative.Easing.inOut(reactNative.Easing.ease),
|
|
13017
|
-
duration: 300
|
|
13016
|
+
useNativeDriver: reactNative.Platform.OS === 'ios' || reactNative.Platform.OS === 'android'
|
|
13018
13017
|
});
|
|
13019
13018
|
animation.start();
|
|
13020
13019
|
return function () {
|
|
@@ -13036,6 +13035,11 @@ var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
|
|
|
13036
13035
|
}, iconProps)));
|
|
13037
13036
|
};
|
|
13038
13037
|
|
|
13038
|
+
if (reactNative.Platform.OS === 'android') {
|
|
13039
|
+
if (reactNative.UIManager.setLayoutAnimationEnabledExperimental) {
|
|
13040
|
+
reactNative.UIManager.setLayoutAnimationEnabledExperimental(true);
|
|
13041
|
+
}
|
|
13042
|
+
}
|
|
13039
13043
|
var IconOnlyContent = function IconOnlyContent(_ref) {
|
|
13040
13044
|
var icon = _ref.icon,
|
|
13041
13045
|
animated = _ref.animated,
|
|
@@ -13061,7 +13065,19 @@ var IconWithTextContent = function IconWithTextContent(_ref2) {
|
|
|
13061
13065
|
testID: "styled-fab-icon"
|
|
13062
13066
|
})), /*#__PURE__*/React__default["default"].createElement(StyledFABText, null, title));
|
|
13063
13067
|
};
|
|
13064
|
-
var
|
|
13068
|
+
var defaultAnimation = {
|
|
13069
|
+
create: {
|
|
13070
|
+
type: 'easeInEaseOut',
|
|
13071
|
+
property: 'opacity'
|
|
13072
|
+
},
|
|
13073
|
+
update: {
|
|
13074
|
+
type: 'spring',
|
|
13075
|
+
springDamping: 1
|
|
13076
|
+
},
|
|
13077
|
+
duration: 400
|
|
13078
|
+
};
|
|
13079
|
+
var FAB = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
13080
|
+
var _StyleSheet$flatten, _StyleSheet$flatten2;
|
|
13065
13081
|
var onPress = _ref3.onPress,
|
|
13066
13082
|
title = _ref3.title,
|
|
13067
13083
|
icon = _ref3.icon,
|
|
@@ -13069,22 +13085,75 @@ var FAB = function FAB(_ref3) {
|
|
|
13069
13085
|
testID = _ref3.testID,
|
|
13070
13086
|
active = _ref3.active,
|
|
13071
13087
|
style = _ref3.style;
|
|
13072
|
-
var isIconOnly = !title;
|
|
13073
13088
|
var theme = useTheme();
|
|
13074
|
-
|
|
13089
|
+
var _React$useState = React__default["default"].useState({
|
|
13090
|
+
hideTitle: false,
|
|
13091
|
+
hideButton: false
|
|
13092
|
+
}),
|
|
13093
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
13094
|
+
displayState = _React$useState2[0],
|
|
13095
|
+
setDisplayState = _React$useState2[1];
|
|
13096
|
+
var _React$useState3 = React__default["default"].useState(false),
|
|
13097
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
13098
|
+
canAnimate = _React$useState4[0],
|
|
13099
|
+
setCanAnimate = _React$useState4[1];
|
|
13100
|
+
var isIconOnly = displayState.hideTitle || active || !title;
|
|
13101
|
+
React.useImperativeHandle(ref, function () {
|
|
13102
|
+
return {
|
|
13103
|
+
show: function show() {
|
|
13104
|
+
setDisplayState({
|
|
13105
|
+
hideButton: false,
|
|
13106
|
+
hideTitle: false
|
|
13107
|
+
});
|
|
13108
|
+
},
|
|
13109
|
+
collapse: function collapse() {
|
|
13110
|
+
setDisplayState({
|
|
13111
|
+
hideButton: false,
|
|
13112
|
+
hideTitle: true
|
|
13113
|
+
});
|
|
13114
|
+
},
|
|
13115
|
+
hide: function hide() {
|
|
13116
|
+
setDisplayState(function (previousState) {
|
|
13117
|
+
return _objectSpread2(_objectSpread2({}, previousState), {}, {
|
|
13118
|
+
hideButton: true
|
|
13119
|
+
});
|
|
13120
|
+
});
|
|
13121
|
+
}
|
|
13122
|
+
};
|
|
13123
|
+
}, [displayState]);
|
|
13124
|
+
React.useEffect(function () {
|
|
13125
|
+
if (canAnimate) {
|
|
13126
|
+
reactNative.LayoutAnimation.configureNext(defaultAnimation);
|
|
13127
|
+
}
|
|
13128
|
+
}, [isIconOnly]);
|
|
13129
|
+
React.useEffect(function () {
|
|
13130
|
+
if (canAnimate) {
|
|
13131
|
+
reactNative.LayoutAnimation.configureNext(defaultAnimation);
|
|
13132
|
+
}
|
|
13133
|
+
}, [displayState.hideButton]);
|
|
13134
|
+
var marginBottom = Number((_StyleSheet$flatten = reactNative.StyleSheet.flatten(style)) === null || _StyleSheet$flatten === void 0 ? void 0 : _StyleSheet$flatten.marginBottom) || 0;
|
|
13135
|
+
return /*#__PURE__*/React__default["default"].createElement(StyledFAB$1
|
|
13136
|
+
/** Add a small timeout before executing animation to prevent flakiness on android */, {
|
|
13137
|
+
onLayout: function onLayout() {
|
|
13138
|
+
return setTimeout(function () {
|
|
13139
|
+
return setCanAnimate(true);
|
|
13140
|
+
}, 200);
|
|
13141
|
+
},
|
|
13075
13142
|
underlayColor: theme.__hd__.fab.colors.buttonPressedBackground,
|
|
13076
13143
|
onPress: onPress,
|
|
13077
|
-
style: style,
|
|
13144
|
+
style: [style, {
|
|
13145
|
+
bottom: displayState.hideButton ? -(marginBottom + theme.__hd__.fab.sizes.height * 2) : (_StyleSheet$flatten2 = reactNative.StyleSheet.flatten(style)) === null || _StyleSheet$flatten2 === void 0 ? void 0 : _StyleSheet$flatten2.bottom
|
|
13146
|
+
}],
|
|
13078
13147
|
testID: testID
|
|
13079
13148
|
}, isIconOnly ? /*#__PURE__*/React__default["default"].createElement(IconOnlyContent, {
|
|
13080
13149
|
animated: animated,
|
|
13081
13150
|
active: active,
|
|
13082
|
-
icon: icon
|
|
13151
|
+
icon: active ? 'add' : icon
|
|
13083
13152
|
}) : /*#__PURE__*/React__default["default"].createElement(IconWithTextContent, {
|
|
13084
13153
|
icon: icon,
|
|
13085
13154
|
title: title
|
|
13086
13155
|
}));
|
|
13087
|
-
};
|
|
13156
|
+
});
|
|
13088
13157
|
|
|
13089
13158
|
var StyledActionItem = index$a(reactNative.TouchableHighlight)(function (_ref) {
|
|
13090
13159
|
var theme = _ref.theme;
|
|
@@ -13181,40 +13250,55 @@ var StyledHeaderText = index$a(Typography.Text)(function (_ref3) {
|
|
|
13181
13250
|
};
|
|
13182
13251
|
});
|
|
13183
13252
|
|
|
13184
|
-
var
|
|
13185
|
-
var
|
|
13186
|
-
|
|
13187
|
-
|
|
13188
|
-
style
|
|
13189
|
-
|
|
13190
|
-
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
var ActionGroup = function ActionGroup(_ref2) {
|
|
13196
|
-
var headerTitle = _ref2.headerTitle,
|
|
13197
|
-
onPress = _ref2.onPress,
|
|
13198
|
-
active = _ref2.active,
|
|
13199
|
-
style = _ref2.style,
|
|
13200
|
-
items = _ref2.items,
|
|
13201
|
-
testID = _ref2.testID,
|
|
13202
|
-
fabTitle = _ref2.fabTitle,
|
|
13203
|
-
_ref2$fabIcon = _ref2.fabIcon,
|
|
13204
|
-
fabIcon = _ref2$fabIcon === void 0 ? 'add' : _ref2$fabIcon;
|
|
13253
|
+
var ActionGroup = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
13254
|
+
var headerTitle = _ref.headerTitle,
|
|
13255
|
+
onPress = _ref.onPress,
|
|
13256
|
+
active = _ref.active,
|
|
13257
|
+
style = _ref.style,
|
|
13258
|
+
items = _ref.items,
|
|
13259
|
+
testID = _ref.testID,
|
|
13260
|
+
fabTitle = _ref.fabTitle,
|
|
13261
|
+
_ref$fabIcon = _ref.fabIcon,
|
|
13262
|
+
fabIcon = _ref$fabIcon === void 0 ? 'add' : _ref$fabIcon;
|
|
13263
|
+
var fabRef = React.useRef(null);
|
|
13205
13264
|
var tranlateXAnimation = React.useRef(new reactNative.Animated.Value(active ? 1 : 0));
|
|
13206
|
-
React.
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13265
|
+
var animatedValues = React.useRef((items === null || items === void 0 ? void 0 : items.map(function () {
|
|
13266
|
+
return new reactNative.Animated.Value(0);
|
|
13267
|
+
})) || []).current;
|
|
13268
|
+
var translateYAnimations = animatedValues === null || animatedValues === void 0 ? void 0 : animatedValues.map(function (value) {
|
|
13269
|
+
return value.interpolate({
|
|
13270
|
+
inputRange: [0, 1],
|
|
13271
|
+
outputRange: active ? [100, 0] : [40, 0]
|
|
13211
13272
|
});
|
|
13212
|
-
animation.start();
|
|
13213
|
-
}, [active]);
|
|
13214
|
-
var interpolatedTranlateXAnimation = tranlateXAnimation.current.interpolate({
|
|
13215
|
-
inputRange: [0, 1],
|
|
13216
|
-
outputRange: [400, 0]
|
|
13217
13273
|
});
|
|
13274
|
+
React.useImperativeHandle(ref, function () {
|
|
13275
|
+
return {
|
|
13276
|
+
showFAB: function showFAB() {
|
|
13277
|
+
var _fabRef$current;
|
|
13278
|
+
return (_fabRef$current = fabRef.current) === null || _fabRef$current === void 0 ? void 0 : _fabRef$current.show();
|
|
13279
|
+
},
|
|
13280
|
+
collapseFAB: function collapseFAB() {
|
|
13281
|
+
var _fabRef$current2;
|
|
13282
|
+
return (_fabRef$current2 = fabRef.current) === null || _fabRef$current2 === void 0 ? void 0 : _fabRef$current2.collapse();
|
|
13283
|
+
},
|
|
13284
|
+
hideFAB: function hideFAB() {
|
|
13285
|
+
var _fabRef$current3;
|
|
13286
|
+
return (_fabRef$current3 = fabRef.current) === null || _fabRef$current3 === void 0 ? void 0 : _fabRef$current3.hide();
|
|
13287
|
+
}
|
|
13288
|
+
};
|
|
13289
|
+
}, [fabRef]);
|
|
13290
|
+
React.useEffect(function () {
|
|
13291
|
+
reactNative.Animated.spring(tranlateXAnimation.current, {
|
|
13292
|
+
toValue: active ? 1 : 0,
|
|
13293
|
+
useNativeDriver: reactNative.Platform.OS !== 'web'
|
|
13294
|
+
}).start();
|
|
13295
|
+
reactNative.Animated.stagger(20, animatedValues.map(function (value) {
|
|
13296
|
+
return reactNative.Animated.spring(value, {
|
|
13297
|
+
toValue: active ? 1 : 0,
|
|
13298
|
+
useNativeDriver: reactNative.Platform.OS !== 'web'
|
|
13299
|
+
});
|
|
13300
|
+
}).reverse()).start();
|
|
13301
|
+
}, [active, animatedValues]);
|
|
13218
13302
|
var interpolatedBackdropOpacityAnimation = tranlateXAnimation.current.interpolate({
|
|
13219
13303
|
inputRange: [0, 1],
|
|
13220
13304
|
outputRange: [0, 0.4]
|
|
@@ -13237,24 +13321,39 @@ var ActionGroup = function ActionGroup(_ref2) {
|
|
|
13237
13321
|
pointerEvents: active ? 'auto' : 'none',
|
|
13238
13322
|
testID: "action-group",
|
|
13239
13323
|
style: {
|
|
13240
|
-
opacity: interpolatedActionGroupOpacityAnimation
|
|
13324
|
+
opacity: interpolatedActionGroupOpacityAnimation
|
|
13325
|
+
}
|
|
13326
|
+
}, !!headerTitle && /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
|
|
13327
|
+
style: {
|
|
13241
13328
|
transform: [{
|
|
13242
|
-
|
|
13329
|
+
translateY: translateYAnimations[0]
|
|
13243
13330
|
}]
|
|
13244
13331
|
}
|
|
13245
|
-
},
|
|
13332
|
+
}, /*#__PURE__*/React__default["default"].createElement(StyledHeaderText, {
|
|
13246
13333
|
testID: "header-text"
|
|
13247
|
-
}, headerTitle), /*#__PURE__*/React__default["default"].createElement(
|
|
13248
|
-
|
|
13249
|
-
|
|
13334
|
+
}, headerTitle)), /*#__PURE__*/React__default["default"].createElement(Box, {
|
|
13335
|
+
style: [style, {
|
|
13336
|
+
paddingBottom: 0
|
|
13337
|
+
}]
|
|
13338
|
+
}, items === null || items === void 0 ? void 0 : items.map(function (itemProp, index) {
|
|
13339
|
+
return /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
|
|
13340
|
+
key: itemProp.key || "".concat(itemProp.icon, "_").concat(itemProp.title),
|
|
13341
|
+
style: {
|
|
13342
|
+
transform: [{
|
|
13343
|
+
translateY: translateYAnimations[index]
|
|
13344
|
+
}]
|
|
13345
|
+
}
|
|
13346
|
+
}, /*#__PURE__*/React__default["default"].createElement(ActionItem, itemProp));
|
|
13347
|
+
}))), /*#__PURE__*/React__default["default"].createElement(StyledFAB, {
|
|
13250
13348
|
testID: "fab",
|
|
13251
13349
|
icon: fabIcon,
|
|
13252
13350
|
onPress: onPress,
|
|
13253
13351
|
animated: true,
|
|
13254
13352
|
active: active,
|
|
13255
|
-
title: fabTitle
|
|
13353
|
+
title: fabTitle,
|
|
13354
|
+
ref: fabRef
|
|
13256
13355
|
}));
|
|
13257
|
-
};
|
|
13356
|
+
});
|
|
13258
13357
|
|
|
13259
13358
|
var index$6 = Object.assign(FAB, {
|
|
13260
13359
|
ActionGroup: ActionGroup
|
|
@@ -14937,7 +15036,7 @@ var getGradientColors = function getGradientColors(theme, intent) {
|
|
|
14937
15036
|
}
|
|
14938
15037
|
};
|
|
14939
15038
|
var Skeleton = function Skeleton(_ref) {
|
|
14940
|
-
var _StyleSheet$flatten;
|
|
15039
|
+
var _StyleSheet$flatten, _StyleSheet$flatten2;
|
|
14941
15040
|
var _ref$intent = _ref.intent,
|
|
14942
15041
|
intent = _ref$intent === void 0 ? 'light' : _ref$intent,
|
|
14943
15042
|
_ref$variant = _ref.variant,
|
|
@@ -14953,10 +15052,14 @@ var Skeleton = function Skeleton(_ref) {
|
|
|
14953
15052
|
_useState2 = _slicedToArray(_useState, 2),
|
|
14954
15053
|
containerWidth = _useState2[0],
|
|
14955
15054
|
setContainerWidth = _useState2[1];
|
|
14956
|
-
var _useState3 = React.useState(
|
|
15055
|
+
var _useState3 = React.useState(Number((_StyleSheet$flatten2 = reactNative.StyleSheet.flatten(style)) === null || _StyleSheet$flatten2 === void 0 ? void 0 : _StyleSheet$flatten2.height) || 0),
|
|
14957
15056
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
14958
|
-
|
|
14959
|
-
|
|
15057
|
+
containerHeight = _useState4[0],
|
|
15058
|
+
setContainerHeight = _useState4[1];
|
|
15059
|
+
var _useState5 = React.useState(false),
|
|
15060
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
15061
|
+
shouldStartAnimation = _useState6[0],
|
|
15062
|
+
setShouldStartAnimation = _useState6[1];
|
|
14960
15063
|
var animatedValue = React.useRef(new reactNative.Animated.Value(0)).current;
|
|
14961
15064
|
React.useEffect(function () {
|
|
14962
15065
|
if (shouldStartAnimation) {
|
|
@@ -14973,7 +15076,10 @@ var Skeleton = function Skeleton(_ref) {
|
|
|
14973
15076
|
outputRange: [-containerWidth, containerWidth]
|
|
14974
15077
|
});
|
|
14975
15078
|
var onContainerLayout = React.useCallback(function (e) {
|
|
14976
|
-
var
|
|
15079
|
+
var _e$nativeEvent$layout = e.nativeEvent.layout,
|
|
15080
|
+
width = _e$nativeEvent$layout.width,
|
|
15081
|
+
height = _e$nativeEvent$layout.height;
|
|
15082
|
+
setContainerHeight(height);
|
|
14977
15083
|
setContainerWidth(width);
|
|
14978
15084
|
if (!shouldStartAnimation) {
|
|
14979
15085
|
setShouldStartAnimation(true);
|
|
@@ -14991,8 +15097,8 @@ var Skeleton = function Skeleton(_ref) {
|
|
|
14991
15097
|
start: gradientPositions.start,
|
|
14992
15098
|
end: gradientPositions.end,
|
|
14993
15099
|
style: {
|
|
14994
|
-
width:
|
|
14995
|
-
height:
|
|
15100
|
+
width: containerWidth,
|
|
15101
|
+
height: containerHeight,
|
|
14996
15102
|
transform: [{
|
|
14997
15103
|
translateX: translateX
|
|
14998
15104
|
}]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.1.0-rc.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/native": "^11.9.3",
|
|
23
23
|
"@emotion/react": "^11.9.3",
|
|
24
|
-
"@hero-design/colors": "
|
|
24
|
+
"@hero-design/colors": "9.1.0-rc.0",
|
|
25
25
|
"date-fns": "^2.16.1",
|
|
26
26
|
"events": "^3.2.0",
|
|
27
27
|
"hero-editor": "^1.9.21"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@babel/preset-typescript": "^7.17.12",
|
|
46
46
|
"@babel/runtime": "^7.18.9",
|
|
47
47
|
"@emotion/jest": "^11.9.3",
|
|
48
|
-
"@hero-design/eslint-plugin": "
|
|
48
|
+
"@hero-design/eslint-plugin": "9.1.0-rc.0",
|
|
49
49
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
50
50
|
"@react-native-community/slider": "4.1.12",
|
|
51
51
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"@types/react-native": "^0.67.7",
|
|
62
62
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
63
63
|
"babel-plugin-inline-import": "^3.0.0",
|
|
64
|
-
"eslint-config-hd": "
|
|
64
|
+
"eslint-config-hd": "9.1.0-rc.0",
|
|
65
65
|
"eslint-plugin-import": "^2.27.5",
|
|
66
66
|
"jest": "^27.3.1",
|
|
67
|
-
"prettier-config-hd": "
|
|
67
|
+
"prettier-config-hd": "9.1.0-rc.0",
|
|
68
68
|
"react": "18.0.0",
|
|
69
69
|
"react-native": "0.69.7",
|
|
70
70
|
"react-native-gesture-handler": "~2.1.0",
|
|
@@ -99,6 +99,7 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
|
|
|
99
99
|
onScroll={[Function]}
|
|
100
100
|
onScrollBeginDrag={[Function]}
|
|
101
101
|
onScrollEndDrag={[Function]}
|
|
102
|
+
onViewableItemsChanged={[Function]}
|
|
102
103
|
pagingEnabled={true}
|
|
103
104
|
removeClippedSubviews={false}
|
|
104
105
|
renderItem={[Function]}
|
|
@@ -110,7 +111,16 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
|
|
|
110
111
|
"viewAreaCoveragePercentThreshold": 50,
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
|
-
viewabilityConfigCallbackPairs={
|
|
114
|
+
viewabilityConfigCallbackPairs={
|
|
115
|
+
Array [
|
|
116
|
+
Object {
|
|
117
|
+
"onViewableItemsChanged": [Function],
|
|
118
|
+
"viewabilityConfig": Object {
|
|
119
|
+
"viewAreaCoveragePercentThreshold": 50,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
]
|
|
123
|
+
}
|
|
114
124
|
>
|
|
115
125
|
<View>
|
|
116
126
|
<View
|
|
@@ -923,6 +933,7 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
|
|
|
923
933
|
onScroll={[Function]}
|
|
924
934
|
onScrollBeginDrag={[Function]}
|
|
925
935
|
onScrollEndDrag={[Function]}
|
|
936
|
+
onViewableItemsChanged={[Function]}
|
|
926
937
|
pagingEnabled={true}
|
|
927
938
|
removeClippedSubviews={false}
|
|
928
939
|
renderItem={[Function]}
|
|
@@ -934,7 +945,16 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
|
|
|
934
945
|
"viewAreaCoveragePercentThreshold": 50,
|
|
935
946
|
}
|
|
936
947
|
}
|
|
937
|
-
viewabilityConfigCallbackPairs={
|
|
948
|
+
viewabilityConfigCallbackPairs={
|
|
949
|
+
Array [
|
|
950
|
+
Object {
|
|
951
|
+
"onViewableItemsChanged": [Function],
|
|
952
|
+
"viewabilityConfig": Object {
|
|
953
|
+
"viewAreaCoveragePercentThreshold": 50,
|
|
954
|
+
},
|
|
955
|
+
},
|
|
956
|
+
]
|
|
957
|
+
}
|
|
938
958
|
>
|
|
939
959
|
<View>
|
|
940
960
|
<View
|
|
@@ -1600,6 +1620,7 @@ exports[`Carousel should call skip call back when press skip 1`] = `
|
|
|
1600
1620
|
onScroll={[Function]}
|
|
1601
1621
|
onScrollBeginDrag={[Function]}
|
|
1602
1622
|
onScrollEndDrag={[Function]}
|
|
1623
|
+
onViewableItemsChanged={[Function]}
|
|
1603
1624
|
pagingEnabled={true}
|
|
1604
1625
|
removeClippedSubviews={false}
|
|
1605
1626
|
renderItem={[Function]}
|
|
@@ -1611,7 +1632,16 @@ exports[`Carousel should call skip call back when press skip 1`] = `
|
|
|
1611
1632
|
"viewAreaCoveragePercentThreshold": 50,
|
|
1612
1633
|
}
|
|
1613
1634
|
}
|
|
1614
|
-
viewabilityConfigCallbackPairs={
|
|
1635
|
+
viewabilityConfigCallbackPairs={
|
|
1636
|
+
Array [
|
|
1637
|
+
Object {
|
|
1638
|
+
"onViewableItemsChanged": [Function],
|
|
1639
|
+
"viewabilityConfig": Object {
|
|
1640
|
+
"viewAreaCoveragePercentThreshold": 50,
|
|
1641
|
+
},
|
|
1642
|
+
},
|
|
1643
|
+
]
|
|
1644
|
+
}
|
|
1615
1645
|
>
|
|
1616
1646
|
<View>
|
|
1617
1647
|
<View
|
|
@@ -9,8 +9,6 @@ import React, {
|
|
|
9
9
|
import {
|
|
10
10
|
Animated,
|
|
11
11
|
FlatList,
|
|
12
|
-
NativeScrollEvent,
|
|
13
|
-
NativeSyntheticEvent,
|
|
14
12
|
StyleProp,
|
|
15
13
|
useWindowDimensions,
|
|
16
14
|
View,
|
|
@@ -129,22 +127,11 @@ const Carousel = ({
|
|
|
129
127
|
};
|
|
130
128
|
}, [currentSlideIndex, carouselRef]);
|
|
131
129
|
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
// Calculate the current index based on the scroll position and container width
|
|
136
|
-
const containerWidth = event.nativeEvent.layoutMeasurement.width;
|
|
137
|
-
const scrollPosition = event.nativeEvent.contentOffset.x;
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* By rounding down, we ensure that any partial visibility of the next item does not affect the index value
|
|
141
|
-
* This helps maintain consistent behavior and aligns with the desired functionality of considering the left-most visible item as the current item.
|
|
142
|
-
*/
|
|
143
|
-
const index = Math.floor(scrollPosition / containerWidth);
|
|
144
|
-
|
|
145
|
-
// Call the callback function with the current index
|
|
130
|
+
const visibleSlideChanged = useCallback(({ viewableItems }) => {
|
|
131
|
+
if (!viewableItems || (viewableItems && !viewableItems.length)) return;
|
|
132
|
+
const { index } = viewableItems[0];
|
|
146
133
|
internalOnItemIndexChange(index);
|
|
147
|
-
};
|
|
134
|
+
}, []);
|
|
148
135
|
|
|
149
136
|
const viewConfig = useRef({ viewAreaCoveragePercentThreshold: 50 }).current;
|
|
150
137
|
|
|
@@ -171,7 +158,7 @@ const Carousel = ({
|
|
|
171
158
|
pagingEnabled
|
|
172
159
|
bounces={false}
|
|
173
160
|
data={items}
|
|
174
|
-
|
|
161
|
+
onViewableItemsChanged={visibleSlideChanged}
|
|
175
162
|
viewabilityConfig={viewConfig}
|
|
176
163
|
scrollEventThrottle={32}
|
|
177
164
|
ref={carouselRef}
|