@doist/reactist 23.1.0 → 24.0.0-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 (43) hide show
  1. package/dist/reactist.cjs.development.js +153 -186
  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 +17 -8
  12. package/es/modal/modal.js.map +1 -1
  13. package/es/tabs/tabs.js +40 -47
  14. package/es/tabs/tabs.js.map +1 -1
  15. package/es/toast/use-toasts.js +1 -1
  16. package/es/toast/use-toasts.js.map +1 -1
  17. package/es/tooltip/tooltip.js +23 -62
  18. package/es/tooltip/tooltip.js.map +1 -1
  19. package/lib/checkbox-field/checkbox-field.js +1 -1
  20. package/lib/checkbox-field/checkbox-field.js.map +1 -1
  21. package/lib/checkbox-field/use-fork-ref.d.ts +11 -0
  22. package/lib/checkbox-field/use-fork-ref.js +2 -0
  23. package/lib/checkbox-field/use-fork-ref.js.map +1 -0
  24. package/lib/menu/menu.d.ts +4 -4
  25. package/lib/menu/menu.js +1 -1
  26. package/lib/menu/menu.js.map +1 -1
  27. package/lib/modal/modal.d.ts +2 -3
  28. package/lib/modal/modal.js +1 -1
  29. package/lib/modal/modal.js.map +1 -1
  30. package/lib/tabs/tabs.d.ts +10 -8
  31. package/lib/tabs/tabs.js +1 -1
  32. package/lib/tabs/tabs.js.map +1 -1
  33. package/lib/toast/use-toasts.js +1 -1
  34. package/lib/toast/use-toasts.js.map +1 -1
  35. package/lib/tooltip/tooltip.d.ts +2 -4
  36. package/lib/tooltip/tooltip.js +1 -1
  37. package/lib/tooltip/tooltip.js.map +1 -1
  38. package/lib/utils/test-helpers.d.ts +13 -2
  39. package/package.json +2 -4
  40. package/es/hooks/use-previous/use-previous.js +0 -26
  41. package/es/hooks/use-previous/use-previous.js.map +0 -1
  42. package/lib/hooks/use-previous/use-previous.js +0 -2
  43. 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",
@@ -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;
@@ -2201,7 +2188,7 @@ function Badge(_ref) {
2201
2188
 
2202
2189
  var modules_8f59d13b = {"overlay":"_8aa86dd3","fadein":"_20c07ee6","fitContent":"_713bc08f","container":"_45139719","full":"ec8619a2","large":"_86a1d5a4","medium":"_11d61de3","small":"aee19643","xlarge":"fe449c81","expand":"_61ffb38f","buttonContainer":"_49ffdac0","headerContent":"ee92ccb3"};
2203
2190
 
2204
- const _excluded$r = ["isOpen", "onDismiss", "height", "width", "exceptionallySetClassName", "exceptionallySetOverlayClassName", "autoFocus", "hideOnEscape", "hideOnInteractOutside", "children", "portalElement"],
2191
+ const _excluded$r = ["isOpen", "onDismiss", "height", "width", "exceptionallySetClassName", "exceptionallySetOverlayClassName", "autoFocus", "hideOnEscape", "hideOnInteractOutside", "children", "portalElement", "onKeyDown"],
2205
2192
  _excluded2$1 = ["children", "button", "withDivider", "exceptionallySetClassName"],
2206
2193
  _excluded3 = ["exceptionallySetClassName", "children"],
2207
2194
  _excluded4 = ["exceptionallySetClassName", "withDivider"],
@@ -2237,7 +2224,8 @@ function Modal(_ref) {
2237
2224
  hideOnEscape = true,
2238
2225
  hideOnInteractOutside = true,
2239
2226
  children,
2240
- portalElement
2227
+ portalElement,
2228
+ onKeyDown
2241
2229
  } = _ref,
2242
2230
  props = _objectWithoutProperties(_ref, _excluded$r);
2243
2231
 
@@ -2246,7 +2234,7 @@ function Modal(_ref) {
2246
2234
  onDismiss == null ? void 0 : onDismiss();
2247
2235
  }
2248
2236
  }, [onDismiss]);
