@hero-design/rn 9.5.4-test.1 → 9.6.0-testonly.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
@@ -1028,9 +1028,16 @@ var palette$b = {
1028
1028
  black: '#000000',
1029
1029
  white: '#ffffff',
1030
1030
  blue: blue$1.base,
1031
+ blueDark15: blue$1.darken15,
1031
1032
  blueDark30: blue$1.darken30,
1033
+ blueDark45: blue$1.darken45,
1034
+ blueDark60: blue$1.darken60,
1032
1035
  blueDark75: blue$1.darken75,
1036
+ blueDark90: blue$1.darken90,
1037
+ blueLight15: blue$1.lighten15,
1033
1038
  blueLight30: blue$1.lighten30,
1039
+ blueLight45: blue$1.lighten45,
1040
+ blueLight60: blue$1.lighten60,
1034
1041
  blueLight75: blue$1.lighten75,
1035
1042
  blueLight90: blue$1.lighten90,
1036
1043
  cloudLight90: cloud.lighten90,
@@ -1101,10 +1108,13 @@ var palette$b = {
1101
1108
  red: vermilion$2.base,
1102
1109
  redDark15: vermilion$2.darken15,
1103
1110
  redDark30: vermilion$2.darken30,
1111
+ redDark45: vermilion$2.darken45,
1104
1112
  redDark60: vermilion$2.darken60,
1105
1113
  redDark75: vermilion$2.darken75,
1114
+ redDark90: vermilion$2.darken90,
1106
1115
  redLight15: vermilion$2.lighten15,
1107
1116
  redLight30: vermilion$2.lighten30,
1117
+ redLight45: vermilion$2.lighten45,
1108
1118
  redLight60: vermilion$2.lighten60,
1109
1119
  redLight75: vermilion$2.lighten75,
1110
1120
  redLight90: vermilion$2.lighten90,
@@ -1121,7 +1131,10 @@ var palette$b = {
1121
1131
  violetDark45: violet$1.darken45,
1122
1132
  violetDark60: violet$1.darken60,
1123
1133
  violetDark75: violet$1.darken75,
1134
+ violetDark90: violet$1.darken90,
1135
+ violetLight15: violet$1.lighten15,
1124
1136
  violetLight30: violet$1.lighten30,
1137
+ violetLight45: violet$1.lighten45,
1125
1138
  violetLight60: violet$1.lighten60,
1126
1139
  violetLight75: violet$1.lighten75,
1127
1140
  violetLight90: violet$1.lighten90,
@@ -7191,8 +7204,8 @@ var Alert = function Alert(_ref2) {
7191
7204
  return /*#__PURE__*/React__default["default"].createElement(Container$1, {
7192
7205
  themeVariant: variant,
7193
7206
  themeIntent: intent,
7194
- style: style,
7195
- testID: testID
7207
+ testID: testID,
7208
+ style: style
7196
7209
  }, /*#__PURE__*/React__default["default"].createElement(ContentContainer$1, {
7197
7210
  showDivider: !!onClose
7198
7211
  }, icon !== null ? /*#__PURE__*/React__default["default"].createElement(AlertIcon, {
@@ -8239,119 +8252,99 @@ var BottomSheetScrollView = function BottomSheetScrollView(_ref) {
8239
8252
  }));
8240
8253
  };
8241
8254
 
8242
- var BottomSheet = function BottomSheet(_ref) {
8243
- var open = _ref.open,
8244
- header = _ref.header,
8245
- footer = _ref.footer,
8246
- children = _ref.children,
8247
- onAnimationEnd = _ref.onAnimationEnd,
8248
- onOpen = _ref.onOpen,
8249
- onRequestClose = _ref.onRequestClose,
8250
- onDismiss = _ref.onDismiss,
8251
- _ref$showCloseButton = _ref.showCloseButton,
8252
- showCloseButton = _ref$showCloseButton === void 0 ? true : _ref$showCloseButton,
8253
- _ref$hasBackdrop = _ref.hasBackdrop,
8254
- hasBackdrop = _ref$hasBackdrop === void 0 ? true : _ref$hasBackdrop,
8255
- _ref$showDivider = _ref.showDivider,
8256
- showDivider = _ref$showDivider === void 0 ? false : _ref$showDivider,
8257
- style = _ref.style,
8258
- testID = _ref.testID,
8259
- _ref$keyboardAvoiding = _ref.keyboardAvoidingViewProps,
8260
- keyboardAvoidingViewProps = _ref$keyboardAvoiding === void 0 ? {} : _ref$keyboardAvoiding;
8261
- var _Dimensions$get = reactNative.Dimensions.get('window'),
8262
- height = _Dimensions$get.height;
8263
- // Internal state to control modal open/close timing with animation
8264
- var _useState = React.useState(open),
8265
- _useState2 = _slicedToArray(_useState, 2),
8266
- visible = _useState2[0],
8267
- setVisibility = _useState2[1];
8268
- var animatedValue = React.useRef(new reactNative.Animated.Value(open ? 0 : 1));
8269
- var _useState3 = React.useState(showDivider),
8270
- _useState4 = _slicedToArray(_useState3, 2),
8271
- internalShowDivider = _useState4[0],
8272
- setInternalShowDivider = _useState4[1];
8273
- React.useEffect(function () {
8274
- // Show the modal before the open animation start
8275
- if (open && !visible) {
8276
- setVisibility(open);
8255
+ var customAlphabet = function customAlphabet(alphabet) {
8256
+ var defaultSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 21;
8257
+ return function () {
8258
+ var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultSize;
8259
+ var id = '';
8260
+ var i = size;
8261
+ while (i--) {
8262
+ id += alphabet[Math.random() * alphabet.length | 0];
8277
8263
  }
8278
- // Delay closing the modal until after the closing animation end
8279
- animatedValue.current.removeAllListeners();
8280
- animatedValue.current.addListener(function (_ref2) {
8281
- var value = _ref2.value;
8282
- var endValueOfTransition = open ? 1 : 0;
8283
- if (endValueOfTransition === 0 && value === endValueOfTransition) {
8284
- setVisibility(false);
8285
- onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
8286
- }
8264
+ return id;
8265
+ };
8266
+ };
8267
+
8268
+ var ACTIONS;
8269
+ (function (ACTIONS) {
8270
+ ACTIONS[ACTIONS["REGISTER_HOST"] = 0] = "REGISTER_HOST";
8271
+ ACTIONS[ACTIONS["DEREGISTER_HOST"] = 1] = "DEREGISTER_HOST";
8272
+ ACTIONS[ACTIONS["ADD_UPDATE_PORTAL"] = 2] = "ADD_UPDATE_PORTAL";
8273
+ ACTIONS[ACTIONS["REMOVE_PORTAL"] = 3] = "REMOVE_PORTAL";
8274
+ })(ACTIONS || (ACTIONS = {}));
8275
+ var INITIAL_STATE = {};
8276
+
8277
+ var PortalStateContext = /*#__PURE__*/React.createContext(null);
8278
+ var PortalDispatchContext = /*#__PURE__*/React.createContext(null);
8279
+
8280
+ var usePortal = function usePortal() {
8281
+ var hostName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'root';
8282
+ var dispatch = React.useContext(PortalDispatchContext);
8283
+ if (dispatch === null) {
8284
+ throw new Error("You must add 'PortalProvider' to the root component.");
8285
+ }
8286
+ var registerHost = React.useCallback(function () {
8287
+ dispatch({
8288
+ type: ACTIONS.REGISTER_HOST,
8289
+ hostName: hostName
8287
8290
  });
8288
- return function () {
8289
- return animatedValue.current.removeAllListeners();
8290
- };
8291
- }, [open]);
8292
- // Animation
8293
- React.useEffect(function () {
8294
- var animation = reactNative.Animated.timing(animatedValue.current, {
8295
- toValue: open ? 1 : 0,
8296
- easing: reactNative.Easing.inOut(reactNative.Easing.cubic),
8297
- useNativeDriver: true
8291
+ }, []);
8292
+ var deregisterHost = React.useCallback(function () {
8293
+ dispatch({
8294
+ type: ACTIONS.DEREGISTER_HOST,
8295
+ hostName: hostName
8298
8296
  });
8299
- animation.start(onAnimationEnd);
8297
+ }, []);
8298
+ var addUpdatePortal = React.useCallback(function (name, node) {
8299
+ dispatch({
8300
+ type: ACTIONS.ADD_UPDATE_PORTAL,
8301
+ hostName: hostName,
8302
+ portalName: name,
8303
+ node: node
8304
+ });
8305
+ }, []);
8306
+ var removePortal = React.useCallback(function (name) {
8307
+ dispatch({
8308
+ type: ACTIONS.REMOVE_PORTAL,
8309
+ hostName: hostName,
8310
+ portalName: name
8311
+ });
8312
+ }, []);
8313
+ return {
8314
+ registerHost: registerHost,
8315
+ deregisterHost: deregisterHost,
8316
+ addPortal: addUpdatePortal,
8317
+ updatePortal: addUpdatePortal,
8318
+ removePortal: removePortal
8319
+ };
8320
+ };
8321
+
8322
+ var usePortalState = function usePortalState(hostName) {
8323
+ var state = React.useContext(PortalStateContext);
8324
+ if (state === null) {
8325
+ throw new Error("You must add 'PortalProvider' to the root component.");
8326
+ }
8327
+ return state[hostName] || [];
8328
+ };
8329
+
8330
+ var PortalHostComponent = function PortalHostComponent(_ref) {
8331
+ var name = _ref.name;
8332
+ var state = usePortalState(name);
8333
+ var _usePortal = usePortal(name),
8334
+ registerHost = _usePortal.registerHost,
8335
+ deregisterHost = _usePortal.deregisterHost;
8336
+ React.useEffect(function () {
8337
+ registerHost();
8300
8338
  return function () {
8301
- return animation.stop();
8302
- };
8303
- }, [open]);
8304
- var interpolateY = animatedValue.current.interpolate({
8305
- inputRange: [0, 1],
8306
- outputRange: [height, 0]
8307
- });
8308
- // Backdrop opacity
8309
- var interpolateOpacity = hasBackdrop ? animatedValue.current.interpolate({
8310
- inputRange: [0, 1],
8311
- outputRange: [0, 0.48]
8312
- }) : 0;
8313
- var BottomSheetContextValue = React.useMemo(function () {
8314
- return {
8315
- setInternalShowDivider: setInternalShowDivider
8339
+ deregisterHost();
8316
8340
  };
8317
- }, [setInternalShowDivider]);
8318
- return /*#__PURE__*/React__default["default"].createElement(reactNative.Modal, {
8319
- visible: visible,
8320
- onRequestClose: onRequestClose,
8321
- transparent: true,
8322
- testID: testID,
8323
- onShow: onOpen
8324
- }, /*#__PURE__*/React__default["default"].createElement(StyledWrapper$9, {
8325
- pointerEvents: "box-none"
8326
- }, /*#__PURE__*/React__default["default"].createElement(StyledKeyboardAvoidingView, _extends$1({
8327
- behavior: reactNative.Platform.OS === 'ios' ? 'padding' : 'height'
8328
- }, keyboardAvoidingViewProps), /*#__PURE__*/React__default["default"].createElement(StyledBackdrop$2, {
8329
- style: {
8330
- opacity: interpolateOpacity
8331
- },
8332
- onPress: onRequestClose
8333
- }), /*#__PURE__*/React__default["default"].createElement(StyledBottomSheet, {
8334
- style: [style, {
8335
- transform: [{
8336
- scaleY: height > 0 ? 1 : 0
8337
- }, {
8338
- translateY: interpolateY
8339
- }]
8340
- }]
8341
- }, header !== undefined ? /*#__PURE__*/React__default["default"].createElement(Header, {
8342
- content: header,
8343
- showDivider: internalShowDivider,
8344
- onRequestClose: onRequestClose,
8345
- showCloseButton: showCloseButton
8346
- }) : null, /*#__PURE__*/React__default["default"].createElement(BottomSheetContext.Provider, {
8347
- value: BottomSheetContextValue
8348
- }, children), footer ? /*#__PURE__*/React__default["default"].createElement(Footer$1, {
8349
- showDivider: showDivider
8350
- }, footer) : null))));
8341
+ }, []);
8342
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, state.map(function (item) {
8343
+ return item.node;
8344
+ }));
8351
8345
  };
8352
- var BottomSheet$1 = Object.assign(BottomSheet, {
8353
- ScrollView: BottomSheetScrollView
8354
- });
8346
+ var PortalHost = /*#__PURE__*/React.memo(PortalHostComponent);
8347
+ PortalHost.displayName = 'PortalHost';
8355
8348
 
8356
8349
  reactNative.Platform.OS === 'ios';
8357
8350
  var isAndroid = reactNative.Platform.OS === 'android';
@@ -8370,236 +8363,582 @@ function omit(keys, obj) {
8370
8363
  return result;
8371
8364
  }
8372
8365
 
8373
- var colors = {
8374
- backgroundColor: {
8375
- property: 'backgroundColor',
8376
- scale: 'colors'
8377
- },
8378
- bgColor: {
8379
- property: 'backgroundColor',
8380
- scale: 'colors'
8381
- },
8382
- borderColor: {
8383
- property: 'borderColor',
8384
- scale: 'colors'
8385
- },
8386
- borderTopColor: {
8387
- property: 'borderTopColor',
8388
- scale: 'colors'
8389
- },
8390
- borderBottomColor: {
8391
- property: 'borderBottomColor',
8392
- scale: 'colors'
8393
- },
8394
- borderStartColor: {
8395
- property: 'borderStartColor',
8396
- scale: 'colors'
8397
- },
8398
- borderEndColor: {
8399
- property: 'borderEndColor',
8400
- scale: 'colors'
8401
- },
8402
- borderLeftColor: {
8403
- property: 'borderLeftColor',
8404
- scale: 'colors'
8405
- },
8406
- borderRightColor: {
8407
- property: 'borderRightColor',
8408
- scale: 'colors'
8366
+ var registerHostIfNotExist = function registerHostIfNotExist(state, hostName) {
8367
+ if (!(hostName in state)) {
8368
+ return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, hostName, []));
8409
8369
  }
8370
+ return _objectSpread2({}, state);
8410
8371
  };
8411
- var space = {
8412
- margin: {
8413
- property: 'margin',
8414
- scale: 'space'
8415
- },
8416
- marginBottom: {
8417
- property: 'marginBottom',
8418
- scale: 'space'
8419
- },
8420
- marginEnd: {
8421
- property: 'marginEnd',
8422
- scale: 'space'
8423
- },
8424
- marginHorizontal: {
8425
- property: 'marginHorizontal',
8426
- scale: 'space'
8427
- },
8428
- marginLeft: {
8429
- property: 'marginLeft',
8430
- scale: 'space'
8431
- },
8432
- marginRight: {
8433
- property: 'marginRight',
8434
- scale: 'space'
8435
- },
8436
- marginStart: {
8437
- property: 'marginStart',
8438
- scale: 'space'
8439
- },
8440
- marginTop: {
8441
- property: 'marginTop',
8442
- scale: 'space'
8443
- },
8444
- marginVertical: {
8445
- property: 'marginVertical',
8446
- scale: 'space'
8447
- },
8448
- padding: {
8449
- property: 'padding',
8450
- scale: 'space'
8451
- },
8452
- paddingBottom: {
8453
- property: 'paddingBottom',
8454
- scale: 'space'
8455
- },
8456
- paddingEnd: {
8457
- property: 'paddingEnd',
8458
- scale: 'space'
8459
- },
8460
- paddingHorizontal: {
8461
- property: 'paddingHorizontal',
8462
- scale: 'space'
8463
- },
8464
- paddingLeft: {
8465
- property: 'paddingLeft',
8466
- scale: 'space'
8467
- },
8468
- paddingRight: {
8469
- property: 'paddingRight',
8470
- scale: 'space'
8471
- },
8472
- paddingStart: {
8473
- property: 'paddingStart',
8474
- scale: 'space'
8475
- },
8476
- paddingTop: {
8477
- property: 'paddingTop',
8478
- scale: 'space'
8479
- },
8480
- paddingVertical: {
8481
- property: 'paddingVertical',
8482
- scale: 'space'
8372
+ var deregisterHost = function deregisterHost(state, hostName) {
8373
+ return _objectSpread2({}, omit([hostName], state));
8374
+ };
8375
+ var addUpdatePortal = function addUpdatePortal(state, hostName, portalName, node) {
8376
+ var newState = registerHostIfNotExist(state, hostName);
8377
+ var index = newState[hostName].findIndex(function (item) {
8378
+ return item.name === portalName;
8379
+ });
8380
+ if (index !== -1) {
8381
+ return _objectSpread2(_objectSpread2({}, newState), {}, _defineProperty({}, hostName, newState[hostName].map(function (item, i) {
8382
+ if (index === i) {
8383
+ return _objectSpread2(_objectSpread2({}, item), {}, {
8384
+ node: node
8385
+ });
8386
+ }
8387
+ return item;
8388
+ })));
8483
8389
  }
8390
+ return _objectSpread2(_objectSpread2({}, newState), {}, _defineProperty({}, hostName, [].concat(_toConsumableArray(newState[hostName]), [{
8391
+ name: portalName,
8392
+ node: node
8393
+ }])));
8484
8394
  };
8485
- var radii = {
8486
- borderBottomEndRadius: {
8487
- property: 'borderBottomEndRadius',
8488
- scale: 'radii'
8489
- },
8490
- borderBottomLeftRadius: {
8491
- property: 'borderBottomLeftRadius',
8492
- scale: 'radii'
8493
- },
8494
- borderBottomRightRadius: {
8495
- property: 'borderBottomRightRadius',
8496
- scale: 'radii'
8497
- },
8498
- borderBottomStartRadius: {
8499
- property: 'borderBottomStartRadius',
8500
- scale: 'radii'
8501
- },
8502
- borderTopEndRadius: {
8503
- property: 'borderTopEndRadius',
8504
- scale: 'radii'
8505
- },
8506
- borderTopLeftRadius: {
8507
- property: 'borderTopLeftRadius',
8508
- scale: 'radii'
8509
- },
8510
- borderTopRightRadius: {
8511
- property: 'borderTopRightRadius',
8512
- scale: 'radii'
8513
- },
8514
- borderTopStartRadius: {
8515
- property: 'borderTopStartRadius',
8516
- scale: 'radii'
8517
- },
8518
- borderRadius: {
8519
- property: 'borderRadius',
8520
- scale: 'radii'
8395
+ var removePortal = function removePortal(state, hostName, portalName) {
8396
+ if (!(hostName in state)) {
8397
+ return _objectSpread2({}, state);
8521
8398
  }
8399
+ return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, hostName, state[hostName].filter(function (item) {
8400
+ return item.name !== portalName;
8401
+ })));
8522
8402
  };
8523
- var borderWidths = {
8524
- borderWidth: {
8525
- property: 'borderWidth',
8526
- scale: 'borderWidths'
8527
- },
8528
- borderBottomWidth: {
8529
- property: 'borderBottomWidth',
8530
- scale: 'borderWidths'
8531
- },
8532
- borderTopWidth: {
8533
- property: 'borderTopWidth',
8534
- scale: 'borderWidths'
8535
- },
8536
- borderLeftWidth: {
8537
- property: 'borderLeftWidth',
8538
- scale: 'borderWidths'
8539
- },
8540
- borderRightWidth: {
8541
- property: 'borderRightWidth',
8542
- scale: 'borderWidths'
8403
+ var reducer = function reducer(state, action) {
8404
+ var type = action.type;
8405
+ switch (type) {
8406
+ case ACTIONS.REGISTER_HOST:
8407
+ return registerHostIfNotExist(state, action.hostName);
8408
+ case ACTIONS.DEREGISTER_HOST:
8409
+ return deregisterHost(state, action.hostName);
8410
+ case ACTIONS.ADD_UPDATE_PORTAL:
8411
+ return addUpdatePortal(state, action.hostName, action.portalName, action.node);
8412
+ case ACTIONS.REMOVE_PORTAL:
8413
+ return removePortal(state, action.hostName, action.portalName);
8414
+ default:
8415
+ return _objectSpread2({}, state);
8543
8416
  }
8544
8417
  };
8545
- var config = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, colors), space), radii), borderWidths);
8546
- var flexPropsKey = ['alignContent', 'alignItems', 'alignSelf', 'display', 'flex', 'flexBasis', 'flexDirection', 'flexGrow', 'flexShrink', 'flexWrap', 'justifyContent'];
8547
8418
 
8548
- var _excluded$m = ["theme"];
8549
- var getThemeValue = function getThemeValue(theme, key, props) {
8550
- var propConfig = config[key];
8551
- var propValue = props[key];
8552
- if (!propValue) return undefined;
8553
- var scale = propConfig.scale,
8554
- property = propConfig.property;
8555
- switch (scale) {
8556
- case 'colors':
8557
- return _defineProperty({}, property, theme.colors[propValue]);
8558
- case 'space':
8559
- return _defineProperty({}, property, theme.space[propValue]);
8560
- case 'radii':
8561
- return _defineProperty({}, property, theme.radii[propValue]);
8562
- case 'borderWidths':
8563
- return _defineProperty({}, property, theme.borderWidths[propValue]);
8564
- }
8419
+ var PortalProviderComponent = function PortalProviderComponent(_ref) {
8420
+ var _ref$rootHostName = _ref.rootHostName,
8421
+ rootHostName = _ref$rootHostName === void 0 ? 'root' : _ref$rootHostName,
8422
+ children = _ref.children;
8423
+ var _useReducer = React.useReducer(reducer, INITIAL_STATE),
8424
+ _useReducer2 = _slicedToArray(_useReducer, 2),
8425
+ state = _useReducer2[0],
8426
+ dispatch = _useReducer2[1];
8427
+ return /*#__PURE__*/React__default["default"].createElement(PortalDispatchContext.Provider, {
8428
+ value: dispatch
8429
+ }, /*#__PURE__*/React__default["default"].createElement(PortalStateContext.Provider, {
8430
+ value: state
8431
+ }, children, /*#__PURE__*/React__default["default"].createElement(PortalHost, {
8432
+ name: rootHostName
8433
+ })));
8565
8434
  };
8566
- var mapStylePropToThemeValue = function mapStylePropToThemeValue(theme, props) {
8567
- var entries = Object.keys(props);
8568
- return entries.reduce(function (result, key) {
8569
- return _objectSpread2(_objectSpread2({}, result), getThemeValue(theme, key, props));
8570
- }, {});
8435
+ var PortalProvider = /*#__PURE__*/React.memo(PortalProviderComponent);
8436
+ PortalProvider.displayName = 'PortalProvider';
8437
+
8438
+ var nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789', 10);
8439
+ var PortalComponent = function PortalComponent(_ref) {
8440
+ var name = _ref.name,
8441
+ hostName = _ref.hostName,
8442
+ children = _ref.children,
8443
+ theme = _ref.theme;
8444
+ var defaultTheme = useTheme();
8445
+ var _usePortal = usePortal(hostName),
8446
+ addUpdatePortal = _usePortal.addPortal,
8447
+ removePortal = _usePortal.removePortal;
8448
+ var nameOrRandom = React.useMemo(function () {
8449
+ return name || nanoid();
8450
+ }, [name]);
8451
+ var ChildrenComponent = React.useMemo(function () {
8452
+ return /*#__PURE__*/React__default["default"].createElement(ThemeProvider, {
8453
+ theme: theme || defaultTheme
8454
+ }, children);
8455
+ }, [theme, children, defaultTheme]);
8456
+ React.useLayoutEffect(function () {
8457
+ addUpdatePortal(nameOrRandom, ChildrenComponent);
8458
+ return function () {
8459
+ removePortal(nameOrRandom);
8460
+ };
8461
+ }, [addUpdatePortal]);
8462
+ React.useLayoutEffect(function () {
8463
+ addUpdatePortal(nameOrRandom, ChildrenComponent);
8464
+ }, [ChildrenComponent]);
8465
+ return null;
8571
8466
  };
8572
- var configKeys = Object.keys(config);
8573
- var StyledBox = index$a(reactNative.View)(function (_ref5) {
8574
- var theme = _ref5.theme,
8575
- otherProps = _objectWithoutProperties(_ref5, _excluded$m);
8576
- var styleProps = pick(configKeys, otherProps);
8577
- var flexProps = pick(_toConsumableArray(flexPropsKey), otherProps);
8578
- return _objectSpread2(_objectSpread2({}, mapStylePropToThemeValue(theme, styleProps)), flexProps);
8467
+ var Portal = /*#__PURE__*/React.memo(PortalComponent);
8468
+ Portal.displayName = 'Portal';
8469
+ var Portal$1 = Object.assign(Portal, {
8470
+ Provider: PortalProvider,
8471
+ Host: PortalHost
8579
8472
  });
8580
8473
 
8581
- var _excluded$l = ["children", "style", "testID"];
8582
- var Box = function Box(_ref) {
8474
+ var _excluded$m = ["visible"];
8475
+ var DEFAULT_BACKDROP_OPACITY = 0.4;
8476
+ var DEFAULT_ANIMATION_CONFIG = {
8477
+ easing: reactNative.Easing.inOut(reactNative.Easing.cubic),
8478
+ useNativeDriver: reactNative.Platform.OS !== 'web',
8479
+ duration: 400
8480
+ };
8481
+ var Modal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
8583
8482
  var children = _ref.children,
8584
- style = _ref.style,
8483
+ onShow = _ref.onShow,
8484
+ onRequestClose = _ref.onRequestClose,
8585
8485
  testID = _ref.testID,
8586
- otherProps = _objectWithoutProperties(_ref, _excluded$l);
8587
- return /*#__PURE__*/React__default["default"].createElement(StyledBox, _extends$1({}, otherProps, {
8588
- style: style,
8589
- testID: testID
8590
- }), children);
8591
- };
8592
-
8593
- function _typeof(obj) {
8594
- "@babel/helpers - typeof";
8595
-
8596
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
8597
- return typeof obj;
8598
- } : function (obj) {
8599
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
8600
- }, _typeof(obj);
8601
- }
8602
-
8486
+ _ref$animationType = _ref.animationType,
8487
+ animationType = _ref$animationType === void 0 ? 'none' : _ref$animationType,
8488
+ _ref$transparent = _ref.transparent,
8489
+ transparent = _ref$transparent === void 0 ? false : _ref$transparent,
8490
+ onDismiss = _ref.onDismiss;
8491
+ var theme = useTheme();
8492
+ var animatedBackdropValue = React.useRef(new reactNative.Animated.Value(0)).current;
8493
+ var animatedModalValue = React.useRef(new reactNative.Animated.Value(0)).current;
8494
+ // Show or hide the backdrop and modal content
8495
+ var animateBackdropAndContent = React.useCallback(function (_ref2) {
8496
+ var toValue = _ref2.toValue,
8497
+ callback = _ref2.callback;
8498
+ if (animationType !== 'none') {
8499
+ // Backdrop animation
8500
+ if (!transparent) {
8501
+ reactNative.Animated.timing(animatedBackdropValue, _objectSpread2({
8502
+ toValue: toValue
8503
+ }, DEFAULT_ANIMATION_CONFIG)).start();
8504
+ }
8505
+ // Modal content animation
8506
+ reactNative.Animated.timing(animatedModalValue, _objectSpread2({
8507
+ toValue: toValue
8508
+ }, DEFAULT_ANIMATION_CONFIG)).start(callback);
8509
+ } else {
8510
+ callback === null || callback === void 0 ? void 0 : callback();
8511
+ }
8512
+ }, [animationType, onShow, transparent]);
8513
+ var backdropOpacityAnimation = animatedBackdropValue.interpolate({
8514
+ inputRange: [0, 1],
8515
+ outputRange: [0, DEFAULT_BACKDROP_OPACITY]
8516
+ });
8517
+ var modalAnimation = animatedModalValue.interpolate({
8518
+ inputRange: [0, 1],
8519
+ outputRange: animationType === 'slide' ? [reactNative.Dimensions.get('window').height, 0] : [0, 1]
8520
+ });
8521
+ React.useImperativeHandle(ref, function () {
8522
+ return {
8523
+ show: function show() {
8524
+ animateBackdropAndContent({
8525
+ toValue: 1,
8526
+ callback: onShow
8527
+ });
8528
+ },
8529
+ hide: function hide(wrapperCallback) {
8530
+ animateBackdropAndContent({
8531
+ toValue: 0,
8532
+ callback: function callback() {
8533
+ if (reactNative.Platform.OS === 'ios') {
8534
+ onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
8535
+ }
8536
+ wrapperCallback();
8537
+ }
8538
+ });
8539
+ }
8540
+ };
8541
+ }, [onDismiss, onShow, animateBackdropAndContent]);
8542
+ // Back button handler
8543
+ React.useEffect(function () {
8544
+ var backHandler = reactNative.BackHandler.addEventListener('hardwareBackPress', function () {
8545
+ onRequestClose === null || onRequestClose === void 0 ? void 0 : onRequestClose();
8546
+ return true;
8547
+ });
8548
+ return function () {
8549
+ return backHandler.remove();
8550
+ };
8551
+ }, [onRequestClose]);
8552
+ return /*#__PURE__*/React__default["default"].createElement(Portal$1, null, /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
8553
+ style: _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
8554
+ backgroundColor: transparent ? 'transparent' : theme.colors.overlayGlobalSurface,
8555
+ opacity: animationType !== 'none' ? backdropOpacityAnimation : DEFAULT_BACKDROP_OPACITY
8556
+ })
8557
+ }), /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
8558
+ testID: testID,
8559
+ style: _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
8560
+ opacity: animationType === 'fade' ? modalAnimation : 1,
8561
+ transform: [{
8562
+ translateY: animationType === 'slide' ? modalAnimation : 0
8563
+ }]
8564
+ })
8565
+ }, children));
8566
+ });
8567
+ var ModalWrapper = function ModalWrapper(_ref3) {
8568
+ var _ref3$visible = _ref3.visible,
8569
+ visible = _ref3$visible === void 0 ? true : _ref3$visible,
8570
+ props = _objectWithoutProperties(_ref3, _excluded$m);
8571
+ var modalRef = React.useRef(null);
8572
+ var _useState = React.useState(visible),
8573
+ _useState2 = _slicedToArray(_useState, 2),
8574
+ internalVisible = _useState2[0],
8575
+ setInternalVisible = _useState2[1];
8576
+ React.useEffect(function () {
8577
+ if (visible) {
8578
+ setInternalVisible(true);
8579
+ } else {
8580
+ var _modalRef$current;
8581
+ // Wait for animation to finish before hiding the modal
8582
+ (_modalRef$current = modalRef.current) === null || _modalRef$current === void 0 ? void 0 : _modalRef$current.hide(function () {
8583
+ return setInternalVisible(false);
8584
+ });
8585
+ }
8586
+ }, [visible]);
8587
+ React.useEffect(function () {
8588
+ if (internalVisible) {
8589
+ var _modalRef$current2;
8590
+ (_modalRef$current2 = modalRef.current) === null || _modalRef$current2 === void 0 ? void 0 : _modalRef$current2.show();
8591
+ }
8592
+ }, [internalVisible]);
8593
+ return internalVisible ? /*#__PURE__*/React__default["default"].createElement(Modal, _extends$1({
8594
+ ref: modalRef
8595
+ }, props)) : null;
8596
+ };
8597
+
8598
+ var BottomSheet = function BottomSheet(_ref) {
8599
+ var open = _ref.open,
8600
+ header = _ref.header,
8601
+ footer = _ref.footer,
8602
+ children = _ref.children,
8603
+ onAnimationEnd = _ref.onAnimationEnd,
8604
+ onOpen = _ref.onOpen,
8605
+ onRequestClose = _ref.onRequestClose,
8606
+ onDismiss = _ref.onDismiss,
8607
+ _ref$showCloseButton = _ref.showCloseButton,
8608
+ showCloseButton = _ref$showCloseButton === void 0 ? true : _ref$showCloseButton,
8609
+ _ref$hasBackdrop = _ref.hasBackdrop,
8610
+ hasBackdrop = _ref$hasBackdrop === void 0 ? true : _ref$hasBackdrop,
8611
+ _ref$showDivider = _ref.showDivider,
8612
+ showDivider = _ref$showDivider === void 0 ? false : _ref$showDivider,
8613
+ style = _ref.style,
8614
+ testID = _ref.testID,
8615
+ _ref$keyboardAvoiding = _ref.keyboardAvoidingViewProps,
8616
+ keyboardAvoidingViewProps = _ref$keyboardAvoiding === void 0 ? {} : _ref$keyboardAvoiding;
8617
+ var _Dimensions$get = reactNative.Dimensions.get('window'),
8618
+ height = _Dimensions$get.height;
8619
+ // Internal state to control modal open/close timing with animation
8620
+ var _useState = React.useState(open),
8621
+ _useState2 = _slicedToArray(_useState, 2),
8622
+ visible = _useState2[0],
8623
+ setVisibility = _useState2[1];
8624
+ var animatedValue = React.useRef(new reactNative.Animated.Value(open ? 0 : 1));
8625
+ var _useState3 = React.useState(showDivider),
8626
+ _useState4 = _slicedToArray(_useState3, 2),
8627
+ internalShowDivider = _useState4[0],
8628
+ setInternalShowDivider = _useState4[1];
8629
+ React.useEffect(function () {
8630
+ // Show the modal before the open animation start
8631
+ if (open && !visible) {
8632
+ setVisibility(open);
8633
+ }
8634
+ // Delay closing the modal until after the closing animation end
8635
+ animatedValue.current.removeAllListeners();
8636
+ animatedValue.current.addListener(function (_ref2) {
8637
+ var value = _ref2.value;
8638
+ var endValueOfTransition = open ? 1 : 0;
8639
+ if (endValueOfTransition === 0 && value === endValueOfTransition) {
8640
+ setVisibility(false);
8641
+ onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
8642
+ }
8643
+ });
8644
+ return function () {
8645
+ return animatedValue.current.removeAllListeners();
8646
+ };
8647
+ }, [open]);
8648
+ // Animation
8649
+ React.useEffect(function () {
8650
+ var animation = reactNative.Animated.timing(animatedValue.current, {
8651
+ toValue: open ? 1 : 0,
8652
+ easing: reactNative.Easing.inOut(reactNative.Easing.cubic),
8653
+ useNativeDriver: true
8654
+ });
8655
+ animation.start(onAnimationEnd);
8656
+ return function () {
8657
+ return animation.stop();
8658
+ };
8659
+ }, [open]);
8660
+ var interpolateY = animatedValue.current.interpolate({
8661
+ inputRange: [0, 1],
8662
+ outputRange: [height, 0]
8663
+ });
8664
+ // Backdrop opacity
8665
+ var interpolateOpacity = hasBackdrop ? animatedValue.current.interpolate({
8666
+ inputRange: [0, 1],
8667
+ outputRange: [0, 0.48]
8668
+ }) : 0;
8669
+ var BottomSheetContextValue = React.useMemo(function () {
8670
+ return {
8671
+ setInternalShowDivider: setInternalShowDivider
8672
+ };
8673
+ }, [setInternalShowDivider]);
8674
+ return /*#__PURE__*/React__default["default"].createElement(ModalWrapper, {
8675
+ visible: visible,
8676
+ onRequestClose: onRequestClose,
8677
+ transparent: true,
8678
+ testID: testID,
8679
+ onShow: onOpen
8680
+ }, /*#__PURE__*/React__default["default"].createElement(StyledWrapper$9, {
8681
+ pointerEvents: "box-none"
8682
+ }, /*#__PURE__*/React__default["default"].createElement(StyledKeyboardAvoidingView, _extends$1({
8683
+ behavior: reactNative.Platform.OS === 'ios' ? 'padding' : 'height'
8684
+ }, keyboardAvoidingViewProps), /*#__PURE__*/React__default["default"].createElement(StyledBackdrop$2, {
8685
+ style: {
8686
+ opacity: interpolateOpacity
8687
+ },
8688
+ onPress: onRequestClose
8689
+ }), /*#__PURE__*/React__default["default"].createElement(StyledBottomSheet, {
8690
+ style: [style, {
8691
+ transform: [{
8692
+ scaleY: height > 0 ? 1 : 0
8693
+ }, {
8694
+ translateY: interpolateY
8695
+ }]
8696
+ }]
8697
+ }, header !== undefined ? /*#__PURE__*/React__default["default"].createElement(Header, {
8698
+ content: header,
8699
+ showDivider: internalShowDivider,
8700
+ onRequestClose: onRequestClose,
8701
+ showCloseButton: showCloseButton
8702
+ }) : null, /*#__PURE__*/React__default["default"].createElement(BottomSheetContext.Provider, {
8703
+ value: BottomSheetContextValue
8704
+ }, children), footer ? /*#__PURE__*/React__default["default"].createElement(Footer$1, {
8705
+ showDivider: showDivider
8706
+ }, footer) : null))));
8707
+ };
8708
+ var BottomSheet$1 = Object.assign(BottomSheet, {
8709
+ ScrollView: BottomSheetScrollView
8710
+ });
8711
+
8712
+ var colors = {
8713
+ backgroundColor: {
8714
+ property: 'backgroundColor',
8715
+ scale: 'colors'
8716
+ },
8717
+ bgColor: {
8718
+ property: 'backgroundColor',
8719
+ scale: 'colors'
8720
+ },
8721
+ borderColor: {
8722
+ property: 'borderColor',
8723
+ scale: 'colors'
8724
+ },
8725
+ borderTopColor: {
8726
+ property: 'borderTopColor',
8727
+ scale: 'colors'
8728
+ },
8729
+ borderBottomColor: {
8730
+ property: 'borderBottomColor',
8731
+ scale: 'colors'
8732
+ },
8733
+ borderStartColor: {
8734
+ property: 'borderStartColor',
8735
+ scale: 'colors'
8736
+ },
8737
+ borderEndColor: {
8738
+ property: 'borderEndColor',
8739
+ scale: 'colors'
8740
+ },
8741
+ borderLeftColor: {
8742
+ property: 'borderLeftColor',
8743
+ scale: 'colors'
8744
+ },
8745
+ borderRightColor: {
8746
+ property: 'borderRightColor',
8747
+ scale: 'colors'
8748
+ }
8749
+ };
8750
+ var space = {
8751
+ margin: {
8752
+ property: 'margin',
8753
+ scale: 'space'
8754
+ },
8755
+ marginBottom: {
8756
+ property: 'marginBottom',
8757
+ scale: 'space'
8758
+ },
8759
+ marginEnd: {
8760
+ property: 'marginEnd',
8761
+ scale: 'space'
8762
+ },
8763
+ marginHorizontal: {
8764
+ property: 'marginHorizontal',
8765
+ scale: 'space'
8766
+ },
8767
+ marginLeft: {
8768
+ property: 'marginLeft',
8769
+ scale: 'space'
8770
+ },
8771
+ marginRight: {
8772
+ property: 'marginRight',
8773
+ scale: 'space'
8774
+ },
8775
+ marginStart: {
8776
+ property: 'marginStart',
8777
+ scale: 'space'
8778
+ },
8779
+ marginTop: {
8780
+ property: 'marginTop',
8781
+ scale: 'space'
8782
+ },
8783
+ marginVertical: {
8784
+ property: 'marginVertical',
8785
+ scale: 'space'
8786
+ },
8787
+ padding: {
8788
+ property: 'padding',
8789
+ scale: 'space'
8790
+ },
8791
+ paddingBottom: {
8792
+ property: 'paddingBottom',
8793
+ scale: 'space'
8794
+ },
8795
+ paddingEnd: {
8796
+ property: 'paddingEnd',
8797
+ scale: 'space'
8798
+ },
8799
+ paddingHorizontal: {
8800
+ property: 'paddingHorizontal',
8801
+ scale: 'space'
8802
+ },
8803
+ paddingLeft: {
8804
+ property: 'paddingLeft',
8805
+ scale: 'space'
8806
+ },
8807
+ paddingRight: {
8808
+ property: 'paddingRight',
8809
+ scale: 'space'
8810
+ },
8811
+ paddingStart: {
8812
+ property: 'paddingStart',
8813
+ scale: 'space'
8814
+ },
8815
+ paddingTop: {
8816
+ property: 'paddingTop',
8817
+ scale: 'space'
8818
+ },
8819
+ paddingVertical: {
8820
+ property: 'paddingVertical',
8821
+ scale: 'space'
8822
+ }
8823
+ };
8824
+ var radii = {
8825
+ borderBottomEndRadius: {
8826
+ property: 'borderBottomEndRadius',
8827
+ scale: 'radii'
8828
+ },
8829
+ borderBottomLeftRadius: {
8830
+ property: 'borderBottomLeftRadius',
8831
+ scale: 'radii'
8832
+ },
8833
+ borderBottomRightRadius: {
8834
+ property: 'borderBottomRightRadius',
8835
+ scale: 'radii'
8836
+ },
8837
+ borderBottomStartRadius: {
8838
+ property: 'borderBottomStartRadius',
8839
+ scale: 'radii'
8840
+ },
8841
+ borderTopEndRadius: {
8842
+ property: 'borderTopEndRadius',
8843
+ scale: 'radii'
8844
+ },
8845
+ borderTopLeftRadius: {
8846
+ property: 'borderTopLeftRadius',
8847
+ scale: 'radii'
8848
+ },
8849
+ borderTopRightRadius: {
8850
+ property: 'borderTopRightRadius',
8851
+ scale: 'radii'
8852
+ },
8853
+ borderTopStartRadius: {
8854
+ property: 'borderTopStartRadius',
8855
+ scale: 'radii'
8856
+ },
8857
+ borderRadius: {
8858
+ property: 'borderRadius',
8859
+ scale: 'radii'
8860
+ }
8861
+ };
8862
+ var borderWidths = {
8863
+ borderWidth: {
8864
+ property: 'borderWidth',
8865
+ scale: 'borderWidths'
8866
+ },
8867
+ borderBottomWidth: {
8868
+ property: 'borderBottomWidth',
8869
+ scale: 'borderWidths'
8870
+ },
8871
+ borderTopWidth: {
8872
+ property: 'borderTopWidth',
8873
+ scale: 'borderWidths'
8874
+ },
8875
+ borderLeftWidth: {
8876
+ property: 'borderLeftWidth',
8877
+ scale: 'borderWidths'
8878
+ },
8879
+ borderRightWidth: {
8880
+ property: 'borderRightWidth',
8881
+ scale: 'borderWidths'
8882
+ }
8883
+ };
8884
+ var config = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, colors), space), radii), borderWidths);
8885
+ var flexPropsKey = ['alignContent', 'alignItems', 'alignSelf', 'display', 'flex', 'flexBasis', 'flexDirection', 'flexGrow', 'flexShrink', 'flexWrap', 'justifyContent'];
8886
+
8887
+ var _excluded$l = ["theme"];
8888
+ var getThemeValue = function getThemeValue(theme, key, props) {
8889
+ var propConfig = config[key];
8890
+ var propValue = props[key];
8891
+ if (!propValue) return undefined;
8892
+ var scale = propConfig.scale,
8893
+ property = propConfig.property;
8894
+ switch (scale) {
8895
+ case 'colors':
8896
+ return _defineProperty({}, property, theme.colors[propValue]);
8897
+ case 'space':
8898
+ return _defineProperty({}, property, theme.space[propValue]);
8899
+ case 'radii':
8900
+ return _defineProperty({}, property, theme.radii[propValue]);
8901
+ case 'borderWidths':
8902
+ return _defineProperty({}, property, theme.borderWidths[propValue]);
8903
+ }
8904
+ };
8905
+ var mapStylePropToThemeValue = function mapStylePropToThemeValue(theme, props) {
8906
+ var entries = Object.keys(props);
8907
+ return entries.reduce(function (result, key) {
8908
+ return _objectSpread2(_objectSpread2({}, result), getThemeValue(theme, key, props));
8909
+ }, {});
8910
+ };
8911
+ var configKeys = Object.keys(config);
8912
+ var StyledBox = index$a(reactNative.View)(function (_ref5) {
8913
+ var theme = _ref5.theme,
8914
+ otherProps = _objectWithoutProperties(_ref5, _excluded$l);
8915
+ var styleProps = pick(configKeys, otherProps);
8916
+ var flexProps = pick(_toConsumableArray(flexPropsKey), otherProps);
8917
+ return _objectSpread2(_objectSpread2({}, mapStylePropToThemeValue(theme, styleProps)), flexProps);
8918
+ });
8919
+
8920
+ var _excluded$k = ["children", "style", "testID"];
8921
+ var Box = function Box(_ref) {
8922
+ var children = _ref.children,
8923
+ style = _ref.style,
8924
+ testID = _ref.testID,
8925
+ otherProps = _objectWithoutProperties(_ref, _excluded$k);
8926
+ return /*#__PURE__*/React__default["default"].createElement(StyledBox, _extends$1({}, otherProps, {
8927
+ style: style,
8928
+ testID: testID
8929
+ }), children);
8930
+ };
8931
+
8932
+ function _typeof(obj) {
8933
+ "@babel/helpers - typeof";
8934
+
8935
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
8936
+ return typeof obj;
8937
+ } : function (obj) {
8938
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
8939
+ }, _typeof(obj);
8940
+ }
8941
+
8603
8942
  function requiredArgs(required, args) {
8604
8943
  if (args.length < required) {
8605
8944
  throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
@@ -11164,7 +11503,7 @@ var Calendar = function Calendar(_ref) {
11164
11503
  })));
