@hero-design/rn 8.2.3 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/es/index.js +315 -53
- package/lib/index.js +314 -51
- package/package.json +5 -5
- package/src/components/Carousel/CarouselItem.tsx +49 -0
- package/src/components/Carousel/CarouselPaginator/StyledCarouselPaginator.tsx +19 -0
- package/src/components/Carousel/CarouselPaginator/index.tsx +58 -0
- package/src/components/Carousel/StyledCarousel.tsx +55 -0
- package/src/components/Carousel/__tests__/StyledCarousel.spec.tsx +13 -0
- package/src/components/Carousel/__tests__/__snapshots__/StyledCarousel.spec.tsx.snap +21 -0
- package/src/components/Carousel/__tests__/index.spec.tsx +86 -0
- package/src/components/Carousel/index.tsx +176 -0
- package/src/components/Carousel/types.ts +10 -0
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +27 -0
- package/src/theme/components/carousel.ts +39 -0
- package/src/theme/getTheme.ts +3 -0
- package/types/components/Carousel/CarouselItem.d.ts +7 -0
- package/types/components/Carousel/CarouselPaginator/StyledCarouselPaginator.d.ts +16 -0
- package/types/components/Carousel/CarouselPaginator/index.d.ts +7 -0
- package/types/components/Carousel/StyledCarousel.d.ts +34 -0
- package/types/components/Carousel/index.d.ts +46 -0
- package/types/components/Carousel/types.d.ts +9 -0
- package/types/index.d.ts +2 -1
- package/types/theme/components/carousel.d.ts +29 -0
- package/types/theme/getTheme.d.ts +2 -0
package/lib/index.js
CHANGED
|
@@ -1826,6 +1826,43 @@ var getCardTheme = function getCardTheme(theme) {
|
|
|
1826
1826
|
};
|
|
1827
1827
|
};
|
|
1828
1828
|
|
|
1829
|
+
var getCarouselTheme = function getCarouselTheme(theme) {
|
|
1830
|
+
var colors = {
|
|
1831
|
+
paginatorBackgroundColor: theme.colors.primary
|
|
1832
|
+
};
|
|
1833
|
+
var space = {
|
|
1834
|
+
headingMarginTop: theme.space.small,
|
|
1835
|
+
headingMarginBottom: theme.space.medium,
|
|
1836
|
+
paginatorMarginHorizontal: theme.space.small
|
|
1837
|
+
};
|
|
1838
|
+
var sizes = {
|
|
1839
|
+
indicatorWidth: theme.sizes.medium,
|
|
1840
|
+
paginatorHeight: theme.sizes.small,
|
|
1841
|
+
paginatorWidth: theme.sizes.small
|
|
1842
|
+
};
|
|
1843
|
+
var radii = {
|
|
1844
|
+
paginatorBorderRadius: theme.radii.rounded
|
|
1845
|
+
};
|
|
1846
|
+
var fontSizes = {
|
|
1847
|
+
heading: theme.fontSizes.xxxxxlarge
|
|
1848
|
+
};
|
|
1849
|
+
var fonts = {
|
|
1850
|
+
heading: theme.fonts.playful.semiBold
|
|
1851
|
+
};
|
|
1852
|
+
var lineHeights = {
|
|
1853
|
+
heading: theme.lineHeights.xxxlarge
|
|
1854
|
+
};
|
|
1855
|
+
return {
|
|
1856
|
+
colors: colors,
|
|
1857
|
+
sizes: sizes,
|
|
1858
|
+
radii: radii,
|
|
1859
|
+
space: space,
|
|
1860
|
+
fonts: fonts,
|
|
1861
|
+
fontSizes: fontSizes,
|
|
1862
|
+
lineHeights: lineHeights
|
|
1863
|
+
};
|
|
1864
|
+
};
|
|
1865
|
+
|
|
1829
1866
|
var getCheckboxTheme = function getCheckboxTheme(theme) {
|
|
1830
1867
|
var colors = {
|
|
1831
1868
|
"default": theme.colors.primaryOutline,
|
|
@@ -2696,6 +2733,7 @@ var getTheme$1 = function getTheme() {
|
|
|
2696
2733
|
button: getButtonTheme(globalTheme),
|
|
2697
2734
|
calendar: getCalendarTheme(globalTheme),
|
|
2698
2735
|
card: getCardTheme(globalTheme),
|
|
2736
|
+
carousel: getCarouselTheme(globalTheme),
|
|
2699
2737
|
checkbox: getCheckboxTheme(globalTheme),
|
|
2700
2738
|
contentNavigator: getContentNavigatorTheme(globalTheme),
|
|
2701
2739
|
datePicker: getDatePickerTheme(globalTheme),
|
|
@@ -5730,7 +5768,7 @@ var StyledText$3 = index$a(reactNative.Text)(function (_ref) {
|
|
|
5730
5768
|
});
|
|
5731
5769
|
});
|
|
5732
5770
|
|
|
5733
|
-
var _excluded$
|
|
5771
|
+
var _excluded$l = ["children", "fontSize", "fontWeight", "intent", "typeface"];
|
|
5734
5772
|
var Text = function Text(_ref) {
|
|
5735
5773
|
var children = _ref.children,
|
|
5736
5774
|
_ref$fontSize = _ref.fontSize,
|
|
@@ -5741,7 +5779,7 @@ var Text = function Text(_ref) {
|
|
|
5741
5779
|
intent = _ref$intent === void 0 ? 'body' : _ref$intent,
|
|
5742
5780
|
_ref$typeface = _ref.typeface,
|
|
5743
5781
|
typeface = _ref$typeface === void 0 ? 'neutral' : _ref$typeface,
|
|
5744
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
5782
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$l);
|
|
5745
5783
|
return /*#__PURE__*/React__default["default"].createElement(StyledText$3, _extends$1({}, nativeProps, {
|
|
5746
5784
|
themeFontSize: fontSize,
|
|
5747
5785
|
themeFontWeight: fontWeight,
|
|
@@ -6220,10 +6258,10 @@ var StyledHeroIcon = index$a(HeroIcon)(function (_ref) {
|
|
|
6220
6258
|
};
|
|
6221
6259
|
});
|
|
6222
6260
|
|
|
6223
|
-
var _excluded$
|
|
6261
|
+
var _excluded$k = ["style"];
|
|
6224
6262
|
var AnimatedIcon = function AnimatedIcon(_ref) {
|
|
6225
6263
|
var style = _ref.style,
|
|
6226
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
6264
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$k);
|
|
6227
6265
|
var rotateAnimation = React.useRef(new reactNative.Animated.Value(0));
|
|
6228
6266
|
React.useEffect(function () {
|
|
6229
6267
|
var animation = reactNative.Animated.loop(reactNative.Animated.timing(rotateAnimation.current, {
|
|
@@ -6329,7 +6367,7 @@ var AccordionItem = function AccordionItem(_ref) {
|
|
|
6329
6367
|
}, content));
|
|
6330
6368
|
};
|
|
6331
6369
|
|
|
6332
|
-
var _excluded$
|
|
6370
|
+
var _excluded$j = ["key"];
|
|
6333
6371
|
var Accordion = function Accordion(_ref) {
|
|
6334
6372
|
var items = _ref.items,
|
|
6335
6373
|
activeItemKey = _ref.activeItemKey,
|
|
@@ -6350,7 +6388,7 @@ var Accordion = function Accordion(_ref) {
|
|
|
6350
6388
|
testID: testID
|
|
6351
6389
|
}, items.map(function (_ref2, index) {
|
|
6352
6390
|
var key = _ref2.key,
|
|
6353
|
-
props = _objectWithoutProperties(_ref2, _excluded$
|
|
6391
|
+
props = _objectWithoutProperties(_ref2, _excluded$j);
|
|
6354
6392
|
var open = _activeItemKey === key;
|
|
6355
6393
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
|
|
6356
6394
|
key: key
|
|
@@ -6732,7 +6770,7 @@ var StyledStatus = index$a(reactNative.Animated.View)(function (_ref3) {
|
|
|
6732
6770
|
};
|
|
6733
6771
|
});
|
|
6734
6772
|
|
|
6735
|
-
var _excluded$
|
|
6773
|
+
var _excluded$i = ["children", "visible", "intent", "style", "testID"];
|
|
6736
6774
|
var Status = function Status(_ref) {
|
|
6737
6775
|
var children = _ref.children,
|
|
6738
6776
|
_ref$visible = _ref.visible,
|
|
@@ -6741,7 +6779,7 @@ var Status = function Status(_ref) {
|
|
|
6741
6779
|
intent = _ref$intent === void 0 ? 'danger' : _ref$intent,
|
|
6742
6780
|
style = _ref.style,
|
|
6743
6781
|
testID = _ref.testID,
|
|
6744
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
6782
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$i);
|
|
6745
6783
|
var _React$useRef = React__default["default"].useRef(new reactNative.Animated.Value(visible ? 1 : 0)),
|
|
6746
6784
|
opacity = _React$useRef.current;
|
|
6747
6785
|
var isFirstRendering = React__default["default"].useRef(true);
|
|
@@ -6774,7 +6812,7 @@ var Status = function Status(_ref) {
|
|
|
6774
6812
|
}));
|
|
6775
6813
|
};
|
|
6776
6814
|
|
|
6777
|
-
var _excluded$
|
|
6815
|
+
var _excluded$h = ["content", "visible", "max", "intent", "style", "testID"];
|
|
6778
6816
|
var DEFAULT_MAX_NUMBER = 99;
|
|
6779
6817
|
var getPaddingState = function getPaddingState(content) {
|
|
6780
6818
|
return content.length > 1 ? 'wideContent' : 'narrowContent';
|
|
@@ -6789,7 +6827,7 @@ var Badge = function Badge(_ref) {
|
|
|
6789
6827
|
intent = _ref$intent === void 0 ? 'danger' : _ref$intent,
|
|
6790
6828
|
style = _ref.style,
|
|
6791
6829
|
testID = _ref.testID,
|
|
6792
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
6830
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$h);
|
|
6793
6831
|
var _React$useRef = React__default["default"].useRef(new reactNative.Animated.Value(visible ? 1 : 0)),
|
|
6794
6832
|
opacity = _React$useRef.current;
|
|
6795
6833
|
var isFirstRendering = React__default["default"].useRef(true);
|
|
@@ -6893,7 +6931,7 @@ function omit(keys, obj) {
|
|
|
6893
6931
|
return result;
|
|
6894
6932
|
}
|
|
6895
6933
|
|
|
6896
|
-
var _excluded$
|
|
6934
|
+
var _excluded$g = ["onTabPress", "renderActiveTabOnly", "selectedTabKey", "tabs"];
|
|
6897
6935
|
var getInactiveIcon = function getInactiveIcon(icon) {
|
|
6898
6936
|
var inactiveIcon = "".concat(icon, "-outlined");
|
|
6899
6937
|
return isHeroIcon(inactiveIcon) ? inactiveIcon : icon;
|
|
@@ -6904,7 +6942,7 @@ var BottomNavigation = function BottomNavigation(_ref) {
|
|
|
6904
6942
|
renderActiveTabOnly = _ref$renderActiveTabO === void 0 ? false : _ref$renderActiveTabO,
|
|
6905
6943
|
selectedTabKey = _ref.selectedTabKey,
|
|
6906
6944
|
tabs = _ref.tabs,
|
|
6907
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
6945
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$g);
|
|
6908
6946
|
var insets = reactNativeSafeAreaContext.useSafeAreaInsets();
|
|
6909
6947
|
/**
|
|
6910
6948
|
* List of loaded tabs, tabs will be loaded when navigated to.
|
|
@@ -6991,13 +7029,13 @@ var StyledDivider = index$a(reactNative.View)(function (_ref) {
|
|
|
6991
7029
|
}, horizontalMargin), verticalMargin);
|
|
6992
7030
|
});
|
|
6993
7031
|
|
|
6994
|
-
var _excluded$
|
|
7032
|
+
var _excluded$f = ["marginHorizontal", "marginVertical", "style", "testID"];
|
|
6995
7033
|
var Divider = function Divider(_ref) {
|
|
6996
7034
|
var marginHorizontal = _ref.marginHorizontal,
|
|
6997
7035
|
marginVertical = _ref.marginVertical,
|
|
6998
7036
|
style = _ref.style,
|
|
6999
7037
|
testID = _ref.testID,
|
|
7000
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
7038
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$f);
|
|
7001
7039
|
return /*#__PURE__*/React__default["default"].createElement(StyledDivider, _extends$1({}, nativeProps, {
|
|
7002
7040
|
themeMarginHorizontal: marginHorizontal,
|
|
7003
7041
|
themeMarginVertical: marginVertical,
|
|
@@ -7127,7 +7165,7 @@ var StyledLoadingDot = index$a(reactNative.View)(function (_ref2) {
|
|
|
7127
7165
|
}, themeStyling());
|
|
7128
7166
|
});
|
|
7129
7167
|
|
|
7130
|
-
var _excluded$
|
|
7168
|
+
var _excluded$e = ["count", "size", "testID", "themeVariant"];
|
|
7131
7169
|
var AnimatedLoadingIndicatorWrapper = reactNative.Animated.createAnimatedComponent(StyledLoadingIndicatorWrapper);
|
|
7132
7170
|
var AnimatedLoadingDot = reactNative.Animated.createAnimatedComponent(StyledLoadingDot);
|
|
7133
7171
|
var renderDotComponent = function renderDotComponent(_ref) {
|
|
@@ -7159,7 +7197,7 @@ var LoadingIndicator = function LoadingIndicator(_ref2) {
|
|
|
7159
7197
|
size = _ref2$size === void 0 ? 12 : _ref2$size,
|
|
7160
7198
|
testID = _ref2.testID,
|
|
7161
7199
|
themeVariant = _ref2.themeVariant,
|
|
7162
|
-
nativeProps = _objectWithoutProperties(_ref2, _excluded$
|
|
7200
|
+
nativeProps = _objectWithoutProperties(_ref2, _excluded$e);
|
|
7163
7201
|
var progressAnimation = React.useRef(new reactNative.Animated.Value(0));
|
|
7164
7202
|
React.useEffect(function () {
|
|
7165
7203
|
var animation = reactNative.Animated.loop(reactNative.Animated.timing(progressAnimation.current, {
|
|
@@ -7555,11 +7593,11 @@ var Header = function Header(_ref) {
|
|
|
7555
7593
|
})) : null), showDivider ? /*#__PURE__*/React__default["default"].createElement(Divider, null) : null);
|
|
7556
7594
|
};
|
|
7557
7595
|
|
|
7558
|
-
var _excluded$
|
|
7596
|
+
var _excluded$d = ["scrollEventThrottle"];
|
|
7559
7597
|
var BottomSheetScrollView = function BottomSheetScrollView(_ref) {
|
|
7560
7598
|
var _ref$scrollEventThrot = _ref.scrollEventThrottle,
|
|
7561
7599
|
scrollEventThrottle = _ref$scrollEventThrot === void 0 ? 100 : _ref$scrollEventThrot,
|
|
7562
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
7600
|
+
props = _objectWithoutProperties(_ref, _excluded$d);
|
|
7563
7601
|
var _useContext = React.useContext(BottomSheetContext),
|
|
7564
7602
|
setInternalShowDivider = _useContext.setInternalShowDivider;
|
|
7565
7603
|
var onScrollBeginDrag = React.useCallback(function (e) {
|
|
@@ -7874,7 +7912,7 @@ var borderWidths = {
|
|
|
7874
7912
|
var config = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, colors), space), radii), borderWidths);
|
|
7875
7913
|
var flexPropsKey = ['alignContent', 'alignItems', 'alignSelf', 'display', 'flex', 'flexBasis', 'flexDirection', 'flexGrow', 'flexShrink', 'flexWrap', 'justifyContent'];
|
|
7876
7914
|
|
|
7877
|
-
var _excluded$
|
|
7915
|
+
var _excluded$c = ["theme"];
|
|
7878
7916
|
var getThemeValue = function getThemeValue(theme, key, props) {
|
|
7879
7917
|
var propConfig = config[key];
|
|
7880
7918
|
var propValue = props[key];
|
|
@@ -7901,18 +7939,18 @@ var mapStylePropToThemeValue = function mapStylePropToThemeValue(theme, props) {
|
|
|
7901
7939
|
var configKeys = Object.keys(config);
|
|
7902
7940
|
var StyledBox = index$a(reactNative.View)(function (_ref5) {
|
|
7903
7941
|
var theme = _ref5.theme,
|
|
7904
|
-
otherProps = _objectWithoutProperties(_ref5, _excluded$
|
|
7942
|
+
otherProps = _objectWithoutProperties(_ref5, _excluded$c);
|
|
7905
7943
|
var styleProps = pick(configKeys, otherProps);
|
|
7906
7944
|
var flexProps = pick(_toConsumableArray(flexPropsKey), otherProps);
|
|
7907
7945
|
return _objectSpread2(_objectSpread2({}, mapStylePropToThemeValue(theme, styleProps)), flexProps);
|
|
7908
7946
|
});
|
|
7909
7947
|
|
|
7910
|
-
var _excluded$
|
|
7948
|
+
var _excluded$b = ["children", "style", "testID"];
|
|
7911
7949
|
var Box = function Box(_ref) {
|
|
7912
7950
|
var children = _ref.children,
|
|
7913
7951
|
style = _ref.style,
|
|
7914
7952
|
testID = _ref.testID,
|
|
7915
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
7953
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$b);
|
|
7916
7954
|
return /*#__PURE__*/React__default["default"].createElement(StyledBox, _extends$1({}, otherProps, {
|
|
7917
7955
|
style: style,
|
|
7918
7956
|
testID: testID
|
|
@@ -10477,6 +10515,251 @@ var Calendar = function Calendar(_ref) {
|
|
|
10477
10515
|
})));
|
|
10478
10516
|
};
|
|
10479
10517
|
|
|
10518
|
+
var StyledCarouselPaginator = index$a(reactNative.View)(function () {
|
|
10519
|
+
return {
|
|
10520
|
+
flexDirection: 'row',
|
|
10521
|
+
alignItems: 'center'
|
|
10522
|
+
};
|
|
10523
|
+
});
|
|
10524
|
+
var StyledCarouselPaginatorAnimatedView = index$a(reactNative.Animated.View)(function (_ref) {
|
|
10525
|
+
var theme = _ref.theme;
|
|
10526
|
+
return {
|
|
10527
|
+
height: theme.__hd__.carousel.sizes.paginatorHeight,
|
|
10528
|
+
width: theme.__hd__.carousel.sizes.paginatorWidth,
|
|
10529
|
+
borderRadius: theme.__hd__.carousel.radii.paginatorBorderRadius,
|
|
10530
|
+
backgroundColor: theme.__hd__.carousel.colors.paginatorBackgroundColor,
|
|
10531
|
+
marginHorizontal: theme.__hd__.carousel.space.paginatorMarginHorizontal
|
|
10532
|
+
};
|
|
10533
|
+
});
|
|
10534
|
+
|
|
10535
|
+
var CarouselPaginator = function CarouselPaginator(_ref) {
|
|
10536
|
+
var numberOfSlides = _ref.numberOfSlides,
|
|
10537
|
+
scrollX = _ref.scrollX;
|
|
10538
|
+
var _useWindowDimensions = reactNative.useWindowDimensions(),
|
|
10539
|
+
width = _useWindowDimensions.width;
|
|
10540
|
+
var theme = useTheme();
|
|
10541
|
+
return /*#__PURE__*/React__default["default"].createElement(StyledCarouselPaginator, null, new Array(numberOfSlides).fill('').map(function (_, index) {
|
|
10542
|
+
var inputRange = [(index - 1) * width, index * width, (index + 1) * width];
|
|
10543
|
+
var indicatorWidth = scrollX.interpolate({
|
|
10544
|
+
inputRange: inputRange,
|
|
10545
|
+
outputRange: [theme.space.small, theme.space.large, theme.space.small],
|
|
10546
|
+
extrapolate: 'clamp'
|
|
10547
|
+
});
|
|
10548
|
+
var opacity = scrollX.interpolate({
|
|
10549
|
+
inputRange: inputRange,
|
|
10550
|
+
outputRange: [0.5, 1, 0.5],
|
|
10551
|
+
extrapolate: 'clamp'
|
|
10552
|
+
});
|
|
10553
|
+
return /*#__PURE__*/React__default["default"].createElement(StyledCarouselPaginatorAnimatedView, {
|
|
10554
|
+
indicatorWidth: indicatorWidth,
|
|
10555
|
+
style: [{
|
|
10556
|
+
width: indicatorWidth,
|
|
10557
|
+
opacity: opacity
|
|
10558
|
+
}],
|
|
10559
|
+
key: index.toString()
|
|
10560
|
+
});
|
|
10561
|
+
}));
|
|
10562
|
+
};
|
|
10563
|
+
|
|
10564
|
+
var _excluded$a = ["rounded", "size", "testID", "style"];
|
|
10565
|
+
var Image = function Image(_ref) {
|
|
10566
|
+
var _ref$rounded = _ref.rounded,
|
|
10567
|
+
rounded = _ref$rounded === void 0 ? false : _ref$rounded,
|
|
10568
|
+
_ref$size = _ref.size,
|
|
10569
|
+
size = _ref$size === void 0 ? '6xlarge' : _ref$size,
|
|
10570
|
+
testID = _ref.testID,
|
|
10571
|
+
style = _ref.style,
|
|
10572
|
+
imageNativeProps = _objectWithoutProperties(_ref, _excluded$a);
|
|
10573
|
+
var theme = useTheme();
|
|
10574
|
+
var imageSize = theme.__hd__.image.sizes[size];
|
|
10575
|
+
return /*#__PURE__*/React__default["default"].createElement(reactNative.Image, _extends$1({
|
|
10576
|
+
testID: testID,
|
|
10577
|
+
style: [{
|
|
10578
|
+
width: imageSize,
|
|
10579
|
+
height: imageSize,
|
|
10580
|
+
borderRadius: rounded ? imageSize / 2 : 0
|
|
10581
|
+
}, style]
|
|
10582
|
+
}, imageNativeProps));
|
|
10583
|
+
};
|
|
10584
|
+
|
|
10585
|
+
var StyledCarousel = index$a(reactNative.View)(function (_ref) {
|
|
10586
|
+
var themeSlideBackground = _ref.themeSlideBackground;
|
|
10587
|
+
return {
|
|
10588
|
+
zIndex: 99999,
|
|
10589
|
+
position: 'absolute',
|
|
10590
|
+
backgroundColor: themeSlideBackground,
|
|
10591
|
+
top: 0,
|
|
10592
|
+
bottom: 0,
|
|
10593
|
+
right: 0,
|
|
10594
|
+
left: 0
|
|
10595
|
+
};
|
|
10596
|
+
});
|
|
10597
|
+
var StyledCarouselView = index$a(reactNative.View)(function () {
|
|
10598
|
+
return {
|
|
10599
|
+
justifyContent: 'space-between',
|
|
10600
|
+
height: '100%'
|
|
10601
|
+
};
|
|
10602
|
+
});
|
|
10603
|
+
var StyledCarouselHeading = index$a(Typography.Text)(function (_ref2) {
|
|
10604
|
+
var theme = _ref2.theme;
|
|
10605
|
+
return {
|
|
10606
|
+
marginTop: theme.__hd__.carousel.space.headingMarginTop,
|
|
10607
|
+
marginBottom: theme.__hd__.carousel.space.headingMarginBottom,
|
|
10608
|
+
fontFamily: theme.__hd__.carousel.fonts.heading,
|
|
10609
|
+
fontSize: theme.__hd__.carousel.fontSizes.heading,
|
|
10610
|
+
lineHeight: theme.__hd__.carousel.lineHeights.heading
|
|
10611
|
+
};
|
|
10612
|
+
});
|
|
10613
|
+
var StyledCarouselImage = index$a(Image)(function () {
|
|
10614
|
+
return {
|
|
10615
|
+
flex: 1,
|
|
10616
|
+
width: '100%',
|
|
10617
|
+
resizeMode: 'contain'
|
|
10618
|
+
};
|
|
10619
|
+
});
|
|
10620
|
+
var StyledCarouselContentWrapper = index$a(Box)(function (_ref3) {
|
|
10621
|
+
var width = _ref3.width;
|
|
10622
|
+
return {
|
|
10623
|
+
width: width
|
|
10624
|
+
};
|
|
10625
|
+
});
|
|
10626
|
+
var StyledCarouselFooterWrapper = index$a(Box)(function () {
|
|
10627
|
+
return {
|
|
10628
|
+
width: '100%'
|
|
10629
|
+
};
|
|
10630
|
+
});
|
|
10631
|
+
|
|
10632
|
+
var CarouselItem = function CarouselItem(_ref) {
|
|
10633
|
+
var width = _ref.width,
|
|
10634
|
+
image = _ref.image,
|
|
10635
|
+
content = _ref.content,
|
|
10636
|
+
heading = _ref.heading,
|
|
10637
|
+
body = _ref.body,
|
|
10638
|
+
minHeight = _ref.minHeight;
|
|
10639
|
+
return /*#__PURE__*/React__default["default"].createElement(Box, {
|
|
10640
|
+
style: {
|
|
10641
|
+
width: width
|
|
10642
|
+
}
|
|
10643
|
+
}, image && /*#__PURE__*/React__default["default"].createElement(StyledCarouselImage, {
|
|
10644
|
+
source: typeof image === 'string' ? {
|
|
10645
|
+
uri: image
|
|
10646
|
+
} : image
|
|
10647
|
+
}), /*#__PURE__*/React__default["default"].createElement(StyledCarouselContentWrapper, {
|
|
10648
|
+
paddingHorizontal: "large",
|
|
10649
|
+
marginTop: "large",
|
|
10650
|
+
width: width,
|
|
10651
|
+
style: {
|
|
10652
|
+
minHeight: minHeight
|
|
10653
|
+
}
|
|
10654
|
+
}, content, /*#__PURE__*/React__default["default"].createElement(StyledCarouselHeading, null, heading), body ? /*#__PURE__*/React__default["default"].createElement(Typography.Text, {
|
|
10655
|
+
fontSize: "large"
|
|
10656
|
+
}, body) : null));
|
|
10657
|
+
};
|
|
10658
|
+
|
|
10659
|
+
var _excluded$9 = ["items", "onFinishPress", "onSkipPress", "onSlideChange", "finishButtonLabel", "skipButtonLabel", "footerHeight", "minContentHeight"];
|
|
10660
|
+
var Carousel = function Carousel(_ref) {
|
|
10661
|
+
var items = _ref.items,
|
|
10662
|
+
onFinishPress = _ref.onFinishPress,
|
|
10663
|
+
onSkipPress = _ref.onSkipPress,
|
|
10664
|
+
onSlideChange = _ref.onSlideChange,
|
|
10665
|
+
_ref$finishButtonLabe = _ref.finishButtonLabel,
|
|
10666
|
+
finishButtonLabel = _ref$finishButtonLabe === void 0 ? "Let's go!" : _ref$finishButtonLabe,
|
|
10667
|
+
_ref$skipButtonLabel = _ref.skipButtonLabel,
|
|
10668
|
+
skipButtonLabel = _ref$skipButtonLabel === void 0 ? 'Skip' : _ref$skipButtonLabel,
|
|
10669
|
+
_ref$footerHeight = _ref.footerHeight,
|
|
10670
|
+
footerHeight = _ref$footerHeight === void 0 ? 70 : _ref$footerHeight,
|
|
10671
|
+
_ref$minContentHeight = _ref.minContentHeight,
|
|
10672
|
+
minContentHeight = _ref$minContentHeight === void 0 ? 250 : _ref$minContentHeight,
|
|
10673
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$9);
|
|
10674
|
+
var carouselRef = React.useRef(null);
|
|
10675
|
+
var _useState = React.useState(0),
|
|
10676
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
10677
|
+
currentSlideIndex = _useState2[0],
|
|
10678
|
+
setCurrentSlideIndex = _useState2[1];
|
|
10679
|
+
var _useWindowDimensions = reactNative.useWindowDimensions(),
|
|
10680
|
+
width = _useWindowDimensions.width;
|
|
10681
|
+
var scrollX = React.useRef(new reactNative.Animated.Value(0)).current;
|
|
10682
|
+
var visibleSlideChanged = React.useCallback(function (_ref2) {
|
|
10683
|
+
var viewableItems = _ref2.viewableItems;
|
|
10684
|
+
if (!viewableItems || viewableItems && !viewableItems.length) return;
|
|
10685
|
+
var currentIndex = viewableItems[0].index;
|
|
10686
|
+
setCurrentSlideIndex(viewableItems[0].index);
|
|
10687
|
+
var currentSlide = items[currentIndex];
|
|
10688
|
+
if (onSlideChange) {
|
|
10689
|
+
onSlideChange(currentSlide);
|
|
10690
|
+
}
|
|
10691
|
+
}, [items, onSlideChange]);
|
|
10692
|
+
var skipCarousel = React.useCallback(function () {
|
|
10693
|
+
var currentSlide = items[currentSlideIndex];
|
|
10694
|
+
if (onSkipPress) {
|
|
10695
|
+
onSkipPress(currentSlide);
|
|
10696
|
+
}
|
|
10697
|
+
}, [currentSlideIndex, onSkipPress, items]);
|
|
10698
|
+
var finishCarousel = React.useCallback(function () {
|
|
10699
|
+
var currentSlide = items[currentSlideIndex];
|
|
10700
|
+
if (onFinishPress) {
|
|
10701
|
+
onFinishPress(currentSlide);
|
|
10702
|
+
}
|
|
10703
|
+
}, [onFinishPress, items, currentSlideIndex]);
|
|
10704
|
+
var viewConfig = React.useRef({
|
|
10705
|
+
viewAreaCoveragePercentThreshold: 50
|
|
10706
|
+
}).current;
|
|
10707
|
+
var isLastSlide = currentSlideIndex === items.length - 1;
|
|
10708
|
+
return /*#__PURE__*/React__default["default"].createElement(StyledCarousel, _extends$1({
|
|
10709
|
+
themeSlideBackground: items[currentSlideIndex].background
|
|
10710
|
+
}, nativeProps), /*#__PURE__*/React__default["default"].createElement(StyledCarouselView, null, /*#__PURE__*/React__default["default"].createElement(reactNative.FlatList, {
|
|
10711
|
+
horizontal: true,
|
|
10712
|
+
showsHorizontalScrollIndicator: false,
|
|
10713
|
+
pagingEnabled: true,
|
|
10714
|
+
bounces: false,
|
|
10715
|
+
data: items,
|
|
10716
|
+
onViewableItemsChanged: visibleSlideChanged,
|
|
10717
|
+
viewabilityConfig: viewConfig,
|
|
10718
|
+
scrollEventThrottle: 32,
|
|
10719
|
+
ref: carouselRef,
|
|
10720
|
+
onScroll: reactNative.Animated.event([{
|
|
10721
|
+
nativeEvent: {
|
|
10722
|
+
contentOffset: {
|
|
10723
|
+
x: scrollX
|
|
10724
|
+
}
|
|
10725
|
+
}
|
|
10726
|
+
}], {
|
|
10727
|
+
useNativeDriver: false
|
|
10728
|
+
}),
|
|
10729
|
+
renderItem: function renderItem(_ref3) {
|
|
10730
|
+
var item = _ref3.item;
|
|
10731
|
+
if (!item) return null;
|
|
10732
|
+
var image = item.image,
|
|
10733
|
+
heading = item.heading,
|
|
10734
|
+
body = item.body,
|
|
10735
|
+
content = item.content;
|
|
10736
|
+
return /*#__PURE__*/React__default["default"].createElement(CarouselItem, {
|
|
10737
|
+
image: image,
|
|
10738
|
+
heading: heading,
|
|
10739
|
+
body: body,
|
|
10740
|
+
content: content,
|
|
10741
|
+
minHeight: minContentHeight,
|
|
10742
|
+
width: width
|
|
10743
|
+
});
|
|
10744
|
+
}
|
|
10745
|
+
}), /*#__PURE__*/React__default["default"].createElement(StyledCarouselFooterWrapper, {
|
|
10746
|
+
paddingHorizontal: "large",
|
|
10747
|
+
flexDirection: "row",
|
|
10748
|
+
justifyContent: "space-between",
|
|
10749
|
+
style: {
|
|
10750
|
+
height: footerHeight
|
|
10751
|
+
}
|
|
10752
|
+
}, /*#__PURE__*/React__default["default"].createElement(CompoundButton, {
|
|
10753
|
+
variant: isLastSlide ? 'filled' : 'text',
|
|
10754
|
+
intent: "primary",
|
|
10755
|
+
onPress: isLastSlide ? finishCarousel : skipCarousel,
|
|
10756
|
+
text: isLastSlide ? finishButtonLabel : skipButtonLabel
|
|
10757
|
+
}), /*#__PURE__*/React__default["default"].createElement(CarouselPaginator, {
|
|
10758
|
+
numberOfSlides: items.length,
|
|
10759
|
+
scrollX: scrollX
|
|
10760
|
+
}))));
|
|
10761
|
+
};
|
|
10762
|
+
|
|
10480
10763
|
var StyledDataCard = index$a(reactNative.View)(function (_ref) {
|
|
10481
10764
|
var theme = _ref.theme;
|
|
10482
10765
|
return {
|
|
@@ -10495,12 +10778,12 @@ var Indicator = index$a(reactNative.View)(function (_ref2) {
|
|
|
10495
10778
|
};
|
|
10496
10779
|
});
|
|
10497
10780
|
|
|
10498
|
-
var _excluded$
|
|
10781
|
+
var _excluded$8 = ["intent", "children"];
|
|
10499
10782
|
var DataCard = function DataCard(_ref) {
|
|
10500
10783
|
var _ref$intent = _ref.intent,
|
|
10501
10784
|
intent = _ref$intent === void 0 ? 'info' : _ref$intent,
|
|
10502
10785
|
children = _ref.children,
|
|
10503
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
10786
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$8);
|
|
10504
10787
|
return /*#__PURE__*/React__default["default"].createElement(StyledDataCard, nativeProps, /*#__PURE__*/React__default["default"].createElement(Indicator, {
|
|
10505
10788
|
themeIntent: intent,
|
|
10506
10789
|
testID: "data-card-indicator"
|
|
@@ -10518,11 +10801,11 @@ var StyledCard = index$a(reactNative.View)(function (_ref) {
|
|
|
10518
10801
|
});
|
|
10519
10802
|
});
|
|
10520
10803
|
|
|
10521
|
-
var _excluded$
|
|
10804
|
+
var _excluded$7 = ["intent", "children"];
|
|
10522
10805
|
var Card = function Card(_ref) {
|
|
10523
10806
|
var intent = _ref.intent,
|
|
10524
10807
|
children = _ref.children,
|
|
10525
|
-
nativeProps = _objectWithoutProperties(_ref, _excluded$
|
|
10808
|
+
nativeProps = _objectWithoutProperties(_ref, _excluded$7);
|
|
10526
10809
|
return /*#__PURE__*/React__default["default"].createElement(StyledCard, _extends$1({}, nativeProps, {
|
|
10527
10810
|
themeIntent: intent
|
|
10528
10811
|
}), children);
|
|
@@ -10756,7 +11039,7 @@ var StyledErrorAndMaxLengthContainer = index$a(reactNative.View)(function () {
|
|
|
10756
11039
|
};
|
|
10757
11040
|
});
|
|
10758
11041
|
|
|
10759
|
-
var _excluded$
|
|
11042
|
+
var _excluded$6 = ["label", "prefix", "suffix", "style", "textStyle", "testID", "accessibilityLabelledBy", "error", "required", "editable", "disabled", "loading", "maxLength", "helpText", "value", "defaultValue", "renderInputValue"];
|
|
10760
11043
|
var getVariant$1 = function getVariant(_ref) {
|
|
10761
11044
|
var disabled = _ref.disabled,
|
|
10762
11045
|
error = _ref.error,
|
|
@@ -10802,7 +11085,7 @@ var TextInput = function TextInput(_ref2, ref) {
|
|
|
10802
11085
|
value = _ref2.value,
|
|
10803
11086
|
defaultValue = _ref2.defaultValue,
|
|
10804
11087
|
renderInputValue = _ref2.renderInputValue,
|
|
10805
|
-
nativeProps = _objectWithoutProperties(_ref2, _excluded$
|
|
11088
|
+
nativeProps = _objectWithoutProperties(_ref2, _excluded$6);
|
|
10806
11089
|
var displayText = (_ref3 = value !== undefined ? value : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : '';
|
|
10807
11090
|
var isEmptyValue = displayText.length === 0;
|
|
10808
11091
|
var actualSuffix = loading ? 'loading' : suffix;
|
|
@@ -11481,11 +11764,11 @@ var StyledFABText = index$a(reactNative.Text)(function (_ref3) {
|
|
|
11481
11764
|
};
|
|
11482
11765
|
});
|
|
11483
11766
|
|
|
11484
|
-
var _excluded$
|
|
11767
|
+
var _excluded$5 = ["active"];
|
|
11485
11768
|
var AnimatedIcons = reactNative.Animated.createAnimatedComponent(StyledFABIcon);
|
|
11486
11769
|
var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
|
|
11487
11770
|
var active = _ref.active,
|
|
11488
|
-
iconProps = _objectWithoutProperties(_ref, _excluded$
|
|
11771
|
+
iconProps = _objectWithoutProperties(_ref, _excluded$5);
|
|
11489
11772
|
var rotateAnimation = React.useRef(new reactNative.Animated.Value(active ? 1 : 0));
|
|
11490
11773
|
React.useEffect(function () {
|
|
11491
11774
|
var animation = reactNative.Animated.timing(rotateAnimation.current, {
|
|
@@ -11732,27 +12015,6 @@ var index$6 = Object.assign(FAB, {
|
|
|
11732
12015
|
ActionGroup: ActionGroup
|
|
11733
12016
|
});
|
|
11734
12017
|
|
|
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
12018
|
var StyledListItemContainer$1 = index$a(reactNative.TouchableOpacity)(function (_ref) {
|
|
11757
12019
|
var theme = _ref.theme,
|
|
11758
12020
|
_ref$themeSelected = _ref.themeSelected,
|
|
@@ -30987,6 +31249,7 @@ exports.Box = Box;
|
|
|
30987
31249
|
exports.Button = CompoundButton;
|
|
30988
31250
|
exports.Calendar = Calendar;
|
|
30989
31251
|
exports.Card = index$8;
|
|
31252
|
+
exports.Carousel = Carousel;
|
|
30990
31253
|
exports.Checkbox = Checkbox;
|
|
30991
31254
|
exports.Collapse = Collapse;
|
|
30992
31255
|
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.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/native": "^11.9.3",
|
|
23
23
|
"@emotion/react": "^11.9.3",
|
|
24
|
-
"@hero-design/colors": "8.
|
|
24
|
+
"@hero-design/colors": "8.3.0",
|
|
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.0",
|
|
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.0",
|
|
64
64
|
"jest": "^27.3.1",
|
|
65
|
-
"prettier-config-hd": "8.
|
|
65
|
+
"prettier-config-hd": "8.3.0",
|
|
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,49 @@
|
|
|
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
|
+
minHeight: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const CarouselItem = ({
|
|
18
|
+
width,
|
|
19
|
+
image,
|
|
20
|
+
content,
|
|
21
|
+
heading,
|
|
22
|
+
body,
|
|
23
|
+
minHeight,
|
|
24
|
+
}: CarouselItemProps) => {
|
|
25
|
+
return (
|
|
26
|
+
<Box style={{ width }}>
|
|
27
|
+
{image && (
|
|
28
|
+
<StyledCarouselImage
|
|
29
|
+
source={typeof image === 'string' ? { uri: image } : image}
|
|
30
|
+
/>
|
|
31
|
+
)}
|
|
32
|
+
|
|
33
|
+
<StyledCarouselContentWrapper
|
|
34
|
+
paddingHorizontal="large"
|
|
35
|
+
marginTop="large"
|
|
36
|
+
width={width}
|
|
37
|
+
style={{ minHeight }}
|
|
38
|
+
>
|
|
39
|
+
{content}
|
|
40
|
+
<StyledCarouselHeading>{heading}</StyledCarouselHeading>
|
|
41
|
+
{body ? (
|
|
42
|
+
<Typography.Text fontSize="large">{body}</Typography.Text>
|
|
43
|
+
) : null}
|
|
44
|
+
</StyledCarouselContentWrapper>
|
|
45
|
+
</Box>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default CarouselItem;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Animated, View } from 'react-native';
|
|
2
|
+
import styled from '@emotion/native';
|
|
3
|
+
|
|
4
|
+
const StyledCarouselPaginator = styled(View)(() => ({
|
|
5
|
+
flexDirection: 'row',
|
|
6
|
+
alignItems: 'center',
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
const StyledCarouselPaginatorAnimatedView = styled(Animated.View)<{
|
|
10
|
+
indicatorWidth: Animated.AnimatedInterpolation;
|
|
11
|
+
}>(({ theme }) => ({
|
|
12
|
+
height: theme.__hd__.carousel.sizes.paginatorHeight,
|
|
13
|
+
width: theme.__hd__.carousel.sizes.paginatorWidth,
|
|
14
|
+
borderRadius: theme.__hd__.carousel.radii.paginatorBorderRadius,
|
|
15
|
+
backgroundColor: theme.__hd__.carousel.colors.paginatorBackgroundColor,
|
|
16
|
+
marginHorizontal: theme.__hd__.carousel.space.paginatorMarginHorizontal,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
export { StyledCarouselPaginator, StyledCarouselPaginatorAnimatedView };
|