@hero-design/rn 8.24.0 → 8.25.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.
Files changed (29) hide show
  1. package/.turbo/turbo-build.log +9 -9
  2. package/es/index.js +111 -60
  3. package/lib/index.js +110 -59
  4. package/package.json +5 -5
  5. package/src/components/Carousel/CardCarousel.tsx +23 -7
  6. package/src/components/Carousel/__tests__/CardCarousel.spec.tsx +177 -70
  7. package/src/components/Carousel/__tests__/__snapshots__/CardCarousel.spec.tsx.snap +294 -1
  8. package/src/components/Collapse/index.tsx +11 -10
  9. package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +21 -15
  10. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +7 -5
  11. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +7 -5
  12. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +7 -5
  13. package/src/components/Error/StyledError.tsx +2 -0
  14. package/src/components/Error/__tests__/__snapshots__/index.spec.tsx.snap +8 -0
  15. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +28 -20
  16. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +28 -20
  17. package/src/components/Spinner/AnimatedSpinner.tsx +2 -2
  18. package/src/components/TextInput/StyledTextInput.tsx +4 -0
  19. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +21 -1
  20. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +112 -78
  21. package/src/components/TextInput/index.tsx +1 -4
  22. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +14 -10
  23. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +14 -10
  24. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +9 -1
  25. package/src/theme/components/error.ts +6 -1
  26. package/src/theme/components/textInput.ts +16 -2
  27. package/types/components/Collapse/index.d.ts +1 -1
  28. package/types/theme/components/error.d.ts +4 -0
  29. package/types/theme/components/textInput.d.ts +4 -0
@@ -1,9 +1,9 @@
1
- @hero-design/rn:build: cache hit, replaying output 5e28173315c89cb6
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 27.7s
9
- @hero-design/rn:build: $ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
1
+ @hero-design/rn:build: cache hit, replaying output 8b413e97d24bd32c
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 37.5s
9
+ @hero-design/rn:build: $ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
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, Easing, TouchableOpacity, Text as Text$1, Image as Image$1, TouchableWithoutFeedback, Pressable, SafeAreaView, KeyboardAvoidingView, TouchableHighlight, ScrollView, Modal, FlatList, useWindowDimensions, TextInput as TextInput$1, PanResponder, InteractionManager, Keyboard, SectionList, LayoutAnimation, 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, FlatList, useWindowDimensions, TextInput as TextInput$1, PanResponder, InteractionManager, Keyboard, SectionList, RefreshControl as RefreshControl$1 } from 'react-native';
3
3
  import React, { useContext, createContext, createElement, useMemo, forwardRef, useEffect, useCallback, useRef, useState, isValidElement, useLayoutEffect, useImperativeHandle } from 'react';
4
4
  import { createIconSet } from 'react-native-vector-icons';
5
5
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -981,9 +981,9 @@ var blue$1 = colorScales.blue,
981
981
  purple$1 = colorScales.purple,
982
982
  vermilion$3 = colorScales.vermilion,
983
983
  smalt = colorScales.smalt,
984
- violet$1 = colorScales.violet,
984
+ violet$2 = colorScales.violet,
985
985
  yellow$1 = colorScales.yellow;