11165
11504
  };
11166
11505
 
11167
- var _excluded$k = ["rounded", "size", "testID", "style"];
11506
+ var _excluded$j = ["rounded", "size", "testID", "style"];
11168
11507
  var Image = function Image(_ref) {
11169
11508
  var _ref$rounded = _ref.rounded,
11170
11509
  rounded = _ref$rounded === void 0 ? false : _ref$rounded,
@@ -11172,7 +11511,7 @@ var Image = function Image(_ref) {
11172
11511
  size = _ref$size === void 0 ? '6xlarge' : _ref$size,
11173
11512
  testID = _ref.testID,
11174
11513
  style = _ref.style,
11175
- imageNativeProps = _objectWithoutProperties(_ref, _excluded$k);
11514
+ imageNativeProps = _objectWithoutProperties(_ref, _excluded$j);
11176
11515
  var theme = useTheme();
11177
11516
  var imageSize = theme.__hd__.image.sizes[size];
11178
11517
  return /*#__PURE__*/React__default["default"].createElement(reactNative.Image, _extends$1({
@@ -11377,12 +11716,12 @@ var Indicator = index$a(reactNative.View)(function (_ref2) {
11377
11716
  };
11378
11717
  });
11379
11718
 
11380
- var _excluded$j = ["intent", "children"];
11719
+ var _excluded$i = ["intent", "children"];
11381
11720
  var DataCard = function DataCard(_ref) {
11382
11721
  var _ref$intent = _ref.intent,
11383
11722
  intent = _ref$intent === void 0 ? 'info' : _ref$intent,
11384
11723
  children = _ref.children,
11385
- nativeProps = _objectWithoutProperties(_ref, _excluded$j);
11724
+ nativeProps = _objectWithoutProperties(_ref, _excluded$i);
11386
11725
  return /*#__PURE__*/React__default["default"].createElement(StyledDataCard, nativeProps, /*#__PURE__*/React__default["default"].createElement(Indicator, {
11387
11726
  themeIntent: intent,
11388
11727
  testID: "data-card-indicator"
@@ -11400,11 +11739,11 @@ var StyledCard$1 = index$a(reactNative.View)(function (_ref) {
11400
11739
  });
11401
11740
  });
11402
11741
 
11403
- var _excluded$i = ["intent", "children"];
11742
+ var _excluded$h = ["intent", "children"];
11404
11743
  var Card = function Card(_ref) {
11405
11744
  var intent = _ref.intent,
11406
11745
  children = _ref.children,
11407
- nativeProps = _objectWithoutProperties(_ref, _excluded$i);
11746
+ nativeProps = _objectWithoutProperties(_ref, _excluded$h);
11408
11747
  return /*#__PURE__*/React__default["default"].createElement(StyledCard$1, _extends$1({}, nativeProps, {
11409
11748
  themeIntent: intent
11410
11749
  }), children);
@@ -11611,7 +11950,7 @@ var CardCarousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
11611
11950
  });
11612
11951
  CardCarousel.displayName = 'CardCarousel';
11613
11952
 
11614
- var _excluded$h = ["items", "onItemIndexChange", "renderActions", "selectedItemIndex", "style", "testID"];
11953
+ var _excluded$g = ["items", "onItemIndexChange", "renderActions", "selectedItemIndex", "style", "testID"];
11615
11954
  function useStateFromProp(initialValue) {
11616
11955
  var _useState = React.useState(initialValue),
11617
11956
  _useState2 = _slicedToArray(_useState, 2),
@@ -11630,7 +11969,7 @@ var Carousel = function Carousel(_ref) {
11630
11969
  selectedItemIndex = _ref$selectedItemInde === void 0 ? 0 : _ref$selectedItemInde,
11631
11970
  style = _ref.style,
11632
11971
  testID = _ref.testID,
11633
- nativeProps = _objectWithoutProperties(_ref, _excluded$h);
11972
+ nativeProps = _objectWithoutProperties(_ref, _excluded$g);
11634
11973
  var carouselRef = React.useRef(null);
11635
11974
  var _useStateFromProp = useStateFromProp(selectedItemIndex),
11636
11975
  _useStateFromProp2 = _slicedToArray(_useStateFromProp, 2),
@@ -11959,7 +12298,7 @@ var StyledErrorAndMaxLengthContainer = index$a(reactNative.View)(function () {
11959
12298
  };
11960
12299
  });
11961
12300
 
11962
- var _excluded$g = ["label", "prefix", "suffix", "style", "textStyle", "testID", "accessibilityLabelledBy", "error", "required", "editable", "disabled", "loading", "maxLength", "hideCharacterCount", "helpText", "value", "defaultValue", "renderInputValue", "allowFontScaling", "variant"];
12301
+ var _excluded$f = ["label", "prefix", "suffix", "style", "textStyle", "testID", "accessibilityLabelledBy", "error", "required", "editable", "disabled", "loading", "maxLength", "hideCharacterCount", "helpText", "value", "defaultValue", "renderInputValue", "allowFontScaling", "variant"];
11963
12302
  var getState$1 = function getState(_ref) {
11964
12303
  var disabled = _ref.disabled,
11965
12304
  error = _ref.error,
@@ -12011,7 +12350,7 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
12011
12350
  allowFontScaling = _ref2$allowFontScalin === void 0 ? false : _ref2$allowFontScalin,
12012
12351
  _ref2$variant = _ref2.variant,
12013
12352
  variant = _ref2$variant === void 0 ? 'text' : _ref2$variant,
12014
- nativeProps = _objectWithoutProperties(_ref2, _excluded$g);
12353
+ nativeProps = _objectWithoutProperties(_ref2, _excluded$f);
12015
12354
  var displayText = (_ref3 = value !== undefined ? value : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : '';
12016
12355
  var isEmptyValue = displayText.length === 0;
12017
12356
  var actualSuffix = loading ? 'loading' : suffix;
@@ -12432,719 +12771,393 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
12432
12771
  style: style
12433
12772
  })), /*#__PURE__*/React__default["default"].createElement(BottomSheet$1, {
12434
12773
  open: open,
12435
- onRequestClose: function onRequestClose() {
12436
- return setOpen(false);
12437
- },
12438
- header: label,
12439
- footer: /*#__PURE__*/React__default["default"].createElement(CompoundButton, {
12440
- variant: "text",
12441
- text: confirmLabel,
12442
- onPress: function onPress() {
12443
- if (selectingDate) {
12444
- onChange(selectingDate);
12445
- }
12446
- setOpen(false);
12447
- }
12448
- })
12449
- }, /*#__PURE__*/React__default["default"].createElement(StyledPickerWrapper$1, null, /*#__PURE__*/React__default["default"].createElement(DateTimePicker__default["default"], {
12450
- testID: "datePickerIOS",
12451
- value: selectingDate,
12452
- minimumDate: minDate,
12453
- maximumDate: maxDate,
12454
- mode: "date",
12455
- onChange: function onChange(_, date) {
12456
- if (date) {
12457
- setSelectingDate(date);
12458
- }
12459
- },
12460
- display: "spinner",
12461
- style: {
12462
- flex: 1
12463
- },
12464
- textColor: theme.colors.onDefaultGlobalSurface
12465
- }))));
12466
- };
12467
-
12468
- var _excluded$f = ["variant"];
12469
- var DatePicker = function DatePicker(_ref) {
12470
- var _ref$variant = _ref.variant,
12471
- variant = _ref$variant === void 0 ? 'default' : _ref$variant,
12472
- props = _objectWithoutProperties(_ref, _excluded$f);
12473
- if (variant === 'calendar') {
12474
- return /*#__PURE__*/React__default["default"].createElement(DatePickerCalendar, props);
12475
- }
12476
- if (reactNative.Platform.OS === 'ios') {
12477
- return /*#__PURE__*/React__default["default"].createElement(DatePickerIOS, props);
12478
- }
12479
- return /*#__PURE__*/React__default["default"].createElement(DatePickerAndroid, props);
12480
- };
12481
-
12482
- var AnimatedPressable$1 = reactNative.Animated.createAnimatedComponent(reactNative.Pressable);
12483
- var StyledContainer$3 = index$a(reactNative.View)(function (_ref) {
12484
- var theme = _ref.theme,
12485
- enableShadow = _ref.enableShadow;
12486
- return _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
12487
- shadowColor: enableShadow ? theme.__hd__.drawer.colors.shadow : 'transparent',
12488
- shadowOffset: theme.__hd__.drawer.shadows.offset,
12489
- shadowOpacity: theme.__hd__.drawer.shadows.opacity,
12490
- shadowRadius: theme.__hd__.drawer.shadows.radius,
12491
- overflow: 'hidden',
12492
- zIndex: 9999,
12493
- elevation: 9999
12494
- });
12495
- });
12496
- var StyledDragableContainer = index$a(reactNative.View)(function (_ref2) {
12497
- var theme = _ref2.theme,
12498
- enableShadow = _ref2.enableShadow;
12499
- return _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
12500
- shadowColor: enableShadow ? theme.__hd__.drawer.colors.shadow : 'transparent',
12501
- shadowOffset: theme.__hd__.drawer.shadows.offset,
12502
- shadowOpacity: theme.__hd__.drawer.shadows.opacity,
12503
- shadowRadius: theme.__hd__.drawer.shadows.radius,
12504
- overflow: 'hidden',
12505
- zIndex: 9999,
12506
- elevation: 9999,
12507
- flexDirection: 'column-reverse'
12508
- });
12509
- });
12510
- var StyledBackdrop$1 = index$a(AnimatedPressable$1)(function (_ref3) {
12511
- var theme = _ref3.theme;
12512
- return _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
12513
- backgroundColor: theme.__hd__.drawer.colors.backdrop
12514
- });
12515
- });
12516
- var StyledDrawerContainer = index$a(reactNative.Animated.View)(function (_ref4) {
12517
- var theme = _ref4.theme,
12518
- enableShadow = _ref4.enableShadow;
12519
- return {
12520
- borderBottomLeftRadius: theme.__hd__.drawer.radii["default"],
12521
- borderBottomRightRadius: theme.__hd__.drawer.radii["default"],
12522
- backgroundColor: theme.__hd__.drawer.colors.background,
12523
- elevation: enableShadow ? theme.__hd__.drawer.shadows.elevation : undefined,
12524
- overflow: 'hidden'
12525
- };
12526
- });
12527
- var StyledDragableDrawerContainer = index$a(reactNative.Animated.View)(function (_ref5) {
12528
- var theme = _ref5.theme,
12529
- enableShadow = _ref5.enableShadow;
12530
- return {
12531
- borderTopLeftRadius: theme.__hd__.drawer.radii["default"],
12532
- borderTopRightRadius: theme.__hd__.drawer.radii["default"],
12533
- backgroundColor: theme.__hd__.drawer.colors.background,
12534
- elevation: enableShadow ? theme.__hd__.drawer.shadows.elevation : undefined,
12535
- overflow: 'hidden',
12536
- maxHeight: '100%'
12537
- };
12538
- });
12539
- var StyledHandlerContainer = index$a(reactNative.View)(function (_ref6) {
12540
- var theme = _ref6.theme;
12541
- return {
12542
- backgroundColor: theme.__hd__.drawer.colors.background,
12543
- paddingVertical: theme.__hd__.drawer.space.handlerPaddingVertical,
12544
- alignItems: 'center'
12545
- };
12546
- });
12547
- var StyledHandler = index$a(reactNative.View)(function (_ref7) {
12548
- var theme = _ref7.theme;
12549
- return {
12550
- width: theme.__hd__.drawer.sizes.handlerWidth,
12551
- height: theme.__hd__.drawer.sizes.handlerHeight,
12552
- backgroundColor: theme.__hd__.drawer.colors.handler,
12553
- borderRadius: theme.__hd__.drawer.radii.handler
12554
- };
12555
- });
12556
-
12557
- var getOffset = function getOffset(height, percentage) {
12558
- if (percentage < 0) return height;
12559
- if (percentage > 100) return 0;
12560
- return height * ((100 - percentage) / 100);
12561
- };
12562
- var calculateSnapPointsData = function calculateSnapPointsData(minimumHeight, height, snapPoints) {
12563
- var filteredSnapPoints = snapPoints.filter(function (value) {
12564
- return value >= minimumHeight;
12565
- });
12566
- var snapPointsOffsetValues = [minimumHeight].concat(_toConsumableArray(filteredSnapPoints)).map(function (value) {
12567
- return getOffset(height, value);
12568
- });
12569
- var uniqSnapPointOffsetValues = Array.from(new Set([].concat(_toConsumableArray(snapPointsOffsetValues), [0])));
12570
- return {
12571
- list: uniqSnapPointOffsetValues,
12572
- minHeightOffset: Math.max.apply(Math, uniqSnapPointOffsetValues),
12573
- maxHeightOffset: 0 // Max height
12574
- };
12575
- };
12576
-
12577
- var calculateAnimatedToValue = function calculateAnimatedToValue(position, heightSnapPoints) {
12578
- var distances = heightSnapPoints.map(function (height) {
12579
- return Math.abs(position - height);
12580
- });
12581
- var minIndex = distances.indexOf(Math.min.apply(Math, _toConsumableArray(distances)));
12582
- return heightSnapPoints[minIndex];
12583
- };
12584
-
12585
- var DragableDrawer = function DragableDrawer(_ref) {
12586
- var children = _ref.children,
12587
- initialHeightPercentage = _ref.initialHeightPercentage,
12588
- _ref$minimumHeightPer = _ref.minimumHeightPercentage,
12589
- minimumHeightPercentage = _ref$minimumHeightPer === void 0 ? 10 : _ref$minimumHeightPer,
12590
- _ref$snapPoints = _ref.snapPoints,
12591
- snapPoints = _ref$snapPoints === void 0 ? [] : _ref$snapPoints,
12592
- onExpanded = _ref.onExpanded,
12593
- onCollapsed = _ref.onCollapsed,
12594
- testID = _ref.testID;
12595
- var _useState = React.useState(0),
12596
- _useState2 = _slicedToArray(_useState, 2),
12597
- height = _useState2[0],
12598
- setHeight = _useState2[1];
12599
- var baseHeightForMeasure = React.useRef(0);
12600
- var snapPointsData = React.useRef({
12601
- list: [],
12602
- minHeightOffset: 0,
12603
- maxHeightOffset: 0
12604
- });
12605
- // Track drag
12606
- var pan = React.useRef(new reactNative.Animated.Value(0)).current;
12607
- var offset = React.useRef(0);
12608
- var offsetBeforePan = React.useRef(0);
12609
- var _useState3 = React.useState(-1),
12610
- _useState4 = _slicedToArray(_useState3, 2),
12611
- animatedToValue = _useState4[0],
12612
- setAnimatedToValue = _useState4[1];
12613
- React.useEffect(function () {
12614
- var id = pan.addListener(function (_ref2) {
12615
- var value = _ref2.value;
12616
- offset.current = value;
12617
- });
12618
- return function () {
12619
- return pan.removeListener(id);
12620
- };
12621
- }, []);
12622
- React.useEffect(function () {
12623
- if (height > 0) {
12624
- var initialOffset = getOffset(height, initialHeightPercentage || minimumHeightPercentage);
12625
- setAnimatedToValue(initialOffset);
12626
- }
12627
- }, [height]);
12628
- React.useEffect(function () {
12629
- if (height > 0) {
12630
- pan.setValue(height);
12631
- offset.current = height;
12632
- baseHeightForMeasure.current = height;
12633
- // Calculate snap points information
12634
- snapPointsData.current = calculateSnapPointsData(minimumHeightPercentage, height, snapPoints);
12635
- }
12636
- }, [height, minimumHeightPercentage]);
12637
- React.useEffect(function () {
12638
- if (animatedToValue >= 0) {
12639
- var animation = reactNative.Animated.timing(pan, {
12640
- toValue: animatedToValue,
12641
- useNativeDriver: true,
12642
- easing: reactNative.Easing.inOut(reactNative.Easing.cubic)
12643
- });
12644
- animation.start(function () {
12645
- if (animatedToValue === 0) {
12646
- onExpanded === null || onExpanded === void 0 ? void 0 : onExpanded();
12647
- } else if (animatedToValue === getOffset(height, minimumHeightPercentage)) {
12648
- onCollapsed === null || onCollapsed === void 0 ? void 0 : onCollapsed();
12649
- }
12650
- setAnimatedToValue(-1);
12651
- });
12652
- return function () {
12653
- return animation.stop();
12654
- };
12655
- }
12656
- }, [animatedToValue]);
12657
- var panResponder = React.useRef(reactNative.PanResponder.create({
12658
- onMoveShouldSetPanResponder: function onMoveShouldSetPanResponder() {
12659
- return true;
12660
- },
12661
- onPanResponderGrant: function onPanResponderGrant() {
12662
- offsetBeforePan.current = offset.current;
12663
- pan.setOffset(offset.current);
12664
- pan.setValue(0);
12665
- },
12666
- onPanResponderMove: function onPanResponderMove(_, gesture) {
12667
- var _snapPointsData$curre;
12668
- var panDistance = gesture.dy;
12669
- // Moving toward top, stop at highest snap point
12670
- if (offsetBeforePan.current + panDistance < 0) {
12671
- pan.setValue(-offsetBeforePan.current);
12672
- return;
12774
+ onRequestClose: function onRequestClose() {
12775
+ return setOpen(false);
12776
+ },
12777
+ header: label,
12778
+ footer: /*#__PURE__*/React__default["default"].createElement(CompoundButton, {
12779
+ variant: "text",
12780
+ text: confirmLabel,
12781
+ onPress: function onPress() {
12782
+ if (selectingDate) {
12783
+ onChange(selectingDate);
12784
+ }
12785
+ setOpen(false);
12673
12786
  }
12674
- // Moving toward bottom, stop at lowest snap point
12675
- if (offsetBeforePan.current + panDistance > ((_snapPointsData$curre = snapPointsData.current) === null || _snapPointsData$curre === void 0 ? void 0 : _snapPointsData$curre.minHeightOffset)) {
12676
- pan.setValue(baseHeightForMeasure.current - baseHeightForMeasure.current * (minimumHeightPercentage / 100) - offsetBeforePan.current);
12677
- return;
12787
+ })
12788
+ }, /*#__PURE__*/React__default["default"].createElement(StyledPickerWrapper$1, null, /*#__PURE__*/React__default["default"].createElement(DateTimePicker__default["default"], {
12789
+ testID: "datePickerIOS",
12790
+ value: selectingDate,
12791
+ minimumDate: minDate,
12792
+ maximumDate: maxDate,
12793
+ mode: "date",
12794
+ onChange: function onChange(_, date) {
12795
+ if (date) {
12796
+ setSelectingDate(date);
12678
12797
  }
12679
- pan.setValue(panDistance);
12680
12798
  },
12681
- onPanResponderRelease: function onPanResponderRelease(_, gesture) {
12682
- pan.flattenOffset();
12683
- // Attach to nearest snappoint
12684
- var panDistance = gesture.dy;
12685
- var offsetAfterPan = offsetBeforePan.current + panDistance;
12686
- var animatedValue = calculateAnimatedToValue(offsetAfterPan, snapPointsData.current.list);
12687
- setAnimatedToValue(animatedValue);
12688
- }
12689
- })).current;
12690
- return /*#__PURE__*/React__default["default"].createElement(StyledDragableContainer, {
12691
- testID: testID,
12692
- enableShadow: true,
12693
- pointerEvents: "box-none"
12694
- }, /*#__PURE__*/React__default["default"].createElement(StyledDragableDrawerContainer, {
12695
- enableShadow: true,
12799
+ display: "spinner",
12696
12800
  style: {
12697
- transform: [{
12698
- scaleY: baseHeightForMeasure.current > 0 ? 1 : 0
12699
- }, {
12700
- translateY: pan
12701
- }]
12801
+ flex: 1
12702
12802
  },
12703
- onLayout: function onLayout(_ref3) {
12704
- var nativeEvent = _ref3.nativeEvent;
12705
- setHeight(nativeEvent.layout.height);
12706
- }
12707
- }, /*#__PURE__*/React__default["default"].createElement(StyledHandlerContainer, panResponder.panHandlers, /*#__PURE__*/React__default["default"].createElement(StyledHandler, null)), children));
12803
+ textColor: theme.colors.onDefaultGlobalSurface
12804
+ }))));
12708
12805
  };
