@hero-design/rn 8.55.1-rc2.0 → 8.55.1

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.
@@ -2,4 +2,4 @@
2
2
  src/index.ts → lib/index.js, es/index.js...
3
3
  (!) 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`.
4
4
  (!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/home/runner/work/hero-design/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
5
- created lib/index.js, es/index.js in 44.1s
5
+ created lib/index.js, es/index.js in 57.1s
package/CHANGELOG.md CHANGED
@@ -1,16 +1,10 @@
1
1
  # @hero-design/rn
2
2
 
3
- ## 8.55.1-rc2.0
3
+ ## 8.55.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - [#2647](https://github.com/Thinkei/hero-design/pull/2647) [`96d0a79e0`](https://github.com/Thinkei/hero-design/commit/96d0a79e008db83c915bbadc8d70a5403d6bd4e3) Thanks [@ttkien](https://github.com/ttkien)! - add pre-commit
8
-
9
- - [#2647](https://github.com/Thinkei/hero-design/pull/2647) [`35fcc3812`](https://github.com/Thinkei/hero-design/commit/35fcc3812a090140848c80ed8d5f39026c4c5ee2) Thanks [@ttkien](https://github.com/ttkien)! - yarn install after bump version
10
-
11
- - Updated dependencies [[`96d0a79e0`](https://github.com/Thinkei/hero-design/commit/96d0a79e008db83c915bbadc8d70a5403d6bd4e3), [`35fcc3812`](https://github.com/Thinkei/hero-design/commit/35fcc3812a090140848c80ed8d5f39026c4c5ee2)]:
12
- - @hero-design/colors@8.42.6-rc2.0
13
- - @hero-design/react-native-month-year-picker@8.42.7-rc2.0
7
+ - [#2666](https://github.com/Thinkei/hero-design/pull/2666) [`61807698e`](https://github.com/Thinkei/hero-design/commit/61807698e94cc831a9083f3d531131c86f4af220) Thanks [@ttkien](https://github.com/ttkien)! - [Carousel] replace useWindowsDimension with onLayout and convert Carousel example to react-native-web
14
8
 
15
9
  ## 8.55.0
16
10
 
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as reactNative from 'react-native';
2
- import { Platform, Dimensions, StyleSheet as StyleSheet$1, Animated, View, UIManager, LayoutAnimation, TouchableOpacity, Text as Text$1, Easing, Image as Image$1, TouchableWithoutFeedback, Pressable, SafeAreaView, KeyboardAvoidingView, TouchableHighlight, ScrollView, Modal as Modal$1, FlatList, useWindowDimensions, TextInput as TextInput$1, PanResponder, BackHandler, InteractionManager, Keyboard, SectionList, RefreshControl as RefreshControl$1 } from 'react-native';
2
+ import { Platform, Dimensions, StyleSheet as StyleSheet$1, Animated, View, UIManager, LayoutAnimation, TouchableOpacity, Text as Text$1, Easing, Image as Image$1, TouchableWithoutFeedback, Pressable, SafeAreaView, KeyboardAvoidingView, TouchableHighlight, ScrollView, Modal as Modal$1, FlatList, TextInput as TextInput$1, PanResponder, BackHandler, InteractionManager, useWindowDimensions, Keyboard, SectionList, RefreshControl as RefreshControl$1 } from 'react-native';
3
3
  import React, { useContext, createContext, createElement, useMemo, forwardRef, useEffect, useCallback, useRef, useState, memo, useReducer, useLayoutEffect, useImperativeHandle, isValidElement } from 'react';
4
4
  import { createIconSet } from 'react-native-vector-icons';
5
5
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -12376,8 +12376,15 @@ var Carousel = function Carousel(_ref) {
12376
12376
  onItemIndexChange(index);
12377
12377
  }
12378
12378
  }, [setCurrentSlideIndex, onItemIndexChange]);
12379
- var _useWindowDimensions = useWindowDimensions(),
12380
- width = _useWindowDimensions.width;
12379
+ var _useState3 = useState(0),
12380
+ _useState4 = _slicedToArray(_useState3, 2),
12381
+ flatListWidth = _useState4[0],
12382
+ setFlatListWidth = _useState4[1];
12383
+ var itemWidth = flatListWidth;
12384
+ var flatListOnLayout = useCallback(function (e) {
12385
+ setFlatListWidth(e.nativeEvent.layout.width);
12386
+ }, [setFlatListWidth]);
12387
+ var width = flatListWidth;
12381
12388
  var scrollX = useRef(new Animated.Value(0)).current;
12382
12389
  useEffect(function () {
12383
12390
  // must use setTimeout since when layout is mounted, the pagination dots are not set correct scrollX
@@ -12392,7 +12399,7 @@ var Carousel = function Carousel(_ref) {
12392
12399
  return function () {
12393
12400
  clearTimeout(handle);
12394
12401
  };
12395
- }, [currentSlideIndex, carouselRef]);
12402
+ }, [currentSlideIndex, carouselRef, scrollX, width]);
12396
12403
  var viewConfig = useRef({
12397
12404
  viewAreaCoveragePercentThreshold: 50
12398
12405
  }).current;
@@ -12413,6 +12420,7 @@ var Carousel = function Carousel(_ref) {
12413
12420
  numberOfPages: items.length,
12414
12421
  currentPage: currentSlideIndex
12415
12422
  })), /*#__PURE__*/React.createElement(StyledCarouselView, null, /*#__PURE__*/React.createElement(FlatList, {
12423
+ onLayout: flatListOnLayout,
12416
12424
  testID: testID ? "".concat(testID, "_flatlist") : undefined,
12417
12425
  horizontal: true,
12418
12426
  showsHorizontalScrollIndicator: false,
@@ -12446,6 +12454,13 @@ var Carousel = function Carousel(_ref) {
12446
12454
  content: content,
12447
12455
  width: width
12448
12456
  });
12457
+ },
12458
+ getItemLayout: function getItemLayout(_, index) {
12459
+ return {
12460
+ length: itemWidth,
12461
+ offset: itemWidth * index,
12462
+ index: index
12463
+ };
12449
12464
  }
12450
12465
  }), /*#__PURE__*/React.createElement(StyledCarouselFooterWrapper, null, renderActions && renderActions(currentSlideIndex), pageControlPosition === 'bottom' && shouldRenderPagination && /*#__PURE__*/React.createElement(StyledPageControl, {
12451
12466
  numberOfPages: items.length,
package/lib/index.js CHANGED
@@ -12406,8 +12406,15 @@ var Carousel = function Carousel(_ref) {
12406
12406
  onItemIndexChange(index);
12407
12407
  }
12408
12408
  }, [setCurrentSlideIndex, onItemIndexChange]);
12409
- var _useWindowDimensions = reactNative.useWindowDimensions(),
12410
- width = _useWindowDimensions.width;
12409
+ var _useState3 = React.useState(0),
12410
+ _useState4 = _slicedToArray(_useState3, 2),
12411
+ flatListWidth = _useState4[0],
12412
+ setFlatListWidth = _useState4[1];
12413
+ var itemWidth = flatListWidth;
12414
+ var flatListOnLayout = React.useCallback(function (e) {
12415
+ setFlatListWidth(e.nativeEvent.layout.width);
12416
+ }, [setFlatListWidth]);
12417
+ var width = flatListWidth;
12411
12418
  var scrollX = React.useRef(new reactNative.Animated.Value(0)).current;
12412
12419
  React.useEffect(function () {
12413
12420
  // must use setTimeout since when layout is mounted, the pagination dots are not set correct scrollX
@@ -12422,7 +12429,7 @@ var Carousel = function Carousel(_ref) {
12422
12429
  return function () {
12423
12430
  clearTimeout(handle);
12424
12431
  };
12425
- }, [currentSlideIndex, carouselRef]);
12432
+ }, [currentSlideIndex, carouselRef, scrollX, width]);
12426
12433
  var viewConfig = React.useRef({
12427
12434
  viewAreaCoveragePercentThreshold: 50
12428
12435
  }).current;
@@ -12443,6 +12450,7 @@ var Carousel = function Carousel(_ref) {
12443
12450
  numberOfPages: items.length,
12444
12451
  currentPage: currentSlideIndex
12445
12452
  })), /*#__PURE__*/React__default["default"].createElement(StyledCarouselView, null, /*#__PURE__*/React__default["default"].createElement(reactNative.FlatList, {
12453
+ onLayout: flatListOnLayout,
12446
12454
  testID: testID ? "".concat(testID, "_flatlist") : undefined,
12447
12455
  horizontal: true,
12448
12456
  showsHorizontalScrollIndicator: false,
@@ -12476,6 +12484,13 @@ var Carousel = function Carousel(_ref) {
12476
12484
  content: content,
12477
12485
  width: width
12478
12486
  });
12487
+ },
12488
+ getItemLayout: function getItemLayout(_, index) {
12489
+ return {
12490
+ length: itemWidth,
12491
+ offset: itemWidth * index,
12492
+ index: index
12493
+ };
12479
12494
  }
12480
12495
  }), /*#__PURE__*/React__default["default"].createElement(StyledCarouselFooterWrapper, null, renderActions && renderActions(currentSlideIndex), pageControlPosition === 'bottom' && shouldRenderPagination && /*#__PURE__*/React__default["default"].createElement(StyledPageControl, {
12481
12496
  numberOfPages: items.length,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.55.1-rc2.0",
3
+ "version": "8.55.1",
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.6-rc2.0",
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.7-rc2.0",
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.1-rc2.0",
52
- "@hero-design/react-native-month-year-picker": "^8.42.7-rc2.0",
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.5-rc2.0",
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.5-rc2.0",
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",
@@ -7,3 +7,4 @@ sonar.sources=.
7
7
  sonar.inclusions=**/*
8
8
  sonar.exclusions=**/__tests__/**,**/public/**
9
9
  sonar.java.binaries=**/src/main/java
10
+ sonar.javascript.lcov.reportPaths=./coverage/lcov.info
@@ -97,6 +97,7 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
97
97
  }
98
98
  getItem={[Function]}
99
99
  getItemCount={[Function]}
100
+ getItemLayout={[Function]}
100
101
  horizontal={true}
101
102
  keyExtractor={[Function]}
102
103
  onContentSizeChange={[Function]}
@@ -133,7 +134,6 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
133
134
  <View>
134
135
  <View
135
136
  onFocusCapture={[Function]}
136
- onLayout={[Function]}
137
137
  style={
138
138
  [
139
139
  {
@@ -148,7 +148,7 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
148
148
  [
149
149
  {},
150
150
  {
151
- "width": 750,
151
+ "width": 300,
152
152
  },
153
153
  ]
154
154
  }
@@ -185,13 +185,13 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
185
185
  },
186
186
  [
187
187
  {
188
- "width": 750,
188
+ "width": 300,
189
189
  },
190
190
  undefined,
191
191
  ],
192
192
  ]
193
193
  }
194
- width={750}
194
+ width={300}
195
195
  >
196
196
  <Text
197
197
  allowFontScaling={false}
@@ -244,7 +244,6 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
244
244
  </View>
245
245
  <View
246
246
  onFocusCapture={[Function]}
247
- onLayout={[Function]}
248
247
  style={
249
248
  [
250
249
  {
@@ -259,7 +258,7 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
259
258
  [
260
259
  {},
261
260
  {
262
- "width": 750,
261
+ "width": 300,
263
262
  },
264
263
  ]
265
264
  }
@@ -300,13 +299,13 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
300
299
  },
301
300
  [
302
301
  {
303
- "width": 750,
302
+ "width": 300,
304
303
  },
305
304
  undefined,
306
305
  ],
307
306
  ]
308
307
  }
309
- width={750}
308
+ width={300}
310
309
  >
311
310
  <Image
312
311
  source={
@@ -376,7 +375,6 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
376
375
  </View>
377
376
  <View
378
377
  onFocusCapture={[Function]}
379
- onLayout={[Function]}
380
378
  style={
381
379
  [
382
380
  {
@@ -391,7 +389,7 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
391
389
  [
392
390
  {},
393
391
  {
394
- "width": 750,
392
+ "width": 300,
395
393
  },
396
394
  ]
397
395
  }
@@ -438,13 +436,13 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
438
436
  },
439
437
  [
440
438
  {
441
- "width": 750,
439
+ "width": 300,
442
440
  },
443
441
  undefined,
444
442
  ],
445
443
  ]
446
444
  }
447
- width={750}
445
+ width={300}
448
446
  >
449
447
  <Text
450
448
  allowFontScaling={false}
@@ -497,7 +495,6 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
497
495
  </View>
498
496
  <View
499
497
  onFocusCapture={[Function]}
500
- onLayout={[Function]}
501
498
  style={
502
499
  [
503
500
  {
@@ -512,7 +509,7 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
512
509
  [
513
510
  {},
514
511
  {
515
- "width": 750,
512
+ "width": 300,
516
513
  },
517
514
  ]
518
515
  }
@@ -557,13 +554,13 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
557
554
  },
558
555
  [
559
556
  {
560
- "width": 750,
557
+ "width": 300,
561
558
  },
562
559
  undefined,
563
560
  ],
564
561
  ]
565
562
  }
566
- width={750}
563
+ width={300}
567
564
  >
568
565
  <Text
569
566
  allowFontScaling={false}
@@ -991,6 +988,7 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
991
988
  }
992
989
  getItem={[Function]}
993
990
  getItemCount={[Function]}
991
+ getItemLayout={[Function]}
994
992
  horizontal={true}
995
993
  keyExtractor={[Function]}
996
994
  onContentSizeChange={[Function]}
@@ -1027,7 +1025,6 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
1027
1025
  <View>
1028
1026
  <View
1029
1027
  onFocusCapture={[Function]}
1030
- onLayout={[Function]}
1031
1028
  style={
1032
1029
  [
1033
1030
  {
@@ -1042,7 +1039,7 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
1042
1039
  [
1043
1040
  {},
1044
1041
  {
1045
- "width": 750,
1042
+ "width": 300,
1046
1043
  },
1047
1044
  ]
1048
1045
  }
@@ -1079,13 +1076,13 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
1079
1076
  },
1080
1077
  [
1081
1078
  {
1082
- "width": 750,
1079
+ "width": 300,
1083
1080
  },
1084
1081
  undefined,
1085
1082
  ],
1086
1083
  ]
1087
1084
  }
1088
- width={750}
1085
+ width={300}
1089
1086
  >
1090
1087
  <Text
1091
1088
  allowFontScaling={false}
@@ -1138,7 +1135,6 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
1138
1135
  </View>
1139
1136
  <View
1140
1137
  onFocusCapture={[Function]}
1141
- onLayout={[Function]}
1142
1138
  style={
1143
1139
  [
1144
1140
  {
@@ -1153,7 +1149,7 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
1153
1149
  [
1154
1150
  {},
1155
1151
  {
1156
- "width": 750,
1152
+ "width": 300,
1157
1153
  },
1158
1154
  ]
1159
1155
  }
@@ -1194,13 +1190,13 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
1194
1190
  },
1195
1191
  [
1196
1192
  {
1197
- "width": 750,
1193
+ "width": 300,
1198
1194
  },
1199
1195
  undefined,
1200
1196
  ],
1201
1197
  ]
1202
1198
  }
1203
- width={750}
1199
+ width={300}
1204
1200
  >
1205
1201
  <Image
1206
1202
  source={
@@ -1270,7 +1266,6 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
1270
1266
  </View>
1271
1267
  <View
1272
1268
  onFocusCapture={[Function]}
1273
- onLayout={[Function]}
1274
1269
  style={
1275
1270
  [
1276
1271
  {
@@ -1285,7 +1280,7 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
1285
1280
  [
1286
1281
  {},
1287
1282
  {
1288
- "width": 750,
1283
+ "width": 300,
1289
1284
  },
1290
1285
  ]
1291
1286
  }
@@ -1332,13 +1327,13 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
1332
1327
  },
1333
1328
  [
1334
1329
  {
1335
- "width": 750,
1330
+ "width": 300,
1336
1331
  },
1337
1332
  undefined,
1338
1333
  ],
1339
1334
  ]
1340
1335
  }
1341
- width={750}
1336
+ width={300}
1342
1337
  >
1343
1338
  <Text
1344
1339
  allowFontScaling={false}
@@ -1391,7 +1386,6 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
1391
1386
  </View>
1392
1387
  <View
1393
1388
  onFocusCapture={[Function]}
1394
- onLayout={[Function]}
1395
1389
  style={
1396
1390
  [
1397
1391
  {
@@ -1406,7 +1400,7 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
1406
1400
  [
1407
1401
  {},
1408
1402
  {
1409
- "width": 750,
1403
+ "width": 300,
1410
1404
  },
1411
1405
  ]
1412
1406
  }
@@ -1451,814 +1445,13 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
1451
1445
  },
1452
1446
  [
1453
1447
  {
1454
- "width": 750,
1448
+ "width": 300,
1455
1449
  },
1456
1450
  undefined,
1457
1451
  ],
1458
1452
  ]
1459
1453
  }
1460
- width={750}
1461
- >
1462
- <Text
1463
- allowFontScaling={false}
1464
- style={
1465
- [
1466
- {
1467
- "color": "#001f23",
1468
- "fontFamily": "RebondGrotesque-SemiBold",
1469
- "fontSize": 36,
1470
- "letterSpacing": 1.5,
1471
- "lineHeight": 44,
1472
- },
1473
- [
1474
- {
1475
- "marginBottom": 16,
1476
- "marginTop": 8,
1477
- },
1478
- undefined,
1479
- ],
1480
- ]
1481
- }
1482
- themeIntent="body"
1483
- themeLevel="h1"
1484
- themeTypeface="playful"
1485
- >
1486
- Test slide 4
1487
- </Text>
1488
- </View>
1489
- </View>
1490
- </View>
1491
- </View>
1492
- </RCTScrollView>
1493
- <View
1494
- style={
1495
- [
1496
- {
1497
- "flexDirection": "row",
1498
- "justifyContent": "space-between",
1499
- "marginBottom": 24,
1500
- "paddingHorizontal": 24,
1501
- "paddingVertical": 16,
1502
- },
1503
- undefined,
1504
- ]
1505
- }
1506
- >
1507
- <View
1508
- accessibilityState={
1509
- {
1510
- "disabled": false,
1511
- }
1512
- }
1513
- accessibilityValue={
1514
- {
1515
- "max": undefined,
1516
- "min": undefined,
1517
- "now": undefined,
1518
- "text": undefined,
1519
- }
1520
- }
1521
- accessible={true}
1522
- focusable={true}
1523
- onClick={[Function]}
1524
- onResponderGrant={[Function]}
1525
- onResponderMove={[Function]}
1526
- onResponderRelease={[Function]}
1527
- onResponderTerminate={[Function]}
1528
- onResponderTerminationRequest={[Function]}
1529
- onStartShouldSetResponder={[Function]}
1530
- style={
1531
- [
1532
- {
1533
- "alignItems": "center",
1534
- "alignSelf": "stretch",
1535
- "backgroundColor": "#401960",
1536
- "borderRadius": 32,
1537
- "flexDirection": "row",
1538
- "height": 60,
1539
- "justifyContent": "center",
1540
- "padding": 16,
1541
- },
1542
- undefined,
1543
- ]
1544
- }
1545
- >
1546
- <Text
1547
- allowFontScaling={false}
1548
- disabled={false}
1549
- ellipsizeMode="tail"
1550
- numberOfLines={1}
1551
- style={
1552
- [
1553
- {
1554
- "color": "#001f23",
1555
- "fontFamily": "BeVietnamPro-SemiBold",
1556
- "fontSize": 18,
1557
- "letterSpacing": 0.24,
1558
- "lineHeight": 28,
1559
- },
1560
- [
1561
- {
1562
- "color": "#ffffff",
1563
- "flexShrink": 1,
1564
- "textAlign": "center",
1565
- },
1566
- undefined,
1567
- ],
1568
- ]
1569
- }
1570
- themeButtonVariant="filled-primary"
1571
- themeIntent="body"
1572
- themeLevel="h5"
1573
- themeTypeface="neutral"
1574
- >
1575
- Skip
1576
- </Text>
1577
- </View>
1578
- </View>
1579
- </View>
1580
- </View>
1581
- <View
1582
- pointerEvents="box-none"
1583
- position="bottom"
1584
- style={
1585
- [
1586
- {
1587
- "bottom": 0,
1588
- "elevation": 9999,
1589
- "flexDirection": "column-reverse",
1590
- "left": 0,
1591
- "paddingHorizontal": 24,
1592
- "paddingVertical": 16,
1593
- "position": "absolute",
1594
- "right": 0,
1595
- "top": 0,
1596
- },
1597
- undefined,
1598
- ]
1599
- }
1600
- />
1601
- </View>
1602
- `;
1603
-
1604
- exports[`Carousel should call skip call back when press skip 1`] = `
1605
- <View
1606
- style={
1607
- {
1608
- "flex": 1,
1609
- }
1610
- }
1611
- >
1612
- <View
1613
- testID="carousel"
1614
- >
1615
- <View
1616
- style={
1617
- [
1618
- {
1619
- "backgroundColor": "#ece8ef",
1620
- "bottom": 0,
1621
- "left": 0,
1622
- "position": "absolute",
1623
- "right": 0,
1624
- "top": 0,
1625
- },
1626
- undefined,
1627
- ]
1628
- }
1629
- themeSlideBackground="#ece8ef"
1630
- />
1631
- <View
1632
- style={
1633
- [
1634
- {
1635
- "alignItems": "center",
1636
- "height": 48,
1637
- "justifyContent": "center",
1638
- },
1639
- undefined,
1640
- ]
1641
- }
1642
- >
1643
- <View
1644
- style={
1645
- [
1646
- {
1647
- "alignItems": "center",
1648
- "flexDirection": "row",
1649
- },
1650
- [
1651
- {
1652
- "paddingVertical": 8,
1653
- },
1654
- undefined,
1655
- ],
1656
- ]
1657
- }
1658
- >
1659
- <View
1660
- accessibilityState={
1661
- {
1662
- "selected": true,
1663
- }
1664
- }
1665
- collapsable={false}
1666
- style={
1667
- {
1668
- "backgroundColor": "#401960",
1669
- "borderRadius": 999,
1670
- "height": 8,
1671
- "marginHorizontal": 8,
1672
- "opacity": 1,
1673
- "width": 24,
1674
- }
1675
- }
1676
- testID="page-control-indicator0"
1677
- />
1678
- <View
1679
- accessibilityState={
1680
- {
1681
- "selected": false,
1682
- }
1683
- }
1684
- collapsable={false}
1685
- style={
1686
- {
1687
- "backgroundColor": "#401960",
1688
- "borderRadius": 999,
1689
- "height": 8,
1690
- "marginHorizontal": 8,
1691
- "opacity": 0.5,
1692
- "width": 8,
1693
- }
1694
- }
1695
- testID="page-control-indicator1"
1696
- />
1697
- <View
1698
- accessibilityState={
1699
- {
1700
- "selected": false,
1701
- }
1702
- }
1703
- collapsable={false}
1704
- style={
1705
- {
1706
- "backgroundColor": "#401960",
1707
- "borderRadius": 999,
1708
- "height": 8,
1709
- "marginHorizontal": 8,
1710
- "opacity": 0.5,
1711
- "width": 8,
1712
- }
1713
- }
1714
- testID="page-control-indicator2"
1715
- />
1716
- <View
1717
- accessibilityState={
1718
- {
1719
- "selected": false,
1720
- }
1721
- }
1722
- collapsable={false}
1723
- style={
1724
- {
1725
- "backgroundColor": "#401960",
1726
- "borderRadius": 999,
1727
- "height": 8,
1728
- "marginHorizontal": 8,
1729
- "opacity": 0.5,
1730
- "width": 8,
1731
- }
1732
- }
1733
- testID="page-control-indicator3"
1734
- />
1735
- </View>
1736
- </View>
1737
- <View
1738
- style={
1739
- [
1740
- {
1741
- "flexGrow": 2,
1742
- "justifyContent": "space-between",
1743
- },
1744
- undefined,
1745
- ]
1746
- }
1747
- >
1748
- <RCTScrollView
1749
- bounces={false}
1750
- data={
1751
- [
1752
- {
1753
- "background": "#ece8ef",
1754
- "body": "Access your Work, Money and Benefits in the palm of your hand.",
1755
- "heading": "Welcome to the new Employment Hero app",
1756
- "image": 1,
1757
- },
1758
- {
1759
- "background": "#ccd2d3",
1760
- "body": "Our app now has a new bright clean modern look and feel with the same great features.",
1761
- "content": <Image
1762
- source={
1763
- {
1764
- "uri": "https://picsum.photos/30",
1765
- }
1766
- }
1767
- />,
1768
- "heading": "Same app with a new look!",
1769
- "image": "https://picsum.photos/800/1200",
1770
- },
1771
- {
1772
- "background": "#ccd2d3",
1773
- "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus vitae pulvinar quam, ac facilisis massa. Aliquam facilisis nisi eu justo dignissim, vel tempus justo iaculis.",
1774
- "heading": "Easier to get around",
1775
- "image": {
1776
- "height": 100,
1777
- "resizeMode": "cover",
1778
- "uri": "https://picsum.photos/1200/800",
1779
- "width": 30,
1780
- },
1781
- },
1782
- {
1783
- "background": "#ccd2d3",
1784
- "heading": "Test slide 4",
1785
- "image": {
1786
- "height": 100,
1787
- "uri": "https://picsum.photos/1200/800",
1788
- "width": 30,
1789
- },
1790
- },
1791
- ]
1792
- }
1793
- getItem={[Function]}
1794
- getItemCount={[Function]}
1795
- horizontal={true}
1796
- keyExtractor={[Function]}
1797
- onContentSizeChange={[Function]}
1798
- onLayout={[Function]}
1799
- onMomentumScrollBegin={[Function]}
1800
- onMomentumScrollEnd={[Function]}
1801
- onScroll={[Function]}
1802
- onScrollBeginDrag={[Function]}
1803
- onScrollEndDrag={[Function]}
1804
- onViewableItemsChanged={[Function]}
1805
- pagingEnabled={true}
1806
- removeClippedSubviews={false}
1807
- renderItem={[Function]}
1808
- scrollEventThrottle={32}
1809
- showsHorizontalScrollIndicator={false}
1810
- stickyHeaderIndices={[]}
1811
- testID="carousel_flatlist"
1812
- viewabilityConfig={
1813
- {
1814
- "viewAreaCoveragePercentThreshold": 50,
1815
- }
1816
- }
1817
- viewabilityConfigCallbackPairs={
1818
- [
1819
- {
1820
- "onViewableItemsChanged": [Function],
1821
- "viewabilityConfig": {
1822
- "viewAreaCoveragePercentThreshold": 50,
1823
- },
1824
- },
1825
- ]
1826
- }
1827
- >
1828
- <View>
1829
- <View
1830
- onFocusCapture={[Function]}
1831
- onLayout={[Function]}
1832
- style={
1833
- [
1834
- {
1835
- "flexDirection": "row",
1836
- },
1837
- null,
1838
- ]
1839
- }
1840
- >
1841
- <View
1842
- style={
1843
- [
1844
- {},
1845
- {
1846
- "width": 750,
1847
- },
1848
- ]
1849
- }
1850
- >
1851
- <Image
1852
- source={1}
1853
- style={
1854
- [
1855
- {
1856
- "borderRadius": 0,
1857
- "height": 72,
1858
- "width": 72,
1859
- },
1860
- [
1861
- {
1862
- "flex": 1,
1863
- "flexGrow": 2,
1864
- "resizeMode": "contain",
1865
- "width": "100%",
1866
- },
1867
- undefined,
1868
- ],
1869
- ]
1870
- }
1871
- />
1872
- <View
1873
- marginTop="large"
1874
- paddingHorizontal="large"
1875
- style={
1876
- [
1877
- {
1878
- "marginTop": 24,
1879
- "paddingHorizontal": 24,
1880
- },
1881
- [
1882
- {
1883
- "width": 750,
1884
- },
1885
- undefined,
1886
- ],
1887
- ]
1888
- }
1889
- width={750}
1890
- >
1891
- <Text
1892
- allowFontScaling={false}
1893
- style={
1894
- [
1895
- {
1896
- "color": "#001f23",
1897
- "fontFamily": "RebondGrotesque-SemiBold",
1898
- "fontSize": 36,
1899
- "letterSpacing": 1.5,
1900
- "lineHeight": 44,
1901
- },
1902
- [
1903
- {
1904
- "marginBottom": 16,
1905
- "marginTop": 8,
1906
- },
1907
- undefined,
1908
- ],
1909
- ]
1910
- }
1911
- themeIntent="body"
1912
- themeLevel="h1"
1913
- themeTypeface="playful"
1914
- >
1915
- Welcome to the new Employment Hero app
1916
- </Text>
1917
- <Text
1918
- allowFontScaling={false}
1919
- style={
1920
- [
1921
- {
1922
- "color": "#001f23",
1923
- "fontFamily": "BeVietnamPro-Regular",
1924
- "fontSize": 16,
1925
- "letterSpacing": 0.48,
1926
- "lineHeight": 24,
1927
- },
1928
- undefined,
1929
- ]
1930
- }
1931
- themeIntent="body"
1932
- themeTypeface="neutral"
1933
- themeVariant="regular"
1934
- >
1935
- Access your Work, Money and Benefits in the palm of your hand.
1936
- </Text>
1937
- </View>
1938
- </View>
1939
- </View>
1940
- <View
1941
- onFocusCapture={[Function]}
1942
- onLayout={[Function]}
1943
- style={
1944
- [
1945
- {
1946
- "flexDirection": "row",
1947
- },
1948
- null,
1949
- ]
1950
- }
1951
- >
1952
- <View
1953
- style={
1954
- [
1955
- {},
1956
- {
1957
- "width": 750,
1958
- },
1959
- ]
1960
- }
1961
- >
1962
- <Image
1963
- source={
1964
- {
1965
- "uri": "https://picsum.photos/800/1200",
1966
- }
1967
- }
1968
- style={
1969
- [
1970
- {
1971
- "borderRadius": 0,
1972
- "height": 72,
1973
- "width": 72,
1974
- },
1975
- [
1976
- {
1977
- "flex": 1,
1978
- "flexGrow": 2,
1979
- "resizeMode": "contain",
1980
- "width": "100%",
1981
- },
1982
- undefined,
1983
- ],
1984
- ]
1985
- }
1986
- />
1987
- <View
1988
- marginTop="large"
1989
- paddingHorizontal="large"
1990
- style={
1991
- [
1992
- {
1993
- "marginTop": 24,
1994
- "paddingHorizontal": 24,
1995
- },
1996
- [
1997
- {
1998
- "width": 750,
1999
- },
2000
- undefined,
2001
- ],
2002
- ]
2003
- }
2004
- width={750}
2005
- >
2006
- <Image
2007
- source={
2008
- {
2009
- "uri": "https://picsum.photos/30",
2010
- }
2011
- }
2012
- style={
2013
- [
2014
- {
2015
- "borderRadius": 0,
2016
- "height": 72,
2017
- "width": 72,
2018
- },
2019
- undefined,
2020
- ]
2021
- }
2022
- />
2023
- <Text
2024
- allowFontScaling={false}
2025
- style={
2026
- [
2027
- {
2028
- "color": "#001f23",
2029
- "fontFamily": "RebondGrotesque-SemiBold",
2030
- "fontSize": 36,
2031
- "letterSpacing": 1.5,
2032
- "lineHeight": 44,
2033
- },
2034
- [
2035
- {
2036
- "marginBottom": 16,
2037
- "marginTop": 8,
2038
- },
2039
- undefined,
2040
- ],
2041
- ]
2042
- }
2043
- themeIntent="body"
2044
- themeLevel="h1"
2045
- themeTypeface="playful"
2046
- >
2047
- Same app with a new look!
2048
- </Text>
2049
- <Text
2050
- allowFontScaling={false}
2051
- style={
2052
- [
2053
- {
2054
- "color": "#001f23",
2055
- "fontFamily": "BeVietnamPro-Regular",
2056
- "fontSize": 16,
2057
- "letterSpacing": 0.48,
2058
- "lineHeight": 24,
2059
- },
2060
- undefined,
2061
- ]
2062
- }
2063
- themeIntent="body"
2064
- themeTypeface="neutral"
2065
- themeVariant="regular"
2066
- >
2067
- Our app now has a new bright clean modern look and feel with the same great features.
2068
- </Text>
2069
- </View>
2070
- </View>
2071
- </View>
2072
- <View
2073
- onFocusCapture={[Function]}
2074
- onLayout={[Function]}
2075
- style={
2076
- [
2077
- {
2078
- "flexDirection": "row",
2079
- },
2080
- null,
2081
- ]
2082
- }
2083
- >
2084
- <View
2085
- style={
2086
- [
2087
- {},
2088
- {
2089
- "width": 750,
2090
- },
2091
- ]
2092
- }
2093
- >
2094
- <Image
2095
- height={100}
2096
- resizeMode="cover"
2097
- source={
2098
- {
2099
- "height": 100,
2100
- "resizeMode": "cover",
2101
- "uri": "https://picsum.photos/1200/800",
2102
- "width": 30,
2103
- }
2104
- }
2105
- style={
2106
- [
2107
- {
2108
- "borderRadius": 0,
2109
- "height": 72,
2110
- "width": 72,
2111
- },
2112
- [
2113
- {
2114
- "alignSelf": "center",
2115
- "height": 100,
2116
- "resizeMode": "cover",
2117
- "width": 30,
2118
- },
2119
- undefined,
2120
- ],
2121
- ]
2122
- }
2123
- width={30}
2124
- />
2125
- <View
2126
- marginTop="large"
2127
- paddingHorizontal="large"
2128
- style={
2129
- [
2130
- {
2131
- "marginTop": 24,
2132
- "paddingHorizontal": 24,
2133
- },
2134
- [
2135
- {
2136
- "width": 750,
2137
- },
2138
- undefined,
2139
- ],
2140
- ]
2141
- }
2142
- width={750}
2143
- >
2144
- <Text
2145
- allowFontScaling={false}
2146
- style={
2147
- [
2148
- {
2149
- "color": "#001f23",
2150
- "fontFamily": "RebondGrotesque-SemiBold",
2151
- "fontSize": 36,
2152
- "letterSpacing": 1.5,
2153
- "lineHeight": 44,
2154
- },
2155
- [
2156
- {
2157
- "marginBottom": 16,
2158
- "marginTop": 8,
2159
- },
2160
- undefined,
2161
- ],
2162
- ]
2163
- }
2164
- themeIntent="body"
2165
- themeLevel="h1"
2166
- themeTypeface="playful"
2167
- >
2168
- Easier to get around
2169
- </Text>
2170
- <Text
2171
- allowFontScaling={false}
2172
- style={
2173
- [
2174
- {
2175
- "color": "#001f23",
2176
- "fontFamily": "BeVietnamPro-Regular",
2177
- "fontSize": 16,
2178
- "letterSpacing": 0.48,
2179
- "lineHeight": 24,
2180
- },
2181
- undefined,
2182
- ]
2183
- }
2184
- themeIntent="body"
2185
- themeTypeface="neutral"
2186
- themeVariant="regular"
2187
- >
2188
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus vitae pulvinar quam, ac facilisis massa. Aliquam facilisis nisi eu justo dignissim, vel tempus justo iaculis.
2189
- </Text>
2190
- </View>
2191
- </View>
2192
- </View>
2193
- <View
2194
- onFocusCapture={[Function]}
2195
- onLayout={[Function]}
2196
- style={
2197
- [
2198
- {
2199
- "flexDirection": "row",
2200
- },
2201
- null,
2202
- ]
2203
- }
2204
- >
2205
- <View
2206
- style={
2207
- [
2208
- {},
2209
- {
2210
- "width": 750,
2211
- },
2212
- ]
2213
- }
2214
- >
2215
- <Image
2216
- height={100}
2217
- source={
2218
- {
2219
- "height": 100,
2220
- "uri": "https://picsum.photos/1200/800",
2221
- "width": 30,
2222
- }
2223
- }
2224
- style={
2225
- [
2226
- {
2227
- "borderRadius": 0,
2228
- "height": 72,
2229
- "width": 72,
2230
- },
2231
- [
2232
- {
2233
- "alignSelf": "center",
2234
- "height": 100,
2235
- "resizeMode": "contain",
2236
- "width": 30,
2237
- },
2238
- undefined,
2239
- ],
2240
- ]
2241
- }
2242
- width={30}
2243
- />
2244
- <View
2245
- marginTop="large"
2246
- paddingHorizontal="large"
2247
- style={
2248
- [
2249
- {
2250
- "marginTop": 24,
2251
- "paddingHorizontal": 24,
2252
- },
2253
- [
2254
- {
2255
- "width": 750,
2256
- },
2257
- undefined,
2258
- ],
2259
- ]
2260
- }
2261
- width={750}
1454
+ width={300}
2262
1455
  >
2263
1456
  <Text
2264
1457
  allowFontScaling={false}
@@ -64,6 +64,14 @@ describe('Carousel', () => {
64
64
  />
65
65
  );
66
66
 
67
+ fireEvent(getByTestId('carousel_flatlist'), 'layout', {
68
+ nativeEvent: {
69
+ layout: {
70
+ width: 300,
71
+ },
72
+ },
73
+ });
74
+
67
75
  expect(getByTestId('carousel')).toBeTruthy();
68
76
 
69
77
  expect(queryByText('Skip')).toBeTruthy();
@@ -96,7 +104,7 @@ describe('Carousel', () => {
96
104
  it('should call skip call back when press skip', () => {
97
105
  const onSkip = jest.fn();
98
106
 
99
- const { queryByText, toJSON } = renderWithTheme(
107
+ const { queryByText } = renderWithTheme(
100
108
  <Carousel
101
109
  testID="carousel"
102
110
  items={carouselData}
@@ -106,8 +114,6 @@ describe('Carousel', () => {
106
114
  />
107
115
  );
108
116
 
109
- expect(toJSON()).toMatchSnapshot();
110
-
111
117
  expect(queryByText('Skip')).toBeTruthy();
112
118
 
113
119
  fireEvent.press(queryByText('Skip'));
@@ -14,7 +14,7 @@ import {
14
14
  ViewProps,
15
15
  ViewStyle,
16
16
  ViewToken,
17
- useWindowDimensions,
17
+ LayoutChangeEvent,
18
18
  } from 'react-native';
19
19
 
20
20
  import { useTheme } from '../../theme';
@@ -112,13 +112,22 @@ const Carousel = ({
112
112
  const internalOnItemIndexChange = useCallback(
113
113
  (index: number) => {
114
114
  setCurrentSlideIndex(index);
115
+
115
116
  if (onItemIndexChange) {
116
117
  onItemIndexChange(index);
117
118
  }
118
119
  },
119
120
  [setCurrentSlideIndex, onItemIndexChange]
120
121
  );
121
- const { width } = useWindowDimensions();
122
+ const [flatListWidth, setFlatListWidth] = useState(0);
123
+ const itemWidth = flatListWidth;
124
+ const flatListOnLayout = useCallback(
125
+ (e: LayoutChangeEvent) => {
126
+ setFlatListWidth(e.nativeEvent.layout.width);
127
+ },
128
+ [setFlatListWidth]
129
+ );
130
+ const width = flatListWidth;
122
131
 
123
132
  const scrollX = useRef(new Animated.Value(0)).current;
124
133
  useEffect(() => {
@@ -133,8 +142,7 @@ const Carousel = ({
133
142
  return () => {
134
143
  clearTimeout(handle);
135
144
  };
136
- }, [currentSlideIndex, carouselRef]);
137
-
145
+ }, [currentSlideIndex, carouselRef, scrollX, width]);
138
146
  const viewConfig = useRef({ viewAreaCoveragePercentThreshold: 50 }).current;
139
147
 
140
148
  const onViewCallBack = useRef(
@@ -167,7 +175,8 @@ const Carousel = ({
167
175
  </StyledPageControlWrapper>
168
176
 
169
177
  <StyledCarouselView>
170
- <FlatList
178
+ <FlatList<CarouselData>
179
+ onLayout={flatListOnLayout}
171
180
  testID={testID ? `${testID}_flatlist` : undefined}
172
181
  horizontal
173
182
  showsHorizontalScrollIndicator={false}
@@ -186,7 +195,6 @@ const Carousel = ({
186
195
  if (!item) return null;
187
196
 
188
197
  const { image, heading, body, content } = item;
189
-
190
198
  return (
191
199
  <CarouselItem
192
200
  image={image}
@@ -197,6 +205,11 @@ const Carousel = ({
197
205
  />
198
206
  );
199
207
  }}
208
+ getItemLayout={(_, index) => ({
209
+ length: itemWidth,
210
+ offset: itemWidth * index,
211
+ index,
212
+ })}
200
213
  />
201
214
  <StyledCarouselFooterWrapper>
202
215
  {renderActions && renderActions(currentSlideIndex)}