@doist/reactist 22.3.2 → 22.3.4-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.
Files changed (48) hide show
  1. package/dist/reactist.cjs.development.js +140 -183
  2. package/dist/reactist.cjs.development.js.map +1 -1
  3. package/dist/reactist.cjs.production.min.js +1 -1
  4. package/dist/reactist.cjs.production.min.js.map +1 -1
  5. package/es/checkbox-field/checkbox-field.js +1 -1
  6. package/es/checkbox-field/checkbox-field.js.map +1 -1
  7. package/es/checkbox-field/use-fork-ref.js +35 -0
  8. package/es/checkbox-field/use-fork-ref.js.map +1 -0
  9. package/es/menu/menu.js +35 -38
  10. package/es/menu/menu.js.map +1 -1
  11. package/es/modal/modal.js +3 -4
  12. package/es/modal/modal.js.map +1 -1
  13. package/es/prose/prose.module.css.js +1 -1
  14. package/es/tabs/tabs.js +40 -47
  15. package/es/tabs/tabs.js.map +1 -1
  16. package/es/toast/use-toasts.js +1 -1
  17. package/es/toast/use-toasts.js.map +1 -1
  18. package/es/tooltip/tooltip.js +23 -62
  19. package/es/tooltip/tooltip.js.map +1 -1
  20. package/lib/checkbox-field/checkbox-field.js +1 -1
  21. package/lib/checkbox-field/checkbox-field.js.map +1 -1
  22. package/lib/checkbox-field/use-fork-ref.d.ts +11 -0
  23. package/lib/checkbox-field/use-fork-ref.js +2 -0
  24. package/lib/checkbox-field/use-fork-ref.js.map +1 -0
  25. package/lib/menu/menu.d.ts +4 -4
  26. package/lib/menu/menu.js +1 -1
  27. package/lib/menu/menu.js.map +1 -1
  28. package/lib/modal/modal.d.ts +1 -2
  29. package/lib/modal/modal.js +1 -1
  30. package/lib/modal/modal.js.map +1 -1
  31. package/lib/prose/prose.module.css.js +1 -1
  32. package/lib/tabs/tabs.d.ts +10 -8
  33. package/lib/tabs/tabs.js +1 -1
  34. package/lib/tabs/tabs.js.map +1 -1
  35. package/lib/toast/use-toasts.js +1 -1
  36. package/lib/toast/use-toasts.js.map +1 -1
  37. package/lib/tooltip/tooltip.d.ts +2 -4
  38. package/lib/tooltip/tooltip.js +1 -1
  39. package/lib/tooltip/tooltip.js.map +1 -1
  40. package/lib/utils/test-helpers.d.ts +13 -2
  41. package/package.json +2 -4
  42. package/styles/prose.css +1 -1
  43. package/styles/prose.module.css.css +1 -1
  44. package/styles/reactist.css +1 -1
  45. package/es/hooks/use-previous/use-previous.js +0 -26
  46. package/es/hooks/use-previous/use-previous.js.map +0 -1
  47. package/lib/hooks/use-previous/use-previous.js +0 -2
  48. package/lib/hooks/use-previous/use-previous.js.map +0 -1
@@ -8,15 +8,10 @@ var React = require('react');
8
8
  var React__default = _interopDefault(React);
9
9
  var classNames = _interopDefault(require('classnames'));
10
10
  var flattenChildren = _interopDefault(require('react-keyed-flatten-children'));
11
- var tooltip = require('ariakit/tooltip');
12
- var portal = require('ariakit/portal');
13
- var ariakitReactUtils = require('ariakit-react-utils');
11
+ var react = require('@ariakit/react');
14
12
  var useCallbackRef = require('use-callback-ref');
15
13
  var FocusLock = _interopDefault(require('react-focus-lock'));
16
14
  var ariaHidden = require('aria-hidden');
17
- var dialog = require('ariakit/dialog');
18
- var tab = require('ariakit/tab');
19
- var Ariakit = require('ariakit/menu');
20
15
  var ReactDOM = _interopDefault(require('react-dom'));
21
16
  var dayjs = _interopDefault(require('dayjs'));