12709
12806
 
12710
- var Drawer = function Drawer(_ref) {
12711
- var visible = _ref.visible,
12712
- children = _ref.children,
12713
- _ref$hasBackdrop = _ref.hasBackdrop,
12714
- hasBackdrop = _ref$hasBackdrop === void 0 ? true : _ref$hasBackdrop,
12715
- onDismiss = _ref.onDismiss,
12716
- testID = _ref.testID;
12717
- var animatedValue = React.useRef(new reactNative.Animated.Value(visible ? 1 : 0)).current;
12718
- var _useState = React.useState(reactNative.Dimensions.get('window').height),
12719
- _useState2 = _slicedToArray(_useState, 2),
12720
- height = _useState2[0],
12721
- setHeight = _useState2[1];
12722
- var enableShadow = visible && !hasBackdrop;
12723
- var interpolateTranslateY = animatedValue.interpolate({
12724
- inputRange: [0, 1],
12725
- outputRange: [-height, 0]
12726
- });
12727
- var interpolateBackdropOpacity = hasBackdrop ? animatedValue.interpolate({
12728
- inputRange: [0, 1],
12729
- outputRange: [0, 0.35]
12730
- }) : 0;
12731
- React.useEffect(function () {
12732
- var animation = reactNative.Animated.timing(animatedValue, {
12733
- toValue: visible ? 1 : 0,
12734
- easing: reactNative.Easing.inOut(reactNative.Easing.cubic),
12735
- useNativeDriver: true
12736
- });
12737
- animation.start();
12738
- return function () {
12739
- return animation.stop();
12740
- };
12741
- }, [visible]);
12742
- return /*#__PURE__*/React__default["default"].createElement(StyledContainer$3, {
12743
- testID: testID,
12744
- enableShadow: enableShadow,
12745
- pointerEvents: "box-none"
12746
- }, /*#__PURE__*/React__default["default"].createElement(StyledBackdrop$1, {
12747
- pointerEvents: visible ? 'auto' : 'box-none',
12748
- onPress: onDismiss,
12749
- style: {
12750
- opacity: interpolateBackdropOpacity
12751
- }
12752
- }), /*#__PURE__*/React__default["default"].createElement(StyledDrawerContainer, {
12753
- enableShadow: enableShadow,
12754
- onLayout: function onLayout(_ref2) {
12755
- var nativeEvent = _ref2.nativeEvent;
12756
- return setHeight(nativeEvent.layout.height);
12757
- },
12758
- style: {
12759
- transform: [{
12760
- translateY: interpolateTranslateY
12761
- }]
12762
- }
12763
- }, children));
12807
+ var _excluded$e = ["variant"];
12808
+ var DatePicker = function DatePicker(_ref) {
12809
+ var _ref$variant = _ref.variant,
12810
+ variant = _ref$variant === void 0 ? 'default' : _ref$variant,
12811
+ props = _objectWithoutProperties(_ref, _excluded$e);
12812
+ if (variant === 'calendar') {
12813
+ return /*#__PURE__*/React__default["default"].createElement(DatePickerCalendar, props);
12814
+ }
12815
+ if (reactNative.Platform.OS === 'ios') {
12816
+ return /*#__PURE__*/React__default["default"].createElement(DatePickerIOS, props);
12817
+ }
12818
+ return /*#__PURE__*/React__default["default"].createElement(DatePickerAndroid, props);
12764
12819
  };
12765
- var index$7 = Object.assign(Drawer, {
12766
- Dragable: DragableDrawer
12767
- });
12768
12820
 
12769
- var StyledWrapper$6 = index$a(reactNative.View)(function (_ref) {
12770
- var theme = _ref.theme;
12771
- return {
12772
- display: 'flex',
12773
- flex: 1,
12774
- flexDirection: 'column',
12775
- alignItems: 'center',
12776
- justifyContent: 'center',
12777
- padding: theme.__hd__.empty.space.wrapperPadding
12778
- };
12821
+ var AnimatedPressable$1 = reactNative.Animated.createAnimatedComponent(reactNative.Pressable);
12822
+ var StyledContainer$3 = index$a(reactNative.View)(function (_ref) {
12823
+ var theme = _ref.theme,
12824
+ enableShadow = _ref.enableShadow;
12825
+ return _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
12826
+ shadowColor: enableShadow ? theme.__hd__.drawer.colors.shadow : 'transparent',
12827
+ shadowOffset: theme.__hd__.drawer.shadows.offset,
12828
+ shadowOpacity: theme.__hd__.drawer.shadows.opacity,
12829
+ shadowRadius: theme.__hd__.drawer.shadows.radius,
12830
+ overflow: 'hidden',
12831
+ zIndex: 9999,
12832
+ elevation: 9999
12833
+ });
12779
12834
  });
12780
- var StyledTitle = index$a(Typography.Title)(function (_ref2) {
12835
+ var StyledDragableContainer = index$a(reactNative.View)(function (_ref2) {
12781
12836
  var theme = _ref2.theme,
12782
- themeVariant = _ref2.themeVariant;
12837
+ enableShadow = _ref2.enableShadow;
12838
+ return _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
12839
+ shadowColor: enableShadow ? theme.__hd__.drawer.colors.shadow : 'transparent',
12840
+ shadowOffset: theme.__hd__.drawer.shadows.offset,
12841
+ shadowOpacity: theme.__hd__.drawer.shadows.opacity,
12842
+ shadowRadius: theme.__hd__.drawer.shadows.radius,
12843
+ overflow: 'hidden',
12844
+ zIndex: 9999,
12845
+ elevation: 9999,
12846
+ flexDirection: 'column-reverse'
12847
+ });
12848
+ });
12849
+ var StyledBackdrop$1 = index$a(AnimatedPressable$1)(function (_ref3) {
12850
+ var theme = _ref3.theme;
12851
+ return _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
12852
+ backgroundColor: theme.__hd__.drawer.colors.backdrop
12853
+ });
12854
+ });
12855
+ var StyledDrawerContainer = index$a(reactNative.Animated.View)(function (_ref4) {
12856
+ var theme = _ref4.theme,
12857
+ enableShadow = _ref4.enableShadow;
12783
12858
  return {
12784
- textAlign: 'center',
12785
- marginBottom: theme.__hd__.empty.space.titleMargin,
12786
- color: themeVariant === 'dark' ? theme.__hd__.empty.colors.invertedText : theme.__hd__.empty.colors.text
12859
+ borderBottomLeftRadius: theme.__hd__.drawer.radii["default"],
12860
+ borderBottomRightRadius: theme.__hd__.drawer.radii["default"],
12861
+ backgroundColor: theme.__hd__.drawer.colors.background,
12862
+ elevation: enableShadow ? theme.__hd__.drawer.shadows.elevation : undefined,
12863
+ overflow: 'hidden'
12787
12864
  };
12788
12865
  });
