@ornikar/kitt-universal 32.5.1 → 32.5.3-canary.00f8f98ae6299285821fb6a87eab9440995c7566.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4274,6 +4274,28 @@ function useStaticBottomSheet(Content) {
4274
4274
  };
4275
4275
  }
4276
4276
 
4277
+ function isDocumentBodyAvailable(body) {
4278
+ return !!body;
4279
+ }
4280
+
4281
+ /**
4282
+ * Returns document.body if it exists, or null otherwise.
4283
+ * This is useful when document.body might not be available, such as when document.write() is called
4284
+ * which destroys the DOM and causes React portals to fail with "Target container is not a DOM element" error.
4285
+ */
4286
+ function getDocumentBodyIfExists() {
4287
+ // document.body can be null when document.write() is called
4288
+ var body = typeof document !== 'undefined' ? document.body : null;
4289
+ return isDocumentBodyAvailable(body) ? body : null;
4290
+ }
4291
+
4292
+ function Portal(_ref) {
4293
+ var children = _ref.children;
4294
+ var container = getDocumentBodyIfExists();
4295
+ if (!container) return null;
4296
+ return /*#__PURE__*/createPortal(children, container);
4297
+ }
4298
+
4277
4299
  function useBlockBodyScroll(shouldBlockScroll, isInitialRender) {
4278
4300
  useEffect(function () {
4279
4301
  if (shouldBlockScroll) {
@@ -4295,7 +4317,9 @@ function ModalBehaviourPortal(_ref) {
4295
4317
  var isInitialRenderRef = useRef(true);
4296
4318
  useBlockBodyScroll(!!visible, isInitialRenderRef.current);
4297
4319
  isInitialRenderRef.current = false;
4298
- return children ? /*#__PURE__*/createPortal(children, document.body) : null;
4320
+ return children ? /*#__PURE__*/jsx(Portal, {
4321
+ children: children
4322
+ }) : null;
4299
4323
  }
4300
4324
 
4301
4325
  var OnCloseContext = /*#__PURE__*/createContext(function () {});
@@ -6372,15 +6396,16 @@ var DatePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
6372
6396
  });
6373
6397
 
6374
6398
  function DocumentPicker(_ref) {
6375
- var onDocumentUpload = _ref.onDocumentUpload,
6376
- children = _ref.children,
6399
+ var children = _ref.children,
6377
6400
  disabled = _ref.disabled,
6378
- documentPickerOptions = _ref.documentPickerOptions;
6401
+ documentPickerOptions = _ref.documentPickerOptions,
6402
+ onDocumentUpload = _ref.onDocumentUpload,
6403
+ onGetDocumentAsyncError = _ref.onGetDocumentAsyncError;
6379
6404
  var childElement = Children.only(children);
6380
6405
  var handlePickDocument = /*#__PURE__*/function () {
6381
6406
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
6382
- var _childElement$props$o, _childElement$props, _result$assets$;
6383
- var result;
6407
+ var _childElement$props$o, _childElement$props, _result$assets;
6408
+ var result, file;
6384
6409
  return _regeneratorRuntime().wrap(function (_context) {
6385
6410
  while (1) switch (_context.prev = _context.next) {
6386
6411
  case 0:
@@ -6391,20 +6416,33 @@ function DocumentPicker(_ref) {
6391
6416
  return _context.abrupt("return");
6392
6417
  case 2:
6393
6418
  (_childElement$props$o = (_childElement$props = childElement.props).onPress) === null || _childElement$props$o === void 0 || _childElement$props$o.call(_childElement$props);
6394
- _context.next = 5;
6419
+ _context.prev = 3;
6420
+ _context.next = 6;
6395
6421
  return getDocumentAsync(_objectSpread(_objectSpread({}, documentPickerOptions), {}, {
6396
6422
  multiple: false
6397
6423
  }));
6398
- case 5:
6424
+ case 6:
6399
6425
  result = _context.sent;
6400
- if (!result.canceled && (_result$assets$ = result.assets[0]) !== null && _result$assets$ !== void 0 && _result$assets$.file) {
6401
- onDocumentUpload(result.assets[0].file);
6426
+ _context.next = 13;
6427
+ break;
6428
+ case 9:
6429
+ _context.prev = 9;
6430
+ _context.t0 = _context["catch"](3);
6431
+ onGetDocumentAsyncError === null || onGetDocumentAsyncError === void 0 || onGetDocumentAsyncError();
6432
+ result = {
6433
+ canceled: true,
6434
+ assets: null
6435
+ };
6436
+ case 13:
6437
+ file = (_result$assets = result.assets) === null || _result$assets === void 0 || (_result$assets = _result$assets.at(0)) === null || _result$assets === void 0 ? void 0 : _result$assets.file;
6438
+ if (!result.canceled && file) {
6439
+ onDocumentUpload(file);
6402
6440
  }
6403
- case 7:
6441
+ case 15:
6404
6442
  case "end":
6405
6443
  return _context.stop();
6406
6444
  }
6407
- }, _callee);
6445
+ }, _callee, null, [[3, 9]]);
6408
6446
  }));
6409
6447
  return function () {
6410
6448
  return _ref2.apply(this, arguments);
@@ -11916,84 +11954,86 @@ function Picker(_ref) {
11916
11954
  isOpen: isOpen,
11917
11955
  disabled: disabled
11918
11956
  }, restToggleProps))