22
17
  var LocalizedFormat = _interopDefault(require('dayjs/plugin/localizedFormat'));
@@ -455,18 +450,6 @@ const HiddenVisually = /*#__PURE__*/polymorphicComponent(function HiddenVisually
455
450
 
456
451
  var modules_95f1407a = {"tooltip":"_487c82cd"};
457
452
 
458
- const SHOW_DELAY = 1000;
459
- const HIDE_DELAY = 100;
460
-
461
- function useDelayedTooltipState(initialState) {
462
- const tooltipState = tooltip.useTooltipState(initialState);
463
- const delay = useDelay();
464
- return React.useMemo(() => _objectSpread2(_objectSpread2({}, tooltipState), {}, {
465
- show: delay(() => tooltipState.show(), SHOW_DELAY),
466
- hide: delay(() => tooltipState.hide(), HIDE_DELAY)
467
- }), [delay, tooltipState]);
468
- }
469
-
470
453
  function Tooltip({
471
454
  children,
472
455
  content,
@@ -475,10 +458,12 @@ function Tooltip({
475
458
  withArrow = false,
476
459
  exceptionallySetClassName
477
460
  }) {
478
- const state = useDelayedTooltipState({
461
+ const tooltip = react.useTooltipStore({
479
462
  placement: position,
480
- gutter: gapSize
463
+ showTimeout: 500,
464
+ hideTimeout: 100
481
465
  });
466
+ const isOpen = tooltip.useState('open');
482
467
  const child = React.Children.only(children);
483
468
 
484
469
  if (!child) {
@@ -507,7 +492,7 @@ function Tooltip({
507
492
  const eventKey = event.key;
508
493
 
509
494
  if (eventKey !== 'Escape' && eventKey !== 'Enter' && eventKey !== 'Space') {
510
- state.show();
495
+ tooltip.show();
511
496
  }
512
497
  }
513
498
 
@@ -522,25 +507,26 @@ function Tooltip({
522
507
  function handleBlur(event) {
523
508
  var _child$props2;
524
509
 
525
- state.hide();
510
+ tooltip.hide();
526
511
  child == null ? void 0 : (_child$props2 = child.props) == null ? void 0 : _child$props2.onBlur == null ? void 0 : _child$props2.onBlur(event);
527
512
  }
528
513
 
529
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(tooltip.TooltipAnchor, {
530
- state: state,
531
- ref: child.ref,
532
- described: true
533
- }, anchorProps => {
534
- // Let child props override anchor props so user can specify attributes like tabIndex
535
- // Also, do not apply the child's props to TooltipAnchor as props like `as` can create problems
536
- // by applying the replacement component/element twice
537
- return /*#__PURE__*/React.cloneElement(child, _objectSpread2(_objectSpread2(_objectSpread2({}, anchorProps), child.props), {}, {
538
- onFocus: handleFocus,
539
- onBlur: handleBlur
540
- }));
541
- }), state.open && content ? /*#__PURE__*/React.createElement(Box, {
542
- as: tooltip.Tooltip,
543
- state: state,
514
+ 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
+ },
524
+ store: tooltip,
525
+ ref: child.ref
526
+ }), isOpen && content ? /*#__PURE__*/React.createElement(Box, {
527
+ as: react.Tooltip,
528
+ gutter: gapSize,
529
+ store: tooltip,
544
530
  className: [modules_95f1407a.tooltip, exceptionallySetClassName],
545
531
  background: "toast",
546
532
  borderRadius: "standard",
@@ -550,37 +536,7 @@ function Tooltip({
550
536
  width: "fitContent",
551
537
  overflow: "hidden",
552
538
  textAlign: "center"
553
- }, withArrow ? /*#__PURE__*/React.createElement(tooltip.TooltipArrow, null) : null, typeof content === 'function' ? content() : content) : null);
554
- }
555
- // Internal helpers
556
- //
557
-
558
- /**
559
- * Returns a function offering the same interface as setTimeout, but cleans up on unmount.
560
- *
561
- * The timeout state is shared, and only one delayed function can be active at any given time. If
562
- * a new delayed function is called while another one was waiting for its time to run, that older
563
- * invocation is cleared and it never runs.
564
- *
565
- * This is suitable for our use case here, but probably not the most intuitive thing in general.
566
- * That's why this is not made a shared util or something like it.
567
- */
568
-
569
- function useDelay() {
570
- const timeoutRef = React.useRef();
571
- const clearTimeouts = React.useCallback(function clearTimeouts() {
572
- if (timeoutRef.current != null) {
573
- clearTimeout(timeoutRef.current);
574
- }
575
- }, []); // Runs clearTimeouts when the component is unmounted
576
-
577
- React.useEffect(() => clearTimeouts, [clearTimeouts]);
578
- return React.useCallback(function delay(fn, delay) {
579
- return () => {
580
- clearTimeouts();
581
- timeoutRef.current = setTimeout(fn, delay);
582
- };
583
- }, [clearTimeouts]);
539
+ }, withArrow ? /*#__PURE__*/React.createElement(react.TooltipArrow, null) : null, typeof content === 'function' ? content() : content) : null);
584
540
  }
585
541
 
586
542
  var modules_c7f5018f = {"svg":"_51539197","spinner":"_54fbe2b3","tint":"a0c466ed","fill":"_745b73d3"};
@@ -1355,7 +1311,7 @@ function ToastsProvider({
1355
1311
  }, [defaultAutoDismissDelay, defaultDismissLabel, removeToast]);
1356
1312
  return /*#__PURE__*/React__default.createElement(ToastsContext.Provider, {
1357
1313
  value: showToast
1358
- }, children, /*#__PURE__*/React__default.createElement(portal.Portal, null, toasts.length === 0 ? null : /*#__PURE__*/React__default.createElement(Box, {
1314
+ }, children, /*#__PURE__*/React__default.createElement(react.Portal, null, toasts.length === 0 ? null : /*#__PURE__*/React__default.createElement(Box, {
1359
1315
  className: [modules_d11e18f0.stackedToastsView, containerClassName],
1360
1316
  position: "fixed",
1361
1317
  width: "full",
@@ -1473,7 +1429,7 @@ const Heading = /*#__PURE__*/React.forwardRef(function Heading(_ref, ref) {
1473
1429
  }), children);
1474
1430
  });
1475
1431
 
1476
- var modules_8ebe6db0 = {"prose":"e3d32437","darkModeTypography":"_95ee669d"};
1432
+ var modules_8ebe6db0 = {"prose":"_31409006","darkModeTypography":"_500989c8"};
1477
1433
 
1478
1434
  const _excluded$f = ["darkModeTypography", "exceptionallySetClassName"];
1479
1435
  /**
@@ -1604,6 +1560,37 @@ function CheckboxIcon(_ref) {
1604
1560
 
1605
1561
  var modules_664a6a80 = {"container":"_84dfdb83","disabled":"_131a2ca4","checked":"_95b1556d","keyFocused":"_49de7ebd","icon":"_6b4b1851","label":"_9047f3bd"};
1606
1562
 
1563
+ /**
1564
+ * Sets both a function and object React ref.
1565
+ */
1566
+
1567
+ function setRef(ref, value) {
1568
+ if (typeof ref === 'function') {
1569
+ ref(value);
1570
+ } else if (ref) {
1571
+ ref.current = value;
1572
+ }
1573
+ }
1574
+ /**
1575
+ * Merges React Refs into a single memoized function ref so you can pass it to an element.
1576
+ * @example
1577
+ * const Component = React.forwardRef((props, ref) => {
1578
+ * const internalRef = React.useRef();
1579
+ * return <div {...props} ref={useForkRef(internalRef, ref)} />;
1580
+ * });
1581
+ */
1582
+
1583
+
1584
+ function useForkRef(...refs) {
1585
+ return React.useMemo(() => {
1586
+ if (!refs.some(Boolean)) return;
1587
+ return value => {
1588
+ refs.forEach(ref => setRef(ref, value));
1589
+ };
1590
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
1591
+ refs);
1592
+ }
1593
+
1607
1594
  const _excluded$j = ["label", "icon", "disabled", "indeterminate", "defaultChecked", "onChange"];
1608
1595
  const CheckboxField = /*#__PURE__*/React.forwardRef(function CheckboxField(_ref, ref) {
1609
1596
  var _ref2, _props$checked, _props$checked2;
@@ -1635,7 +1622,7 @@ const CheckboxField = /*#__PURE__*/React.forwardRef(function CheckboxField(_ref,
1635
1622
  const [checkedState, setChecked] = React.useState((_ref2 = (_props$checked = props.checked) != null ? _props$checked : defaultChecked) != null ? _ref2 : false);
1636
1623
  const isChecked = (_props$checked2 = props.checked) != null ? _props$checked2 : checkedState;
1637
1624
  const internalRef = React.useRef(null);
1638
- const combinedRef = ariakitReactUtils.useForkRef(internalRef, ref);
1625
+ const combinedRef = useForkRef(internalRef, ref);
1639
1626
  React.useEffect(function setIndeterminate() {
1640
1627
  if (internalRef.current && typeof indeterminate === 'boolean') {
1641
1628
  internalRef.current.indeterminate = indeterminate;
@@ -2246,7 +2233,7 @@ function Modal(_ref) {
2246
2233
  onDismiss == null ? void 0 : onDismiss();
2247
2234
  }
2248
2235
  }, [onDismiss]);
2249
- const state = dialog.useDialogState({
2236
+ const store = react.useDialogStore({
2250
2237
  open: isOpen,
2251
2238
  setOpen
2252
2239
  });
@@ -2280,7 +2267,7 @@ function Modal(_ref) {
2280
2267
  return null;
2281
2268
  }
2282
2269
 
2283
- return /*#__PURE__*/React.createElement(portal.Portal, {
2270
+ return /*#__PURE__*/React.createElement(react.Portal, {
2284
2271
  portalRef: portalRef,
2285
2272
  portalElement: portalElement
2286
2273
  }, /*#__PURE__*/React.createElement(Box, {
@@ -2299,10 +2286,10 @@ function Modal(_ref) {
2299
2286
  autoFocus: autoFocus,
2300
2287
  whiteList: isNotInternalFrame,
2301
2288
  returnFocus: true
2302
- }, /*#__PURE__*/React.createElement(dialog.Dialog, _objectSpread2(_objectSpread2({}, props), {}, {
2289
+ }, /*#__PURE__*/React.createElement(react.Dialog, _objectSpread2(_objectSpread2({}, props), {}, {
2303
2290
  ref: dialogRef,
2304
2291
  as: Box,
2305
- state: state,
2292
+ store: store,
2306
2293
  hideOnEscape: hideOnEscape,
2307
2294
  preventBodyScroll: true,
2308
2295
  borderRadius: "full",
@@ -2464,28 +2451,6 @@ function ModalActions(_ref5) {
2464
2451
  }, children));
2465
2452
  }
2466
2453
 
2467
- /**
2468
- * usePrevious tracks the change of the given value -
2469
- * when a given value has been changed from a previous call,
2470
- * it will return the value prior to the change.
2471
- *
2472
- * Example:
2473
- *
2474
- * const [x, setX] = useState(1)
2475
- * const prevX = usePrevious(x)
2476
- *
2477
- * Suppose `setX(2)` is called, then in the next component render
2478
- * x = 2 and prevX = 1
2479
- */
2480
-
2481
- function usePrevious(value) {
2482
- const ref = React.useRef(null);
2483
- React.useEffect(() => {
2484
- ref.current = value;
2485
- }, [value]);
2486
- return ref.current;
2487
- }
2488
-
2489
2454
  var modules_40c67f5b = {"tab":"e96bf360","track":"_430e252d","tab-neutral":"f631ccbe","tab-themed":"_6ba96acc","track-neutral":"ef4cd8d3","track-themed":"_344b3b10"};
2490
2455
 
2491
2456
  const _excluded$s = ["as", "children", "id", "exceptionallySetClassName"],
@@ -2503,26 +2468,21 @@ function Tabs({
2503
2468
  variant = 'neutral',
2504
2469
  onSelectedIdChange
2505
2470
  }) {
2506
- const tabState = tab.useTabState({
2471
+ const tabStore = react.useTabStore({
2472
+ defaultSelectedId,
2507
2473
  selectedId,
2508
2474
  setSelectedId: onSelectedIdChange
2509
2475
  });
2510
- const previousDefaultSelectedId = usePrevious(defaultSelectedId);
2511
- const {
2512
- selectedId: actualSelectedId,
2513
- select
2514
- } = tabState;
2515
- React.useEffect(function selectDefaultTab() {
2516
- if (!selectedId && defaultSelectedId !== previousDefaultSelectedId && defaultSelectedId !== actualSelectedId && defaultSelectedId !== undefined) {
2517
- select(defaultSelectedId);
2518
- }
2519
- }, [selectedId, defaultSelectedId, actualSelectedId, select, previousDefaultSelectedId]);
2520
- const memoizedTabState = React.useMemo(function memoizeTabState() {
2476
+ const actualSelectedId = tabStore.useState('selectedId');
2477
+ const memoizedTabState = React.useMemo(() => {
2478
+ var _ref;
2479
+
2521
2480
  return {
2522
- tabState,
2523
- variant
2481
+ tabStore,
2482
+ variant,
2483
+ selectedId: (_ref = selectedId != null ? selectedId : actualSelectedId) != null ? _ref : null
2524
2484
  };
2525
- }, [variant, tabState]);
2485
+ }, [variant, tabStore, selectedId, actualSelectedId]);
2526
2486
  return /*#__PURE__*/React.createElement(TabsContext.Provider, {
2527
2487
  value: memoizedTabState
2528
2488
  }, children);
@@ -2532,30 +2492,27 @@ function Tabs({
2532
2492
  */
2533
2493
 
2534
2494
 
2535
- const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref, ref) {
2495
+ const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref2, ref) {
2536
2496
  let {
2537
2497
  as,
2538
2498
  children,
2539
2499
  id,
2540
2500
  exceptionallySetClassName
2541
- } = _ref,
2542
- props = _objectWithoutProperties(_ref, _excluded$s);
2501
+ } = _ref2,
2502
+ props = _objectWithoutProperties(_ref2, _excluded$s);
2543
2503
 
2544
2504
  const tabContextValue = React.useContext(TabsContext);
2545
-
2546
- if (!tabContextValue) {
2547
- return null;
2548
- }
2549
-
2505
+ if (!tabContextValue) return null;
2550
2506
  const {
2551
2507
  variant,
2552
- tabState
2508
+ tabStore
2553
2509
  } = tabContextValue;
2554
- return /*#__PURE__*/React.createElement(tab.Tab, _objectSpread2(_objectSpread2({}, props), {}, {
2510
+ const className = classNames(exceptionallySetClassName, modules_40c67f5b.tab, modules_40c67f5b["tab-" + variant]);
2511
+ return /*#__PURE__*/React.createElement(react.Tab, _objectSpread2(_objectSpread2({}, props), {}, {
2555
2512
  as: as,
2556
- className: classNames(exceptionallySetClassName, modules_40c67f5b.tab, modules_40c67f5b["tab-" + variant]),
2513
+ className: className,
2557
2514
  id: id,
2558
- state: tabState,
2515
+ store: tabStore,
2559
2516
  ref: ref
2560
2517
  }), children);
2561
2518
  });
@@ -2563,12 +2520,12 @@ const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref, ref) {
2563
2520
  * A component used to group `<Tab>` elements together.
2564
2521
  */
2565
2522
 
2566
- function TabList(_ref2) {
2523
+ function TabList(_ref3) {
2567
2524
  let {
2568
2525
  children,
2569
2526
  space
2570
- } = _ref2,
2571
- props = _objectWithoutProperties(_ref2, _excluded2$2);
2527
+ } = _ref3,
2528
+ props = _objectWithoutProperties(_ref3, _excluded2$2);
2572
2529
 
2573
2530
  const tabContextValue = React.useContext(TabsContext);
2574
2531
 
@@ -2577,15 +2534,15 @@ function TabList(_ref2) {
2577
2534
  }
2578
2535
 
2579
2536
  const {
2580
- tabState,
2537
+ tabStore,
2581
2538
  variant
2582
2539
  } = tabContextValue;
2583
2540
  return (
2584
2541
  /*#__PURE__*/
2585
2542
  // The extra <Box> prevents <Inline>'s negative margins from collapsing when used in a flex container
2586
2543
  // which will render the track with the wrong height
2587
- React.createElement(Box, null, /*#__PURE__*/React.createElement(tab.TabList, _objectSpread2({
2588
- state: tabState,
2544
+ React.createElement(Box, null, /*#__PURE__*/React.createElement(react.TabList, _objectSpread2({
2545
+ store: tabStore,
2589
2546
  as: Box,
2590
2547
  position: "relative",
2591
2548
  width: "maxContent"
@@ -2597,22 +2554,24 @@ function TabList(_ref2) {
2597
2554
  );
2598
2555
  }
2599
2556
  /**
2600
- * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a corresponding `<Tab>` component.
2557
+ * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a
2558
+ * corresponding `<Tab>` component.
2601
2559
  */
2602
2560
 
2603
2561
 
2604
- const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref3, ref) {
2562
+ const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref4, ref) {
2605
2563
  let {
2606
2564
  children,
2607
2565
  id,
2608
2566
  as,
2609
2567
  render = 'always'
2610
- } = _ref3,
2611
- props = _objectWithoutProperties(_ref3, _excluded3$1);
2568
+ } = _ref4,
2569
+ props = _objectWithoutProperties(_ref4, _excluded3$1);
2612
2570
 
2613
2571
  const tabContextValue = React.useContext(TabsContext);
2614
2572
  const [tabRendered, setTabRendered] = React.useState(false);
2615
- const tabIsActive = (tabContextValue == null ? void 0 : tabContextValue.tabState.selectedId) === id;
2573
+ const selectedId = tabContextValue == null ? void 0 : tabContextValue.tabStore.useState('selectedId');
2574
+ const tabIsActive = selectedId === id;
2616
2575
  React.useEffect(function trackTabRenderedState() {
2617
2576
  if (!tabRendered && tabIsActive) {
2618
2577
  setTabRendered(true);
@@ -2624,28 +2583,28 @@ const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref3, ref)
2624
2583
  }
2625
2584
 
2626
2585
  const {
2627
- tabState
2586
+ tabStore
2628
2587
  } = tabContextValue;
2629
2588
  const shouldRender = render === 'always' || render === 'active' && tabIsActive || render === 'lazy' && (tabIsActive || tabRendered);
2630
- return shouldRender ? /*#__PURE__*/React.createElement(tab.TabPanel, _objectSpread2(_objectSpread2({
2631
- tabId: id
2632
- }, props), {}, {
2633
- state: tabState,
2589
+ return shouldRender ? /*#__PURE__*/React.createElement(react.TabPanel, _objectSpread2(_objectSpread2({}, props), {}, {
2590
+ tabId: id,
2591
+ store: tabStore,
2634
2592
  as: as,
2635
2593
  ref: ref
2636
2594
  }), children) : null;
2637
2595
  });
2638
2596
  /**
2639
- * Allows content to be rendered based on the current tab being selected while outside of the TabPanel
2640
- * component. Can be placed freely within the main `<Tabs>` component.
2597
+ * Allows content to be rendered based on the current tab being selected while outside of the
2598
+ * TabPanel component. Can be placed freely within the main `<Tabs>` component.
2641
2599
  */
2642
2600
 
2643
2601
  function TabAwareSlot({
2644
2602
  children
2645
2603
  }) {
2646
2604
  const tabContextValue = React.useContext(TabsContext);
2605
+ const selectedId = tabContextValue == null ? void 0 : tabContextValue.tabStore.useState('selectedId');
2647
2606
  return tabContextValue ? children({
2648
- selectedId: tabContextValue == null ? void 0 : tabContextValue.tabState.selectedId
2607
+ selectedId
2649
2608
  }) : null;
2650
2609
  }
2651
2610
 
@@ -2673,27 +2632,20 @@ function Menu(_ref) {
2673
2632
  } = _ref,
2674
2633
  props = _objectWithoutProperties(_ref, _excluded$t);
2675
2634
 
2676
- const [anchorRect, handleAnchorRectChange] = React.useState(null);
2677
- const getAnchorRect = React.useMemo(() => {
2678
- return anchorRect ? () => anchorRect : undefined;
2679
- }, [anchorRect]);
2680
- const state = Ariakit.useMenuState(_objectSpread2({
2681
- focusLoop: true,
2682
- gutter: 8,
2683
- shift: 4,
2684
- getAnchorRect
2635
+ const [anchorRect, setAnchorRect] = React.useState(null);
2636
+ const getAnchorRect = React.useMemo(() => anchorRect ? () => anchorRect : null, [anchorRect]);
2637
+ const menuStore = react.useMenuStore(_objectSpread2({
2638
+ focusLoop: true
2685
2639
  }, props));
2686
- React.useEffect(() => {
2687
- if (!state.open) handleAnchorRectChange(null);
2688
- }, [state.open]);
2689
2640
  const handleItemSelect = React.useCallback(function handleItemSelect(value) {
2690
- if (onItemSelect) onItemSelect(value);
2641
+ onItemSelect == null ? void 0 : onItemSelect(value);
2691
2642
  }, [onItemSelect]);
2692
2643
  const value = React.useMemo(() => ({
2693
- state,
2644
+ menuStore,
2694
2645
  handleItemSelect,
2695
- handleAnchorRectChange
2696
- }), [state, handleItemSelect]);
2646
+ getAnchorRect,
2647
+ setAnchorRect
2648
+ }), [menuStore, handleItemSelect, getAnchorRect, setAnchorRect]);
2697
2649
  return /*#__PURE__*/React.createElement(MenuContext.Provider, {
2698
2650
  value: value
2699
2651
  }, children);
@@ -2710,10 +2662,10 @@ const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2,
2710
2662
  props = _objectWithoutProperties(_ref2, _excluded2$3);
2711
2663
 
2712
2664
  const {
2713
- state
2665
+ menuStore
2714
2666
  } = React.useContext(MenuContext);
2715
- return /*#__PURE__*/React.createElement(Ariakit.MenuButton, _objectSpread2(_objectSpread2({}, props), {}, {
2716
- state: state,
2667
+ return /*#__PURE__*/React.createElement(react.MenuButton, _objectSpread2(_objectSpread2({}, props), {}, {
2668
+ store: menuStore,
2717
2669
  ref: ref,
2718
2670
  className: classNames('reactist_menubutton', exceptionallySetClassName)
2719
2671
  }));
@@ -2728,17 +2680,17 @@ const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMen
2728
2680
  props = _objectWithoutProperties(_ref3, _excluded3$2);
2729
2681
 
2730
2682
  const {
2731
- handleAnchorRectChange,
2732
- state
2683
+ setAnchorRect,
2684
+ menuStore
2733
2685
  } = React.useContext(MenuContext);
2734
- const handleContextMenu = React.useCallback(event => {
2686
+ const handleContextMenu = React.useCallback(function handleContextMenu(event) {
2735
2687
  event.preventDefault();
2736
- handleAnchorRectChange({
2688
+ setAnchorRect({
2737
2689
  x: event.clientX,
2738
2690
  y: event.clientY
2739
2691
  });
2740
- state.show();
2741
- }, [handleAnchorRectChange, state]);
2692
+ menuStore.show();
2693
+ }, [setAnchorRect, menuStore]);
2742
2694
  return /*#__PURE__*/React.createElement(component, _objectSpread2(_objectSpread2({}, props), {}, {
2743
2695
  onContextMenu: handleContextMenu,
2744
2696
  ref
@@ -2756,14 +2708,19 @@ const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref4, ref)
2756
2708
  props = _objectWithoutProperties(_ref4, _excluded4$1);
2757
2709
 
2758
2710
  const {
2759
- state
2711
+ menuStore,
2712
+ getAnchorRect
2760
2713
  } = React.useContext(MenuContext);
2761
- return state.open ? /*#__PURE__*/React.createElement(portal.Portal, {
2714
+ const isOpen = menuStore.useState('open');
2715
+ return isOpen ? /*#__PURE__*/React.createElement(react.Portal, {
2762
2716
  preserveTabOrder: true
2763
- }, /*#__PURE__*/React.createElement(Ariakit.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
2764
- state: state,
2717
+ }, /*#__PURE__*/React.createElement(react.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
2718
+ store: menuStore,
2719
+ gutter: 8,
2720
+ shift: 4,
2765
2721
  ref: ref,
2766
2722
  className: classNames('reactist_menulist', exceptionallySetClassName),
2723
+ getAnchorRect: getAnchorRect != null ? getAnchorRect : undefined,
2767
2724
  modal: modal
2768
2725
  }))) : null;
2769
2726
  });
@@ -2786,11 +2743,11 @@ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref)
2786
2743
 
2787
2744
  const {
2788
2745
  handleItemSelect,
2789
- state
2746
+ menuStore
2790
2747
  } = React.useContext(MenuContext);
2791
2748
  const {
2792
2749
  hide
2793
- } = state;
2750
+ } = menuStore;
2794
2751
  const handleClick = React.useCallback(function handleClick(event) {
2795
2752
  onClick == null ? void 0 : onClick(event);
2796
2753
  const onSelectResult = onSelect && !event.defaultPrevented ? onSelect() : undefined;
@@ -2798,9 +2755,9 @@ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref)
2798
2755
  handleItemSelect(value);
2799
2756
  if (shouldClose) hide();
2800
2757
  }, [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value]);
2801
- return /*#__PURE__*/React.createElement(Ariakit.MenuItem, _objectSpread2(_objectSpread2({}, props), {}, {
2758
+ return /*#__PURE__*/React.createElement(react.MenuItem, _objectSpread2(_objectSpread2({}, props), {}, {
2802
2759
  as: as,
2803
- state: state,
2760
+ store: menuStore,
2804
2761
  ref: ref,
2805
2762
  onClick: handleClick,
2806
2763
  className: exceptionallySetClassName,
@@ -2835,11 +2792,11 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
2835
2792
  }, ref) {
2836
2793
  const {
2837
2794
  handleItemSelect: parentMenuItemSelect,
2838
- state
2795
+ menuStore
2839
2796
  } = React.useContext(MenuContext);
2840
2797
  const {
2841
2798
  hide: parentMenuHide
2842
- } = state;
2799
+ } = menuStore;
2843
2800
  const handleSubItemSelect = React.useCallback(function handleSubItemSelect(value) {
2844
2801
  if (onItemSelect) onItemSelect(value);
2845
2802
  parentMenuItemSelect(value);
@@ -2853,9 +2810,9 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
2853
2810
  }, [button]);
2854
2811
  return /*#__PURE__*/React.createElement(Menu, {
2855
2812
  onItemSelect: handleSubItemSelect
2856
- }, /*#__PURE__*/React.createElement(Ariakit.MenuItem, {
2813
+ }, /*#__PURE__*/React.createElement(react.MenuItem, {
2857
2814
  as: "div",
2858
- state: state,
2815
+ store: menuStore,
2859
2816
  ref: ref,
2860
2817
  hideOnClick: false
2861
2818
  }, renderMenuButton), list);
@@ -2876,11 +2833,11 @@ const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(_ref6, re
2876
2833
  props = _objectWithoutProperties(_ref6, _excluded6);
2877
2834
 
2878
2835
  const {
2879
- state
2836
+ menuStore
2880
2837
  } = React.useContext(MenuContext);
2881
- return /*#__PURE__*/React.createElement(Ariakit.MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
2838
+ return /*#__PURE__*/React.createElement(react.MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
2882
2839
  ref: ref,
2883
- state: state,
2840
+ store: menuStore,
2884
2841
  className: exceptionallySetClassName
2885
2842
  }), label ? /*#__PURE__*/React.createElement("div", {
2886
2843
  role: "presentation",