@hero-design/rn 8.12.5 → 8.14.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/lib/index.js CHANGED
@@ -2193,6 +2193,44 @@ var getEmptyTheme = function getEmptyTheme(theme) {
2193
2193
  };
2194
2194
  };
2195
2195
 
2196
+ var getErrorTheme = function getErrorTheme(theme) {
2197
+ var space = {
2198
+ titleMarginBottom: theme.space.small,
2199
+ imageMarginBottom: theme.space.xlarge,
2200
+ wrapperPadding: theme.space.large,
2201
+ button: {
2202
+ wrapperHorizontalPadding: theme.space.medium,
2203
+ wrapperVerticalPadding: theme.space.xxxlarge,
2204
+ margin: theme.space.medium,
2205
+ padding: theme.space.medium
2206
+ }
2207
+ };
2208
+ var sizes = {
2209
+ image: theme.sizes['19xlarge']
2210
+ };
2211
+ var colors = {
2212
+ title: theme.colors.onDefaultGlobalSurface,
2213
+ description: theme.colors.mutedOnDefaultGlobalSurface,
2214
+ fullScreenBackground: theme.colors.decorativePrimarySurface,
2215
+ inPageBackground: theme.colors.neutralGlobalSurface
2216
+ };
2217
+ var fontSizes = {
2218
+ title: theme.fontSizes.xxxlarge,
2219
+ description: theme.fontSizes.xlarge
2220
+ };
2221
+ var fonts = {
2222
+ title: theme.fonts.playful.semiBold,
2223
+ description: theme.fonts.playful.regular
2224
+ };
2225
+ return {
2226
+ fontSizes: fontSizes,
2227
+ colors: colors,
2228
+ sizes: sizes,
2229
+ space: space,
2230
+ fonts: fonts
2231
+ };
2232
+ };
2233
+
2196
2234
  var getFABTheme = function getFABTheme(theme) {
2197
2235
  var colors = {
2198
2236
  buttonBackground: theme.colors.primary,
@@ -2973,6 +3011,7 @@ var getTheme$1 = function getTheme() {
2973
3011
  divider: getDividerTheme(globalTheme),
2974
3012
  drawer: getDrawerTheme(globalTheme),
2975
3013
  empty: getEmptyTheme(globalTheme),
3014
+ error: getErrorTheme(globalTheme),
2976
3015
  fab: getFABTheme(globalTheme),
2977
3016
  icon: getIconTheme(globalTheme),
2978
3017
  image: getImageTheme(globalTheme),
@@ -6007,7 +6046,7 @@ var StyledText$3 = index$a(reactNative.Text)(function (_ref) {
6007
6046
  });
6008
6047
  });
6009
6048
 
6010
- var _excluded$p = ["children", "fontSize", "fontWeight", "intent", "typeface", "allowFontScaling"];
6049
+ var _excluded$q = ["children", "fontSize", "fontWeight", "intent", "typeface", "allowFontScaling"];
6011
6050
  var Text = function Text(_ref) {
6012
6051
  var children = _ref.children,
6013
6052
  _ref$fontSize = _ref.fontSize,
@@ -6020,7 +6059,7 @@ var Text = function Text(_ref) {
6020
6059
  typeface = _ref$typeface === void 0 ? 'neutral' : _ref$typeface,
6021
6060
  _ref$allowFontScaling = _ref.allowFontScaling,
6022
6061
  allowFontScaling = _ref$allowFontScaling === void 0 ? false : _ref$allowFontScaling,
6023
- nativeProps = _objectWithoutProperties(_ref, _excluded$p);
6062
+ nativeProps = _objectWithoutProperties(_ref, _excluded$q);
6024
6063
  return /*#__PURE__*/React__default["default"].createElement(StyledText$3, _extends$1({}, nativeProps, {
6025
6064
  themeFontSize: fontSize,
6026
6065
  themeFontWeight: fontWeight,
@@ -6527,10 +6566,10 @@ var StyledHeroIcon = index$a(HeroIcon)(function (_ref) {
6527
6566
  };
6528
6567
  });
6529
6568
 
6530
- var _excluded$o = ["style"];
6569
+ var _excluded$p = ["style"];
6531
6570
  var AnimatedIcon = function AnimatedIcon(_ref) {
6532
6571
  var style = _ref.style,
6533
- otherProps = _objectWithoutProperties(_ref, _excluded$o);
6572
+ otherProps = _objectWithoutProperties(_ref, _excluded$p);
6534
6573
  var rotateAnimation = React.useRef(new reactNative.Animated.Value(0));
6535
6574
  React.useEffect(function () {
6536
6575
  var animation = reactNative.Animated.loop(reactNative.Animated.timing(rotateAnimation.current, {
@@ -6636,7 +6675,7 @@ var AccordionItem = function AccordionItem(_ref) {
6636
6675
  }, content));
6637
6676
  };
6638
6677
 
6639
- var _excluded$n = ["key"];
6678
+ var _excluded$o = ["key"];
6640
6679
  var Accordion = function Accordion(_ref) {
6641
6680
  var items = _ref.items,
6642
6681
  activeItemKey = _ref.activeItemKey,
@@ -6657,7 +6696,7 @@ var Accordion = function Accordion(_ref) {
6657
6696
  testID: testID
6658
6697
  }, items.map(function (_ref2, index) {
6659
6698
  var key = _ref2.key,
6660
- props = _objectWithoutProperties(_ref2, _excluded$n);
6699
+ props = _objectWithoutProperties(_ref2, _excluded$o);
6661
6700
  var open = _activeItemKey === key;
6662
6701
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
6663
6702
  key: key
@@ -7043,7 +7082,7 @@ var StyledStatus = index$a(reactNative.Animated.View)(function (_ref3) {
7043
7082
  };
7044
7083
  });
7045
7084
 
7046
- var _excluded$m = ["children", "visible", "intent", "style", "testID"];
7085
+ var _excluded$n = ["children", "visible", "intent", "style", "testID"];
7047
7086
  var Status = function Status(_ref) {
7048
7087
  var children = _ref.children,
7049
7088
  _ref$visible = _ref.visible,
@@ -7052,7 +7091,7 @@ var Status = function Status(_ref) {
7052
7091
  intent = _ref$intent === void 0 ? 'danger' : _ref$intent,
7053
7092
  style = _ref.style,
7054
7093
  testID = _ref.testID,
7055
- nativeProps = _objectWithoutProperties(_ref, _excluded$m);
7094
+ nativeProps = _objectWithoutProperties(_ref, _excluded$n);
7056
7095
  var _React$useRef = React__default["default"].useRef(new reactNative.Animated.Value(visible ? 1 : 0)),
7057
7096
  opacity = _React$useRef.current;
7058
7097
  var isFirstRendering = React__default["default"].useRef(true);
@@ -7085,7 +7124,7 @@ var Status = function Status(_ref) {
7085
7124
  }));
7086
7125
  };
7087
7126
 
7088
- var _excluded$l = ["content", "visible", "max", "intent", "style", "testID"];
7127
+ var _excluded$m = ["content", "visible", "max", "intent", "style", "testID"];
7089
7128
  var DEFAULT_MAX_NUMBER = 99;
7090
7129
  var getPaddingState = function getPaddingState(content) {
7091
7130
  return content.length > 1 ? 'wideContent' : 'narrowContent';
@@ -7100,7 +7139,7 @@ var Badge = function Badge(_ref) {
7100
7139
  intent = _ref$intent === void 0 ? 'danger' : _ref$intent,
7101
7140
  style = _ref.style,
7102
7141
  testID = _ref.testID,
7103
- nativeProps = _objectWithoutProperties(_ref, _excluded$l);
7142
+ nativeProps = _objectWithoutProperties(_ref, _excluded$m);
7104
7143
  var _React$useRef = React__default["default"].useRef(new reactNative.Animated.Value(visible ? 1 : 0)),
7105
7144
  opacity = _React$useRef.current;
7106
7145
  var isFirstRendering = React__default["default"].useRef(true);
@@ -7204,7 +7243,7 @@ function omit(keys, obj) {
7204
7243
  return result;
7205
7244
  }
7206
7245
 
7207
- var _excluded$k = ["onTabPress", "renderActiveTabOnly", "selectedTabKey", "tabs"];
7246
+ var _excluded$l = ["onTabPress", "renderActiveTabOnly", "selectedTabKey", "tabs"];
7208
7247
  var getInactiveIcon = function getInactiveIcon(icon) {
7209
7248
  var inactiveIcon = "".concat(icon, "-outlined");
7210
7249
  return isHeroIcon(inactiveIcon) ? inactiveIcon : icon;
@@ -7215,7 +7254,7 @@ var BottomNavigation = function BottomNavigation(_ref) {
7215
7254
  renderActiveTabOnly = _ref$renderActiveTabO === void 0 ? false : _ref$renderActiveTabO,
7216
7255
  selectedTabKey = _ref.selectedTabKey,
7217
7256
  tabs = _ref.tabs,
7218
- nativeProps = _objectWithoutProperties(_ref, _excluded$k);
7257
+ nativeProps = _objectWithoutProperties(_ref, _excluded$l);
7219
7258
  var insets = reactNativeSafeAreaContext.useSafeAreaInsets();
7220
7259
  /**
7221
7260
  * List of loaded tabs, tabs will be loaded when navigated to.
@@ -7302,13 +7341,13 @@ var StyledDivider = index$a(reactNative.View)(function (_ref) {
7302
7341
  }, horizontalMargin), verticalMargin);
7303
7342
  });
7304
7343
 
7305
- var _excluded$j = ["marginHorizontal", "marginVertical", "style", "testID"];
7344
+ var _excluded$k = ["marginHorizontal", "marginVertical", "style", "testID"];
7306
7345
  var Divider = function Divider(_ref) {
7307
7346
  var marginHorizontal = _ref.marginHorizontal,
7308
7347
  marginVertical = _ref.marginVertical,
7309
7348
  style = _ref.style,
7310
7349
  testID = _ref.testID,
7311
- nativeProps = _objectWithoutProperties(_ref, _excluded$j);
7350
+ nativeProps = _objectWithoutProperties(_ref, _excluded$k);
7312
7351
  return /*#__PURE__*/React__default["default"].createElement(StyledDivider, _extends$1({}, nativeProps, {
7313
7352
  themeMarginHorizontal: marginHorizontal,
7314
7353
  themeMarginVertical: marginVertical,
@@ -7438,7 +7477,7 @@ var StyledLoadingDot = index$a(reactNative.View)(function (_ref2) {
7438
7477
  }, themeStyling());
7439
7478
  });
7440
7479
 
7441
- var _excluded$i = ["count", "size", "testID", "themeVariant"];
7480
+ var _excluded$j = ["count", "size", "testID", "themeVariant"];
7442
7481
  var AnimatedLoadingIndicatorWrapper = reactNative.Animated.createAnimatedComponent(StyledLoadingIndicatorWrapper);
7443
7482
  var AnimatedLoadingDot = reactNative.Animated.createAnimatedComponent(StyledLoadingDot);
7444
7483
  var renderDotComponent = function renderDotComponent(_ref) {
@@ -7470,7 +7509,7 @@ var LoadingIndicator = function LoadingIndicator(_ref2) {
7470
7509
  size = _ref2$size === void 0 ? 12 : _ref2$size,
7471
7510
  testID = _ref2.testID,
7472
7511
  themeVariant = _ref2.themeVariant,
7473
- nativeProps = _objectWithoutProperties(_ref2, _excluded$i);
7512
+ nativeProps = _objectWithoutProperties(_ref2, _excluded$j);
7474
7513
  var progressAnimation = React.useRef(new reactNative.Animated.Value(0));
7475
7514
  React.useEffect(function () {
7476
7515
  var animation = reactNative.Animated.loop(reactNative.Animated.timing(progressAnimation.current, {
@@ -7900,11 +7939,11 @@ var Header = function Header(_ref) {
7900
7939
  })) : null), showDivider ? /*#__PURE__*/React__default["default"].createElement(Divider, null) : null);
7901
7940
  };
7902
7941
 
7903
- var _excluded$h = ["scrollEventThrottle"];
7942
+ var _excluded$i = ["scrollEventThrottle"];
7904
7943
  var BottomSheetScrollView = function BottomSheetScrollView(_ref) {
7905
7944
  var _ref$scrollEventThrot = _ref.scrollEventThrottle,
7906
7945
  scrollEventThrottle = _ref$scrollEventThrot === void 0 ? 100 : _ref$scrollEventThrot,
7907
- props = _objectWithoutProperties(_ref, _excluded$h);
7946
+ props = _objectWithoutProperties(_ref, _excluded$i);
7908
7947
  var _useContext = React.useContext(BottomSheetContext),
7909
7948
  setInternalShowDivider = _useContext.setInternalShowDivider;
7910
7949
  var onScrollBeginDrag = React.useCallback(function (e) {
@@ -8219,7 +8258,7 @@ var borderWidths = {
8219
8258
  var config = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, colors), space), radii), borderWidths);
8220
8259
  var flexPropsKey = ['alignContent', 'alignItems', 'alignSelf', 'display', 'flex', 'flexBasis', 'flexDirection', 'flexGrow', 'flexShrink', 'flexWrap', 'justifyContent'];
8221
8260
 
8222
- var _excluded$g = ["theme"];
8261
+ var _excluded$h = ["theme"];
8223
8262
  var getThemeValue = function getThemeValue(theme, key, props) {
8224
8263
  var propConfig = config[key];
8225
8264
  var propValue = props[key];
@@ -8246,18 +8285,18 @@ var mapStylePropToThemeValue = function mapStylePropToThemeValue(theme, props) {
8246
8285
  var configKeys = Object.keys(config);
8247
8286
  var StyledBox = index$a(reactNative.View)(function (_ref5) {
8248
8287
  var theme = _ref5.theme,
8249
- otherProps = _objectWithoutProperties(_ref5, _excluded$g);
8288
+ otherProps = _objectWithoutProperties(_ref5, _excluded$h);
8250
8289
  var styleProps = pick(configKeys, otherProps);
8251
8290
  var flexProps = pick(_toConsumableArray(flexPropsKey), otherProps);
8252
8291
  return _objectSpread2(_objectSpread2({}, mapStylePropToThemeValue(theme, styleProps)), flexProps);
8253
8292
  });
8254
8293
 
8255
- var _excluded$f = ["children", "style", "testID"];
8294
+ var _excluded$g = ["children", "style", "testID"];
8256
8295
  var Box = function Box(_ref) {
8257
8296
  var children = _ref.children,
8258
8297
  style = _ref.style,
8259
8298
  testID = _ref.testID,
8260
- otherProps = _objectWithoutProperties(_ref, _excluded$f);
8299
+ otherProps = _objectWithoutProperties(_ref, _excluded$g);
8261
8300
  return /*#__PURE__*/React__default["default"].createElement(StyledBox, _extends$1({}, otherProps, {
8262
8301
  style: style,
8263
8302
  testID: testID
@@ -10822,7 +10861,7 @@ var Calendar = function Calendar(_ref) {
10822
10861
  })));
10823
10862
  };
10824
10863
 
10825
- var _excluded$e = ["rounded", "size", "testID", "style"];
10864
+ var _excluded$f = ["rounded", "size", "testID", "style"];
10826
10865
  var Image = function Image(_ref) {
10827
10866
  var _ref$rounded = _ref.rounded,
10828
10867
  rounded = _ref$rounded === void 0 ? false : _ref$rounded,
@@ -10830,7 +10869,7 @@ var Image = function Image(_ref) {
10830
10869
  size = _ref$size === void 0 ? '6xlarge' : _ref$size,
10831
10870
  testID = _ref.testID,
10832
10871
  style = _ref.style,
10833
- imageNativeProps = _objectWithoutProperties(_ref, _excluded$e);
10872
+ imageNativeProps = _objectWithoutProperties(_ref, _excluded$f);
10834
10873
  var theme = useTheme();
10835
10874
  var imageSize = theme.__hd__.image.sizes[size];
10836
10875
  return /*#__PURE__*/React__default["default"].createElement(reactNative.Image, _extends$1({
@@ -11023,12 +11062,12 @@ var Indicator = index$a(reactNative.View)(function (_ref2) {
11023
11062
  };
11024
11063
  });
11025
11064
 
11026
- var _excluded$d = ["intent", "children"];
11065
+ var _excluded$e = ["intent", "children"];
11027
11066
  var DataCard = function DataCard(_ref) {
11028
11067
  var _ref$intent = _ref.intent,
11029
11068
  intent = _ref$intent === void 0 ? 'info' : _ref$intent,
11030
11069
  children = _ref.children,
11031
- nativeProps = _objectWithoutProperties(_ref, _excluded$d);
11070
+ nativeProps = _objectWithoutProperties(_ref, _excluded$e);
11032
11071
  return /*#__PURE__*/React__default["default"].createElement(StyledDataCard, nativeProps, /*#__PURE__*/React__default["default"].createElement(Indicator, {
11033
11072
  themeIntent: intent,
11034
11073
  testID: "data-card-indicator"
@@ -11046,11 +11085,11 @@ var StyledCard$1 = index$a(reactNative.View)(function (_ref) {
11046
11085
  });
11047
11086
  });
11048
11087
 
11049
- var _excluded$c = ["intent", "children"];
11088
+ var _excluded$d = ["intent", "children"];
11050
11089
  var Card = function Card(_ref) {
11051
11090
  var intent = _ref.intent,
11052
11091
  children = _ref.children,
11053
- nativeProps = _objectWithoutProperties(_ref, _excluded$c);
11092
+ nativeProps = _objectWithoutProperties(_ref, _excluded$d);
11054
11093
  return /*#__PURE__*/React__default["default"].createElement(StyledCard$1, _extends$1({}, nativeProps, {
11055
11094
  themeIntent: intent
11056
11095
  }), children);
@@ -11238,7 +11277,7 @@ var CardCarousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
11238
11277
  }));
11239
11278
  });
11240
11279
 
11241
- var _excluded$b = ["items", "onItemIndexChange", "renderActions", "selectedItemIndex", "style", "shouldShowPagination"];
11280
+ var _excluded$c = ["items", "onItemIndexChange", "renderActions", "selectedItemIndex", "style", "shouldShowPagination"];
11242
11281
  function useStateFromProp(initialValue) {
11243
11282
  var _useState = React.useState(initialValue),
11244
11283
  _useState2 = _slicedToArray(_useState, 2),
@@ -11260,7 +11299,7 @@ var Carousel = function Carousel(_ref) {
11260
11299
  shouldShowPagination = _ref$shouldShowPagina === void 0 ? function () {
11261
11300
  return true;
11262
11301
  } : _ref$shouldShowPagina,
11263
- nativeProps = _objectWithoutProperties(_ref, _excluded$b);
11302
+ nativeProps = _objectWithoutProperties(_ref, _excluded$c);
11264
11303
  var carouselRef = React.useRef(null);
11265
11304
  var _useStateFromProp = useStateFromProp(selectedItemIndex),
11266
11305
  _useStateFromProp2 = _slicedToArray(_useStateFromProp, 2),
@@ -11480,7 +11519,7 @@ var StyledAsteriskLabelInsideTextInput = index$a(Typography.Text)(function (_ref
11480
11519
  fontSize: theme.__hd__.textInput.fontSizes.asteriskLabel
11481
11520
  };
11482
11521
  });
11483
- var StyledErrorContainer$1 = index$a(reactNative.View)(function (_ref7) {
11522
+ var StyledErrorContainer$2 = index$a(reactNative.View)(function (_ref7) {
11484
11523
  var theme = _ref7.theme;
11485
11524
  return {
11486
11525
  marginRight: theme.__hd__.textInput.space.errorContainerMarginRight,
@@ -11572,7 +11611,7 @@ var StyledErrorAndMaxLengthContainer = index$a(reactNative.View)(function () {
11572
11611
  };
11573
11612
  });
11574
11613
 
11575
- var _excluded$a = ["label", "prefix", "suffix", "style", "textStyle", "testID", "accessibilityLabelledBy", "error", "required", "editable", "disabled", "loading", "maxLength", "helpText", "value", "defaultValue", "renderInputValue", "allowFontScaling"];
11614
+ var _excluded$b = ["label", "prefix", "suffix", "style", "textStyle", "testID", "accessibilityLabelledBy", "error", "required", "editable", "disabled", "loading", "maxLength", "helpText", "value", "defaultValue", "renderInputValue", "allowFontScaling"];
11576
11615
  var getVariant$1 = function getVariant(_ref) {
11577
11616
  var disabled = _ref.disabled,
11578
11617
  error = _ref.error,
@@ -11620,7 +11659,7 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
11620
11659
  renderInputValue = _ref2.renderInputValue,
11621
11660
  _ref2$allowFontScalin = _ref2.allowFontScaling,
11622
11661
  allowFontScaling = _ref2$allowFontScalin === void 0 ? false : _ref2$allowFontScalin,
11623
- nativeProps = _objectWithoutProperties(_ref2, _excluded$a);
11662
+ nativeProps = _objectWithoutProperties(_ref2, _excluded$b);
11624
11663
  var displayText = (_ref3 = value !== undefined ? value : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : '';
11625
11664
  var isEmptyValue = displayText.length === 0;
11626
11665
  var actualSuffix = loading ? 'loading' : suffix;
@@ -11783,7 +11822,7 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
11783
11822
  icon: actualSuffix,
11784
11823
  spin: actualSuffix === 'loading',
11785
11824
  size: "xsmall"
11786
- }) : suffix), /*#__PURE__*/React__default["default"].createElement(StyledErrorAndHelpTextContainer, null, /*#__PURE__*/React__default["default"].createElement(StyledErrorAndMaxLengthContainer, null, error ? /*#__PURE__*/React__default["default"].createElement(StyledErrorContainer$1, null, /*#__PURE__*/React__default["default"].createElement(Icon, {
11825
+ }) : suffix), /*#__PURE__*/React__default["default"].createElement(StyledErrorAndHelpTextContainer, null, /*#__PURE__*/React__default["default"].createElement(StyledErrorAndMaxLengthContainer, null, error ? /*#__PURE__*/React__default["default"].createElement(StyledErrorContainer$2, null, /*#__PURE__*/React__default["default"].createElement(Icon, {
11787
11826
  testID: "input-error-icon",
11788
11827
  icon: "circle-info",
11789
11828
  size: "xsmall",
@@ -12291,6 +12330,210 @@ var Empty = function Empty(_ref) {
12291
12330
  }, description));
12292
12331
  };
12293
12332
 
12333
+ var StyledErrorModal = index$a(reactNative.Modal)({
12334
+ height: '100%',
12335
+ width: '100%'
12336
+ });
12337
+ var StyledErrorContainer$1 = index$a(reactNative.View)(function (_ref) {
12338
+ var theme = _ref.theme,
12339
+ themeVariant = _ref.themeVariant;
12340
+ return {
12341
+ display: 'flex',
12342
+ flex: 1,
12343
+ flexDirection: 'column',
12344
+ backgroundColor: themeVariant === 'in-page' ? theme.__hd__.error.colors.inPageBackground : theme.__hd__.error.colors.fullScreenBackground
12345
+ };
12346
+ });
12347
+ var StyledErrorContent = index$a(reactNative.View)(function (_ref2) {
12348
+ var theme = _ref2.theme;
12349
+ return {
12350
+ display: 'flex',
12351
+ flex: 1,
12352
+ flexDirection: 'column',
12353
+ justifyContent: 'center',
12354
+ alignItems: 'center',
12355
+ padding: theme.__hd__.error.space.wrapperPadding
12356
+ };
12357
+ });
12358
+ var StyledErrorButtonContainer = index$a(reactNative.View)(function (_ref3) {
12359
+ var theme = _ref3.theme;
12360
+ return {
12361
+ display: 'flex',
12362
+ flexDirection: 'column',
12363
+ justifyContent: 'center',
12364
+ alignItems: 'center',
12365
+ paddingHorizontal: theme.__hd__.error.space.button.wrapperHorizontalPadding,
12366
+ paddingVertical: theme.__hd__.error.space.button.wrapperVerticalPadding
12367
+ };
12368
+ });
12369
+ var StyledErrorButtonPrimary = index$a(CompoundButton)(function (_ref4) {
12370
+ var theme = _ref4.theme;
12371
+ return {
12372
+ padding: theme.__hd__.error.space.button.padding
12373
+ };
12374
+ });
12375
+ var StyledErrorButtonSecondary = index$a(CompoundButton)(function (_ref5) {
12376
+ var theme = _ref5.theme;
12377
+ return {
12378
+ marginTop: theme.__hd__.error.space.button.margin,
12379
+ padding: theme.__hd__.error.space.button.padding
12380
+ };
12381
+ });
12382
+ var StyledErrorImage = index$a(Image)(function (_ref6) {
12383
+ var theme = _ref6.theme;
12384
+ return {
12385
+ marginBottom: theme.__hd__.error.space.imageMarginBottom,
12386
+ width: theme.__hd__.error.sizes.image,
12387
+ height: theme.__hd__.error.sizes.image,
12388
+ resizeMode: 'contain'
12389
+ };
12390
+ });
12391
+ var StyledErrorTitle = index$a(Typography.Text)(function (_ref7) {
12392
+ var theme = _ref7.theme;
12393
+ return {
12394
+ fontFamily: theme.__hd__.error.fonts.title,
12395
+ fontSize: theme.__hd__.error.fontSizes.title,
12396
+ textAlign: 'center',
12397
+ marginBottom: theme.__hd__.error.space.titleMarginBottom,
12398
+ color: theme.__hd__.error.colors.title
12399
+ };
12400
+ });
12401
+ var StyledErrorDescription = index$a(Typography.Text)(function (_ref8) {
12402
+ var theme = _ref8.theme;
12403
+ return {
12404
+ fontFamily: theme.__hd__.error.fonts.description,
12405
+ fontSize: theme.__hd__.error.fontSizes.description,
12406
+ textAlign: 'center',
12407
+ color: theme.__hd__.error.colors.description
12408
+ };
12409
+ });
12410
+
12411
+ var _excluded$a = ["variant", "title", "description", "image", "testID", "ctaText", "onCtaPress", "secondaryCtaText", "onSecondaryCtaPress"],
12412
+ _excluded2 = ["visible", "variant", "title", "description", "image", "testID", "ctaText", "onCtaPress", "secondaryCtaText", "onSecondaryCtaPress"];
12413
+ var ErrorPage = function ErrorPage(_ref) {
12414
+ var _ref$variant = _ref.variant,
12415
+ variant = _ref$variant === void 0 ? 'in-page' : _ref$variant,
12416
+ title = _ref.title,
12417
+ description = _ref.description,
12418
+ image = _ref.image,
12419
+ testID = _ref.testID,
12420
+ ctaText = _ref.ctaText,
12421
+ onCtaPress = _ref.onCtaPress,
12422
+ secondaryCtaText = _ref.secondaryCtaText,
12423
+ onSecondaryCtaPress = _ref.onSecondaryCtaPress,
12424
+ nativeProps = _objectWithoutProperties(_ref, _excluded$a);
12425
+ var showCta = ctaText && onCtaPress !== undefined;
12426
+ var showSecondaryCta = secondaryCtaText && onSecondaryCtaPress !== undefined;
12427
+ var showButtonContainer = showCta || showSecondaryCta;
12428
+ return /*#__PURE__*/React__default["default"].createElement(StyledErrorContainer$1, {
12429
+ testID: testID,
12430
+ themeVariant: variant
12431
+ }, /*#__PURE__*/React__default["default"].createElement(StyledErrorContent, nativeProps, image && /*#__PURE__*/React__default["default"].createElement(StyledErrorImage, {
12432
+ source: typeof image === 'string' ? {
12433
+ uri: image
12434
+ } : image,
12435
+ testID: "error-image"
12436
+ }), /*#__PURE__*/React__default["default"].createElement(StyledErrorTitle, null, title), description && /*#__PURE__*/React__default["default"].createElement(StyledErrorDescription, null, description)), showButtonContainer && /*#__PURE__*/React__default["default"].createElement(StyledErrorButtonContainer, null, showCta && /*#__PURE__*/React__default["default"].createElement(StyledErrorButtonPrimary, {
12437
+ variant: "filled",
12438
+ text: ctaText,
12439
+ onPress: onCtaPress
12440
+ }), showSecondaryCta && /*#__PURE__*/React__default["default"].createElement(StyledErrorButtonSecondary, {
12441
+ variant: "text",
12442
+ text: secondaryCtaText,
12443
+ onPress: onSecondaryCtaPress
12444
+ })));
12445
+ };
12446
+ /**
12447
+ * Renders error page
12448
+ *
12449
+ * @param {ErrorProps}
12450
+ * @return {*} {ReactElement}
12451
+ */
12452
+ var Error$1 = function Error(_ref2) {
12453
+ var _ref2$visible = _ref2.visible,
12454
+ visible = _ref2$visible === void 0 ? true : _ref2$visible,
12455
+ _ref2$variant = _ref2.variant,
12456
+ variant = _ref2$variant === void 0 ? 'in-page' : _ref2$variant,
12457
+ title = _ref2.title,
12458
+ description = _ref2.description,
12459
+ image = _ref2.image,
12460
+ testID = _ref2.testID,
12461
+ ctaText = _ref2.ctaText,
12462
+ onCtaPress = _ref2.onCtaPress,
12463
+ secondaryCtaText = _ref2.secondaryCtaText,
12464
+ onSecondaryCtaPress = _ref2.onSecondaryCtaPress,
12465
+ nativeProps = _objectWithoutProperties(_ref2, _excluded2);
12466
+ useDeprecation("Visible prop is deprecated. Use conditional rendering instead", visible);
12467
+ var _useState = React.useState(visible),
12468
+ _useState2 = _slicedToArray(_useState, 2),
12469
+ isVisible = _useState2[0],
12470
+ setIsVisible = _useState2[1];
12471
+ var _useState3 = React.useState(null),
12472
+ _useState4 = _slicedToArray(_useState3, 2),
12473
+ ctaPressed = _useState4[0],
12474
+ setCtaPressed = _useState4[1];
12475
+ var onCloseModal = React.useCallback(function () {
12476
+ if (ctaPressed === 'cta' && onCtaPress) {
12477
+ onCtaPress();
12478
+ }
12479
+ if (ctaPressed === 'secondaryCta' && onSecondaryCtaPress) {
12480
+ onSecondaryCtaPress();
12481
+ }
12482
+ setCtaPressed(null);
12483
+ }, [ctaPressed, onCtaPress, onSecondaryCtaPress]);
12484
+ React.useEffect(function () {
12485
+ setIsVisible(visible);
12486
+ }, [visible]);
12487
+ // These useEffect lines prevents race condition error when callback contains navigation logic
12488
+ React.useEffect(function () {
12489
+ if (ctaPressed) {
12490
+ setIsVisible(false);
12491
+ }
12492
+ }, [ctaPressed]);
12493
+ React.useEffect(function () {
12494
+ if (!isVisible) {
12495
+ onCloseModal();
12496
+ }
12497
+ }, [isVisible, onCloseModal]);
12498
+ if (variant === 'full-screen') {
12499
+ return /*#__PURE__*/React__default["default"].createElement(StyledErrorModal, {
12500
+ visible: isVisible,
12501
+ onRequestClose: function onRequestClose() {
12502
+ return setIsVisible(false);
12503
+ },
12504
+ onDismiss: function onDismiss() {
12505
+ return setIsVisible(false);
12506
+ },
12507
+ animationType: "slide"
12508
+ }, /*#__PURE__*/React__default["default"].createElement(ErrorPage, _extends$1({
12509
+ variant: variant,
12510
+ title: title,
12511
+ description: description,
12512
+ image: image,
12513
+ testID: testID,
12514
+ ctaText: ctaText,
12515
+ onCtaPress: onCtaPress && function () {
12516
+ setCtaPressed('cta');
12517
+ },
12518
+ secondaryCtaText: secondaryCtaText,
12519
+ onSecondaryCtaPress: onSecondaryCtaPress && function () {
12520
+ setCtaPressed('secondaryCta');
12521
+ }
12522
+ }, nativeProps)));
12523
+ }
12524
+ return /*#__PURE__*/React__default["default"].createElement(ErrorPage, _extends$1({
12525
+ variant: variant,
12526
+ title: title,
12527
+ description: description,
12528
+ image: image,
12529
+ testID: testID,
12530
+ ctaText: ctaText,
12531
+ onCtaPress: onCtaPress,
12532
+ secondaryCtaText: secondaryCtaText,
12533
+ onSecondaryCtaPress: onSecondaryCtaPress
12534
+ }, nativeProps));
12535
+ };
12536
+
12294
12537
  var StyledFABContainer = index$a(reactNative.TouchableHighlight)(function (_ref) {
12295
12538
  var theme = _ref.theme;
12296
12539
  return {
@@ -31831,7 +32074,7 @@ var RichTextEditor = function RichTextEditor(_ref) {
31831
32074
  hideKeyboardAccessoryView: true,
31832
32075
  keyboardDisplayRequiresUserAction: false,
31833
32076
  height: webviewHeight
31834
- })))), /*#__PURE__*/React__default["default"].createElement(StyledErrorAndHelpTextContainer, null, /*#__PURE__*/React__default["default"].createElement(StyledErrorAndMaxLengthContainer, null, error ? /*#__PURE__*/React__default["default"].createElement(StyledErrorContainer$1, null, /*#__PURE__*/React__default["default"].createElement(Icon, {
32077
+ })))), /*#__PURE__*/React__default["default"].createElement(StyledErrorAndHelpTextContainer, null, /*#__PURE__*/React__default["default"].createElement(StyledErrorAndMaxLengthContainer, null, error ? /*#__PURE__*/React__default["default"].createElement(StyledErrorContainer$2, null, /*#__PURE__*/React__default["default"].createElement(Icon, {
31835
32078
  testID: "input-error-icon",
31836
32079
  icon: "circle-info",
31837
32080
  size: "xsmall",
@@ -31870,6 +32113,7 @@ exports.DatePicker = DatePicker;
31870
32113
  exports.Divider = Divider;
31871
32114
  exports.Drawer = index$7;
31872
32115
  exports.Empty = Empty;
32116
+ exports.Error = Error$1;
31873
32117
  exports.FAB = index$6;
31874
32118
  exports.Icon = Icon;
31875
32119
  exports.Image = Image;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.12.5",
3
+ "version": "8.14.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.12.5",
24
+ "@hero-design/colors": "8.14.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.12.5",
47
+ "@hero-design/eslint-plugin": "8.14.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.12.5",
63
+ "eslint-config-hd": "8.14.0",
64
64
  "jest": "^27.3.1",
65
- "prettier-config-hd": "8.12.5",
65
+ "prettier-config-hd": "8.14.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,86 @@
1
+ import styled from '@emotion/native';
2
+ import { Modal, View } from 'react-native';
3
+ import Image from '../Image';
4
+ import Typography from '../Typography';
5
+ import Button from '../Button';
6
+
7
+ type ErrorVariant = 'full-screen' | 'in-page';
8
+
9
+ const StyledErrorModal = styled(Modal)({
10
+ height: '100%',
11
+ width: '100%',
12
+ });
13
+
14
+ const StyledErrorContainer = styled(View)<{ themeVariant: ErrorVariant }>(
15
+ ({ theme, themeVariant }) => ({
16
+ display: 'flex',
17
+ flex: 1,
18
+ flexDirection: 'column',
19
+ backgroundColor:
20
+ themeVariant === 'in-page'
21
+ ? theme.__hd__.error.colors.inPageBackground
22
+ : theme.__hd__.error.colors.fullScreenBackground,
23
+ })
24
+ );
25
+
26
+ const StyledErrorContent = styled(View)(({ theme }) => ({
27
+ display: 'flex',
28
+ flex: 1,
29
+ flexDirection: 'column',
30
+ justifyContent: 'center',
31
+ alignItems: 'center',
32
+ padding: theme.__hd__.error.space.wrapperPadding,
33
+ }));
34
+
35
+ const StyledErrorButtonContainer = styled(View)(({ theme }) => ({
36
+ display: 'flex',
37
+ flexDirection: 'column',
38
+ justifyContent: 'center',
39
+ alignItems: 'center',
40
+ paddingHorizontal: theme.__hd__.error.space.button.wrapperHorizontalPadding,
41
+ paddingVertical: theme.__hd__.error.space.button.wrapperVerticalPadding,
42
+ }));
43
+
44
+ const StyledErrorButtonPrimary = styled(Button)(({ theme }) => ({
45
+ padding: theme.__hd__.error.space.button.padding,
46
+ }));
47
+
48
+ const StyledErrorButtonSecondary = styled(Button)(({ theme }) => ({
49
+ marginTop: theme.__hd__.error.space.button.margin,
50
+ padding: theme.__hd__.error.space.button.padding,
51
+ }));
52
+
53
+ const StyledErrorImage = styled(Image)(({ theme }) => ({
54
+ marginBottom: theme.__hd__.error.space.imageMarginBottom,
55
+ width: theme.__hd__.error.sizes.image,
56
+ height: theme.__hd__.error.sizes.image,
57
+ resizeMode: 'contain',
58
+ }));
59
+
60
+ const StyledErrorTitle = styled(Typography.Text)(({ theme }) => ({
61
+ fontFamily: theme.__hd__.error.fonts.title,
62
+ fontSize: theme.__hd__.error.fontSizes.title,
63
+ textAlign: 'center',
64
+ marginBottom: theme.__hd__.error.space.titleMarginBottom,
65
+ color: theme.__hd__.error.colors.title,
66
+ }));
67
+
68
+ const StyledErrorDescription = styled(Typography.Text)(({ theme }) => ({
69
+ fontFamily: theme.__hd__.error.fonts.description,
70
+ fontSize: theme.__hd__.error.fontSizes.description,
71
+ textAlign: 'center',
72
+ color: theme.__hd__.error.colors.description,
73
+ }));
74
+
75
+ export {
76
+ ErrorVariant,
77
+ StyledErrorModal,
78
+ StyledErrorImage,
79
+ StyledErrorContainer,
80
+ StyledErrorButtonContainer,
81
+ StyledErrorButtonPrimary,
82
+ StyledErrorButtonSecondary,
83
+ StyledErrorContent,
84
+ StyledErrorTitle,
85
+ StyledErrorDescription,
86
+ };