@hero-design/rn 8.42.0 → 8.42.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/lib/index.js CHANGED
@@ -8514,6 +8514,332 @@ var BottomSheetScrollView = function BottomSheetScrollView(_ref) {
8514
8514
  }));
8515
8515
  };
8516
8516
 
8517
+ var customAlphabet = function customAlphabet(alphabet) {
8518
+ var defaultSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 21;
8519
+ return function () {
8520
+ var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultSize;
8521
+ var id = '';
8522
+ var i = size;
8523
+ while (i--) {
8524
+ id += alphabet[Math.random() * alphabet.length | 0];
8525
+ }
8526
+ return id;
8527
+ };
8528
+ };
8529
+
8530
+ var ACTIONS;
8531
+ (function (ACTIONS) {
8532
+ ACTIONS[ACTIONS["REGISTER_HOST"] = 0] = "REGISTER_HOST";
8533
+ ACTIONS[ACTIONS["DEREGISTER_HOST"] = 1] = "DEREGISTER_HOST";
8534
+ ACTIONS[ACTIONS["ADD_UPDATE_PORTAL"] = 2] = "ADD_UPDATE_PORTAL";
8535
+ ACTIONS[ACTIONS["REMOVE_PORTAL"] = 3] = "REMOVE_PORTAL";
8536
+ })(ACTIONS || (ACTIONS = {}));
8537
+ var INITIAL_STATE = {};
8538
+
8539
+ var PortalStateContext = /*#__PURE__*/React.createContext(null);
8540
+ var PortalDispatchContext = /*#__PURE__*/React.createContext(null);
8541
+
8542
+ var usePortal = function usePortal() {
8543
+ var hostName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'root';
8544
+ var dispatch = React.useContext(PortalDispatchContext);
8545
+ if (dispatch === null) {
8546
+ throw new Error("You must add 'PortalProvider' to the root component.");
8547
+ }
8548
+ var registerHost = React.useCallback(function () {
8549
+ dispatch({
8550
+ type: ACTIONS.REGISTER_HOST,
8551
+ hostName: hostName
8552
+ });
8553
+ }, []);
8554
+ var deregisterHost = React.useCallback(function () {
8555
+ dispatch({
8556
+ type: ACTIONS.DEREGISTER_HOST,
8557
+ hostName: hostName
8558
+ });
8559
+ }, []);
8560
+ var addUpdatePortal = React.useCallback(function (name, node) {
8561
+ dispatch({
8562
+ type: ACTIONS.ADD_UPDATE_PORTAL,
8563
+ hostName: hostName,
8564
+ portalName: name,
8565
+ node: node
8566
+ });
8567
+ }, []);
8568
+ var removePortal = React.useCallback(function (name) {
8569
+ dispatch({
8570
+ type: ACTIONS.REMOVE_PORTAL,
8571
+ hostName: hostName,
8572
+ portalName: name
8573
+ });
8574
+ }, []);
8575
+ return {
8576
+ registerHost: registerHost,
8577
+ deregisterHost: deregisterHost,
8578
+ addPortal: addUpdatePortal,
8579
+ updatePortal: addUpdatePortal,
8580
+ removePortal: removePortal
8581
+ };
8582
+ };
8583
+
8584
+ var usePortalState = function usePortalState(hostName) {
8585
+ var state = React.useContext(PortalStateContext);
8586
+ if (state === null) {
8587
+ throw new Error("You must add 'PortalProvider' to the root component.");
8588
+ }
8589
+ return state[hostName] || [];
8590
+ };
8591
+
8592
+ var PortalHostComponent = function PortalHostComponent(_ref) {
8593
+ var name = _ref.name;
8594
+ var state = usePortalState(name);
8595
+ var _usePortal = usePortal(name),
8596
+ registerHost = _usePortal.registerHost,
8597
+ deregisterHost = _usePortal.deregisterHost;
8598
+ React.useEffect(function () {
8599
+ registerHost();
8600
+ return function () {
8601
+ deregisterHost();
8602
+ };
8603
+ }, []);
8604
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, state.map(function (item) {
8605
+ return item.node;
8606
+ }));
8607
+ };
8608
+ var PortalHost = /*#__PURE__*/React.memo(PortalHostComponent);
8609
+ PortalHost.displayName = 'PortalHost';
8610
+
8611
+ var registerHostIfNotExist = function registerHostIfNotExist(state, hostName) {
8612
+ if (!(hostName in state)) {
8613
+ return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, hostName, []));
8614
+ }
8615
+ return _objectSpread2({}, state);
8616
+ };
8617
+ var deregisterHost = function deregisterHost(state, hostName) {
8618
+ return _objectSpread2({}, omit([hostName], state));
8619
+ };
8620
+ var addUpdatePortal = function addUpdatePortal(state, hostName, portalName, node) {
8621
+ var newState = registerHostIfNotExist(state, hostName);
8622
+ var index = newState[hostName].findIndex(function (item) {
8623
+ return item.name === portalName;
8624
+ });
8625
+ if (index !== -1) {
8626
+ return _objectSpread2(_objectSpread2({}, newState), {}, _defineProperty({}, hostName, newState[hostName].map(function (item, i) {
8627
+ if (index === i) {
8628
+ return _objectSpread2(_objectSpread2({}, item), {}, {
8629
+ node: node
8630
+ });
8631
+ }
8632
+ return item;
8633
+ })));
8634
+ }
8635
+ return _objectSpread2(_objectSpread2({}, newState), {}, _defineProperty({}, hostName, [].concat(_toConsumableArray(newState[hostName]), [{
8636
+ name: portalName,
8637
+ node: node
8638
+ }])));
8639
+ };
8640
+ var removePortal = function removePortal(state, hostName, portalName) {
8641
+ if (!(hostName in state)) {
8642
+ return _objectSpread2({}, state);
8643
+ }
8644
+ return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, hostName, state[hostName].filter(function (item) {
8645
+ return item.name !== portalName;
8646
+ })));
8647
+ };
8648
+ var reducer = function reducer(state, action) {
8649
+ var type = action.type;
8650
+ switch (type) {
8651
+ case ACTIONS.REGISTER_HOST:
8652
+ return registerHostIfNotExist(state, action.hostName);
8653
+ case ACTIONS.DEREGISTER_HOST:
8654
+ return deregisterHost(state, action.hostName);
8655
+ case ACTIONS.ADD_UPDATE_PORTAL:
8656
+ return addUpdatePortal(state, action.hostName, action.portalName, action.node);
8657
+ case ACTIONS.REMOVE_PORTAL:
8658
+ return removePortal(state, action.hostName, action.portalName);
8659
+ default:
8660
+ return _objectSpread2({}, state);
8661
+ }
8662
+ };
8663
+
8664
+ var PortalProviderComponent = function PortalProviderComponent(_ref) {
8665
+ var _ref$rootHostName = _ref.rootHostName,
8666
+ rootHostName = _ref$rootHostName === void 0 ? 'root' : _ref$rootHostName,
8667
+ children = _ref.children;
8668
+ var _useReducer = React.useReducer(reducer, INITIAL_STATE),
8669
+ _useReducer2 = _slicedToArray(_useReducer, 2),
8670
+ state = _useReducer2[0],
8671
+ dispatch = _useReducer2[1];
8672
+ return /*#__PURE__*/React__default["default"].createElement(PortalDispatchContext.Provider, {
8673
+ value: dispatch
8674
+ }, /*#__PURE__*/React__default["default"].createElement(PortalStateContext.Provider, {
8675
+ value: state
8676
+ }, children, /*#__PURE__*/React__default["default"].createElement(PortalHost, {
8677
+ name: rootHostName
8678
+ })));
8679
+ };
8680
+ var PortalProvider = /*#__PURE__*/React.memo(PortalProviderComponent);
8681
+ PortalProvider.displayName = 'PortalProvider';
8682
+
8683
+ var nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789', 10);
8684
+ var PortalComponent = function PortalComponent(_ref) {
8685
+ var name = _ref.name,
8686
+ hostName = _ref.hostName,
8687
+ children = _ref.children,
8688
+ theme = _ref.theme;
8689
+ var defaultTheme = useTheme();
8690
+ var _usePortal = usePortal(hostName),
8691
+ addUpdatePortal = _usePortal.addPortal,
8692
+ removePortal = _usePortal.removePortal;
8693
+ var nameOrRandom = React.useMemo(function () {
8694
+ return name || nanoid();
8695
+ }, [name]);
8696
+ var ChildrenComponent = React.useMemo(function () {
8697
+ return /*#__PURE__*/React__default["default"].createElement(ThemeProvider, {
8698
+ theme: theme || defaultTheme
8699
+ }, children);
8700
+ }, [theme, children, defaultTheme]);
8701
+ React.useLayoutEffect(function () {
8702
+ addUpdatePortal(nameOrRandom, ChildrenComponent);
8703
+ return function () {
8704
+ removePortal(nameOrRandom);
8705
+ };
8706
+ }, [addUpdatePortal]);
8707
+ React.useLayoutEffect(function () {
8708
+ addUpdatePortal(nameOrRandom, ChildrenComponent);
8709
+ }, [ChildrenComponent]);
8710
+ return null;
8711
+ };
8712
+ var Portal = /*#__PURE__*/React.memo(PortalComponent);
8713
+ Portal.displayName = 'Portal';
8714
+ var Portal$1 = Object.assign(Portal, {
8715
+ Provider: PortalProvider,
8716
+ Host: PortalHost
8717
+ });
8718
+
8719
+ var _excluded$m = ["visible"];
8720
+ var DEFAULT_BACKDROP_OPACITY = 0.4;
8721
+ var DEFAULT_ANIMATION_CONFIG = {
8722
+ easing: reactNative.Easing.inOut(reactNative.Easing.cubic),
8723
+ useNativeDriver: reactNative.Platform.OS !== 'web',
8724
+ duration: 400
8725
+ };
8726
+ var Modal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
8727
+ var children = _ref.children,
8728
+ onShow = _ref.onShow,
8729
+ onRequestClose = _ref.onRequestClose,
8730
+ testID = _ref.testID,
8731
+ _ref$animationType = _ref.animationType,
8732
+ animationType = _ref$animationType === void 0 ? 'none' : _ref$animationType,
8733
+ _ref$transparent = _ref.transparent,
8734
+ transparent = _ref$transparent === void 0 ? false : _ref$transparent,
8735
+ onDismiss = _ref.onDismiss;
8736
+ var theme = useTheme();
8737
+ var animatedBackdropValue = React.useRef(new reactNative.Animated.Value(0)).current;
8738
+ var animatedModalValue = React.useRef(new reactNative.Animated.Value(0)).current;
8739
+ // Show or hide the backdrop and modal content
8740
+ var animateBackdropAndContent = React.useCallback(function (_ref2) {
8741
+ var toValue = _ref2.toValue,
8742
+ callback = _ref2.callback;
8743
+ if (animationType !== 'none') {
8744
+ // Backdrop animation
8745
+ if (!transparent) {
8746
+ reactNative.Animated.timing(animatedBackdropValue, _objectSpread2({
8747
+ toValue: toValue
8748
+ }, DEFAULT_ANIMATION_CONFIG)).start();
8749
+ }
8750
+ // Modal content animation
8751
+ reactNative.Animated.timing(animatedModalValue, _objectSpread2({
8752
+ toValue: toValue
8753
+ }, DEFAULT_ANIMATION_CONFIG)).start(callback);
8754
+ } else {
8755
+ callback === null || callback === void 0 ? void 0 : callback();
8756
+ }
8757
+ }, [animationType, onShow, transparent]);
8758
+ var backdropOpacityAnimation = animatedBackdropValue.interpolate({
8759
+ inputRange: [0, 1],
8760
+ outputRange: [0, DEFAULT_BACKDROP_OPACITY]
8761
+ });
8762
+ var modalAnimation = animatedModalValue.interpolate({
8763
+ inputRange: [0, 1],
8764
+ outputRange: animationType === 'slide' ? [reactNative.Dimensions.get('window').height, 0] : [0, 1]
8765
+ });
8766
+ React.useImperativeHandle(ref, function () {
8767
+ return {
8768
+ show: function show() {
8769
+ animateBackdropAndContent({
8770
+ toValue: 1,
8771
+ callback: onShow
8772
+ });
8773
+ },
8774
+ hide: function hide(wrapperCallback) {
8775
+ animateBackdropAndContent({
8776
+ toValue: 0,
8777
+ callback: function callback() {
8778
+ if (reactNative.Platform.OS === 'ios') {
8779
+ onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
8780
+ }
8781
+ wrapperCallback();
8782
+ }
8783
+ });
8784
+ }
8785
+ };
8786
+ }, [onDismiss, onShow, animateBackdropAndContent]);
8787
+ // Back button handler
8788
+ React.useEffect(function () {
8789
+ var backHandler = reactNative.BackHandler.addEventListener('hardwareBackPress', function () {
8790
+ onRequestClose === null || onRequestClose === void 0 ? void 0 : onRequestClose();
8791
+ return true;
8792
+ });
8793
+ return function () {
8794
+ return backHandler.remove();
8795
+ };
8796
+ }, [onRequestClose]);
8797
+ return /*#__PURE__*/React__default["default"].createElement(Portal$1, null, /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
8798
+ style: _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
8799
+ backgroundColor: transparent ? 'transparent' : theme.colors.overlayGlobalSurface,
8800
+ opacity: animationType !== 'none' ? backdropOpacityAnimation : DEFAULT_BACKDROP_OPACITY
8801
+ })
8802
+ }), /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
8803
+ testID: testID,
8804
+ style: _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
8805
+ opacity: animationType === 'fade' ? modalAnimation : 1,
8806
+ transform: [{
8807
+ translateY: animationType === 'slide' ? modalAnimation : 0
8808
+ }]
8809
+ })
8810
+ }, children));
8811
+ });
8812
+ var ModalWrapper = function ModalWrapper(_ref3) {
8813
+ var _ref3$visible = _ref3.visible,
8814
+ visible = _ref3$visible === void 0 ? true : _ref3$visible,
8815
+ props = _objectWithoutProperties(_ref3, _excluded$m);
8816
+ var modalRef = React.useRef(null);
8817
+ var _useState = React.useState(visible),
8818
+ _useState2 = _slicedToArray(_useState, 2),
8819
+ internalVisible = _useState2[0],
8820
+ setInternalVisible = _useState2[1];
8821
+ React.useEffect(function () {
8822
+ if (visible) {
8823
+ setInternalVisible(true);
8824
+ } else {
8825
+ var _modalRef$current;
8826
+ // Wait for animation to finish before hiding the modal
8827
+ (_modalRef$current = modalRef.current) === null || _modalRef$current === void 0 ? void 0 : _modalRef$current.hide(function () {
8828
+ return setInternalVisible(false);
8829
+ });
8830
+ }
8831
+ }, [visible]);
8832
+ React.useEffect(function () {
8833
+ if (internalVisible) {
8834
+ var _modalRef$current2;
8835
+ (_modalRef$current2 = modalRef.current) === null || _modalRef$current2 === void 0 ? void 0 : _modalRef$current2.show();
8836
+ }
8837
+ }, [internalVisible]);
8838
+ return internalVisible ? /*#__PURE__*/React__default["default"].createElement(Modal, _extends$1({
8839
+ ref: modalRef
8840
+ }, props)) : null;
8841
+ };
8842
+
8517
8843
  var BottomSheet = function BottomSheet(_ref) {
8518
8844
  var open = _ref.open,
8519
8845
  header = _ref.header,
@@ -8590,7 +8916,7 @@ var BottomSheet = function BottomSheet(_ref) {
8590
8916
  setInternalShowDivider: setInternalShowDivider
8591
8917
  };
8592
8918
  }, [setInternalShowDivider]);