11919
- })), /*#__PURE__*/createPortal(/*#__PURE__*/jsx(View, _objectSpread(_objectSpread({
11920
- ref: refMemo,
11921
- testID: testID
11922
- }, menuProps), {}, {
11923
- position: strategy,
11924
- top: 0,
11925
- left: 0,
11926
- width: isItemsWidthFixed ? '100%' : itemsWidth,
11927
- maxWidth: isItemsWidthFixed ? 'kitt.picker.maxWidthFixed' : undefined,
11928
- zIndex: 1,
11929
- _web: {
11930
- style: {
11931
- transform: "translate3d(".concat(tooltipX, "px, ").concat(tooltipY, "px, 0)"),
11932
- visibility: isOpen ? 'visible' : 'hidden',
11933
- transitionDuration: '300ms',
11934
- transitionProperty: 'opacity, padding',
11935
- transitionTimingFunction: 'ease-in-out'
11936
- }
11937
- },
11938
- children: /*#__PURE__*/jsx(View, {
11939
- opacity: isOpen ? 1 : 0,
11940
- backgroundColor: "kitt.picker.web.optionsContainer.backgroundColor",
11941
- borderRadius: "kitt.picker.web.optionsContainer.borderRadius",
11942
- shadow: "kitt.picker.web.optionsContainer.shadow",
11957
+ })), /*#__PURE__*/jsx(Portal, {
11958
+ children: /*#__PURE__*/jsx(View, _objectSpread(_objectSpread({
11959
+ ref: refMemo,
11960
+ testID: testID
11961
+ }, menuProps), {}, {
11962
+ position: strategy,
11963
+ top: 0,
11964
+ left: 0,
11965
+ width: isItemsWidthFixed ? '100%' : itemsWidth,
11966
+ maxWidth: isItemsWidthFixed ? 'kitt.picker.maxWidthFixed' : undefined,
11967
+ zIndex: 1,
11943
11968
  _web: {
11944
11969
  style: {
11945
- transform: "translateY(".concat(isOpen ? 0 : 8, ")"),
11970
+ transform: "translate3d(".concat(tooltipX, "px, ").concat(tooltipY, "px, 0)"),
11946
11971
  visibility: isOpen ? 'visible' : 'hidden',
11947
11972
  transitionDuration: '300ms',
11973
+ transitionProperty: 'opacity, padding',
11948
11974
  transitionTimingFunction: 'ease-in-out'
11949
11975
  }
11950
11976
  },
11951
- children: /*#__PURE__*/jsx(CSSTransition, {
11952
- unmountOnExit: true,
11953
- nodeRef: nodeRef,
11954
- timeout: 300,
11955
- "in": isOpen,
11956
- classNames: pickerClassNames,
11957
- children: /*#__PURE__*/jsx(View, {
11958
- ref: nodeRef,
11959
- paddingY: "kitt.2",
11960
- children: childrenArray.map(function (child, index) {
11961
- var currentValue = items[index];
11962
- if (currentValue === undefined) {
11963
- throw new Error("Picker: No value found for item at index ".concat(index));
11964
- }
11965
- var _getItemProps = getItemProps({
11966
- item: currentValue,
11967
- index: index,
11968
- disabled: disabled
11969
- }),
11970
- onClick = _getItemProps.onClick,
11971
- ariaSelected = _getItemProps['aria-selected'],
11972
- itemProps = _objectWithoutProperties(_getItemProps, _excluded3$2);
11973
- return /*#__PURE__*/jsx(Pressable, _objectSpread(_objectSpread({}, itemProps), {}, {
11974
- accessibilityState: {
11975
- selected: ariaSelected
11976
- },
11977
- onPress: onClick,
11978
- children: function (_ref2) {
11979
- var isHovered = _ref2.isHovered,
11980
- isFocused = _ref2.isFocused,
11981
- isPressed = _ref2.isPressed;
11982
- return /*#__PURE__*/jsx(PickerItem, {
11983
- isSelected: checkSelectedItem(selectedItem || undefined, currentValue),
11984
- isHighlighted: highlightedIndex === index,
11985
- isHovered: isHovered,
11986
- isFocused: isFocused,
11987
- isPressed: isPressed,
11988
- children: child
11989
- });
11977
+ children: /*#__PURE__*/jsx(View, {
11978
+ opacity: isOpen ? 1 : 0,
11979
+ backgroundColor: "kitt.picker.web.optionsContainer.backgroundColor",
11980
+ borderRadius: "kitt.picker.web.optionsContainer.borderRadius",
11981
+ shadow: "kitt.picker.web.optionsContainer.shadow",
11982
+ _web: {
11983
+ style: {
11984
+ transform: "translateY(".concat(isOpen ? 0 : 8, ")"),
11985
+ visibility: isOpen ? 'visible' : 'hidden',
11986
+ transitionDuration: '300ms',
11987
+ transitionTimingFunction: 'ease-in-out'
11988
+ }
11989
+ },
11990
+ children: /*#__PURE__*/jsx(CSSTransition, {
11991
+ unmountOnExit: true,
11992
+ nodeRef: nodeRef,
11993
+ timeout: 300,
11994
+ "in": isOpen,
11995
+ classNames: pickerClassNames,
11996
+ children: /*#__PURE__*/jsx(View, {
11997
+ ref: nodeRef,
11998
+ paddingY: "kitt.2",
11999
+ children: childrenArray.map(function (child, index) {
12000
+ var currentValue = items[index];
12001
+ if (currentValue === undefined) {
12002
+ throw new Error("Picker: No value found for item at index ".concat(index));
11990
12003
  }
11991
- }), itemProps.id);
12004
+ var _getItemProps = getItemProps({
12005
+ item: currentValue,
12006
+ index: index,
12007
+ disabled: disabled
12008
+ }),
12009
+ onClick = _getItemProps.onClick,
12010
+ ariaSelected = _getItemProps['aria-selected'],
12011
+ itemProps = _objectWithoutProperties(_getItemProps, _excluded3$2);
12012
+ return /*#__PURE__*/jsx(Pressable, _objectSpread(_objectSpread({}, itemProps), {}, {
12013
+ accessibilityState: {
12014
+ selected: ariaSelected
12015
+ },
12016
+ onPress: onClick,
12017
+ children: function (_ref2) {
12018
+ var isHovered = _ref2.isHovered,
12019
+ isFocused = _ref2.isFocused,
12020
+ isPressed = _ref2.isPressed;
12021
+ return /*#__PURE__*/jsx(PickerItem, {
12022
+ isSelected: checkSelectedItem(selectedItem || undefined, currentValue),
12023
+ isHighlighted: highlightedIndex === index,
12024
+ isHovered: isHovered,
12025
+ isFocused: isFocused,
12026
+ isPressed: isPressed,
12027
+ children: child
12028
+ });
12029
+ }
12030
+ }), itemProps.id);
12031
+ })
11992
12032
  })
11993
12033
  })
11994
12034
  })
11995
- })
11996
- })), document.body)]
12035
+ }))
12036
+ })]
11997
12037
  });
