react-hook-toolkit 1.0.20 → 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.
@@ -1,5 +1,4 @@
1
1
  import React, { FC } from 'react';
2
- import '../chunk1314/chunkcss9876.css';
3
2
  export declare const DynamicLoader: (Component: any) => (props: any) => import("react/jsx-runtime").JSX.Element;
4
3
  interface PropsType {
5
4
  type: string;
@@ -54,7 +53,7 @@ interface DownloadFileProps {
54
53
  }
55
54
  export declare const DownloadFile: React.FC<DownloadFileProps>;
56
55
  type MenuPosition = 'auto' | 'fixed';
57
- type Theme = 'light' | 'dark';
56
+ type ThemeMode = 'light' | 'dark';
58
57
  interface ContextMenuProps {
59
58
  options: any;
60
59
  children: React.ReactNode;
@@ -65,7 +64,7 @@ interface ContextMenuProps {
65
64
  onShow?: () => void;
66
65
  onHide?: () => void;
67
66
  currentInstance?: any;
68
- theme?: Theme;
67
+ theme?: ThemeMode;
69
68
  }
70
69
  export declare const ContextMenuWrapper: React.FC<ContextMenuProps>;
71
70
  export {};
@@ -12,9 +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, Typography, Card, Grid, Skeleton, CircularProgress, } from '@mui/material';
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 '../chunk1314/chunkcss9876.css';
17
+ import { useTheme } from '@mui/material/styles';
18
18
  import NProgress from 'nprogress';
19
19
  import { ErrorBoundary } from 'react-error-boundary';
20
20
  import { promise } from '../utils';
@@ -167,16 +167,58 @@ export var DownloadFile = function (_a) {
167
167
  zIndex: 1,
168
168
  } }))] }) }));
169
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
+ });
170
215
  export var ContextMenuWrapper = function (_a) {
171
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();
172
218
  var _d = useState(false), isVisible = _d[0], setIsVisible = _d[1];
173
219
  var _e = useState({ x: 0, y: 0 }), menuPosition = _e[0], setMenuPosition = _e[1];
174
220
  var menuRef = useRef(null);
175
221
  var triggerRef = useRef(null);
176
- var menuClasses = "context-menu ".concat(menuClassName || '', " context-menu-").concat(theme);
177
- var itemClasses = function (item) {
178
- return "context-menu-item ".concat(item.disabled ? 'context-menu-item--disabled' : '', " ").concat(item.className || '', " context-menu-item-").concat(theme);
179
- };
180
222
  var handleContextMenu = function (e) {
181
223
  var _a, _b;
182
224
  e.preventDefault();
@@ -238,20 +280,20 @@ export var ContextMenuWrapper = function (_a) {
238
280
  document.removeEventListener('keydown', handleKeyDown);
239
281
  };
240
282
  }, [isVisible]);
241
- return (_jsxs("div", { ref: triggerRef, className: "context-menu-trigger ".concat(className || ''), onContextMenu: handleContextMenu, children: [children, isVisible && (_jsx("div", { ref: menuRef, className: menuClasses, style: {
283
+ return (_jsxs("div", { ref: triggerRef, className: "context-menu-trigger ".concat(className || ''), onContextMenu: handleContextMenu, children: [children, isVisible && (_jsx("div", { ref: menuRef, style: {
242
284
  position: 'fixed',
243
285
  left: "".concat(menuPosition.x, "px"),
244
286
  top: "".concat(menuPosition.y, "px"),
245
- zIndex: 9999,
246
- }, role: "menu", children: _jsx("ul", { className: "context-menu-list context-menu-list-".concat(theme), children: options.map(function (item, index) {
247
- if (item === 'divider') {
248
- return (_jsx("li", { className: "context-menu-divider context-menu-divider-".concat(theme) }, "divider-".concat(index.toString())));
249
- }
250
- return (_jsxs("li", { className: itemClasses(item), onClick: function () { return handleItemClick(item); }, onKeyDown: function (e) {
251
- if (e.key === 'Enter' || e.key === ' ') {
252
- e.preventDefault();
253
- handleItemClick(item);
254
- }
255
- }, role: "menuitem", tabIndex: item.disabled ? -1 : 0, "aria-disabled": item.disabled, children: [item.icon && _jsx("span", { className: "context-menu-icon context-menu-icon-".concat(theme), children: item.icon }), _jsx("span", { className: "context-menu-text context-menu-text-".concat(theme), children: item.label }), item.shortcut && (_jsx("span", { className: "context-menu-shortcut context-menu-shortcut-".concat(theme), children: item.shortcut }))] }, item.key || index));
256
- }) }) }))] }));
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
+ }) }) }) }))] }));
257
299
  };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import 'nprogress/nprogress.css';
2
+ import './app.css';
2
3
  import { ReactHooksWrapper, getHook, setHook } from "./chunk1415/chunk143";
3
4
  import { DynamicLoader, AlertMessage, FilePreview, LabeledValue, DetailsCard, UploadFile, DownloadFile, ContextMenuWrapper } from './chunk1516/chunk613852';
4
5
  import { FileSkeleton, TableSkeleton, PieChartSkeleton, CardSkeleton, LineChartSkeleton, FieldSkeleton } from './chunk1617/chunk613555';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import 'nprogress/nprogress.css';
2
+ import './app.css';
2
3
  import { ReactHooksWrapper, getHook, setHook } from "./chunk1415/chunk143";
3
4
  import { DynamicLoader, AlertMessage, FilePreview, LabeledValue, DetailsCard, UploadFile, DownloadFile, ContextMenuWrapper } from './chunk1516/chunk613852';
4
5
  import { FileSkeleton, TableSkeleton, PieChartSkeleton, CardSkeleton, LineChartSkeleton, FieldSkeleton } from './chunk1617/chunk613555';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-hook-toolkit",
3
- "version": "1.0.20",
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",