@hero-design/rn 8.6.0 → 8.6.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.
@@ -1,9 +1,9 @@
1
- @hero-design/rn:build: cache hit, replaying output 78cd11edb8437bed
2
- @hero-design/rn:build: $ yarn build:js && yarn build:types
3
- @hero-design/rn:build: $ rollup -c
4
- @hero-design/rn:build: 
5
- @hero-design/rn:build: src/index.ts → lib/index.js, es/index.js...
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
- @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 24.4s
9
- @hero-design/rn:build: $ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
1
+ @hero-design/rn:build: cache hit, replaying output 7b99cd6b10674a23
2
+ @hero-design/rn:build: $ yarn build:js && yarn build:types
3
+ @hero-design/rn:build: $ rollup -c
4
+ @hero-design/rn:build: 
5
+ @hero-design/rn:build: src/index.ts → lib/index.js, es/index.js...
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
+ @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.2s
9
+ @hero-design/rn:build: $ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
package/es/index.js CHANGED
@@ -10605,15 +10605,27 @@ var StyledCarouselImage = index$a(Image)(function () {
10605
10605
  resizeMode: 'contain'
10606
10606
  };
10607
10607
  });
10608
- var StyledCarouselContentWrapper = index$a(Box)(function (_ref3) {
10609
- var width = _ref3.width;
10608
+ var StyledCustomSizeCarouselImage = index$a(Image)(function (_ref3) {
10609
+ var height = _ref3.height,
10610
+ _ref3$resizeMode = _ref3.resizeMode,
10611
+ resizeMode = _ref3$resizeMode === void 0 ? 'contain' : _ref3$resizeMode,
10612
+ width = _ref3.width;
10613
+ return {
10614
+ alignSelf: 'center',
10615
+ width: width,
10616
+ height: height,
10617
+ resizeMode: resizeMode
10618
+ };
10619
+ });
10620
+ var StyledCarouselContentWrapper = index$a(Box)(function (_ref4) {
10621
+ var width = _ref4.width;
10610
10622
  return {
10611
10623
  width: width,
10612
10624
  minHeight: scale(250)
10613
10625
  };
10614
10626
  });
10615
- var StyledCarouselFooterWrapper = index$a(View)(function (_ref4) {
10616
- var theme = _ref4.theme;
10627
+ var StyledCarouselFooterWrapper = index$a(View)(function (_ref5) {
10628
+ var theme = _ref5.theme;
10617
10629
  return {
10618
10630
  paddingHorizontal: theme.__hd__.carousel.space.footerPaddingHorizontal,
10619
10631
  flexDirection: 'row',
@@ -10623,6 +10635,9 @@ var StyledCarouselFooterWrapper = index$a(View)(function (_ref4) {
10623
10635
  };
10624
10636
  });
10625
10637
 
10638
+ function isCarouselImageProps(image) {
10639
+ return typeof image !== 'string';
10640
+ }
10626
10641
  var CarouselItem = function CarouselItem(_ref) {
10627
10642
  var width = _ref.width,
10628
10643
  image = _ref.image,
@@ -10633,11 +10648,16 @@ var CarouselItem = function CarouselItem(_ref) {
10633
10648
  style: {
10634
10649
  width: width
10635
10650
  }
10636
- }, image && /*#__PURE__*/React.createElement(StyledCarouselImage, {
10637
- source: typeof image === 'string' ? {
10651
+ }, image && (isCarouselImageProps(image) ? /*#__PURE__*/React.createElement(StyledCustomSizeCarouselImage, {
10652
+ source: image,
10653
+ height: image.height,
10654
+ width: image.width,
10655
+ resizeMode: image.resizeMode
10656
+ }) : /*#__PURE__*/React.createElement(StyledCarouselImage, {
10657
+ source: {
10638
10658
  uri: image
10639
- } : image
10640
- }), /*#__PURE__*/React.createElement(StyledCarouselContentWrapper, {
10659
+ }
10660
+ })), /*#__PURE__*/React.createElement(StyledCarouselContentWrapper, {
10641
10661
  paddingHorizontal: "large",
10642
10662
  marginTop: "large",
10643
10663
  width: width
@@ -10646,7 +10666,7 @@ var CarouselItem = function CarouselItem(_ref) {
10646
10666
  }, body) : null));
10647
10667
  };
10648
10668
 
10649
- var _excluded$e = ["items", "onItemIndexChange", "renderActions", "selectedItemIndex", "style"];
10669
+ var _excluded$e = ["items", "onItemIndexChange", "renderActions", "selectedItemIndex", "style", "shouldShowPagination"];
10650
10670
  function useStateFromProp(initialValue) {
10651
10671
  var _useState = useState(initialValue),
10652
10672
  _useState2 = _slicedToArray(_useState, 2),
@@ -10664,6 +10684,10 @@ var Carousel = function Carousel(_ref) {
10664
10684
  _ref$selectedItemInde = _ref.selectedItemIndex,
10665
10685
  selectedItemIndex = _ref$selectedItemInde === void 0 ? 0 : _ref$selectedItemInde,
10666
10686
  style = _ref.style,
10687
+ _ref$shouldShowPagina = _ref.shouldShowPagination,
10688
+ shouldShowPagination = _ref$shouldShowPagina === void 0 ? function () {
10689
+ return true;
10690
+ } : _ref$shouldShowPagina,
10667
10691
  nativeProps = _objectWithoutProperties(_ref, _excluded$e);
10668
10692
  var carouselRef = useRef(null);
10669
10693
  var _useStateFromProp = useStateFromProp(selectedItemIndex),
@@ -10740,7 +10764,7 @@ var Carousel = function Carousel(_ref) {
10740
10764
  width: width
10741
10765
  });
10742
10766
  }
10743
- }), /*#__PURE__*/React.createElement(StyledCarouselFooterWrapper, null, renderActions && renderActions(currentSlideIndex), /*#__PURE__*/React.createElement(CarouselPaginator, {
10767
+ }), /*#__PURE__*/React.createElement(StyledCarouselFooterWrapper, null, renderActions && renderActions(currentSlideIndex), shouldShowPagination(currentSlideIndex) && /*#__PURE__*/React.createElement(CarouselPaginator, {
10744
10768
  numberOfSlides: items.length,
10745
10769
  scrollX: scrollX
10746
10770
  }))));
package/lib/index.js CHANGED
@@ -10634,15 +10634,27 @@ var StyledCarouselImage = index$a(Image)(function () {
10634
10634
  resizeMode: 'contain'
10635
10635
  };
10636
10636
  });
10637
- var StyledCarouselContentWrapper = index$a(Box)(function (_ref3) {
10638
- var width = _ref3.width;
10637
+ var StyledCustomSizeCarouselImage = index$a(Image)(function (_ref3) {
10638
+ var height = _ref3.height,
10639
+ _ref3$resizeMode = _ref3.resizeMode,
10640
+ resizeMode = _ref3$resizeMode === void 0 ? 'contain' : _ref3$resizeMode,
10641
+ width = _ref3.width;
10642
+ return {
10643
+ alignSelf: 'center',
10644
+ width: width,
10645
+ height: height,
10646
+ resizeMode: resizeMode
10647
+ };
10648
+ });
10649
+ var StyledCarouselContentWrapper = index$a(Box)(function (_ref4) {
10650
+ var width = _ref4.width;
10639
10651
  return {
10640
10652
  width: width,
10641
10653
  minHeight: scale(250)
10642
10654
  };
10643
10655
  });
10644
- var StyledCarouselFooterWrapper = index$a(reactNative.View)(function (_ref4) {
10645
- var theme = _ref4.theme;
10656
+ var StyledCarouselFooterWrapper = index$a(reactNative.View)(function (_ref5) {
10657
+ var theme = _ref5.theme;
10646
10658
  return {
10647
10659
  paddingHorizontal: theme.__hd__.carousel.space.footerPaddingHorizontal,
10648
10660
  flexDirection: 'row',
@@ -10652,6 +10664,9 @@ var StyledCarouselFooterWrapper = index$a(reactNative.View)(function (_ref4) {
10652
10664
  };
10653
10665
  });
10654
10666
 
10667
+ function isCarouselImageProps(image) {
10668
+ return typeof image !== 'string';
10669
+ }
10655
10670
  var CarouselItem = function CarouselItem(_ref) {
10656
10671
  var width = _ref.width,
10657
10672
  image = _ref.image,
@@ -10662,11 +10677,16 @@ var CarouselItem = function CarouselItem(_ref) {
10662
10677
  style: {
10663
10678
  width: width
10664
10679
  }
10665
- }, image && /*#__PURE__*/React__default["default"].createElement(StyledCarouselImage, {
10666
- source: typeof image === 'string' ? {
10680
+ }, image && (isCarouselImageProps(image) ? /*#__PURE__*/React__default["default"].createElement(StyledCustomSizeCarouselImage, {
10681
+ source: image,
10682
+ height: image.height,
10683
+ width: image.width,
10684
+ resizeMode: image.resizeMode
10685
+ }) : /*#__PURE__*/React__default["default"].createElement(StyledCarouselImage, {
10686
+ source: {
10667
10687
  uri: image
10668
- } : image
10669
- }), /*#__PURE__*/React__default["default"].createElement(StyledCarouselContentWrapper, {
10688
+ }
10689
+ })), /*#__PURE__*/React__default["default"].createElement(StyledCarouselContentWrapper, {
10670
10690
  paddingHorizontal: "large",
10671
10691
  marginTop: "large",
10672
10692
  width: width
@@ -10675,7 +10695,7 @@ var CarouselItem = function CarouselItem(_ref) {
10675
10695
  }, body) : null));
10676
10696
  };
10677
10697
 
10678
- var _excluded$e = ["items", "onItemIndexChange", "renderActions", "selectedItemIndex", "style"];
10698
+ var _excluded$e = ["items", "onItemIndexChange", "renderActions", "selectedItemIndex", "style", "shouldShowPagination"];
10679
10699
  function useStateFromProp(initialValue) {
10680
10700
  var _useState = React.useState(initialValue),
10681
10701
  _useState2 = _slicedToArray(_useState, 2),
@@ -10693,6 +10713,10 @@ var Carousel = function Carousel(_ref) {
10693
10713
  _ref$selectedItemInde = _ref.selectedItemIndex,
10694
10714
  selectedItemIndex = _ref$selectedItemInde === void 0 ? 0 : _ref$selectedItemInde,
10695
10715
  style = _ref.style,
10716
+ _ref$shouldShowPagina = _ref.shouldShowPagination,
10717
+ shouldShowPagination = _ref$shouldShowPagina === void 0 ? function () {
10718
+ return true;
10719
+ } : _ref$shouldShowPagina,
10696
10720
  nativeProps = _objectWithoutProperties(_ref, _excluded$e);
10697
10721
  var carouselRef = React.useRef(null);
10698
10722
  var _useStateFromProp = useStateFromProp(selectedItemIndex),
@@ -10769,7 +10793,7 @@ var Carousel = function Carousel(_ref) {
10769
10793
  width: width
10770
10794
  });
10771
10795
  }
10772
- }), /*#__PURE__*/React__default["default"].createElement(StyledCarouselFooterWrapper, null, renderActions && renderActions(currentSlideIndex), /*#__PURE__*/React__default["default"].createElement(CarouselPaginator, {
10796
+ }), /*#__PURE__*/React__default["default"].createElement(StyledCarouselFooterWrapper, null, renderActions && renderActions(currentSlideIndex), shouldShowPagination(currentSlideIndex) && /*#__PURE__*/React__default["default"].createElement(CarouselPaginator, {
10773
10797
  numberOfSlides: items.length,
10774
10798
  scrollX: scrollX
10775
10799
  }))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.6.0",
3
+ "version": "8.6.1",
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.6.0",
24
+ "@hero-design/colors": "8.6.1",
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.6.0",
47
+ "@hero-design/eslint-plugin": "8.6.1",
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.6.0",
63
+ "eslint-config-hd": "8.6.1",
64
64
  "jest": "^27.3.1",
65
- "prettier-config-hd": "8.6.0",
65
+ "prettier-config-hd": "8.6.1",
66
66
  "react": "18.0.0",
67
67
  "react-native": "0.69.7",
68
68
  "react-native-gesture-handler": "~2.1.0",
@@ -1,18 +1,24 @@
1
1
  import React from 'react';
2
-
3
2
  import {
4
3
  StyledCarouselContentWrapper,
5
4
  StyledCarouselHeading,
6
5
  StyledCarouselImage,
6
+ StyledCustomSizeCarouselImage,
7
7
  } from './StyledCarousel';
8
8
  import Box from '../Box';
9
9
  import Typography from '../Typography';
10
- import { CarouselData } from './types';
10
+ import { CarouselData, CarouselImageProps } from './types';
11
11
 
12
12
  interface CarouselItemProps extends Omit<CarouselData, 'background'> {
13
13
  width: number;
14
14
  }
15
15
 
16
+ function isCarouselImageProps(
17
+ image: CarouselImageProps | string
18
+ ): image is CarouselImageProps {
19
+ return typeof image !== 'string';
20
+ }
21
+
16
22
  const CarouselItem = ({
17
23
  width,
18
24
  image,
@@ -22,11 +28,17 @@ const CarouselItem = ({
22
28
  }: CarouselItemProps) => {
23
29
  return (
24
30
  <Box style={{ width }}>
25
- {image && (
26
- <StyledCarouselImage
27
- source={typeof image === 'string' ? { uri: image } : image}
28
- />
29
- )}
31
+ {image &&
32
+ (isCarouselImageProps(image) ? (
33
+ <StyledCustomSizeCarouselImage
34
+ source={image}
35
+ height={image.height}
36
+ width={image.width}
37
+ resizeMode={image.resizeMode}
38
+ />
39
+ ) : (
40
+ <StyledCarouselImage source={{ uri: image }} />
41
+ ))}
30
42
 
31
43
  <StyledCarouselContentWrapper
32
44
  paddingHorizontal="large"
@@ -1,4 +1,4 @@
1
- import { View } from 'react-native';
1
+ import { View, ImageResizeMode } from 'react-native';
2
2
  import styled from '@emotion/native';
3
3
  import Typography from '../Typography';
4
4
  import Image from '../Image';
@@ -35,6 +35,17 @@ const StyledCarouselImage = styled(Image)(() => ({
35
35
  resizeMode: 'contain',
36
36
  }));
37
37
 
38
+ const StyledCustomSizeCarouselImage = styled(Image)<{
39
+ height?: number;
40
+ width?: number;
41
+ resizeMode?: ImageResizeMode;
42
+ }>(({ height, resizeMode = 'contain', width }) => ({
43
+ alignSelf: 'center',
44
+ width,
45
+ height,
46
+ resizeMode,
47
+ }));
48
+
38
49
  const StyledCarouselContentWrapper = styled(Box)<{
39
50
  width: number;
40
51
  }>(({ width }) => ({
@@ -57,4 +68,5 @@ export {
57
68
  StyledCarouselImage,
58
69
  StyledCarouselContentWrapper,
59
70
  StyledCarouselFooterWrapper,
71
+ StyledCustomSizeCarouselImage,
60
72
  };
@@ -46,6 +46,10 @@ interface CarouselProps extends ViewProps {
46
46
  * Render action elements function.
47
47
  */
48
48
  renderActions?: (pageIndex: number) => JSX.Element;
49
+ /**
50
+ * Should show paginations
51
+ */
52
+ shouldShowPagination?: (pageIndex: number) => boolean;
49
53
  /**
50
54
  * Current selected item index.
51
55
  */
@@ -68,6 +72,7 @@ const Carousel = ({
68
72
  renderActions,
69
73
  selectedItemIndex = 0,
70
74
  style,
75
+ shouldShowPagination = () => true,
71
76
  ...nativeProps
72
77
  }: CarouselProps) => {
73
78
  const carouselRef = useRef<FlatList>(null);
@@ -147,7 +152,12 @@ const Carousel = ({
147
152
  />
148
153
  <StyledCarouselFooterWrapper>
149
154
  {renderActions && renderActions(currentSlideIndex)}
150
- <CarouselPaginator numberOfSlides={items.length} scrollX={scrollX} />
155
+ {shouldShowPagination(currentSlideIndex) && (
156
+ <CarouselPaginator
157
+ numberOfSlides={items.length}
158
+ scrollX={scrollX}
159
+ />
160
+ )}
151
161
  </StyledCarouselFooterWrapper>
152
162
  </StyledCarouselView>
153
163
  </View>
@@ -1,8 +1,14 @@
1
1
  import { ReactNode } from 'react';
2
- import { ImageSourcePropType } from 'react-native';
2
+ import { ImageSourcePropType, ImageResizeMode } from 'react-native';
3
+
4
+ export type CarouselImageProps = ImageSourcePropType & {
5
+ height?: number;
6
+ width?: number;
7
+ resizeMode?: ImageResizeMode;
8
+ };
3
9
 
4
10
  export type CarouselData = {
5
- image: ImageSourcePropType | string;
11
+ image: CarouselImageProps | string;
6
12
  content?: ReactNode;
7
13
  heading: string;
8
14
  body?: string;
@@ -1,4 +1,4 @@
1
- import { View } from 'react-native';
1
+ import { View, ImageResizeMode } from 'react-native';
2
2
  declare const StyledBackDrop: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
3
3
  theme?: import("@emotion/react").Theme | undefined;
4
4
  as?: import("react").ElementType<any> | undefined;
@@ -21,6 +21,14 @@ declare const StyledCarouselImage: import("@emotion/native").StyledComponent<imp
21
21
  theme?: import("@emotion/react").Theme | undefined;
22
22
  as?: import("react").ElementType<any> | undefined;
23
23
  }, {}, {}>;
24
+ declare const StyledCustomSizeCarouselImage: import("@emotion/native").StyledComponent<import("../Image").ImageProps & {
25
+ theme?: import("@emotion/react").Theme | undefined;
26
+ as?: import("react").ElementType<any> | undefined;
27
+ } & {
28
+ height?: number | undefined;
29
+ width?: number | undefined;
30
+ resizeMode?: ImageResizeMode | undefined;
31
+ }, {}, {}>;
24
32
  declare const StyledCarouselContentWrapper: import("@emotion/native").StyledComponent<import("../Box").BoxProps & {
25
33
  theme?: import("@emotion/react").Theme | undefined;
26
34
  as?: import("react").ElementType<any> | undefined;
@@ -33,4 +41,4 @@ declare const StyledCarouselFooterWrapper: import("@emotion/native").StyledCompo
33
41
  }, {}, {
34
42
  ref?: import("react").Ref<View> | undefined;
35
43
  }>;
36
- export { StyledBackDrop, StyledCarouselView, StyledCarouselHeading, StyledCarouselImage, StyledCarouselContentWrapper, StyledCarouselFooterWrapper, };
44
+ export { StyledBackDrop, StyledCarouselView, StyledCarouselHeading, StyledCarouselImage, StyledCarouselContentWrapper, StyledCarouselFooterWrapper, StyledCustomSizeCarouselImage, };
@@ -22,11 +22,15 @@ interface CarouselProps extends ViewProps {
22
22
  * Render action elements function.
23
23
  */
24
24
  renderActions?: (pageIndex: number) => JSX.Element;
25
+ /**
26
+ * Should show paginations
27
+ */
28
+ shouldShowPagination?: (pageIndex: number) => boolean;
25
29
  /**
26
30
  * Current selected item index.
27
31
  */
28
32
  selectedItemIndex?: number;
29
33
  }
30
34
  export declare function useStateFromProp<T>(initialValue: T): [T, Dispatch<SetStateAction<T>>];
31
- declare const Carousel: ({ items, onItemIndexChange, renderActions, selectedItemIndex, style, ...nativeProps }: CarouselProps) => JSX.Element;
35
+ declare const Carousel: ({ items, onItemIndexChange, renderActions, selectedItemIndex, style, shouldShowPagination, ...nativeProps }: CarouselProps) => JSX.Element;
32
36
  export default Carousel;
@@ -1,7 +1,12 @@
1
1
  import { ReactNode } from 'react';
2
- import { ImageSourcePropType } from 'react-native';
2
+ import { ImageSourcePropType, ImageResizeMode } from 'react-native';
3
+ export declare type CarouselImageProps = ImageSourcePropType & {
4
+ height?: number;
5
+ width?: number;
6
+ resizeMode?: ImageResizeMode;
7
+ };
3
8
  export declare type CarouselData = {
4
- image: ImageSourcePropType | string;
9
+ image: CarouselImageProps | string;
5
10
  content?: ReactNode;
6
11
  heading: string;
7
12
  body?: string;