@doist/reactist 24.1.0-beta → 24.1.1-beta

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.
@@ -473,54 +473,9 @@ function Tooltip({
473
473
  if (typeof child.ref === 'string') {
474
474
  throw new Error('Tooltip: String refs cannot be used as they cannot be forwarded');
475
475
  }
476
- /**
477
- * Prevents the tooltip from automatically firing on focus all the time. This is to prevent
478
- * tooltips from showing when the trigger element is focused back after a popover or dialog that
479
- * it opened was closed. See link below for more details.
480
- * @see https://github.com/ariakit/ariakit/discussions/749
481
- */
482
-
483
-
484
- function handleFocus(event) {
485
- var _child$props;
486
-
487
- // If focus is not followed by a key up event, does it mean that it's not an intentional
488
- // keyboard focus? Not sure but it seems to work.
489
- // This may be resolved soon in an upcoming version of ariakit:
490
- // https://github.com/ariakit/ariakit/issues/750
491
- function handleKeyUp(event) {
492
- const eventKey = event.key;
493
-
494
- if (eventKey !== 'Escape' && eventKey !== 'Enter' && eventKey !== 'Space') {
495
- tooltip.show();
496
- }
497
- }
498
-
499
- event.currentTarget.addEventListener('keyup', handleKeyUp, {
500
- once: true
501
- });
502
- event.preventDefault(); // Prevent tooltip.show from being called by TooltipReference
503
-
504
- child == null ? void 0 : (_child$props = child.props) == null ? void 0 : _child$props.onFocus == null ? void 0 : _child$props.onFocus(event);
505
- }
506
-
507
- function handleBlur(event) {
508
- var _child$props2;
509
-
510
- tooltip.hide();
511
- child == null ? void 0 : (_child$props2 = child.props) == null ? void 0 : _child$props2.onBlur == null ? void 0 : _child$props2.onBlur(event);
512
- }
513
476
 
514
477
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(react.TooltipAnchor, {
515
- render: anchorProps => {
516
- // Let child props override anchor props so user can specify attributes like tabIndex
517
- // Also, do not apply the child's props to TooltipAnchor as props like `as` can create problems
518
- // by applying the replacement component/element twice
519
- return /*#__PURE__*/React.cloneElement(child, _objectSpread2(_objectSpread2(_objectSpread2({}, child.props), anchorProps), {}, {
520
- onFocus: handleFocus,
521
- onBlur: handleBlur
522
- }));
523
- },
478
+ render: child,
524
479
  store: tooltip,
525
480
  ref: child.ref
526
481
  }), isOpen && content ? /*#__PURE__*/React.createElement(Box, {
@@ -2647,15 +2602,12 @@ function Menu(_ref) {
2647
2602
  const menuStore = react.useMenuStore(_objectSpread2({
2648
2603
  focusLoop: true
2649
2604
  }, props));
2650
- const handleItemSelect = React.useCallback(function handleItemSelect(value) {
2651
- onItemSelect == null ? void 0 : onItemSelect(value);
2652
- }, [onItemSelect]);
2653
2605
  const value = React.useMemo(() => ({
2654
2606
  menuStore,
2655
- handleItemSelect,
2607
+ handleItemSelect: onItemSelect,
2656
2608
  getAnchorRect,
2657
2609
  setAnchorRect
2658
- }), [menuStore, handleItemSelect, getAnchorRect, setAnchorRect]);
2610
+ }), [menuStore, onItemSelect, getAnchorRect, setAnchorRect]);
2659
2611
  return /*#__PURE__*/React.createElement(MenuContext.Provider, {
2660
2612
  value: value
2661
2613
  }, children);
@@ -2731,7 +2683,15 @@ const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref4, ref)
2731
2683
  ref: ref,
2732
2684
  className: classNames('reactist_menulist', exceptionallySetClassName),
2733
2685
  getAnchorRect: getAnchorRect != null ? getAnchorRect : undefined,
2734
- modal: modal
2686
+ modal: modal,
2687
+ onBlur: event => {
2688
+ var _event$relatedTarget;
2689
+
2690
+ if (!event.relatedTarget) return;
2691
+ if (event.currentTarget.contains(event.relatedTarget)) return;
2692
+ if ((_event$relatedTarget = event.relatedTarget) != null && _event$relatedTarget.closest('[role^="menu"]')) return;
2693
+ menuStore.hide();
2694
+ }
2735
2695
  }))) : null;
2736
2696
  });
2737
2697
  /**
@@ -2762,7 +2722,7 @@ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref)
2762
2722
  onClick == null ? void 0 : onClick(event);
2763
2723
  const onSelectResult = onSelect && !event.defaultPrevented ? onSelect() : undefined;
2764
2724
  const shouldClose = onSelectResult !== false && hideOnSelect;
2765
- handleItemSelect(value);
2725
+ handleItemSelect == null ? void 0 : handleItemSelect(value);
2766
2726
  if (shouldClose) hide();
2767
2727
  }, [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value]);
2768
2728
  return /*#__PURE__*/React.createElement(react.MenuItem, _objectSpread2(_objectSpread2({}, props), {}, {
@@ -2809,7 +2769,7 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
2809
2769
  } = menuStore;
2810
2770
  const handleSubItemSelect = React.useCallback(function handleSubItemSelect(value) {
2811
2771
  if (onItemSelect) onItemSelect(value);
2812
- parentMenuItemSelect(value);
2772
+ parentMenuItemSelect == null ? void 0 : parentMenuItemSelect(value);
2813
2773
  parentMenuHide();
2814
2774
  }, [parentMenuHide, parentMenuItemSelect, onItemSelect]);
2815
2775
  const [button, list] = React.Children.toArray(children); // Ariakit needs to be able to pass props to the MenuButton