11998
12038
  }
11999
12039
  Picker.Option = PickerOption;
@@ -13483,65 +13523,67 @@ function Tooltip(_ref) {
13483
13523
  onFocus: handleToggleTooltip,
13484
13524
  onBlur: handleToggleTooltip,
13485
13525
  width: '100%'
13486
- }), /*#__PURE__*/createPortal(/*#__PURE__*/jsx(View, {
13487
- ref: refs.setFloating,
13488
- "aria-hidden": !isVisible,
13489
- paddingX: {
13490
- base: 'kitt.4',
13491
- small: 0
13492
- },
13493
- width: {
13494
- base: '100%',
13495
- small: 'max-content'
13496
- },
13497
- maxWidth: {
13498
- base: '100%',
13499
- small: 'kitt.tooltip.maxWidth'
13500
- },
13501
- opacity: isVisible ? 'kitt.tooltip.opacity' : 0,
13502
- paddingTop: placement === 'bottom' ? currentFloatingPadding : undefined,
13503
- paddingBottom: placement === 'top' ? currentFloatingPadding : undefined,
13504
- style: {
13505
- pointerEvents: isVisible ? 'auto' : 'none'
13506
- },
13507
- position: strategy,
13508
- zIndex: zIndex,
13509
- top: 0,
13510
- left: 0,
13511
- _web: {
13526
+ }), /*#__PURE__*/jsx(Portal, {
13527
+ children: /*#__PURE__*/jsx(View, {
13528
+ ref: refs.setFloating,
13529
+ "aria-hidden": !isVisible,
13530
+ paddingX: {
13531
+ base: 'kitt.4',
13532
+ small: 0
13533
+ },
13534
+ width: {
13535
+ base: '100%',
13536
+ small: 'max-content'
13537
+ },
13538
+ maxWidth: {
13539
+ base: '100%',
13540
+ small: 'kitt.tooltip.maxWidth'
13541
+ },
13542
+ opacity: isVisible ? 'kitt.tooltip.opacity' : 0,
13543
+ paddingTop: placement === 'bottom' ? currentFloatingPadding : undefined,
13544
+ paddingBottom: placement === 'top' ? currentFloatingPadding : undefined,
13512
13545
  style: {
13513
- transform: "translate3d(".concat(isBase && !fullWidth ? "0, ".concat(tooltipY, "px, 0") : "".concat(tooltipX, "px, ").concat(tooltipY, "px, 0"), ")"),
13514
- visibility: isVisible ? 'visible' : 'hidden',
13515
- transitionDuration: transitionDuration,
13516
- transitionProperty: theme.kitt.tooltip.transition[themePart].property,
13517
- transitionTimingFunction: transitionTimingFunction
13518
- }
13519
- },
13520
- onTouchStart: handleToggleTooltip,
13521
- onTouchEnd: handleToggleTooltip,
13522
- onMouseEnter: handleToggleTooltip,
13523
- onMouseLeave: handleToggleTooltip,
13524
- children: /*#__PURE__*/jsxs(View, {
13546
+ pointerEvents: isVisible ? 'auto' : 'none'
13547
+ },
13548
+ position: strategy,
13549
+ zIndex: zIndex,
13550
+ top: 0,
13551
+ left: 0,
13525
13552
  _web: {
13526
13553
  style: {
13527
- transform: "scale(".concat(isVisible ? 1 : 0.8, ")"),
13528
- transitionDuration: isVisible ? '0' : transitionDuration,
13529
- transitionProperty: 'all',
13530
- transitionTimingFunction: transitionTimingFunction,
13531
- transformOrigin: transformOrigin
13554
+ transform: "translate3d(".concat(isBase && !fullWidth ? "0, ".concat(tooltipY, "px, 0") : "".concat(tooltipX, "px, ").concat(tooltipY, "px, 0"), ")"),
13555
+ visibility: isVisible ? 'visible' : 'hidden',
13556
+ transitionDuration: transitionDuration,
13557
+ transitionProperty: theme.kitt.tooltip.transition[themePart].property,
13558
+ transitionTimingFunction: transitionTimingFunction
13532
13559
  }
13533
13560
  },
13534
- children: [shouldRenderArrow && placement === 'bottom' ? /*#__PURE__*/jsx(Arrow, _objectSpread({
13535
- ref: arrowRef,
13536
- position: "bottom"
13537
- }, sharedArrowProps)) : null, /*#__PURE__*/jsx(TooltipContent, {
13538
- children: content
13539
- }), shouldRenderArrow && placement === 'top' ? /*#__PURE__*/jsx(Arrow, _objectSpread({
13540
- ref: arrowRef,
13541
- position: "top"
13542
- }, sharedArrowProps)) : null]
13561
+ onTouchStart: handleToggleTooltip,
13562
+ onTouchEnd: handleToggleTooltip,
13563
+ onMouseEnter: handleToggleTooltip,
13564
+ onMouseLeave: handleToggleTooltip,
13565
+ children: /*#__PURE__*/jsxs(View, {
13566
+ _web: {
13567
+ style: {
13568
+ transform: "scale(".concat(isVisible ? 1 : 0.8, ")"),
13569
+ transitionDuration: isVisible ? '0' : transitionDuration,
13570
+ transitionProperty: 'all',
13571
+ transitionTimingFunction: transitionTimingFunction,
13572
+ transformOrigin: transformOrigin
13573
+ }
13574
+ },
13575
+ children: [shouldRenderArrow && placement === 'bottom' ? /*#__PURE__*/jsx(Arrow, _objectSpread({
13576
+ ref: arrowRef,
13577
+ position: "bottom"
13578
+ }, sharedArrowProps)) : null, /*#__PURE__*/jsx(TooltipContent, {
13579
+ children: content
13580
+ }), shouldRenderArrow && placement === 'top' ? /*#__PURE__*/jsx(Arrow, _objectSpread({
13581
+ ref: arrowRef,
13582
+ position: "top"
13583
+ }, sharedArrowProps)) : null]
13584
+ })
13543
13585
  })
13544
- }), document.body)]
13586
+ })]
13545
13587
  });
13546
13588
  }
13547
13589
  Tooltip.Arrow = Arrow;