@doist/reactist 22.0.1-beta → 22.1.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.
Files changed (64) hide show
  1. package/dist/reactist.cjs.development.js +188 -353
  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/hooks/use-previous/use-previous.js +26 -0
  8. package/es/hooks/use-previous/use-previous.js.map +1 -0
  9. package/es/index.js +0 -1
  10. package/es/index.js.map +1 -1
  11. package/es/menu/menu.js +38 -35
  12. package/es/menu/menu.js.map +1 -1
  13. package/es/modal/modal.js +4 -3
  14. package/es/modal/modal.js.map +1 -1
  15. package/es/tabs/tabs.js +47 -40
  16. package/es/tabs/tabs.js.map +1 -1
  17. package/es/text-area/text-area.module.css.js +1 -1
  18. package/es/toast/use-toasts.js +6 -4
  19. package/es/toast/use-toasts.js.map +1 -1
  20. package/es/tooltip/tooltip.js +62 -20
  21. package/es/tooltip/tooltip.js.map +1 -1
  22. package/lib/checkbox-field/checkbox-field.js +1 -1
  23. package/lib/checkbox-field/checkbox-field.js.map +1 -1
  24. package/lib/hooks/use-previous/use-previous.js +2 -0
  25. package/lib/hooks/use-previous/use-previous.js.map +1 -0
  26. package/lib/index.d.ts +0 -1
  27. package/lib/index.js +1 -1
  28. package/lib/menu/menu.d.ts +4 -4
  29. package/lib/menu/menu.js +1 -1
  30. package/lib/menu/menu.js.map +1 -1
  31. package/lib/modal/modal.d.ts +2 -1
  32. package/lib/modal/modal.js +1 -1
  33. package/lib/modal/modal.js.map +1 -1
  34. package/lib/tabs/tabs.d.ts +8 -10
  35. package/lib/tabs/tabs.js +1 -1
  36. package/lib/tabs/tabs.js.map +1 -1
  37. package/lib/text-area/text-area.module.css.js +1 -1
  38. package/lib/toast/use-toasts.d.ts +5 -1
  39. package/lib/toast/use-toasts.js +1 -1
  40. package/lib/toast/use-toasts.js.map +1 -1
  41. package/lib/tooltip/tooltip.d.ts +4 -2
  42. package/lib/tooltip/tooltip.js +1 -1
  43. package/lib/tooltip/tooltip.js.map +1 -1
  44. package/lib/utils/test-helpers.d.ts +2 -13
  45. package/package.json +6 -5
  46. package/styles/reactist.css +2 -3
  47. package/styles/text-area.css +1 -1
  48. package/styles/text-area.module.css.css +1 -1
  49. package/es/checkbox-field/use-fork-ref.js +0 -35
  50. package/es/checkbox-field/use-fork-ref.js.map +0 -1
  51. package/es/deprecated-modal/modal.js +0 -219
  52. package/es/deprecated-modal/modal.js.map +0 -1
  53. package/es/deprecated-modal/modal.module.css.js +0 -4
  54. package/es/deprecated-modal/modal.module.css.js.map +0 -1
  55. package/lib/checkbox-field/use-fork-ref.d.ts +0 -11
  56. package/lib/checkbox-field/use-fork-ref.js +0 -2
  57. package/lib/checkbox-field/use-fork-ref.js.map +0 -1
  58. package/lib/deprecated-modal/index.d.ts +0 -1
  59. package/lib/deprecated-modal/modal.d.ts +0 -157
  60. package/lib/deprecated-modal/modal.js +0 -2
  61. package/lib/deprecated-modal/modal.js.map +0 -1
  62. package/lib/deprecated-modal/modal.module.css.js +0 -2
  63. package/lib/deprecated-modal/modal.module.css.js.map +0 -1
  64. package/lib/deprecated-modal/modal.test.d.ts +0 -1
@@ -8,14 +8,18 @@ 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 react = require('@ariakit/react');
11
+ var tooltip = require('ariakit/tooltip');
12
+ var portal = require('ariakit/portal');
13
+ var ariakitReactUtils = require('ariakit-react-utils');
12
14
  var useCallbackRef = require('use-callback-ref');
13
15
  var FocusLock = _interopDefault(require('react-focus-lock'));
14
16
  var ariaHidden = require('aria-hidden');
17
+ var dialog = require('ariakit/dialog');
18
+ var tab = require('ariakit/tab');
19
+ var Ariakit = require('ariakit/menu');
15
20
  var ReactDOM = _interopDefault(require('react-dom'));
16
21
  var dayjs = _interopDefault(require('dayjs'));
17
22
  var LocalizedFormat = _interopDefault(require('dayjs/plugin/localizedFormat'));
18
- var dialog = require('@reach/dialog');
19
23
 
