@doist/reactist 21.2.2 → 22.0.1-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/reactist.cjs.development.js +139 -185
- package/dist/reactist.cjs.development.js.map +1 -1
- package/dist/reactist.cjs.production.min.js +1 -1
- package/dist/reactist.cjs.production.min.js.map +1 -1
- package/es/checkbox-field/checkbox-field.js +1 -1
- package/es/checkbox-field/checkbox-field.js.map +1 -1
- package/es/checkbox-field/use-fork-ref.js +35 -0
- package/es/checkbox-field/use-fork-ref.js.map +1 -0
- package/es/menu/menu.js +35 -38
- package/es/menu/menu.js.map +1 -1
- package/es/modal/modal.js +3 -4
- package/es/modal/modal.js.map +1 -1
- package/es/tabs/tabs.js +40 -47
- package/es/tabs/tabs.js.map +1 -1
- package/es/toast/use-toasts.js +1 -1
- package/es/toast/use-toasts.js.map +1 -1
- package/es/tooltip/tooltip.js +20 -62
- package/es/tooltip/tooltip.js.map +1 -1
- package/lib/checkbox-field/checkbox-field.js +1 -1
- package/lib/checkbox-field/checkbox-field.js.map +1 -1
- package/lib/checkbox-field/use-fork-ref.d.ts +11 -0
- package/lib/checkbox-field/use-fork-ref.js +2 -0
- package/lib/checkbox-field/use-fork-ref.js.map +1 -0
- package/lib/menu/menu.d.ts +4 -4
- package/lib/menu/menu.js +1 -1
- package/lib/menu/menu.js.map +1 -1
- package/lib/modal/modal.d.ts +1 -2
- package/lib/modal/modal.js +1 -1
- package/lib/modal/modal.js.map +1 -1
- package/lib/tabs/tabs.d.ts +10 -8
- package/lib/tabs/tabs.js +1 -1
- package/lib/tabs/tabs.js.map +1 -1
- package/lib/toast/use-toasts.js +1 -1
- package/lib/toast/use-toasts.js.map +1 -1
- package/lib/tooltip/tooltip.d.ts +2 -4
- package/lib/tooltip/tooltip.js +1 -1
- package/lib/tooltip/tooltip.js.map +1 -1
- package/lib/utils/test-helpers.d.ts +13 -2
- package/package.json +2 -4
- package/es/hooks/use-previous/use-previous.js +0 -26
- package/es/hooks/use-previous/use-previous.js.map +0 -1
- package/lib/hooks/use-previous/use-previous.js +0 -2
- package/lib/hooks/use-previous/use-previous.js.map +0 -1
|
@@ -8,19 +8,14 @@ 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
|
|
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'));
|
|
23
|
-
var dialog
|
|
18
|
+
var dialog = require('@reach/dialog');
|
|
24
19
|
|
|
25
20
|
function ownKeys(object, enumerableOnly) {
|
|
26
21
|
var keys = Object.keys(object);
|
|
@@ -456,18 +451,6 @@ const HiddenVisually = /*#__PURE__*/polymorphicComponent(function HiddenVisually
|
|
|
456
451
|
|
|
457
452
|
var modules_95f1407a = {"tooltip":"_487c82cd"};
|
|
458
453
|
|
|
459
|
-
const SHOW_DELAY = 500;
|
|
460
|
-
const HIDE_DELAY = 100;
|
|
461
|
-
|
|
462
|
-
function useDelayedTooltipState(initialState) {
|
|
463
|
-
const tooltipState = tooltip.useTooltipState(initialState);
|
|
464
|
-
const delay = useDelay();
|
|
465
|
-
return React.useMemo(() => _objectSpread2(_objectSpread2({}, tooltipState), {}, {
|
|
466
|
-
show: delay(() => tooltipState.show(), SHOW_DELAY),
|
|
467
|
-
hide: delay(() => tooltipState.hide(), HIDE_DELAY)
|
|
468
|
-
}), [delay, tooltipState]);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
454
|
function Tooltip({
|
|
472
455
|
children,
|
|
473
456
|
content,
|
|
@@ -476,10 +459,12 @@ function Tooltip({
|
|
|
476
459
|
withArrow = false,
|
|
477
460
|
exceptionallySetClassName
|
|
478
461
|
}) {
|
|
479
|
-
const
|
|
462
|
+
const tooltip = react.useTooltipStore({
|
|
480
463
|
placement: position,
|
|
481
|
-
|
|
464
|
+
showTimeout: 500,
|
|
465
|
+
hideTimeout: 100
|
|
482
466
|
});
|
|
467
|
+
const isOpen = tooltip.useState('open');
|
|
483
468
|
const child = React.Children.only(children);
|
|
484
469
|
|
|
485
470
|
if (!child) {
|
|
@@ -508,7 +493,7 @@ function Tooltip({
|
|
|
508
493
|
const eventKey = event.key;
|
|
509
494
|
|
|
510
495
|
if (eventKey !== 'Escape' && eventKey !== 'Enter' && eventKey !== 'Space') {
|
|
511
|
-
|
|
496
|
+
tooltip.show();
|
|
512
497
|
}
|
|
513
498
|
}
|
|
514
499
|
|
|
@@ -523,25 +508,23 @@ function Tooltip({
|
|
|
523
508
|
function handleBlur(event) {
|
|
524
509
|
var _child$props2;
|
|
525
510
|
|
|
526
|
-
|
|
511
|
+
tooltip.hide();
|
|
527
512
|
child == null ? void 0 : (_child$props2 = child.props) == null ? void 0 : _child$props2.onBlur == null ? void 0 : _child$props2.onBlur(event);
|
|
528
513
|
}
|
|
529
514
|
|
|
530
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
as: tooltip.Tooltip,
|
|
544
|
-
state: state,
|
|
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,
|
|
545
528
|
className: [modules_95f1407a.tooltip, exceptionallySetClassName],
|
|
546
529
|
background: "toast",
|
|
547
530
|
borderRadius: "standard",
|
|
@@ -551,37 +534,7 @@ function Tooltip({
|
|
|
551
534
|
width: "fitContent",
|
|
552
535
|
overflow: "hidden",
|
|
553
536
|
textAlign: "center"
|
|
554
|
-
}, withArrow ? /*#__PURE__*/React.createElement(
|
|
555
|
-
}
|
|
556
|
-
// Internal helpers
|
|
557
|
-
//
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* Returns a function offering the same interface as setTimeout, but cleans up on unmount.
|
|
561
|
-
*
|
|
562
|
-
* The timeout state is shared, and only one delayed function can be active at any given time. If
|
|
563
|
-
* a new delayed function is called while another one was waiting for its time to run, that older
|
|
564
|
-
* invocation is cleared and it never runs.
|
|
565
|
-
*
|
|
566
|
-
* This is suitable for our use case here, but probably not the most intuitive thing in general.
|
|
567
|
-
* That's why this is not made a shared util or something like it.
|
|
568
|
-
*/
|
|
569
|
-
|
|
570
|
-
function useDelay() {
|
|
571
|
-
const timeoutRef = React.useRef();
|
|
572
|
-
const clearTimeouts = React.useCallback(function clearTimeouts() {
|
|
573
|
-
if (timeoutRef.current != null) {
|
|
574
|
-
clearTimeout(timeoutRef.current);
|
|
575
|
-
}
|
|
576
|
-
}, []); // Runs clearTimeouts when the component is unmounted
|
|
577
|
-
|
|
578
|
-
React.useEffect(() => clearTimeouts, [clearTimeouts]);
|
|
579
|
-
return React.useCallback(function delay(fn, delay) {
|
|
580
|
-
return () => {
|
|
581
|
-
clearTimeouts();
|
|
582
|
-
timeoutRef.current = setTimeout(fn, delay);
|
|
583
|
-
};
|
|
584
|
-
}, [clearTimeouts]);
|
|
537
|
+
}, withArrow ? /*#__PURE__*/React.createElement(react.TooltipArrow, null) : null, typeof content === 'function' ? content() : content) : null);
|
|
585
538
|
}
|
|
586
539
|
|
|
587
540
|
var modules_c7f5018f = {"svg":"_51539197","spinner":"_54fbe2b3","tint":"a0c466ed","fill":"_745b73d3"};
|
|
@@ -1354,7 +1307,7 @@ function ToastsProvider({
|
|
|
1354
1307
|
}, [defaultAutoDismissDelay, defaultDismissLabel, removeToast]);
|
|
1355
1308
|
return /*#__PURE__*/React__default.createElement(ToastsContext.Provider, {
|
|
1356
1309
|
value: showToast
|
|
1357
|
-
}, children, /*#__PURE__*/React__default.createElement(
|
|
1310
|
+
}, children, /*#__PURE__*/React__default.createElement(react.Portal, null, toasts.length === 0 ? null : /*#__PURE__*/React__default.createElement(Box, {
|
|
1358
1311
|
className: modules_d11e18f0.stackedToastsView,
|
|
1359
1312
|
position: "fixed",
|
|
1360
1313
|
width: "full",
|
|
@@ -1602,6 +1555,37 @@ function CheckboxIcon(_ref) {
|
|
|
1602
1555
|
|
|
1603
1556
|
var modules_664a6a80 = {"container":"_84dfdb83","disabled":"_131a2ca4","checked":"_95b1556d","keyFocused":"_49de7ebd","icon":"_6b4b1851","label":"_9047f3bd"};
|
|
1604
1557
|
|
|
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
|
+
|
|
1605
1589
|
const _excluded$j = ["label", "icon", "disabled", "indeterminate", "defaultChecked", "onChange"];
|
|
1606
1590
|
const CheckboxField = /*#__PURE__*/React.forwardRef(function CheckboxField(_ref, ref) {
|
|
1607
1591
|
var _ref2, _props$checked, _props$checked2;
|
|
@@ -1633,7 +1617,7 @@ const CheckboxField = /*#__PURE__*/React.forwardRef(function CheckboxField(_ref,
|
|
|
1633
1617
|
const [checkedState, setChecked] = React.useState((_ref2 = (_props$checked = props.checked) != null ? _props$checked : defaultChecked) != null ? _ref2 : false);
|
|
1634
1618
|
const isChecked = (_props$checked2 = props.checked) != null ? _props$checked2 : checkedState;
|
|
1635
1619
|
const internalRef = React.useRef(null);
|
|
1636
|
-
const combinedRef =
|
|
1620
|
+
const combinedRef = useForkRef(internalRef, ref);
|
|
1637
1621
|
React.useEffect(function setIndeterminate() {
|
|
1638
1622
|
if (internalRef.current && typeof indeterminate === 'boolean') {
|
|
1639
1623
|
internalRef.current.indeterminate = indeterminate;
|
|
@@ -2244,7 +2228,7 @@ function Modal(_ref) {
|
|
|
2244
2228
|
onDismiss == null ? void 0 : onDismiss();
|
|
2245
2229
|
}
|
|
2246
2230
|
}, [onDismiss]);
|
|
2247
|
-
const
|
|
2231
|
+
const store = react.useDialogStore({
|
|
2248
2232
|
open: isOpen,
|
|
2249
2233
|
setOpen
|
|
2250
2234
|
});
|
|
@@ -2278,7 +2262,7 @@ function Modal(_ref) {
|
|
|
2278
2262
|
return null;
|
|
2279
2263
|
}
|
|
2280
2264
|
|
|
2281
|
-
return /*#__PURE__*/React.createElement(
|
|
2265
|
+
return /*#__PURE__*/React.createElement(react.Portal, {
|
|
2282
2266
|
portalRef: portalRef,
|
|
2283
2267
|
portalElement: portalElement
|
|
2284
2268
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
@@ -2297,10 +2281,10 @@ function Modal(_ref) {
|
|
|
2297
2281
|
autoFocus: autoFocus,
|
|
2298
2282
|
whiteList: isNotInternalFrame,
|
|
2299
2283
|
returnFocus: true
|
|
2300
|
-
}, /*#__PURE__*/React.createElement(
|
|
2284
|
+
}, /*#__PURE__*/React.createElement(react.Dialog, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2301
2285
|
ref: dialogRef,
|
|
2302
2286
|
as: Box,
|
|
2303
|
-
|
|
2287
|
+
store: store,
|
|
2304
2288
|
hideOnEscape: hideOnEscape,
|
|
2305
2289
|
preventBodyScroll: true,
|
|
2306
2290
|
borderRadius: "full",
|
|
@@ -2462,28 +2446,6 @@ function ModalActions(_ref5) {
|
|
|
2462
2446
|
}, children));
|
|
2463
2447
|
}
|
|
2464
2448
|
|
|
2465
|
-
/**
|
|
2466
|
-
* usePrevious tracks the change of the given value -
|
|
2467
|
-
* when a given value has been changed from a previous call,
|
|
2468
|
-
* it will return the value prior to the change.
|
|
2469
|
-
*
|
|
2470
|
-
* Example:
|
|
2471
|
-
*
|
|
2472
|
-
* const [x, setX] = useState(1)
|
|
2473
|
-
* const prevX = usePrevious(x)
|
|
2474
|
-
*
|
|
2475
|
-
* Suppose `setX(2)` is called, then in the next component render
|
|
2476
|
-
* x = 2 and prevX = 1
|
|
2477
|
-
*/
|
|
2478
|
-
|
|
2479
|
-
function usePrevious(value) {
|
|
2480
|
-
const ref = React.useRef(null);
|
|
2481
|
-
React.useEffect(() => {
|
|
2482
|
-
ref.current = value;
|
|
2483
|
-
}, [value]);
|
|
2484
|
-
return ref.current;
|
|
2485
|
-
}
|
|
2486
|
-
|
|
2487
2449
|
var modules_40c67f5b = {"tab":"e96bf360","track":"_430e252d","tab-neutral":"f631ccbe","tab-themed":"_6ba96acc","track-neutral":"ef4cd8d3","track-themed":"_344b3b10"};
|
|
2488
2450
|
|
|
2489
2451
|
const _excluded$s = ["as", "children", "id", "exceptionallySetClassName"],
|
|
@@ -2501,26 +2463,21 @@ function Tabs({
|
|
|
2501
2463
|
variant = 'neutral',
|
|
2502
2464
|
onSelectedIdChange
|
|
2503
2465
|
}) {
|
|
2504
|
-
const
|
|
2466
|
+
const tabStore = react.useTabStore({
|
|
2467
|
+
defaultSelectedId,
|
|
2505
2468
|
selectedId,
|
|
2506
2469
|
setSelectedId: onSelectedIdChange
|
|
2507
2470
|
});
|
|
2508
|
-
const
|
|
2509
|
-
const {
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
} = tabState;
|
|
2513
|
-
React.useEffect(function selectDefaultTab() {
|
|
2514
|
-
if (!selectedId && defaultSelectedId !== previousDefaultSelectedId && defaultSelectedId !== actualSelectedId && defaultSelectedId !== undefined) {
|
|
2515
|
-
select(defaultSelectedId);
|
|
2516
|
-
}
|
|
2517
|
-
}, [selectedId, defaultSelectedId, actualSelectedId, select, previousDefaultSelectedId]);
|
|
2518
|
-
const memoizedTabState = React.useMemo(function memoizeTabState() {
|
|
2471
|
+
const actualSelectedId = tabStore.useState('selectedId');
|
|
2472
|
+
const memoizedTabState = React.useMemo(() => {
|
|
2473
|
+
var _ref;
|
|
2474
|
+
|
|
2519
2475
|
return {
|
|
2520
|
-
|
|
2521
|
-
variant
|
|
2476
|
+
tabStore,
|
|
2477
|
+
variant,
|
|
2478
|
+
selectedId: (_ref = selectedId != null ? selectedId : actualSelectedId) != null ? _ref : null
|
|
2522
2479
|
};
|
|
2523
|
-
}, [variant,
|
|
2480
|
+
}, [variant, tabStore, selectedId, actualSelectedId]);
|
|
2524
2481
|
return /*#__PURE__*/React.createElement(TabsContext.Provider, {
|
|
2525
2482
|
value: memoizedTabState
|
|
2526
2483
|
}, children);
|
|
@@ -2530,30 +2487,27 @@ function Tabs({
|
|
|
2530
2487
|
*/
|
|
2531
2488
|
|
|
2532
2489
|
|
|
2533
|
-
const Tab = /*#__PURE__*/polymorphicComponent(function Tab(
|
|
2490
|
+
const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref2, ref) {
|
|
2534
2491
|
let {
|
|
2535
2492
|
as,
|
|
2536
2493
|
children,
|
|
2537
2494
|
id,
|
|
2538
2495
|
exceptionallySetClassName
|
|
2539
|
-
} =
|
|
2540
|
-
props = _objectWithoutProperties(
|
|
2496
|
+
} = _ref2,
|
|
2497
|
+
props = _objectWithoutProperties(_ref2, _excluded$s);
|
|
2541
2498
|
|
|
2542
2499
|
const tabContextValue = React.useContext(TabsContext);
|
|
2543
|
-
|
|
2544
|
-
if (!tabContextValue) {
|
|
2545
|
-
return null;
|
|
2546
|
-
}
|
|
2547
|
-
|
|
2500
|
+
if (!tabContextValue) return null;
|
|
2548
2501
|
const {
|
|
2549
2502
|
variant,
|
|
2550
|
-
|
|
2503
|
+
tabStore
|
|
2551
2504
|
} = tabContextValue;
|
|
2552
|
-
|
|
2505
|
+
const className = classNames(exceptionallySetClassName, modules_40c67f5b.tab, modules_40c67f5b["tab-" + variant]);
|
|
2506
|
+
return /*#__PURE__*/React.createElement(react.Tab, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2553
2507
|
as: as,
|
|
2554
|
-
className:
|
|
2508
|
+
className: className,
|
|
2555
2509
|
id: id,
|
|
2556
|
-
|
|
2510
|
+
store: tabStore,
|
|
2557
2511
|
ref: ref
|
|
2558
2512
|
}), children);
|
|
2559
2513
|
});
|
|
@@ -2561,12 +2515,12 @@ const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref, ref) {
|
|
|
2561
2515
|
* A component used to group `<Tab>` elements together.
|
|
2562
2516
|
*/
|
|
2563
2517
|
|
|
2564
|
-
function TabList(
|
|
2518
|
+
function TabList(_ref3) {
|
|
2565
2519
|
let {
|
|
2566
2520
|
children,
|
|
2567
2521
|
space
|
|
2568
|
-
} =
|
|
2569
|
-
props = _objectWithoutProperties(
|
|
2522
|
+
} = _ref3,
|
|
2523
|
+
props = _objectWithoutProperties(_ref3, _excluded2$2);
|
|
2570
2524
|
|
|
2571
2525
|
const tabContextValue = React.useContext(TabsContext);
|
|
2572
2526
|
|
|
@@ -2575,15 +2529,15 @@ function TabList(_ref2) {
|
|
|
2575
2529
|
}
|
|
2576
2530
|
|
|
2577
2531
|
const {
|
|
2578
|
-
|
|
2532
|
+
tabStore,
|
|
2579
2533
|
variant
|
|
2580
2534
|
} = tabContextValue;
|
|
2581
2535
|
return (
|
|
2582
2536
|
/*#__PURE__*/
|
|
2583
2537
|
// The extra <Box> prevents <Inline>'s negative margins from collapsing when used in a flex container
|
|
2584
2538
|
// which will render the track with the wrong height
|
|
2585
|
-
React.createElement(Box, null, /*#__PURE__*/React.createElement(
|
|
2586
|
-
|
|
2539
|
+
React.createElement(Box, null, /*#__PURE__*/React.createElement(react.TabList, _objectSpread2({
|
|
2540
|
+
store: tabStore,
|
|
2587
2541
|
as: Box,
|
|
2588
2542
|
position: "relative",
|
|
2589
2543
|
width: "maxContent"
|
|
@@ -2595,22 +2549,24 @@ function TabList(_ref2) {
|
|
|
2595
2549
|
);
|
|
2596
2550
|
}
|
|
2597
2551
|
/**
|
|
2598
|
-
* Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a
|
|
2552
|
+
* Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a
|
|
2553
|
+
* corresponding `<Tab>` component.
|
|
2599
2554
|
*/
|
|
2600
2555
|
|
|
2601
2556
|
|
|
2602
|
-
const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(
|
|
2557
|
+
const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref4, ref) {
|
|
2603
2558
|
let {
|
|
2604
2559
|
children,
|
|
2605
2560
|
id,
|
|
2606
2561
|
as,
|
|
2607
2562
|
render = 'always'
|
|
2608
|
-
} =
|
|
2609
|
-
props = _objectWithoutProperties(
|
|
2563
|
+
} = _ref4,
|
|
2564
|
+
props = _objectWithoutProperties(_ref4, _excluded3$1);
|
|
2610
2565
|
|
|
2611
2566
|
const tabContextValue = React.useContext(TabsContext);
|
|
2612
2567
|
const [tabRendered, setTabRendered] = React.useState(false);
|
|
2613
|
-
const
|
|
2568
|
+
const selectedId = tabContextValue == null ? void 0 : tabContextValue.tabStore.useState('selectedId');
|
|
2569
|
+
const tabIsActive = selectedId === id;
|
|
2614
2570
|
React.useEffect(function trackTabRenderedState() {
|
|
2615
2571
|
if (!tabRendered && tabIsActive) {
|
|
2616
2572
|
setTabRendered(true);
|
|
@@ -2622,28 +2578,28 @@ const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref3, ref)
|
|
|
2622
2578
|
}
|
|
2623
2579
|
|
|
2624
2580
|
const {
|
|
2625
|
-
|
|
2581
|
+
tabStore
|
|
2626
2582
|
} = tabContextValue;
|
|
2627
2583
|
const shouldRender = render === 'always' || render === 'active' && tabIsActive || render === 'lazy' && (tabIsActive || tabRendered);
|
|
2628
|
-
return shouldRender ? /*#__PURE__*/React.createElement(
|
|
2629
|
-
tabId: id
|
|
2630
|
-
|
|
2631
|
-
state: tabState,
|
|
2584
|
+
return shouldRender ? /*#__PURE__*/React.createElement(react.TabPanel, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2585
|
+
tabId: id,
|
|
2586
|
+
store: tabStore,
|
|
2632
2587
|
as: as,
|
|
2633
2588
|
ref: ref
|
|
2634
2589
|
}), children) : null;
|
|
2635
2590
|
});
|
|
2636
2591
|
/**
|
|
2637
|
-
* Allows content to be rendered based on the current tab being selected while outside of the
|
|
2638
|
-
* component. Can be placed freely within the main `<Tabs>` component.
|
|
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.
|
|
2639
2594
|
*/
|
|
2640
2595
|
|
|
2641
2596
|
function TabAwareSlot({
|
|
2642
2597
|
children
|
|
2643
2598
|
}) {
|
|
2644
2599
|
const tabContextValue = React.useContext(TabsContext);
|
|
2600
|
+
const selectedId = tabContextValue == null ? void 0 : tabContextValue.tabStore.useState('selectedId');
|
|
2645
2601
|
return tabContextValue ? children({
|
|
2646
|
-
selectedId
|
|
2602
|
+
selectedId
|
|
2647
2603
|
}) : null;
|
|
2648
2604
|
}
|
|
2649
2605
|
|
|
@@ -2671,27 +2627,20 @@ function Menu(_ref) {
|
|
|
2671
2627
|
} = _ref,
|
|
2672
2628
|
props = _objectWithoutProperties(_ref, _excluded$t);
|
|
2673
2629
|
|
|
2674
|
-
const [anchorRect,
|
|
2675
|
-
const getAnchorRect = React.useMemo(() =>
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
const state = Ariakit.useMenuState(_objectSpread2({
|
|
2679
|
-
focusLoop: true,
|
|
2680
|
-
gutter: 8,
|
|
2681
|
-
shift: 4,
|
|
2682
|
-
getAnchorRect
|
|
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
|
|
2683
2634
|
}, props));
|
|
2684
|
-
React.useEffect(() => {
|
|
2685
|
-
if (!state.open) handleAnchorRectChange(null);
|
|
2686
|
-
}, [state.open]);
|
|
2687
2635
|
const handleItemSelect = React.useCallback(function handleItemSelect(value) {
|
|
2688
|
-
|
|
2636
|
+
onItemSelect == null ? void 0 : onItemSelect(value);
|
|
2689
2637
|
}, [onItemSelect]);
|
|
2690
2638
|
const value = React.useMemo(() => ({
|
|
2691
|
-
|
|
2639
|
+
menuStore,
|
|
2692
2640
|
handleItemSelect,
|
|
2693
|
-
|
|
2694
|
-
|
|
2641
|
+
getAnchorRect,
|
|
2642
|
+
setAnchorRect
|
|
2643
|
+
}), [menuStore, handleItemSelect, getAnchorRect, setAnchorRect]);
|
|
2695
2644
|
return /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
2696
2645
|
value: value
|
|
2697
2646
|
}, children);
|
|
@@ -2708,10 +2657,10 @@ const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2,
|
|
|
2708
2657
|
props = _objectWithoutProperties(_ref2, _excluded2$3);
|
|
2709
2658
|
|
|
2710
2659
|
const {
|
|
2711
|
-
|
|
2660
|
+
menuStore
|
|
2712
2661
|
} = React.useContext(MenuContext);
|
|
2713
|
-
return /*#__PURE__*/React.createElement(
|
|
2714
|
-
|
|
2662
|
+
return /*#__PURE__*/React.createElement(react.MenuButton, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2663
|
+
store: menuStore,
|
|
2715
2664
|
ref: ref,
|
|
2716
2665
|
className: classNames('reactist_menubutton', exceptionallySetClassName)
|
|
2717
2666
|
}));
|
|
@@ -2726,17 +2675,17 @@ const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMen
|
|
|
2726
2675
|
props = _objectWithoutProperties(_ref3, _excluded3$2);
|
|
2727
2676
|
|
|
2728
2677
|
const {
|
|
2729
|
-
|
|
2730
|
-
|
|
2678
|
+
setAnchorRect,
|
|
2679
|
+
menuStore
|
|
2731
2680
|
} = React.useContext(MenuContext);
|
|
2732
|
-
const handleContextMenu = React.useCallback(event
|
|
2681
|
+
const handleContextMenu = React.useCallback(function handleContextMenu(event) {
|
|
2733
2682
|
event.preventDefault();
|
|
2734
|
-
|
|
2683
|
+
setAnchorRect({
|
|
2735
2684
|
x: event.clientX,
|
|
2736
2685
|
y: event.clientY
|
|
2737
2686
|
});
|
|
2738
|
-
|
|
2739
|
-
}, [
|
|
2687
|
+
menuStore.show();
|
|
2688
|
+
}, [setAnchorRect, menuStore]);
|
|
2740
2689
|
return /*#__PURE__*/React.createElement(component, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2741
2690
|
onContextMenu: handleContextMenu,
|
|
2742
2691
|
ref
|
|
@@ -2754,14 +2703,19 @@ const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref4, ref)
|
|
|
2754
2703
|
props = _objectWithoutProperties(_ref4, _excluded4$1);
|
|
2755
2704
|
|
|
2756
2705
|
const {
|
|
2757
|
-
|
|
2706
|
+
menuStore,
|
|
2707
|
+
getAnchorRect
|
|
2758
2708
|
} = React.useContext(MenuContext);
|
|
2759
|
-
|
|
2709
|
+
const isOpen = menuStore.useState('open');
|
|
2710
|
+
return isOpen ? /*#__PURE__*/React.createElement(react.Portal, {
|
|
2760
2711
|
preserveTabOrder: true
|
|
2761
|
-
}, /*#__PURE__*/React.createElement(
|
|
2762
|
-
|
|
2712
|
+
}, /*#__PURE__*/React.createElement(react.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2713
|
+
store: menuStore,
|
|
2714
|
+
gutter: 8,
|
|
2715
|
+
shift: 4,
|
|
2763
2716
|
ref: ref,
|
|
2764
2717
|
className: classNames('reactist_menulist', exceptionallySetClassName),
|
|
2718
|
+
getAnchorRect: getAnchorRect != null ? getAnchorRect : undefined,
|
|
2765
2719
|
modal: modal
|
|
2766
2720
|
}))) : null;
|
|
2767
2721
|
});
|
|
@@ -2784,11 +2738,11 @@ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref)
|
|
|
2784
2738
|
|
|
2785
2739
|
const {
|
|
2786
2740
|
handleItemSelect,
|
|
2787
|
-
|
|
2741
|
+
menuStore
|
|
2788
2742
|
} = React.useContext(MenuContext);
|
|
2789
2743
|
const {
|
|
2790
2744
|
hide
|
|
2791
|
-
} =
|
|
2745
|
+
} = menuStore;
|
|
2792
2746
|
const handleClick = React.useCallback(function handleClick(event) {
|
|
2793
2747
|
onClick == null ? void 0 : onClick(event);
|
|
2794
2748
|
const onSelectResult = onSelect && !event.defaultPrevented ? onSelect() : undefined;
|
|
@@ -2796,9 +2750,9 @@ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref)
|
|
|
2796
2750
|
handleItemSelect(value);
|
|
2797
2751
|
if (shouldClose) hide();
|
|
2798
2752
|
}, [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value]);
|
|
2799
|
-
return /*#__PURE__*/React.createElement(
|
|
2753
|
+
return /*#__PURE__*/React.createElement(react.MenuItem, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2800
2754
|
as: as,
|
|
2801
|
-
|
|
2755
|
+
store: menuStore,
|
|
2802
2756
|
ref: ref,
|
|
2803
2757
|
onClick: handleClick,
|
|
2804
2758
|
className: exceptionallySetClassName,
|
|
@@ -2833,11 +2787,11 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
|
|
|
2833
2787
|
}, ref) {
|
|
2834
2788
|
const {
|
|
2835
2789
|
handleItemSelect: parentMenuItemSelect,
|
|
2836
|
-
|
|
2790
|
+
menuStore
|
|
2837
2791
|
} = React.useContext(MenuContext);
|
|
2838
2792
|
const {
|
|
2839
2793
|
hide: parentMenuHide
|
|
2840
|
-
} =
|
|
2794
|
+
} = menuStore;
|
|
2841
2795
|
const handleSubItemSelect = React.useCallback(function handleSubItemSelect(value) {
|
|
2842
2796
|
if (onItemSelect) onItemSelect(value);
|
|
2843
2797
|
parentMenuItemSelect(value);
|
|
@@ -2851,9 +2805,9 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
|
|
|
2851
2805
|
}, [button]);
|
|
2852
2806
|
return /*#__PURE__*/React.createElement(Menu, {
|
|
2853
2807
|
onItemSelect: handleSubItemSelect
|
|
2854
|
-
}, /*#__PURE__*/React.createElement(
|
|
2808
|
+
}, /*#__PURE__*/React.createElement(react.MenuItem, {
|
|
2855
2809
|
as: "div",
|
|
2856
|
-
|
|
2810
|
+
store: menuStore,
|
|
2857
2811
|
ref: ref,
|
|
2858
2812
|
hideOnClick: false
|
|
2859
2813
|
}, renderMenuButton), list);
|
|
@@ -2874,11 +2828,11 @@ const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(_ref6, re
|
|
|
2874
2828
|
props = _objectWithoutProperties(_ref6, _excluded6);
|
|
2875
2829
|
|
|
2876
2830
|
const {
|
|
2877
|
-
|
|
2831
|
+
menuStore
|
|
2878
2832
|
} = React.useContext(MenuContext);
|
|
2879
|
-
return /*#__PURE__*/React.createElement(
|
|
2833
|
+
return /*#__PURE__*/React.createElement(react.MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2880
2834
|
ref: ref,
|
|
2881
|
-
|
|
2835
|
+
store: menuStore,
|
|
2882
2836
|
className: exceptionallySetClassName
|
|
2883
2837
|
}), label ? /*#__PURE__*/React.createElement("div", {
|
|
2884
2838
|
role: "presentation",
|
|
@@ -3780,7 +3734,7 @@ function DeprecatedModal(_ref) {
|
|
|
3780
3734
|
onDismiss,
|
|
3781
3735
|
height
|
|
3782
3736
|
}), [onDismiss, height]);
|
|
3783
|
-
return /*#__PURE__*/React.createElement(dialog
|
|
3737
|
+
return /*#__PURE__*/React.createElement(dialog.DialogOverlay, {
|
|
3784
3738
|
isOpen: isOpen,
|
|
3785
3739
|
onDismiss: onDismiss,
|
|
3786
3740
|
dangerouslyBypassFocusLock // We're setting up our own focus lock below
|
|
@@ -3791,7 +3745,7 @@ function DeprecatedModal(_ref) {
|
|
|
3791
3745
|
autoFocus: autoFocus,
|
|
3792
3746
|
whiteList: isNotInternalFrame$1,
|
|
3793
3747
|
returnFocus: true
|
|
3794
|
-
}, /*#__PURE__*/React.createElement(dialog
|
|
3748
|
+
}, /*#__PURE__*/React.createElement(dialog.DialogContent, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
3795
3749
|
as: Box,
|
|
3796
3750
|
borderRadius: "full",
|
|
3797
3751
|
background: "default",
|