8593
- return /*#__PURE__*/React__default["default"].createElement(reactNative.Modal, {
8919
+ return /*#__PURE__*/React__default["default"].createElement(ModalWrapper, {
8594
8920
  visible: visible,
8595
8921
  onRequestClose: onRequestClose,
8596
8922
  transparent: true,
@@ -8803,7 +9129,7 @@ var borderWidths = {
8803
9129
  var config = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, colors), space), radii), borderWidths);
8804
9130
  var flexPropsKey = ['alignContent', 'alignItems', 'alignSelf', 'display', 'flex', 'flexBasis', 'flexDirection', 'flexGrow', 'flexShrink', 'flexWrap', 'justifyContent'];
8805
9131
 
8806
- var _excluded$m = ["theme"];
9132
+ var _excluded$l = ["theme"];
8807
9133
  var getThemeValue = function getThemeValue(theme, key, props) {
8808
9134
  var propConfig = config[key];
8809
9135
  var propValue = props[key];
@@ -8830,18 +9156,18 @@ var mapStylePropToThemeValue = function mapStylePropToThemeValue(theme, props) {
8830
9156
  var configKeys = Object.keys(config);
8831
9157
  var StyledBox = index$a(reactNative.View)(function (_ref5) {
8832
9158
  var theme = _ref5.theme,
8833
- otherProps = _objectWithoutProperties(_ref5, _excluded$m);
9159
+ otherProps = _objectWithoutProperties(_ref5, _excluded$l);
8834
9160
  var styleProps = pick(configKeys, otherProps);
8835
9161
  var flexProps = pick(_toConsumableArray(flexPropsKey), otherProps);
8836
9162
  return _objectSpread2(_objectSpread2({}, mapStylePropToThemeValue(theme, styleProps)), flexProps);
8837
9163
  });
8838
9164
 
8839
- var _excluded$l = ["children", "style", "testID"];
9165
+ var _excluded$k = ["children", "style", "testID"];
8840
9166
  var Box = function Box(_ref) {
8841
9167
  var children = _ref.children,
8842
9168
  style = _ref.style,
8843
9169
  testID = _ref.testID,
8844
- otherProps = _objectWithoutProperties(_ref, _excluded$l);
9170
+ otherProps = _objectWithoutProperties(_ref, _excluded$k);
8845
9171
  return /*#__PURE__*/React__default["default"].createElement(StyledBox, _extends$1({}, otherProps, {
8846
9172
  style: style,
8847
9173
  testID: testID
@@ -11481,7 +11807,7 @@ var Calendar = function Calendar(_ref) {
11481
11807
  })));
11482
11808
  };
11483
11809
 
11484
- var _excluded$k = ["rounded", "size", "testID", "style"];
11810
+ var _excluded$j = ["rounded", "size", "testID", "style"];
11485
11811
  var Image = function Image(_ref) {
11486
11812
  var _ref$rounded = _ref.rounded,
11487
11813
  rounded = _ref$rounded === void 0 ? false : _ref$rounded,
@@ -11489,7 +11815,7 @@ var Image = function Image(_ref) {
11489
11815
  size = _ref$size === void 0 ? '6xlarge' : _ref$size,
11490
11816
  testID = _ref.testID,
11491
11817
  style = _ref.style,
11492
- imageNativeProps = _objectWithoutProperties(_ref, _excluded$k);
11818
+ imageNativeProps = _objectWithoutProperties(_ref, _excluded$j);
11493
11819
  var theme = useTheme();
11494
11820
  var imageSize = theme.__hd__.image.sizes[size];
11495
11821
  return /*#__PURE__*/React__default["default"].createElement(reactNative.Image, _extends$1({
@@ -11694,12 +12020,12 @@ var Indicator = index$a(reactNative.View)(function (_ref2) {
11694
12020
  };
11695
12021
  });
11696
12022
 
11697
- var _excluded$j = ["intent", "children"];
12023
+ var _excluded$i = ["intent", "children"];
11698
12024
  var DataCard = function DataCard(_ref) {
11699
12025
  var _ref$intent = _ref.intent,
11700
12026
  intent = _ref$intent === void 0 ? 'info' : _ref$intent,
11701
12027
  children = _ref.children,
11702
- nativeProps = _objectWithoutProperties(_ref, _excluded$j);
12028
+ nativeProps = _objectWithoutProperties(_ref, _excluded$i);
11703
12029
  return /*#__PURE__*/React__default["default"].createElement(StyledDataCard, nativeProps, /*#__PURE__*/React__default["default"].createElement(Indicator, {
11704
12030
  themeIntent: intent,
11705
12031
  testID: "data-card-indicator"
@@ -11717,11 +12043,11 @@ var StyledCard$1 = index$a(reactNative.View)(function (_ref) {
11717
12043
  });
11718
12044
  });
11719
12045
 
11720
- var _excluded$i = ["intent", "children"];
12046
+ var _excluded$h = ["intent", "children"];
11721
12047
  var Card = function Card(_ref) {
11722
12048
  var intent = _ref.intent,
11723
12049
  children = _ref.children,
11724
- nativeProps = _objectWithoutProperties(_ref, _excluded$i);
12050
+ nativeProps = _objectWithoutProperties(_ref, _excluded$h);
11725
12051
  return /*#__PURE__*/React__default["default"].createElement(StyledCard$1, _extends$1({}, nativeProps, {
11726
12052
  themeIntent: intent
11727
12053
  }), children);
@@ -11928,7 +12254,7 @@ var CardCarousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
11928
12254
  });
11929
12255
  CardCarousel.displayName = 'CardCarousel';
11930
12256
 
11931
- var _excluded$h = ["items", "onItemIndexChange", "renderActions", "selectedItemIndex", "style", "shouldShowPagination", "testID", "pageControlPosition"];
12257
+ var _excluded$g = ["items", "onItemIndexChange", "renderActions", "selectedItemIndex", "style", "shouldShowPagination", "testID", "pageControlPosition"];
11932
12258
  function useStateFromProp(initialValue) {
11933
12259
  var _useState = React.useState(initialValue),
11934
12260
  _useState2 = _slicedToArray(_useState, 2),
@@ -11954,7 +12280,7 @@ var Carousel = function Carousel(_ref) {
11954
12280
  testID = _ref.testID,
11955
12281
  _ref$pageControlPosit = _ref.pageControlPosition,
11956
12282
  pageControlPosition = _ref$pageControlPosit === void 0 ? 'top' : _ref$pageControlPosit,
11957
- nativeProps = _objectWithoutProperties(_ref, _excluded$h);
12283
+ nativeProps = _objectWithoutProperties(_ref, _excluded$g);
11958
12284
  useDeprecation("shouldShowPagination prop has been deprecated", shouldShowPagination !== noop);
11959
12285
  useDeprecation("The use of 'pageControlPosition == bottom' has been deprecated", pageControlPosition === 'bottom');
11960
12286
  var carouselRef = React.useRef(null);
@@ -12291,7 +12617,7 @@ var StyledErrorAndMaxLengthContainer = index$a(reactNative.View)(function () {
12291
12617
  };
12292
12618
  });
12293
12619
 
12294
- var _excluded$g = ["label", "prefix", "suffix", "style", "textStyle", "testID", "accessibilityLabelledBy", "error", "required", "editable", "disabled", "loading", "maxLength", "hideCharacterCount", "helpText", "value", "defaultValue", "renderInputValue", "allowFontScaling", "variant"];
12620
+ var _excluded$f = ["label", "prefix", "suffix", "style", "textStyle", "testID", "accessibilityLabelledBy", "error", "required", "editable", "disabled", "loading", "maxLength", "hideCharacterCount", "helpText", "value", "defaultValue", "renderInputValue", "allowFontScaling", "variant"];
12295
12621
  var getState$1 = function getState(_ref) {
12296
12622
  var disabled = _ref.disabled,
12297
12623
  error = _ref.error,
@@ -12343,7 +12669,7 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
12343
12669
  allowFontScaling = _ref2$allowFontScalin === void 0 ? false : _ref2$allowFontScalin,
12344
12670
  _ref2$variant = _ref2.variant,
12345
12671
  variant = _ref2$variant === void 0 ? 'text' : _ref2$variant,
12346
- nativeProps = _objectWithoutProperties(_ref2, _excluded$g);
12672
+ nativeProps = _objectWithoutProperties(_ref2, _excluded$f);
12347
12673
  var displayText = (_ref3 = value !== undefined ? value : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : '';
12348
12674
  var isEmptyValue = displayText.length === 0;
12349
12675
  var actualSuffix = loading ? 'loading' : suffix;
@@ -12764,719 +13090,393 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
12764
13090
  style: style
12765
13091
  })), /*#__PURE__*/React__default["default"].createElement(BottomSheet$1, {
12766
13092
  open: open,
12767
- onRequestClose: function onRequestClose() {
12768
- return setOpen(false);
12769
- },
12770
- header: label,
12771
- footer: /*#__PURE__*/React__default["default"].createElement(CompoundButton, {
12772
- variant: "text",
12773
- text: confirmLabel,
12774
- onPress: function onPress() {
12775
- if (selectingDate) {
12776
- onChange(selectingDate);
12777
- }
12778
- setOpen(false);
12779
- }
12780
- })
12781
- }, /*#__PURE__*/React__default["default"].createElement(StyledPickerWrapper$1, null, /*#__PURE__*/React__default["default"].createElement(DateTimePicker__default["default"], {
12782
- testID: "datePickerIOS",
12783
- value: selectingDate,
12784
- minimumDate: minDate,
12785
- maximumDate: maxDate,
12786
- mode: "date",
12787
- onChange: function onChange(_, date) {
12788
- if (date) {
12789
- setSelectingDate(date);
12790
- }
12791
- },
12792
- display: "spinner",
12793
- style: {
12794
- flex: 1
12795
- },
12796
- textColor: theme.colors.onDefaultGlobalSurface
12797
- }))));
12798
- };
12799
-
12800
- var _excluded$f = ["variant"];
12801
- var DatePicker = function DatePicker(_ref) {
12802
- var _ref$variant = _ref.variant,
12803
- variant = _ref$variant === void 0 ? 'default' : _ref$variant,
12804
- props = _objectWithoutProperties(_ref, _excluded$f);
12805
- if (variant === 'calendar') {
12806
- return /*#__PURE__*/React__default["default"].createElement(DatePickerCalendar, props);
12807
- }
12808
- if (reactNative.Platform.OS === 'ios') {
12809
- return /*#__PURE__*/React__default["default"].createElement(DatePickerIOS, props);
12810
- }
12811
- return /*#__PURE__*/React__default["default"].createElement(DatePickerAndroid, props);
12812
- };
12813
-
12814
- var AnimatedPressable$1 = reactNative.Animated.createAnimatedComponent(reactNative.Pressable);
12815
- var StyledContainer$3 = index$a(reactNative.View)(function (_ref) {
12816
- var theme = _ref.theme,
12817
- enableShadow = _ref.enableShadow;
12818
- return _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
12819
- shadowColor: enableShadow ? theme.__hd__.drawer.colors.shadow : 'transparent',
12820
- shadowOffset: theme.__hd__.drawer.shadows.offset,
12821
- shadowOpacity: theme.__hd__.drawer.shadows.opacity,
12822
- shadowRadius: theme.__hd__.drawer.shadows.radius,
12823
- overflow: 'hidden',
12824
- zIndex: 9999,
12825
- elevation: 9999
12826
- });
12827
- });
12828
- var StyledDragableContainer = index$a(reactNative.View)(function (_ref2) {
12829
- var theme = _ref2.theme,
12830
- enableShadow = _ref2.enableShadow;
12831
- return _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
12832
- shadowColor: enableShadow ? theme.__hd__.drawer.colors.shadow : 'transparent',
12833
- shadowOffset: theme.__hd__.drawer.shadows.offset,
12834
- shadowOpacity: theme.__hd__.drawer.shadows.opacity,
12835
- shadowRadius: theme.__hd__.drawer.shadows.radius,
12836
- overflow: 'hidden',
12837
- zIndex: 9999,
12838
- elevation: 9999,
12839
- flexDirection: 'column-reverse'
12840
- });
12841
- });
12842
- var StyledBackdrop$1 = index$a(AnimatedPressable$1)(function (_ref3) {
12843
- var theme = _ref3.theme;
12844
- return _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
12845
- backgroundColor: theme.__hd__.drawer.colors.backdrop
12846
- });
12847
- });
12848
- var StyledDrawerContainer = index$a(reactNative.Animated.View)(function (_ref4) {
12849
- var theme = _ref4.theme,
12850
- enableShadow = _ref4.enableShadow;
12851
- return {
12852
- borderBottomLeftRadius: theme.__hd__.drawer.radii["default"],
12853
- borderBottomRightRadius: theme.__hd__.drawer.radii["default"],
12854
- backgroundColor: theme.__hd__.drawer.colors.background,
12855
- elevation: enableShadow ? theme.__hd__.drawer.shadows.elevation : undefined,
12856
- overflow: 'hidden'
12857
- };
12858
- });
12859
- var StyledDragableDrawerContainer = index$a(reactNative.Animated.View)(function (_ref5) {
12860
- var theme = _ref5.theme,
12861
- enableShadow = _ref5.enableShadow;
12862
- return {
12863
- borderTopLeftRadius: theme.__hd__.drawer.radii["default"],
12864
- borderTopRightRadius: theme.__hd__.drawer.radii["default"],
12865
- backgroundColor: theme.__hd__.drawer.colors.background,
12866
- elevation: enableShadow ? theme.__hd__.drawer.shadows.elevation : undefined,
12867
- overflow: 'hidden',
12868
- maxHeight: '100%'
12869
- };
12870
- });
12871
- var StyledHandlerContainer = index$a(reactNative.View)(function (_ref6) {
12872
- var theme = _ref6.theme;
12873
- return {
12874
- backgroundColor: theme.__hd__.drawer.colors.background,
12875
- paddingVertical: theme.__hd__.drawer.space.handlerPaddingVertical,
12876
- alignItems: 'center'
12877
- };
12878
- });
12879
- var StyledHandler = index$a(reactNative.View)(function (_ref7) {
12880
- var theme = _ref7.theme;
12881
- return {
12882
- width: theme.__hd__.drawer.sizes.handlerWidth,
12883
- height: theme.__hd__.drawer.sizes.handlerHeight,
12884
- backgroundColor: theme.__hd__.drawer.colors.handler,
12885
- borderRadius: theme.__hd__.drawer.radii.handler
12886
- };
12887
- });
12888
-
12889
- var getOffset = function getOffset(height, percentage) {
12890
- if (percentage < 0) return height;
12891
- if (percentage > 100) return 0;
12892
- return height * ((100 - percentage) / 100);
12893
- };
12894
- var calculateSnapPointsData = function calculateSnapPointsData(minimumHeight, height, snapPoints) {
12895
- var filteredSnapPoints = snapPoints.filter(function (value) {
12896
- return value >= minimumHeight;
12897
- });
12898
- var snapPointsOffsetValues = [minimumHeight].concat(_toConsumableArray(filteredSnapPoints)).map(function (value) {
12899
- return getOffset(height, value);
12900
- });
12901
- var uniqSnapPointOffsetValues = Array.from(new Set([].concat(_toConsumableArray(snapPointsOffsetValues), [0])));
12902
- return {
12903
- list: uniqSnapPointOffsetValues,
12904
- minHeightOffset: Math.max.apply(Math, uniqSnapPointOffsetValues),
12905
- maxHeightOffset: 0 // Max height
12906
- };
12907
- };
12908
-
12909
- var calculateAnimatedToValue = function calculateAnimatedToValue(position, heightSnapPoints) {
12910
- var distances = heightSnapPoints.map(function (height) {
12911
- return Math.abs(position - height);
12912
- });
12913
- var minIndex = distances.indexOf(Math.min.apply(Math, _toConsumableArray(distances)));
12914
- return heightSnapPoints[minIndex];
12915
- };
12916
-
12917
- var DragableDrawer = function DragableDrawer(_ref) {
12918
- var children = _ref.children,
12919
- initialHeightPercentage = _ref.initialHeightPercentage,
12920
- _ref$minimumHeightPer = _ref.minimumHeightPercentage,
12921
- minimumHeightPercentage = _ref$minimumHeightPer === void 0 ? 10 : _ref$minimumHeightPer,
12922
- _ref$snapPoints = _ref.snapPoints,
12923
- snapPoints = _ref$snapPoints === void 0 ? [] : _ref$snapPoints,
12924
- onExpanded = _ref.onExpanded,
12925
- onCollapsed = _ref.onCollapsed,
12926
- testID = _ref.testID;
12927
- var _useState = React.useState(0),
12928
- _useState2 = _slicedToArray(_useState, 2),
12929
- height = _useState2[0],
12930
- setHeight = _useState2[1];
12931
- var baseHeightForMeasure = React.useRef(0);
12932
- var snapPointsData = React.useRef({
12933
- list: [],
12934
- minHeightOffset: 0,
12935
- maxHeightOffset: 0
12936
- });
12937
- // Track drag
12938
- var pan = React.useRef(new reactNative.Animated.Value(0)).current;
12939
- var offset = React.useRef(0);
12940
- var offsetBeforePan = React.useRef(0);
12941
- var _useState3 = React.useState(-1),
12942
- _useState4 = _slicedToArray(_useState3, 2),
12943
- animatedToValue = _useState4[0],
12944
- setAnimatedToValue = _useState4[1];
12945
- React.useEffect(function () {
12946
- var id = pan.addListener(function (_ref2) {
12947
- var value = _ref2.value;
12948
- offset.current = value;
12949
- });
12950
- return function () {
12951
- return pan.removeListener(id);
12952
- };
12953
- }, []);
12954
- React.useEffect(function () {
12955
- if (height > 0) {
12956
- var initialOffset = getOffset(height, initialHeightPercentage || minimumHeightPercentage);
12957
- setAnimatedToValue(initialOffset);
12958
- }
12959
- }, [height]);
12960
- React.useEffect(function () {
12961
- if (height > 0) {
12962
- pan.setValue(height);
12963
- offset.current = height;
12964
- baseHeightForMeasure.current = height;
12965
- // Calculate snap points information
12966
- snapPointsData.current = calculateSnapPointsData(minimumHeightPercentage, height, snapPoints);
12967
- }
12968
- }, [height, minimumHeightPercentage]);
12969
- React.useEffect(function () {
12970
- if (animatedToValue >= 0) {
12971
- var animation = reactNative.Animated.timing(pan, {
12972
- toValue: animatedToValue,
12973
- useNativeDriver: true,
12974
- easing: reactNative.Easing.inOut(reactNative.Easing.cubic)
12975
- });
12976
- animation.start(function () {
12977
- if (animatedToValue === 0) {
12978
- onExpanded === null || onExpanded === void 0 ? void 0 : onExpanded();
12979
- } else if (animatedToValue === getOffset(height, minimumHeightPercentage)) {
12980
- onCollapsed === null || onCollapsed === void 0 ? void 0 : onCollapsed();
12981
- }
12982
- setAnimatedToValue(-1);
12983
- });
12984
- return function () {
12985
- return animation.stop();
12986
- };
12987
- }
12988
- }, [animatedToValue]);
12989
- var panResponder = React.useRef(reactNative.PanResponder.create({
12990
- onMoveShouldSetPanResponder: function onMoveShouldSetPanResponder() {
12991
- return true;
12992
- },
12993
- onPanResponderGrant: function onPanResponderGrant() {
12994
- offsetBeforePan.current = offset.current;
12995
- pan.setOffset(offset.current);
12996
- pan.setValue(0);
12997
- },
12998
- onPanResponderMove: function onPanResponderMove(_, gesture) {
12999
- var _snapPointsData$curre;
13000
- var panDistance = gesture.dy;
13001
- // Moving toward top, stop at highest snap point
13002
- if (offsetBeforePan.current + panDistance < 0) {
13003
- pan.setValue(-offsetBeforePan.current);
13004
- return;
13093
+ onRequestClose: function onRequestClose() {
13094
+ return setOpen(false);
13095
+ },
13096
+ header: label,
13097
+ footer: /*#__PURE__*/React__default["default"].createElement(CompoundButton, {
13098
+ variant: "text",
13099
+ text: confirmLabel,
13100
+ onPress: function onPress() {
13101
+ if (selectingDate) {
13102
+ onChange(selectingDate);
13103
+ }
13104
+ setOpen(false);
13005
13105
  }
13006
- // Moving toward bottom, stop at lowest snap point
13007
- if (offsetBeforePan.current + panDistance > ((_snapPointsData$curre = snapPointsData.current) === null || _snapPointsData$curre === void 0 ? void 0 : _snapPointsData$curre.minHeightOffset)) {
13008
- pan.setValue(baseHeightForMeasure.current - baseHeightForMeasure.current * (minimumHeightPercentage / 100) - offsetBeforePan.current);
13009
- return;
13106
+ })
13107
+ }, /*#__PURE__*/React__default["default"].createElement(StyledPickerWrapper$1, null, /*#__PURE__*/React__default["default"].createElement(DateTimePicker__default["default"], {
13108
+ testID: "datePickerIOS",
13109
+ value: selectingDate,
13110
+ minimumDate: minDate,
13111
+ maximumDate: maxDate,
13112
+ mode: "date",
13113
+ onChange: function onChange(_, date) {
13114
+ if (date) {
13115
+ setSelectingDate(date);
13010
13116
  }
13011
- pan.setValue(panDistance);
13012
13117
  },
13013
- onPanResponderRelease: function onPanResponderRelease(_, gesture) {
13014
- pan.flattenOffset();
13015
- // Attach to nearest snappoint
13016
- var panDistance = gesture.dy;
13017
- var offsetAfterPan = offsetBeforePan.current + panDistance;
13018
- var animatedValue = calculateAnimatedToValue(offsetAfterPan, snapPointsData.current.list);
13019
- setAnimatedToValue(animatedValue);
13020
- }
13021
- })).current;
13022
- return /*#__PURE__*/React__default["default"].createElement(StyledDragableContainer, {
13023
- testID: testID,
13024
- enableShadow: true,
13025
- pointerEvents: "box-none"
13026
- }, /*#__PURE__*/React__default["default"].createElement(StyledDragableDrawerContainer, {
13027
- enableShadow: true,
13118
+ display: "spinner",
13028
13119
  style: {
13029
- transform: [{
13030
- scaleY: baseHeightForMeasure.current > 0 ? 1 : 0
13031
- }, {
13032
- translateY: pan
13033
- }]
13120
+ flex: 1
13034
13121
  },
13035
- onLayout: function onLayout(_ref3) {
13036
- var nativeEvent = _ref3.nativeEvent;
13037
- setHeight(nativeEvent.layout.height);
13038
- }
13039
- }, /*#__PURE__*/React__default["default"].createElement(StyledHandlerContainer, panResponder.panHandlers, /*#__PURE__*/React__default["default"].createElement(StyledHandler, null)), children));
13122
+ textColor: theme.colors.onDefaultGlobalSurface
13123
+ }))));
13040
13124
  };