20
24
  function ownKeys(object, enumerableOnly) {
21
25
  var keys = Object.keys(object);
@@ -451,6 +455,18 @@ const HiddenVisually = /*#__PURE__*/polymorphicComponent(function HiddenVisually
451
455
 
452
456
  var modules_95f1407a = {"tooltip":"_487c82cd"};
453
457
 
458
+ const SHOW_DELAY = 500;
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
+
454
470
  function Tooltip({
455
471
  children,
456
472
  content,
@@ -459,12 +475,10 @@ function Tooltip({
459
475
  withArrow = false,
460
476
  exceptionallySetClassName
461
477
  }) {
462
- const tooltip = react.useTooltipStore({
478
+ const state = useDelayedTooltipState({
463
479
  placement: position,
464
- showTimeout: 500,
465
- hideTimeout: 100
480
+ gutter: gapSize
466
481
  });
467
- const isOpen = tooltip.useState('open');
468
482
  const child = React.Children.only(children);
469
483
 
470
484
  if (!child) {
@@ -493,7 +507,7 @@ function Tooltip({
493
507
  const eventKey = event.key;
494
508
 
495
509
  if (eventKey !== 'Escape' && eventKey !== 'Enter' && eventKey !== 'Space') {
496
- tooltip.show();
510
+ state.show();
497
511
  }
498
512
  }
499
513
 
@@ -508,23 +522,25 @@ function Tooltip({
508
522
  function handleBlur(event) {
509
523
  var _child$props2;
510
524
 
511
- tooltip.hide();
525
+ state.hide();
512
526
  child == null ? void 0 : (_child$props2 = child.props) == null ? void 0 : _child$props2.onBlur == null ? void 0 : _child$props2.onBlur(event);
513
527
  }
514
528
 
515
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(react.TooltipAnchor, {
516
- render: anchorProps => {
517
- return /*#__PURE__*/React.cloneElement(child, _objectSpread2(_objectSpread2(_objectSpread2({}, child.props), anchorProps), {}, {
518
- onFocus: handleFocus,
519
- onBlur: handleBlur
520
- }));
521
- },
522
- store: tooltip,
523
- ref: child.ref
524
- }), isOpen && content ? /*#__PURE__*/React.createElement(Box, {
525
- as: react.Tooltip,
526
- gutter: gapSize,
527
- store: tooltip,
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,
528
544
  className: [modules_95f1407a.tooltip, exceptionallySetClassName],
529
545
  background: "toast",
530
546
  borderRadius: "standard",
@@ -534,7 +550,37 @@ function Tooltip({
534
550
  width: "fitContent",
535
551
  overflow: "hidden",
536
552
  textAlign: "center"
537
- }, withArrow ? /*#__PURE__*/React.createElement(react.TooltipArrow, null) : null, typeof content === 'function' ? content() : content) : null);
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]);
538
584
  }
539
585
 
540
586
  var modules_c7f5018f = {"svg":"_51539197","spinner":"_54fbe2b3","tint":"a0c466ed","fill":"_745b73d3"};
@@ -1274,7 +1320,8 @@ function ToastsProvider({
1274
1320
  defaultAutoDismissDelay = 10
1275
1321
  /* seconds */
1276
1322
  ,
1277
- defaultDismissLabel = 'Close'
1323
+ defaultDismissLabel = 'Close',
1324
+ containerClassName
1278
1325
  }) {
1279
1326
  const [toasts, setToasts] = React__default.useState([]);
1280
1327
  const {
@@ -1307,12 +1354,13 @@ function ToastsProvider({
1307
1354
  }, [defaultAutoDismissDelay, defaultDismissLabel, removeToast]);
1308
1355
  return /*#__PURE__*/React__default.createElement(ToastsContext.Provider, {
1309
1356
  value: showToast
1310
- }, children, /*#__PURE__*/React__default.createElement(react.Portal, null, toasts.length === 0 ? null : /*#__PURE__*/React__default.createElement(Box, {
1311
- className: modules_d11e18f0.stackedToastsView,
1357
+ }, children, /*#__PURE__*/React__default.createElement(portal.Portal, null, toasts.length === 0 ? null : /*#__PURE__*/React__default.createElement(Box, {
1358
+ className: [modules_d11e18f0.stackedToastsView, containerClassName],
1312
1359
  position: "fixed",
1313
1360
  width: "full",
1314
1361
  paddingX: padding,
1315
- paddingBottom: padding
1362
+ paddingBottom: padding,
1363
+ "data-testid": "toasts-container"
1316
1364
  }, /*#__PURE__*/React__default.createElement(Stack, {
1317
1365
  space: "medium"
1318
1366
  }, toasts.map(_ref => {
@@ -1555,37 +1603,6 @@ function CheckboxIcon(_ref) {
1555
1603
 
1556
1604
  var modules_664a6a80 = {"container":"_84dfdb83","disabled":"_131a2ca4","checked":"_95b1556d","keyFocused":"_49de7ebd","icon":"_6b4b1851","label":"_9047f3bd"};
1557
1605
 
1558
- /**
1559
- * Sets both a function and object React ref.
1560
- */
1561
-
1562
- function setRef(ref, value) {
1563
- if (typeof ref === 'function') {
1564
- ref(value);
1565
- } else if (ref) {
1566
- ref.current = value;
1567
- }
1568
- }
1569
- /**
1570
- * Merges React Refs into a single memoized function ref so you can pass it to an element.
1571
- * @example
1572
- * const Component = React.forwardRef((props, ref) => {
1573
- * const internalRef = React.useRef();
1574
- * return <div {...props} ref={useForkRef(internalRef, ref)} />;
1575
- * });
1576
- */
1577
-
1578
-
1579
- function useForkRef(...refs) {
1580
- return React.useMemo(() => {
1581
- if (!refs.some(Boolean)) return;
1582
- return value => {
1583
- refs.forEach(ref => setRef(ref, value));
1584
- };
1585
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
1586
- refs);
1587
- }
1588
-
1589
1606
  const _excluded$j = ["label", "icon", "disabled", "indeterminate", "defaultChecked", "onChange"];
1590
1607
  const CheckboxField = /*#__PURE__*/React.forwardRef(function CheckboxField(_ref, ref) {
1591
1608
  var _ref2, _props$checked, _props$checked2;
@@ -1617,7 +1634,7 @@ const CheckboxField = /*#__PURE__*/React.forwardRef(function CheckboxField(_ref,
1617
1634
  const [checkedState, setChecked] = React.useState((_ref2 = (_props$checked = props.checked) != null ? _props$checked : defaultChecked) != null ? _ref2 : false);
1618
1635
  const isChecked = (_props$checked2 = props.checked) != null ? _props$checked2 : checkedState;
1619
1636
  const internalRef = React.useRef(null);
1620
- const combinedRef = useForkRef(internalRef, ref);
1637
+ const combinedRef = ariakitReactUtils.useForkRef(internalRef, ref);
1621
1638
  React.useEffect(function setIndeterminate() {
1622
1639
  if (internalRef.current && typeof indeterminate === 'boolean') {
1623
1640
  internalRef.current.indeterminate = indeterminate;
@@ -2028,7 +2045,7 @@ const SwitchField = /*#__PURE__*/React.forwardRef(function SwitchField(_ref, ref
2028
2045
  }, hint) : null);
2029
2046
  });
2030
2047
 
2031
- var modules_2728c236 = {"textAreaContainer":"fdc243b3","innerContainer":"_5c1dd8bc","bordered":"_269f9e63","error":"d1e4b585","autoExpand":"_10c6f2ef"};
2048
+ var modules_2728c236 = {"textAreaContainer":"_29503131","innerContainer":"_6ea894ce","bordered":"e1e8b6a7","error":"_1b94ff46","autoExpand":"e82223c4"};
2032
2049
 
2033
2050
  const _excluded$o = ["variant", "id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "message", "tone", "maxWidth", "hidden", "aria-describedby", "rows", "autoExpand"];
2034
2051
  const TextArea = /*#__PURE__*/React.forwardRef(function TextArea(_ref, ref) {
@@ -2228,7 +2245,7 @@ function Modal(_ref) {
2228
2245
  onDismiss == null ? void 0 : onDismiss();
2229
2246
  }
2230
2247
  }, [onDismiss]);
2231
- const store = react.useDialogStore({
2248
+ const state = dialog.useDialogState({
2232
2249
  open: isOpen,
2233
2250
  setOpen
2234
2251
  });
@@ -2262,7 +2279,7 @@ function Modal(_ref) {
2262
2279
  return null;
2263
2280
  }
2264
2281
 
2265
- return /*#__PURE__*/React.createElement(react.Portal, {
2282
+ return /*#__PURE__*/React.createElement(portal.Portal, {
2266
2283
  portalRef: portalRef,
2267
2284
  portalElement: portalElement
2268
2285
  }, /*#__PURE__*/React.createElement(Box, {
@@ -2281,10 +2298,10 @@ function Modal(_ref) {
2281
2298
  autoFocus: autoFocus,
2282
2299
  whiteList: isNotInternalFrame,
2283
2300
  returnFocus: true
2284
- }, /*#__PURE__*/React.createElement(react.Dialog, _objectSpread2(_objectSpread2({}, props), {}, {
2301
+ }, /*#__PURE__*/React.createElement(dialog.Dialog, _objectSpread2(_objectSpread2({}, props), {}, {
2285
2302
  ref: dialogRef,
2286
2303
  as: Box,
2287
- store: store,
2304
+ state: state,
2288
2305
  hideOnEscape: hideOnEscape,
2289
2306
  preventBodyScroll: true,
2290
2307
  borderRadius: "full",
@@ -2446,6 +2463,28 @@ function ModalActions(_ref5) {
2446
2463
  }, children));
2447
2464
  }
2448
2465
 
2466
+ /**
2467
+ * usePrevious tracks the change of the given value -
2468
+ * when a given value has been changed from a previous call,
2469
+ * it will return the value prior to the change.
2470
+ *
2471
+ * Example:
2472
+ *
2473
+ * const [x, setX] = useState(1)
2474
+ * const prevX = usePrevious(x)
2475
+ *
2476
+ * Suppose `setX(2)` is called, then in the next component render
2477
+ * x = 2 and prevX = 1
2478
+ */
2479
+
2480
+ function usePrevious(value) {
2481
+ const ref = React.useRef(null);
2482
+ React.useEffect(() => {
2483
+ ref.current = value;
2484
+ }, [value]);
2485
+ return ref.current;
2486
+ }
2487
+
2449
2488
  var modules_40c67f5b = {"tab":"e96bf360","track":"_430e252d","tab-neutral":"f631ccbe","tab-themed":"_6ba96acc","track-neutral":"ef4cd8d3","track-themed":"_344b3b10"};
2450
2489
 
2451
2490
  const _excluded$s = ["as", "children", "id", "exceptionallySetClassName"],
@@ -2463,21 +2502,26 @@ function Tabs({
2463
2502
  variant = 'neutral',
2464
2503
  onSelectedIdChange
2465
2504
  }) {
2466
- const tabStore = react.useTabStore({
2467
- defaultSelectedId,
2505
+ const tabState = tab.useTabState({
2468
2506
  selectedId,
2469
2507
  setSelectedId: onSelectedIdChange
2470
2508
  });
2471
- const actualSelectedId = tabStore.useState('selectedId');
2472
- const memoizedTabState = React.useMemo(() => {
2473
- var _ref;
2474
-
2509
+ const previousDefaultSelectedId = usePrevious(defaultSelectedId);
2510
+ const {
2511
+ selectedId: actualSelectedId,
2512
+ select
2513
+ } = tabState;
2514
+ React.useEffect(function selectDefaultTab() {
2515
+ if (!selectedId && defaultSelectedId !== previousDefaultSelectedId && defaultSelectedId !== actualSelectedId && defaultSelectedId !== undefined) {
2516
+ select(defaultSelectedId);
2517
+ }
2518
+ }, [selectedId, defaultSelectedId, actualSelectedId, select, previousDefaultSelectedId]);
2519
+ const memoizedTabState = React.useMemo(function memoizeTabState() {
2475
2520
  return {
2476
- tabStore,
2477
- variant,
2478
- selectedId: (_ref = selectedId != null ? selectedId : actualSelectedId) != null ? _ref : null
2521
+ tabState,
2522
+ variant
2479
2523
  };
2480
- }, [variant, tabStore, selectedId, actualSelectedId]);
2524
+ }, [variant, tabState]);
2481
2525
  return /*#__PURE__*/React.createElement(TabsContext.Provider, {
2482
2526
  value: memoizedTabState
2483
2527
  }, children);
@@ -2487,27 +2531,30 @@ function Tabs({
2487
2531
  */
2488
2532
 
2489
2533
 
2490
- const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref2, ref) {
2534
+ const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref, ref) {
2491
2535
  let {
2492
2536
  as,
2493
2537
  children,
2494
2538
  id,
2495
2539
  exceptionallySetClassName
2496
- } = _ref2,
2497
- props = _objectWithoutProperties(_ref2, _excluded$s);
2540
+ } = _ref,
2541
+ props = _objectWithoutProperties(_ref, _excluded$s);
2498
2542
 
2499
2543
  const tabContextValue = React.useContext(TabsContext);
2500
- if (!tabContextValue) return null;
2544
+
2545
+ if (!tabContextValue) {
2546
+ return null;
2547
+ }
2548
+
2501
2549
  const {
2502
2550
  variant,
2503
- tabStore
2551
+ tabState
2504
2552
  } = tabContextValue;
2505
- const className = classNames(exceptionallySetClassName, modules_40c67f5b.tab, modules_40c67f5b["tab-" + variant]);
2506
- return /*#__PURE__*/React.createElement(react.Tab, _objectSpread2(_objectSpread2({}, props), {}, {
2553
+ return /*#__PURE__*/React.createElement(tab.Tab, _objectSpread2(_objectSpread2({}, props), {}, {
2507
2554
  as: as,
2508
- className: className,
2555
+ className: classNames(exceptionallySetClassName, modules_40c67f5b.tab, modules_40c67f5b["tab-" + variant]),
2509
2556
  id: id,
2510
- store: tabStore,
2557
+ state: tabState,
2511
2558
  ref: ref
2512
2559
  }), children);
2513
2560
  });
@@ -2515,12 +2562,12 @@ const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref2, ref) {
2515
2562
  * A component used to group `<Tab>` elements together.
2516
2563
  */
2517
2564
 
2518
- function TabList(_ref3) {
2565
+ function TabList(_ref2) {
2519
2566
  let {
2520
2567
  children,
2521
2568
  space
2522
- } = _ref3,
2523
- props = _objectWithoutProperties(_ref3, _excluded2$2);
2569
+ } = _ref2,
2570
+ props = _objectWithoutProperties(_ref2, _excluded2$2);
2524
2571
 
2525
2572
  const tabContextValue = React.useContext(TabsContext);
2526
2573
 
@@ -2529,15 +2576,15 @@ function TabList(_ref3) {
2529
2576
  }
2530
2577
 
2531
2578
  const {
2532
- tabStore,
2579
+ tabState,
2533
2580
  variant
2534
2581
  } = tabContextValue;
2535
2582
  return (
2536
2583
  /*#__PURE__*/
2537
2584
  // The extra <Box> prevents <Inline>'s negative margins from collapsing when used in a flex container
2538
2585
  // which will render the track with the wrong height
2539
- React.createElement(Box, null, /*#__PURE__*/React.createElement(react.TabList, _objectSpread2({
2540
- store: tabStore,
2586
+ React.createElement(Box, null, /*#__PURE__*/React.createElement(tab.TabList, _objectSpread2({
2587
+ state: tabState,
2541
2588
  as: Box,
2542
2589
  position: "relative",
2543
2590
  width: "maxContent"
@@ -2549,24 +2596,22 @@ function TabList(_ref3) {
2549
2596
  );
2550
2597
  }
2551
2598
  /**
2552
- * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a
2553
- * corresponding `<Tab>` component.
2599
+ * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a corresponding `<Tab>` component.
2554
2600
  */
2555
2601
 
2556
2602
 
2557
- const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref4, ref) {
2603
+ const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref3, ref) {
2558
2604
  let {
2559
2605
  children,
2560
2606
  id,
2561
2607
  as,
2562
2608
  render = 'always'
2563
- } = _ref4,
2564
- props = _objectWithoutProperties(_ref4, _excluded3$1);
2609
+ } = _ref3,
2610
+ props = _objectWithoutProperties(_ref3, _excluded3$1);
2565
2611
 
2566
2612
  const tabContextValue = React.useContext(TabsContext);
2567
2613
  const [tabRendered, setTabRendered] = React.useState(false);
2568
- const selectedId = tabContextValue == null ? void 0 : tabContextValue.tabStore.useState('selectedId');
2569
- const tabIsActive = selectedId === id;
2614
+ const tabIsActive = (tabContextValue == null ? void 0 : tabContextValue.tabState.selectedId) === id;
2570
2615
  React.useEffect(function trackTabRenderedState() {
2571
2616
  if (!tabRendered && tabIsActive) {
2572
2617
  setTabRendered(true);
@@ -2578,28 +2623,28 @@ const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref4, ref)
2578
2623
  }
2579
2624
 
2580
2625
  const {
2581
- tabStore
2626
+ tabState
2582
2627
  } = tabContextValue;
2583
2628
  const shouldRender = render === 'always' || render === 'active' && tabIsActive || render === 'lazy' && (tabIsActive || tabRendered);
2584
- return shouldRender ? /*#__PURE__*/React.createElement(react.TabPanel, _objectSpread2(_objectSpread2({}, props), {}, {
2585
- tabId: id,
2586
- store: tabStore,
2629
+ return shouldRender ? /*#__PURE__*/React.createElement(tab.TabPanel, _objectSpread2(_objectSpread2({
2630
+ tabId: id
2631
+ }, props), {}, {
2632
+ state: tabState,
2587
2633
  as: as,
2588
2634
  ref: ref
2589
2635
  }), children) : null;
2590
2636
  });
2591
2637
  /**
2592
- * Allows content to be rendered based on the current tab being selected while outside of the
2593
- * TabPanel component. Can be placed freely within the main `<Tabs>` component.
2638
+ * Allows content to be rendered based on the current tab being selected while outside of the TabPanel
2639
+ * component. Can be placed freely within the main `<Tabs>` component.
2594
2640
  */
2595
2641
 
2596
2642
  function TabAwareSlot({
2597
2643
  children
2598
2644
  }) {
2599
2645
  const tabContextValue = React.useContext(TabsContext);
2600
- const selectedId = tabContextValue == null ? void 0 : tabContextValue.tabStore.useState('selectedId');
2601
2646
  return tabContextValue ? children({
2602
- selectedId
2647
+ selectedId: tabContextValue == null ? void 0 : tabContextValue.tabState.selectedId
2603
2648
  }) : null;
2604
2649
  }
2605
2650
 
@@ -2627,20 +2672,27 @@ function Menu(_ref) {
2627
2672
  } = _ref,
2628
2673
  props = _objectWithoutProperties(_ref, _excluded$t);
2629
2674
 
2630
- const [anchorRect, setAnchorRect] = React.useState(null);
2631
- const getAnchorRect = React.useMemo(() => anchorRect ? () => anchorRect : null, [anchorRect]);
2632
- const menuStore = react.useMenuStore(_objectSpread2({
2633
- focusLoop: true
2675
+ const [anchorRect, handleAnchorRectChange] = React.useState(null);
2676
+ const getAnchorRect = React.useMemo(() => {
2677
+ return anchorRect ? () => anchorRect : undefined;
2678
+ }, [anchorRect]);
2679
+ const state = Ariakit.useMenuState(_objectSpread2({
2680
+ focusLoop: true,
2681
+ gutter: 8,
2682
+ shift: 4,
2683
+ getAnchorRect
2634
2684
  }, props));
2685
+ React.useEffect(() => {
2686
+ if (!state.open) handleAnchorRectChange(null);
2687
+ }, [state.open]);
2635
2688
  const handleItemSelect = React.useCallback(function handleItemSelect(value) {
2636
- onItemSelect == null ? void 0 : onItemSelect(value);
2689
+ if (onItemSelect) onItemSelect(value);
2637
2690
  }, [onItemSelect]);
2638
2691
  const value = React.useMemo(() => ({
2639
- menuStore,
2692
+ state,
2640
2693
  handleItemSelect,
2641
- getAnchorRect,
2642
- setAnchorRect
2643
- }), [menuStore, handleItemSelect, getAnchorRect, setAnchorRect]);
2694
+ handleAnchorRectChange
2695
+ }), [state, handleItemSelect]);
2644
2696
  return /*#__PURE__*/React.createElement(MenuContext.Provider, {
2645
2697
  value: value
2646
2698
  }, children);
@@ -2657,10 +2709,10 @@ const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2,
2657
2709
  props = _objectWithoutProperties(_ref2, _excluded2$3);
2658
2710
 
2659
2711
  const {
2660
- menuStore
2712
+ state
2661
2713
  } = React.useContext(MenuContext);
2662
- return /*#__PURE__*/React.createElement(react.MenuButton, _objectSpread2(_objectSpread2({}, props), {}, {
2663
- store: menuStore,
2714
+ return /*#__PURE__*/React.createElement(Ariakit.MenuButton, _objectSpread2(_objectSpread2({}, props), {}, {
2715
+ state: state,
2664
2716
  ref: ref,
2665
2717
  className: classNames('reactist_menubutton', exceptionallySetClassName)
2666
2718
  }));
@@ -2675,17 +2727,17 @@ const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMen
2675
2727
  props = _objectWithoutProperties(_ref3, _excluded3$2);
2676
2728
 
2677
2729
  const {
2678
- setAnchorRect,
2679
- menuStore
2730
+ handleAnchorRectChange,
2731
+ state
2680
2732
  } = React.useContext(MenuContext);
2681
- const handleContextMenu = React.useCallback(function handleContextMenu(event) {
2733
+ const handleContextMenu = React.useCallback(event => {
2682
2734
  event.preventDefault();
2683
- setAnchorRect({
2735
+ handleAnchorRectChange({
2684
2736
  x: event.clientX,
2685
2737
  y: event.clientY
2686
2738
  });
2687
- menuStore.show();
2688
- }, [setAnchorRect, menuStore]);
2739
+ state.show();
2740
+ }, [handleAnchorRectChange, state]);
2689
2741
  return /*#__PURE__*/React.createElement(component, _objectSpread2(_objectSpread2({}, props), {}, {
2690
2742
  onContextMenu: handleContextMenu,
2691
2743
  ref
@@ -2703,19 +2755,14 @@ const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref4, ref)
2703
2755
  props = _objectWithoutProperties(_ref4, _excluded4$1);
2704
2756
 
2705
2757
  const {
2706
- menuStore,
2707
- getAnchorRect
2758
+ state
2708
2759
  } = React.useContext(MenuContext);
2709
- const isOpen = menuStore.useState('open');
2710
- return isOpen ? /*#__PURE__*/React.createElement(react.Portal, {
2760
+ return state.open ? /*#__PURE__*/React.createElement(portal.Portal, {
2711
2761
  preserveTabOrder: true
2712
- }, /*#__PURE__*/React.createElement(react.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
2713
- store: menuStore,
2714
- gutter: 8,
2715
- shift: 4,
2762
+ }, /*#__PURE__*/React.createElement(Ariakit.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
2763
+ state: state,
2716
2764
  ref: ref,
2717
2765
  className: classNames('reactist_menulist', exceptionallySetClassName),
2718
- getAnchorRect: getAnchorRect != null ? getAnchorRect : undefined,
2719
2766
  modal: modal
2720
2767
  }))) : null;
2721
2768
  });
@@ -2738,11 +2785,11 @@ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref)
2738
2785
 
2739
2786
  const {
2740
2787
  handleItemSelect,
2741
- menuStore
2788
+ state
2742
2789
  } = React.useContext(MenuContext);
2743
2790
  const {
2744
2791
  hide
2745
- } = menuStore;
2792
+ } = state;
2746
2793
  const handleClick = React.useCallback(function handleClick(event) {
2747
2794
  onClick == null ? void 0 : onClick(event);
2748
2795
  const onSelectResult = onSelect && !event.defaultPrevented ? onSelect() : undefined;
@@ -2750,9 +2797,9 @@ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref)
2750
2797
  handleItemSelect(value);
2751
2798
  if (shouldClose) hide();
2752
2799
  }, [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value]);
2753
- return /*#__PURE__*/React.createElement(react.MenuItem, _objectSpread2(_objectSpread2({}, props), {}, {
2800
+ return /*#__PURE__*/React.createElement(Ariakit.MenuItem, _objectSpread2(_objectSpread2({}, props), {}, {
2754
2801
  as: as,
2755
- store: menuStore,
2802
+ state: state,
2756
2803
  ref: ref,
2757
2804
  onClick: handleClick,
2758
2805
  className: exceptionallySetClassName,
@@ -2787,11 +2834,11 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
2787
2834
  }, ref) {
2788
2835
  const {
2789
2836
  handleItemSelect: parentMenuItemSelect,
2790
- menuStore
2837
+ state
2791
2838
  } = React.useContext(MenuContext);
2792
2839
  const {
2793
2840
  hide: parentMenuHide
2794
- } = menuStore;
2841
+ } = state;
2795
2842
  const handleSubItemSelect = React.useCallback(function handleSubItemSelect(value) {
2796
2843
  if (onItemSelect) onItemSelect(value);
2797
2844
  parentMenuItemSelect(value);
@@ -2805,9 +2852,9 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
2805
2852
  }, [button]);
2806
2853
  return /*#__PURE__*/React.createElement(Menu, {
2807
2854
  onItemSelect: handleSubItemSelect
2808
- }, /*#__PURE__*/React.createElement(react.MenuItem, {
2855
+ }, /*#__PURE__*/React.createElement(Ariakit.MenuItem, {
2809
2856
  as: "div",
2810
- store: menuStore,
2857
+ state: state,
2811
2858
  ref: ref,
2812
2859
  hideOnClick: false
2813
2860
  }, renderMenuButton), list);
@@ -2828,11 +2875,11 @@ const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(_ref6, re
2828
2875
  props = _objectWithoutProperties(_ref6, _excluded6);
2829
2876
 
2830
2877
  const {
2831
- menuStore
2878
+ state
2832
2879
  } = React.useContext(MenuContext);
2833
- return /*#__PURE__*/React.createElement(react.MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
2880
+ return /*#__PURE__*/React.createElement(Ariakit.MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
2834
2881
  ref: ref,
2835
- store: menuStore,
2882
+ state: state,
2836
2883
  className: exceptionallySetClassName
2837
2884
  }), label ? /*#__PURE__*/React.createElement("div", {
2838
2885
  role: "presentation",
@@ -3691,212 +3738,6 @@ Select.defaultProps = {
3691
3738
  disabled: false
3692
3739
  };
3693
3740
 
3694
- var modules_8f59d13b$1 = {"reach-portal":"ad18b0a0","fadein":"f7a1b219","fitContent":"_8ed9bb5c","container":"f67e892e","full":"_4139421e","large":"_649eb5fe","medium":"_5323e676","small":"_56ca7ae6","xlarge":"a7be0fce","overlay":"_88a7a680","expand":"b29456b8","buttonContainer":"_09ef1f4f","headerContent":"_0e5b530a"};
3695
-
3696
- const _excluded$y = ["isOpen", "onDismiss", "height", "width", "exceptionallySetClassName", "autoFocus", "children"],
3697
- _excluded2$4 = ["children", "button", "withDivider", "exceptionallySetClassName"],
3698
- _excluded3$3 = ["exceptionallySetClassName", "children"],
3699
- _excluded4$2 = ["exceptionallySetClassName", "withDivider"],
3700
- _excluded5$2 = ["children"];
3701
- const ModalContext$1 = /*#__PURE__*/React.createContext({
3702
- onDismiss: undefined,
3703
- height: 'fitContent'
3704
- });
3705
-
3706
- function isNotInternalFrame$1(element) {
3707
- return !(element.ownerDocument === document && element.tagName.toLowerCase() === 'iframe');
3708
- }
3709
- /**
3710
- * Renders a modal that sits on top of the rest of the content in the entire page.
3711
- *
3712
- * Follows the WAI-ARIA Dialog (Modal) Pattern.
3713
- *
3714
- * @see DeprecatedModalHeader
3715
- * @see DeprecatedModalFooter
3716
- * @see DeprecatedModalBody
3717
- * @deprecated
3718
- */
3719
-
3720
-
3721
- function DeprecatedModal(_ref) {
3722
- let {
3723
- isOpen,
3724
- onDismiss,
3725
- height = 'fitContent',
3726
- width = 'medium',
3727
- exceptionallySetClassName,
3728
- autoFocus = true,
3729
- children
3730
- } = _ref,
3731
- props = _objectWithoutProperties(_ref, _excluded$y);
3732
-
3733
- const contextValue = React.useMemo(() => ({
3734
- onDismiss,
3735
- height
3736
- }), [onDismiss, height]);
3737
- return /*#__PURE__*/React.createElement(dialog.DialogOverlay, {
3738
- isOpen: isOpen,
3739
- onDismiss: onDismiss,
3740
- dangerouslyBypassFocusLock // We're setting up our own focus lock below
3741
- : true,
3742
- className: classNames(modules_8f59d13b$1.overlay, modules_8f59d13b$1[height], modules_8f59d13b$1[width]),
3743
- "data-testid": "modal-overlay"
3744
- }, /*#__PURE__*/React.createElement(FocusLock, {
3745
- autoFocus: autoFocus,
3746
- whiteList: isNotInternalFrame$1,
3747
- returnFocus: true
3748
- }, /*#__PURE__*/React.createElement(dialog.DialogContent, _objectSpread2(_objectSpread2({}, props), {}, {
3749
- as: Box,
3750
- borderRadius: "full",
3751
- background: "default",
3752
- display: "flex",
3753
- flexDirection: "column",
3754
- overflow: "hidden",
3755
- height: height === 'expand' ? 'full' : undefined,
3756
- flexGrow: height === 'expand' ? 1 : 0,
3757
- className: [exceptionallySetClassName, modules_8f59d13b$1.container]
3758
- }), /*#__PURE__*/React.createElement(ModalContext$1.Provider, {
3759
- value: contextValue
3760
- }, children))));
3761
- }
3762
- /**
3763
- * The close button rendered by ModalHeader. Provided independently so that consumers can customize
3764
- * the button's label.
3765
- *
3766
- * @see DeprecatedModalHeader
3767
- */
3768
-
3769
- function DeprecatedModalCloseButton(props) {
3770
- const {
3771
- onDismiss
3772
- } = React.useContext(ModalContext$1);
3773
- const [includeInTabOrder, setIncludeInTabOrder] = React.useState(false);
3774
- const [isMounted, setIsMounted] = React.useState(false);
3775
- React.useEffect(function skipAutoFocus() {
3776
- if (isMounted) {
3777
- setIncludeInTabOrder(true);
3778
- } else {
3779
- setIsMounted(true);
3780
- }
3781
- }, [isMounted]);
3782
- return /*#__PURE__*/React.createElement(Button, _objectSpread2(_objectSpread2({}, props), {}, {
3783
- variant: "quaternary",
3784
- onClick: onDismiss,
3785
- icon: /*#__PURE__*/React.createElement(CloseIcon, null),
3786
- tabIndex: includeInTabOrder ? 0 : -1
3787
- }));
3788
- }
3789
- /**
3790
- * Renders a standard modal header area with an optional close button.
3791
- *
3792
- * @see DeprecatedModal
3793
- * @see DeprecatedModalFooter
3794
- * @see DeprecatedModalBody
3795
- */
3796
-
3797
- function DeprecatedModalHeader(_ref2) {
3798
- let {
3799
- children,
3800
- button = true,
3801
- withDivider = false,
3802
- exceptionallySetClassName
3803
- } = _ref2,
3804
- props = _objectWithoutProperties(_ref2, _excluded2$4);
3805
-
3806
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
3807
- as: "header",
3808
- paddingLeft: "large",
3809
- paddingRight: button === false || button === null ? 'large' : 'small',
3810
- paddingY: "small",
3811
- className: exceptionallySetClassName
3812
- }), /*#__PURE__*/React.createElement(Columns, {
3813
- space: "large",
3814
- alignY: "center"
3815
- }, /*#__PURE__*/React.createElement(Column, {
3816
- width: "auto"
3817
- }, children), button === false || button === null ? /*#__PURE__*/React.createElement("div", {
3818
- className: modules_8f59d13b$1.headerContent
3819
- }) : /*#__PURE__*/React.createElement(Column, {
3820
- width: "content",
3821
- exceptionallySetClassName: modules_8f59d13b$1.buttonContainer,
3822
- "data-testid": "button-container"
3823
- }, typeof button === 'boolean' ? /*#__PURE__*/React.createElement(DeprecatedModalCloseButton, {
3824
- "aria-label": "Close modal",
3825
- autoFocus: false
3826
- }) : button))), withDivider ? /*#__PURE__*/React.createElement(Divider, null) : null);
3827
- }
3828
- /**
3829
- * Renders the body of a modal.
3830
- *
3831
- * Convenient to use alongside ModalHeader and/or ModalFooter as needed. It ensures, among other
3832
- * things, that the contet of the modal body expands or contracts depending on the modal height
3833
- * setting or the size of the content. The body content also automatically scrolls when it's too
3834
- * large to fit the available space.
3835
- *
3836
- * @see DeprecatedModal
3837
- * @see DeprecatedModalHeader
3838
- * @see DeprecatedModalFooter
3839
- */
3840
-
3841
- function DeprecatedModalBody(_ref3) {
3842
- let {
3843
- exceptionallySetClassName,
3844
- children
3845
- } = _ref3,
3846
- props = _objectWithoutProperties(_ref3, _excluded3$3);
3847
-
3848
- const {
3849
- height
3850
- } = React.useContext(ModalContext$1);
3851
- return /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
3852
- className: exceptionallySetClassName,
3853
- flexGrow: height === 'expand' ? 1 : 0,
3854
- height: height === 'expand' ? 'full' : undefined,
3855
- overflow: "auto"
3856
- }), /*#__PURE__*/React.createElement(Box, {
3857
- padding: "large",
3858
- paddingBottom: "xxlarge"
3859
- }, children));
3860
- }
3861
- /**
3862
- * Renders a standard modal footer area.
3863
- *
3864
- * @see DeprecatedModal
3865
- * @see DeprecatedModalHeader
3866
- * @see DeprecatedModalBody
3867
- */
3868
-
3869
- function DeprecatedModalFooter(_ref4) {
3870
- let {
3871
- exceptionallySetClassName,
3872
- withDivider = false
3873
- } = _ref4,
3874
- props = _objectWithoutProperties(_ref4, _excluded4$2);
3875
-
3876
- return /*#__PURE__*/React.createElement(React.Fragment, null, withDivider ? /*#__PURE__*/React.createElement(Divider, null) : null, /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({
3877
- as: "footer"
3878
- }, props), {}, {
3879
- className: exceptionallySetClassName,
3880
- padding: "large"
3881
- })));
3882
- }
3883
- /**
3884
- * A specific version of the ModalFooter, tailored to showing an inline list of actions (buttons).
3885
- * @see DeprecatedModalFooter
3886
- */
3887
-
3888
- function DeprecatedModalActions(_ref5) {
3889
- let {
3890
- children
3891
- } = _ref5,
3892
- props = _objectWithoutProperties(_ref5, _excluded5$2);
3893
-
3894
- return /*#__PURE__*/React.createElement(DeprecatedModalFooter, _objectSpread2({}, props), /*#__PURE__*/React.createElement(Inline, {
3895
- align: "right",
3896
- space: "large"
3897
- }, children));
3898
- }
3899
-
3900
3741
  exports.Alert = Alert;
3901
3742
  exports.Avatar = Avatar;
3902
3743
  exports.Badge = Badge;
@@ -3913,12 +3754,6 @@ exports.ContextMenuTrigger = ContextMenuTrigger;
3913
3754
  exports.DeprecatedButton = Button$1;
3914
3755
  exports.DeprecatedDropdown = Dropdown;
3915
3756
  exports.DeprecatedInput = Input;
3916
- exports.DeprecatedModal = DeprecatedModal;
3917
- exports.DeprecatedModalActions = DeprecatedModalActions;
3918
- exports.DeprecatedModalBody = DeprecatedModalBody;
3919
- exports.DeprecatedModalCloseButton = DeprecatedModalCloseButton;
3920
- exports.DeprecatedModalFooter = DeprecatedModalFooter;
3921
- exports.DeprecatedModalHeader = DeprecatedModalHeader;
3922
3757
  exports.DeprecatedSelect = Select;
3923
3758
  exports.Divider = Divider;
3924
3759
  exports.Heading = Heading;