@hero-design/rn 8.11.2 → 8.11.3

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.
@@ -1,9 +1,9 @@
1
- @hero-design/rn:build: cache hit, replaying output 19e687d21fa4a4ae
1
+ @hero-design/rn:build: cache hit, replaying output de0243cb44d0158b
2
2
  @hero-design/rn:build: $ yarn build:js && yarn build:types
3
3
  @hero-design/rn:build: $ rollup -c
4
4
  @hero-design/rn:build: 
5
5
  @hero-design/rn:build: src/index.ts → lib/index.js, es/index.js...
6
6
  @hero-design/rn:build: (!) Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
7
7
  @hero-design/rn:build: (!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/root/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
8
- @hero-design/rn:build: created lib/index.js, es/index.js in 28.5s
8
+ @hero-design/rn:build: created lib/index.js, es/index.js in 28.6s
9
9
  @hero-design/rn:build: $ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
package/es/index.js CHANGED
@@ -10847,7 +10847,8 @@ var CardCarousel = /*#__PURE__*/forwardRef(function (_ref, ref) {
10847
10847
  _ref$autoPlay = _ref.autoPlay,
10848
10848
  autoPlay = _ref$autoPlay === void 0 ? false : _ref$autoPlay,
10849
10849
  _ref$autoPlayInterval = _ref.autoPlayInterval,
10850
- autoPlayInterval = _ref$autoPlayInterval === void 0 ? 3000 : _ref$autoPlayInterval;
10850
+ autoPlayInterval = _ref$autoPlayInterval === void 0 ? 3000 : _ref$autoPlayInterval,
10851
+ onLayout = _ref.onLayout;
10851
10852
  var _useState = useState(0),
10852
10853
  _useState2 = _slicedToArray(_useState, 2),
10853
10854
  currentIndex = _useState2[0],
@@ -10928,9 +10929,12 @@ var CardCarousel = /*#__PURE__*/forwardRef(function (_ref, ref) {
10928
10929
  index: index
10929
10930
  };
10930
10931
  }, [itemWidth]);
10931
- var onLayout = useCallback(function (e) {
10932
+ var flatListOnLayout = useCallback(function (e) {
10932
10933
  setFlatListWidth(e.nativeEvent.layout.width);
10933
- }, [setFlatListWidth]);
10934
+ setTimeout(function () {
10935
+ onLayout === null || onLayout === void 0 ? void 0 : onLayout(e);
10936
+ });
10937
+ }, [setFlatListWidth, onLayout]);
10934
10938
  var renderItem = useCallback(function (_ref3) {
10935
10939
  var item = _ref3.item;
10936
10940
  return /*#__PURE__*/React.createElement(StyledItemWrapper, {
@@ -10943,10 +10947,13 @@ var CardCarousel = /*#__PURE__*/forwardRef(function (_ref, ref) {
10943
10947
  style: style,
10944
10948
  testID: testID
10945
10949
  }, /*#__PURE__*/React.createElement(FlatList, {
10946
- contentContainerStyle: {
10947
- paddingHorizontal: theme.__hd__.cardCarousel.space.contentContainerPaddingHorizontal
10950
+ contentInset: {
10951
+ top: 0,
10952
+ left: theme.__hd__.cardCarousel.space.contentContainerPaddingHorizontal,
10953
+ bottom: 0,
10954
+ right: theme.__hd__.cardCarousel.space.contentContainerPaddingHorizontal
10948
10955
  },
10949
- onLayout: onLayout,
10956
+ onLayout: flatListOnLayout,
10950
10957
  data: items,
10951
10958
  horizontal: true,
10952
10959
  showsHorizontalScrollIndicator: false,
@@ -10962,7 +10969,7 @@ var CardCarousel = /*#__PURE__*/forwardRef(function (_ref, ref) {
10962
10969
  },
10963
10970
  decelerationRate: "fast",
10964
10971
  renderToHardwareTextureAndroid: true,
10965
- snapToInterval: itemWidth + theme.__hd__.cardCarousel.space.carouselItemSpacing,
10972
+ snapToInterval: itemWidth,
10966
10973
  onViewableItemsChanged: visibleSlideChanged,
10967
10974
  viewabilityConfig: {
10968
10975
  itemVisiblePercentThreshold: 80
package/lib/index.js CHANGED
@@ -10876,7 +10876,8 @@ var CardCarousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
10876
10876
  _ref$autoPlay = _ref.autoPlay,
10877
10877
  autoPlay = _ref$autoPlay === void 0 ? false : _ref$autoPlay,
10878
10878
  _ref$autoPlayInterval = _ref.autoPlayInterval,
10879
- autoPlayInterval = _ref$autoPlayInterval === void 0 ? 3000 : _ref$autoPlayInterval;
10879
+ autoPlayInterval = _ref$autoPlayInterval === void 0 ? 3000 : _ref$autoPlayInterval,
10880
+ onLayout = _ref.onLayout;
10880
10881
  var _useState = React.useState(0),
10881
10882
  _useState2 = _slicedToArray(_useState, 2),
10882
10883
  currentIndex = _useState2[0],
@@ -10957,9 +10958,12 @@ var CardCarousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
10957
10958
  index: index
10958
10959
  };
10959
10960
  }, [itemWidth]);
10960
- var onLayout = React.useCallback(function (e) {
10961
+ var flatListOnLayout = React.useCallback(function (e) {
10961
10962
  setFlatListWidth(e.nativeEvent.layout.width);
10962
- }, [setFlatListWidth]);
10963
+ setTimeout(function () {
10964
+ onLayout === null || onLayout === void 0 ? void 0 : onLayout(e);
10965
+ });
10966
+ }, [setFlatListWidth, onLayout]);
10963
10967
  var renderItem = React.useCallback(function (_ref3) {
10964
10968
  var item = _ref3.item;
10965
10969
  return /*#__PURE__*/React__default["default"].createElement(StyledItemWrapper, {
@@ -10972,10 +10976,13 @@ var CardCarousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
10972
10976
  style: style,
10973
10977
  testID: testID
10974
10978
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.FlatList, {
10975
- contentContainerStyle: {
10976
- paddingHorizontal: theme.__hd__.cardCarousel.space.contentContainerPaddingHorizontal
10979
+ contentInset: {
10980
+ top: 0,
10981
+ left: theme.__hd__.cardCarousel.space.contentContainerPaddingHorizontal,
10982
+ bottom: 0,
10983
+ right: theme.__hd__.cardCarousel.space.contentContainerPaddingHorizontal
10977
10984
  },
10978
- onLayout: onLayout,
10985
+ onLayout: flatListOnLayout,
10979
10986
  data: items,
10980
10987
  horizontal: true,
10981
10988
  showsHorizontalScrollIndicator: false,
@@ -10991,7 +10998,7 @@ var CardCarousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
10991
10998
  },
10992
10999
  decelerationRate: "fast",
10993
11000
  renderToHardwareTextureAndroid: true,
10994
- snapToInterval: itemWidth + theme.__hd__.cardCarousel.space.carouselItemSpacing,
11001
+ snapToInterval: itemWidth,
10995
11002
  onViewableItemsChanged: visibleSlideChanged,
10996
11003
  viewabilityConfig: {
10997
11004
  itemVisiblePercentThreshold: 80
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.11.2",
3
+ "version": "8.11.3",
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": "8.11.2",
24
+ "@hero-design/colors": "8.11.3",
25
25
  "date-fns": "^2.16.1",
26
26
  "events": "^3.2.0",
27
27
  "hero-editor": "^1.9.21"
@@ -44,7 +44,7 @@
44
44
  "@babel/preset-typescript": "^7.17.12",
45
45
  "@babel/runtime": "^7.18.9",
46
46
  "@emotion/jest": "^11.9.3",
47
- "@hero-design/eslint-plugin": "8.11.2",
47
+ "@hero-design/eslint-plugin": "8.11.3",
48
48
  "@react-native-community/datetimepicker": "^3.5.2",
49
49
  "@react-native-community/slider": "4.1.12",
50
50
  "@rollup/plugin-babel": "^5.3.1",
@@ -60,9 +60,9 @@
60
60
  "@types/react-native": "^0.67.7",
61
61
  "@types/react-native-vector-icons": "^6.4.10",
62
62
  "babel-plugin-inline-import": "^3.0.0",
63
- "eslint-config-hd": "8.11.2",
63
+ "eslint-config-hd": "8.11.3",
64
64
  "jest": "^27.3.1",
65
- "prettier-config-hd": "8.11.2",
65
+ "prettier-config-hd": "8.11.3",
66
66
  "react": "18.0.0",
67
67
  "react-native": "0.69.7",
68
68
  "react-native-gesture-handler": "~2.1.0",
@@ -5,7 +5,12 @@ import React, {
5
5
  useRef,
6
6
  useState,
7
7
  } from 'react';
8
- import { FlatList, StyleProp, ViewStyle } from 'react-native';
8
+ import {
9
+ FlatList,
10
+ LayoutChangeEvent,
11
+ StyleProp,
12
+ ViewStyle,
13
+ } from 'react-native';
9
14
  import { useTheme } from '../../theme';
10
15
  import { ITEM_WIDTH_RATE, VIEW_POSITION_CENTER } from './contants';
11
16
  import {
@@ -34,9 +39,9 @@ export interface CardCarouselProps {
34
39
  */
35
40
  onItemIndexChange?: (index: number) => void;
36
41
  /**
37
- * Carousel data.
42
+ * Carousel items.
38
43
  */
39
- items: any[];
44
+ items: React.ReactNode[];
40
45
  /**
41
46
  * Indicates hide or show page control.
42
47
  */
@@ -53,6 +58,10 @@ export interface CardCarouselProps {
53
58
  * Component ref.
54
59
  */
55
60
  ref?: React.Ref<CardCarouselHandles>;
61
+ /*
62
+ * onLayout event handler.
63
+ */
64
+ onLayout?: (event: LayoutChangeEvent) => void;
56
65
  }
57
66
 
58
67
  export const CardCarousel = forwardRef<CardCarouselHandles, CardCarouselProps>(
@@ -65,6 +74,7 @@ export const CardCarousel = forwardRef<CardCarouselHandles, CardCarouselProps>(
65
74
  testID,
66
75
  autoPlay = false,
67
76
  autoPlayInterval = 3000,
77
+ onLayout,
68
78
  }: CardCarouselProps,
69
79
  ref?: React.Ref<CardCarouselHandles>
70
80
  ) => {
@@ -155,11 +165,14 @@ export const CardCarousel = forwardRef<CardCarouselHandles, CardCarouselProps>(
155
165
  [itemWidth]
156
166
  );
157
167
 
158
- const onLayout = useCallback(
168
+ const flatListOnLayout = useCallback(
159
169
  (e) => {
160
170
  setFlatListWidth(e.nativeEvent.layout.width);
171
+ setTimeout(() => {
172
+ onLayout?.(e);
173
+ });
161
174
  },
162
- [setFlatListWidth]
175
+ [setFlatListWidth, onLayout]
163
176
  );
164
177
 
165
178
  const renderItem = useCallback(
@@ -179,11 +192,15 @@ export const CardCarousel = forwardRef<CardCarouselHandles, CardCarouselProps>(
179
192
  return (
180
193
  <StyledWrapper style={style} testID={testID}>
181
194
  <FlatList
182
- contentContainerStyle={{
183
- paddingHorizontal:
195
+ contentInset={{
196
+ top: 0,
197
+ left: theme.__hd__.cardCarousel.space
198
+ .contentContainerPaddingHorizontal,
199
+ bottom: 0,
200
+ right:
184
201
  theme.__hd__.cardCarousel.space.contentContainerPaddingHorizontal,
185
202
  }}
186
- onLayout={onLayout}
203
+ onLayout={flatListOnLayout}
187
204
  data={items}
188
205
  horizontal
189
206
  showsHorizontalScrollIndicator={false}
@@ -197,14 +214,13 @@ export const CardCarousel = forwardRef<CardCarouselHandles, CardCarouselProps>(
197
214
  keyExtractor={(_, index) => `${index}`}
198
215
  decelerationRate="fast"
199
216
  renderToHardwareTextureAndroid
200
- snapToInterval={
201
- itemWidth + theme.__hd__.cardCarousel.space.carouselItemSpacing
202
- }
217
+ snapToInterval={itemWidth}
203
218
  onViewableItemsChanged={visibleSlideChanged}
204
219
  viewabilityConfig={{
205
220
  itemVisiblePercentThreshold: 80,
206
221
  }}
207
222
  />
223
+
208
224
  {!hidePageControl && (
209
225
  <StyledPageControl
210
226
  testID="pageControl"
@@ -15,9 +15,12 @@ exports[`CardCarousel should render correctly 1`] = `
15
15
  >
16
16
  <RCTScrollView
17
17
  bounces={false}
18
- contentContainerStyle={
18
+ contentInset={
19
19
  Object {
20
- "paddingHorizontal": 24,
20
+ "bottom": 0,
21
+ "left": 24,
22
+ "right": 24,
23
+ "top": 0,
21
24
  }
22
25
  }
23
26
  data={
@@ -51,7 +54,7 @@ exports[`CardCarousel should render correctly 1`] = `
51
54
  scrollEventThrottle={32}
52
55
  showsHorizontalScrollIndicator={false}
53
56
  snapToAlignment="center"
54
- snapToInterval={8}
57
+ snapToInterval={0}
55
58
  stickyHeaderIndices={Array []}
56
59
  viewabilityConfig={
57
60
  Object {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { StyleProp, ViewStyle } from 'react-native';
2
+ import { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';
3
3
  export declare type CardCarouselHandles = {
4
4
  snapToIndex: (index: number) => void;
5
5
  };
@@ -17,9 +17,9 @@ export interface CardCarouselProps {
17
17
  */
18
18
  onItemIndexChange?: (index: number) => void;
19
19
  /**
20
- * Carousel data.
20
+ * Carousel items.
21
21
  */
22
- items: any[];
22
+ items: React.ReactNode[];
23
23
  /**
24
24
  * Indicates hide or show page control.
25
25
  */
@@ -36,5 +36,6 @@ export interface CardCarouselProps {
36
36
  * Component ref.
37
37
  */
38
38
  ref?: React.Ref<CardCarouselHandles>;
39
+ onLayout?: (event: LayoutChangeEvent) => void;
39
40
  }
40
- export declare const CardCarousel: React.ForwardRefExoticComponent<Pick<CardCarouselProps, "style" | "testID" | "items" | "onItemIndexChange" | "hidePageControl" | "autoPlay" | "autoPlayInterval"> & React.RefAttributes<CardCarouselHandles>>;
41
+ export declare const CardCarousel: React.ForwardRefExoticComponent<Pick<CardCarouselProps, "style" | "onLayout" | "testID" | "items" | "onItemIndexChange" | "hidePageControl" | "autoPlay" | "autoPlayInterval"> & React.RefAttributes<CardCarouselHandles>>;
@@ -33,6 +33,6 @@ interface CarouselProps extends ViewProps {
33
33
  }
34
34
  export declare function useStateFromProp<T>(initialValue: T): [T, Dispatch<SetStateAction<T>>];
35
35
  declare const _default: (({ items, onItemIndexChange, renderActions, selectedItemIndex, style, shouldShowPagination, ...nativeProps }: CarouselProps) => JSX.Element) & {
36
- Card: React.ForwardRefExoticComponent<Pick<import("./CardCarousel").CardCarouselProps, "style" | "testID" | "items" | "onItemIndexChange" | "hidePageControl" | "autoPlay" | "autoPlayInterval"> & React.RefAttributes<import("./CardCarousel").CardCarouselHandles>>;
36
+ Card: React.ForwardRefExoticComponent<Pick<import("./CardCarousel").CardCarouselProps, "style" | "onLayout" | "testID" | "items" | "onItemIndexChange" | "hidePageControl" | "autoPlay" | "autoPlayInterval"> & React.RefAttributes<import("./CardCarousel").CardCarouselHandles>>;
37
37
  };
38
38
  export default _default;