12789
- var StyledDescription = index$a(Typography.Body)(function (_ref3) {
12790
- var theme = _ref3.theme,
12791
- themeVariant = _ref3.themeVariant;
12866
+ var StyledDragableDrawerContainer = index$a(reactNative.Animated.View)(function (_ref5) {
12867
+ var theme = _ref5.theme,
12868
+ enableShadow = _ref5.enableShadow;
12792
12869
  return {
12793
- textAlign: 'center',
12794
- color: themeVariant === 'dark' ? theme.__hd__.empty.colors.invertedSubduedText : theme.__hd__.empty.colors.subduedText
12870
+ borderTopLeftRadius: theme.__hd__.drawer.radii["default"],
12871
+ borderTopRightRadius: theme.__hd__.drawer.radii["default"],
12872
+ backgroundColor: theme.__hd__.drawer.colors.background,
12873
+ elevation: enableShadow ? theme.__hd__.drawer.shadows.elevation : undefined,
12874
+ overflow: 'hidden',
12875
+ maxHeight: '100%'
12795
12876
  };
12796
12877
  });
12797
-
12798
- var Empty = function Empty(_ref) {
12799
- var image = _ref.image,
12800
- title = _ref.title,
12801
- description = _ref.description,
12802
- style = _ref.style,
12803
- testID = _ref.testID,
12804
- _ref$variant = _ref.variant,
12805
- variant = _ref$variant === void 0 ? 'light' : _ref$variant;
12806
- var theme = useTheme();
12807
- return /*#__PURE__*/React__default["default"].createElement(StyledWrapper$6, {
12808
- style: style,
12809
- testID: testID
12810
- }, image !== undefined && /*#__PURE__*/React__default["default"].cloneElement(image, _objectSpread2(_objectSpread2({}, image.props), {}, {
12811
- style: [{
12812
- marginBottom: theme.__hd__.empty.space.imageMargin
12813
- }, image.props.style]
12814
- })), /*#__PURE__*/React__default["default"].createElement(StyledTitle, {
12815
- themeVariant: variant,
12816
- level: "h4",
12817
- typeface: "playful"
12818
- }, title), !!description && /*#__PURE__*/React__default["default"].createElement(StyledDescription, {
12819
- themeVariant: variant,
12820
- typeface: "playful"
12821
- }, description));
12822
- };
12823
-
12824
- var customAlphabet = function customAlphabet(alphabet) {
12825
- var defaultSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 21;
12826
- return function () {
12827
- var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultSize;
12828
- var id = '';
12829
- var i = size;
12830
- while (i--) {
12831
- id += alphabet[Math.random() * alphabet.length | 0];
12832
- }
12833
- return id;
12878
+ var StyledHandlerContainer = index$a(reactNative.View)(function (_ref6) {
12879
+ var theme = _ref6.theme;
12880
+ return {
12881
+ backgroundColor: theme.__hd__.drawer.colors.background,
12882
+ paddingVertical: theme.__hd__.drawer.space.handlerPaddingVertical,
12883
+ alignItems: 'center'
12834
12884
  };
12835
- };
12836
-
12837
- var ACTIONS;
12838
- (function (ACTIONS) {
12839
- ACTIONS[ACTIONS["REGISTER_HOST"] = 0] = "REGISTER_HOST";
12840
- ACTIONS[ACTIONS["DEREGISTER_HOST"] = 1] = "DEREGISTER_HOST";
12841
- ACTIONS[ACTIONS["ADD_UPDATE_PORTAL"] = 2] = "ADD_UPDATE_PORTAL";
12842
- ACTIONS[ACTIONS["REMOVE_PORTAL"] = 3] = "REMOVE_PORTAL";
12843
- })(ACTIONS || (ACTIONS = {}));
12844
- var INITIAL_STATE = {};
12845
-
12846
- var PortalStateContext = /*#__PURE__*/React.createContext(null);
12847
- var PortalDispatchContext = /*#__PURE__*/React.createContext(null);
12885
+ });
12886
+ var StyledHandler = index$a(reactNative.View)(function (_ref7) {
12887
+ var theme = _ref7.theme;
12888
+ return {
12889
+ width: theme.__hd__.drawer.sizes.handlerWidth,
12890
+ height: theme.__hd__.drawer.sizes.handlerHeight,
12891
+ backgroundColor: theme.__hd__.drawer.colors.handler,
12892
+ borderRadius: theme.__hd__.drawer.radii.handler
12893
+ };
12894
+ });
12848
12895
 
12849
- var usePortal = function usePortal() {
12850
- var hostName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'root';
12851
- var dispatch = React.useContext(PortalDispatchContext);
12852
- if (dispatch === null) {
12853
- throw new Error("You must add 'PortalProvider' to the root component.");
12854
- }
12855
- var registerHost = React.useCallback(function () {
12856
- dispatch({
12857
- type: ACTIONS.REGISTER_HOST,
12858
- hostName: hostName
12859
- });
12860
- }, []);
12861
- var deregisterHost = React.useCallback(function () {
12862
- dispatch({
12863
- type: ACTIONS.DEREGISTER_HOST,
12864
- hostName: hostName
12865
- });
12866
- }, []);
12867
- var addUpdatePortal = React.useCallback(function (name, node) {
12868
- dispatch({
12869
- type: ACTIONS.ADD_UPDATE_PORTAL,
12870
- hostName: hostName,
12871
- portalName: name,
12872
- node: node
12873
- });
12874
- }, []);
12875
- var removePortal = React.useCallback(function (name) {
12876
- dispatch({
12877
- type: ACTIONS.REMOVE_PORTAL,
12878
- hostName: hostName,
12879
- portalName: name
12880
- });
12881
- }, []);
12896
+ var getOffset = function getOffset(height, percentage) {
12897
+ if (percentage < 0) return height;
12898
+ if (percentage > 100) return 0;
12899
+ return height * ((100 - percentage) / 100);
12900
+ };
12901
+ var calculateSnapPointsData = function calculateSnapPointsData(minimumHeight, height, snapPoints) {
12902
+ var filteredSnapPoints = snapPoints.filter(function (value) {
12903
+ return value >= minimumHeight;
12904
+ });
12905
+ var snapPointsOffsetValues = [minimumHeight].concat(_toConsumableArray(filteredSnapPoints)).map(function (value) {
12906
+ return getOffset(height, value);
12907
+ });
12908
+ var uniqSnapPointOffsetValues = Array.from(new Set([].concat(_toConsumableArray(snapPointsOffsetValues), [0])));
12882
12909
  return {
12883
- registerHost: registerHost,
12884
- deregisterHost: deregisterHost,
12885
- addPortal: addUpdatePortal,
12886
- updatePortal: addUpdatePortal,
12887
- removePortal: removePortal
12910
+ list: uniqSnapPointOffsetValues,
12911
+ minHeightOffset: Math.max.apply(Math, uniqSnapPointOffsetValues),
12912
+ maxHeightOffset: 0 // Max height
12888
12913
  };
12889
12914
  };
12890
12915
 
12891
- var usePortalState = function usePortalState(hostName) {
12892
- var state = React.useContext(PortalStateContext);
12893
- if (state === null) {
12894
- throw new Error("You must add 'PortalProvider' to the root component.");
12895
- }
12896
- return state[hostName] || [];
12916
+ var calculateAnimatedToValue = function calculateAnimatedToValue(position, heightSnapPoints) {
12917
+ var distances = heightSnapPoints.map(function (height) {
12918
+ return Math.abs(position - height);
12919
+ });
12920
+ var minIndex = distances.indexOf(Math.min.apply(Math, _toConsumableArray(distances)));
12921
+ return heightSnapPoints[minIndex];
12897
12922
  };
12898
12923
 
12899
- var PortalHostComponent = function PortalHostComponent(_ref) {
12900
- var name = _ref.name;
12901
- var state = usePortalState(name);
12902
- var _usePortal = usePortal(name),
12903
- registerHost = _usePortal.registerHost,
12904
- deregisterHost = _usePortal.deregisterHost;
12924
+ var DragableDrawer = function DragableDrawer(_ref) {
12925
+ var children = _ref.children,
12926
+ initialHeightPercentage = _ref.initialHeightPercentage,
12927
+ _ref$minimumHeightPer = _ref.minimumHeightPercentage,
12928
+ minimumHeightPercentage = _ref$minimumHeightPer === void 0 ? 10 : _ref$minimumHeightPer,
12929
+ _ref$snapPoints = _ref.snapPoints,
12930
+ snapPoints = _ref$snapPoints === void 0 ? [] : _ref$snapPoints,
12931
+ onExpanded = _ref.onExpanded,
12932
+ onCollapsed = _ref.onCollapsed,
12933
+ testID = _ref.testID;
12934
+ var _useState = React.useState(0),
12935
+ _useState2 = _slicedToArray(_useState, 2),
12936
+ height = _useState2[0],
12937
+ setHeight = _useState2[1];
12938
+ var baseHeightForMeasure = React.useRef(0);
12939
+ var snapPointsData = React.useRef({
12940
+ list: [],
12941
+ minHeightOffset: 0,
12942
+ maxHeightOffset: 0
12943
+ });
12944
+ // Track drag
12945
+ var pan = React.useRef(new reactNative.Animated.Value(0)).current;
12946
+ var offset = React.useRef(0);
12947
+ var offsetBeforePan = React.useRef(0);
12948
+ var _useState3 = React.useState(-1),
12949
+ _useState4 = _slicedToArray(_useState3, 2),
12950
+ animatedToValue = _useState4[0],
12951
+ setAnimatedToValue = _useState4[1];
12905
12952
  React.useEffect(function () {
12906
- registerHost();
12953
+ var id = pan.addListener(function (_ref2) {
12954
+ var value = _ref2.value;
12955
+ offset.current = value;
12956
+ });
12907
12957
  return function () {
12908
- deregisterHost();
12958
+ return pan.removeListener(id);
12909
12959
  };
12910
12960
  }, []);
12911
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, state.map(function (item) {
12912
- return item.node;
12913
- }));
12914
- };
12915
- var PortalHost = /*#__PURE__*/React.memo(PortalHostComponent);
12916
- PortalHost.displayName = 'PortalHost';
12917
-
12918
- var registerHostIfNotExist = function registerHostIfNotExist(state, hostName) {
12919
- if (!(hostName in state)) {
12920
- return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, hostName, []));
12921
- }
12922
- return _objectSpread2({}, state);
12923
- };
12924
- var deregisterHost = function deregisterHost(state, hostName) {
12925
- return _objectSpread2({}, omit([hostName], state));
12926
- };
12927
- var addUpdatePortal = function addUpdatePortal(state, hostName, portalName, node) {
12928
- var newState = registerHostIfNotExist(state, hostName);
12929
- var index = newState[hostName].findIndex(function (item) {
12930
- return item.name === portalName;
12931
- });
12932
- if (index !== -1) {
12933
- return _objectSpread2(_objectSpread2({}, newState), {}, _defineProperty({}, hostName, newState[hostName].map(function (item, i) {
12934
- if (index === i) {
12935
- return _objectSpread2(_objectSpread2({}, item), {}, {
12936
- node: node
12937
- });
12961
+ React.useEffect(function () {
12962
+ if (height > 0) {
12963
+ var initialOffset = getOffset(height, initialHeightPercentage || minimumHeightPercentage);
12964
+ setAnimatedToValue(initialOffset);
12965
+ }
12966
+ }, [height]);
12967
+ React.useEffect(function () {
12968
+ if (height > 0) {
12969
+ pan.setValue(height);
12970
+ offset.current = height;
12971
+ baseHeightForMeasure.current = height;
12972
+ // Calculate snap points information
12973
+ snapPointsData.current = calculateSnapPointsData(minimumHeightPercentage, height, snapPoints);
12974
+ }
12975
+ }, [height, minimumHeightPercentage]);
12976
+ React.useEffect(function () {
12977
+ if (animatedToValue >= 0) {
12978
+ var animation = reactNative.Animated.timing(pan, {
12979
+ toValue: animatedToValue,
12980
+ useNativeDriver: true,
12981
+ easing: reactNative.Easing.inOut(reactNative.Easing.cubic)
12982
+ });
12983
+ animation.start(function () {
12984
+ if (animatedToValue === 0) {
12985
+ onExpanded === null || onExpanded === void 0 ? void 0 : onExpanded();
12986
+ } else if (animatedToValue === getOffset(height, minimumHeightPercentage)) {
12987
+ onCollapsed === null || onCollapsed === void 0 ? void 0 : onCollapsed();
12988
+ }
12989
+ setAnimatedToValue(-1);
12990
+ });
12991
+ return function () {
12992
+ return animation.stop();
12993
+ };
12994
+ }
12995
+ }, [animatedToValue]);
12996
+ var panResponder = React.useRef(reactNative.PanResponder.create({
12997
+ onMoveShouldSetPanResponder: function onMoveShouldSetPanResponder() {
12998
+ return true;
12999
+ },
13000
+ onPanResponderGrant: function onPanResponderGrant() {
13001
+ offsetBeforePan.current = offset.current;
13002
+ pan.setOffset(offset.current);
13003
+ pan.setValue(0);
13004
+ },
13005
+ onPanResponderMove: function onPanResponderMove(_, gesture) {
13006
+ var _snapPointsData$curre;
13007
+ var panDistance = gesture.dy;
13008
+ // Moving toward top, stop at highest snap point
13009
+ if (offsetBeforePan.current + panDistance < 0) {
13010
+ pan.setValue(-offsetBeforePan.current);
13011
+ return;
12938
13012
  }
12939
- return item;
12940
- })));
12941
- }
12942
- return _objectSpread2(_objectSpread2({}, newState), {}, _defineProperty({}, hostName, [].concat(_toConsumableArray(newState[hostName]), [{
12943
- name: portalName,
12944
- node: node
12945
- }])));
12946
- };
12947
- var removePortal = function removePortal(state, hostName, portalName) {
12948
- if (!(hostName in state)) {
12949
- return _objectSpread2({}, state);
12950
- }
12951
- return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, hostName, state[hostName].filter(function (item) {
12952
- return item.name !== portalName;
12953
- })));
12954
- };
12955
- var reducer = function reducer(state, action) {
12956
- var type = action.type;
12957
- switch (type) {
12958
- case ACTIONS.REGISTER_HOST:
12959
- return registerHostIfNotExist(state, action.hostName);
12960
- case ACTIONS.DEREGISTER_HOST:
12961
- return deregisterHost(state, action.hostName);
12962
- case ACTIONS.ADD_UPDATE_PORTAL:
12963
- return addUpdatePortal(state, action.hostName, action.portalName, action.node);
12964
- case ACTIONS.REMOVE_PORTAL:
12965
- return removePortal(state, action.hostName, action.portalName);
12966
- default:
12967
- return _objectSpread2({}, state);
12968
- }
12969
- };
12970
-
12971
- var PortalProviderComponent = function PortalProviderComponent(_ref) {
12972
- var _ref$rootHostName = _ref.rootHostName,
12973
- rootHostName = _ref$rootHostName === void 0 ? 'root' : _ref$rootHostName,
12974
- children = _ref.children;
12975
- var _useReducer = React.useReducer(reducer, INITIAL_STATE),
12976
- _useReducer2 = _slicedToArray(_useReducer, 2),
12977
- state = _useReducer2[0],
12978
- dispatch = _useReducer2[1];
12979
- return /*#__PURE__*/React__default["default"].createElement(PortalDispatchContext.Provider, {
12980
- value: dispatch
12981
- }, /*#__PURE__*/React__default["default"].createElement(PortalStateContext.Provider, {
12982
- value: state
12983
- }, children, /*#__PURE__*/React__default["default"].createElement(PortalHost, {
12984
- name: rootHostName
12985
- })));
13013
+ // Moving toward bottom, stop at lowest snap point
13014
+ if (offsetBeforePan.current + panDistance > ((_snapPointsData$curre = snapPointsData.current) === null || _snapPointsData$curre === void 0 ? void 0 : _snapPointsData$curre.minHeightOffset)) {
13015
+ pan.setValue(baseHeightForMeasure.current - baseHeightForMeasure.current * (minimumHeightPercentage / 100) - offsetBeforePan.current);
13016
+ return;
13017
+ }
13018
+ pan.setValue(panDistance);
13019
+ },
13020
+ onPanResponderRelease: function onPanResponderRelease(_, gesture) {
13021
+ pan.flattenOffset();
13022
+ // Attach to nearest snappoint
13023
+ var panDistance = gesture.dy;
13024
+ var offsetAfterPan = offsetBeforePan.current + panDistance;
13025
+ var animatedValue = calculateAnimatedToValue(offsetAfterPan, snapPointsData.current.list);
13026
+ setAnimatedToValue(animatedValue);
13027
+ }
13028
+ })).current;
13029
+ return /*#__PURE__*/React__default["default"].createElement(StyledDragableContainer, {
13030
+ testID: testID,
13031
+ enableShadow: true,
13032
+ pointerEvents: "box-none"
13033
+ }, /*#__PURE__*/React__default["default"].createElement(StyledDragableDrawerContainer, {
13034
+ enableShadow: true,
13035
+ style: {
13036
+ transform: [{
13037
+ scaleY: baseHeightForMeasure.current > 0 ? 1 : 0
13038
+ }, {
13039
+ translateY: pan
13040
+ }]
13041
+ },
13042
+ onLayout: function onLayout(_ref3) {
13043
+ var nativeEvent = _ref3.nativeEvent;
13044
+ setHeight(nativeEvent.layout.height);
13045
+ }
13046
+ }, /*#__PURE__*/React__default["default"].createElement(StyledHandlerContainer, panResponder.panHandlers, /*#__PURE__*/React__default["default"].createElement(StyledHandler, null)), children));
12986
13047
  };
12987
- var PortalProvider = /*#__PURE__*/React.memo(PortalProviderComponent);
12988
- PortalProvider.displayName = 'PortalProvider';
12989
13048
 
12990
- var nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789', 10);
12991
- var PortalComponent = function PortalComponent(_ref) {
12992
- var name = _ref.name,
12993
- hostName = _ref.hostName,
13049
+ var Drawer = function Drawer(_ref) {
13050
+ var visible = _ref.visible,
12994
13051
  children = _ref.children,
12995
- theme = _ref.theme;
12996
- var defaultTheme = useTheme();
12997
- var _usePortal = usePortal(hostName),
12998
- addUpdatePortal = _usePortal.addPortal,
12999
- removePortal = _usePortal.removePortal;
13000
- var nameOrRandom = React.useMemo(function () {
13001
- return name || nanoid();
13002
- }, [name]);
13003
- var ChildrenComponent = React.useMemo(function () {
13004
- return /*#__PURE__*/React__default["default"].createElement(ThemeProvider, {
13005
- theme: theme || defaultTheme
13006
- }, children);
13007
- }, [theme, children, defaultTheme]);
13008
- React.useLayoutEffect(function () {
13009
- addUpdatePortal(nameOrRandom, ChildrenComponent);
13010
- return function () {
13011
- removePortal(nameOrRandom);
13012
- };
13013
- }, [addUpdatePortal]);
13014
- React.useLayoutEffect(function () {
13015
- addUpdatePortal(nameOrRandom, ChildrenComponent);
13016
- }, [ChildrenComponent]);
13017
- return null;
13018
- };
13019
- var Portal = /*#__PURE__*/React.memo(PortalComponent);
13020
- Portal.displayName = 'Portal';
13021
- var Portal$1 = Object.assign(Portal, {
13022
- Provider: PortalProvider,
13023
- Host: PortalHost
13024
- });
13025
-
13026
- var _excluded$e = ["visible"];
13027
- var DEFAULT_BACKDROP_OPACITY = 0.4;
13028
- var DEFAULT_ANIMATION_CONFIG = {
13029
- easing: reactNative.Easing.inOut(reactNative.Easing.cubic),
13030
- useNativeDriver: reactNative.Platform.OS !== 'web',
13031
- duration: 400
13032
- };
13033
- var Modal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
13034
- var children = _ref.children,
13035
- onShow = _ref.onShow,
13036
- onRequestClose = _ref.onRequestClose,
13037
- testID = _ref.testID,
13038
- _ref$animationType = _ref.animationType,
13039
- animationType = _ref$animationType === void 0 ? 'none' : _ref$animationType,
13040
- _ref$transparent = _ref.transparent,
13041
- transparent = _ref$transparent === void 0 ? false : _ref$transparent,
13042
- onDismiss = _ref.onDismiss;
13043
- var theme = useTheme();
13044
- var animatedBackdropValue = React.useRef(new reactNative.Animated.Value(0)).current;
13045
- var animatedModalValue = React.useRef(new reactNative.Animated.Value(0)).current;
13046
- // Show or hide the backdrop and modal content
13047
- var animateBackdropAndContent = React.useCallback(function (_ref2) {
13048
- var toValue = _ref2.toValue,
13049
- callback = _ref2.callback;
13050
- if (animationType !== 'none') {
13051
- // Backdrop animation
13052
- if (!transparent) {
13053
- reactNative.Animated.timing(animatedBackdropValue, _objectSpread2({
13054
- toValue: toValue
13055
- }, DEFAULT_ANIMATION_CONFIG)).start();
13056
- }
13057
- // Modal content animation
13058
- reactNative.Animated.timing(animatedModalValue, _objectSpread2({
13059
- toValue: toValue
13060
- }, DEFAULT_ANIMATION_CONFIG)).start(callback);
13061
- } else {
13062
- callback === null || callback === void 0 ? void 0 : callback();
13063
- }
13064
- }, [animationType, onShow, transparent]);
13065
- var backdropOpacityAnimation = animatedBackdropValue.interpolate({
13052
+ _ref$hasBackdrop = _ref.hasBackdrop,
13053
+ hasBackdrop = _ref$hasBackdrop === void 0 ? true : _ref$hasBackdrop,
13054
+ onDismiss = _ref.onDismiss,
13055
+ testID = _ref.testID;
13056
+ var animatedValue = React.useRef(new reactNative.Animated.Value(visible ? 1 : 0)).current;
13057
+ var _useState = React.useState(reactNative.Dimensions.get('window').height),
13058
+ _useState2 = _slicedToArray(_useState, 2),
13059
+ height = _useState2[0],
13060
+ setHeight = _useState2[1];
13061
+ var enableShadow = visible && !hasBackdrop;
13062
+ var interpolateTranslateY = animatedValue.interpolate({
13066
13063
  inputRange: [0, 1],
13067
- outputRange: [0, DEFAULT_BACKDROP_OPACITY]
13064
+ outputRange: [-height, 0]
13068
13065
  });
13069
- var modalAnimation = animatedModalValue.interpolate({
13066
+ var interpolateBackdropOpacity = hasBackdrop ? animatedValue.interpolate({
13070
13067
  inputRange: [0, 1],
13071
- outputRange: animationType === 'slide' ? [reactNative.Dimensions.get('window').height, 0] : [0, 1]
13072
- });
13073
- React.useImperativeHandle(ref, function () {
13074
- return {
13075
- show: function show() {
13076
- animateBackdropAndContent({
13077
- toValue: 1,
13078
- callback: onShow
13079
- });
13080
- },
13081
- hide: function hide(wrapperCallback) {
13082
- animateBackdropAndContent({
13083
- toValue: 0,
13084
- callback: function callback() {
13085
- if (reactNative.Platform.OS === 'ios') {
13086
- onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
13087
- }
13088
- wrapperCallback();
13089
- }
13090
- });
13091
- }
13092
- };
13093
- }, [onDismiss, onShow, animateBackdropAndContent]);
13094
- // Back button handler
13068
+ outputRange: [0, 0.35]
13069
+ }) : 0;
13095
13070
  React.useEffect(function () {
13096
- var backHandler = reactNative.BackHandler.addEventListener('hardwareBackPress', function () {
13097
- onRequestClose === null || onRequestClose === void 0 ? void 0 : onRequestClose();
13098
- return true;
13071
+ var animation = reactNative.Animated.timing(animatedValue, {
13072
+ toValue: visible ? 1 : 0,
13073
+ easing: reactNative.Easing.inOut(reactNative.Easing.cubic),
13074
+ useNativeDriver: true
13099
13075
  });
13076
+ animation.start();
13100
13077
  return function () {
13101
- return backHandler.remove();
13078
+ return animation.stop();
13102
13079
  };
13103
- }, [onRequestClose]);
13104
- return /*#__PURE__*/React__default["default"].createElement(Portal$1, null, /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
13105
- style: _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
13106
- backgroundColor: transparent ? 'transparent' : theme.colors.overlayGlobalSurface,
13107
- opacity: animationType !== 'none' ? backdropOpacityAnimation : DEFAULT_BACKDROP_OPACITY
13108
- })
13109
- }), /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
13080
+ }, [visible]);
13081
+ return /*#__PURE__*/React__default["default"].createElement(StyledContainer$3, {
13110
13082
  testID: testID,
13111
- style: _objectSpread2(_objectSpread2({}, reactNative.StyleSheet.absoluteFillObject), {}, {
13112
- opacity: animationType === 'fade' ? modalAnimation : 1,
13083
+ enableShadow: enableShadow,
13084
+ pointerEvents: "box-none"
13085
+ }, /*#__PURE__*/React__default["default"].createElement(StyledBackdrop$1, {
13086
+ pointerEvents: visible ? 'auto' : 'box-none',
13087
+ onPress: onDismiss,
13088
+ style: {
13089
+ opacity: interpolateBackdropOpacity
13090
+ }
13091
+ }), /*#__PURE__*/React__default["default"].createElement(StyledDrawerContainer, {
13092
+ enableShadow: enableShadow,
13093
+ onLayout: function onLayout(_ref2) {
13094
+ var nativeEvent = _ref2.nativeEvent;
13095
+ return setHeight(nativeEvent.layout.height);
13096
+ },
13097
+ style: {
13113
13098
  transform: [{
13114
- translateY: animationType === 'slide' ? modalAnimation : 0
13099
+ translateY: interpolateTranslateY
13115
13100
  }]
13116
- })
13101
+ }
13117
13102
  }, children));
13103
+ };
13104
+ var index$7 = Object.assign(Drawer, {
13105
+ Dragable: DragableDrawer
13118
13106
  });
13119
- var ModalWrapper = function ModalWrapper(_ref3) {
13120
- var _ref3$visible = _ref3.visible,
13121
- visible = _ref3$visible === void 0 ? true : _ref3$visible,
13122
- props = _objectWithoutProperties(_ref3, _excluded$e);
13123
- var modalRef = React.useRef(null);
13124
- var _useState = React.useState(visible),
13125
- _useState2 = _slicedToArray(_useState, 2),
13126
- internalVisible = _useState2[0],
13127
- setInternalVisible = _useState2[1];
13128
- React.useEffect(function () {
13129
- if (visible) {
13130
- setInternalVisible(true);
13131
- } else {
13132
- var _modalRef$current;
13133
- // Wait for animation to finish before hiding the modal
13134
- (_modalRef$current = modalRef.current) === null || _modalRef$current === void 0 ? void 0 : _modalRef$current.hide(function () {
13135
- return setInternalVisible(false);
13136
- });
13137
- }
13138
- }, [visible]);
13139
- React.useEffect(function () {
13140
- if (internalVisible) {
13141
- var _modalRef$current2;
13142
- (_modalRef$current2 = modalRef.current) === null || _modalRef$current2 === void 0 ? void 0 : _modalRef$current2.show();
13143
- }
13144
- }, [internalVisible]);
13145
- return internalVisible ? /*#__PURE__*/React__default["default"].createElement(Modal, _extends$1({
13146
- ref: modalRef
13147
- }, props)) : null;
13107
+
13108
+ var StyledWrapper$6 = index$a(reactNative.View)(function (_ref) {
13109
+ var theme = _ref.theme;
13110
+ return {
13111
+ display: 'flex',
13112
+ flex: 1,
13113
+ flexDirection: 'column',
13114
+ alignItems: 'center',
13115
+ justifyContent: 'center',
13116
+ padding: theme.__hd__.empty.space.wrapperPadding
13117
+ };
13118
+ });
13119
+ var StyledTitle = index$a(Typography.Title)(function (_ref2) {
13120
+ var theme = _ref2.theme,
13121
+ themeVariant = _ref2.themeVariant;
13122
+ return {
13123
+ textAlign: 'center',
13124
+ marginBottom: theme.__hd__.empty.space.titleMargin,
13125
+ color: themeVariant === 'dark' ? theme.__hd__.empty.colors.invertedText : theme.__hd__.empty.colors.text
13126
+ };
13127
+ });
13128
+ var StyledDescription = index$a(Typography.Body)(function (_ref3) {
13129
+ var theme = _ref3.theme,
13130
+ themeVariant = _ref3.themeVariant;
13131
+ return {
13132
+ textAlign: 'center',
13133
+ color: themeVariant === 'dark' ? theme.__hd__.empty.colors.invertedSubduedText : theme.__hd__.empty.colors.subduedText
13134
+ };
13135
+ });
13136
+
13137
+ var Empty = function Empty(_ref) {
13138
+ var image = _ref.image,
13139
+ title = _ref.title,
13140
+ description = _ref.description,
13141
+ style = _ref.style,
13142
+ testID = _ref.testID,
13143
+ _ref$variant = _ref.variant,
13144
+ variant = _ref$variant === void 0 ? 'light' : _ref$variant;
13145
+ var theme = useTheme();
13146
+ return /*#__PURE__*/React__default["default"].createElement(StyledWrapper$6, {
13147
+ style: style,
13148
+ testID: testID
13149
+ }, image !== undefined && /*#__PURE__*/React__default["default"].cloneElement(image, _objectSpread2(_objectSpread2({}, image.props), {}, {
13150
+ style: [{
13151
+ marginBottom: theme.__hd__.empty.space.imageMargin
13152
+ }, image.props.style]
13153
+ })), /*#__PURE__*/React__default["default"].createElement(StyledTitle, {
13154
+ themeVariant: variant,
13155
+ level: "h4",
13156
+ typeface: "playful"
13157
+ }, title), !!description && /*#__PURE__*/React__default["default"].createElement(StyledDescription, {
13158
+ themeVariant: variant,
13159
+ typeface: "playful"
13160
+ }, description));
13148
13161
  };
13149
13162
 
13150
13163
  var StyledErrorModal = index$a(ModalWrapper)({