13041
13125
 
13042
- var Drawer = function Drawer(_ref) {
13043
- var visible = _ref.visible,
13044
- children = _ref.children,
13045
- _ref$hasBackdrop = _ref.hasBackdrop,
13046
- hasBackdrop = _ref$hasBackdrop === void 0 ? true : _ref$hasBackdrop,
13047
- onDismiss = _ref.onDismiss,
13048
- testID = _ref.testID;
13049
- var animatedValue = React.useRef(new reactNative.Animated.Value(visible ? 1 : 0)).current;
13050
- var _useState = React.useState(reactNative.Dimensions.get('window').height),
13051
- _useState2 = _slicedToArray(_useState, 2),
13052
- height = _useState2[0],
13053
- setHeight = _useState2[1];
13054
- var enableShadow = visible && !hasBackdrop;
13055
- var interpolateTranslateY = animatedValue.interpolate({
13056
- inputRange: [0, 1],
13057
- outputRange: [-height, 0]
13058
- });
13059
- var interpolateBackdropOpacity = hasBackdrop ? animatedValue.interpolate({
13060
- inputRange: [0, 1],
13061
- outputRange: [0, 0.35]
13062
- }) : 0;
13063
- React.useEffect(function () {
13064
- var animation = reactNative.Animated.timing(animatedValue, {
13065
- toValue: visible ? 1 : 0,
13066
- easing: reactNative.Easing.inOut(reactNative.Easing.cubic),
13067
- useNativeDriver: true
13068
- });
13069
- animation.start();
13070
- return function () {
13071
- return animation.stop();
13072
- };
13073
- }, [visible]);
13074
- return /*#__PURE__*/React__default["default"].createElement(StyledContainer$3, {
13075
- testID: testID,
13076
- enableShadow: enableShadow,
13077
- pointerEvents: "box-none"
13078
- }, /*#__PURE__*/React__default["default"].createElement(StyledBackdrop$1, {
13079
- pointerEvents: visible ? 'auto' : 'box-none',
13080
- onPress: onDismiss,
13081
- style: {
13082
- opacity: interpolateBackdropOpacity
13083
- }
13084
- }), /*#__PURE__*/React__default["default"].createElement(StyledDrawerContainer, {
13085
- enableShadow: enableShadow,
13086
- onLayout: function onLayout(_ref2) {
13087
- var nativeEvent = _ref2.nativeEvent;
13088
- return setHeight(nativeEvent.layout.height);
13089
- },
13090
- style: {
13091
- transform: [{
13092
- translateY: interpolateTranslateY
13093
- }]
13094
- }
13095
- }, children));
13126
+ var _excluded$e = ["variant"];
13127
+ var DatePicker = function DatePicker(_ref) {
13128
+ var _ref$variant = _ref.variant,
13129
+ variant = _ref$variant === void 0 ? 'default' : _ref$variant,
13130
+ props = _objectWithoutProperties(_ref, _excluded$e);
13131
+ if (variant === 'calendar') {
13132
+ return /*#__PURE__*/React__default["default"].createElement(DatePickerCalendar, props);
13133
+ }
13134
+ if (reactNative.Platform.OS === 'ios') {
13135
+ return /*#__PURE__*/React__default["default"].createElement(DatePickerIOS, props);
13136
+ }
13137
+ return /*#__PURE__*/React__default["default"].createElement(DatePickerAndroid, props);
13096
13138
  };
13097
- var index$7 = Object.assign(Drawer, {
13098
- Dragable: DragableDrawer
13099
- });
13100
13139
 
13101
- var StyledWrapper$6 = index$a(reactNative.View)(function (_ref) {
13102
- var theme = _ref.theme;
13103
- return {
13104
- display: 'flex',
13105
- flex: 1,
13106
- flexDirection: 'column',
13107
- alignItems: 'center',
13108
- justifyContent: 'center',
13109
- padding: theme.__hd__.empty.space.wrapperPadding
13110
- };
13140
+ var AnimatedPressable$1 = reactNative.Animated.createAnimatedComponent(reactNative.Pressable);
13141
+ var StyledContainer$3 = index$a(reactNative.View)(function (_ref) {
13142
+ var theme = _ref.theme,
13143
+ enableShadow = _ref.enableShadow;
13144
+ return _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
13145
+ shadowColor: enableShadow ? theme.__hd__.drawer.colors.shadow : 'transparent',
13146
+ shadowOffset: theme.__hd__.drawer.shadows.offset,
13147
+ shadowOpacity: theme.__hd__.drawer.shadows.opacity,
13148
+ shadowRadius: theme.__hd__.drawer.shadows.radius,
13149
+ overflow: 'hidden',
13150
+ zIndex: 9999,
13151
+ elevation: 9999
13152
+ });
13111
13153
  });
13112
- var StyledTitle = index$a(Typography.Title)(function (_ref2) {
13154
+ var StyledDragableContainer = index$a(reactNative.View)(function (_ref2) {
13113
13155
  var theme = _ref2.theme,
13114
- themeVariant = _ref2.themeVariant;
13156
+ enableShadow = _ref2.enableShadow;
13157
+ return _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
13158
+ shadowColor: enableShadow ? theme.__hd__.drawer.colors.shadow : 'transparent',
13159
+ shadowOffset: theme.__hd__.drawer.shadows.offset,
13160
+ shadowOpacity: theme.__hd__.drawer.shadows.opacity,
13161
+ shadowRadius: theme.__hd__.drawer.shadows.radius,
13162
+ overflow: 'hidden',
13163
+ zIndex: 9999,
13164
+ elevation: 9999,
13165
+ flexDirection: 'column-reverse'
13166
+ });
13167
+ });
13168
+ var StyledBackdrop$1 = index$a(AnimatedPressable$1)(function (_ref3) {
13169
+ var theme = _ref3.theme;
13170
+ return _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
13171
+ backgroundColor: theme.__hd__.drawer.colors.backdrop
13172
+ });
13173
+ });
13174
+ var StyledDrawerContainer = index$a(reactNative.Animated.View)(function (_ref4) {
13175
+ var theme = _ref4.theme,
13176
+ enableShadow = _ref4.enableShadow;
13115
13177
  return {
13116
- textAlign: 'center',
13117
- marginBottom: theme.__hd__.empty.space.titleMargin,
13118
- color: themeVariant === 'dark' ? theme.__hd__.empty.colors.invertedText : theme.__hd__.empty.colors.text
13178
+ borderBottomLeftRadius: theme.__hd__.drawer.radii["default"],
13179
+ borderBottomRightRadius: theme.__hd__.drawer.radii["default"],
13180
+ backgroundColor: theme.__hd__.drawer.colors.background,
13181
+ elevation: enableShadow ? theme.__hd__.drawer.shadows.elevation : undefined,
13182
+ overflow: 'hidden'
13119
13183
  };
13120
13184
  });