2249
- const state = dialog.useDialogState({
2237
+ const store = react.useDialogStore({
2250
2238
  open: isOpen,
2251
2239
  setOpen
2252
2240
  });
@@ -2275,12 +2263,20 @@ function Modal(_ref) {
2275
2263
 
2276
2264
  return ariaHidden.hideOthers(portalRef.current);
2277
2265
  }, [isOpen]);
2266
+ const handleKeyDown = React.useCallback(function handleKeyDown(event) {
2267
+ if (hideOnEscape && onDismiss != null && event.key === 'Escape' && !event.defaultPrevented) {
2268
+ event.stopPropagation();
2269
+ onDismiss();
2270
+ }
2271
+
2272
+ onKeyDown == null ? void 0 : onKeyDown(event);
2273
+ }, [onDismiss, hideOnEscape, onKeyDown]);
2278
2274
 
2279
2275
  if (!isOpen) {
2280
2276
  return null;
2281
2277
  }
2282
2278
 
2283
- return /*#__PURE__*/React.createElement(portal.Portal, {
2279
+ return /*#__PURE__*/React.createElement(react.Portal, {
2284
2280
  portalRef: portalRef,
2285
2281
  portalElement: portalElement
2286
2282
  }, /*#__PURE__*/React.createElement(Box, {
@@ -2299,11 +2295,10 @@ function Modal(_ref) {
2299
2295
  autoFocus: autoFocus,
2300
2296
  whiteList: isNotInternalFrame,
2301
2297
  returnFocus: true
2302
- }, /*#__PURE__*/React.createElement(dialog.Dialog, _objectSpread2(_objectSpread2({}, props), {}, {
2298
+ }, /*#__PURE__*/React.createElement(react.Dialog, _objectSpread2(_objectSpread2({}, props), {}, {
2303
2299
  ref: dialogRef,
2304
2300
  as: Box,
2305
- state: state,
2306
- hideOnEscape: hideOnEscape,
2301
+ store: store,
2307
2302
  preventBodyScroll: true,
2308
2303
  borderRadius: "full",
2309
2304
  background: "default",
@@ -2321,7 +2316,9 @@ function Modal(_ref) {
2321
2316
  // Disable portal and backdrop as we control their markup
2322
2317
  portal: false,
2323
2318
  backdrop: false,
2324
- hideOnInteractOutside: false
2319
+ hideOnInteractOutside: false,
2320
+ hideOnEscape: false,
2321
+ onKeyDown: handleKeyDown
2325
2322
  }), /*#__PURE__*/React.createElement(ModalContext.Provider, {
2326
2323
  value: contextValue
2327
2324
  }, children)))));
@@ -2464,28 +2461,6 @@ function ModalActions(_ref5) {
2464
2461
  }, children));
2465
2462
  }
2466
2463
 
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
2464
  var modules_40c67f5b = {"tab":"e96bf360","track":"_430e252d","tab-neutral":"f631ccbe","tab-themed":"_6ba96acc","track-neutral":"ef4cd8d3","track-themed":"_344b3b10"};
2490
2465
 
2491
2466
  const _excluded$s = ["as", "children", "id", "exceptionallySetClassName"],
@@ -2503,26 +2478,21 @@ function Tabs({
2503
2478
  variant = 'neutral',
2504
2479
  onSelectedIdChange
2505
2480
  }) {
2506
- const tabState = tab.useTabState({
2481
+ const tabStore = react.useTabStore({
2482
+ defaultSelectedId,
2507
2483
  selectedId,
2508
2484
  setSelectedId: onSelectedIdChange
2509
2485
  });
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() {
2486
+ const actualSelectedId = tabStore.useState('selectedId');
2487
+ const memoizedTabState = React.useMemo(() => {
2488
+ var _ref;
2489
+
2521
2490
  return {
2522
- tabState,
2523
- variant
2491
+ tabStore,
2492
+ variant,
2493
+ selectedId: (_ref = selectedId != null ? selectedId : actualSelectedId) != null ? _ref : null
2524
2494
  };
2525
- }, [variant, tabState]);
2495
+ }, [variant, tabStore, selectedId, actualSelectedId]);
2526
2496
  return /*#__PURE__*/React.createElement(TabsContext.Provider, {
2527
2497
  value: memoizedTabState
2528
2498
  }, children);
@@ -2532,30 +2502,27 @@ function Tabs({
2532
2502
  */
2533
2503
 
2534
2504
 
2535
- const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref, ref) {
2505
+ const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref2, ref) {
2536
2506
  let {
2537
2507
  as,
2538
2508
  children,
2539
2509
  id,
2540
2510
  exceptionallySetClassName
2541
- } = _ref,
2542
- props = _objectWithoutProperties(_ref, _excluded$s);
2511
+ } = _ref2,
2512
+ props = _objectWithoutProperties(_ref2, _excluded$s);
2543
2513
 
2544
2514
  const tabContextValue = React.useContext(TabsContext);
2545
-
2546
- if (!tabContextValue) {
2547
- return null;
2548
- }
2549
-
2515
+ if (!tabContextValue) return null;
2550
2516
  const {
2551
2517
  variant,
2552
- tabState
2518
+ tabStore
2553
2519
  } = tabContextValue;
2554
- return /*#__PURE__*/React.createElement(tab.Tab, _objectSpread2(_objectSpread2({}, props), {}, {
2520
+ const className = classNames(exceptionallySetClassName, modules_40c67f5b.tab, modules_40c67f5b["tab-" + variant]);
2521
+ return /*#__PURE__*/React.createElement(react.Tab, _objectSpread2(_objectSpread2({}, props), {}, {
2555
2522
  as: as,
2556
- className: classNames(exceptionallySetClassName, modules_40c67f5b.tab, modules_40c67f5b["tab-" + variant]),
2523
+ className: className,
2557
2524
  id: id,
2558
- state: tabState,
2525
+ store: tabStore,
2559
2526
  ref: ref
2560
2527
  }), children);
2561
2528
  });
@@ -2563,12 +2530,12 @@ const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref, ref) {
2563
2530
  * A component used to group `<Tab>` elements together.
2564
2531
  */
2565
2532
 
2566
- function TabList(_ref2) {
2533
+ function TabList(_ref3) {
2567
2534
  let {
2568
2535
  children,
2569
2536
  space
2570
- } = _ref2,
2571
- props = _objectWithoutProperties(_ref2, _excluded2$2);
2537
+ } = _ref3,
2538
+ props = _objectWithoutProperties(_ref3, _excluded2$2);
2572
2539
 
2573
2540
  const tabContextValue = React.useContext(TabsContext);
2574
2541
 
@@ -2577,15 +2544,15 @@ function TabList(_ref2) {
2577
2544
  }
2578
2545
 
2579
2546
  const {
2580
- tabState,
2547
+ tabStore,
2581
2548
  variant
2582
2549
  } = tabContextValue;
2583
2550
  return (
2584
2551
  /*#__PURE__*/
2585
2552
  // The extra <Box> prevents <Inline>'s negative margins from collapsing when used in a flex container
2586
2553
  // which will render the track with the wrong height
2587
- React.createElement(Box, null, /*#__PURE__*/React.createElement(tab.TabList, _objectSpread2({
2588
- state: tabState,
2554
+ React.createElement(Box, null, /*#__PURE__*/React.createElement(react.TabList, _objectSpread2({
2555
+ store: tabStore,
2589
2556
  as: Box,
2590
2557
  position: "relative",
2591
2558
  width: "maxContent"
@@ -2597,22 +2564,24 @@ function TabList(_ref2) {
2597
2564
  );
2598
2565
  }
2599
2566
  /**
2600
- * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a corresponding `<Tab>` component.
2567
+ * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a
2568
+ * corresponding `<Tab>` component.
2601
2569
  */
2602
2570
 
2603
2571
 
2604
- const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref3, ref) {
2572
+ const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref4, ref) {
2605
2573
  let {
2606
2574
  children,
2607
2575
  id,
2608
2576
  as,
2609
2577
  render = 'always'
2610
- } = _ref3,
2611
- props = _objectWithoutProperties(_ref3, _excluded3$1);
2578
+ } = _ref4,
2579
+ props = _objectWithoutProperties(_ref4, _excluded3$1);
2612
2580
 
2613
2581
  const tabContextValue = React.useContext(TabsContext);
2614
2582
  const [tabRendered, setTabRendered] = React.useState(false);
2615
- const tabIsActive = (tabContextValue == null ? void 0 : tabContextValue.tabState.selectedId) === id;
2583
+ const selectedId = tabContextValue == null ? void 0 : tabContextValue.tabStore.useState('selectedId');
2584
+ const tabIsActive = selectedId === id;
2616
2585
  React.useEffect(function trackTabRenderedState() {
2617
2586
  if (!tabRendered && tabIsActive) {
2618
2587
  setTabRendered(true);
@@ -2624,28 +2593,28 @@ const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref3, ref)
2624
2593
  }
2625
2594
 
2626
2595
  const {
2627
- tabState
2596
+ tabStore
2628
2597
  } = tabContextValue;
2629
2598
  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,
2599
+ return shouldRender ? /*#__PURE__*/React.createElement(react.TabPanel, _objectSpread2(_objectSpread2({}, props), {}, {
2600
+ tabId: id,
2601
+ store: tabStore,
2634
2602
  as: as,
2635
2603
  ref: ref
2636
2604
  }), children) : null;
2637
2605
  });
2638
2606
  /**
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.
2607
+ * Allows content to be rendered based on the current tab being selected while outside of the
2608
+ * TabPanel component. Can be placed freely within the main `<Tabs>` component.
2641
2609
  */
2642
2610
 
2643
2611
  function TabAwareSlot({
2644
2612
  children
2645
2613
  }) {
2646
2614
  const tabContextValue = React.useContext(TabsContext);
2615
+ const selectedId = tabContextValue == null ? void 0 : tabContextValue.tabStore.useState('selectedId');
2647
2616
  return tabContextValue ? children({
2648
- selectedId: tabContextValue == null ? void 0 : tabContextValue.tabState.selectedId
2617
+ selectedId
2649
2618
  }) : null;
2650
2619
  }
2651
2620
 
@@ -2673,27 +2642,20 @@ function Menu(_ref) {
2673
2642
  } = _ref,
2674
2643
  props = _objectWithoutProperties(_ref, _excluded$t);
2675
2644
 
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
2645
+ const [anchorRect, setAnchorRect] = React.useState(null);
2646
+ const getAnchorRect = React.useMemo(() => anchorRect ? () => anchorRect : null, [anchorRect]);
2647
+ const menuStore = react.useMenuStore(_objectSpread2({
2648
+ focusLoop: true
2685
2649
  }, props));
2686
- React.useEffect(() => {
2687
- if (!state.open) handleAnchorRectChange(null);
2688
- }, [state.open]);
2689
2650
  const handleItemSelect = React.useCallback(function handleItemSelect(value) {
2690
- if (onItemSelect) onItemSelect(value);
2651
+ onItemSelect == null ? void 0 : onItemSelect(value);
2691
2652
  }, [onItemSelect]);
2692
2653
  const value = React.useMemo(() => ({
2693
- state,
2654
+ menuStore,
2694
2655
  handleItemSelect,
2695
- handleAnchorRectChange
2696
- }), [state, handleItemSelect]);
2656
+ getAnchorRect,
2657
+ setAnchorRect
2658
+ }), [menuStore, handleItemSelect, getAnchorRect, setAnchorRect]);
2697
2659
  return /*#__PURE__*/React.createElement(MenuContext.Provider, {
2698
2660
  value: value
2699
2661
  }, children);
@@ -2710,10 +2672,10 @@ const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2,
2710
2672
  props = _objectWithoutProperties(_ref2, _excluded2$3);
2711
2673
 
2712
2674
  const {
2713
- state
2675
+ menuStore
2714
2676
  } = React.useContext(MenuContext);
2715
- return /*#__PURE__*/React.createElement(Ariakit.MenuButton, _objectSpread2(_objectSpread2({}, props), {}, {
2716
- state: state,
2677
+ return /*#__PURE__*/React.createElement(react.MenuButton, _objectSpread2(_objectSpread2({}, props), {}, {
2678
+ store: menuStore,
2717
2679
  ref: ref,
2718
2680
  className: classNames('reactist_menubutton', exceptionallySetClassName)
2719
2681
  }));
@@ -2728,17 +2690,17 @@ const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMen
2728
2690
  props = _objectWithoutProperties(_ref3, _excluded3$2);
2729
2691
 
2730
2692
  const {
2731
- handleAnchorRectChange,
2732
- state
2693
+ setAnchorRect,
2694
+ menuStore
2733
2695
  } = React.useContext(MenuContext);
2734
- const handleContextMenu = React.useCallback(event => {
2696
+ const handleContextMenu = React.useCallback(function handleContextMenu(event) {
2735
2697
  event.preventDefault();
2736
- handleAnchorRectChange({
2698
+ setAnchorRect({
2737
2699
  x: event.clientX,
2738
2700
  y: event.clientY
2739
2701
  });
2740
- state.show();
2741
- }, [handleAnchorRectChange, state]);
2702
+ menuStore.show();
2703
+ }, [setAnchorRect, menuStore]);
2742
2704
  return /*#__PURE__*/React.createElement(component, _objectSpread2(_objectSpread2({}, props), {}, {
2743
2705
  onContextMenu: handleContextMenu,
2744
2706
  ref
@@ -2756,14 +2718,19 @@ const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref4, ref)
2756
2718
  props = _objectWithoutProperties(_ref4, _excluded4$1);
2757
2719
 
2758
2720
  const {
2759
- state
2721
+ menuStore,
2722
+ getAnchorRect
2760
2723
  } = React.useContext(MenuContext);
2761
- return state.open ? /*#__PURE__*/React.createElement(portal.Portal, {
2724
+ const isOpen = menuStore.useState('open');
2725
+ return isOpen ? /*#__PURE__*/React.createElement(react.Portal, {
2762
2726
  preserveTabOrder: true
2763
- }, /*#__PURE__*/React.createElement(Ariakit.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
2764
- state: state,
2727
+ }, /*#__PURE__*/React.createElement(react.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
2728
+ store: menuStore,
2729
+ gutter: 8,
2730
+ shift: 4,
2765
2731
  ref: ref,
2766
2732
  className: classNames('reactist_menulist', exceptionallySetClassName),
2733
+ getAnchorRect: getAnchorRect != null ? getAnchorRect : undefined,
2767
2734
  modal: modal
2768
2735
  }))) : null;
2769
2736
  });
@@ -2786,11 +2753,11 @@ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref)
2786
2753
 
2787
2754
  const {
2788
2755
  handleItemSelect,
2789
- state
2756
+ menuStore
2790
2757
  } = React.useContext(MenuContext);
2791
2758
  const {
2792
2759
  hide
2793
- } = state;
2760
+ } = menuStore;
2794
2761
  const handleClick = React.useCallback(function handleClick(event) {
2795
2762
  onClick == null ? void 0 : onClick(event);
2796
2763
  const onSelectResult = onSelect && !event.defaultPrevented ? onSelect() : undefined;
@@ -2798,9 +2765,9 @@ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref)
2798
2765
  handleItemSelect(value);
2799
2766
  if (shouldClose) hide();
2800
2767
  }, [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value]);
2801
- return /*#__PURE__*/React.createElement(Ariakit.MenuItem, _objectSpread2(_objectSpread2({}, props), {}, {
2768
+ return /*#__PURE__*/React.createElement(react.MenuItem, _objectSpread2(_objectSpread2({}, props), {}, {
2802
2769
  as: as,
2803
- state: state,
2770
+ store: menuStore,
2804
2771
  ref: ref,
2805
2772
  onClick: handleClick,
2806
2773
  className: exceptionallySetClassName,
@@ -2835,11 +2802,11 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
2835
2802
  }, ref) {
2836
2803
  const {
2837
2804
  handleItemSelect: parentMenuItemSelect,
2838
- state
2805
+ menuStore
2839
2806
  } = React.useContext(MenuContext);
2840
2807
  const {
2841
2808
  hide: parentMenuHide
2842
- } = state;
2809
+ } = menuStore;
2843
2810
  const handleSubItemSelect = React.useCallback(function handleSubItemSelect(value) {
2844
2811
  if (onItemSelect) onItemSelect(value);
2845
2812
  parentMenuItemSelect(value);
@@ -2853,9 +2820,9 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
2853
2820
  }, [button]);
2854
2821
  return /*#__PURE__*/React.createElement(Menu, {
2855
2822
  onItemSelect: handleSubItemSelect
2856
- }, /*#__PURE__*/React.createElement(Ariakit.MenuItem, {
2823
+ }, /*#__PURE__*/React.createElement(react.MenuItem, {
2857
2824
  as: "div",
2858
- state: state,
2825
+ store: menuStore,
2859
2826
  ref: ref,
2860
2827
  hideOnClick: false
2861
2828
  }, renderMenuButton), list);
@@ -2876,11 +2843,11 @@ const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(_ref6, re
2876
2843
  props = _objectWithoutProperties(_ref6, _excluded6);
2877
2844
 
2878
2845
  const {
2879
- state
2846
+ menuStore
2880
2847
  } = React.useContext(MenuContext);
2881
- return /*#__PURE__*/React.createElement(Ariakit.MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
2848
+ return /*#__PURE__*/React.createElement(react.MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
2882
2849
  ref: ref,
2883
- state: state,
2850
+ store: menuStore,
2884
2851
  className: exceptionallySetClassName
2885
2852
  }), label ? /*#__PURE__*/React.createElement("div", {
2886
2853
  role: "presentation",