@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.
@@ -4238,6 +4238,29 @@ function useStaticBottomSheet(Content) {
4238
4238
  };
4239
4239
  }
4240
4240
 
4241
+ function isDocumentBodyAvailable(body) {
4242
+ return !!body;
4243
+ }
4244
+
4245
+ /**
4246
+ * Returns document.body if it exists, or null otherwise.
4247
+ * This is useful when document.body might not be available, such as when document.write() is called
4248
+ * which destroys the DOM and causes React portals to fail with "Target container is not a DOM element" error.
4249
+ */
4250
+ function getDocumentBodyIfExists() {
4251
+ // document.body can be null when document.write() is called
4252
+ const body = typeof document !== 'undefined' ? document.body : null;
4253
+ return isDocumentBodyAvailable(body) ? body : null;
4254
+ }
4255
+
4256
+ function Portal({
4257
+ children
4258
+ }) {
4259
+ const container = getDocumentBodyIfExists();
4260
+ if (!container) return null;
4261
+ return /*#__PURE__*/reactDom.createPortal(children, container);
4262
+ }
4263
+
4241
4264
  function useBlockBodyScroll(shouldBlockScroll, isInitialRender) {
4242
4265
  react.useEffect(() => {
4243
4266
  if (shouldBlockScroll) {
@@ -4260,7 +4283,9 @@ function ModalBehaviourPortal({
4260
4283
  const isInitialRenderRef = react.useRef(true);
4261
4284
  useBlockBodyScroll(!!visible, isInitialRenderRef.current);
4262
4285
  isInitialRenderRef.current = false;
4263
- return children ? /*#__PURE__*/reactDom.createPortal(children, document.body) : null;
4286
+ return children ? /*#__PURE__*/jsxRuntime.jsx(Portal, {
4287
+ children: children
4288
+ }) : null;
4264
4289
  }
4265
4290
 
4266
4291
  const OnCloseContext = /*#__PURE__*/react.createContext(() => {});
@@ -6314,10 +6339,11 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
6314
6339
  });
6315
6340
 
6316
6341
  function DocumentPicker({
6317
- onDocumentUpload,
6318
6342
  children,
6319
6343
  disabled,
6320
- documentPickerOptions
6344
+ documentPickerOptions,
6345
+ onDocumentUpload,
6346
+ onGetDocumentAsyncError
6321
6347
  }) {
6322
6348
  const childElement = react.Children.only(children);
6323
6349
  return /*#__PURE__*/react.cloneElement(childElement, {
@@ -6326,12 +6352,22 @@ function DocumentPicker({
6326
6352
  onPress: async () => {
6327
6353
  if (disabled) return;
6328
6354
  childElement.props.onPress?.();
6329
- const result = await expoDocumentPicker.getDocumentAsync({
6330
- ...documentPickerOptions,
6331
- multiple: false
6332
- });
6333
- if (!result.canceled && result.assets[0]?.file) {
6334
- onDocumentUpload(result.assets[0].file);
6355
+ let result;
6356
+ try {
6357
+ result = await expoDocumentPicker.getDocumentAsync({
6358
+ ...documentPickerOptions,
6359
+ multiple: false
6360
+ });
6361
+ } catch (error) {
6362
+ onGetDocumentAsyncError?.();
6363
+ result = {
6364
+ canceled: true,
6365
+ assets: null
6366
+ };
6367
+ }
6368
+ const file = result.assets?.at(0)?.file;
6369
+ if (!result.canceled && file) {
6370
+ onDocumentUpload(file);
6335
6371
  }
6336
6372
  },
6337
6373
  disabled
@@ -11745,87 +11781,89 @@ function Picker({
11745
11781
  disabled,
11746
11782
  ...restToggleProps
11747
11783
  })
11748
- }), /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/jsxRuntime.jsx(View, {
11749
- ref: refMemo,
11750
- testID: testID,
11751
- ...menuProps,
11752
- position: strategy,
11753
- top: 0,
11754
- left: 0,
11755
- width: isItemsWidthFixed ? '100%' : itemsWidth,
11756
- maxWidth: isItemsWidthFixed ? 'kitt.picker.maxWidthFixed' : undefined,
11757
- zIndex: 1,
11758
- _web: {
11759
- style: {
11760
- transform: `translate3d(${tooltipX}px, ${tooltipY}px, 0)`,
11761
- visibility: isOpen ? 'visible' : 'hidden',
11762
- transitionDuration: '300ms',
11763
- transitionProperty: 'opacity, padding',
11764
- transitionTimingFunction: 'ease-in-out'
11765
- }
11766
- },
11784
+ }), /*#__PURE__*/jsxRuntime.jsx(Portal, {
11767
11785
  children: /*#__PURE__*/jsxRuntime.jsx(View, {
11768
- opacity: isOpen ? 1 : 0,
11769
- backgroundColor: "kitt.picker.web.optionsContainer.backgroundColor",
11770
- borderRadius: "kitt.picker.web.optionsContainer.borderRadius",
11771
- shadow: "kitt.picker.web.optionsContainer.shadow",
11786
+ ref: refMemo,
11787
+ testID: testID,
11788
+ ...menuProps,
11789
+ position: strategy,
11790
+ top: 0,
11791
+ left: 0,
11792
+ width: isItemsWidthFixed ? '100%' : itemsWidth,
11793
+ maxWidth: isItemsWidthFixed ? 'kitt.picker.maxWidthFixed' : undefined,
11794
+ zIndex: 1,
11772
11795
  _web: {
11773
11796
  style: {
11774
- transform: `translateY(${isOpen ? 0 : 8})`,
11797
+ transform: `translate3d(${tooltipX}px, ${tooltipY}px, 0)`,
11775
11798
  visibility: isOpen ? 'visible' : 'hidden',
11776
11799
  transitionDuration: '300ms',
11800
+ transitionProperty: 'opacity, padding',
11777
11801
  transitionTimingFunction: 'ease-in-out'
11778
11802
  }
11779
11803
  },
11780
- children: /*#__PURE__*/jsxRuntime.jsx(reactTransitionGroup.CSSTransition, {
11781
- unmountOnExit: true,
11782
- nodeRef: nodeRef,
11783
- timeout: 300,
11784
- in: isOpen,
11785
- classNames: pickerClassNames,
11786
- children: /*#__PURE__*/jsxRuntime.jsx(View, {
11787
- ref: nodeRef,
11788
- paddingY: "kitt.2",
11789
- children: childrenArray.map((child, index) => {
11790
- const currentValue = items[index];
11791
- if (currentValue === undefined) {
11792
- throw new Error(`Picker: No value found for item at index ${index}`);
11793
- }
11794
- const {
11795
- onClick,
11796
- 'aria-selected': ariaSelected,
11797
- ...itemProps
11798
- } = getItemProps({
11799
- item: currentValue,
11800
- index,
11801
- disabled
11802
- });
11803
- return /*#__PURE__*/jsxRuntime.jsx(Pressable, {
11804
- ...itemProps,
11805
- accessibilityState: {
11806
- selected: ariaSelected
11807
- },
11808
- onPress: onClick,
11809
- children: ({
11810
- isHovered,
11811
- isFocused,
11812
- isPressed
11813
- }) => {
11814
- return /*#__PURE__*/jsxRuntime.jsx(PickerItem, {
11815
- isSelected: checkSelectedItem(selectedItem || undefined, currentValue),
11816
- isHighlighted: highlightedIndex === index,
11817
- isHovered: isHovered,
11818
- isFocused: isFocused,
11819
- isPressed: isPressed,
11820
- children: child
11821
- });
11804
+ children: /*#__PURE__*/jsxRuntime.jsx(View, {
11805
+ opacity: isOpen ? 1 : 0,
11806
+ backgroundColor: "kitt.picker.web.optionsContainer.backgroundColor",
11807
+ borderRadius: "kitt.picker.web.optionsContainer.borderRadius",
11808
+ shadow: "kitt.picker.web.optionsContainer.shadow",
11809
+ _web: {
11810
+ style: {
11811
+ transform: `translateY(${isOpen ? 0 : 8})`,
11812
+ visibility: isOpen ? 'visible' : 'hidden',
11813
+ transitionDuration: '300ms',
11814
+ transitionTimingFunction: 'ease-in-out'
11815
+ }
11816
+ },
11817
+ children: /*#__PURE__*/jsxRuntime.jsx(reactTransitionGroup.CSSTransition, {
11818
+ unmountOnExit: true,
11819
+ nodeRef: nodeRef,
11820
+ timeout: 300,
11821
+ in: isOpen,
11822
+ classNames: pickerClassNames,
11823
+ children: /*#__PURE__*/jsxRuntime.jsx(View, {
11824
+ ref: nodeRef,
11825
+ paddingY: "kitt.2",
11826
+ children: childrenArray.map((child, index) => {
11827
+ const currentValue = items[index];
11828
+ if (currentValue === undefined) {
11829
+ throw new Error(`Picker: No value found for item at index ${index}`);
11822
11830
  }
11823
- }, itemProps.id);
11831
+ const {
11832
+ onClick,
11833
+ 'aria-selected': ariaSelected,
11834
+ ...itemProps
11835
+ } = getItemProps({
11836
+ item: currentValue,
11837
+ index,
11838
+ disabled
11839
+ });
11840
+ return /*#__PURE__*/jsxRuntime.jsx(Pressable, {
11841
+ ...itemProps,
11842
+ accessibilityState: {
11843
+ selected: ariaSelected
11844
+ },
11845
+ onPress: onClick,
11846
+ children: ({
11847
+ isHovered,
11848
+ isFocused,
11849
+ isPressed
11850
+ }) => {
11851
+ return /*#__PURE__*/jsxRuntime.jsx(PickerItem, {
11852
+ isSelected: checkSelectedItem(selectedItem || undefined, currentValue),
11853
+ isHighlighted: highlightedIndex === index,
11854
+ isHovered: isHovered,
11855
+ isFocused: isFocused,
11856
+ isPressed: isPressed,
11857
+ children: child
11858
+ });
11859
+ }
11860
+ }, itemProps.id);
11861
+ })
11824
11862
  })
11825
11863
  })
11826
11864
  })
11827
11865
  })
11828
- }), document.body)]
11866
+ })]
11829
11867
  });
11830
11868
  }
11831
11869
  Picker.Option = PickerOption;
@@ -13289,67 +13327,69 @@ function Tooltip({
13289
13327
  onFocus: handleToggleTooltip,
13290
13328
  onBlur: handleToggleTooltip,
13291
13329
  width: '100%'
13292
- }), /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/jsxRuntime.jsx(View, {
13293
- ref: refs.setFloating,
13294
- "aria-hidden": !isVisible,
13295
- paddingX: {
13296
- base: 'kitt.4',
13297
- small: 0
13298
- },
13299
- width: {
13300
- base: '100%',
13301
- small: 'max-content'
13302
- },
13303
- maxWidth: {
13304
- base: '100%',
13305
- small: 'kitt.tooltip.maxWidth'
13306
- },
13307
- opacity: isVisible ? 'kitt.tooltip.opacity' : 0,
13308
- paddingTop: placement === 'bottom' ? currentFloatingPadding : undefined,
13309
- paddingBottom: placement === 'top' ? currentFloatingPadding : undefined,
13310
- style: {
13311
- pointerEvents: isVisible ? 'auto' : 'none'
13312
- },
13313
- position: strategy,
13314
- zIndex: zIndex,
13315
- top: 0,
13316
- left: 0,
13317
- _web: {
13330
+ }), /*#__PURE__*/jsxRuntime.jsx(Portal, {
13331
+ children: /*#__PURE__*/jsxRuntime.jsx(View, {
13332
+ ref: refs.setFloating,
13333
+ "aria-hidden": !isVisible,
13334
+ paddingX: {
13335
+ base: 'kitt.4',
13336
+ small: 0
13337
+ },
13338
+ width: {
13339
+ base: '100%',
13340
+ small: 'max-content'
13341
+ },
13342
+ maxWidth: {
13343
+ base: '100%',
13344
+ small: 'kitt.tooltip.maxWidth'
13345
+ },
13346
+ opacity: isVisible ? 'kitt.tooltip.opacity' : 0,
13347
+ paddingTop: placement === 'bottom' ? currentFloatingPadding : undefined,
13348
+ paddingBottom: placement === 'top' ? currentFloatingPadding : undefined,
13318
13349
  style: {
13319
- transform: `translate3d(${isBase && !fullWidth ? `0, ${tooltipY}px, 0` : `${tooltipX}px, ${tooltipY}px, 0`})`,
13320
- visibility: isVisible ? 'visible' : 'hidden',
13321
- transitionDuration,
13322
- transitionProperty: theme.kitt.tooltip.transition[themePart].property,
13323
- transitionTimingFunction
13324
- }
13325
- },
13326
- onTouchStart: handleToggleTooltip,
13327
- onTouchEnd: handleToggleTooltip,
13328
- onMouseEnter: handleToggleTooltip,
13329
- onMouseLeave: handleToggleTooltip,
13330
- children: /*#__PURE__*/jsxRuntime.jsxs(View, {
13350
+ pointerEvents: isVisible ? 'auto' : 'none'
13351
+ },
13352
+ position: strategy,
13353
+ zIndex: zIndex,
13354
+ top: 0,
13355
+ left: 0,
13331
13356
  _web: {
13332
13357
  style: {
13333
- transform: `scale(${isVisible ? 1 : 0.8})`,
13334
- transitionDuration: isVisible ? '0' : transitionDuration,
13335
- transitionProperty: 'all',
13336
- transitionTimingFunction,
13337
- transformOrigin
13358
+ transform: `translate3d(${isBase && !fullWidth ? `0, ${tooltipY}px, 0` : `${tooltipX}px, ${tooltipY}px, 0`})`,
13359
+ visibility: isVisible ? 'visible' : 'hidden',
13360
+ transitionDuration,
13361
+ transitionProperty: theme.kitt.tooltip.transition[themePart].property,
13362
+ transitionTimingFunction
13338
13363
  }
13339
13364
  },
13340
- children: [shouldRenderArrow && placement === 'bottom' ? /*#__PURE__*/jsxRuntime.jsx(Arrow, {
13341
- ref: arrowRef,
13342
- position: "bottom",
13343
- ...sharedArrowProps
13344
- }) : null, /*#__PURE__*/jsxRuntime.jsx(TooltipContent, {
13345
- children: content
13346
- }), shouldRenderArrow && placement === 'top' ? /*#__PURE__*/jsxRuntime.jsx(Arrow, {
13347
- ref: arrowRef,
13348
- position: "top",
13349
- ...sharedArrowProps
13350
- }) : null]
13365
+ onTouchStart: handleToggleTooltip,
13366
+ onTouchEnd: handleToggleTooltip,
13367
+ onMouseEnter: handleToggleTooltip,
13368
+ onMouseLeave: handleToggleTooltip,
13369
+ children: /*#__PURE__*/jsxRuntime.jsxs(View, {
13370
+ _web: {
13371
+ style: {
13372
+ transform: `scale(${isVisible ? 1 : 0.8})`,
13373
+ transitionDuration: isVisible ? '0' : transitionDuration,
13374
+ transitionProperty: 'all',
13375
+ transitionTimingFunction,
13376
+ transformOrigin
13377
+ }
13378
+ },
13379
+ children: [shouldRenderArrow && placement === 'bottom' ? /*#__PURE__*/jsxRuntime.jsx(Arrow, {
13380
+ ref: arrowRef,
13381
+ position: "bottom",
13382
+ ...sharedArrowProps
13383
+ }) : null, /*#__PURE__*/jsxRuntime.jsx(TooltipContent, {
13384
+ children: content
13385
+ }), shouldRenderArrow && placement === 'top' ? /*#__PURE__*/jsxRuntime.jsx(Arrow, {
13386
+ ref: arrowRef,
13387
+ position: "top",
13388
+ ...sharedArrowProps
13389
+ }) : null]
13390
+ })
13351
13391
  })
13352
- }), document.body)]
13392
+ })]
13353
13393
  });
13354
13394
  }
13355
13395
  Tooltip.Arrow = Arrow;