@ornikar/kitt-universal 32.5.2 → 32.5.3

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.
@@ -4229,6 +4229,29 @@ function useStaticBottomSheet(Content) {
4229
4229
  };
4230
4230
  }
4231
4231
 
4232
+ function isDocumentBodyAvailable(body) {
4233
+ return !!body;
4234
+ }
4235
+
4236
+ /**
4237
+ * Returns document.body if it exists, or null otherwise.
4238
+ * This is useful when document.body might not be available, such as when document.write() is called
4239
+ * which destroys the DOM and causes React portals to fail with "Target container is not a DOM element" error.
4240
+ */
4241
+ function getDocumentBodyIfExists() {
4242
+ // document.body can be null when document.write() is called
4243
+ const body = typeof document !== 'undefined' ? document.body : null;
4244
+ return isDocumentBodyAvailable(body) ? body : null;
4245
+ }
4246
+
4247
+ function Portal({
4248
+ children
4249
+ }) {
4250
+ const container = getDocumentBodyIfExists();
4251
+ if (!container) return null;
4252
+ return /*#__PURE__*/createPortal(children, container);
4253
+ }
4254
+
4232
4255
  function useBlockBodyScroll(shouldBlockScroll, isInitialRender) {
4233
4256
  useEffect(() => {
4234
4257
  if (shouldBlockScroll) {
@@ -4251,7 +4274,9 @@ function ModalBehaviourPortal({
4251
4274
  const isInitialRenderRef = useRef(true);
4252
4275
  useBlockBodyScroll(!!visible, isInitialRenderRef.current);
4253
4276
  isInitialRenderRef.current = false;
4254
- return children ? /*#__PURE__*/createPortal(children, document.body) : null;
4277
+ return children ? /*#__PURE__*/jsx(Portal, {
4278
+ children: children
4279
+ }) : null;
4255
4280
  }
4256
4281
 
4257
4282
  const OnCloseContext = /*#__PURE__*/createContext(() => {});
@@ -11747,87 +11772,89 @@ function Picker({
11747
11772
  disabled,
11748
11773
  ...restToggleProps
11749
11774
  })
11750
- }), /*#__PURE__*/createPortal(/*#__PURE__*/jsx(View, {
11751
- ref: refMemo,
11752
- testID: testID,
11753
- ...menuProps,
11754
- position: strategy,
11755
- top: 0,
11756
- left: 0,
11757
- width: isItemsWidthFixed ? '100%' : itemsWidth,
11758
- maxWidth: isItemsWidthFixed ? 'kitt.picker.maxWidthFixed' : undefined,
11759
- zIndex: 1,
11760
- _web: {
11761
- style: {
11762
- transform: `translate3d(${tooltipX}px, ${tooltipY}px, 0)`,
11763
- visibility: isOpen ? 'visible' : 'hidden',
11764
- transitionDuration: '300ms',
11765
- transitionProperty: 'opacity, padding',
11766
- transitionTimingFunction: 'ease-in-out'
11767
- }
11768
- },
11775
+ }), /*#__PURE__*/jsx(Portal, {
11769
11776
  children: /*#__PURE__*/jsx(View, {
11770
- opacity: isOpen ? 1 : 0,
11771
- backgroundColor: "kitt.picker.web.optionsContainer.backgroundColor",
11772
- borderRadius: "kitt.picker.web.optionsContainer.borderRadius",
11773
- shadow: "kitt.picker.web.optionsContainer.shadow",
11777
+ ref: refMemo,
11778
+ testID: testID,
11779
+ ...menuProps,
11780
+ position: strategy,
11781
+ top: 0,
11782
+ left: 0,
11783
+ width: isItemsWidthFixed ? '100%' : itemsWidth,
11784
+ maxWidth: isItemsWidthFixed ? 'kitt.picker.maxWidthFixed' : undefined,
11785
+ zIndex: 1,
11774
11786
  _web: {
11775
11787
  style: {
11776
- transform: `translateY(${isOpen ? 0 : 8})`,
11788
+ transform: `translate3d(${tooltipX}px, ${tooltipY}px, 0)`,
11777
11789
  visibility: isOpen ? 'visible' : 'hidden',
11778
11790
  transitionDuration: '300ms',
11791
+ transitionProperty: 'opacity, padding',
11779
11792
  transitionTimingFunction: 'ease-in-out'
11780
11793
  }
11781
11794
  },
11782
- children: /*#__PURE__*/jsx(CSSTransition, {
11783
- unmountOnExit: true,
11784
- nodeRef: nodeRef,
11785
- timeout: 300,
11786
- in: isOpen,
11787
- classNames: pickerClassNames,
11788
- children: /*#__PURE__*/jsx(View, {
11789
- ref: nodeRef,
11790
- paddingY: "kitt.2",
11791
- children: childrenArray.map((child, index) => {
11792
- const currentValue = items[index];
11793
- if (currentValue === undefined) {
11794
- throw new Error(`Picker: No value found for item at index ${index}`);
11795
- }
11796
- const {
11797
- onClick,
11798
- 'aria-selected': ariaSelected,
11799
- ...itemProps
11800
- } = getItemProps({
11801
- item: currentValue,
11802
- index,
11803
- disabled
11804
- });
11805
- return /*#__PURE__*/jsx(Pressable, {
11806
- ...itemProps,
11807
- accessibilityState: {
11808
- selected: ariaSelected
11809
- },
11810
- onPress: onClick,
11811
- children: ({
11812
- isHovered,
11813
- isFocused,
11814
- isPressed
11815
- }) => {
11816
- return /*#__PURE__*/jsx(PickerItem, {
11817
- isSelected: checkSelectedItem(selectedItem || undefined, currentValue),
11818
- isHighlighted: highlightedIndex === index,
11819
- isHovered: isHovered,
11820
- isFocused: isFocused,
11821
- isPressed: isPressed,
11822
- children: child
11823
- });
11795
+ children: /*#__PURE__*/jsx(View, {
11796
+ opacity: isOpen ? 1 : 0,
11797
+ backgroundColor: "kitt.picker.web.optionsContainer.backgroundColor",
11798
+ borderRadius: "kitt.picker.web.optionsContainer.borderRadius",
11799
+ shadow: "kitt.picker.web.optionsContainer.shadow",
11800
+ _web: {
11801
+ style: {
11802
+ transform: `translateY(${isOpen ? 0 : 8})`,
11803
+ visibility: isOpen ? 'visible' : 'hidden',
11804
+ transitionDuration: '300ms',
11805
+ transitionTimingFunction: 'ease-in-out'
11806
+ }
11807
+ },
11808
+ children: /*#__PURE__*/jsx(CSSTransition, {
11809
+ unmountOnExit: true,
11810
+ nodeRef: nodeRef,
11811
+ timeout: 300,
11812
+ in: isOpen,
11813
+ classNames: pickerClassNames,
11814
+ children: /*#__PURE__*/jsx(View, {
11815
+ ref: nodeRef,
11816
+ paddingY: "kitt.2",
11817
+ children: childrenArray.map((child, index) => {
11818
+ const currentValue = items[index];
11819
+ if (currentValue === undefined) {
11820
+ throw new Error(`Picker: No value found for item at index ${index}`);
11824
11821
  }
11825
- }, itemProps.id);
11822
+ const {
11823
+ onClick,
11824
+ 'aria-selected': ariaSelected,
11825
+ ...itemProps
11826
+ } = getItemProps({
11827
+ item: currentValue,
11828
+ index,
11829
+ disabled
11830
+ });
11831
+ return /*#__PURE__*/jsx(Pressable, {
11832
+ ...itemProps,
11833
+ accessibilityState: {
11834
+ selected: ariaSelected
11835
+ },
11836
+ onPress: onClick,
11837
+ children: ({
11838
+ isHovered,
11839
+ isFocused,
11840
+ isPressed
11841
+ }) => {
11842
+ return /*#__PURE__*/jsx(PickerItem, {
11843
+ isSelected: checkSelectedItem(selectedItem || undefined, currentValue),
11844
+ isHighlighted: highlightedIndex === index,
11845
+ isHovered: isHovered,
11846
+ isFocused: isFocused,
11847
+ isPressed: isPressed,
11848
+ children: child
11849
+ });
11850
+ }
11851
+ }, itemProps.id);
11852
+ })
11826
11853
  })
11827
11854
  })
11828
11855
  })
11829
11856
  })
11830
- }), document.body)]
11857
+ })]
11831
11858
  });
11832
11859
  }
11833
11860
  Picker.Option = PickerOption;
@@ -13291,67 +13318,69 @@ function Tooltip({
13291
13318
  onFocus: handleToggleTooltip,
13292
13319
  onBlur: handleToggleTooltip,
13293
13320
  width: '100%'
13294
- }), /*#__PURE__*/createPortal(/*#__PURE__*/jsx(View, {
13295
- ref: refs.setFloating,
13296
- "aria-hidden": !isVisible,
13297
- paddingX: {
13298
- base: 'kitt.4',
13299
- small: 0
13300
- },
13301
- width: {
13302
- base: '100%',
13303
- small: 'max-content'
13304
- },
13305
- maxWidth: {
13306
- base: '100%',
13307
- small: 'kitt.tooltip.maxWidth'
13308
- },
13309
- opacity: isVisible ? 'kitt.tooltip.opacity' : 0,
13310
- paddingTop: placement === 'bottom' ? currentFloatingPadding : undefined,
13311
- paddingBottom: placement === 'top' ? currentFloatingPadding : undefined,
13312
- style: {
13313
- pointerEvents: isVisible ? 'auto' : 'none'
13314
- },
13315
- position: strategy,
13316
- zIndex: zIndex,
13317
- top: 0,
13318
- left: 0,
13319
- _web: {
13321
+ }), /*#__PURE__*/jsx(Portal, {
13322
+ children: /*#__PURE__*/jsx(View, {
13323
+ ref: refs.setFloating,
13324
+ "aria-hidden": !isVisible,
13325
+ paddingX: {
13326
+ base: 'kitt.4',
13327
+ small: 0
13328
+ },
13329
+ width: {
13330
+ base: '100%',
13331
+ small: 'max-content'
13332
+ },
13333
+ maxWidth: {
13334
+ base: '100%',
13335
+ small: 'kitt.tooltip.maxWidth'
13336
+ },
13337
+ opacity: isVisible ? 'kitt.tooltip.opacity' : 0,
13338
+ paddingTop: placement === 'bottom' ? currentFloatingPadding : undefined,
13339
+ paddingBottom: placement === 'top' ? currentFloatingPadding : undefined,
13320
13340
  style: {
13321
- transform: `translate3d(${isBase && !fullWidth ? `0, ${tooltipY}px, 0` : `${tooltipX}px, ${tooltipY}px, 0`})`,
13322
- visibility: isVisible ? 'visible' : 'hidden',
13323
- transitionDuration,
13324
- transitionProperty: theme.kitt.tooltip.transition[themePart].property,
13325
- transitionTimingFunction
13326
- }
13327
- },
13328
- onTouchStart: handleToggleTooltip,
13329
- onTouchEnd: handleToggleTooltip,
13330
- onMouseEnter: handleToggleTooltip,
13331
- onMouseLeave: handleToggleTooltip,
13332
- children: /*#__PURE__*/jsxs(View, {
13341
+ pointerEvents: isVisible ? 'auto' : 'none'
13342
+ },
13343
+ position: strategy,
13344
+ zIndex: zIndex,
13345
+ top: 0,
13346
+ left: 0,
13333
13347
  _web: {
13334
13348
  style: {
13335
- transform: `scale(${isVisible ? 1 : 0.8})`,
13336
- transitionDuration: isVisible ? '0' : transitionDuration,
13337
- transitionProperty: 'all',
13338
- transitionTimingFunction,
13339
- transformOrigin
13349
+ transform: `translate3d(${isBase && !fullWidth ? `0, ${tooltipY}px, 0` : `${tooltipX}px, ${tooltipY}px, 0`})`,
13350
+ visibility: isVisible ? 'visible' : 'hidden',
13351
+ transitionDuration,
13352
+ transitionProperty: theme.kitt.tooltip.transition[themePart].property,
13353
+ transitionTimingFunction
13340
13354
  }
13341
13355
  },
13342
- children: [shouldRenderArrow && placement === 'bottom' ? /*#__PURE__*/jsx(Arrow, {
13343
- ref: arrowRef,
13344
- position: "bottom",
13345
- ...sharedArrowProps
13346
- }) : null, /*#__PURE__*/jsx(TooltipContent, {
13347
- children: content
13348
- }), shouldRenderArrow && placement === 'top' ? /*#__PURE__*/jsx(Arrow, {
13349
- ref: arrowRef,
13350
- position: "top",
13351
- ...sharedArrowProps
13352
- }) : null]
13356
+ onTouchStart: handleToggleTooltip,
13357
+ onTouchEnd: handleToggleTooltip,
13358
+ onMouseEnter: handleToggleTooltip,
13359
+ onMouseLeave: handleToggleTooltip,
13360
+ children: /*#__PURE__*/jsxs(View, {
13361
+ _web: {
13362
+ style: {
13363
+ transform: `scale(${isVisible ? 1 : 0.8})`,
13364
+ transitionDuration: isVisible ? '0' : transitionDuration,
13365
+ transitionProperty: 'all',
13366
+ transitionTimingFunction,
13367
+ transformOrigin
13368
+ }
13369
+ },
13370
+ children: [shouldRenderArrow && placement === 'bottom' ? /*#__PURE__*/jsx(Arrow, {
13371
+ ref: arrowRef,
13372
+ position: "bottom",
13373
+ ...sharedArrowProps
13374
+ }) : null, /*#__PURE__*/jsx(TooltipContent, {
13375
+ children: content
13376
+ }), shouldRenderArrow && placement === 'top' ? /*#__PURE__*/jsx(Arrow, {
13377
+ ref: arrowRef,
13378
+ position: "top",
13379
+ ...sharedArrowProps
13380
+ }) : null]
13381
+ })
13353
13382
  })
13354
- }), document.body)]
13383
+ })]
13355
13384
  });
13356
13385
  }
13357
13386
  Tooltip.Arrow = Arrow;