13121
- var StyledDescription = index$a(Typography.Body)(function (_ref3) {
13122
- var theme = _ref3.theme,
13123
- themeVariant = _ref3.themeVariant;
13185
+ var StyledDragableDrawerContainer = index$a(reactNative.Animated.View)(function (_ref5) {
13186
+ var theme = _ref5.theme,
13187
+ enableShadow = _ref5.enableShadow;
13124
13188
  return {
13125
- textAlign: 'center',
13126
- color: themeVariant === 'dark' ? theme.__hd__.empty.colors.invertedSubduedText : theme.__hd__.empty.colors.subduedText
13189
+ borderTopLeftRadius: theme.__hd__.drawer.radii["default"],
13190
+ borderTopRightRadius: theme.__hd__.drawer.radii["default"],
13191
+ backgroundColor: theme.__hd__.drawer.colors.background,
13192
+ elevation: enableShadow ? theme.__hd__.drawer.shadows.elevation : undefined,
13193
+ overflow: 'hidden',
13194
+ maxHeight: '100%'
13127
13195
  };
13128
13196
  });
13129
-
13130
- var Empty = function Empty(_ref) {
13131
- var image = _ref.image,
13132
- title = _ref.title,
13133
- description = _ref.description,
13134
- style = _ref.style,
13135
- testID = _ref.testID,
13136
- _ref$variant = _ref.variant,
13137
- variant = _ref$variant === void 0 ? 'light' : _ref$variant;
13138
- var theme = useTheme();
13139
- return /*#__PURE__*/React__default["default"].createElement(StyledWrapper$6, {
13140
- style: style,
13141
- testID: testID
13142
- }, image !== undefined && /*#__PURE__*/React__default["default"].cloneElement(image, _objectSpread2(_objectSpread2({}, image.props), {}, {
13143
- style: [{
13144
- marginBottom: theme.__hd__.empty.space.imageMargin
13145
- }, image.props.style]
13146
- })), /*#__PURE__*/React__default["default"].createElement(StyledTitle, {
13147
- themeVariant: variant,
13148
- level: "h4",
13149
- typeface: "playful"
13150
- }, title), !!description && /*#__PURE__*/React__default["default"].createElement(StyledDescription, {
13151
- themeVariant: variant,
13152
- typeface: "playful"
13153
- }, description));
13154
- };
13155
-
13156
- var customAlphabet = function customAlphabet(alphabet) {
13157
- var defaultSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 21;
13158
- return function () {
13159
- var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultSize;
13160
- var id = '';
13161
- var i = size;
13162
- while (i--) {
13163
- id += alphabet[Math.random() * alphabet.length | 0];
13164
- }
13165
- return id;
13197
+ var StyledHandlerContainer = index$a(reactNative.View)(function (_ref6) {
13198
+ var theme = _ref6.theme;
13199
+ return {
13200
+ backgroundColor: theme.__hd__.drawer.colors.background,
13201
+ paddingVertical: theme.__hd__.drawer.space.handlerPaddingVertical,
13202
+ alignItems: 'center'
13166
13203
  };
13167
- };
13168
-
13169
- var ACTIONS;
13170
- (function (ACTIONS) {
13171
- ACTIONS[ACTIONS["REGISTER_HOST"] = 0] = "REGISTER_HOST";
13172
- ACTIONS[ACTIONS["DEREGISTER_HOST"] = 1] = "DEREGISTER_HOST";
13173
- ACTIONS[ACTIONS["ADD_UPDATE_PORTAL"] = 2] = "ADD_UPDATE_PORTAL";
13174
- ACTIONS[ACTIONS["REMOVE_PORTAL"] = 3] = "REMOVE_PORTAL";
13175
- })(ACTIONS || (ACTIONS = {}));
13176
- var INITIAL_STATE = {};
13177
-
13178
- var PortalStateContext = /*#__PURE__*/React.createContext(null);
13179
- var PortalDispatchContext = /*#__PURE__*/React.createContext(null);
13204
+ });
13205
+ var StyledHandler = index$a(reactNative.View)(function (_ref7) {
13206
+ var theme = _ref7.theme;
13207
+ return {
13208
+ width: theme.__hd__.drawer.sizes.handlerWidth,
13209
+ height: theme.__hd__.drawer.sizes.handlerHeight,
13210
+ backgroundColor: theme.__hd__.drawer.colors.handler,
13211
+ borderRadius: theme.__hd__.drawer.radii.handler
13212
+ };
13213
+ });
13180
13214
 
13181
- var usePortal = function usePortal() {
13182
- var hostName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'root';
13183
- var dispatch = React.useContext(PortalDispatchContext);
13184
- if (dispatch === null) {
13185
- throw new Error("You must add 'PortalProvider' to the root component.");
13186
- }
13187
- var registerHost = React.useCallback(function () {
13188
- dispatch({
13189
- type: ACTIONS.REGISTER_HOST,
13190
- hostName: hostName
13191
- });
13192
- }, []);
13193
- var deregisterHost = React.useCallback(function () {
13194
- dispatch({
13195
- type: ACTIONS.DEREGISTER_HOST,
13196
- hostName: hostName
13197
- });
13198
- }, []);
13199
- var addUpdatePortal = React.useCallback(function (name, node) {
13200
- dispatch({
13201
- type: ACTIONS.ADD_UPDATE_PORTAL,
13202
- hostName: hostName,
13203
- portalName: name,
13204
- node: node
13205
- });
13206
- }, []);
13207
- var removePortal = React.useCallback(function (name) {
13208
- dispatch({
13209
- type: ACTIONS.REMOVE_PORTAL,
13210
- hostName: hostName,
13211
- portalName: name
13212
- });
13213
- }, []);
13215
+ var getOffset = function getOffset(height, percentage) {
13216
+ if (percentage < 0) return height;
13217
+ if (percentage > 100) return 0;
13218
+ return height * ((100 - percentage) / 100);
13219
+ };
13220
+ var calculateSnapPointsData = function calculateSnapPointsData(minimumHeight, height, snapPoints) {
13221
+ var filteredSnapPoints = snapPoints.filter(function (value) {
13222
+ return value >= minimumHeight;
13223
+ });
13224
+ var snapPointsOffsetValues = [minimumHeight].concat(_toConsumableArray(filteredSnapPoints)).map(function (value) {
13225
+ return getOffset(height, value);
13226
+ });
13227
+ var uniqSnapPointOffsetValues = Array.from(new Set([].concat(_toConsumableArray(snapPointsOffsetValues), [0])));
13214
13228
  return {
13215
- registerHost: registerHost,
13216
- deregisterHost: deregisterHost,
13217
- addPortal: addUpdatePortal,
13218
- updatePortal: addUpdatePortal,
13219
- removePortal: removePortal
13229
+ list: uniqSnapPointOffsetValues,
13230
+ minHeightOffset: Math.max.apply(Math, uniqSnapPointOffsetValues),
13231
+ maxHeightOffset: 0 // Max height
13220
13232
  };
13221
13233
  };
13222
13234
 
13223
- var usePortalState = function usePortalState(hostName) {
13224
- var state = React.useContext(PortalStateContext);
13225
- if (state === null) {
13226
- throw new Error("You must add 'PortalProvider' to the root component.");
13227
- }
13228
- return state[hostName] || [];
13235
+ var calculateAnimatedToValue = function calculateAnimatedToValue(position, heightSnapPoints) {
13236
+ var distances = heightSnapPoints.map(function (height) {
13237
+ return Math.abs(position - height);
13238
+ });
13239
+ var minIndex = distances.indexOf(Math.min.apply(Math, _toConsumableArray(distances)));
13240
+ return heightSnapPoints[minIndex];
13229
13241
  };
13230
13242
 
13231
- var PortalHostComponent = function PortalHostComponent(_ref) {
13232
- var name = _ref.name;
13233
- var state = usePortalState(name);
13234
- var _usePortal = usePortal(name),
13235
- registerHost = _usePortal.registerHost,
13236
- deregisterHost = _usePortal.deregisterHost;
13243
+ var DragableDrawer = function DragableDrawer(_ref) {
13244
+ var children = _ref.children,
13245
+ initialHeightPercentage = _ref.initialHeightPercentage,
13246
+ _ref$minimumHeightPer = _ref.minimumHeightPercentage,
13247
+ minimumHeightPercentage = _ref$minimumHeightPer === void 0 ? 10 : _ref$minimumHeightPer,
13248
+ _ref$snapPoints = _ref.snapPoints,
13249
+ snapPoints = _ref$snapPoints === void 0 ? [] : _ref$snapPoints,
13250
+ onExpanded = _ref.onExpanded,
13251
+ onCollapsed = _ref.onCollapsed,
13252
+ testID = _ref.testID;
13253
+ var _useState = React.useState(0),
13254
+ _useState2 = _slicedToArray(_useState, 2),
13255
+ height = _useState2[0],
13256
+ setHeight = _useState2[1];
13257
+ var baseHeightForMeasure = React.useRef(0);
13258
+ var snapPointsData = React.useRef({
13259
+ list: [],
13260
+ minHeightOffset: 0,
13261
+ maxHeightOffset: 0
13262
+ });
13263
+ // Track drag
13264
+ var pan = React.useRef(new reactNative.Animated.Value(0)).current;
13265
+ var offset = React.useRef(0);
13266
+ var offsetBeforePan = React.useRef(0);
13267
+ var _useState3 = React.useState(-1),
13268
+ _useState4 = _slicedToArray(_useState3, 2),
13269
+ animatedToValue = _useState4[0],
13270
+ setAnimatedToValue = _useState4[1];
13237
13271
  React.useEffect(function () {
13238
- registerHost();
13272
+ var id = pan.addListener(function (_ref2) {
13273
+ var value = _ref2.value;
13274
+ offset.current = value;
13275
+ });
13239
13276
  return function () {
13240
- deregisterHost();
13277
+ return pan.removeListener(id);
13241
13278
  };
13242
13279
  }, []);
13243
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, state.map(function (item) {
13244
- return item.node;
13245
- }));
13246
- };
13247
- var PortalHost = /*#__PURE__*/React.memo(PortalHostComponent);
13248
- PortalHost.displayName = 'PortalHost';
13249
-
13250
- var registerHostIfNotExist = function registerHostIfNotExist(state, hostName) {
13251
- if (!(hostName in state)) {
13252
- return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, hostName, []));
13253
- }
13254
- return _objectSpread2({}, state);
13255
- };
13256
- var deregisterHost = function deregisterHost(state, hostName) {
13257
- return _objectSpread2({}, omit([hostName], state));
13258
- };
13259
- var addUpdatePortal = function addUpdatePortal(state, hostName, portalName, node) {
13260
- var newState = registerHostIfNotExist(state, hostName);
13261
- var index = newState[hostName].findIndex(function (item) {
13262
- return item.name === portalName;
13263
- });
13264
- if (index !== -1) {
13265
- return _objectSpread2(_objectSpread2({}, newState), {}, _defineProperty({}, hostName, newState[hostName].map(function (item, i) {
13266
- if (index === i) {
13267
- return _objectSpread2(_objectSpread2({}, item), {}, {
13268
- node: node
13269
- });
13280
+ React.useEffect(function () {
13281
+ if (height > 0) {
13282
+ var initialOffset = getOffset(height, initialHeightPercentage || minimumHeightPercentage);
13283
+ setAnimatedToValue(initialOffset);
13284
+ }
13285
+ }, [height]);
13286
+ React.useEffect(function () {
13287
+ if (height > 0) {
13288
+ pan.setValue(height);
13289
+ offset.current = height;
13290
+ baseHeightForMeasure.current = height;
13291
+ // Calculate snap points information
13292
+ snapPointsData.current = calculateSnapPointsData(minimumHeightPercentage, height, snapPoints);
13293
+ }
13294
+ }, [height, minimumHeightPercentage]);
13295
+ React.useEffect(function () {
13296
+ if (animatedToValue >= 0) {
13297
+ var animation = reactNative.Animated.timing(pan, {
13298
+ toValue: animatedToValue,
13299
+ useNativeDriver: true,
13300
+ easing: reactNative.Easing.inOut(reactNative.Easing.cubic)
13301
+ });
13302
+ animation.start(function () {
13303
+ if (animatedToValue === 0) {
13304
+ onExpanded === null || onExpanded === void 0 ? void 0 : onExpanded();
13305
+ } else if (animatedToValue === getOffset(height, minimumHeightPercentage)) {
13306
+ onCollapsed === null || onCollapsed === void 0 ? void 0 : onCollapsed();
13307
+ }
13308
+ setAnimatedToValue(-1);
13309
+ });
13310
+ return function () {
13311
+ return animation.stop();
13312
+ };
13313
+ }
13314
+ }, [animatedToValue]);
13315
+ var panResponder = React.useRef(reactNative.PanResponder.create({
13316
+ onMoveShouldSetPanResponder: function onMoveShouldSetPanResponder() {
13317
+ return true;
13318
+ },
13319
+ onPanResponderGrant: function onPanResponderGrant() {
13320
+ offsetBeforePan.current = offset.current;
13321
+ pan.setOffset(offset.current);
13322
+ pan.setValue(0);
13323
+ },
13324
+ onPanResponderMove: function onPanResponderMove(_, gesture) {
13325
+ var _snapPointsData$curre;
13326
+ var panDistance = gesture.dy;
13327
+ // Moving toward top, stop at highest snap point
13328
+ if (offsetBeforePan.current + panDistance < 0) {
13329
+ pan.setValue(-offsetBeforePan.current);
13330
+ return;
13270
13331
  }
13271
- return item;
13272
- })));
13273
- }
13274
- return _objectSpread2(_objectSpread2({}, newState), {}, _defineProperty({}, hostName, [].concat(_toConsumableArray(newState[hostName]), [{
13275
- name: portalName,
13276
- node: node
13277
- }])));
13278
- };
13279
- var removePortal = function removePortal(state, hostName, portalName) {
13280
- if (!(hostName in state)) {
13281
- return _objectSpread2({}, state);
13282
- }
13283
- return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, hostName, state[hostName].filter(function (item) {
13284
- return item.name !== portalName;
13285
- })));
13286
- };
13287
- var reducer = function reducer(state, action) {
13288
- var type = action.type;
13289
- switch (type) {
13290
- case ACTIONS.REGISTER_HOST:
13291
- return registerHostIfNotExist(state, action.hostName);
13292
- case ACTIONS.DEREGISTER_HOST:
13293
- return deregisterHost(state, action.hostName);
13294
- case ACTIONS.ADD_UPDATE_PORTAL:
13295
- return addUpdatePortal(state, action.hostName, action.portalName, action.node);
13296
- case ACTIONS.REMOVE_PORTAL:
13297
- return removePortal(state, action.hostName, action.portalName);
13298
- default:
13299
- return _objectSpread2({}, state);
13300
- }
13301
- };
13302
-
13303
- var PortalProviderComponent = function PortalProviderComponent(_ref) {
13304
- var _ref$rootHostName = _ref.rootHostName,
13305
- rootHostName = _ref$rootHostName === void 0 ? 'root' : _ref$rootHostName,
13306
- children = _ref.children;
13307
- var _useReducer = React.useReducer(reducer, INITIAL_STATE),
13308
- _useReducer2 = _slicedToArray(_useReducer, 2),
13309
- state = _useReducer2[0],
13310
- dispatch = _useReducer2[1];
13311
- return /*#__PURE__*/React__default["default"].createElement(PortalDispatchContext.Provider, {
13312
- value: dispatch
13313
- }, /*#__PURE__*/React__default["default"].createElement(PortalStateContext.Provider, {
13314
- value: state
13315
- }, children, /*#__PURE__*/React__default["default"].createElement(PortalHost, {
13316
- name: rootHostName
13317
- })));
13332
+ // Moving toward bottom, stop at lowest snap point
13333
+ if (offsetBeforePan.current + panDistance > ((_snapPointsData$curre = snapPointsData.current) === null || _snapPointsData$curre === void 0 ? void 0 : _snapPointsData$curre.minHeightOffset)) {
13334
+ pan.setValue(baseHeightForMeasure.current - baseHeightForMeasure.current * (minimumHeightPercentage / 100) - offsetBeforePan.current);
13335
+ return;
13336
+ }
13337
+ pan.setValue(panDistance);
13338
+ },
13339
+ onPanResponderRelease: function onPanResponderRelease(_, gesture) {
13340
+ pan.flattenOffset();
13341
+ // Attach to nearest snappoint
13342
+ var panDistance = gesture.dy;
13343
+ var offsetAfterPan = offsetBeforePan.current + panDistance;
13344
+ var animatedValue = calculateAnimatedToValue(offsetAfterPan, snapPointsData.current.list);
13345
+ setAnimatedToValue(animatedValue);
13346
+ }
13347
+ })).current;
13348
+ return /*#__PURE__*/React__default["default"].createElement(StyledDragableContainer, {
13349
+ testID: testID,
13350
+ enableShadow: true,
13351
+ pointerEvents: "box-none"
13352
+ }, /*#__PURE__*/React__default["default"].createElement(StyledDragableDrawerContainer, {
13353
+ enableShadow: true,
13354
+ style: {
13355
+ transform: [{
13356
+ scaleY: baseHeightForMeasure.current > 0 ? 1 : 0
13357
+ }, {
13358
+ translateY: pan
13359
+ }]
13360
+ },
13361
+ onLayout: function onLayout(_ref3) {
13362
+ var nativeEvent = _ref3.nativeEvent;
13363
+ setHeight(nativeEvent.layout.height);
13364
+ }
13365
+ }, /*#__PURE__*/React__default["default"].createElement(StyledHandlerContainer, panResponder.panHandlers, /*#__PURE__*/React__default["default"].createElement(StyledHandler, null)), children));
13318
13366
  };
13319
- var PortalProvider = /*#__PURE__*/React.memo(PortalProviderComponent);
13320
- PortalProvider.displayName = 'PortalProvider';
13321
13367
 
13322
- var nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789', 10);
13323
- var PortalComponent = function PortalComponent(_ref) {
13324
- var name = _ref.name,
13325
- hostName = _ref.hostName,
13368
+ var Drawer = function Drawer(_ref) {
13369
+ var visible = _ref.visible,
13326
13370
  children = _ref.children,
13327
- theme = _ref.theme;
13328
- var defaultTheme = useTheme();
13329
- var _usePortal = usePortal(hostName),
13330
- addUpdatePortal = _usePortal.addPortal,
13331
- removePortal = _usePortal.removePortal;
13332
- var nameOrRandom = React.useMemo(function () {
13333
- return name || nanoid();
13334
- }, [name]);
13335
- var ChildrenComponent = React.useMemo(function () {
13336
- return /*#__PURE__*/React__default["default"].createElement(ThemeProvider, {
13337
- theme: theme || defaultTheme
13338
- }, children);
13339
- }, [theme, children, defaultTheme]);
13340
- React.useLayoutEffect(function () {
13341
- addUpdatePortal(nameOrRandom, ChildrenComponent);
13342
- return function () {
13343
- removePortal(nameOrRandom);
13344
- };
13345
- }, [addUpdatePortal]);
13346
- React.useLayoutEffect(function () {
13347
- addUpdatePortal(nameOrRandom, ChildrenComponent);
13348
- }, [ChildrenComponent]);
13349
- return null;
13350
- };
13351
- var Portal = /*#__PURE__*/React.memo(PortalComponent);
13352
- Portal.displayName = 'Portal';
13353
- var Portal$1 = Object.assign(Portal, {
13354
- Provider: PortalProvider,
13355
- Host: PortalHost
13356
- });
13357
-
13358
- var _excluded$e = ["visible"];
13359
- var DEFAULT_BACKDROP_OPACITY = 0.4;
13360
- var DEFAULT_ANIMATION_CONFIG = {
13361
- easing: reactNative.Easing.inOut(reactNative.Easing.cubic),
13362
- useNativeDriver: reactNative.Platform.OS !== 'web',
13363
- duration: 400
13364
- };
13365
- var Modal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
13366
- var children = _ref.children,
13367
- onShow = _ref.onShow,
13368
- onRequestClose = _ref.onRequestClose,
13369
- testID = _ref.testID,
13370
- _ref$animationType = _ref.animationType,
13371
- animationType = _ref$animationType === void 0 ? 'none' : _ref$animationType,
13372
- _ref$transparent = _ref.transparent,
13373
- transparent = _ref$transparent === void 0 ? false : _ref$transparent,
13374
- onDismiss = _ref.onDismiss;
13375
- var theme = useTheme();
13376
- var animatedBackdropValue = React.useRef(new reactNative.Animated.Value(0)).current;
13377
- var animatedModalValue = React.useRef(new reactNative.Animated.Value(0)).current;
13378
- // Show or hide the backdrop and modal content
13379
- var animateBackdropAndContent = React.useCallback(function (_ref2) {
13380
- var toValue = _ref2.toValue,
13381
- callback = _ref2.callback;
13382
- if (animationType !== 'none') {
13383
- // Backdrop animation
13384
- if (!transparent) {
13385
- reactNative.Animated.timing(animatedBackdropValue, _objectSpread2({
13386
- toValue: toValue
13387
- }, DEFAULT_ANIMATION_CONFIG)).start();
13388
- }
13389
- // Modal content animation
13390
- reactNative.Animated.timing(animatedModalValue, _objectSpread2({
13391
- toValue: toValue
13392
- }, DEFAULT_ANIMATION_CONFIG)).start(callback);
13393
- } else {
13394
- callback === null || callback === void 0 ? void 0 : callback();
13395
- }
13396
- }, [animationType, onShow, transparent]);
13397
- var backdropOpacityAnimation = animatedBackdropValue.interpolate({
13371
+ _ref$hasBackdrop = _ref.hasBackdrop,
13372
+ hasBackdrop = _ref$hasBackdrop === void 0 ? true : _ref$hasBackdrop,
13373
+ onDismiss = _ref.onDismiss,
13374
+ testID = _ref.testID;
13375
+ var animatedValue = React.useRef(new reactNative.Animated.Value(visible ? 1 : 0)).current;
13376
+ var _useState = React.useState(reactNative.Dimensions.get('window').height),
13377
+ _useState2 = _slicedToArray(_useState, 2),
13378
+ height = _useState2[0],
13379
+ setHeight = _useState2[1];
13380
+ var enableShadow = visible && !hasBackdrop;
13381
+ var interpolateTranslateY = animatedValue.interpolate({
13398
13382
  inputRange: [0, 1],
13399
- outputRange: [0, DEFAULT_BACKDROP_OPACITY]
13383
+ outputRange: [-height, 0]
13400
13384
  });
13401
- var modalAnimation = animatedModalValue.interpolate({
13385
+ var interpolateBackdropOpacity = hasBackdrop ? animatedValue.interpolate({
13402
13386
  inputRange: [0, 1],
13403
- outputRange: animationType === 'slide' ? [reactNative.Dimensions.get('window').height, 0] : [0, 1]
13404
- });
13405
- React.useImperativeHandle(ref, function () {
13406
- return {
13407
- show: function show() {
13408
- animateBackdropAndContent({
13409
- toValue: 1,
13410
- callback: onShow
13411
- });
13412
- },
13413
- hide: function hide(wrapperCallback) {
13414
- animateBackdropAndContent({
13415
- toValue: 0,
13416
- callback: function callback() {
13417
- if (reactNative.Platform.OS === 'ios') {
13418
- onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
13419
- }
13420
- wrapperCallback();
13421
- }
13422
- });
13423
- }
13424
- };
13425
- }, [onDismiss, onShow, animateBackdropAndContent]);
13426
- // Back button handler
13387
+ outputRange: [0, 0.35]
13388
+ }) : 0;
13427
13389
  React.useEffect(function () {
13428
- var backHandler = reactNative.BackHandler.addEventListener('hardwareBackPress', function () {
13429
- onRequestClose === null || onRequestClose === void 0 ? void 0 : onRequestClose();
13430
- return true;
13390
+ var animation = reactNative.Animated.timing(animatedValue, {
13391
+ toValue: visible ? 1 : 0,
13392
+ easing: reactNative.Easing.inOut(reactNative.Easing.cubic),
13393
+ useNativeDriver: true
13431
13394
  });
13395
+ animation.start();
13432
13396
  return function () {
13433
- return backHandler.remove();
13397
+ return animation.stop();
13434
13398
  };
13435
- }, [onRequestClose]);
13436
- return /*#__PURE__*/React__default["default"].createElement(Portal$1, null, /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
13437
- style: _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
13438
- backgroundColor: transparent ? 'transparent' : theme.colors.overlayGlobalSurface,
13439
- opacity: animationType !== 'none' ? backdropOpacityAnimation : DEFAULT_BACKDROP_OPACITY
13440
- })
13441
- }), /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
13399
+ }, [visible]);
13400
+ return /*#__PURE__*/React__default["default"].createElement(StyledContainer$3, {
13442
13401
  testID: testID,
13443
- style: _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
13444
- opacity: animationType === 'fade' ? modalAnimation : 1,
13402
+ enableShadow: enableShadow,
13403
+ pointerEvents: "box-none"
13404
+ }, /*#__PURE__*/React__default["default"].createElement(StyledBackdrop$1, {
13405
+ pointerEvents: visible ? 'auto' : 'box-none',
13406
+ onPress: onDismiss,
13407
+ style: {
13408
+ opacity: interpolateBackdropOpacity
13409
+ }
13410
+ }), /*#__PURE__*/React__default["default"].createElement(StyledDrawerContainer, {
13411
+ enableShadow: enableShadow,
13412
+ onLayout: function onLayout(_ref2) {
13413
+ var nativeEvent = _ref2.nativeEvent;
13414
+ return setHeight(nativeEvent.layout.height);
13415
+ },
13416
+ style: {
13445
13417
  transform: [{
13446
- translateY: animationType === 'slide' ? modalAnimation : 0
13418
+ translateY: interpolateTranslateY
13447
13419
  }]
13448
- })
13420
+ }
13449
13421
  }, children));
