@doist/reactist 29.1.1 → 30.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/CHANGELOG.md +18 -0
- package/dist/reactist.cjs.development.js +6749 -1832
- 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/avatar/avatar.js +106 -36
- package/es/avatar/avatar.js.map +1 -1
- package/es/avatar/utils.js +17 -19
- package/es/avatar/utils.js.map +1 -1
- package/es/badge/badge.js +50 -6
- package/es/badge/badge.js.map +1 -1
- package/es/banner/banner.js +384 -41
- package/es/banner/banner.js.map +1 -1
- package/es/base-field/base-field.js +367 -77
- package/es/base-field/base-field.js.map +1 -1
- package/es/box/box.js +139 -61
- package/es/box/box.js.map +1 -1
- package/es/button/button.js +346 -36
- package/es/button/button.js.map +1 -1
- package/es/checkbox-field/checkbox-field.js +71 -48
- package/es/checkbox-field/checkbox-field.js.map +1 -1
- package/es/checkbox-field/checkbox-icon.js +88 -28
- package/es/checkbox-field/checkbox-icon.js.map +1 -1
- package/es/checkbox-field/use-fork-ref.js +15 -20
- package/es/checkbox-field/use-fork-ref.js.map +1 -1
- package/es/columns/columns.js +46 -23
- package/es/columns/columns.js.map +1 -1
- package/es/components/color-picker/color-picker.js +190 -46
- package/es/components/color-picker/color-picker.js.map +1 -1
- package/es/components/deprecated-button/deprecated-button.js +102 -9
- package/es/components/deprecated-button/deprecated-button.js.map +1 -1
- package/es/components/deprecated-button/index.js +5 -2
- package/es/components/deprecated-button/index.js.map +1 -1
- package/es/components/deprecated-dropdown/dropdown.js +234 -134
- package/es/components/deprecated-dropdown/dropdown.js.map +1 -1
- package/es/components/deprecated-dropdown/index.js +4 -1
- package/es/components/deprecated-dropdown/index.js.map +1 -1
- package/es/components/deprecated-input/index.js +5 -2
- package/es/components/deprecated-input/index.js.map +1 -1
- package/es/components/deprecated-input/input.js +27 -4
- package/es/components/deprecated-input/input.js.map +1 -1
- package/es/components/deprecated-select/select.js +110 -7
- package/es/components/deprecated-select/select.js.map +1 -1
- package/es/components/key-capturer/key-capturer.js +190 -137
- package/es/components/key-capturer/key-capturer.js.map +1 -1
- package/es/components/keyboard-shortcut/keyboard-shortcut.js +65 -45
- package/es/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/es/components/progress-bar/progress-bar.js +61 -9
- package/es/components/progress-bar/progress-bar.js.map +1 -1
- package/es/components/time/index.js +5 -2
- package/es/components/time/index.js.map +1 -1
- package/es/components/time/time-utils.js +59 -53
- package/es/components/time/time-utils.js.map +1 -1
- package/es/components/time/time.js +94 -91
- package/es/components/time/time.js.map +1 -1
- package/es/divider/divider.js +44 -5
- package/es/divider/divider.js.map +1 -1
- package/es/heading/heading.js +122 -20
- package/es/heading/heading.js.map +1 -1
- package/es/hidden/hidden.js +36 -30
- package/es/hidden/hidden.js.map +1 -1
- package/es/hidden-visually/hidden-visually.js +9 -4
- package/es/hidden-visually/hidden-visually.js.map +1 -1
- package/es/icons/alert-icon.js +145 -18
- package/es/icons/alert-icon.js.map +1 -1
- package/es/icons/banner-icon.js +213 -25
- package/es/icons/banner-icon.js.map +1 -1
- package/es/icons/close-icon.js +26 -3
- package/es/icons/close-icon.js.map +1 -1
- package/es/icons/password-hidden-icon.js +40 -6
- package/es/icons/password-hidden-icon.js.map +1 -1
- package/es/icons/password-visible-icon.js +33 -5
- package/es/icons/password-visible-icon.js.map +1 -1
- package/es/index.js +9 -9
- package/es/inline/inline.js +24 -9
- package/es/inline/inline.js.map +1 -1
- package/es/loading/loading.js +63 -17
- package/es/loading/loading.js.map +1 -1
- package/es/menu/menu.js +469 -92
- package/es/menu/menu.js.map +1 -1
- package/es/modal/modal.js +675 -112
- package/es/modal/modal.js.map +1 -1
- package/es/notice/notice.js +77 -10
- package/es/notice/notice.js.map +1 -1
- package/es/password-field/password-field.js +89 -11
- package/es/password-field/password-field.js.map +1 -1
- package/es/prose/prose.js +48 -9
- package/es/prose/prose.js.map +1 -1
- package/es/select-field/select-field.js +150 -19
- package/es/select-field/select-field.js.map +1 -1
- package/es/spinner/spinner.js +39 -6
- package/es/spinner/spinner.js.map +1 -1
- package/es/stack/stack.js +29 -17
- package/es/stack/stack.js.map +1 -1
- package/es/switch-field/switch-field.js +225 -42
- package/es/switch-field/switch-field.js.map +1 -1
- package/es/tabs/tabs.js +207 -109
- package/es/tabs/tabs.js.map +1 -1
- package/es/text/text.js +27 -17
- package/es/text/text.js.map +1 -1
- package/es/text-area/text-area.js +264 -54
- package/es/text-area/text-area.js.map +1 -1
- package/es/text-field/text-field.js +204 -31
- package/es/text-field/text-field.js.map +1 -1
- package/es/text-link/text-link.js +21 -10
- package/es/text-link/text-link.js.map +1 -1
- package/es/toast/static-toast.js +143 -25
- package/es/toast/static-toast.js.map +1 -1
- package/es/toast/toast-animation.js +159 -109
- package/es/toast/toast-animation.js.map +1 -1
- package/es/toast/use-toasts.js +309 -84
- package/es/toast/use-toasts.js.map +1 -1
- package/es/tooltip/tooltip.js +88 -32
- package/es/tooltip/tooltip.js.map +1 -1
- package/es/utils/common-helpers.js +12 -11
- package/es/utils/common-helpers.js.map +1 -1
- package/es/utils/polymorphism.js +84 -1
- package/es/utils/polymorphism.js.map +1 -1
- package/es/utils/responsive-props.js +43 -32
- package/es/utils/responsive-props.js.map +1 -1
- package/lib/avatar/avatar.js +109 -35
- package/lib/avatar/avatar.js.map +1 -1
- package/lib/avatar/utils.js +17 -19
- package/lib/avatar/utils.js.map +1 -1
- package/lib/badge/badge.js +53 -5
- package/lib/badge/badge.js.map +1 -1
- package/lib/banner/banner.js +385 -38
- package/lib/banner/banner.js.map +1 -1
- package/lib/base-field/base-field.js +366 -73
- package/lib/base-field/base-field.js.map +1 -1
- package/lib/box/box.js +141 -61
- package/lib/box/box.js.map +1 -1
- package/lib/button/button.js +347 -35
- package/lib/button/button.js.map +1 -1
- package/lib/checkbox-field/checkbox-field.js +73 -46
- package/lib/checkbox-field/checkbox-field.js.map +1 -1
- package/lib/checkbox-field/checkbox-icon.js +92 -28
- package/lib/checkbox-field/checkbox-icon.js.map +1 -1
- package/lib/checkbox-field/use-fork-ref.js +15 -20
- package/lib/checkbox-field/use-fork-ref.js.map +1 -1
- package/lib/columns/columns.js +49 -22
- package/lib/columns/columns.js.map +1 -1
- package/lib/components/color-picker/color-picker.js +189 -45
- package/lib/components/color-picker/color-picker.js.map +1 -1
- package/lib/components/deprecated-button/deprecated-button.js +104 -9
- package/lib/components/deprecated-button/deprecated-button.js.map +1 -1
- package/lib/components/deprecated-dropdown/dropdown.js +235 -133
- package/lib/components/deprecated-dropdown/dropdown.js.map +1 -1
- package/lib/components/deprecated-input/input.js +28 -4
- package/lib/components/deprecated-input/input.js.map +1 -1
- package/lib/components/deprecated-select/select.js +112 -7
- package/lib/components/deprecated-select/select.js.map +1 -1
- package/lib/components/key-capturer/key-capturer.js +188 -135
- package/lib/components/key-capturer/key-capturer.js.map +1 -1
- package/lib/components/keyboard-shortcut/keyboard-shortcut.js +67 -45
- package/lib/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/lib/components/progress-bar/progress-bar.js +60 -8
- package/lib/components/progress-bar/progress-bar.js.map +1 -1
- package/lib/components/time/time-utils.js +59 -53
- package/lib/components/time/time-utils.js.map +1 -1
- package/lib/components/time/time.js +93 -90
- package/lib/components/time/time.js.map +1 -1
- package/lib/divider/divider.js +47 -4
- package/lib/divider/divider.js.map +1 -1
- package/lib/heading/heading.js +125 -19
- package/lib/heading/heading.js.map +1 -1
- package/lib/hidden/hidden.js +39 -29
- package/lib/hidden/hidden.js.map +1 -1
- package/lib/hidden-visually/hidden-visually.js +11 -3
- package/lib/hidden-visually/hidden-visually.js.map +1 -1
- package/lib/icons/alert-icon.js +149 -18
- package/lib/icons/alert-icon.js.map +1 -1
- package/lib/icons/banner-icon.js +217 -25
- package/lib/icons/banner-icon.js.map +1 -1
- package/lib/icons/close-icon.js +29 -3
- package/lib/icons/close-icon.js.map +1 -1
- package/lib/icons/password-hidden-icon.js +43 -6
- package/lib/icons/password-hidden-icon.js.map +1 -1
- package/lib/icons/password-visible-icon.js +36 -5
- package/lib/icons/password-visible-icon.js.map +1 -1
- package/lib/inline/inline.js +27 -8
- package/lib/inline/inline.js.map +1 -1
- package/lib/loading/loading.js +67 -17
- package/lib/loading/loading.js.map +1 -1
- package/lib/menu/menu.js +471 -91
- package/lib/menu/menu.js.map +1 -1
- package/lib/modal/modal.js +671 -106
- package/lib/modal/modal.js.map +1 -1
- package/lib/notice/notice.js +75 -8
- package/lib/notice/notice.js.map +1 -1
- package/lib/password-field/password-field.js +92 -10
- package/lib/password-field/password-field.js.map +1 -1
- package/lib/prose/prose.js +51 -8
- package/lib/prose/prose.js.map +1 -1
- package/lib/select-field/select-field.js +152 -17
- package/lib/select-field/select-field.js.map +1 -1
- package/lib/spinner/spinner.js +39 -6
- package/lib/spinner/spinner.js.map +1 -1
- package/lib/stack/stack.js +29 -15
- package/lib/stack/stack.js.map +1 -1
- package/lib/switch-field/switch-field.js +225 -38
- package/lib/switch-field/switch-field.js.map +1 -1
- package/lib/tabs/tabs.js +207 -107
- package/lib/tabs/tabs.js.map +1 -1
- package/lib/text/text.js +30 -16
- package/lib/text/text.js.map +1 -1
- package/lib/text-area/text-area.js +264 -52
- package/lib/text-area/text-area.js.map +1 -1
- package/lib/text-field/text-field.js +207 -30
- package/lib/text-field/text-field.js.map +1 -1
- package/lib/text-link/text-link.js +24 -9
- package/lib/text-link/text-link.js.map +1 -1
- package/lib/toast/static-toast.js +142 -22
- package/lib/toast/static-toast.js.map +1 -1
- package/lib/toast/toast-animation.js +158 -108
- package/lib/toast/toast-animation.js.map +1 -1
- package/lib/toast/use-toasts.js +310 -82
- package/lib/toast/use-toasts.js.map +1 -1
- package/lib/tooltip/tooltip.js +87 -31
- package/lib/tooltip/tooltip.js.map +1 -1
- package/lib/utils/common-helpers.js +12 -11
- package/lib/utils/common-helpers.js.map +1 -1
- package/lib/utils/polymorphism.js +84 -1
- package/lib/utils/polymorphism.js.map +1 -1
- package/lib/utils/responsive-props.js +43 -32
- package/lib/utils/responsive-props.js.map +1 -1
- package/package.json +12 -3
package/es/menu/menu.js
CHANGED
|
@@ -1,91 +1,341 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _extends from '@babel/runtime/helpers/extends';
|
|
2
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
|
+
import { c } from 'react-compiler-runtime';
|
|
2
5
|
import * as React from 'react';
|
|
3
|
-
import { MenuButton as MenuButton$1, Role, Portal, Menu as Menu$1, MenuItem as MenuItem$1, MenuGroup as MenuGroup$1
|
|
6
|
+
import { useMenuStore, MenuButton as MenuButton$1, Role, Portal, Menu as Menu$1, MenuItem as MenuItem$1, MenuGroup as MenuGroup$1 } from '@ariakit/react';
|
|
4
7
|
import classNames from 'classnames';
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const _excluded = ["children", "onItemSelect"],
|
|
10
|
+
_excluded2 = ["exceptionallySetClassName"],
|
|
11
|
+
_excluded3 = ["render"],
|
|
12
|
+
_excluded4 = ["exceptionallySetClassName", "modal", "flip"],
|
|
13
|
+
_excluded5 = ["value", "children", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName"],
|
|
14
|
+
_excluded6 = ["label", "children", "exceptionallySetClassName"];
|
|
15
|
+
const MenuContext = /*#__PURE__*/React.createContext({
|
|
16
|
+
menuStore: null,
|
|
17
|
+
handleItemSelect: () => undefined,
|
|
18
|
+
getAnchorRect: null,
|
|
19
|
+
setAnchorRect: () => undefined
|
|
11
20
|
});
|
|
12
|
-
|
|
21
|
+
const SubMenuContext = /*#__PURE__*/React.createContext({
|
|
22
|
+
isSubMenu: false
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
//
|
|
26
|
+
// Menu
|
|
27
|
+
//
|
|
28
|
+
|
|
13
29
|
/**
|
|
14
30
|
* Wrapper component to control a menu. It does not render anything, only providing the state
|
|
15
31
|
* management for the menu components inside it.
|
|
16
32
|
*/
|
|
17
|
-
function Menu(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
function Menu(t0) {
|
|
34
|
+
const $ = c(15);
|
|
35
|
+
let children;
|
|
36
|
+
let onItemSelect;
|
|
37
|
+
let props;
|
|
38
|
+
if ($[0] !== t0) {
|
|
39
|
+
var _t = t0;
|
|
40
|
+
({
|
|
41
|
+
children,
|
|
42
|
+
onItemSelect
|
|
43
|
+
} = _t);
|
|
44
|
+
props = _objectWithoutProperties(_t, _excluded);
|
|
45
|
+
$[0] = t0;
|
|
46
|
+
$[1] = children;
|
|
47
|
+
$[2] = onItemSelect;
|
|
48
|
+
$[3] = props;
|
|
49
|
+
} else {
|
|
50
|
+
children = $[1];
|
|
51
|
+
onItemSelect = $[2];
|
|
52
|
+
props = $[3];
|
|
53
|
+
}
|
|
54
|
+
const [anchorRect, setAnchorRect] = React.useState(null);
|
|
55
|
+
let t1;
|
|
56
|
+
if ($[4] !== anchorRect) {
|
|
57
|
+
t1 = anchorRect ? () => anchorRect : null;
|
|
58
|
+
$[4] = anchorRect;
|
|
59
|
+
$[5] = t1;
|
|
60
|
+
} else {
|
|
61
|
+
t1 = $[5];
|
|
62
|
+
}
|
|
63
|
+
const getAnchorRect = t1;
|
|
64
|
+
let t2;
|
|
65
|
+
if ($[6] !== props) {
|
|
66
|
+
t2 = _objectSpread({
|
|
67
|
+
focusLoop: true
|
|
68
|
+
}, props);
|
|
69
|
+
$[6] = props;
|
|
70
|
+
$[7] = t2;
|
|
71
|
+
} else {
|
|
72
|
+
t2 = $[7];
|
|
73
|
+
}
|
|
74
|
+
const menuStore = useMenuStore(t2);
|
|
75
|
+
let t3;
|
|
76
|
+
if ($[8] !== getAnchorRect || $[9] !== menuStore || $[10] !== onItemSelect) {
|
|
77
|
+
t3 = {
|
|
78
|
+
menuStore,
|
|
79
|
+
handleItemSelect: onItemSelect,
|
|
80
|
+
getAnchorRect,
|
|
81
|
+
setAnchorRect
|
|
82
|
+
};
|
|
83
|
+
$[8] = getAnchorRect;
|
|
84
|
+
$[9] = menuStore;
|
|
85
|
+
$[10] = onItemSelect;
|
|
86
|
+
$[11] = t3;
|
|
87
|
+
} else {
|
|
88
|
+
t3 = $[11];
|
|
89
|
+
}
|
|
90
|
+
const value = t3;
|
|
91
|
+
let t4;
|
|
92
|
+
if ($[12] !== children || $[13] !== value) {
|
|
93
|
+
t4 = /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
94
|
+
value: value
|
|
95
|
+
}, children);
|
|
96
|
+
$[12] = children;
|
|
97
|
+
$[13] = value;
|
|
98
|
+
$[14] = t4;
|
|
99
|
+
} else {
|
|
100
|
+
t4 = $[14];
|
|
101
|
+
}
|
|
102
|
+
return t4;
|
|
24
103
|
}
|
|
104
|
+
|
|
105
|
+
//
|
|
106
|
+
// MenuButton
|
|
107
|
+
//
|
|
108
|
+
|
|
25
109
|
/**
|
|
26
110
|
* A button to toggle a dropdown menu open or closed.
|
|
27
111
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
112
|
+
const MenuButton = /*#__PURE__*/React.forwardRef(function MenuButton(t0, ref) {
|
|
113
|
+
const $ = c(10);
|
|
114
|
+
let exceptionallySetClassName;
|
|
115
|
+
let props;
|
|
116
|
+
if ($[0] !== t0) {
|
|
117
|
+
var _t2 = t0;
|
|
118
|
+
({
|
|
119
|
+
exceptionallySetClassName
|
|
120
|
+
} = _t2);
|
|
121
|
+
props = _objectWithoutProperties(_t2, _excluded2);
|
|
122
|
+
$[0] = t0;
|
|
123
|
+
$[1] = exceptionallySetClassName;
|
|
124
|
+
$[2] = props;
|
|
125
|
+
} else {
|
|
126
|
+
exceptionallySetClassName = $[1];
|
|
127
|
+
props = $[2];
|
|
128
|
+
}
|
|
129
|
+
const {
|
|
130
|
+
menuStore
|
|
131
|
+
} = React.useContext(MenuContext);
|
|
132
|
+
if (!menuStore) {
|
|
133
|
+
throw new Error("MenuButton must be wrapped in <Menu/>");
|
|
134
|
+
}
|
|
135
|
+
let t1;
|
|
136
|
+
if ($[3] !== exceptionallySetClassName) {
|
|
137
|
+
t1 = classNames("reactist_menubutton", exceptionallySetClassName);
|
|
138
|
+
$[3] = exceptionallySetClassName;
|
|
139
|
+
$[4] = t1;
|
|
140
|
+
} else {
|
|
141
|
+
t1 = $[4];
|
|
142
|
+
}
|
|
143
|
+
let t2;
|
|
144
|
+
if ($[5] !== menuStore || $[6] !== props || $[7] !== ref || $[8] !== t1) {
|
|
145
|
+
t2 = /*#__PURE__*/React.createElement(MenuButton$1, _extends({}, props, {
|
|
146
|
+
store: menuStore,
|
|
147
|
+
ref: ref,
|
|
148
|
+
className: t1
|
|
149
|
+
}));
|
|
150
|
+
$[5] = menuStore;
|
|
151
|
+
$[6] = props;
|
|
152
|
+
$[7] = ref;
|
|
153
|
+
$[8] = t1;
|
|
154
|
+
$[9] = t2;
|
|
155
|
+
} else {
|
|
156
|
+
t2 = $[9];
|
|
157
|
+
}
|
|
158
|
+
return t2;
|
|
35
159
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
160
|
+
|
|
161
|
+
//
|
|
162
|
+
// ContextMenuTrigger
|
|
163
|
+
//
|
|
164
|
+
|
|
165
|
+
const ContextMenuTrigger = /*#__PURE__*/React.forwardRef(function ContextMenuTrigger(_ref, ref) {
|
|
166
|
+
let {
|
|
167
|
+
render
|
|
168
|
+
} = _ref,
|
|
169
|
+
props = _objectWithoutProperties(_ref, _excluded3);
|
|
170
|
+
const {
|
|
171
|
+
setAnchorRect,
|
|
172
|
+
menuStore
|
|
173
|
+
} = React.useContext(MenuContext);
|
|
174
|
+
if (!menuStore) {
|
|
175
|
+
throw new Error('ContextMenuTrigger must be wrapped in <Menu/>');
|
|
176
|
+
}
|
|
177
|
+
const handleContextMenu = React.useCallback(function handleContextMenu(event) {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
setAnchorRect({
|
|
180
|
+
x: event.clientX,
|
|
181
|
+
y: event.clientY
|
|
182
|
+
});
|
|
183
|
+
menuStore.show();
|
|
184
|
+
}, [setAnchorRect, menuStore]);
|
|
185
|
+
const isOpen = menuStore.useState('open');
|
|
186
|
+
React.useEffect(() => {
|
|
187
|
+
if (!isOpen) setAnchorRect(null);
|
|
188
|
+
}, [isOpen, setAnchorRect]);
|
|
189
|
+
return /*#__PURE__*/React.createElement(Role.div, _extends({}, props, {
|
|
190
|
+
onContextMenu: handleContextMenu,
|
|
191
|
+
ref: ref,
|
|
192
|
+
render: render
|
|
193
|
+
}));
|
|
53
194
|
});
|
|
195
|
+
|
|
196
|
+
//
|
|
197
|
+
// MenuList
|
|
198
|
+
//
|
|
199
|
+
|
|
54
200
|
/**
|
|
55
201
|
* The dropdown menu itself, containing a list of menu items.
|
|
56
202
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
203
|
+
const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(_ref2, ref) {
|
|
204
|
+
let {
|
|
205
|
+
exceptionallySetClassName,
|
|
206
|
+
modal = true,
|
|
207
|
+
flip
|
|
208
|
+
} = _ref2,
|
|
209
|
+
props = _objectWithoutProperties(_ref2, _excluded4);
|
|
210
|
+
const {
|
|
211
|
+
menuStore,
|
|
212
|
+
getAnchorRect
|
|
213
|
+
} = React.useContext(MenuContext);
|
|
214
|
+
if (!menuStore) {
|
|
215
|
+
throw new Error('MenuList must be wrapped in <Menu/>');
|
|
216
|
+
}
|
|
217
|
+
const {
|
|
218
|
+
isSubMenu
|
|
219
|
+
} = React.useContext(SubMenuContext);
|
|
220
|
+
const isOpen = menuStore.useState('open');
|
|
221
|
+
return isOpen ? /*#__PURE__*/React.createElement(Portal, {
|
|
222
|
+
preserveTabOrder: true
|
|
223
|
+
}, /*#__PURE__*/React.createElement(Menu$1, _extends({}, props, {
|
|
224
|
+
store: menuStore,
|
|
225
|
+
gutter: 8,
|
|
226
|
+
shift: 4,
|
|
227
|
+
ref: ref,
|
|
228
|
+
className: classNames('reactist_menulist', exceptionallySetClassName),
|
|
229
|
+
getAnchorRect: getAnchorRect ?? undefined,
|
|
230
|
+
modal: modal,
|
|
231
|
+
flip: flip ?? (isSubMenu ? 'left bottom' : undefined)
|
|
232
|
+
}))) : null;
|
|
67
233
|
});
|
|
234
|
+
|
|
235
|
+
//
|
|
236
|
+
// MenuItem
|
|
237
|
+
//
|
|
238
|
+
|
|
68
239
|
/**
|
|
69
240
|
* A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`
|
|
70
241
|
* callback.
|
|
71
242
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
243
|
+
const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(t0, ref) {
|
|
244
|
+
const $ = c(22);
|
|
245
|
+
let children;
|
|
246
|
+
let exceptionallySetClassName;
|
|
247
|
+
let onClick;
|
|
248
|
+
let onSelect;
|
|
249
|
+
let props;
|
|
250
|
+
let t1;
|
|
251
|
+
let value;
|
|
252
|
+
if ($[0] !== t0) {
|
|
253
|
+
var _t3 = t0;
|
|
254
|
+
({
|
|
255
|
+
value,
|
|
256
|
+
children,
|
|
257
|
+
onSelect,
|
|
258
|
+
hideOnSelect: t1,
|
|
259
|
+
onClick,
|
|
260
|
+
exceptionallySetClassName
|
|
261
|
+
} = _t3);
|
|
262
|
+
props = _objectWithoutProperties(_t3, _excluded5);
|
|
263
|
+
$[0] = t0;
|
|
264
|
+
$[1] = children;
|
|
265
|
+
$[2] = exceptionallySetClassName;
|
|
266
|
+
$[3] = onClick;
|
|
267
|
+
$[4] = onSelect;
|
|
268
|
+
$[5] = props;
|
|
269
|
+
$[6] = t1;
|
|
270
|
+
$[7] = value;
|
|
271
|
+
} else {
|
|
272
|
+
children = $[1];
|
|
273
|
+
exceptionallySetClassName = $[2];
|
|
274
|
+
onClick = $[3];
|
|
275
|
+
onSelect = $[4];
|
|
276
|
+
props = $[5];
|
|
277
|
+
t1 = $[6];
|
|
278
|
+
value = $[7];
|
|
279
|
+
}
|
|
280
|
+
const hideOnSelect = t1 === undefined ? true : t1;
|
|
281
|
+
const {
|
|
282
|
+
handleItemSelect,
|
|
283
|
+
menuStore
|
|
284
|
+
} = React.useContext(MenuContext);
|
|
285
|
+
if (!menuStore) {
|
|
286
|
+
throw new Error("MenuItem must be wrapped in <Menu/>");
|
|
287
|
+
}
|
|
288
|
+
const {
|
|
289
|
+
hide
|
|
290
|
+
} = menuStore;
|
|
291
|
+
let t2;
|
|
292
|
+
if ($[8] !== handleItemSelect || $[9] !== hide || $[10] !== hideOnSelect || $[11] !== onClick || $[12] !== onSelect || $[13] !== value) {
|
|
293
|
+
t2 = function handleClick(event) {
|
|
294
|
+
onClick?.(event);
|
|
295
|
+
const onSelectResult = onSelect && !event.defaultPrevented ? onSelect() : undefined;
|
|
296
|
+
const shouldClose = onSelectResult !== false && hideOnSelect;
|
|
297
|
+
handleItemSelect?.(value);
|
|
298
|
+
if (shouldClose) {
|
|
299
|
+
hide();
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
$[8] = handleItemSelect;
|
|
303
|
+
$[9] = hide;
|
|
304
|
+
$[10] = hideOnSelect;
|
|
305
|
+
$[11] = onClick;
|
|
306
|
+
$[12] = onSelect;
|
|
307
|
+
$[13] = value;
|
|
308
|
+
$[14] = t2;
|
|
309
|
+
} else {
|
|
310
|
+
t2 = $[14];
|
|
311
|
+
}
|
|
312
|
+
const handleClick = t2;
|
|
313
|
+
let t3;
|
|
314
|
+
if ($[15] !== children || $[16] !== exceptionallySetClassName || $[17] !== handleClick || $[18] !== menuStore || $[19] !== props || $[20] !== ref) {
|
|
315
|
+
t3 = /*#__PURE__*/React.createElement(MenuItem$1, _extends({}, props, {
|
|
316
|
+
store: menuStore,
|
|
317
|
+
ref: ref,
|
|
318
|
+
onClick: handleClick,
|
|
319
|
+
className: exceptionallySetClassName,
|
|
320
|
+
hideOnClick: false
|
|
321
|
+
}), children);
|
|
322
|
+
$[15] = children;
|
|
323
|
+
$[16] = exceptionallySetClassName;
|
|
324
|
+
$[17] = handleClick;
|
|
325
|
+
$[18] = menuStore;
|
|
326
|
+
$[19] = props;
|
|
327
|
+
$[20] = ref;
|
|
328
|
+
$[21] = t3;
|
|
329
|
+
} else {
|
|
330
|
+
t3 = $[21];
|
|
331
|
+
}
|
|
332
|
+
return t3;
|
|
88
333
|
});
|
|
334
|
+
|
|
335
|
+
//
|
|
336
|
+
// SubMenu
|
|
337
|
+
//
|
|
338
|
+
|
|
89
339
|
/**
|
|
90
340
|
* This component can be rendered alongside other `MenuItem` inside a `MenuList` in order to have
|
|
91
341
|
* a sub-menu.
|
|
@@ -107,40 +357,167 @@ var MenuItem = React.forwardRef(function MenuItem(_a, ref) {
|
|
|
107
357
|
* The `MenuButton` will become a menu item in the current menu items list, and it will lead to
|
|
108
358
|
* opening a sub-menu with the menu items list below it.
|
|
109
359
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
360
|
+
const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu(t0, ref) {
|
|
361
|
+
const $ = c(17);
|
|
362
|
+
const {
|
|
363
|
+
children,
|
|
364
|
+
onItemSelect
|
|
365
|
+
} = t0;
|
|
366
|
+
const {
|
|
367
|
+
handleItemSelect: parentMenuItemSelect,
|
|
368
|
+
menuStore
|
|
369
|
+
} = React.useContext(MenuContext);
|
|
370
|
+
if (!menuStore) {
|
|
371
|
+
throw new Error("SubMenu must be wrapped in <Menu/>");
|
|
372
|
+
}
|
|
373
|
+
const {
|
|
374
|
+
hide: parentMenuHide
|
|
375
|
+
} = menuStore;
|
|
376
|
+
let t1;
|
|
377
|
+
if ($[0] !== onItemSelect || $[1] !== parentMenuHide || $[2] !== parentMenuItemSelect) {
|
|
378
|
+
t1 = function handleSubItemSelect(value) {
|
|
379
|
+
onItemSelect?.(value);
|
|
380
|
+
parentMenuItemSelect?.(value);
|
|
381
|
+
parentMenuHide();
|
|
382
|
+
};
|
|
383
|
+
$[0] = onItemSelect;
|
|
384
|
+
$[1] = parentMenuHide;
|
|
385
|
+
$[2] = parentMenuItemSelect;
|
|
386
|
+
$[3] = t1;
|
|
387
|
+
} else {
|
|
388
|
+
t1 = $[3];
|
|
389
|
+
}
|
|
390
|
+
const handleSubItemSelect = t1;
|
|
391
|
+
let t2;
|
|
392
|
+
if ($[4] !== children) {
|
|
393
|
+
t2 = React.Children.toArray(children);
|
|
394
|
+
$[4] = children;
|
|
395
|
+
$[5] = t2;
|
|
396
|
+
} else {
|
|
397
|
+
t2 = $[5];
|
|
398
|
+
}
|
|
399
|
+
const [button, list] = t2;
|
|
400
|
+
const buttonElement = button;
|
|
401
|
+
let t3;
|
|
402
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
403
|
+
t3 = {
|
|
404
|
+
isSubMenu: true
|
|
405
|
+
};
|
|
406
|
+
$[6] = t3;
|
|
407
|
+
} else {
|
|
408
|
+
t3 = $[6];
|
|
409
|
+
}
|
|
410
|
+
const subMenuContextValue = t3;
|
|
411
|
+
let t4;
|
|
412
|
+
if ($[7] !== buttonElement || $[8] !== menuStore || $[9] !== ref) {
|
|
413
|
+
t4 = /*#__PURE__*/React.createElement(MenuItem$1, {
|
|
414
|
+
store: menuStore,
|
|
415
|
+
ref: ref,
|
|
416
|
+
hideOnClick: false,
|
|
417
|
+
render: buttonElement
|
|
418
|
+
}, buttonElement.props.children);
|
|
419
|
+
$[7] = buttonElement;
|
|
420
|
+
$[8] = menuStore;
|
|
421
|
+
$[9] = ref;
|
|
422
|
+
$[10] = t4;
|
|
423
|
+
} else {
|
|
424
|
+
t4 = $[10];
|
|
425
|
+
}
|
|
426
|
+
let t5;
|
|
427
|
+
if ($[11] !== list) {
|
|
428
|
+
t5 = /*#__PURE__*/React.createElement(SubMenuContext.Provider, {
|
|
429
|
+
value: subMenuContextValue
|
|
430
|
+
}, list);
|
|
431
|
+
$[11] = list;
|
|
432
|
+
$[12] = t5;
|
|
433
|
+
} else {
|
|
434
|
+
t5 = $[12];
|
|
435
|
+
}
|
|
436
|
+
let t6;
|
|
437
|
+
if ($[13] !== handleSubItemSelect || $[14] !== t4 || $[15] !== t5) {
|
|
438
|
+
t6 = /*#__PURE__*/React.createElement(Menu, {
|
|
439
|
+
onItemSelect: handleSubItemSelect
|
|
440
|
+
}, t4, t5);
|
|
441
|
+
$[13] = handleSubItemSelect;
|
|
442
|
+
$[14] = t4;
|
|
443
|
+
$[15] = t5;
|
|
444
|
+
$[16] = t6;
|
|
445
|
+
} else {
|
|
446
|
+
t6 = $[16];
|
|
447
|
+
}
|
|
448
|
+
return t6;
|
|
128
449
|
});
|
|
450
|
+
|
|
451
|
+
//
|
|
452
|
+
// MenuGroup
|
|
453
|
+
//
|
|
454
|
+
|
|
129
455
|
/**
|
|
130
456
|
* A way to semantically group some menu items.
|
|
131
457
|
*
|
|
132
458
|
* This group does not add any visual separator. You can do that yourself adding `<hr />` elements
|
|
133
459
|
* before and/or after the group if you so wish.
|
|
134
460
|
*/
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
461
|
+
const MenuGroup = /*#__PURE__*/React.forwardRef(function MenuGroup(t0, ref) {
|
|
462
|
+
const $ = c(14);
|
|
463
|
+
let children;
|
|
464
|
+
let exceptionallySetClassName;
|
|
465
|
+
let label;
|
|
466
|
+
let props;
|
|
467
|
+
if ($[0] !== t0) {
|
|
468
|
+
var _t4 = t0;
|
|
469
|
+
({
|
|
470
|
+
label,
|
|
471
|
+
children,
|
|
472
|
+
exceptionallySetClassName
|
|
473
|
+
} = _t4);
|
|
474
|
+
props = _objectWithoutProperties(_t4, _excluded6);
|
|
475
|
+
$[0] = t0;
|
|
476
|
+
$[1] = children;
|
|
477
|
+
$[2] = exceptionallySetClassName;
|
|
478
|
+
$[3] = label;
|
|
479
|
+
$[4] = props;
|
|
480
|
+
} else {
|
|
481
|
+
children = $[1];
|
|
482
|
+
exceptionallySetClassName = $[2];
|
|
483
|
+
label = $[3];
|
|
484
|
+
props = $[4];
|
|
485
|
+
}
|
|
486
|
+
const {
|
|
487
|
+
menuStore
|
|
488
|
+
} = React.useContext(MenuContext);
|
|
489
|
+
if (!menuStore) {
|
|
490
|
+
throw new Error("MenuGroup must be wrapped in <Menu/>");
|
|
491
|
+
}
|
|
492
|
+
let t1;
|
|
493
|
+
if ($[5] !== label) {
|
|
494
|
+
t1 = label ? /*#__PURE__*/React.createElement("div", {
|
|
495
|
+
role: "presentation",
|
|
496
|
+
className: "reactist_menugroup__label"
|
|
497
|
+
}, label) : null;
|
|
498
|
+
$[5] = label;
|
|
499
|
+
$[6] = t1;
|
|
500
|
+
} else {
|
|
501
|
+
t1 = $[6];
|
|
502
|
+
}
|
|
503
|
+
let t2;
|
|
504
|
+
if ($[7] !== children || $[8] !== exceptionallySetClassName || $[9] !== menuStore || $[10] !== props || $[11] !== ref || $[12] !== t1) {
|
|
505
|
+
t2 = /*#__PURE__*/React.createElement(MenuGroup$1, _extends({}, props, {
|
|
506
|
+
ref: ref,
|
|
507
|
+
store: menuStore,
|
|
508
|
+
className: exceptionallySetClassName
|
|
509
|
+
}), t1, children);
|
|
510
|
+
$[7] = children;
|
|
511
|
+
$[8] = exceptionallySetClassName;
|
|
512
|
+
$[9] = menuStore;
|
|
513
|
+
$[10] = props;
|
|
514
|
+
$[11] = ref;
|
|
515
|
+
$[12] = t1;
|
|
516
|
+
$[13] = t2;
|
|
517
|
+
} else {
|
|
518
|
+
t2 = $[13];
|
|
519
|
+
}
|
|
520
|
+
return t2;
|
|
144
521
|
});
|
|
145
522
|
|
|
146
523
|
export { ContextMenuTrigger, Menu, MenuButton, MenuGroup, MenuItem, MenuList, SubMenu };
|