@doist/reactist 22.0.0-beta → 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 +190 -482
- 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/index.js +1 -1
- package/es/menu/menu.js +89 -337
- 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/index.js +1 -1
- package/lib/menu/index.d.ts +2 -1
- package/lib/menu/menu.d.ts +27 -167
- 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/styles/menu.css +1 -8
- package/styles/reactist.css +2 -2
- package/es/hooks/use-previous/use-previous.js +0 -26
- package/es/hooks/use-previous/use-previous.js.map +0 -1
- package/es/menu/menu.module.css.js +0 -4
- package/es/menu/menu.module.css.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
- package/lib/menu/menu.module.css.js +0 -2
- package/lib/menu/menu.module.css.js.map +0 -1
- package/styles/menu.module.css.css +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,43 +2578,37 @@ 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
|
|
|
2650
|
-
var modules_2befbba6 = {"menuList":"c63e79f3","subMenuList":"_1e89cfc6","iconMenuItem":"_1b808bea","menuItem":"_8607099d","legacyLayout":"_609759d5","menuGroupLabel":"f1730843","menuItemIcon":"_7cec7dce","menuItemLabel":"_91c012d8","menuItemDescription":"bb494fd4","destructive":"_503b074a","menuGroupInfo":"ad6d2e4a","iconsMenuGroup":"_410b11f2"};
|
|
2651
|
-
|
|
2652
2606
|
const _excluded$t = ["children", "onItemSelect"],
|
|
2653
2607
|
_excluded2$3 = ["exceptionallySetClassName"],
|
|
2654
|
-
_excluded3$2 = ["
|
|
2655
|
-
_excluded4$1 = ["
|
|
2656
|
-
_excluded5$1 = ["exceptionallySetClassName", "
|
|
2657
|
-
_excluded6 = ["
|
|
2658
|
-
_excluded7 = ["value", "label", "description", "icon", "shortcut", "tone", "children", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName", "as"],
|
|
2659
|
-
_excluded8 = ["label", "info", "children", "exceptionallySetClassName"],
|
|
2660
|
-
_excluded9 = ["value", "label", "description", "icon", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName", "as"],
|
|
2661
|
-
_excluded10 = ["children"];
|
|
2608
|
+
_excluded3$2 = ["as"],
|
|
2609
|
+
_excluded4$1 = ["exceptionallySetClassName", "modal"],
|
|
2610
|
+
_excluded5$1 = ["value", "children", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName", "as"],
|
|
2611
|
+
_excluded6 = ["label", "children", "exceptionallySetClassName"];
|
|
2662
2612
|
const MenuContext = /*#__PURE__*/React.createContext( // Ariakit gives us no means to obtain a valid initial/default value of type MenuStateReturn
|
|
2663
2613
|
// (it is normally obtained by calling useMenuState but we can't call hooks outside components).
|
|
2664
2614
|
// This is however of little consequence since this value is only used if some of the components
|
|
@@ -2670,45 +2620,36 @@ const MenuContext = /*#__PURE__*/React.createContext( // Ariakit gives us no mea
|
|
|
2670
2620
|
* management for the menu components inside it.
|
|
2671
2621
|
*/
|
|
2672
2622
|
|
|
2673
|
-
|
|
2623
|
+
function Menu(_ref) {
|
|
2674
2624
|
let {
|
|
2675
2625
|
children,
|
|
2676
2626
|
onItemSelect
|
|
2677
2627
|
} = _ref,
|
|
2678
2628
|
props = _objectWithoutProperties(_ref, _excluded$t);
|
|
2679
2629
|
|
|
2680
|
-
const [anchorRect,
|
|
2681
|
-
const getAnchorRect = React.useMemo(() =>
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
const state = Ariakit.useMenuState(_objectSpread2({
|
|
2685
|
-
focusLoop: true,
|
|
2686
|
-
gutter: 8,
|
|
2687
|
-
shift: 4,
|
|
2688
|
-
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
|
|
2689
2634
|
}, props));
|
|
2690
|
-
React.useEffect(() => {
|
|
2691
|
-
if (!state.open) handleAnchorRectChange(null);
|
|
2692
|
-
}, [state.open]);
|
|
2693
|
-
React.useImperativeHandle(ref, () => ({
|
|
2694
|
-
open: state.show
|
|
2695
|
-
}));
|
|
2696
2635
|
const handleItemSelect = React.useCallback(function handleItemSelect(value) {
|
|
2697
|
-
|
|
2636
|
+
onItemSelect == null ? void 0 : onItemSelect(value);
|
|
2698
2637
|
}, [onItemSelect]);
|
|
2699
2638
|
const value = React.useMemo(() => ({
|
|
2700
|
-
|
|
2639
|
+
menuStore,
|
|
2701
2640
|
handleItemSelect,
|
|
2702
|
-
|
|
2703
|
-
|
|
2641
|
+
getAnchorRect,
|
|
2642
|
+
setAnchorRect
|
|
2643
|
+
}), [menuStore, handleItemSelect, getAnchorRect, setAnchorRect]);
|
|
2704
2644
|
return /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
2705
2645
|
value: value
|
|
2706
2646
|
}, children);
|
|
2707
|
-
}
|
|
2647
|
+
}
|
|
2708
2648
|
/**
|
|
2709
2649
|
* A button to toggle a dropdown menu open or closed.
|
|
2710
2650
|
*/
|
|
2711
2651
|
|
|
2652
|
+
|
|
2712
2653
|
const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2, ref) {
|
|
2713
2654
|
let {
|
|
2714
2655
|
exceptionallySetClassName
|
|
@@ -2716,122 +2657,35 @@ const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2,
|
|
|
2716
2657
|
props = _objectWithoutProperties(_ref2, _excluded2$3);
|
|
2717
2658
|
|
|
2718
2659
|
const {
|
|
2719
|
-
|
|
2660
|
+
menuStore
|
|
2720
2661
|
} = React.useContext(MenuContext);
|
|
2721
|
-
return /*#__PURE__*/React.createElement(
|
|
2722
|
-
|
|
2662
|
+
return /*#__PURE__*/React.createElement(react.MenuButton, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2663
|
+
store: menuStore,
|
|
2723
2664
|
ref: ref,
|
|
2724
|
-
className: exceptionallySetClassName
|
|
2725
|
-
}));
|
|
2726
|
-
});
|
|
2727
|
-
/**
|
|
2728
|
-
* Renders the content inside a standard MenuItem. It is extracted into a component for reuse in
|
|
2729
|
-
* the SubMenuItem, which is a MenuItem visually, but semantically it's closer to be a MenuButton.
|
|
2730
|
-
* @private
|
|
2731
|
-
*/
|
|
2732
|
-
|
|
2733
|
-
function MenuItemContent({
|
|
2734
|
-
label,
|
|
2735
|
-
description,
|
|
2736
|
-
icon,
|
|
2737
|
-
shortcut,
|
|
2738
|
-
id
|
|
2739
|
-
}) {
|
|
2740
|
-
if (!label) return null;
|
|
2741
|
-
return /*#__PURE__*/React.createElement(Box, {
|
|
2742
|
-
display: "flex",
|
|
2743
|
-
gap: "small",
|
|
2744
|
-
alignItems: "center",
|
|
2745
|
-
width: "full",
|
|
2746
|
-
"aria-hidden": true
|
|
2747
|
-
}, icon ? /*#__PURE__*/React.createElement("div", {
|
|
2748
|
-
className: modules_2befbba6.menuItemIcon
|
|
2749
|
-
}, icon) : null, /*#__PURE__*/React.createElement(Box, {
|
|
2750
|
-
display: "inlineFlex",
|
|
2751
|
-
flexDirection: "column",
|
|
2752
|
-
gap: "xsmall",
|
|
2753
|
-
paddingY: "xsmall",
|
|
2754
|
-
alignItems: "flexStart",
|
|
2755
|
-
overflow: "hidden",
|
|
2756
|
-
flexGrow: 1
|
|
2757
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
2758
|
-
id: id + "-label",
|
|
2759
|
-
weight: description ? 'semibold' : 'regular',
|
|
2760
|
-
size: "copy",
|
|
2761
|
-
lineClamp: 1,
|
|
2762
|
-
exceptionallySetClassName: modules_2befbba6.menuItemLabel
|
|
2763
|
-
}, label), description ? /*#__PURE__*/React.createElement(Text, {
|
|
2764
|
-
id: id + "-description",
|
|
2765
|
-
size: "copy",
|
|
2766
|
-
tone: "secondary",
|
|
2767
|
-
exceptionallySetClassName: modules_2befbba6.menuItemDescription
|
|
2768
|
-
}, description) : null), shortcut ? /*#__PURE__*/React.createElement("div", null, shortcut) : null);
|
|
2769
|
-
} //
|
|
2770
|
-
// SubMenuItem
|
|
2771
|
-
//
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
function ArrowRightIcon() {
|
|
2775
|
-
return /*#__PURE__*/React.createElement("svg", {
|
|
2776
|
-
width: "24",
|
|
2777
|
-
height: "24"
|
|
2778
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
2779
|
-
d: "M14.243 12L9.646 7.404a.5.5 0 1 1 .708-.707l4.95 4.95a.5.5 0 0 1 0 .707l-4.95 4.95a.5.5 0 0 1-.708-.708L14.243 12z",
|
|
2780
|
-
fill: "currentColor",
|
|
2781
|
-
fillRule: "evenodd"
|
|
2782
|
-
}));
|
|
2783
|
-
}
|
|
2784
|
-
/**
|
|
2785
|
-
* A menu item to toggle a sub-menu open or closed.
|
|
2786
|
-
*/
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
const SubMenuItem = /*#__PURE__*/polymorphicComponent(function SubMenuItem(_ref3, ref) {
|
|
2790
|
-
let {
|
|
2791
|
-
exceptionallySetClassName,
|
|
2792
|
-
label,
|
|
2793
|
-
icon
|
|
2794
|
-
} = _ref3,
|
|
2795
|
-
props = _objectWithoutProperties(_ref3, _excluded3$2);
|
|
2796
|
-
|
|
2797
|
-
const id = useId(props.id);
|
|
2798
|
-
const {
|
|
2799
|
-
state
|
|
2800
|
-
} = React.useContext(MenuContext);
|
|
2801
|
-
return /*#__PURE__*/React.createElement(Ariakit.MenuButton, _objectSpread2(_objectSpread2({
|
|
2802
|
-
"aria-labelledby": label && !props['aria-label'] ? id + "-label" : undefined
|
|
2803
|
-
}, props), {}, {
|
|
2804
|
-
state: state,
|
|
2805
|
-
ref: ref,
|
|
2806
|
-
className: classNames(modules_2befbba6.menuItem, exceptionallySetClassName)
|
|
2807
|
-
}), /*#__PURE__*/React.createElement(MenuItemContent, {
|
|
2808
|
-
id: id,
|
|
2809
|
-
icon: icon,
|
|
2810
|
-
label: label,
|
|
2811
|
-
shortcut: /*#__PURE__*/React.createElement(ArrowRightIcon, null)
|
|
2665
|
+
className: classNames('reactist_menubutton', exceptionallySetClassName)
|
|
2812
2666
|
}));
|
|
2813
2667
|
}); //
|
|
2814
2668
|
// ContextMenuTrigger
|
|
2815
2669
|
//
|
|
2816
2670
|
|
|
2817
|
-
const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMenuTrigger(
|
|
2671
|
+
const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMenuTrigger(_ref3, ref) {
|
|
2818
2672
|
let {
|
|
2819
2673
|
as: component = 'div'
|
|
2820
|
-
} =
|
|
2821
|
-
props = _objectWithoutProperties(
|
|
2674
|
+
} = _ref3,
|
|
2675
|
+
props = _objectWithoutProperties(_ref3, _excluded3$2);
|
|
2822
2676
|
|
|
2823
2677
|
const {
|
|
2824
|
-
|
|
2825
|
-
|
|
2678
|
+
setAnchorRect,
|
|
2679
|
+
menuStore
|
|
2826
2680
|
} = React.useContext(MenuContext);
|
|
2827
|
-
const handleContextMenu = React.useCallback(event
|
|
2681
|
+
const handleContextMenu = React.useCallback(function handleContextMenu(event) {
|
|
2828
2682
|
event.preventDefault();
|
|
2829
|
-
|
|
2683
|
+
setAnchorRect({
|
|
2830
2684
|
x: event.clientX,
|
|
2831
2685
|
y: event.clientY
|
|
2832
2686
|
});
|
|
2833
|
-
|
|
2834
|
-
}, [
|
|
2687
|
+
menuStore.show();
|
|
2688
|
+
}, [setAnchorRect, menuStore]);
|
|
2835
2689
|
return /*#__PURE__*/React.createElement(component, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2836
2690
|
onContextMenu: handleContextMenu,
|
|
2837
2691
|
ref
|
|
@@ -2841,155 +2695,90 @@ const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMen
|
|
|
2841
2695
|
* The dropdown menu itself, containing a list of menu items.
|
|
2842
2696
|
*/
|
|
2843
2697
|
|
|
2844
|
-
const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(
|
|
2698
|
+
const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref4, ref) {
|
|
2845
2699
|
let {
|
|
2846
2700
|
exceptionallySetClassName,
|
|
2847
2701
|
modal = true
|
|
2848
|
-
} =
|
|
2849
|
-
props = _objectWithoutProperties(
|
|
2702
|
+
} = _ref4,
|
|
2703
|
+
props = _objectWithoutProperties(_ref4, _excluded4$1);
|
|
2850
2704
|
|
|
2851
2705
|
const {
|
|
2852
|
-
|
|
2706
|
+
menuStore,
|
|
2707
|
+
getAnchorRect
|
|
2853
2708
|
} = React.useContext(MenuContext);
|
|
2854
|
-
|
|
2855
|
-
return /*#__PURE__*/React.createElement(
|
|
2709
|
+
const isOpen = menuStore.useState('open');
|
|
2710
|
+
return isOpen ? /*#__PURE__*/React.createElement(react.Portal, {
|
|
2856
2711
|
preserveTabOrder: true
|
|
2857
|
-
}, /*#__PURE__*/React.createElement(
|
|
2858
|
-
|
|
2712
|
+
}, /*#__PURE__*/React.createElement(react.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2713
|
+
store: menuStore,
|
|
2714
|
+
gutter: 8,
|
|
2715
|
+
shift: 4,
|
|
2859
2716
|
ref: ref,
|
|
2860
|
-
className: classNames(
|
|
2717
|
+
className: classNames('reactist_menulist', exceptionallySetClassName),
|
|
2718
|
+
getAnchorRect: getAnchorRect != null ? getAnchorRect : undefined,
|
|
2861
2719
|
modal: modal
|
|
2862
|
-
})));
|
|
2720
|
+
}))) : null;
|
|
2863
2721
|
});
|
|
2864
2722
|
/**
|
|
2865
|
-
*
|
|
2723
|
+
* A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`
|
|
2724
|
+
* callback.
|
|
2866
2725
|
*/
|
|
2867
2726
|
|
|
2868
|
-
const
|
|
2727
|
+
const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref) {
|
|
2869
2728
|
let {
|
|
2729
|
+
value,
|
|
2730
|
+
children,
|
|
2731
|
+
onSelect,
|
|
2732
|
+
hideOnSelect = true,
|
|
2733
|
+
onClick,
|
|
2870
2734
|
exceptionallySetClassName,
|
|
2871
|
-
|
|
2872
|
-
} =
|
|
2873
|
-
props = _objectWithoutProperties(
|
|
2874
|
-
|
|
2875
|
-
const {
|
|
2876
|
-
state
|
|
2877
|
-
} = React.useContext(MenuContext);
|
|
2878
|
-
if (!state.open) return null;
|
|
2879
|
-
return /*#__PURE__*/React.createElement(portal.Portal, {
|
|
2880
|
-
preserveTabOrder: true
|
|
2881
|
-
}, /*#__PURE__*/React.createElement(Ariakit.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2882
|
-
state: state,
|
|
2883
|
-
ref: ref,
|
|
2884
|
-
className: classNames(modules_2befbba6.menuList, modules_2befbba6.subMenuList, exceptionallySetClassName),
|
|
2885
|
-
modal: modal
|
|
2886
|
-
})));
|
|
2887
|
-
}); //
|
|
2888
|
-
// MenuItem
|
|
2889
|
-
//
|
|
2735
|
+
as = 'button'
|
|
2736
|
+
} = _ref5,
|
|
2737
|
+
props = _objectWithoutProperties(_ref5, _excluded5$1);
|
|
2890
2738
|
|
|
2891
|
-
function useMenuItemClickHandler({
|
|
2892
|
-
value,
|
|
2893
|
-
hideOnSelect,
|
|
2894
|
-
onClick,
|
|
2895
|
-
onSelect
|
|
2896
|
-
}) {
|
|
2897
2739
|
const {
|
|
2898
2740
|
handleItemSelect,
|
|
2899
|
-
|
|
2741
|
+
menuStore
|
|
2900
2742
|
} = React.useContext(MenuContext);
|
|
2901
2743
|
const {
|
|
2902
2744
|
hide
|
|
2903
|
-
} =
|
|
2904
|
-
|
|
2745
|
+
} = menuStore;
|
|
2746
|
+
const handleClick = React.useCallback(function handleClick(event) {
|
|
2905
2747
|
onClick == null ? void 0 : onClick(event);
|
|
2906
2748
|
const onSelectResult = onSelect && !event.defaultPrevented ? onSelect() : undefined;
|
|
2907
2749
|
const shouldClose = onSelectResult !== false && hideOnSelect;
|
|
2908
2750
|
handleItemSelect(value);
|
|
2909
2751
|
if (shouldClose) hide();
|
|
2910
2752
|
}, [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value]);
|
|
2911
|
-
}
|
|
2912
|
-
/**
|
|
2913
|
-
* A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`
|
|
2914
|
-
* callback.
|
|
2915
|
-
*/
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref7, ref) {
|
|
2919
|
-
let {
|
|
2920
|
-
value,
|
|
2921
|
-
label,
|
|
2922
|
-
description,
|
|
2923
|
-
icon,
|
|
2924
|
-
shortcut,
|
|
2925
|
-
tone,
|
|
2926
|
-
children,
|
|
2927
|
-
onSelect,
|
|
2928
|
-
hideOnSelect = true,
|
|
2929
|
-
onClick,
|
|
2930
|
-
exceptionallySetClassName,
|
|
2931
|
-
as = 'button'
|
|
2932
|
-
} = _ref7,
|
|
2933
|
-
props = _objectWithoutProperties(_ref7, _excluded7);
|
|
2934
|
-
|
|
2935
|
-
const id = useId(props.id);
|
|
2936
|
-
const {
|
|
2937
|
-
state
|
|
2938
|
-
} = React.useContext(MenuContext);
|
|
2939
|
-
const handleClick = useMenuItemClickHandler({
|
|
2940
|
-
value,
|
|
2941
|
-
onSelect,
|
|
2942
|
-
onClick,
|
|
2943
|
-
hideOnSelect
|
|
2944
|
-
});
|
|
2945
|
-
return /*#__PURE__*/React.createElement(Ariakit.MenuItem, _objectSpread2(_objectSpread2({
|
|
2946
|
-
"aria-labelledby": label && !props['aria-label'] ? id + "-label" : undefined,
|
|
2947
|
-
"aria-describedby": label && description ? id + "-description" : undefined
|
|
2948
|
-
}, props), {}, {
|
|
2753
|
+
return /*#__PURE__*/React.createElement(react.MenuItem, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2949
2754
|
as: as,
|
|
2950
|
-
|
|
2755
|
+
store: menuStore,
|
|
2951
2756
|
ref: ref,
|
|
2952
2757
|
onClick: handleClick,
|
|
2953
|
-
className:
|
|
2758
|
+
className: exceptionallySetClassName,
|
|
2954
2759
|
hideOnClick: false
|
|
2955
|
-
}), children
|
|
2956
|
-
width: "full",
|
|
2957
|
-
className: label ? undefined : modules_2befbba6.legacyLayout
|
|
2958
|
-
}, children) : null, /*#__PURE__*/React.createElement(MenuItemContent, {
|
|
2959
|
-
id: id,
|
|
2960
|
-
icon: icon,
|
|
2961
|
-
label: label,
|
|
2962
|
-
description: description,
|
|
2963
|
-
shortcut: shortcut
|
|
2964
|
-
}));
|
|
2760
|
+
}), children);
|
|
2965
2761
|
});
|
|
2966
2762
|
/**
|
|
2967
|
-
* This component can be rendered alongside other `MenuItem`
|
|
2968
|
-
* sub-menu.
|
|
2763
|
+
* This component can be rendered alongside other `MenuItem` inside a `MenuList` in order to have
|
|
2764
|
+
* a sub-menu.
|
|
2969
2765
|
*
|
|
2970
|
-
* Its children are expected to
|
|
2971
|
-
*
|
|
2972
|
-
* 1. A `SubMenuItem` element: the menu item that triggers the sub-menu to open.
|
|
2973
|
-
* 2. A `SubMenuList` element: the list of menu items that will be shown when the sub-menu is open.
|
|
2974
|
-
*
|
|
2975
|
-
* ## Usage
|
|
2766
|
+
* Its children are expected to have the structure of a first level menu (a `MenuButton` and a
|
|
2767
|
+
* `MenuList`).
|
|
2976
2768
|
*
|
|
2977
2769
|
* ```jsx
|
|
2978
|
-
* <
|
|
2979
|
-
*
|
|
2770
|
+
* <MenuItem label="Edit profile" />
|
|
2771
|
+
* <SubMenu>
|
|
2772
|
+
* <MenuButton>More options</MenuButton>
|
|
2980
2773
|
* <MenuList>
|
|
2981
|
-
* <MenuItem label="
|
|
2982
|
-
* <MenuItem label="
|
|
2983
|
-
* <SubMenu>
|
|
2984
|
-
* <SubMenuItem label="Submenu" />
|
|
2985
|
-
* <SubMenuList>
|
|
2986
|
-
* <MenuItem label="Submenu Item 1" />
|
|
2987
|
-
* <MenuItem label="Submenu Item 2" />
|
|
2988
|
-
* </SubMenuList>
|
|
2989
|
-
* </SubMenu>
|
|
2774
|
+
* <MenuItem label="Preferences" />
|
|
2775
|
+
* <MenuItem label="Sign out" />
|
|
2990
2776
|
* </MenuList>
|
|
2991
|
-
* </
|
|
2777
|
+
* </SubMenu>
|
|
2992
2778
|
* ```
|
|
2779
|
+
*
|
|
2780
|
+
* The `MenuButton` will become a menu item in the current menu items list, and it will lead to
|
|
2781
|
+
* opening a sub-menu with the menu items list below it.
|
|
2993
2782
|
*/
|
|
2994
2783
|
|
|
2995
2784
|
const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
|
|
@@ -2998,11 +2787,11 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
|
|
|
2998
2787
|
}, ref) {
|
|
2999
2788
|
const {
|
|
3000
2789
|
handleItemSelect: parentMenuItemSelect,
|
|
3001
|
-
|
|
2790
|
+
menuStore
|
|
3002
2791
|
} = React.useContext(MenuContext);
|
|
3003
2792
|
const {
|
|
3004
2793
|
hide: parentMenuHide
|
|
3005
|
-
} =
|
|
2794
|
+
} = menuStore;
|
|
3006
2795
|
const handleSubItemSelect = React.useCallback(function handleSubItemSelect(value) {
|
|
3007
2796
|
if (onItemSelect) onItemSelect(value);
|
|
3008
2797
|
parentMenuItemSelect(value);
|
|
@@ -3016,14 +2805,12 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
|
|
|
3016
2805
|
}, [button]);
|
|
3017
2806
|
return /*#__PURE__*/React.createElement(Menu, {
|
|
3018
2807
|
onItemSelect: handleSubItemSelect
|
|
3019
|
-
}, /*#__PURE__*/React.createElement(
|
|
2808
|
+
}, /*#__PURE__*/React.createElement(react.MenuItem, {
|
|
3020
2809
|
as: "div",
|
|
3021
|
-
|
|
2810
|
+
store: menuStore,
|
|
3022
2811
|
ref: ref,
|
|
3023
2812
|
hideOnClick: false
|
|
3024
|
-
}, renderMenuButton),
|
|
3025
|
-
className: modules_2befbba6.subMenuContainer
|
|
3026
|
-
}, list));
|
|
2813
|
+
}, renderMenuButton), list);
|
|
3027
2814
|
});
|
|
3028
2815
|
/**
|
|
3029
2816
|
* A way to semantically group some menu items.
|
|
@@ -3032,100 +2819,25 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
|
|
|
3032
2819
|
* before and/or after the group if you so wish.
|
|
3033
2820
|
*/
|
|
3034
2821
|
|
|
3035
|
-
const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(
|
|
2822
|
+
const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(_ref6, ref) {
|
|
3036
2823
|
let {
|
|
3037
2824
|
label,
|
|
3038
|
-
info,
|
|
3039
2825
|
children,
|
|
3040
2826
|
exceptionallySetClassName
|
|
3041
|
-
} =
|
|
3042
|
-
props = _objectWithoutProperties(
|
|
2827
|
+
} = _ref6,
|
|
2828
|
+
props = _objectWithoutProperties(_ref6, _excluded6);
|
|
3043
2829
|
|
|
3044
|
-
const id = useId(props.id);
|
|
3045
2830
|
const {
|
|
3046
|
-
|
|
2831
|
+
menuStore
|
|
3047
2832
|
} = React.useContext(MenuContext);
|
|
3048
|
-
return /*#__PURE__*/React.createElement(
|
|
3049
|
-
"aria-labelledby": "menugroup-label-" + id
|
|
3050
|
-
}, props), {}, {
|
|
3051
|
-
id: id,
|
|
2833
|
+
return /*#__PURE__*/React.createElement(react.MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
3052
2834
|
ref: ref,
|
|
3053
|
-
|
|
2835
|
+
store: menuStore,
|
|
3054
2836
|
className: exceptionallySetClassName
|
|
3055
|
-
}), /*#__PURE__*/React.createElement(
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
className: modules_2befbba6.menuGroupLabel
|
|
3060
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
3061
|
-
id: "menugroup-label-" + id,
|
|
3062
|
-
size: "copy",
|
|
3063
|
-
weight: "semibold"
|
|
3064
|
-
}, label), info ? /*#__PURE__*/React.createElement(Box, {
|
|
3065
|
-
flexShrink: 0,
|
|
3066
|
-
display: "flex",
|
|
3067
|
-
alignItems: "center",
|
|
3068
|
-
justifyContent: "center",
|
|
3069
|
-
className: modules_2befbba6.menuGroupInfo
|
|
3070
|
-
}, info) : null), children);
|
|
3071
|
-
});
|
|
3072
|
-
/**
|
|
3073
|
-
* A menu item that visually only shows as an icon. It must be used inside an `IconsMenuGroup`.
|
|
3074
|
-
*/
|
|
3075
|
-
|
|
3076
|
-
const IconMenuItem = /*#__PURE__*/polymorphicComponent(function IconMenuItem(_ref9, ref) {
|
|
3077
|
-
let {
|
|
3078
|
-
value,
|
|
3079
|
-
label,
|
|
3080
|
-
description,
|
|
3081
|
-
icon,
|
|
3082
|
-
onSelect,
|
|
3083
|
-
hideOnSelect = true,
|
|
3084
|
-
onClick,
|
|
3085
|
-
exceptionallySetClassName,
|
|
3086
|
-
as = 'button'
|
|
3087
|
-
} = _ref9,
|
|
3088
|
-
props = _objectWithoutProperties(_ref9, _excluded9);
|
|
3089
|
-
|
|
3090
|
-
const id = useId(props.id);
|
|
3091
|
-
const {
|
|
3092
|
-
state
|
|
3093
|
-
} = React.useContext(MenuContext);
|
|
3094
|
-
const handleClick = useMenuItemClickHandler({
|
|
3095
|
-
value,
|
|
3096
|
-
onSelect,
|
|
3097
|
-
onClick,
|
|
3098
|
-
hideOnSelect
|
|
3099
|
-
});
|
|
3100
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
3101
|
-
content: label
|
|
3102
|
-
}, /*#__PURE__*/React.createElement(Ariakit.MenuItem, _objectSpread2(_objectSpread2({
|
|
3103
|
-
"aria-label": label,
|
|
3104
|
-
"aria-describedby": id + "-description"
|
|
3105
|
-
}, props), {}, {
|
|
3106
|
-
as: as,
|
|
3107
|
-
state: state,
|
|
3108
|
-
ref: ref,
|
|
3109
|
-
onClick: handleClick,
|
|
3110
|
-
className: classNames(modules_2befbba6.iconMenuItem, exceptionallySetClassName),
|
|
3111
|
-
hideOnClick: false
|
|
3112
|
-
}), icon));
|
|
3113
|
-
});
|
|
3114
|
-
/**
|
|
3115
|
-
* Semantically equivalent to `MenuGroup`, but meant to group `IconMenuItem`s only.
|
|
3116
|
-
*/
|
|
3117
|
-
|
|
3118
|
-
const IconsMenuGroup = /*#__PURE__*/polymorphicComponent(function IconsMenuGroup(_ref10, ref) {
|
|
3119
|
-
let {
|
|
3120
|
-
children
|
|
3121
|
-
} = _ref10,
|
|
3122
|
-
props = _objectWithoutProperties(_ref10, _excluded10);
|
|
3123
|
-
|
|
3124
|
-
return /*#__PURE__*/React.createElement(MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
3125
|
-
ref: ref
|
|
3126
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
3127
|
-
className: modules_2befbba6.iconsMenuGroup
|
|
3128
|
-
}, children));
|
|
2837
|
+
}), label ? /*#__PURE__*/React.createElement("div", {
|
|
2838
|
+
role: "presentation",
|
|
2839
|
+
className: "reactist_menugroup__label"
|
|
2840
|
+
}, label) : null, children);
|
|
3129
2841
|
});
|
|
3130
2842
|
|
|
3131
2843
|
const _excluded$u = ["type", "variant", "size", "loading", "disabled", "tooltip", "onClick", "children"];
|
|
@@ -4022,7 +3734,7 @@ function DeprecatedModal(_ref) {
|
|
|
4022
3734
|
onDismiss,
|
|
4023
3735
|
height
|
|
4024
3736
|
}), [onDismiss, height]);
|
|
4025
|
-
return /*#__PURE__*/React.createElement(dialog
|
|
3737
|
+
return /*#__PURE__*/React.createElement(dialog.DialogOverlay, {
|
|
4026
3738
|
isOpen: isOpen,
|
|
4027
3739
|
onDismiss: onDismiss,
|
|
4028
3740
|
dangerouslyBypassFocusLock // We're setting up our own focus lock below
|
|
@@ -4033,7 +3745,7 @@ function DeprecatedModal(_ref) {
|
|
|
4033
3745
|
autoFocus: autoFocus,
|
|
4034
3746
|
whiteList: isNotInternalFrame$1,
|
|
4035
3747
|
returnFocus: true
|
|
4036
|
-
}, /*#__PURE__*/React.createElement(dialog
|
|
3748
|
+
}, /*#__PURE__*/React.createElement(dialog.DialogContent, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
4037
3749
|
as: Box,
|
|
4038
3750
|
borderRadius: "full",
|
|
4039
3751
|
background: "default",
|
|
@@ -4212,8 +3924,6 @@ exports.Divider = Divider;
|
|
|
4212
3924
|
exports.Heading = Heading;
|
|
4213
3925
|
exports.Hidden = Hidden;
|
|
4214
3926
|
exports.HiddenVisually = HiddenVisually;
|
|
4215
|
-
exports.IconMenuItem = IconMenuItem;
|
|
4216
|
-
exports.IconsMenuGroup = IconsMenuGroup;
|
|
4217
3927
|
exports.Inline = Inline;
|
|
4218
3928
|
exports.KeyCapturer = KeyCapturer;
|
|
4219
3929
|
exports.KeyboardShortcut = KeyboardShortcut;
|
|
@@ -4238,8 +3948,6 @@ exports.SelectField = SelectField;
|
|
|
4238
3948
|
exports.Stack = Stack;
|
|
4239
3949
|
exports.StaticToast = StaticToast;
|
|
4240
3950
|
exports.SubMenu = SubMenu;
|
|
4241
|
-
exports.SubMenuItem = SubMenuItem;
|
|
4242
|
-
exports.SubMenuList = SubMenuList;
|
|
4243
3951
|
exports.SwitchField = SwitchField;
|
|
4244
3952
|
exports.Tab = Tab;
|
|
4245
3953
|
exports.TabAwareSlot = TabAwareSlot;
|