react-hook-toolkit 1.0.21 → 1.0.22
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.
|
@@ -53,7 +53,7 @@ interface DownloadFileProps {
|
|
|
53
53
|
}
|
|
54
54
|
export declare const DownloadFile: React.FC<DownloadFileProps>;
|
|
55
55
|
type MenuPosition = 'auto' | 'fixed';
|
|
56
|
-
type
|
|
56
|
+
type ThemeMode = 'light' | 'dark';
|
|
57
57
|
interface ContextMenuProps {
|
|
58
58
|
options: any;
|
|
59
59
|
children: React.ReactNode;
|
|
@@ -64,7 +64,7 @@ interface ContextMenuProps {
|
|
|
64
64
|
onShow?: () => void;
|
|
65
65
|
onHide?: () => void;
|
|
66
66
|
currentInstance?: any;
|
|
67
|
-
theme?:
|
|
67
|
+
theme?: ThemeMode;
|
|
68
68
|
}
|
|
69
69
|
export declare const ContextMenuWrapper: React.FC<ContextMenuProps>;
|
|
70
70
|
export {};
|
|
@@ -12,8 +12,9 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
13
|
import { forwardRef, useState } from 'react';
|
|
14
14
|
import { useEffect, useCallback, useRef, Suspense } from 'react';
|
|
15
|
-
import { Box, Alert, AlertTitle, IconButton, CardContent, Tooltip,
|
|
15
|
+
import { Paper, MenuList, MenuItem, ListItemIcon, ListItemText, Divider, Typography, styled, Box, Alert, AlertTitle, IconButton, CardContent, Tooltip, Card, Grid, Skeleton, CircularProgress, } from '@mui/material';
|
|
16
16
|
import { Close, InsertDriveFile, Image, Description, Download, CheckCircleOutlined, ErrorOutlineOutlined, Upload, } from '@mui/icons-material';
|
|
17
|
+
import { useTheme } from '@mui/material/styles';
|
|
17
18
|
import NProgress from 'nprogress';
|
|
18
19
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
19
20
|
import { promise } from '../utils';
|
|
@@ -166,16 +167,58 @@ export var DownloadFile = function (_a) {
|
|
|
166
167
|
zIndex: 1,
|
|
167
168
|
} }))] }) }));
|
|
168
169
|
};
|
|
170
|
+
var StyledMenuPaper = styled(Paper)(function (_a) {
|
|
171
|
+
var theme = _a.theme;
|
|
172
|
+
return ({
|
|
173
|
+
minWidth: 200,
|
|
174
|
+
padding: theme.spacing(0, 0),
|
|
175
|
+
boxShadow: theme.shadows[3],
|
|
176
|
+
'&.context-menu-dark': {
|
|
177
|
+
backgroundColor: theme.palette.grey[800],
|
|
178
|
+
color: theme.palette.common.white,
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
var StyledMenuItem = styled(MenuItem)(function (_a) {
|
|
183
|
+
var theme = _a.theme;
|
|
184
|
+
return ({
|
|
185
|
+
padding: theme.spacing(0.5, 1),
|
|
186
|
+
fontSize: '14px',
|
|
187
|
+
'& .MuiListItemText-root': {
|
|
188
|
+
'& .MuiTypography-root': {
|
|
189
|
+
fontSize: '14px',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
'&.context-menu-item-dark': {
|
|
193
|
+
color: theme.palette.common.white,
|
|
194
|
+
'&:hover': {
|
|
195
|
+
backgroundColor: theme.palette.grey[700],
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
'&.context-menu-item--disabled': {
|
|
199
|
+
opacity: 0.5,
|
|
200
|
+
pointerEvents: 'none',
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
var ShortcutText = styled(Typography)(function (_a) {
|
|
205
|
+
var theme = _a.theme;
|
|
206
|
+
return ({
|
|
207
|
+
marginLeft: theme.spacing(2),
|
|
208
|
+
fontSize: '0.75rem',
|
|
209
|
+
color: theme.palette.text.secondary,
|
|
210
|
+
'&.context-menu-shortcut-dark': {
|
|
211
|
+
color: theme.palette.grey[400],
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
});
|
|
169
215
|
export var ContextMenuWrapper = function (_a) {
|
|
170
216
|
var options = _a.options, children = _a.children, disabled = _a.disabled, className = _a.className, menuClassName = _a.menuClassName, _b = _a.position, position = _b === void 0 ? 'auto' : _b, onShow = _a.onShow, onHide = _a.onHide, currentInstance = _a.currentInstance, _c = _a.theme, theme = _c === void 0 ? 'light' : _c;
|
|
217
|
+
var muiTheme = useTheme();
|
|
171
218
|
var _d = useState(false), isVisible = _d[0], setIsVisible = _d[1];
|
|
172
219
|
var _e = useState({ x: 0, y: 0 }), menuPosition = _e[0], setMenuPosition = _e[1];
|
|
173
220
|
var menuRef = useRef(null);
|
|
174
221
|
var triggerRef = useRef(null);
|
|
175
|
-
var menuClasses = "context-menu ".concat(menuClassName || '', " context-menu-").concat(theme);
|
|
176
|
-
var itemClasses = function (item) {
|
|
177
|
-
return "context-menu-item ".concat(item.disabled ? 'context-menu-item--disabled' : '', " ").concat(item.className || '', " context-menu-item-").concat(theme);
|
|
178
|
-
};
|
|
179
222
|
var handleContextMenu = function (e) {
|
|
180
223
|
var _a, _b;
|
|
181
224
|
e.preventDefault();
|
|
@@ -237,20 +280,20 @@ export var ContextMenuWrapper = function (_a) {
|
|
|
237
280
|
document.removeEventListener('keydown', handleKeyDown);
|
|
238
281
|
};
|
|
239
282
|
}, [isVisible]);
|
|
240
|
-
return (_jsxs("div", { ref: triggerRef, className: "context-menu-trigger ".concat(className || ''), onContextMenu: handleContextMenu, children: [children, isVisible && (_jsx("div", { ref: menuRef,
|
|
283
|
+
return (_jsxs("div", { ref: triggerRef, className: "context-menu-trigger ".concat(className || ''), onContextMenu: handleContextMenu, children: [children, isVisible && (_jsx("div", { ref: menuRef, style: {
|
|
241
284
|
position: 'fixed',
|
|
242
285
|
left: "".concat(menuPosition.x, "px"),
|
|
243
286
|
top: "".concat(menuPosition.y, "px"),
|
|
244
|
-
zIndex:
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
287
|
+
zIndex: muiTheme.zIndex.modal,
|
|
288
|
+
}, children: _jsx(StyledMenuPaper, { className: "".concat(menuClassName || '', " context-menu-").concat(theme), children: _jsx(MenuList, { children: options.map(function (item, index) {
|
|
289
|
+
if (item === 'divider') {
|
|
290
|
+
return _jsx(Divider, { className: "context-menu-divider-".concat(theme) }, "divider-".concat(index.toString()));
|
|
291
|
+
}
|
|
292
|
+
return (_jsxs(StyledMenuItem, { sx: { fontSize: '10px' }, className: "".concat(item.className || '', " context-menu-item-").concat(theme, " ").concat(item.disabled ? 'context-menu-item--disabled' : ''), onClick: function () { return handleItemClick(item); }, onKeyDown: function (e) {
|
|
293
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
294
|
+
e.preventDefault();
|
|
295
|
+
handleItemClick(item);
|
|
296
|
+
}
|
|
297
|
+
}, tabIndex: item.disabled ? -1 : 0, disabled: item.disabled, children: [item.icon && (_jsx(ListItemIcon, { sx: { marginRight: -1 }, className: "context-menu-icon-".concat(theme), children: item.icon })), _jsx(ListItemText, { className: "context-menu-text-".concat(theme), children: item.label }), item.shortcut && (_jsx(ShortcutText, { className: "context-menu-shortcut-".concat(theme), children: item.shortcut }))] }, item.key || index));
|
|
298
|
+
}) }) }) }))] }));
|
|
256
299
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-hook-toolkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"description": "Ultimate package for React developers, offering a powerful collection of hooks and components to enhance their development experience.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|