@hero-design/rn 8.2.3 → 8.3.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.
- package/.turbo/turbo-build.log +9 -9
- package/es/index.js +316 -53
- package/lib/index.js +315 -51
- package/package.json +5 -5
- package/src/components/Carousel/CarouselItem.tsx +44 -0
- package/src/components/Carousel/CarouselPaginator/StyledCarouselPaginator.tsx +20 -0
- package/src/components/Carousel/CarouselPaginator/index.tsx +57 -0
- package/src/components/Carousel/StyledCarousel.tsx +58 -0
- package/src/components/Carousel/__tests__/StyledCarousel.spec.tsx +13 -0
- package/src/components/Carousel/__tests__/__snapshots__/StyledCarousel.spec.tsx.snap +20 -0
- package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +600 -0
- package/src/components/Carousel/__tests__/index.spec.tsx +94 -0
- package/src/components/Carousel/index.tsx +157 -0
- package/src/components/Carousel/types.ts +10 -0
- package/src/components/Typography/Text/StyledText.tsx +1 -0
- package/src/components/Typography/Text/index.tsx +1 -0
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +34 -0
- package/src/theme/components/carousel.ts +42 -0
- package/src/theme/components/typography.ts +2 -0
- package/src/theme/getTheme.ts +3 -0
- package/src/theme/global/typography.ts +3 -0
- package/types/components/Carousel/CarouselItem.d.ts +6 -0
- package/types/components/Carousel/CarouselPaginator/StyledCarouselPaginator.d.ts +14 -0
- package/types/components/Carousel/CarouselPaginator/index.d.ts +7 -0
- package/types/components/Carousel/StyledCarousel.d.ts +36 -0
- package/types/components/Carousel/index.d.ts +32 -0
- package/types/components/Carousel/types.d.ts +9 -0
- package/types/components/Typography/Text/StyledText.d.ts +1 -1
- package/types/components/Typography/Text/index.d.ts +1 -1
- package/types/index.d.ts +2 -1
- package/types/theme/components/carousel.d.ts +32 -0
- package/types/theme/components/typography.d.ts +2 -0
- package/types/theme/getTheme.d.ts +2 -0
- package/types/theme/global/typography.d.ts +1 -0
package/lib/index.js
CHANGED
|
@@ -1405,6 +1405,7 @@ var getFontSizes = function getFontSizes(baseFontSize) {
|
|
|
1405
1405
|
});
|
|
1406
1406
|
return {
|
|
1407
1407
|
'7xlarge': scale(fontSizes[10]),
|
|
1408
|
+
'6xlarge': scale(fontSizes[9]),
|
|
1408
1409
|
xxxxxlarge: scale(fontSizes[8]),
|
|
1409
1410
|
xxxxlarge: scale(fontSizes[7]),
|
|
1410
1411
|
xxxlarge: scale(fontSizes[6]),
|
|
@@ -1421,6 +1422,7 @@ var getLineHeights = function getLineHeights(fontSizes) {
|
|
|
1421
1422
|
var additionalSpace = 8;
|
|
1422
1423
|
return {
|
|
1423
1424
|
'7xlarge': fontSizes['7xlarge'] + additionalSpace,
|
|
1425
|
+
'6xlarge': fontSizes['6xlarge'] + additionalSpace,
|
|
1424
1426
|
xxxxxlarge: fontSizes.xxxxxlarge + additionalSpace,
|
|
1425
1427
|
xxxxlarge: fontSizes.xxxxlarge + additionalSpace,
|
|
1426
1428
|
xxxlarge: fontSizes.xxxlarge + additionalSpace,
|
|
@@ -1826,6 +1828,46 @@ var getCardTheme = function getCardTheme(theme) {
|
|
|
1826
1828
|
};
|
|
1827
1829
|
};
|
|
1828
1830
|
|
|
1831
|
+
var getCarouselTheme = function getCarouselTheme(theme) {
|
|
1832
|
+
var colors = {
|
|
1833
|
+
paginatorBackgroundColor: theme.colors.primary
|
|
1834
|
+
};
|
|
1835
|
+
var space = {
|
|
1836
|
+
headingMarginTop: theme.space.small,
|
|
1837
|
+
headingMarginBottom: theme.space.medium,
|
|
1838
|
+
paginatorMarginHorizontal: theme.space.small,
|
|
1839
|
+
footerPaddingHorizontal: theme.space.large,
|
|
1840
|
+
footerPaddingVertical: theme.space.medium,
|
|
1841
|
+
footerMarginBottom: theme.space.large
|
|
1842
|
+
};
|
|
1843
|
+
var sizes = {
|
|
1844
|
+
indicatorWidth: theme.sizes.medium,
|
|
1845
|
+
paginatorHeight: theme.sizes.small,
|
|
1846
|
+
paginatorWidth: theme.sizes.small
|
|
1847
|
+
};
|
|
1848
|
+
var radii = {
|
|
1849
|
+
paginatorBorderRadius: theme.radii.rounded
|
|
1850
|
+
};
|
|
1851
|
+
var fontSizes = {
|
|
1852
|
+
heading: theme.fontSizes['6xlarge']
|
|
1853
|
+
};
|
|
1854
|
+
var fonts = {
|
|
1855
|
+
heading: theme.fonts.playful.semiBold
|
|
1856
|
+
};
|
|
1857
|
+
var lineHeights = {
|
|
1858
|
+
heading: theme.lineHeights['6xlarge']
|
|
1859
|
+
};
|
|
1860
|
+
return {
|
|
1861
|
+
colors: colors,
|
|
1862
|
+
sizes: sizes,
|
|
1863
|
+
radii: radii,
|
|
1864
|
+
space: space,
|
|
1865
|
+
fonts: fonts,
|
|
1866
|
+
fontSizes: fontSizes,
|
|
1867
|
+
lineHeights: lineHeights
|
|
1868
|
+
};
|
|
1869
|
+
};
|
|
1870
|
+
|
|
1829
1871
|
var getCheckboxTheme = function getCheckboxTheme(theme) {
|
|
1830
1872
|
var colors = {
|
|
1831
1873
|
"default": theme.colors.primaryOutline,
|
|
@@ -2661,6 +2703,7 @@ var getTypographyTheme = function getTypographyTheme(theme) {
|
|
|
2661
2703
|
xlarge: theme.fontSizes.xlarge,
|
|
2662
2704
|
xxxlarge: theme.fontSizes.xxxlarge,
|
|
2663
2705
|
xxxxxlarge: theme.fontSizes.xxxxxlarge,
|
|
2706
|
+
'6xlarge': theme.fontSizes['6xlarge'],
|
|
2664
2707
|
'7xlarge': theme.fontSizes['7xlarge']
|
|
2665
2708
|
};
|
|
2666
2709
|
var lineHeights = {
|
|
@@ -2670,6 +2713,7 @@ var getTypographyTheme = function getTypographyTheme(theme) {
|
|
|
2670
2713
|
xlarge: theme.lineHeights.xlarge,
|
|
2671
2714
|
xxxlarge: theme.lineHeights.xxxlarge,
|
|
2672
2715
|
xxxxxlarge: theme.lineHeights.xxxxxlarge,
|
|
2716
|
+
'6xlarge': theme.lineHeights['6xlarge'],
|
|
2673
2717
|
'7xlarge': theme.lineHeights['7xlarge']
|
|
2674
2718
|
};
|
|
2675
2719
|
return {
|
|
@@ -2696,6 +2740,7 @@ var getTheme$1 = function getTheme() {
|
|
|
2696
2740
|
button: getButtonTheme(globalTheme),
|
|
2697
2741
|
calendar: getCalendarTheme(globalTheme),
|
|
2698
2742
|
card: getCardTheme(globalTheme),
|
|
2743
|
+
carousel: getCarouselTheme(globalTheme),
|
|
2699
2744
|
checkbox: getCheckboxTheme(globalTheme),
|
|
2700
2745
|
contentNavigator: getContentNavigatorTheme(globalTheme),
|
|
2701
2746
|
datePicker: getDatePickerTheme(globalTheme),
|
|
@@ -5730,7 +5775,7 @@ var StyledText$3 = index$a(reactNative.Text)(function (_ref) {
|
|
|
5730
5775
|
});
|
|
5731
5776
|
});
|
|
5732
5777
|
|
|
5733
|
-
var _excluded$
|
|
5778
|
+
var _excluded$l = ["children", "fontSize", "fontWeight", "intent", "typeface"];
|
|
5734
5779
|
var Text = function Text(_ref) {
|
|
5735
5780
|
var children = _ref.children,
|
|
5736
5781
|
_ref$fontSize = _ref.fontSize,
|
|
@@ -5741,7 +5786,7 @@ var Text = function Text(_ref) {
|
|
|
5741
5786
|
intent = _ref$intent === void 0 ? 'body' : _ref$intent,
|
|
5742
5787
|
_ref$typeface = _ref.typeface,
|
|
5743
5788
|
typeface = _ref$typeface === void 0 ? 'neutral' : _ref$typeface,
|
|
5744
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
5789
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$l);
|
|
5745
5790
|
return /*#__PURE__*/React__default["default"].createElement(StyledText$3, _extends$1({}, nativeProps, {
|
|
5746
5791
|
themeFontSize: fontSize,
|
|
5747
5792
|
themeFontWeight: fontWeight,
|
|
@@ -6220,10 +6265,10 @@ var StyledHeroIcon = index$a(HeroIcon)(function (_ref) {
|
|
|
6220
6265
|
};
|
|
6221
6266
|
});
|
|
6222
6267
|
|
|
6223
|
-
var _excluded$
|
|
6268
|
+
var _excluded$k = ["style"];
|
|
6224
6269
|
var AnimatedIcon = function AnimatedIcon(_ref) {
|
|
6225
6270
|
var style = _ref.style,
|
|
6226
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
6271
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$k);
|
|
6227
6272
|
var rotateAnimation = React.useRef(new reactNative.Animated.Value(0));
|
|
6228
6273
|
React.useEffect(function () {
|
|
6229
6274
|
var animation = reactNative.Animated.loop(reactNative.Animated.timing(rotateAnimation.current, {
|
|
@@ -6329,7 +6374,7 @@ var AccordionItem = function AccordionItem(_ref) {
|
|
|
6329
6374
|
}, content));
|
|
6330
6375
|
};
|
|
6331
6376
|
|
|
6332
|
-
var _excluded$
|
|
6377
|
+
var _excluded$j = ["key"];
|
|
6333
6378
|
var Accordion = function Accordion(_ref) {
|
|
6334
6379
|
var items = _ref.items,
|
|
6335
6380
|
activeItemKey = _ref.activeItemKey,
|
|
@@ -6350,7 +6395,7 @@ var Accordion = function Accordion(_ref) {
|
|
|
6350
6395
|
testID: testID
|
|
6351
6396
|
}, items.map(function (_ref2, index) {
|
|
6352
6397
|
var key = _ref2.key,
|
|
6353
|
-
props = _objectWithoutProperties(_ref2, _excluded$
|
|
6398
|
+
props = _objectWithoutProperties(_ref2, _excluded$j);
|
|
6354
6399
|
var open = _activeItemKey === key;
|
|
6355
6400
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
|
|
6356
6401
|
key: key
|
|
@@ -6732,7 +6777,7 @@ var StyledStatus = index$a(reactNative.Animated.View)(function (_ref3) {
|
|
|
6732
6777
|
};
|
|
6733
6778
|
});
|
|
6734
6779
|
|
|
6735
|
-
var _excluded$
|
|
6780
|
+
var _excluded$i = ["children", "visible", "intent", "style", "testID"];
|
|
6736
6781
|
var Status = function Status(_ref) {
|
|
6737
6782
|
var children = _ref.children,
|
|
6738
6783
|
_ref$visible = _ref.visible,
|
|
@@ -6741,7 +6786,7 @@ var Status = function Status(_ref) {
|
|
|
6741
6786
|
intent = _ref$intent === void 0 ? 'danger' : _ref$intent,
|
|
6742
6787
|
style = _ref.style,
|
|
6743
6788
|
testID = _ref.testID,
|
|
6744
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
6789
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$i);
|
|
6745
6790
|
var _React$useRef = React__default["default"].useRef(new reactNative.Animated.Value(visible ? 1 : 0)),
|
|
6746
6791
|
opacity = _React$useRef.current;
|
|
6747
6792
|
var isFirstRendering = React__default["default"].useRef(true);
|
|
@@ -6774,7 +6819,7 @@ var Status = function Status(_ref) {
|
|
|
6774
6819
|
}));
|
|
6775
6820
|
};
|
|
6776
6821
|
|
|
6777
|
-
var _excluded$
|
|
6822
|
+
var _excluded$h = ["content", "visible", "max", "intent", "style", "testID"];
|
|
6778
6823
|
var DEFAULT_MAX_NUMBER = 99;
|
|
6779
6824
|
var getPaddingState = function getPaddingState(content) {
|
|
6780
6825
|
return content.length > 1 ? 'wideContent' : 'narrowContent';
|
|
@@ -6789,7 +6834,7 @@ var Badge = function Badge(_ref) {
|
|
|
6789
6834
|
intent = _ref$intent === void 0 ? 'danger' : _ref$intent,
|
|
6790
6835
|
style = _ref.style,
|
|
6791
6836
|
testID = _ref.testID,
|
|
6792
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
6837
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$h);
|
|
6793
6838
|
var _React$useRef = React__default["default"].useRef(new reactNative.Animated.Value(visible ? 1 : 0)),
|
|
6794
6839
|
opacity = _React$useRef.current;
|
|
6795
6840
|
var isFirstRendering = React__default["default"].useRef(true);
|
|
@@ -6893,7 +6938,7 @@ function omit(keys, obj) {
|
|
|
6893
6938
|
return result;
|
|
6894
6939
|
}
|
|
6895
6940
|
|
|
6896
|
-
var _excluded$
|
|
6941
|
+
var _excluded$g = ["onTabPress", "renderActiveTabOnly", "selectedTabKey", "tabs"];
|
|
6897
6942
|
var getInactiveIcon = function getInactiveIcon(icon) {
|
|
6898
6943
|
var inactiveIcon = "".concat(icon, "-outlined");
|
|
6899
6944
|
return isHeroIcon(inactiveIcon) ? inactiveIcon : icon;
|
|
@@ -6904,7 +6949,7 @@ var BottomNavigation = function BottomNavigation(_ref) {
|
|
|
6904
6949
|
renderActiveTabOnly = _ref$renderActiveTabO === void 0 ? false : _ref$renderActiveTabO,
|
|
6905
6950
|
selectedTabKey = _ref.selectedTabKey,
|
|
6906
6951
|
tabs = _ref.tabs,
|
|
6907
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
6952
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$g);
|
|
6908
6953
|
var insets = reactNativeSafeAreaContext.useSafeAreaInsets();
|
|
6909
6954
|
/**
|
|
6910
6955
|
* List of loaded tabs, tabs will be loaded when navigated to.
|
|
@@ -6991,13 +7036,13 @@ var StyledDivider = index$a(reactNative.View)(function (_ref) {
|
|
|
6991
7036
|
}, horizontalMargin), verticalMargin);
|
|
6992
7037
|
});
|
|
6993
7038
|
|
|
6994
|
-
var _excluded$
|
|
7039
|
+
var _excluded$f = ["marginHorizontal", "marginVertical", "style", "testID"];
|
|
6995
7040
|
var Divider = function Divider(_ref) {
|
|
6996
7041
|
var marginHorizontal = _ref.marginHorizontal,
|
|
6997
7042
|
marginVertical = _ref.marginVertical,
|
|
6998
7043
|
style = _ref.style,
|
|
6999
7044
|
testID = _ref.testID,
|
|
7000
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
7045
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$f);
|
|
7001
7046
|
return /*#__PURE__*/React__default["default"].createElement(StyledDivider, _extends$1({}, nativeProps, {
|
|
7002
7047
|
themeMarginHorizontal: marginHorizontal,
|
|
7003
7048
|
themeMarginVertical: marginVertical,
|
|
@@ -7127,7 +7172,7 @@ var StyledLoadingDot = index$a(reactNative.View)(function (_ref2) {
|
|
|
7127
7172
|
}, themeStyling());
|
|
7128
7173
|
});
|
|
7129
7174
|
|
|
7130
|
-
var _excluded$
|
|
7175
|
+
var _excluded$e = ["count", "size", "testID", "themeVariant"];
|
|
7131
7176
|
var AnimatedLoadingIndicatorWrapper = reactNative.Animated.createAnimatedComponent(StyledLoadingIndicatorWrapper);
|
|
7132
7177
|
var AnimatedLoadingDot = reactNative.Animated.createAnimatedComponent(StyledLoadingDot);
|
|
7133
7178
|
var renderDotComponent = function renderDotComponent(_ref) {
|
|
@@ -7159,7 +7204,7 @@ var LoadingIndicator = function LoadingIndicator(_ref2) {
|
|
|
7159
7204
|
size = _ref2$size === void 0 ? 12 : _ref2$size,
|
|
7160
7205
|
testID = _ref2.testID,
|
|
7161
7206
|
themeVariant = _ref2.themeVariant,
|
|
7162
|
-
nativeProps = _objectWithoutProperties(_ref2, _excluded$
|
|
7207
|
+
nativeProps = _objectWithoutProperties(_ref2, _excluded$e);
|
|
7163
7208
|
var progressAnimation = React.useRef(new reactNative.Animated.Value(0));
|
|
7164
7209
|
React.useEffect(function () {
|
|
7165
7210
|
var animation = reactNative.Animated.loop(reactNative.Animated.timing(progressAnimation.current, {
|
|
@@ -7555,11 +7600,11 @@ var Header = function Header(_ref) {
|
|
|
7555
7600
|
})) : null), showDivider ? /*#__PURE__*/React__default["default"].createElement(Divider, null) : null);
|
|
7556
7601
|
};
|
|
7557
7602
|
|
|
7558
|
-
var _excluded$
|
|
7603
|
+
var _excluded$d = ["scrollEventThrottle"];
|
|
7559
7604
|
var BottomSheetScrollView = function BottomSheetScrollView(_ref) {
|
|
7560
7605
|
var _ref$scrollEventThrot = _ref.scrollEventThrottle,
|
|
7561
7606
|
scrollEventThrottle = _ref$scrollEventThrot === void 0 ? 100 : _ref$scrollEventThrot,
|
|
7562
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
7607
|
+
props = _objectWithoutProperties(_ref, _excluded$d);
|
|
7563
7608
|
var _useContext = React.useContext(BottomSheetContext),
|
|
7564
7609
|
setInternalShowDivider = _useContext.setInternalShowDivider;
|
|
7565
7610
|
var onScrollBeginDrag = React.useCallback(function (e) {
|
|
@@ -7874,7 +7919,7 @@ var borderWidths = {
|
|
|
7874
7919
|
var config = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, colors), space), radii), borderWidths);
|
|
7875
7920
|
var flexPropsKey = ['alignContent', 'alignItems', 'alignSelf', 'display', 'flex', 'flexBasis', 'flexDirection', 'flexGrow', 'flexShrink', 'flexWrap', 'justifyContent'];
|
|
7876
7921
|
|
|
7877
|
-
var _excluded$
|
|
7922
|
+
var _excluded$c = ["theme"];
|
|
7878
7923
|
var getThemeValue = function getThemeValue(theme, key, props) {
|
|
7879
7924
|
var propConfig = config[key];
|
|
7880
7925
|
var propValue = props[key];
|
|
@@ -7901,18 +7946,18 @@ var mapStylePropToThemeValue = function mapStylePropToThemeValue(theme, props) {
|
|
|
7901
7946
|
var configKeys = Object.keys(config);
|
|
7902
7947
|
var StyledBox = index$a(reactNative.View)(function (_ref5) {
|
|
7903
7948
|
var theme = _ref5.theme,
|
|
7904
|
-
otherProps = _objectWithoutProperties(_ref5, _excluded$
|
|
7949
|
+
otherProps = _objectWithoutProperties(_ref5, _excluded$c);
|
|
7905
7950
|
var styleProps = pick(configKeys, otherProps);
|
|
7906
7951
|
var flexProps = pick(_toConsumableArray(flexPropsKey), otherProps);
|
|
7907
7952
|
return _objectSpread2(_objectSpread2({}, mapStylePropToThemeValue(theme, styleProps)), flexProps);
|
|
7908
7953
|
});
|
|
7909
7954
|
|
|
7910
|
-
var _excluded$
|
|
7955
|
+
var _excluded$b = ["children", "style", "testID"];
|
|
7911
7956
|
var Box = function Box(_ref) {
|
|
7912
7957
|
var children = _ref.children,
|
|
7913
7958
|
style = _ref.style,
|
|
7914
7959
|
testID = _ref.testID,
|
|
7915
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
7960
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$b);
|
|
7916
7961
|
return /*#__PURE__*/React__default["default"].createElement(StyledBox, _extends$1({}, otherProps, {
|
|
7917
7962
|
style: style,
|
|
7918
7963
|
testID: testID
|
|
@@ -10477,6 +10522,245 @@ var Calendar = function Calendar(_ref) {
|
|
|
10477
10522
|
})));
|
|
10478
10523
|
};
|
|
10479
10524
|
|
|
10525
|
+
var StyledCarouselPaginator = index$a(reactNative.View)(function () {
|
|
10526
|
+
return {
|
|
10527
|
+
flexDirection: 'row',
|
|
10528
|
+
alignItems: 'center',
|
|
10529
|
+
marginStart: 'auto'
|
|
10530
|
+
};
|
|
10531
|
+
});
|
|
10532
|
+
var StyledCarouselPaginatorAnimatedView = index$a(reactNative.Animated.View)(function (_ref) {
|
|
10533
|
+
var theme = _ref.theme;
|
|
10534
|
+
return {
|
|
10535
|
+
height: theme.__hd__.carousel.sizes.paginatorHeight,
|
|
10536
|
+
width: theme.__hd__.carousel.sizes.paginatorWidth,
|
|
10537
|
+
borderRadius: theme.__hd__.carousel.radii.paginatorBorderRadius,
|
|
10538
|
+
backgroundColor: theme.__hd__.carousel.colors.paginatorBackgroundColor,
|
|
10539
|
+
marginHorizontal: theme.__hd__.carousel.space.paginatorMarginHorizontal
|
|
10540
|
+
};
|
|
10541
|
+
});
|
|
10542
|
+
|
|
10543
|
+
var CarouselPaginator = function CarouselPaginator(_ref) {
|
|
10544
|
+
var numberOfSlides = _ref.numberOfSlides,
|
|
10545
|
+
scrollX = _ref.scrollX;
|
|
10546
|
+
var _useWindowDimensions = reactNative.useWindowDimensions(),
|
|
10547
|
+
width = _useWindowDimensions.width;
|
|
10548
|
+
var theme = useTheme();
|
|
10549
|
+
return /*#__PURE__*/React__default["default"].createElement(StyledCarouselPaginator, null, new Array(numberOfSlides).fill('').map(function (_, index) {
|
|
10550
|
+
var inputRange = [(index - 1) * width - 1, index * width - 1, (index + 1) * width];
|
|
10551
|
+
var indicatorWidth = scrollX.interpolate({
|
|
10552
|
+
inputRange: inputRange,
|
|
10553
|
+
outputRange: [theme.space.small, theme.space.large, theme.space.small],
|
|
10554
|
+
extrapolate: 'clamp'
|
|
10555
|
+
});
|
|
10556
|
+
var opacity = scrollX.interpolate({
|
|
10557
|
+
inputRange: inputRange,
|
|
10558
|
+
outputRange: [0.5, 1, 0.5],
|
|
10559
|
+
extrapolate: 'clamp'
|
|
10560
|
+
});
|
|
10561
|
+
return /*#__PURE__*/React__default["default"].createElement(StyledCarouselPaginatorAnimatedView, {
|
|
10562
|
+
style: [{
|
|
10563
|
+
width: indicatorWidth,
|
|
10564
|
+
opacity: opacity
|
|
10565
|
+
}],
|
|
10566
|
+
key: index.toString()
|
|
10567
|
+
});
|
|
10568
|
+
}));
|
|
10569
|
+
};
|
|
10570
|
+
|
|
10571
|
+
var _excluded$a = ["rounded", "size", "testID", "style"];
|
|
10572
|
+
var Image = function Image(_ref) {
|
|
10573
|
+
var _ref$rounded = _ref.rounded,
|
|
10574
|
+
rounded = _ref$rounded === void 0 ? false : _ref$rounded,
|
|
10575
|
+
_ref$size = _ref.size,
|
|
10576
|
+
size = _ref$size === void 0 ? '6xlarge' : _ref$size,
|
|
10577
|
+
testID = _ref.testID,
|
|
10578
|
+
style = _ref.style,
|
|
10579
|
+
imageNativeProps = _objectWithoutProperties(_ref, _excluded$a);
|
|
10580
|
+
var theme = useTheme();
|
|
10581
|
+
var imageSize = theme.__hd__.image.sizes[size];
|
|
10582
|
+
return /*#__PURE__*/React__default["default"].createElement(reactNative.Image, _extends$1({
|
|
10583
|
+
testID: testID,
|
|
10584
|
+
style: [{
|
|
10585
|
+
width: imageSize,
|
|
10586
|
+
height: imageSize,
|
|
10587
|
+
borderRadius: rounded ? imageSize / 2 : 0
|
|
10588
|
+
}, style]
|
|
10589
|
+
}, imageNativeProps));
|
|
10590
|
+
};
|
|
10591
|
+
|
|
10592
|
+
var StyledBackDrop = index$a(reactNative.View)(function (_ref) {
|
|
10593
|
+
var themeSlideBackground = _ref.themeSlideBackground;
|
|
10594
|
+
return {
|
|
10595
|
+
position: 'absolute',
|
|
10596
|
+
backgroundColor: themeSlideBackground,
|
|
10597
|
+
top: 0,
|
|
10598
|
+
bottom: 0,
|
|
10599
|
+
right: 0,
|
|
10600
|
+
left: 0
|
|
10601
|
+
};
|
|
10602
|
+
});
|
|
10603
|
+
var StyledCarouselView = index$a(reactNative.View)(function () {
|
|
10604
|
+
return {
|
|
10605
|
+
flexGrow: 2,
|
|
10606
|
+
justifyContent: 'space-between'
|
|
10607
|
+
};
|
|
10608
|
+
});
|
|
10609
|
+
var StyledCarouselHeading = index$a(Typography.Text)(function (_ref2) {
|
|
10610
|
+
var theme = _ref2.theme;
|
|
10611
|
+
return {
|
|
10612
|
+
marginTop: theme.__hd__.carousel.space.headingMarginTop,
|
|
10613
|
+
marginBottom: theme.__hd__.carousel.space.headingMarginBottom,
|
|
10614
|
+
fontFamily: theme.__hd__.carousel.fonts.heading,
|
|
10615
|
+
fontSize: theme.__hd__.carousel.fontSizes.heading,
|
|
10616
|
+
lineHeight: theme.__hd__.carousel.lineHeights.heading
|
|
10617
|
+
};
|
|
10618
|
+
});
|
|
10619
|
+
var StyledCarouselImage = index$a(Image)(function () {
|
|
10620
|
+
return {
|
|
10621
|
+
flex: 1,
|
|
10622
|
+
width: '100%',
|
|
10623
|
+
resizeMode: 'contain'
|
|
10624
|
+
};
|
|
10625
|
+
});
|
|
10626
|
+
var StyledCarouselContentWrapper = index$a(Box)(function (_ref3) {
|
|
10627
|
+
var width = _ref3.width;
|
|
10628
|
+
return {
|
|
10629
|
+
width: width
|
|
10630
|
+
};
|
|
10631
|
+
});
|
|
10632
|
+
var StyledCarouselFooterWrapper = index$a(reactNative.View)(function (_ref4) {
|
|
10633
|
+
var theme = _ref4.theme;
|
|
10634
|
+
return {
|
|
10635
|
+
paddingHorizontal: theme.__hd__.carousel.space.footerPaddingHorizontal,
|
|
10636
|
+
flexDirection: 'row',
|
|
10637
|
+
justifyContent: 'space-between',
|
|
10638
|
+
paddingVertical: theme.__hd__.carousel.space.footerPaddingVertical,
|
|
10639
|
+
marginBottom: theme.__hd__.carousel.space.footerMarginBottom
|
|
10640
|
+
};
|
|
10641
|
+
});
|
|
10642
|
+
|
|
10643
|
+
var CarouselItem = function CarouselItem(_ref) {
|
|
10644
|
+
var width = _ref.width,
|
|
10645
|
+
image = _ref.image,
|
|
10646
|
+
content = _ref.content,
|
|
10647
|
+
heading = _ref.heading,
|
|
10648
|
+
body = _ref.body;
|
|
10649
|
+
return /*#__PURE__*/React__default["default"].createElement(Box, {
|
|
10650
|
+
style: {
|
|
10651
|
+
width: width
|
|
10652
|
+
}
|
|
10653
|
+
}, image && /*#__PURE__*/React__default["default"].createElement(StyledCarouselImage, {
|
|
10654
|
+
source: typeof image === 'string' ? {
|
|
10655
|
+
uri: image
|
|
10656
|
+
} : image
|
|
10657
|
+
}), /*#__PURE__*/React__default["default"].createElement(StyledCarouselContentWrapper, {
|
|
10658
|
+
paddingHorizontal: "large",
|
|
10659
|
+
marginTop: "large",
|
|
10660
|
+
width: width
|
|
10661
|
+
}, content, /*#__PURE__*/React__default["default"].createElement(StyledCarouselHeading, null, heading), body ? /*#__PURE__*/React__default["default"].createElement(Typography.Text, null, body) : null));
|
|
10662
|
+
};
|
|
10663
|
+
|
|
10664
|
+
var _excluded$9 = ["items", "onItemIndexChange", "renderActions", "selectedItemIndex", "style"];
|
|
10665
|
+
function useStateFromProp(initialValue) {
|
|
10666
|
+
var _useState = React.useState(initialValue),
|
|
10667
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
10668
|
+
value = _useState2[0],
|
|
10669
|
+
setValue = _useState2[1];
|
|
10670
|
+
React.useEffect(function () {
|
|
10671
|
+
return setValue(initialValue);
|
|
10672
|
+
}, [initialValue]);
|
|
10673
|
+
return [value, setValue];
|
|
10674
|
+
}
|
|
10675
|
+
var Carousel = function Carousel(_ref) {
|
|
10676
|
+
var items = _ref.items,
|
|
10677
|
+
onItemIndexChange = _ref.onItemIndexChange,
|
|
10678
|
+
renderActions = _ref.renderActions,
|
|
10679
|
+
_ref$selectedItemInde = _ref.selectedItemIndex,
|
|
10680
|
+
selectedItemIndex = _ref$selectedItemInde === void 0 ? 0 : _ref$selectedItemInde,
|
|
10681
|
+
style = _ref.style,
|
|
10682
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$9);
|
|
10683
|
+
var carouselRef = React.useRef(null);
|
|
10684
|
+
var _useStateFromProp = useStateFromProp(selectedItemIndex),
|
|
10685
|
+
_useStateFromProp2 = _slicedToArray(_useStateFromProp, 2),
|
|
10686
|
+
currentSlideIndex = _useStateFromProp2[0],
|
|
10687
|
+
setCurrentSlideIndex = _useStateFromProp2[1];
|
|
10688
|
+
var internalOnItemIndexChange = React.useCallback(function (index) {
|
|
10689
|
+
setCurrentSlideIndex(index);
|
|
10690
|
+
if (onItemIndexChange) {
|
|
10691
|
+
onItemIndexChange(index);
|
|
10692
|
+
}
|
|
10693
|
+
}, [setCurrentSlideIndex, onItemIndexChange]);
|
|
10694
|
+
var _useWindowDimensions = reactNative.useWindowDimensions(),
|
|
10695
|
+
width = _useWindowDimensions.width;
|
|
10696
|
+
var scrollX = React.useRef(new reactNative.Animated.Value(0)).current;
|
|
10697
|
+
React.useEffect(function () {
|
|
10698
|
+
// must use setTimeout since when layout is mounted, the pagination dots are not set correct scrollX
|
|
10699
|
+
var handle = setTimeout(function () {
|
|
10700
|
+
var _carouselRef$current;
|
|
10701
|
+
scrollX.setValue(currentSlideIndex * width);
|
|
10702
|
+
(_carouselRef$current = carouselRef.current) === null || _carouselRef$current === void 0 ? void 0 : _carouselRef$current.scrollToOffset({
|
|
10703
|
+
offset: currentSlideIndex * width,
|
|
10704
|
+
animated: true
|
|
10705
|
+
});
|
|
10706
|
+
}, 100);
|
|
10707
|
+
return function () {
|
|
10708
|
+
clearTimeout(handle);
|
|
10709
|
+
};
|
|
10710
|
+
}, [currentSlideIndex, carouselRef]);
|
|
10711
|
+
var visibleSlideChanged = React.useCallback(function (_ref2) {
|
|
10712
|
+
var viewableItems = _ref2.viewableItems;
|
|
10713
|
+
if (!viewableItems || viewableItems && !viewableItems.length) return;
|
|
10714
|
+
var index = viewableItems[0].index;
|
|
10715
|
+
internalOnItemIndexChange(index);
|
|
10716
|
+
}, []);
|
|
10717
|
+
var viewConfig = React.useRef({
|
|
10718
|
+
viewAreaCoveragePercentThreshold: 50
|
|
10719
|
+
}).current;
|
|
10720
|
+
return /*#__PURE__*/React__default["default"].createElement(reactNative.View, _extends$1({
|
|
10721
|
+
style: style
|
|
10722
|
+
}, nativeProps), /*#__PURE__*/React__default["default"].createElement(StyledBackDrop, {
|
|
10723
|
+
themeSlideBackground: items[currentSlideIndex].background
|
|
10724
|
+
}), /*#__PURE__*/React__default["default"].createElement(StyledCarouselView, null, /*#__PURE__*/React__default["default"].createElement(reactNative.FlatList, {
|
|
10725
|
+
horizontal: true,
|
|
10726
|
+
showsHorizontalScrollIndicator: false,
|
|
10727
|
+
pagingEnabled: true,
|
|
10728
|
+
bounces: false,
|
|
10729
|
+
data: items,
|
|
10730
|
+
onViewableItemsChanged: visibleSlideChanged,
|
|
10731
|
+
viewabilityConfig: viewConfig,
|
|
10732
|
+
scrollEventThrottle: 32,
|
|
10733
|
+
ref: carouselRef,
|
|
10734
|
+
onScroll: reactNative.Animated.event([{
|
|
10735
|
+
nativeEvent: {
|
|
10736
|
+
contentOffset: {
|
|
10737
|
+
x: scrollX
|
|
10738
|
+
}
|
|
10739
|
+
}
|
|
10740
|
+
}], {
|
|
10741
|
+
useNativeDriver: false
|
|
10742
|
+
}),
|
|
10743
|
+
renderItem: function renderItem(_ref3) {
|
|
10744
|
+
var item = _ref3.item;
|
|
10745
|
+
if (!item) return null;
|
|
10746
|
+
var image = item.image,
|
|
10747
|
+
heading = item.heading,
|
|
10748
|
+
body = item.body,
|
|
10749
|
+
content = item.content;
|
|
10750
|
+
return /*#__PURE__*/React__default["default"].createElement(CarouselItem, {
|
|
10751
|
+
image: image,
|
|
10752
|
+
heading: heading,
|
|
10753
|
+
body: body,
|
|
10754
|
+
content: content,
|
|
10755
|
+
width: width
|
|
10756
|
+
});
|
|
10757
|
+
}
|
|
10758
|
+
}), /*#__PURE__*/React__default["default"].createElement(StyledCarouselFooterWrapper, null, renderActions && renderActions(currentSlideIndex), /*#__PURE__*/React__default["default"].createElement(CarouselPaginator, {
|
|
10759
|
+
numberOfSlides: items.length,
|
|
10760
|
+
scrollX: scrollX
|
|
10761
|
+
}))));
|
|
10762
|
+
};
|
|
10763
|
+
|
|
10480
10764
|
var StyledDataCard = index$a(reactNative.View)(function (_ref) {
|
|
10481
10765
|
var theme = _ref.theme;
|
|
10482
10766
|
return {
|
|
@@ -10495,12 +10779,12 @@ var Indicator = index$a(reactNative.View)(function (_ref2) {
|
|
|
10495
10779
|
};
|
|
10496
10780
|
});
|
|
10497
10781
|
|
|
10498
|
-
var _excluded$
|
|
10782
|
+
var _excluded$8 = ["intent", "children"];
|
|
10499
10783
|
var DataCard = function DataCard(_ref) {
|
|
10500
10784
|
var _ref$intent = _ref.intent,
|
|
10501
10785
|
intent = _ref$intent === void 0 ? 'info' : _ref$intent,
|
|
10502
10786
|
children = _ref.children,
|
|
10503
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
10787
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$8);
|
|
10504
10788
|
return /*#__PURE__*/React__default["default"].createElement(StyledDataCard, nativeProps, /*#__PURE__*/React__default["default"].createElement(Indicator, {
|
|
10505
10789
|
themeIntent: intent,
|
|
10506
10790
|
testID: "data-card-indicator"
|
|
@@ -10518,11 +10802,11 @@ var StyledCard = index$a(reactNative.View)(function (_ref) {
|
|
|
10518
10802
|
});
|
|
10519
10803
|
});
|
|
10520
10804
|
|
|
10521
|
-
var _excluded$
|
|
10805
|
+
var _excluded$7 = ["intent", "children"];
|
|
10522
10806
|
var Card = function Card(_ref) {
|
|
10523
10807
|
var intent = _ref.intent,
|
|
10524
10808
|
children = _ref.children,
|
|
10525
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
10809
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$7);
|
|
10526
10810
|
return /*#__PURE__*/React__default["default"].createElement(StyledCard, _extends$1({}, nativeProps, {
|
|
10527
10811
|
themeIntent: intent
|
|
10528
10812
|
}), children);
|
|
@@ -10756,7 +11040,7 @@ var StyledErrorAndMaxLengthContainer = index$a(reactNative.View)(function () {
|
|
|
10756
11040
|
};
|
|
10757
11041
|
});
|
|
10758
11042
|
|
|
10759
|
-
var _excluded$
|
|
11043
|
+
var _excluded$6 = ["label", "prefix", "suffix", "style", "textStyle", "testID", "accessibilityLabelledBy", "error", "required", "editable", "disabled", "loading", "maxLength", "helpText", "value", "defaultValue", "renderInputValue"];
|
|
10760
11044
|
var getVariant$1 = function getVariant(_ref) {
|
|
10761
11045
|
var disabled = _ref.disabled,
|
|
10762
11046
|
error = _ref.error,
|
|
@@ -10802,7 +11086,7 @@ var TextInput = function TextInput(_ref2, ref) {
|
|
|
10802
11086
|
value = _ref2.value,
|
|
10803
11087
|
defaultValue = _ref2.defaultValue,
|
|
10804
11088
|
renderInputValue = _ref2.renderInputValue,
|
|
10805
|
-
nativeProps = _objectWithoutProperties(_ref2, _excluded$
|
|
11089
|
+
nativeProps = _objectWithoutProperties(_ref2, _excluded$6);
|
|
10806
11090
|
var displayText = (_ref3 = value !== undefined ? value : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : '';
|
|
10807
11091
|
var isEmptyValue = displayText.length === 0;
|
|
10808
11092
|
var actualSuffix = loading ? 'loading' : suffix;
|
|
@@ -11481,11 +11765,11 @@ var StyledFABText = index$a(reactNative.Text)(function (_ref3) {
|
|
|
11481
11765
|
};
|
|
11482
11766
|
});
|
|
11483
11767
|
|
|
11484
|
-
var _excluded$
|
|
11768
|
+
var _excluded$5 = ["active"];
|
|
11485
11769
|
var AnimatedIcons = reactNative.Animated.createAnimatedComponent(StyledFABIcon);
|
|
11486
11770
|
var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
|
|
11487
11771
|
var active = _ref.active,
|
|
11488
|
-
iconProps = _objectWithoutProperties(_ref, _excluded$
|
|
11772
|
+
iconProps = _objectWithoutProperties(_ref, _excluded$5);
|
|
11489
11773
|
var rotateAnimation = React.useRef(new reactNative.Animated.Value(active ? 1 : 0));
|
|
11490
11774
|
React.useEffect(function () {
|
|
11491
11775
|
var animation = reactNative.Animated.timing(rotateAnimation.current, {
|
|
@@ -11732,27 +12016,6 @@ var index$6 = Object.assign(FAB, {
|
|
|
11732
12016
|
ActionGroup: ActionGroup
|
|
11733
12017
|
});
|
|
11734
12018
|
|
|
11735
|
-
var _excluded$5 = ["rounded", "size", "testID", "style"];
|
|
11736
|
-
var Image = function Image(_ref) {
|
|
11737
|
-
var _ref$rounded = _ref.rounded,
|
|
11738
|
-
rounded = _ref$rounded === void 0 ? false : _ref$rounded,
|
|
11739
|
-
_ref$size = _ref.size,
|
|
11740
|
-
size = _ref$size === void 0 ? '6xlarge' : _ref$size,
|
|
11741
|
-
testID = _ref.testID,
|
|
11742
|
-
style = _ref.style,
|
|
11743
|
-
imageNativeProps = _objectWithoutProperties(_ref, _excluded$5);
|
|
11744
|
-
var theme = useTheme();
|
|
11745
|
-
var imageSize = theme.__hd__.image.sizes[size];
|
|
11746
|
-
return /*#__PURE__*/React__default["default"].createElement(reactNative.Image, _extends$1({
|
|
11747
|
-
testID: testID,
|
|
11748
|
-
style: [{
|
|
11749
|
-
width: imageSize,
|
|
11750
|
-
height: imageSize,
|
|
11751
|
-
borderRadius: rounded ? imageSize / 2 : 0
|
|
11752
|
-
}, style]
|
|
11753
|
-
}, imageNativeProps));
|
|
11754
|
-
};
|
|
11755
|
-
|
|
11756
12019
|
var StyledListItemContainer$1 = index$a(reactNative.TouchableOpacity)(function (_ref) {
|
|
11757
12020
|
var theme = _ref.theme,
|
|
11758
12021
|
_ref$themeSelected = _ref.themeSelected,
|
|
@@ -30987,6 +31250,7 @@ exports.Box = Box;
|
|
|
30987
31250
|
exports.Button = CompoundButton;
|
|
30988
31251
|
exports.Calendar = Calendar;
|
|
30989
31252
|
exports.Card = index$8;
|
|
31253
|
+
exports.Carousel = Carousel;
|
|
30990
31254
|
exports.Checkbox = Checkbox;
|
|
30991
31255
|
exports.Collapse = Collapse;
|
|
30992
31256
|
exports.ContentNavigator = ContentNavigator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.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.
|
|
24
|
+
"@hero-design/colors": "8.3.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.
|
|
47
|
+
"@hero-design/eslint-plugin": "8.3.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.
|
|
63
|
+
"eslint-config-hd": "8.3.1",
|
|
64
64
|
"jest": "^27.3.1",
|
|
65
|
-
"prettier-config-hd": "8.
|
|
65
|
+
"prettier-config-hd": "8.3.1",
|
|
66
66
|
"react": "18.0.0",
|
|
67
67
|
"react-native": "0.69.7",
|
|
68
68
|
"react-native-gesture-handler": "~2.1.0",
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
StyledCarouselContentWrapper,
|
|
5
|
+
StyledCarouselHeading,
|
|
6
|
+
StyledCarouselImage,
|
|
7
|
+
} from './StyledCarousel';
|
|
8
|
+
import Box from '../Box';
|
|
9
|
+
import Typography from '../Typography';
|
|
10
|
+
import { CarouselData } from './types';
|
|
11
|
+
|
|
12
|
+
interface CarouselItemProps extends Omit<CarouselData, 'background'> {
|
|
13
|
+
width: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const CarouselItem = ({
|
|
17
|
+
width,
|
|
18
|
+
image,
|
|
19
|
+
content,
|
|
20
|
+
heading,
|
|
21
|
+
body,
|
|
22
|
+
}: CarouselItemProps) => {
|
|
23
|
+
return (
|
|
24
|
+
<Box style={{ width }}>
|
|
25
|
+
{image && (
|
|
26
|
+
<StyledCarouselImage
|
|
27
|
+
source={typeof image === 'string' ? { uri: image } : image}
|
|
28
|
+
/>
|
|
29
|
+
)}
|
|
30
|
+
|
|
31
|
+
<StyledCarouselContentWrapper
|
|
32
|
+
paddingHorizontal="large"
|
|
33
|
+
marginTop="large"
|
|
34
|
+
width={width}
|
|
35
|
+
>
|
|
36
|
+
{content}
|
|
37
|
+
<StyledCarouselHeading>{heading}</StyledCarouselHeading>
|
|
38
|
+
{body ? <Typography.Text>{body}</Typography.Text> : null}
|
|
39
|
+
</StyledCarouselContentWrapper>
|
|
40
|
+
</Box>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default CarouselItem;
|