@doist/reactist 18.0.0 → 19.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/reactist.cjs.development.js +275 -266
- 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/index.js +1 -1
- package/es/new-components/badge/badge.js +12 -12
- package/es/new-components/badge/badge.js.map +1 -1
- package/es/new-components/badge/badge.module.css.js +1 -1
- package/es/new-components/checkbox-field/checkbox-field.js +1 -1
- package/es/new-components/checkbox-field/checkbox-field.js.map +1 -1
- package/es/{components → new-components}/menu/menu.js +7 -6
- package/es/new-components/menu/menu.js.map +1 -0
- package/es/new-components/modal/modal.js +4 -6
- package/es/new-components/modal/modal.js.map +1 -1
- package/es/new-components/password-field/password-field.js +1 -1
- package/es/new-components/password-field/password-field.js.map +1 -1
- package/es/new-components/tooltip/tooltip.js +12 -3
- package/es/new-components/tooltip/tooltip.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/new-components/badge/badge.d.ts +11 -2
- package/lib/new-components/badge/badge.js +1 -1
- package/lib/new-components/badge/badge.js.map +1 -1
- package/lib/new-components/badge/badge.module.css.js +1 -1
- package/lib/{components/menu/menu.test.d.ts → new-components/badge/badge.test.d.ts} +0 -0
- package/lib/new-components/checkbox-field/checkbox-field.js +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.js.map +1 -1
- package/lib/{components → new-components}/menu/index.d.ts +0 -0
- package/lib/{components → new-components}/menu/menu.d.ts +1 -2
- package/lib/new-components/menu/menu.js +2 -0
- package/lib/new-components/menu/menu.js.map +1 -0
- package/lib/new-components/menu/menu.test.d.ts +1 -0
- package/lib/new-components/modal/modal.js +1 -1
- package/lib/new-components/modal/modal.js.map +1 -1
- package/lib/new-components/password-field/password-field.js +1 -1
- package/lib/new-components/password-field/password-field.js.map +1 -1
- package/lib/new-components/tooltip/tooltip.js +1 -1
- package/lib/new-components/tooltip/tooltip.js.map +1 -1
- package/package.json +4 -3
- package/styles/badge.css +1 -1
- package/styles/badge.module.css.css +1 -1
- package/styles/menu.css +1 -1
- package/styles/reactist.css +2 -2
- package/es/components/menu/menu.js.map +0 -1
- package/lib/components/menu/menu.js +0 -2
- package/lib/components/menu/menu.js.map +0 -1
|
@@ -10,16 +10,16 @@ var classNames = _interopDefault(require('classnames'));
|
|
|
10
10
|
var flattenChildren = _interopDefault(require('react-keyed-flatten-children'));
|
|
11
11
|
var tooltip = require('ariakit/tooltip');
|
|
12
12
|
var portal = require('ariakit/portal');
|
|
13
|
-
var
|
|
13
|
+
var ariakitReactUtils = require('ariakit-react-utils');
|
|
14
14
|
var useCallbackRef = require('use-callback-ref');
|
|
15
15
|
var FocusLock = _interopDefault(require('react-focus-lock'));
|
|
16
16
|
var ariaHidden = require('aria-hidden');
|
|
17
17
|
var dialog = require('ariakit/dialog');
|
|
18
18
|
var tab = require('ariakit/tab');
|
|
19
|
+
var Ariakit = require('ariakit/menu');
|
|
19
20
|
var ReactDOM = _interopDefault(require('react-dom'));
|
|
20
21
|
var dayjs = _interopDefault(require('dayjs'));
|
|
21
22
|
var LocalizedFormat = _interopDefault(require('dayjs/plugin/localizedFormat'));
|
|
22
|
-
var Ariakit = require('ariakit/menu');
|
|
23
23
|
var dialog$1 = require('@reach/dialog');
|
|
24
24
|
|
|
25
25
|
function ownKeys(object, enumerableOnly) {
|
|
@@ -520,17 +520,26 @@ function Tooltip({
|
|
|
520
520
|
child == null ? void 0 : (_child$props = child.props) == null ? void 0 : _child$props.onFocus == null ? void 0 : _child$props.onFocus(event);
|
|
521
521
|
}
|
|
522
522
|
|
|
523
|
+
function handleBlur(event) {
|
|
524
|
+
var _child$props2;
|
|
525
|
+
|
|
526
|
+
state.hide();
|
|
527
|
+
child == null ? void 0 : (_child$props2 = child.props) == null ? void 0 : _child$props2.onBlur == null ? void 0 : _child$props2.onBlur(event);
|
|
528
|
+
}
|
|
529
|
+
|
|
523
530
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(tooltip.TooltipAnchor, {
|
|
524
531
|
state: state,
|
|
525
532
|
ref: child.ref,
|
|
526
|
-
onFocus: handleFocus,
|
|
527
533
|
described: true
|
|
528
534
|
}, anchorProps => {
|
|
529
535
|
// Let child props override anchor props so user can specify attributes like tabIndex
|
|
530
536
|
// Also, do not apply the child's props to TooltipAnchor as props like `as` can create problems
|
|
531
537
|
// by applying the replacement component/element twice
|
|
532
|
-
return /*#__PURE__*/React.cloneElement(child, _objectSpread2(_objectSpread2({}, anchorProps), child.props)
|
|
533
|
-
|
|
538
|
+
return /*#__PURE__*/React.cloneElement(child, _objectSpread2(_objectSpread2(_objectSpread2({}, anchorProps), child.props), {}, {
|
|
539
|
+
onFocus: handleFocus,
|
|
540
|
+
onBlur: handleBlur
|
|
541
|
+
}));
|
|
542
|
+
}), state.open ? /*#__PURE__*/React.createElement(Box, {
|
|
534
543
|
as: tooltip.Tooltip,
|
|
535
544
|
state: state,
|
|
536
545
|
className: [modules_95f1407a.tooltip, exceptionallySetClassName],
|
|
@@ -1530,7 +1539,7 @@ const CheckboxField = /*#__PURE__*/React.forwardRef(function CheckboxField(_ref,
|
|
|
1530
1539
|
const [checkedState, setChecked] = React.useState((_ref2 = (_props$checked = props.checked) != null ? _props$checked : defaultChecked) != null ? _ref2 : false);
|
|
1531
1540
|
const isChecked = (_props$checked2 = props.checked) != null ? _props$checked2 : checkedState;
|
|
1532
1541
|
const internalRef = React.useRef(null);
|
|
1533
|
-
const combinedRef =
|
|
1542
|
+
const combinedRef = ariakitReactUtils.useForkRef(internalRef, ref);
|
|
1534
1543
|
React.useEffect(function setIndeterminate() {
|
|
1535
1544
|
if (internalRef.current && typeof indeterminate === 'boolean') {
|
|
1536
1545
|
internalRef.current.indeterminate = indeterminate;
|
|
@@ -1745,7 +1754,7 @@ const PasswordField = /*#__PURE__*/React.forwardRef(function PasswordField(_ref,
|
|
|
1745
1754
|
|
|
1746
1755
|
const id = useId(props.id);
|
|
1747
1756
|
const internalRef = React.useRef(null);
|
|
1748
|
-
const inputRef =
|
|
1757
|
+
const inputRef = ariakitReactUtils.useForkRef(internalRef, ref);
|
|
1749
1758
|
const [isPasswordVisible, setPasswordVisible] = React.useState(false);
|
|
1750
1759
|
|
|
1751
1760
|
function togglePasswordVisibility() {
|
|
@@ -2099,23 +2108,24 @@ function Avatar(_ref) {
|
|
|
2099
2108
|
|
|
2100
2109
|
Avatar.displayName = 'Avatar';
|
|
2101
2110
|
|
|
2102
|
-
var modules_33c7c985 = {"badge":"
|
|
2111
|
+
var modules_33c7c985 = {"badge":"c717b894","badge-info":"_0fddcc47","badge-positive":"_62550d9b","badge-promote":"_5fdf5bab","badge-attention":"_2d52906f"};
|
|
2103
2112
|
|
|
2104
|
-
const _excluded$o = ["
|
|
2105
|
-
|
|
2113
|
+
const _excluded$o = ["tone", "label"];
|
|
2114
|
+
|
|
2115
|
+
function Badge(_ref) {
|
|
2106
2116
|
let {
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
exceptionallySetClassName
|
|
2117
|
+
tone,
|
|
2118
|
+
label
|
|
2110
2119
|
} = _ref,
|
|
2111
|
-
|
|
2120
|
+
props = _objectWithoutProperties(_ref, _excluded$o);
|
|
2112
2121
|
|
|
2113
|
-
return /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({},
|
|
2114
|
-
|
|
2122
|
+
return /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2123
|
+
as: "span" // It enables putting the badge inside a button (https://stackoverflow.com/a/12982334)
|
|
2124
|
+
,
|
|
2115
2125
|
display: "inline",
|
|
2116
|
-
className: [modules_33c7c985.badge, modules_33c7c985["badge-" +
|
|
2117
|
-
}),
|
|
2118
|
-
}
|
|
2126
|
+
className: [modules_33c7c985.badge, modules_33c7c985["badge-" + tone]]
|
|
2127
|
+
}), label);
|
|
2128
|
+
}
|
|
2119
2129
|
|
|
2120
2130
|
var modules_8f59d13b = {"overlay":"_868392ae","fadein":"_63d7ee15","fitContent":"b8548bf2","container":"_31956461","full":"_1007df83","large":"_10c275aa","medium":"_0ac526b4","small":"_30f38fdb","xlarge":"_54868e8b","expand":"c0bc68bc","buttonContainer":"_6527332a","headerContent":"_4750dc1b"};
|
|
2121
2131
|
|
|
@@ -2159,14 +2169,14 @@ function Modal(_ref) {
|
|
|
2159
2169
|
} = _ref,
|
|
2160
2170
|
props = _objectWithoutProperties(_ref, _excluded$p);
|
|
2161
2171
|
|
|
2162
|
-
const
|
|
2172
|
+
const setOpen = React.useCallback(visible => {
|
|
2163
2173
|
if (!visible) {
|
|
2164
2174
|
onDismiss == null ? void 0 : onDismiss();
|
|
2165
2175
|
}
|
|
2166
2176
|
}, [onDismiss]);
|
|
2167
2177
|
const state = dialog.useDialogState({
|
|
2168
|
-
|
|
2169
|
-
|
|
2178
|
+
open: isOpen,
|
|
2179
|
+
setOpen
|
|
2170
2180
|
});
|
|
2171
2181
|
const contextValue = React.useMemo(() => ({
|
|
2172
2182
|
onDismiss,
|
|
@@ -2198,9 +2208,7 @@ function Modal(_ref) {
|
|
|
2198
2208
|
return null;
|
|
2199
2209
|
}
|
|
2200
2210
|
|
|
2201
|
-
return /*#__PURE__*/React.createElement(portal.Portal
|
|
2202
|
-
, {
|
|
2203
|
-
// @ts-expect-error `portalRef` doesn't accept MutableRefObject initialized as null
|
|
2211
|
+
return /*#__PURE__*/React.createElement(portal.Portal, {
|
|
2204
2212
|
portalRef: portalRef,
|
|
2205
2213
|
portalElement: portalElement
|
|
2206
2214
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
@@ -2569,7 +2577,243 @@ function TabAwareSlot({
|
|
|
2569
2577
|
}) : null;
|
|
2570
2578
|
}
|
|
2571
2579
|
|
|
2572
|
-
const _excluded$r = ["
|
|
2580
|
+
const _excluded$r = ["children", "onItemSelect"],
|
|
2581
|
+
_excluded2$3 = ["exceptionallySetClassName"],
|
|
2582
|
+
_excluded3$2 = ["as"],
|
|
2583
|
+
_excluded4$1 = ["exceptionallySetClassName", "modal"],
|
|
2584
|
+
_excluded5$1 = ["value", "children", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName", "as"],
|
|
2585
|
+
_excluded6 = ["label", "children", "exceptionallySetClassName"];
|
|
2586
|
+
const MenuContext = /*#__PURE__*/React.createContext( // Ariakit gives us no means to obtain a valid initial/default value of type MenuStateReturn
|
|
2587
|
+
// (it is normally obtained by calling useMenuState but we can't call hooks outside components).
|
|
2588
|
+
// This is however of little consequence since this value is only used if some of the components
|
|
2589
|
+
// are used outside Menu, something that should not happen and we do not support.
|
|
2590
|
+
// @ts-expect-error
|
|
2591
|
+
{});
|
|
2592
|
+
/**
|
|
2593
|
+
* Wrapper component to control a menu. It does not render anything, only providing the state
|
|
2594
|
+
* management for the menu components inside it.
|
|
2595
|
+
*/
|
|
2596
|
+
|
|
2597
|
+
function Menu(_ref) {
|
|
2598
|
+
let {
|
|
2599
|
+
children,
|
|
2600
|
+
onItemSelect
|
|
2601
|
+
} = _ref,
|
|
2602
|
+
props = _objectWithoutProperties(_ref, _excluded$r);
|
|
2603
|
+
|
|
2604
|
+
const [anchorRect, handleAnchorRectChange] = React.useState(null);
|
|
2605
|
+
const getAnchorRect = React.useMemo(() => {
|
|
2606
|
+
return anchorRect ? () => anchorRect : undefined;
|
|
2607
|
+
}, [anchorRect]);
|
|
2608
|
+
const state = Ariakit.useMenuState(_objectSpread2({
|
|
2609
|
+
focusLoop: true,
|
|
2610
|
+
gutter: 8,
|
|
2611
|
+
shift: 4,
|
|
2612
|
+
getAnchorRect
|
|
2613
|
+
}, props));
|
|
2614
|
+
const handleItemSelect = React.useCallback(function handleItemSelect(value) {
|
|
2615
|
+
if (onItemSelect) onItemSelect(value);
|
|
2616
|
+
}, [onItemSelect]);
|
|
2617
|
+
const value = React.useMemo(() => ({
|
|
2618
|
+
state,
|
|
2619
|
+
handleItemSelect,
|
|
2620
|
+
handleAnchorRectChange
|
|
2621
|
+
}), [state, handleItemSelect]);
|
|
2622
|
+
return /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
2623
|
+
value: value
|
|
2624
|
+
}, children);
|
|
2625
|
+
}
|
|
2626
|
+
/**
|
|
2627
|
+
* A button to toggle a dropdown menu open or closed.
|
|
2628
|
+
*/
|
|
2629
|
+
|
|
2630
|
+
|
|
2631
|
+
const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2, ref) {
|
|
2632
|
+
let {
|
|
2633
|
+
exceptionallySetClassName
|
|
2634
|
+
} = _ref2,
|
|
2635
|
+
props = _objectWithoutProperties(_ref2, _excluded2$3);
|
|
2636
|
+
|
|
2637
|
+
const {
|
|
2638
|
+
state
|
|
2639
|
+
} = React.useContext(MenuContext);
|
|
2640
|
+
return /*#__PURE__*/React.createElement(Ariakit.MenuButton, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2641
|
+
state: state,
|
|
2642
|
+
ref: ref,
|
|
2643
|
+
className: classNames('reactist_menubutton', exceptionallySetClassName)
|
|
2644
|
+
}));
|
|
2645
|
+
}); //
|
|
2646
|
+
// ContextMenuTrigger
|
|
2647
|
+
//
|
|
2648
|
+
|
|
2649
|
+
const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMenuTrigger(_ref3, ref) {
|
|
2650
|
+
let {
|
|
2651
|
+
as: component = 'div'
|
|
2652
|
+
} = _ref3,
|
|
2653
|
+
props = _objectWithoutProperties(_ref3, _excluded3$2);
|
|
2654
|
+
|
|
2655
|
+
const {
|
|
2656
|
+
handleAnchorRectChange,
|
|
2657
|
+
state
|
|
2658
|
+
} = React.useContext(MenuContext);
|
|
2659
|
+
const handleContextMenu = React.useCallback(event => {
|
|
2660
|
+
event.preventDefault();
|
|
2661
|
+
handleAnchorRectChange({
|
|
2662
|
+
x: event.clientX,
|
|
2663
|
+
y: event.clientY
|
|
2664
|
+
});
|
|
2665
|
+
state.show();
|
|
2666
|
+
}, [handleAnchorRectChange, state]);
|
|
2667
|
+
return /*#__PURE__*/React.createElement(component, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2668
|
+
onContextMenu: handleContextMenu,
|
|
2669
|
+
ref
|
|
2670
|
+
}));
|
|
2671
|
+
});
|
|
2672
|
+
/**
|
|
2673
|
+
* The dropdown menu itself, containing a list of menu items.
|
|
2674
|
+
*/
|
|
2675
|
+
|
|
2676
|
+
const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref4, ref) {
|
|
2677
|
+
let {
|
|
2678
|
+
exceptionallySetClassName,
|
|
2679
|
+
modal = true
|
|
2680
|
+
} = _ref4,
|
|
2681
|
+
props = _objectWithoutProperties(_ref4, _excluded4$1);
|
|
2682
|
+
|
|
2683
|
+
const {
|
|
2684
|
+
state
|
|
2685
|
+
} = React.useContext(MenuContext);
|
|
2686
|
+
return state.open ? /*#__PURE__*/React.createElement(portal.Portal, {
|
|
2687
|
+
preserveTabOrder: true
|
|
2688
|
+
}, /*#__PURE__*/React.createElement(Ariakit.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2689
|
+
state: state,
|
|
2690
|
+
ref: ref,
|
|
2691
|
+
className: classNames('reactist_menulist', exceptionallySetClassName),
|
|
2692
|
+
modal: modal
|
|
2693
|
+
}))) : null;
|
|
2694
|
+
});
|
|
2695
|
+
/**
|
|
2696
|
+
* A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`
|
|
2697
|
+
* callback.
|
|
2698
|
+
*/
|
|
2699
|
+
|
|
2700
|
+
const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref) {
|
|
2701
|
+
let {
|
|
2702
|
+
value,
|
|
2703
|
+
children,
|
|
2704
|
+
onSelect,
|
|
2705
|
+
hideOnSelect = true,
|
|
2706
|
+
onClick,
|
|
2707
|
+
exceptionallySetClassName,
|
|
2708
|
+
as = 'button'
|
|
2709
|
+
} = _ref5,
|
|
2710
|
+
props = _objectWithoutProperties(_ref5, _excluded5$1);
|
|
2711
|
+
|
|
2712
|
+
const {
|
|
2713
|
+
handleItemSelect,
|
|
2714
|
+
state
|
|
2715
|
+
} = React.useContext(MenuContext);
|
|
2716
|
+
const {
|
|
2717
|
+
hide
|
|
2718
|
+
} = state;
|
|
2719
|
+
const handleClick = React.useCallback(function handleClick(event) {
|
|
2720
|
+
onClick == null ? void 0 : onClick(event);
|
|
2721
|
+
const onSelectResult = onSelect && !event.defaultPrevented ? onSelect() : undefined;
|
|
2722
|
+
const shouldClose = onSelectResult !== false && hideOnSelect;
|
|
2723
|
+
handleItemSelect(value);
|
|
2724
|
+
if (shouldClose) hide();
|
|
2725
|
+
}, [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value]);
|
|
2726
|
+
return /*#__PURE__*/React.createElement(Ariakit.MenuItem, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2727
|
+
as: as,
|
|
2728
|
+
state: state,
|
|
2729
|
+
ref: ref,
|
|
2730
|
+
onClick: handleClick,
|
|
2731
|
+
className: exceptionallySetClassName,
|
|
2732
|
+
hideOnClick: false
|
|
2733
|
+
}), children);
|
|
2734
|
+
});
|
|
2735
|
+
/**
|
|
2736
|
+
* This component can be rendered alongside other `MenuItem` inside a `MenuList` in order to have
|
|
2737
|
+
* a sub-menu.
|
|
2738
|
+
*
|
|
2739
|
+
* Its children are expected to have the structure of a first level menu (a `MenuButton` and a
|
|
2740
|
+
* `MenuList`).
|
|
2741
|
+
*
|
|
2742
|
+
* ```jsx
|
|
2743
|
+
* <MenuItem label="Edit profile" />
|
|
2744
|
+
* <SubMenu>
|
|
2745
|
+
* <MenuButton>More options</MenuButton>
|
|
2746
|
+
* <MenuList>
|
|
2747
|
+
* <MenuItem label="Preferences" />
|
|
2748
|
+
* <MenuItem label="Sign out" />
|
|
2749
|
+
* </MenuList>
|
|
2750
|
+
* </SubMenu>
|
|
2751
|
+
* ```
|
|
2752
|
+
*
|
|
2753
|
+
* The `MenuButton` will become a menu item in the current menu items list, and it will lead to
|
|
2754
|
+
* opening a sub-menu with the menu items list below it.
|
|
2755
|
+
*/
|
|
2756
|
+
|
|
2757
|
+
const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
|
|
2758
|
+
children,
|
|
2759
|
+
onItemSelect
|
|
2760
|
+
}, ref) {
|
|
2761
|
+
const {
|
|
2762
|
+
handleItemSelect: parentMenuItemSelect,
|
|
2763
|
+
state
|
|
2764
|
+
} = React.useContext(MenuContext);
|
|
2765
|
+
const {
|
|
2766
|
+
hide: parentMenuHide
|
|
2767
|
+
} = state;
|
|
2768
|
+
const handleSubItemSelect = React.useCallback(function handleSubItemSelect(value) {
|
|
2769
|
+
if (onItemSelect) onItemSelect(value);
|
|
2770
|
+
parentMenuItemSelect(value);
|
|
2771
|
+
parentMenuHide();
|
|
2772
|
+
}, [parentMenuHide, parentMenuItemSelect, onItemSelect]);
|
|
2773
|
+
const [button, list] = React.Children.toArray(children); // Ariakit needs to be able to pass props to the MenuButton
|
|
2774
|
+
// and combine it with the MenuItem component
|
|
2775
|
+
|
|
2776
|
+
const renderMenuButton = React.useCallback(function renderMenuButton(props) {
|
|
2777
|
+
return /*#__PURE__*/React.cloneElement(button, props);
|
|
2778
|
+
}, [button]);
|
|
2779
|
+
return /*#__PURE__*/React.createElement(Menu, {
|
|
2780
|
+
onItemSelect: handleSubItemSelect
|
|
2781
|
+
}, /*#__PURE__*/React.createElement(Ariakit.MenuItem, {
|
|
2782
|
+
as: "div",
|
|
2783
|
+
state: state,
|
|
2784
|
+
ref: ref,
|
|
2785
|
+
hideOnClick: false
|
|
2786
|
+
}, renderMenuButton), list);
|
|
2787
|
+
});
|
|
2788
|
+
/**
|
|
2789
|
+
* A way to semantically group some menu items.
|
|
2790
|
+
*
|
|
2791
|
+
* This group does not add any visual separator. You can do that yourself adding `<hr />` elements
|
|
2792
|
+
* before and/or after the group if you so wish.
|
|
2793
|
+
*/
|
|
2794
|
+
|
|
2795
|
+
const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(_ref6, ref) {
|
|
2796
|
+
let {
|
|
2797
|
+
label,
|
|
2798
|
+
children,
|
|
2799
|
+
exceptionallySetClassName
|
|
2800
|
+
} = _ref6,
|
|
2801
|
+
props = _objectWithoutProperties(_ref6, _excluded6);
|
|
2802
|
+
|
|
2803
|
+
const {
|
|
2804
|
+
state
|
|
2805
|
+
} = React.useContext(MenuContext);
|
|
2806
|
+
return /*#__PURE__*/React.createElement(Ariakit.MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2807
|
+
ref: ref,
|
|
2808
|
+
state: state,
|
|
2809
|
+
className: exceptionallySetClassName
|
|
2810
|
+
}), label ? /*#__PURE__*/React.createElement("div", {
|
|
2811
|
+
role: "presentation",
|
|
2812
|
+
className: "reactist_menugroup__label"
|
|
2813
|
+
}, label) : null, children);
|
|
2814
|
+
});
|
|
2815
|
+
|
|
2816
|
+
const _excluded$s = ["type", "variant", "size", "loading", "disabled", "tooltip", "onClick", "children"];
|
|
2573
2817
|
/**
|
|
2574
2818
|
* @deprecated
|
|
2575
2819
|
*/
|
|
@@ -2585,7 +2829,7 @@ const Button$1 = /*#__PURE__*/React.forwardRef(function Button(_ref, ref) {
|
|
|
2585
2829
|
onClick,
|
|
2586
2830
|
children
|
|
2587
2831
|
} = _ref,
|
|
2588
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
2832
|
+
props = _objectWithoutProperties(_ref, _excluded$s);
|
|
2589
2833
|
|
|
2590
2834
|
const className = classNames('reactist_button', variant ? "reactist_button--" + variant : null, size !== 'default' ? "reactist_button--" + size : null, {
|
|
2591
2835
|
'reactist_button--loading': loading
|
|
@@ -2608,7 +2852,7 @@ Button$1.defaultProps = {
|
|
|
2608
2852
|
disabled: false
|
|
2609
2853
|
};
|
|
2610
2854
|
|
|
2611
|
-
const _excluded$
|
|
2855
|
+
const _excluded$t = ["children", "onClick", "tooltip", "className"];
|
|
2612
2856
|
|
|
2613
2857
|
class Box$1 extends React.Component {
|
|
2614
2858
|
constructor(props, context) {
|
|
@@ -2761,7 +3005,7 @@ const Trigger = /*#__PURE__*/React.forwardRef(function Trigger(_ref, ref) {
|
|
|
2761
3005
|
tooltip,
|
|
2762
3006
|
className
|
|
2763
3007
|
} = _ref,
|
|
2764
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
3008
|
+
props = _objectWithoutProperties(_ref, _excluded$t);
|
|
2765
3009
|
|
|
2766
3010
|
function handleClick(event) {
|
|
2767
3011
|
event.preventDefault();
|
|
@@ -2888,7 +3132,7 @@ function ColorItem({
|
|
|
2888
3132
|
|
|
2889
3133
|
ColorItem.displayName = 'ColorItem';
|
|
2890
3134
|
|
|
2891
|
-
const _excluded$
|
|
3135
|
+
const _excluded$u = ["children", "className", "translateKey", "isMac"];
|
|
2892
3136
|
// Support for setting up how to translate modifiers globally.
|
|
2893
3137
|
//
|
|
2894
3138
|
|
|
@@ -2970,7 +3214,7 @@ function KeyboardShortcut(_ref) {
|
|
|
2970
3214
|
translateKey = globalTranslateKey,
|
|
2971
3215
|
isMac = (_navigator$platform$t = (_navigator$platform = navigator.platform) == null ? void 0 : _navigator$platform.toUpperCase().includes('MAC')) != null ? _navigator$platform$t : false
|
|
2972
3216
|
} = _ref,
|
|
2973
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
3217
|
+
props = _objectWithoutProperties(_ref, _excluded$u);
|
|
2974
3218
|
|
|
2975
3219
|
const shortcuts = typeof children === 'string' ? [children] : children;
|
|
2976
3220
|
return /*#__PURE__*/React.createElement("span", _objectSpread2({
|
|
@@ -3376,241 +3620,6 @@ Time.defaultProps = {
|
|
|
3376
3620
|
}
|
|
3377
3621
|
};
|
|
3378
3622
|
|
|
3379
|
-
const _excluded$u = ["children", "onItemSelect"],
|
|
3380
|
-
_excluded2$3 = ["exceptionallySetClassName"],
|
|
3381
|
-
_excluded3$2 = ["as"],
|
|
3382
|
-
_excluded4$1 = ["exceptionallySetClassName"],
|
|
3383
|
-
_excluded5$1 = ["value", "children", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName", "as"],
|
|
3384
|
-
_excluded6 = ["label", "children", "exceptionallySetClassName"];
|
|
3385
|
-
const MenuContext = /*#__PURE__*/React.createContext( // Ariakit gives us no means to obtain a valid initial/default value of type MenuStateReturn
|
|
3386
|
-
// (it is normally obtained by calling useMenuState but we can't call hooks outside components).
|
|
3387
|
-
// This is however of little consequence since this value is only used if some of the components
|
|
3388
|
-
// are used outside Menu, something that should not happen and we do not support.
|
|
3389
|
-
// @ts-expect-error
|
|
3390
|
-
{});
|
|
3391
|
-
/**
|
|
3392
|
-
* Wrapper component to control a menu. It does not render anything, only providing the state
|
|
3393
|
-
* management for the menu components inside it. Note that if you are relying on the `[role='menu']`
|
|
3394
|
-
* attribute to style the menu list, it is applied a `menubar` role instead in Safari.
|
|
3395
|
-
*/
|
|
3396
|
-
|
|
3397
|
-
function Menu(_ref) {
|
|
3398
|
-
let {
|
|
3399
|
-
children,
|
|
3400
|
-
onItemSelect
|
|
3401
|
-
} = _ref,
|
|
3402
|
-
props = _objectWithoutProperties(_ref, _excluded$u);
|
|
3403
|
-
|
|
3404
|
-
const [anchorRect, handleAnchorRectChange] = React.useState(null);
|
|
3405
|
-
const getAnchorRect = React.useMemo(() => {
|
|
3406
|
-
return anchorRect ? () => anchorRect : undefined;
|
|
3407
|
-
}, [anchorRect]);
|
|
3408
|
-
const state = Ariakit.useMenuState(_objectSpread2({
|
|
3409
|
-
focusLoop: true,
|
|
3410
|
-
gutter: 8,
|
|
3411
|
-
shift: 4,
|
|
3412
|
-
getAnchorRect
|
|
3413
|
-
}, props));
|
|
3414
|
-
const handleItemSelect = React.useCallback(function handleItemSelect(value) {
|
|
3415
|
-
if (onItemSelect) onItemSelect(value);
|
|
3416
|
-
}, [onItemSelect]);
|
|
3417
|
-
const value = React.useMemo(() => ({
|
|
3418
|
-
state,
|
|
3419
|
-
handleItemSelect,
|
|
3420
|
-
handleAnchorRectChange
|
|
3421
|
-
}), [state, handleItemSelect]);
|
|
3422
|
-
return /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
3423
|
-
value: value
|
|
3424
|
-
}, children);
|
|
3425
|
-
}
|
|
3426
|
-
/**
|
|
3427
|
-
* A button to toggle a dropdown menu open or closed.
|
|
3428
|
-
*/
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2, ref) {
|
|
3432
|
-
let {
|
|
3433
|
-
exceptionallySetClassName
|
|
3434
|
-
} = _ref2,
|
|
3435
|
-
props = _objectWithoutProperties(_ref2, _excluded2$3);
|
|
3436
|
-
|
|
3437
|
-
const {
|
|
3438
|
-
state
|
|
3439
|
-
} = React.useContext(MenuContext);
|
|
3440
|
-
return /*#__PURE__*/React.createElement(Ariakit.MenuButton, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
3441
|
-
state: state,
|
|
3442
|
-
ref: ref,
|
|
3443
|
-
className: classNames('reactist_menubutton', exceptionallySetClassName)
|
|
3444
|
-
}));
|
|
3445
|
-
}); //
|
|
3446
|
-
// ContextMenuTrigger
|
|
3447
|
-
//
|
|
3448
|
-
|
|
3449
|
-
const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMenuTrigger(_ref3, ref) {
|
|
3450
|
-
let {
|
|
3451
|
-
as: component = 'div'
|
|
3452
|
-
} = _ref3,
|
|
3453
|
-
props = _objectWithoutProperties(_ref3, _excluded3$2);
|
|
3454
|
-
|
|
3455
|
-
const {
|
|
3456
|
-
handleAnchorRectChange,
|
|
3457
|
-
state
|
|
3458
|
-
} = React.useContext(MenuContext);
|
|
3459
|
-
const handleContextMenu = React.useCallback(event => {
|
|
3460
|
-
event.preventDefault();
|
|
3461
|
-
handleAnchorRectChange({
|
|
3462
|
-
x: event.clientX,
|
|
3463
|
-
y: event.clientY
|
|
3464
|
-
});
|
|
3465
|
-
state.show();
|
|
3466
|
-
}, [handleAnchorRectChange, state]);
|
|
3467
|
-
return /*#__PURE__*/React.createElement(component, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
3468
|
-
onContextMenu: handleContextMenu,
|
|
3469
|
-
ref
|
|
3470
|
-
}));
|
|
3471
|
-
});
|
|
3472
|
-
/**
|
|
3473
|
-
* The dropdown menu itself, containing a list of menu items.
|
|
3474
|
-
*/
|
|
3475
|
-
|
|
3476
|
-
const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref4, ref) {
|
|
3477
|
-
let {
|
|
3478
|
-
exceptionallySetClassName
|
|
3479
|
-
} = _ref4,
|
|
3480
|
-
props = _objectWithoutProperties(_ref4, _excluded4$1);
|
|
3481
|
-
|
|
3482
|
-
const {
|
|
3483
|
-
state
|
|
3484
|
-
} = React.useContext(MenuContext);
|
|
3485
|
-
return state.visible ? /*#__PURE__*/React.createElement(portal.Portal, {
|
|
3486
|
-
preserveTabOrder: true
|
|
3487
|
-
}, /*#__PURE__*/React.createElement(Ariakit.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
3488
|
-
state: state,
|
|
3489
|
-
ref: ref,
|
|
3490
|
-
className: classNames('reactist_menulist', exceptionallySetClassName)
|
|
3491
|
-
}))) : null;
|
|
3492
|
-
});
|
|
3493
|
-
/**
|
|
3494
|
-
* A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`
|
|
3495
|
-
* callback.
|
|
3496
|
-
*/
|
|
3497
|
-
|
|
3498
|
-
const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref) {
|
|
3499
|
-
let {
|
|
3500
|
-
value,
|
|
3501
|
-
children,
|
|
3502
|
-
onSelect,
|
|
3503
|
-
hideOnSelect = true,
|
|
3504
|
-
onClick,
|
|
3505
|
-
exceptionallySetClassName,
|
|
3506
|
-
as = 'button'
|
|
3507
|
-
} = _ref5,
|
|
3508
|
-
props = _objectWithoutProperties(_ref5, _excluded5$1);
|
|
3509
|
-
|
|
3510
|
-
const {
|
|
3511
|
-
handleItemSelect,
|
|
3512
|
-
state
|
|
3513
|
-
} = React.useContext(MenuContext);
|
|
3514
|
-
const {
|
|
3515
|
-
hide
|
|
3516
|
-
} = state;
|
|
3517
|
-
const handleClick = React.useCallback(function handleClick(event) {
|
|
3518
|
-
onClick == null ? void 0 : onClick(event);
|
|
3519
|
-
const onSelectResult = onSelect && !event.defaultPrevented ? onSelect() : undefined;
|
|
3520
|
-
const shouldClose = onSelectResult !== false && hideOnSelect;
|
|
3521
|
-
handleItemSelect(value);
|
|
3522
|
-
if (shouldClose) hide();
|
|
3523
|
-
}, [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value]);
|
|
3524
|
-
return /*#__PURE__*/React.createElement(Ariakit.MenuItem, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
3525
|
-
as: as,
|
|
3526
|
-
state: state,
|
|
3527
|
-
ref: ref,
|
|
3528
|
-
onClick: handleClick,
|
|
3529
|
-
className: exceptionallySetClassName,
|
|
3530
|
-
hideOnClick: false
|
|
3531
|
-
}), children);
|
|
3532
|
-
});
|
|
3533
|
-
/**
|
|
3534
|
-
* This component can be rendered alongside other `MenuItem` inside a `MenuList` in order to have
|
|
3535
|
-
* a sub-menu.
|
|
3536
|
-
*
|
|
3537
|
-
* Its children are expected to have the structure of a first level menu (a `MenuButton` and a
|
|
3538
|
-
* `MenuList`).
|
|
3539
|
-
*
|
|
3540
|
-
* ```jsx
|
|
3541
|
-
* <MenuItem label="Edit profile" />
|
|
3542
|
-
* <SubMenu>
|
|
3543
|
-
* <MenuButton>More options</MenuButton>
|
|
3544
|
-
* <MenuList>
|
|
3545
|
-
* <MenuItem label="Preferences" />
|
|
3546
|
-
* <MenuItem label="Sign out" />
|
|
3547
|
-
* </MenuList>
|
|
3548
|
-
* </SubMenu>
|
|
3549
|
-
* ```
|
|
3550
|
-
*
|
|
3551
|
-
* The `MenuButton` will become a menu item in the current menu items list, and it will lead to
|
|
3552
|
-
* opening a sub-menu with the menu items list below it.
|
|
3553
|
-
*/
|
|
3554
|
-
|
|
3555
|
-
const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
|
|
3556
|
-
children,
|
|
3557
|
-
onItemSelect
|
|
3558
|
-
}, ref) {
|
|
3559
|
-
const {
|
|
3560
|
-
handleItemSelect: parentMenuItemSelect,
|
|
3561
|
-
state
|
|
3562
|
-
} = React.useContext(MenuContext);
|
|
3563
|
-
const {
|
|
3564
|
-
hide: parentMenuHide
|
|
3565
|
-
} = state;
|
|
3566
|
-
const handleSubItemSelect = React.useCallback(function handleSubItemSelect(value) {
|
|
3567
|
-
if (onItemSelect) onItemSelect(value);
|
|
3568
|
-
parentMenuItemSelect(value);
|
|
3569
|
-
parentMenuHide();
|
|
3570
|
-
}, [parentMenuHide, parentMenuItemSelect, onItemSelect]);
|
|
3571
|
-
const [button, list] = React.Children.toArray(children); // Ariakit needs to be able to pass props to the MenuButton
|
|
3572
|
-
// and combine it with the MenuItem component
|
|
3573
|
-
|
|
3574
|
-
const renderMenuButton = React.useCallback(function renderMenuButton(props) {
|
|
3575
|
-
return /*#__PURE__*/React.cloneElement(button, props);
|
|
3576
|
-
}, [button]);
|
|
3577
|
-
return /*#__PURE__*/React.createElement(Menu, {
|
|
3578
|
-
onItemSelect: handleSubItemSelect
|
|
3579
|
-
}, /*#__PURE__*/React.createElement(Ariakit.MenuItem, {
|
|
3580
|
-
as: "div",
|
|
3581
|
-
state: state,
|
|
3582
|
-
ref: ref,
|
|
3583
|
-
hideOnClick: false
|
|
3584
|
-
}, renderMenuButton), list);
|
|
3585
|
-
});
|
|
3586
|
-
/**
|
|
3587
|
-
* A way to semantically group some menu items.
|
|
3588
|
-
*
|
|
3589
|
-
* This group does not add any visual separator. You can do that yourself adding `<hr />` elements
|
|
3590
|
-
* before and/or after the group if you so wish.
|
|
3591
|
-
*/
|
|
3592
|
-
|
|
3593
|
-
const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(_ref6, ref) {
|
|
3594
|
-
let {
|
|
3595
|
-
label,
|
|
3596
|
-
children,
|
|
3597
|
-
exceptionallySetClassName
|
|
3598
|
-
} = _ref6,
|
|
3599
|
-
props = _objectWithoutProperties(_ref6, _excluded6);
|
|
3600
|
-
|
|
3601
|
-
const {
|
|
3602
|
-
state
|
|
3603
|
-
} = React.useContext(MenuContext);
|
|
3604
|
-
return /*#__PURE__*/React.createElement(Ariakit.MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
3605
|
-
ref: ref,
|
|
3606
|
-
state: state,
|
|
3607
|
-
className: exceptionallySetClassName
|
|
3608
|
-
}), label ? /*#__PURE__*/React.createElement("div", {
|
|
3609
|
-
role: "presentation",
|
|
3610
|
-
className: "reactist_menugroup__label"
|
|
3611
|
-
}, label) : null, children);
|
|
3612
|
-
});
|
|
3613
|
-
|
|
3614
3623
|
const Input = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
3615
3624
|
const className = classNames('reactist_input', props.className);
|
|
3616
3625
|
return /*#__PURE__*/React.createElement("input", _objectSpread2(_objectSpread2({}, props), {}, {
|