@doist/reactist 22.0.0 → 22.0.2-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 +136 -182
- 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 +4 -6
- 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,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
|
|
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 = 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
|
-
|
|
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
|
|
461
|
+
const tooltip = react.useTooltipStore({
|
|
479
462
|
placement: position,
|
|
480
|
-
|
|
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
|
-
|
|
495
|
+
tooltip.show();
|
|
511
496
|
}
|
|
512
497
|
}
|
|
513
498
|
|
|
@@ -522,25 +507,23 @@ function Tooltip({
|
|
|
522
507
|
function handleBlur(event) {
|
|
523
508
|
var _child$props2;
|
|
524
509
|
|
|
525
|
-
|
|
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(
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
as: tooltip.Tooltip,
|
|
543
|
-
state: state,
|
|
514
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(react.TooltipAnchor, {
|
|
515
|
+
render: anchorProps => {
|
|
516
|
+
return /*#__PURE__*/React.cloneElement(child, _objectSpread2(_objectSpread2(_objectSpread2({}, child.props), anchorProps), {}, {
|
|
517
|
+
onFocus: handleFocus,
|
|
518
|
+
onBlur: handleBlur
|
|
519
|
+
}));
|
|
520
|
+
},
|
|
521
|
+
store: tooltip,
|
|
522
|
+
ref: child.ref
|
|
523
|
+
}), isOpen && content ? /*#__PURE__*/React.createElement(Box, {
|
|
524
|
+
as: react.Tooltip,
|
|
525
|
+
gutter: gapSize,
|
|
526
|
+
store: tooltip,
|
|
544
527
|
className: [modules_95f1407a.tooltip, exceptionallySetClassName],
|
|
545
528
|
background: "toast",
|
|
546
529
|
borderRadius: "standard",
|
|
@@ -550,37 +533,7 @@ function Tooltip({
|
|
|
550
533
|
width: "fitContent",
|
|
551
534
|
overflow: "hidden",
|
|
552
535
|
textAlign: "center"
|
|
553
|
-
}, withArrow ? /*#__PURE__*/React.createElement(
|
|
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]);
|
|
536
|
+
}, withArrow ? /*#__PURE__*/React.createElement(react.TooltipArrow, null) : null, typeof content === 'function' ? content() : content) : null);
|
|
584
537
|
}
|
|
585
538
|
|
|
586
539
|
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, containerClassName],
|
|
1359
1312
|
position: "fixed",
|
|
1360
1313
|
width: "full",
|
|
@@ -1603,6 +1556,37 @@ function CheckboxIcon(_ref) {
|
|
|
1603
1556
|
|
|
1604
1557
|
var modules_664a6a80 = {"container":"_84dfdb83","disabled":"_131a2ca4","checked":"_95b1556d","keyFocused":"_49de7ebd","icon":"_6b4b1851","label":"_9047f3bd"};
|
|
1605
1558
|
|
|
1559
|
+
/**
|
|
1560
|
+
* Sets both a function and object React ref.
|
|
1561
|
+
*/
|
|
1562
|
+
|
|
1563
|
+
function setRef(ref, value) {
|
|
1564
|
+
if (typeof ref === 'function') {
|
|
1565
|
+
ref(value);
|
|
1566
|
+
} else if (ref) {
|
|
1567
|
+
ref.current = value;
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
/**
|
|
1571
|
+
* Merges React Refs into a single memoized function ref so you can pass it to an element.
|
|
1572
|
+
* @example
|
|
1573
|
+
* const Component = React.forwardRef((props, ref) => {
|
|
1574
|
+
* const internalRef = React.useRef();
|
|
1575
|
+
* return <div {...props} ref={useForkRef(internalRef, ref)} />;
|
|
1576
|
+
* });
|
|
1577
|
+
*/
|
|
1578
|
+
|
|
1579
|
+
|
|
1580
|
+
function useForkRef(...refs) {
|
|
1581
|
+
return React.useMemo(() => {
|
|
1582
|
+
if (!refs.some(Boolean)) return;
|
|
1583
|
+
return value => {
|
|
1584
|
+
refs.forEach(ref => setRef(ref, value));
|
|
1585
|
+
};
|
|
1586
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1587
|
+
refs);
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1606
1590
|
const _excluded$j = ["label", "icon", "disabled", "indeterminate", "defaultChecked", "onChange"];
|
|
1607
1591
|
const CheckboxField = /*#__PURE__*/React.forwardRef(function CheckboxField(_ref, ref) {
|
|
1608
1592
|
var _ref2, _props$checked, _props$checked2;
|
|
@@ -1634,7 +1618,7 @@ const CheckboxField = /*#__PURE__*/React.forwardRef(function CheckboxField(_ref,
|
|
|
1634
1618
|
const [checkedState, setChecked] = React.useState((_ref2 = (_props$checked = props.checked) != null ? _props$checked : defaultChecked) != null ? _ref2 : false);
|
|
1635
1619
|
const isChecked = (_props$checked2 = props.checked) != null ? _props$checked2 : checkedState;
|
|
1636
1620
|
const internalRef = React.useRef(null);
|
|
1637
|
-
const combinedRef =
|
|
1621
|
+
const combinedRef = useForkRef(internalRef, ref);
|
|
1638
1622
|
React.useEffect(function setIndeterminate() {
|
|
1639
1623
|
if (internalRef.current && typeof indeterminate === 'boolean') {
|
|
1640
1624
|
internalRef.current.indeterminate = indeterminate;
|
|
@@ -2245,7 +2229,7 @@ function Modal(_ref) {
|
|
|
2245
2229
|
onDismiss == null ? void 0 : onDismiss();
|
|
2246
2230
|
}
|
|
2247
2231
|
}, [onDismiss]);
|
|
2248
|
-
const
|
|
2232
|
+
const store = react.useDialogStore({
|
|
2249
2233
|
open: isOpen,
|
|
2250
2234
|
setOpen
|
|
2251
2235
|
});
|
|
@@ -2279,7 +2263,7 @@ function Modal(_ref) {
|
|
|
2279
2263
|
return null;
|
|
2280
2264
|
}
|
|
2281
2265
|
|
|
2282
|
-
return /*#__PURE__*/React.createElement(
|
|
2266
|
+
return /*#__PURE__*/React.createElement(react.Portal, {
|
|
2283
2267
|
portalRef: portalRef,
|
|
2284
2268
|
portalElement: portalElement
|
|
2285
2269
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
@@ -2298,10 +2282,10 @@ function Modal(_ref) {
|
|
|
2298
2282
|
autoFocus: autoFocus,
|
|
2299
2283
|
whiteList: isNotInternalFrame,
|
|
2300
2284
|
returnFocus: true
|
|
2301
|
-
}, /*#__PURE__*/React.createElement(
|
|
2285
|
+
}, /*#__PURE__*/React.createElement(react.Dialog, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2302
2286
|
ref: dialogRef,
|
|
2303
2287
|
as: Box,
|
|
2304
|
-
|
|
2288
|
+
store: store,
|
|
2305
2289
|
hideOnEscape: hideOnEscape,
|
|
2306
2290
|
preventBodyScroll: true,
|
|
2307
2291
|
borderRadius: "full",
|
|
@@ -2463,28 +2447,6 @@ function ModalActions(_ref5) {
|
|
|
2463
2447
|
}, children));
|
|
2464
2448
|
}
|
|
2465
2449
|
|
|
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
|
-
|
|
2488
2450
|
var modules_40c67f5b = {"tab":"e96bf360","track":"_430e252d","tab-neutral":"f631ccbe","tab-themed":"_6ba96acc","track-neutral":"ef4cd8d3","track-themed":"_344b3b10"};
|
|
2489
2451
|
|
|
2490
2452
|
const _excluded$s = ["as", "children", "id", "exceptionallySetClassName"],
|
|
@@ -2502,26 +2464,21 @@ function Tabs({
|
|
|
2502
2464
|
variant = 'neutral',
|
|
2503
2465
|
onSelectedIdChange
|
|
2504
2466
|
}) {
|
|
2505
|
-
const
|
|
2467
|
+
const tabStore = react.useTabStore({
|
|
2468
|
+
defaultSelectedId,
|
|
2506
2469
|
selectedId,
|
|
2507
2470
|
setSelectedId: onSelectedIdChange
|
|
2508
2471
|
});
|
|
2509
|
-
const
|
|
2510
|
-
const {
|
|
2511
|
-
|
|
2512
|
-
|
|
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() {
|
|
2472
|
+
const actualSelectedId = tabStore.useState('selectedId');
|
|
2473
|
+
const memoizedTabState = React.useMemo(() => {
|
|
2474
|
+
var _ref;
|
|
2475
|
+
|
|
2520
2476
|
return {
|
|
2521
|
-
|
|
2522
|
-
variant
|
|
2477
|
+
tabStore,
|
|
2478
|
+
variant,
|
|
2479
|
+
selectedId: (_ref = selectedId != null ? selectedId : actualSelectedId) != null ? _ref : null
|
|
2523
2480
|
};
|
|
2524
|
-
}, [variant,
|
|
2481
|
+
}, [variant, tabStore, selectedId, actualSelectedId]);
|
|
2525
2482
|
return /*#__PURE__*/React.createElement(TabsContext.Provider, {
|
|
2526
2483
|
value: memoizedTabState
|
|
2527
2484
|
}, children);
|
|
@@ -2531,30 +2488,27 @@ function Tabs({
|
|
|
2531
2488
|
*/
|
|
2532
2489
|
|
|
2533
2490
|
|
|
2534
|
-
const Tab = /*#__PURE__*/polymorphicComponent(function Tab(
|
|
2491
|
+
const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref2, ref) {
|
|
2535
2492
|
let {
|
|
2536
2493
|
as,
|
|
2537
2494
|
children,
|
|
2538
2495
|
id,
|
|
2539
2496
|
exceptionallySetClassName
|
|
2540
|
-
} =
|
|
2541
|
-
props = _objectWithoutProperties(
|
|
2497
|
+
} = _ref2,
|
|
2498
|
+
props = _objectWithoutProperties(_ref2, _excluded$s);
|
|
2542
2499
|
|
|
2543
2500
|
const tabContextValue = React.useContext(TabsContext);
|
|
2544
|
-
|
|
2545
|
-
if (!tabContextValue) {
|
|
2546
|
-
return null;
|
|
2547
|
-
}
|
|
2548
|
-
|
|
2501
|
+
if (!tabContextValue) return null;
|
|
2549
2502
|
const {
|
|
2550
2503
|
variant,
|
|
2551
|
-
|
|
2504
|
+
tabStore
|
|
2552
2505
|
} = tabContextValue;
|
|
2553
|
-
|
|
2506
|
+
const className = classNames(exceptionallySetClassName, modules_40c67f5b.tab, modules_40c67f5b["tab-" + variant]);
|
|
2507
|
+
return /*#__PURE__*/React.createElement(react.Tab, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2554
2508
|
as: as,
|
|
2555
|
-
className:
|
|
2509
|
+
className: className,
|
|
2556
2510
|
id: id,
|
|
2557
|
-
|
|
2511
|
+
store: tabStore,
|
|
2558
2512
|
ref: ref
|
|
2559
2513
|
}), children);
|
|
2560
2514
|
});
|
|
@@ -2562,12 +2516,12 @@ const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref, ref) {
|
|
|
2562
2516
|
* A component used to group `<Tab>` elements together.
|
|
2563
2517
|
*/
|
|
2564
2518
|
|
|
2565
|
-
function TabList(
|
|
2519
|
+
function TabList(_ref3) {
|
|
2566
2520
|
let {
|
|
2567
2521
|
children,
|
|
2568
2522
|
space
|
|
2569
|
-
} =
|
|
2570
|
-
props = _objectWithoutProperties(
|
|
2523
|
+
} = _ref3,
|
|
2524
|
+
props = _objectWithoutProperties(_ref3, _excluded2$2);
|
|
2571
2525
|
|
|
2572
2526
|
const tabContextValue = React.useContext(TabsContext);
|
|
2573
2527
|
|
|
@@ -2576,15 +2530,15 @@ function TabList(_ref2) {
|
|
|
2576
2530
|
}
|
|
2577
2531
|
|
|
2578
2532
|
const {
|
|
2579
|
-
|
|
2533
|
+
tabStore,
|
|
2580
2534
|
variant
|
|
2581
2535
|
} = tabContextValue;
|
|
2582
2536
|
return (
|
|
2583
2537
|
/*#__PURE__*/
|
|
2584
2538
|
// The extra <Box> prevents <Inline>'s negative margins from collapsing when used in a flex container
|
|
2585
2539
|
// which will render the track with the wrong height
|
|
2586
|
-
React.createElement(Box, null, /*#__PURE__*/React.createElement(
|
|
2587
|
-
|
|
2540
|
+
React.createElement(Box, null, /*#__PURE__*/React.createElement(react.TabList, _objectSpread2({
|
|
2541
|
+
store: tabStore,
|
|
2588
2542
|
as: Box,
|
|
2589
2543
|
position: "relative",
|
|
2590
2544
|
width: "maxContent"
|
|
@@ -2596,22 +2550,24 @@ function TabList(_ref2) {
|
|
|
2596
2550
|
);
|
|
2597
2551
|
}
|
|
2598
2552
|
/**
|
|
2599
|
-
* Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a
|
|
2553
|
+
* Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a
|
|
2554
|
+
* corresponding `<Tab>` component.
|
|
2600
2555
|
*/
|
|
2601
2556
|
|
|
2602
2557
|
|
|
2603
|
-
const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(
|
|
2558
|
+
const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref4, ref) {
|
|
2604
2559
|
let {
|
|
2605
2560
|
children,
|
|
2606
2561
|
id,
|
|
2607
2562
|
as,
|
|
2608
2563
|
render = 'always'
|
|
2609
|
-
} =
|
|
2610
|
-
props = _objectWithoutProperties(
|
|
2564
|
+
} = _ref4,
|
|
2565
|
+
props = _objectWithoutProperties(_ref4, _excluded3$1);
|
|
2611
2566
|
|
|
2612
2567
|
const tabContextValue = React.useContext(TabsContext);
|
|
2613
2568
|
const [tabRendered, setTabRendered] = React.useState(false);
|
|
2614
|
-
const
|
|
2569
|
+
const selectedId = tabContextValue == null ? void 0 : tabContextValue.tabStore.useState('selectedId');
|
|
2570
|
+
const tabIsActive = selectedId === id;
|
|
2615
2571
|
React.useEffect(function trackTabRenderedState() {
|
|
2616
2572
|
if (!tabRendered && tabIsActive) {
|
|
2617
2573
|
setTabRendered(true);
|
|
@@ -2623,28 +2579,28 @@ const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref3, ref)
|
|
|
2623
2579
|
}
|
|
2624
2580
|
|
|
2625
2581
|
const {
|
|
2626
|
-
|
|
2582
|
+
tabStore
|
|
2627
2583
|
} = tabContextValue;
|
|
2628
2584
|
const shouldRender = render === 'always' || render === 'active' && tabIsActive || render === 'lazy' && (tabIsActive || tabRendered);
|
|
2629
|
-
return shouldRender ? /*#__PURE__*/React.createElement(
|
|
2630
|
-
tabId: id
|
|
2631
|
-
|
|
2632
|
-
state: tabState,
|
|
2585
|
+
return shouldRender ? /*#__PURE__*/React.createElement(react.TabPanel, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2586
|
+
tabId: id,
|
|
2587
|
+
store: tabStore,
|
|
2633
2588
|
as: as,
|
|
2634
2589
|
ref: ref
|
|
2635
2590
|
}), children) : null;
|
|
2636
2591
|
});
|
|
2637
2592
|
/**
|
|
2638
|
-
* Allows content to be rendered based on the current tab being selected while outside of the
|
|
2639
|
-
* component. Can be placed freely within the main `<Tabs>` component.
|
|
2593
|
+
* Allows content to be rendered based on the current tab being selected while outside of the
|
|
2594
|
+
* TabPanel component. Can be placed freely within the main `<Tabs>` component.
|
|
2640
2595
|
*/
|
|
2641
2596
|
|
|
2642
2597
|
function TabAwareSlot({
|
|
2643
2598
|
children
|
|
2644
2599
|
}) {
|
|
2645
2600
|
const tabContextValue = React.useContext(TabsContext);
|
|
2601
|
+
const selectedId = tabContextValue == null ? void 0 : tabContextValue.tabStore.useState('selectedId');
|
|
2646
2602
|
return tabContextValue ? children({
|
|
2647
|
-
selectedId
|
|
2603
|
+
selectedId
|
|
2648
2604
|
}) : null;
|
|
2649
2605
|
}
|
|
2650
2606
|
|
|
@@ -2672,27 +2628,20 @@ function Menu(_ref) {
|
|
|
2672
2628
|
} = _ref,
|
|
2673
2629
|
props = _objectWithoutProperties(_ref, _excluded$t);
|
|
2674
2630
|
|
|
2675
|
-
const [anchorRect,
|
|
2676
|
-
const getAnchorRect = React.useMemo(() =>
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
const state = Ariakit.useMenuState(_objectSpread2({
|
|
2680
|
-
focusLoop: true,
|
|
2681
|
-
gutter: 8,
|
|
2682
|
-
shift: 4,
|
|
2683
|
-
getAnchorRect
|
|
2631
|
+
const [anchorRect, setAnchorRect] = React.useState(null);
|
|
2632
|
+
const getAnchorRect = React.useMemo(() => anchorRect ? () => anchorRect : null, [anchorRect]);
|
|
2633
|
+
const menuStore = react.useMenuStore(_objectSpread2({
|
|
2634
|
+
focusLoop: true
|
|
2684
2635
|
}, props));
|
|
2685
|
-
React.useEffect(() => {
|
|
2686
|
-
if (!state.open) handleAnchorRectChange(null);
|
|
2687
|
-
}, [state.open]);
|
|
2688
2636
|
const handleItemSelect = React.useCallback(function handleItemSelect(value) {
|
|
2689
|
-
|
|
2637
|
+
onItemSelect == null ? void 0 : onItemSelect(value);
|
|
2690
2638
|
}, [onItemSelect]);
|
|
2691
2639
|
const value = React.useMemo(() => ({
|
|
2692
|
-
|
|
2640
|
+
menuStore,
|
|
2693
2641
|
handleItemSelect,
|
|
2694
|
-
|
|
2695
|
-
|
|
2642
|
+
getAnchorRect,
|
|
2643
|
+
setAnchorRect
|
|
2644
|
+
}), [menuStore, handleItemSelect, getAnchorRect, setAnchorRect]);
|
|
2696
2645
|
return /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
2697
2646
|
value: value
|
|
2698
2647
|
}, children);
|
|
@@ -2709,10 +2658,10 @@ const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2,
|
|
|
2709
2658
|
props = _objectWithoutProperties(_ref2, _excluded2$3);
|
|
2710
2659
|
|
|
2711
2660
|
const {
|
|
2712
|
-
|
|
2661
|
+
menuStore
|
|
2713
2662
|
} = React.useContext(MenuContext);
|
|
2714
|
-
return /*#__PURE__*/React.createElement(
|
|
2715
|
-
|
|
2663
|
+
return /*#__PURE__*/React.createElement(react.MenuButton, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2664
|
+
store: menuStore,
|
|
2716
2665
|
ref: ref,
|
|
2717
2666
|
className: classNames('reactist_menubutton', exceptionallySetClassName)
|
|
2718
2667
|
}));
|
|
@@ -2727,17 +2676,17 @@ const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMen
|
|
|
2727
2676
|
props = _objectWithoutProperties(_ref3, _excluded3$2);
|
|
2728
2677
|
|
|
2729
2678
|
const {
|
|
2730
|
-
|
|
2731
|
-
|
|
2679
|
+
setAnchorRect,
|
|
2680
|
+
menuStore
|
|
2732
2681
|
} = React.useContext(MenuContext);
|
|
2733
|
-
const handleContextMenu = React.useCallback(event
|
|
2682
|
+
const handleContextMenu = React.useCallback(function handleContextMenu(event) {
|
|
2734
2683
|
event.preventDefault();
|
|
2735
|
-
|
|
2684
|
+
setAnchorRect({
|
|
2736
2685
|
x: event.clientX,
|
|
2737
2686
|
y: event.clientY
|
|
2738
2687
|
});
|
|
2739
|
-
|
|
2740
|
-
}, [
|
|
2688
|
+
menuStore.show();
|
|
2689
|
+
}, [setAnchorRect, menuStore]);
|
|
2741
2690
|
return /*#__PURE__*/React.createElement(component, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2742
2691
|
onContextMenu: handleContextMenu,
|
|
2743
2692
|
ref
|
|
@@ -2755,14 +2704,19 @@ const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref4, ref)
|
|
|
2755
2704
|
props = _objectWithoutProperties(_ref4, _excluded4$1);
|
|
2756
2705
|
|
|
2757
2706
|
const {
|
|
2758
|
-
|
|
2707
|
+
menuStore,
|
|
2708
|
+
getAnchorRect
|
|
2759
2709
|
} = React.useContext(MenuContext);
|
|
2760
|
-
|
|
2710
|
+
const isOpen = menuStore.useState('open');
|
|
2711
|
+
return isOpen ? /*#__PURE__*/React.createElement(react.Portal, {
|
|
2761
2712
|
preserveTabOrder: true
|
|
2762
|
-
}, /*#__PURE__*/React.createElement(
|
|
2763
|
-
|
|
2713
|
+
}, /*#__PURE__*/React.createElement(react.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2714
|
+
store: menuStore,
|
|
2715
|
+
gutter: 8,
|
|
2716
|
+
shift: 4,
|
|
2764
2717
|
ref: ref,
|
|
2765
2718
|
className: classNames('reactist_menulist', exceptionallySetClassName),
|
|
2719
|
+
getAnchorRect: getAnchorRect != null ? getAnchorRect : undefined,
|
|
2766
2720
|
modal: modal
|
|
2767
2721
|
}))) : null;
|
|
2768
2722
|
});
|
|
@@ -2785,11 +2739,11 @@ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref)
|
|
|
2785
2739
|
|
|
2786
2740
|
const {
|
|
2787
2741
|
handleItemSelect,
|
|
2788
|
-
|
|
2742
|
+
menuStore
|
|
2789
2743
|
} = React.useContext(MenuContext);
|
|
2790
2744
|
const {
|
|
2791
2745
|
hide
|
|
2792
|
-
} =
|
|
2746
|
+
} = menuStore;
|
|
2793
2747
|
const handleClick = React.useCallback(function handleClick(event) {
|
|
2794
2748
|
onClick == null ? void 0 : onClick(event);
|
|
2795
2749
|
const onSelectResult = onSelect && !event.defaultPrevented ? onSelect() : undefined;
|
|
@@ -2797,9 +2751,9 @@ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref)
|
|
|
2797
2751
|
handleItemSelect(value);
|
|
2798
2752
|
if (shouldClose) hide();
|
|
2799
2753
|
}, [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value]);
|
|
2800
|
-
return /*#__PURE__*/React.createElement(
|
|
2754
|
+
return /*#__PURE__*/React.createElement(react.MenuItem, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2801
2755
|
as: as,
|
|
2802
|
-
|
|
2756
|
+
store: menuStore,
|
|
2803
2757
|
ref: ref,
|
|
2804
2758
|
onClick: handleClick,
|
|
2805
2759
|
className: exceptionallySetClassName,
|
|
@@ -2834,11 +2788,11 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
|
|
|
2834
2788
|
}, ref) {
|
|
2835
2789
|
const {
|
|
2836
2790
|
handleItemSelect: parentMenuItemSelect,
|
|
2837
|
-
|
|
2791
|
+
menuStore
|
|
2838
2792
|
} = React.useContext(MenuContext);
|
|
2839
2793
|
const {
|
|
2840
2794
|
hide: parentMenuHide
|
|
2841
|
-
} =
|
|
2795
|
+
} = menuStore;
|
|
2842
2796
|
const handleSubItemSelect = React.useCallback(function handleSubItemSelect(value) {
|
|
2843
2797
|
if (onItemSelect) onItemSelect(value);
|
|
2844
2798
|
parentMenuItemSelect(value);
|
|
@@ -2852,9 +2806,9 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
|
|
|
2852
2806
|
}, [button]);
|
|
2853
2807
|
return /*#__PURE__*/React.createElement(Menu, {
|
|
2854
2808
|
onItemSelect: handleSubItemSelect
|
|
2855
|
-
}, /*#__PURE__*/React.createElement(
|
|
2809
|
+
}, /*#__PURE__*/React.createElement(react.MenuItem, {
|
|
2856
2810
|
as: "div",
|
|
2857
|
-
|
|
2811
|
+
store: menuStore,
|
|
2858
2812
|
ref: ref,
|
|
2859
2813
|
hideOnClick: false
|
|
2860
2814
|
}, renderMenuButton), list);
|
|
@@ -2875,11 +2829,11 @@ const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(_ref6, re
|
|
|
2875
2829
|
props = _objectWithoutProperties(_ref6, _excluded6);
|
|
2876
2830
|
|
|
2877
2831
|
const {
|
|
2878
|
-
|
|
2832
|
+
menuStore
|
|
2879
2833
|
} = React.useContext(MenuContext);
|
|
2880
|
-
return /*#__PURE__*/React.createElement(
|
|
2834
|
+
return /*#__PURE__*/React.createElement(react.MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2881
2835
|
ref: ref,
|
|
2882
|
-
|
|
2836
|
+
store: menuStore,
|
|
2883
2837
|
className: exceptionallySetClassName
|
|
2884
2838
|
}), label ? /*#__PURE__*/React.createElement("div", {
|
|
2885
2839
|
role: "presentation",
|