986
- ({
986
+ var palette$b = {
987
987
  black: '#000000',
988
988
  white: '#ffffff',
989
989
  blue: blue$1.base,
@@ -1058,21 +1058,40 @@ var blue$1 = colorScales.blue,
1058
1058
  smaltLight45: smalt.lighten45,
1059
1059
  smaltLight75: smalt.lighten75,
1060
1060
  smaltLight90: smalt.lighten90,
1061
- violet: violet$1.base,
1062
- violetDark15: violet$1.darken15,
1063
- violetDark30: violet$1.darken30,
1064
- violetDark45: violet$1.darken45,
1065
- violetDark60: violet$1.darken60,
1066
- violetDark75: violet$1.darken75,
1067
- violetLight30: violet$1.lighten30,
1068
- violetLight60: violet$1.lighten60,
1069
- violetLight75: violet$1.lighten75,
1070
- violetLight90: violet$1.lighten90,
1061
+ violet: violet$2.base,
1062
+ violetDark15: violet$2.darken15,
1063
+ violetDark30: violet$2.darken30,
1064
+ violetDark45: violet$2.darken45,
1065
+ violetDark60: violet$2.darken60,
1066
+ violetDark75: violet$2.darken75,
1067
+ violetLight30: violet$2.lighten30,
1068
+ violetLight60: violet$2.lighten60,
1069
+ violetLight75: violet$2.lighten75,
1070
+ violetLight90: violet$2.lighten90,
1071
1071
  yellow: yellow$1.base,
1072
1072
  yellowDark15: yellow$1.darken15,
1073
1073
  yellowDark75: yellow$1.darken75,
1074
+ yellowLight45: yellow$1.lighten45,
1074
1075
  yellowLight60: yellow$1.lighten60,
1076
+ yellowLight75: yellow$1.lighten75,
1075
1077
  yellowLight90: yellow$1.lighten90
1078
+ };
1079
+ var mauve$4 = colorScales.mauve,
1080
+ violet$1 = colorScales.violet;
1081
+ Object.assign(Object.assign({}, palette$b), {
1082
+ mauve: mauve$4.base,
1083
+ mauveLight80: mauve$4.lighten80,
1084
+ violetDark50: violet$1.darken50
1085
+ });
1086
+ var apple$4 = colorScales.apple,
1087
+ hitPink$1 = colorScales.hitPink;
1088
+ Object.assign(Object.assign({}, palette$b), {
1089
+ apple: apple$4.base,
1090
+ appleDark20: apple$4.darken20,
1091
+ appleDark50: apple$4.darken50,
1092
+ appleLight90: apple$4.lighten90,
1093
+ hitPink: hitPink$1.base,
1094
+ hitPinkLight80: hitPink$1.lighten80
1076
1095
  });
1077
1096
  var aliceBlue$1 = colorScales.aliceBlue,
1078
1097
  antiFlashWhite$1 = colorScales.antiFlashWhite,
@@ -1239,7 +1258,7 @@ var currant$1 = colorScales.currant,
1239
1258
  vermilion = colorScales.vermilion,
1240
1259
  mauve$3 = colorScales.mauve,
1241
1260
  violet1$3 = colorScales.violet1,
1242
- violet$2 = colorScales.violet,
1261
+ violet$3 = colorScales.violet,
1243
1262
  scarletGum$2 = colorScales.scarletGum;
1244
1263
  var palette$6 = {
1245
1264
  currant: currant$1.base,
@@ -1258,9 +1277,9 @@ var palette$6 = {
1258
1277
  pastelRed: pastelRed.base,
1259
1278
  vermilion: vermilion.base,
1260
1279
  mauve: mauve$3.base,
1261
- violetLight30: violet$2.lighten30,
1280
+ violetLight30: violet$3.lighten30,
1262
1281
  violet1: violet1$3.base,
1263
- violet: violet$2.base,
1282
+ violet: violet$3.base,
1264
1283
  scarletGum: scarletGum$2.base
1265
1284
  };
1266
1285
  var violet1$2 = colorScales.violet1,
@@ -2240,12 +2259,17 @@ var getErrorTheme = function getErrorTheme(theme) {
2240
2259
  title: theme.fonts.playful.semiBold,
2241
2260
  description: theme.fonts.playful.regular
2242
2261
  };
2262
+ var lineHeight = {
2263
+ title: theme.lineHeights.xxxlarge,
2264
+ description: theme.lineHeights.xlarge
2265
+ };
2243
2266
  return {
2244
2267
  fontSizes: fontSizes,
2245
2268
  colors: colors,
2246
2269
  sizes: sizes,
2247
2270
  space: space,
2248
- fonts: fonts
2271
+ fonts: fonts,
2272
+ lineHeight: lineHeight
2249
2273
  };
2250
2274
  };
2251
2275
 
@@ -2907,7 +2931,7 @@ var getTextInputTheme = function getTextInputTheme(theme) {
2907
2931
  var space = {
2908
2932
  containerPadding: theme.space.medium,
2909
2933
  labelLeft: theme.space.medium,
2910
- labelTop: theme.lineHeights.small / -2,
2934
+ labelTop: theme.lineHeights.small / -4,
2911
2935
  labelPaddingBottom: theme.space.small,
2912
2936
  labelHorizontalPadding: theme.space.xsmall,
2913
2937
  inputHorizontalMargin: theme.space.small,
@@ -2926,7 +2950,8 @@ var getTextInputTheme = function getTextInputTheme(theme) {
2926
2950
  labelInsideTextInput: theme.fontSizes.large,
2927
2951
  error: theme.fontSizes.small,
2928
2952
  maxLength: theme.fontSizes.small,
2929
- asteriskLabel: theme.fontSizes.large
2953
+ asteriskLabel: theme.fontSizes.large,
2954
+ topLabel: theme.fontSizes.small
2930
2955
  };
2931
2956
  var borderWidths = {
2932
2957
  container: {
@@ -2942,6 +2967,9 @@ var getTextInputTheme = function getTextInputTheme(theme) {
2942
2967
  textareaHeight: theme.sizes['15xlarge'],
2943
2968
  textInputMaxHeight: theme.sizes['15xlarge']
2944
2969
  };
2970
+ var lineHeights = {
2971
+ topLabel: theme.lineHeights.large / 2
2972
+ };
2945
2973
  return {
2946
2974
  colors: colors,
2947
2975
  space: space,
@@ -2949,7 +2977,8 @@ var getTextInputTheme = function getTextInputTheme(theme) {
2949
2977
  fontSizes: fontSizes,
2950
2978
  borderWidths: borderWidths,
2951
2979
  radii: radii,
2952
- sizes: sizes
2980
+ sizes: sizes,
2981
+ lineHeights: lineHeights
2953
2982
  };
2954
2983
  };
2955
2984
 
@@ -6005,26 +6034,6 @@ var index$a = components.reduce(function (acc, comp) {
6005
6034
  });
6006
6035
  }, styled);
6007
6036
 
6008
- var StyledWrapper$c = index$a(Animated.View)({
6009
- margin: 0,
6010
- padding: 0,
6011
- overflow: 'hidden'
6012
- });
6013
- /**
6014
- * Height need to be high enough to cover most scenario
6015
- * This container's purpose is only to help get correct children height and returns it
6016
- * to use with Animated.timing
6017
- */
6018
- var StyledHiddenWrapper = index$a(View)(function () {
6019
- return {
6020
- height: Dimensions.get('window').height
6021
- };
6022
- });
6023
- var StyledChildWrapper = index$a(View)({
6024
- margin: 0,
6025
- padding: 0
6026
- });
6027
-
6028
6037
  // Get previous state value
6029
6038
  var usePrevious = function usePrevious(value) {
6030
6039
  var ref = React.useRef();
@@ -6050,13 +6059,37 @@ var useDeprecation = function useDeprecation(message) {
6050
6059
  }, [message, cond]);
6051
6060
  };
6052
6061
 
6062
+ var StyledWrapper$c = index$a(Animated.View)({
6063
+ margin: 0,
6064
+ padding: 0,
6065
+ overflow: 'hidden'
6066
+ });
6067
+ /**
6068
+ * Height need to be high enough to cover most scenario
6069
+ * This container's purpose is only to help get correct children height and returns it
6070
+ * to use with Animated.timing
6071
+ */
6072
+ var StyledHiddenWrapper = index$a(View)(function () {
6073
+ return {
6074
+ height: Dimensions.get('window').height
6075
+ };
6076
+ });
6077
+ var StyledChildWrapper = index$a(View)({
6078
+ margin: 0,
6079
+ padding: 0
6080
+ });
6081
+
6082
+ if (Platform.OS === 'android') {
6083
+ if (UIManager.setLayoutAnimationEnabledExperimental) {
6084
+ UIManager.setLayoutAnimationEnabledExperimental(true);
6085
+ }
6086
+ }
6053
6087
  var Collapse = function Collapse(_ref) {
6054
6088
  var _ref$open = _ref.open,
6055
6089
  open = _ref$open === void 0 ? false : _ref$open,
6056
6090
  children = _ref.children,
6057
6091
  testID = _ref.testID,
6058
6092
  style = _ref.style;
6059
- var collapseAnim = React.useRef(new Animated.Value(0)).current;
6060
6093
  var _React$useState = React.useState(0),
6061
6094
  _React$useState2 = _slicedToArray(_React$useState, 2),
6062
6095
  contentHeight = _React$useState2[0],
@@ -6064,11 +6097,7 @@ var Collapse = function Collapse(_ref) {
6064
6097
  var previousOpenState = usePrevious(open);
6065
6098
  useEffect(function () {
6066
6099
  if (open !== previousOpenState && previousOpenState !== undefined || open) {
6067
- Animated.timing(collapseAnim, {
6068
- toValue: open ? contentHeight : 0,
6069
- easing: Easing.inOut(Easing.cubic),
6070
- useNativeDriver: false
6071
- }).start();
6100
+ LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
6072
6101
  }
6073
6102
  }, [open, previousOpenState, contentHeight]);
6074
6103
  var fetchMaxHeight = useCallback(function (_ref2) {
@@ -6077,7 +6106,7 @@ var Collapse = function Collapse(_ref) {
6077
6106
  }, []);
6078
6107
  return /*#__PURE__*/React.createElement(StyledWrapper$c, {
6079
6108
  style: {
6080
- height: collapseAnim
6109
+ height: open ? contentHeight : 0
6081
6110
  },
6082
6111
  testID: testID
6083
6112
  }, /*#__PURE__*/React.createElement(StyledHiddenWrapper, null, /*#__PURE__*/React.createElement(StyledChildWrapper, {
@@ -11289,6 +11318,7 @@ var CardCarousel = /*#__PURE__*/forwardRef(function (_ref, ref) {
11289
11318
  setFlatListWidth = _useState4[1];
11290
11319
  var itemWidth = flatListWidth * ITEM_WIDTH_RATE;
11291
11320
  var carouselRef = useRef(null);
11321
+ var viewPosition = Platform.OS === 'ios' ? VIEW_POSITION_CENTER : undefined;
11292
11322
  var _snapToIndex = useCallback(function (index) {
11293
11323
  var _carouselRef$current;
11294
11324
  var validIndex = 0;
@@ -11302,7 +11332,7 @@ var CardCarousel = /*#__PURE__*/forwardRef(function (_ref, ref) {
11302
11332
  (_carouselRef$current = carouselRef.current) === null || _carouselRef$current === void 0 ? void 0 : _carouselRef$current.scrollToIndex({
11303
11333
  index: validIndex,
11304
11334
  animated: true,
11305
- viewPosition: VIEW_POSITION_CENTER
11335
+ viewPosition: viewPosition
11306
11336
  });
11307
11337
  }, [carouselRef, itemWidth]);
11308
11338
  /*
@@ -11317,7 +11347,7 @@ var CardCarousel = /*#__PURE__*/forwardRef(function (_ref, ref) {
11317
11347
  (_carouselRef$current2 = carouselRef.current) === null || _carouselRef$current2 === void 0 ? void 0 : _carouselRef$current2.scrollToIndex({
11318
11348
  index: nextIndex,
11319
11349
  animated: true,
11320
- viewPosition: VIEW_POSITION_CENTER
11350
+ viewPosition: viewPosition
11321
11351
  });
11322
11352
  }, [carouselRef, currentIndex, itemWidth, items.length]);
11323
11353
  React.useImperativeHandle(ref, function () {
@@ -11372,16 +11402,31 @@ var CardCarousel = /*#__PURE__*/forwardRef(function (_ref, ref) {
11372
11402
  }
11373
11403
  }, /*#__PURE__*/React.createElement(StyledShadow, null, /*#__PURE__*/React.createElement(StyledCard, null, item)));
11374
11404
  }, [itemWidth]);
11405
+ var contentContainerPaddingHorizontal = theme.__hd__.cardCarousel.space.contentContainerPaddingHorizontal;
11375
11406
  return /*#__PURE__*/React.createElement(StyledWrapper$7, {
11376
11407
  style: style,
11377
11408
  testID: testID
11378
11409
  }, /*#__PURE__*/React.createElement(FlatList, {
11379
11410
  contentInset: {
11380
11411
  top: 0,
11381
- left: theme.__hd__.cardCarousel.space.contentContainerPaddingHorizontal,
11412
+ left: contentContainerPaddingHorizontal,
11382
11413
  bottom: 0,
11383
- right: theme.__hd__.cardCarousel.space.contentContainerPaddingHorizontal
11414
+ right: contentContainerPaddingHorizontal
11384
11415
  },
11416
+ ListHeaderComponent: Platform.select({
11417
+ android: /*#__PURE__*/React.createElement(View, {
11418
+ style: {
11419
+ width: contentContainerPaddingHorizontal
11420
+ }
11421
+ })
11422
+ }),
11423
+ ListFooterComponent: Platform.select({
11424
+ android: /*#__PURE__*/React.createElement(View, {
11425
+ style: {
11426
+ width: contentContainerPaddingHorizontal
11427
+ }
11428
+ })
11429
+ }),
11385
11430
  onLayout: flatListOnLayout,
11386
11431
  data: items,
11387
11432
  horizontal: true,
@@ -11398,7 +11443,9 @@ var CardCarousel = /*#__PURE__*/forwardRef(function (_ref, ref) {
11398
11443
  },
11399
11444
  decelerationRate: "fast",
11400
11445
  renderToHardwareTextureAndroid: true,
11401
- snapToInterval: itemWidth,
11446
+ snapToInterval: Platform.select({
11447
+ ios: itemWidth
11448
+ }),
11402
11449
  onViewableItemsChanged: visibleSlideChanged,
11403
11450
  viewabilityConfig: {
11404
11451
  itemVisiblePercentThreshold: 80
@@ -11623,14 +11670,18 @@ var StyledLabel = index$a(Typography.Text)(function (_ref3) {
11623
11670
  var theme = _ref3.theme,
11624
11671
  themeState = _ref3.themeState;
11625
11672
  return {
11626
- color: theme.__hd__.textInput.colors.labels[themeState]
11673
+ color: theme.__hd__.textInput.colors.labels[themeState],
11674
+ fontSize: theme.__hd__.textInput.fontSizes.topLabel,
11675
+ lineHeight: theme.__hd__.textInput.lineHeights.topLabel
11627
11676
  };
11628
11677
  });
11629
11678
  var StyledAsteriskLabel = index$a(Typography.Text)(function (_ref4) {
11630
11679
  var theme = _ref4.theme,
11631
11680
  themeState = _ref4.themeState;
11632
11681
  return {
11633
- color: theme.__hd__.textInput.colors.asterisks[themeState]
11682
+ color: theme.__hd__.textInput.colors.asterisks[themeState],
11683
+ fontSize: theme.__hd__.textInput.fontSizes.topLabel,
11684
+ lineHeight: theme.__hd__.textInput.lineHeights.topLabel
11634
11685
  };
11635
11686
  });
11636
11687
  var StyledLabelContainerInsideTextInput = index$a(View)(function (_ref5) {
@@ -11938,12 +11989,10 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
11938
11989
  backgroundColor: backgroundColor
11939
11990
  }
11940
11991
  }, required && /*#__PURE__*/React.createElement(StyledAsteriskLabel, {
11941
- themeState: state,
11942
- fontSize: "small"
11992
+ themeState: state
11943
11993
  }, "*"), !!label && /*#__PURE__*/React.createElement(StyledLabel, {
11944
11994
  nativeID: accessibilityLabelledBy,
11945
11995
  testID: "input-label",
11946
- fontSize: "small",
11947
11996
  themeState: state,
11948
11997
  style: {
11949
11998
  backgroundColor: backgroundColor
@@ -12667,7 +12716,8 @@ var StyledErrorTitle = index$a(Typography.Text)(function (_ref8) {
12667
12716
  fontSize: theme.__hd__.error.fontSizes.title,
12668
12717
  textAlign: 'center',
12669
12718
  marginBottom: theme.__hd__.error.space.titleMarginBottom,
12670
- color: theme.__hd__.error.colors.title
12719
+ color: theme.__hd__.error.colors.title,
12720
+ lineHeight: theme.__hd__.error.lineHeight.title
12671
12721
  };
12672
12722
  });
12673
12723
  var StyledErrorDescription = index$a(Typography.Text)(function (_ref9) {
@@ -12676,7 +12726,8 @@ var StyledErrorDescription = index$a(Typography.Text)(function (_ref9) {
12676
12726
  fontFamily: theme.__hd__.error.fonts.description,
12677
12727
  fontSize: theme.__hd__.error.fontSizes.description,
12678
12728
  textAlign: 'center',
12679
- color: theme.__hd__.error.colors.description
12729
+ color: theme.__hd__.error.colors.description,
12730
+ lineHeight: theme.__hd__.error.lineHeight.description
12680
12731
  };
12681
12732
  });
12682
12733
 
@@ -13901,7 +13952,7 @@ var AnimatedSpinner = function AnimatedSpinner(_ref) {
13901
13952
  toValue: 1,
13902
13953
  duration: 1200,
13903
13954
  easing: Easing.linear,
13904
- useNativeDriver: true
13955
+ useNativeDriver: Platform.OS !== 'web'
13905
13956
  }));
13906
13957
  animation.start();
13907
13958
  return function () {