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