13422
+ };
13423
+ var index$7 = Object.assign(Drawer, {
13424
+ Dragable: DragableDrawer
13450
13425
  });
13451
- var ModalWrapper = function ModalWrapper(_ref3) {
13452
- var _ref3$visible = _ref3.visible,
13453
- visible = _ref3$visible === void 0 ? true : _ref3$visible,
13454
- props = _objectWithoutProperties(_ref3, _excluded$e);
13455
- var modalRef = React.useRef(null);
13456
- var _useState = React.useState(visible),
13457
- _useState2 = _slicedToArray(_useState, 2),
13458
- internalVisible = _useState2[0],
13459
- setInternalVisible = _useState2[1];
13460
- React.useEffect(function () {
13461
- if (visible) {
13462
- setInternalVisible(true);
13463
- } else {
13464
- var _modalRef$current;
13465
- // Wait for animation to finish before hiding the modal
13466
- (_modalRef$current = modalRef.current) === null || _modalRef$current === void 0 ? void 0 : _modalRef$current.hide(function () {
13467
- return setInternalVisible(false);
13468
- });
13469
- }
13470
- }, [visible]);
13471
- React.useEffect(function () {
13472
- if (internalVisible) {
13473
- var _modalRef$current2;
13474
- (_modalRef$current2 = modalRef.current) === null || _modalRef$current2 === void 0 ? void 0 : _modalRef$current2.show();
13475
- }
13476
- }, [internalVisible]);
13477
- return internalVisible ? /*#__PURE__*/React__default["default"].createElement(Modal, _extends$1({
13478
- ref: modalRef
13479
- }, props)) : null;
13426
+
13427
+ var StyledWrapper$6 = index$a(reactNative.View)(function (_ref) {
13428
+ var theme = _ref.theme;
13429
+ return {
13430
+ display: 'flex',
13431
+ flex: 1,
13432
+ flexDirection: 'column',
13433
+ alignItems: 'center',
13434
+ justifyContent: 'center',
13435
+ padding: theme.__hd__.empty.space.wrapperPadding
13436
+ };
13437
+ });
13438
+ var StyledTitle = index$a(Typography.Title)(function (_ref2) {
13439
+ var theme = _ref2.theme,
13440
+ themeVariant = _ref2.themeVariant;
13441
+ return {
13442
+ textAlign: 'center',
13443
+ marginBottom: theme.__hd__.empty.space.titleMargin,
13444
+ color: themeVariant === 'dark' ? theme.__hd__.empty.colors.invertedText : theme.__hd__.empty.colors.text
13445
+ };
13446
+ });
13447
+ var StyledDescription = index$a(Typography.Body)(function (_ref3) {
13448
+ var theme = _ref3.theme,
13449
+ themeVariant = _ref3.themeVariant;
13450
+ return {
13451
+ textAlign: 'center',
13452
+ color: themeVariant === 'dark' ? theme.__hd__.empty.colors.invertedSubduedText : theme.__hd__.empty.colors.subduedText
13453
+ };
13454
+ });
13455
+
13456
+ var Empty = function Empty(_ref) {
13457
+ var image = _ref.image,
13458
+ title = _ref.title,
13459
+ description = _ref.description,
13460
+ style = _ref.style,
13461
+ testID = _ref.testID,
13462
+ _ref$variant = _ref.variant,
13463
+ variant = _ref$variant === void 0 ? 'light' : _ref$variant;
13464
+ var theme = useTheme();
13465
+ return /*#__PURE__*/React__default["default"].createElement(StyledWrapper$6, {
13466
+ style: style,
13467
+ testID: testID
13468
+ }, image !== undefined && /*#__PURE__*/React__default["default"].cloneElement(image, _objectSpread2(_objectSpread2({}, image.props), {}, {
13469
+ style: [{
13470
+ marginBottom: theme.__hd__.empty.space.imageMargin
13471
+ }, image.props.style]
13472
+ })), /*#__PURE__*/React__default["default"].createElement(StyledTitle, {
13473
+ themeVariant: variant,
13474
+ level: "h4",
13475
+ typeface: "playful"
13476
+ }, title), !!description && /*#__PURE__*/React__default["default"].createElement(StyledDescription, {
13477
+ themeVariant: variant,
13478
+ typeface: "playful"
13479
+ }, description));
13480
13480
  };
13481
13481
 
13482
13482
  var StyledErrorModal = index$a(ModalWrapper)({