react-hook-toolkit 1.0.6 → 1.0.8

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/README.md CHANGED
@@ -24,8 +24,8 @@ pnpm add react-hook-toolkit
24
24
  ## Features
25
25
  Here's the properly structured documentation with clear purpose explanations:
26
26
 
27
- --------------------------------------- **HOOKS** --------------------------------------------
28
- 📌 **useAxios**
27
+ ---------------------------------------------------- **Custom Hooks** --------------------------------------------------
28
+ 📌 **useAxios**
29
29
  A custom hook for making API requests using Axios. It manages request states (`loading`, `error`, `data`) and provides a function (`makeRequest`) to initiate a request.
30
30
  ```ts
31
31
  const { data, loading, error, makeRequest, cancelRequest } = useAxios({ baseURL: '/api' });
@@ -35,6 +35,25 @@ useEffect(() => {
35
35
  }, []);
36
36
  ```
37
37
 
38
+ 📌 **useDrawer**
39
+ A custom hook for managing application drawer state. It provides control over drawer visibility (`drawerOpen`) and active menu selection (`currentMainMenu`), with methods to toggle these states.
40
+
41
+ ```tsx
42
+ const {
43
+ drawerOpen,
44
+ currentMainMenu,
45
+ openDrawer,
46
+ closeDrawer,
47
+ setCurrentMainMenu
48
+ } = useDrawer();
49
+
50
+ // Example usage:
51
+ <button onClick={openDrawer}>Open Menu</button>
52
+ <button onClick={() => setCurrentMainMenu('settings')}>
53
+ Show Settings
54
+ </button>
55
+ ```
56
+
38
57
  ---
39
58
 
40
59
  📌 **useAdvReducer**
@@ -575,8 +594,7 @@ useUpdateEffect(() => {
575
594
  }, [value]);
576
595
  ```
577
596
 
578
- --------------------------------------- **COMPONENTS** --------------------------------------------
579
- ---
597
+ ------------------------------------------------ **Custom Components** --------------------------------------------
580
598
 
581
599
  ✅ **DynamicLoader**
582
600
  A Higher-Order Component (HOC) that dynamically loads a React component using `React.lazy()` with `Suspense`, while wrapping it in an `ErrorBoundary` to handle potential errors gracefully. It ensures that the component is loaded only when needed, reducing the initial bundle size and improving performance.
@@ -586,6 +604,20 @@ import React, { lazy } from "react";
586
604
  const MyComponent = DynamicLoader(lazy(() => import("./MyComponent")));
587
605
 
588
606
  ```
607
+ ---
608
+
609
+ ✅ **FilePreview**
610
+ Displays a styled file card with an icon based on file type, filename with ellipsis handling, file size, and an optional download action.
611
+
612
+ ```tsx
613
+ <FilePreview
614
+ primaryKey="file123"
615
+ filename="example.pdf"
616
+ size="2.3 MB"
617
+ onDownload={(id) => console.log("Download:", id)}
618
+ />
619
+ ```
620
+
589
621
  ---
590
622
  ✅ **AlertMessage**
591
623
  A functional React component that displays dynamic alerts using the enqueueSnackbar function. It provides a customizable message with a specified type and duration. The alerts can be dismissed manually by clicking a close button, and they support various configurations such as position, auto-hide duration, and duplicate prevention.
@@ -595,6 +627,58 @@ A functional React component that displays dynamic alerts using the enqueueSnack
595
627
  ```
596
628
  ---
597
629
 
630
+ ### ✅ **FileSkeleton**
631
+ Displays one or more placeholder file cards mimicking the layout of file previews. Useful during file list loading.
632
+
633
+ ```tsx
634
+ <FileSkeleton
635
+ length={3}
636
+ width={350}
637
+ borderColor="#dfdfdf"
638
+ />
639
+ ```
640
+
641
+ ---
642
+
643
+ ### ✅ **TableSkeleton**
644
+ Shows a full table layout with skeleton headers and rows. Includes a toolbar area for filters or search bars.
645
+
646
+ ```tsx
647
+ <TableSkeleton
648
+ rows={6}
649
+ columns={6}
650
+ />
651
+ ```
652
+
653
+ ---
654
+
655
+ ### ✅ **LineChartSkeleton**
656
+ Represents a placeholder for a line chart with gridlines and axis lines to simulate loading of chart data.
657
+
658
+ ```tsx
659
+ <LineChartSkeleton />
660
+ ```
661
+
662
+ ---
663
+
664
+ ### ✅ **CardSkeleton**
665
+ Simulates a card layout with a title and multiple row placeholders, ideal for stat or summary cards.
666
+
667
+ ```tsx
668
+ <CardSkeleton />
669
+ ```
670
+
671
+ ---
672
+
673
+ ### ✅ **PieChartSkeleton**
674
+ Displays a skeleton placeholder for a pie chart inside a card layout. Includes a title and circular loading element.
675
+
676
+ ```tsx
677
+ <PieChartSkeleton />
678
+ ```
679
+
680
+ ---
681
+
598
682
  ✏️ **Authors**
599
683
 
600
684
  ![NPM](https://img.shields.io/badge/Author-React%20Expert-red) &nbsp; ![npm](https://img.shields.io/npm/v/react-hook-toolkit?color=1C939D) &nbsp; ![npm](https://img.shields.io/npm/dt/react-hook-toolkit) &nbsp; ![NPM](https://img.shields.io/npm/l/react-hook-toolkit) &nbsp; ![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/react-hook-toolkit)
@@ -0,0 +1,16 @@
1
+ import { FC, ReactNode } from 'react';
2
+ export interface DrawerContextValue {
3
+ drawerOpen: boolean;
4
+ openDrawer: () => void;
5
+ closeDrawer: () => void;
6
+ openDrawerInButton: () => void;
7
+ closeDrawerInButton: () => void;
8
+ currentMainMenu?: string;
9
+ setCurrentMainMenu?: (value: string) => void;
10
+ }
11
+ interface DrawerProviderProps {
12
+ children: ReactNode;
13
+ }
14
+ declare const DrawerContext: import("react").Context<DrawerContextValue>;
15
+ export declare const DrawerProvider: FC<DrawerProviderProps>;
16
+ export default DrawerContext;
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useState } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ var DrawerContext = createContext({
5
+ drawerOpen: false,
6
+ openDrawer: function () { },
7
+ closeDrawer: function () { },
8
+ openDrawerInButton: function () { },
9
+ closeDrawerInButton: function () { },
10
+ currentMainMenu: '',
11
+ setCurrentMainMenu: function () { }
12
+ });
13
+ export var DrawerProvider = function (_a) {
14
+ var children = _a.children;
15
+ var _b = useState(true), drawerOpen = _b[0], setDrawer = _b[1];
16
+ var _c = useState(''), currentMainMenu = _c[0], setCurrOpenMenu = _c[1];
17
+ var openDrawer = function () { return setDrawer(true); };
18
+ var closeDrawer = function () { return setDrawer(false); };
19
+ var openDrawerInButton = function () { return setDrawer(false); };
20
+ var closeDrawerInButton = function () { return setDrawer(true); };
21
+ var setCurrentMainMenu = function (value) { return setCurrOpenMenu(value); };
22
+ return (_jsx(DrawerContext.Provider, { value: {
23
+ drawerOpen: drawerOpen,
24
+ openDrawer: openDrawer,
25
+ closeDrawer: closeDrawer,
26
+ openDrawerInButton: openDrawerInButton,
27
+ closeDrawerInButton: closeDrawerInButton,
28
+ currentMainMenu: currentMainMenu,
29
+ setCurrentMainMenu: setCurrentMainMenu
30
+ }, children: children }));
31
+ };
32
+ DrawerProvider.propTypes = {
33
+ children: PropTypes.node.isRequired
34
+ };
35
+ export default DrawerContext;
@@ -14,6 +14,7 @@ interface UseAxiosConfig extends AxiosRequestConfig {
14
14
  };
15
15
  }
16
16
  export declare const useAxios: <T>(config?: UseAxiosConfig) => UseAxiosResponse<T>;
17
+ export declare const useDrawer: () => import("../contexts/DrowerContexts").DrawerContextValue;
17
18
  export declare const useAdvReducer: <State, Action extends {
18
19
  type: string;
19
20
  }>(initialState: State, actions: Record<string, (state: State, action: Action) => State>) => (state: State | undefined, action: Action) => State;
@@ -54,8 +54,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
54
54
  }
55
55
  return to.concat(ar || Array.prototype.slice.call(from));
56
56
  };
57
- import { useState, useEffect, useCallback, useRef } from 'react';
57
+ import { useState, useEffect, useCallback, useRef, useContext } from 'react';
58
58
  import axios, { AxiosError } from 'axios';
59
+ import DrawerContext from '../contexts/DrowerContexts';
59
60
  var isReady = function () {
60
61
  return typeof window !== "undefined" && typeof window.document !== "undefined"
61
62
  ? true
@@ -130,6 +131,13 @@ export var useAxios = function (config) {
130
131
  cancelRequest: cancelRequest,
131
132
  };
132
133
  };
134
+ export var useDrawer = function () {
135
+ var context = useContext(DrawerContext);
136
+ if (context === undefined) {
137
+ throw new Error('useDrawer must be used within a DrawerProvider');
138
+ }
139
+ return context;
140
+ };
133
141
  export var useAdvReducer = function (initialState, actions) { return function (state, action) {
134
142
  if (state === void 0) { state = initialState; }
135
143
  if (actions[action.type]) {
@@ -6,4 +6,14 @@ interface PropsType {
6
6
  duration?: number;
7
7
  }
8
8
  export declare const AlertMessage: FC<PropsType>;
9
- export default AlertMessage;
9
+ interface FileComponentProps {
10
+ primaryKey: string | number;
11
+ filename: string;
12
+ size: string | number;
13
+ onDownload?: any;
14
+ width?: number;
15
+ borderColor?: string;
16
+ fileColor?: 'inherit' | 'primary' | 'secondary' | 'error' | 'disabled' | 'action';
17
+ }
18
+ export declare const FilePreview: ({ primaryKey, filename, size, onDownload, width, borderColor, fileColor, }: FileComponentProps) => import("react/jsx-runtime").JSX.Element;
19
+ export {};
@@ -11,8 +11,8 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { useEffect, useCallback, useRef, Suspense } from 'react';
14
- import { Box, Alert, AlertTitle, IconButton } from '@mui/material';
15
- import { Close } from '@mui/icons-material';
14
+ import { Box, Alert, AlertTitle, IconButton, CardContent, Tooltip, Typography, Card, } from '@mui/material';
15
+ import { Close, InsertDriveFile, Image, Description, Download } from '@mui/icons-material';
16
16
  import NProgress from 'nprogress';
17
17
  import { ErrorBoundary } from 'react-error-boundary';
18
18
  import { promise } from '../utils';
@@ -71,4 +71,49 @@ export var AlertMessage = function (_a) {
71
71
  }
72
72
  return null;
73
73
  };
74
- export default AlertMessage;
74
+ export var FilePreview = function (_a) {
75
+ var primaryKey = _a.primaryKey, filename = _a.filename, size = _a.size, _b = _a.onDownload, onDownload = _b === void 0 ? undefined : _b, _c = _a.width, width = _c === void 0 ? 350 : _c, _d = _a.borderColor, borderColor = _d === void 0 ? '#dfdfdf' : _d, _e = _a.fileColor, fileColor = _e === void 0 ? 'primary' : _e;
76
+ // Icon mapping configuration
77
+ var iconMap = {
78
+ pdf: _jsx(InsertDriveFile, { fontSize: "large", color: fileColor }),
79
+ image: _jsx(Image, { fontSize: "large", color: fileColor }),
80
+ doc: _jsx(Description, { fontSize: "large", color: fileColor }),
81
+ default: _jsx(Description, { fontSize: "large", color: fileColor }),
82
+ };
83
+ // Determine file type from filename extension
84
+ var getFileType = function (filenames) {
85
+ var extension = filenames.split('.').pop().toLowerCase();
86
+ if (['pdf'].includes(extension))
87
+ return 'pdf';
88
+ if (['jpg', 'jpeg', 'png', 'gif'].includes(extension))
89
+ return 'image';
90
+ if (['doc', 'docx', 'txt'].includes(extension))
91
+ return 'doc';
92
+ return 'default';
93
+ };
94
+ return (_jsx(Card, { variant: "outlined", sx: {
95
+ maxWidth: width,
96
+ minWidth: width,
97
+ border: "1px solid ".concat(borderColor),
98
+ borderRadius: 1,
99
+ '&:hover': { boxShadow: 2 },
100
+ marginLeft: 1,
101
+ }, children: _jsxs(CardContent, { sx: {
102
+ display: 'flex',
103
+ alignItems: 'center',
104
+ gap: 2,
105
+ padding: '8px !important',
106
+ }, children: [iconMap[getFileType(filename)], _jsxs(Box, { sx: { flexGrow: 1 }, children: [filename.length > 33 ? (_jsx(Tooltip, { title: filename, placement: "top", arrow: true, children: _jsx(Typography, { sx: {
107
+ fontSize: '14px',
108
+ whiteSpace: 'nowrap',
109
+ overflow: 'hidden',
110
+ textOverflow: 'ellipsis',
111
+ maxWidth: width - 120,
112
+ }, variant: "body1", fontWeight: "medium", children: filename }) })) : (_jsx(Typography, { sx: {
113
+ fontSize: '14px',
114
+ whiteSpace: 'nowrap',
115
+ overflow: 'hidden',
116
+ textOverflow: 'ellipsis',
117
+ maxWidth: width - 120,
118
+ }, children: filename })), _jsx(Typography, { variant: "caption", color: "text.secondary", children: size })] }), _jsx(IconButton, { disabled: onDownload === undefined, "aria-label": "download", onClick: function () { return onDownload(primaryKey); }, sx: { color: '#dfdfdf', '&:hover': { color: 'primary.main' } }, children: _jsx(Download, { fontSize: "small", color: "primary" }) })] }) }));
119
+ };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import 'nprogress/nprogress.css';
2
2
  import { ReactHooksWrapper, getHook, setHook } from "./hookExecuter/hookExecuter";
3
- import { DynamicLoader, AlertMessage } from './hooks/hooksComp';
3
+ import { DynamicLoader, AlertMessage, FilePreview } from './hooks/hooksComp';
4
+ import { FileSkeleton, TableSkeleton, PieChartSkeleton, CardSkeleton, LineChartSkeleton, FieldSkeleton } from './skeletons/skeletons';
4
5
  import { useAxios, useAdvReducer, useFetch, useLocalStorage, useToggle, useDebounce, useThrottle, usePrevious, useMediaQuery, useClipboard, useInterval, useWindowSize, useKeyPress, useOnlineStatus, useScrollPosition, useTimeout, useDarkMode, useForm, useArray, useStepper, useUpdateEffect, useTouch, useSound, useSessionStorage, usePreferredLanguage, useHistory, useEventListener, useBattery, useDebouncedCallback, useScrollLock, useResizeObserver, useMousePosition, useScrollDirection, useImageLoader, usePersistedState, useReducedMotion, useCookie, useFetchRetry, useDelay, useVisibilityChange, useDebouncedValue, useAsync, useScript, useIndexedDB, useGeoLocation, useTimer, useIsMounted, useCss, useSpeak, useCountUp, useCountDown } from './hooks/hooks';
5
6
  export default ReactHooksWrapper;
6
- export { getHook, setHook, useAxios, useAdvReducer, useFetch, useLocalStorage, useToggle, useDebounce, useThrottle, usePrevious, useMediaQuery, useClipboard, useInterval, useWindowSize, useKeyPress, useOnlineStatus, useScrollPosition, useTimeout, useDarkMode, useForm, useArray, useStepper, useUpdateEffect, useTouch, useSound, useSessionStorage, usePreferredLanguage, useHistory, useEventListener, useBattery, useDebouncedCallback, useScrollLock, useResizeObserver, useMousePosition, useScrollDirection, useImageLoader, usePersistedState, useReducedMotion, useCookie, useFetchRetry, useDelay, useVisibilityChange, useDebouncedValue, useAsync, useScript, useIndexedDB, useGeoLocation, useTimer, useIsMounted, useCss, useSpeak, useCountUp, useCountDown, DynamicLoader, AlertMessage };
7
+ export { getHook, setHook, useAxios, useAdvReducer, useFetch, useLocalStorage, useToggle, useDebounce, useThrottle, usePrevious, useMediaQuery, useClipboard, useInterval, useWindowSize, useKeyPress, useOnlineStatus, useScrollPosition, useTimeout, useDarkMode, useForm, useArray, useStepper, useUpdateEffect, useTouch, useSound, useSessionStorage, usePreferredLanguage, useHistory, useEventListener, useBattery, useDebouncedCallback, useScrollLock, useResizeObserver, useMousePosition, useScrollDirection, useImageLoader, usePersistedState, useReducedMotion, useCookie, useFetchRetry, useDelay, useVisibilityChange, useDebouncedValue, useAsync, useScript, useIndexedDB, useGeoLocation, useTimer, useIsMounted, useCss, useSpeak, useCountUp, useCountDown, DynamicLoader, AlertMessage, FilePreview, FileSkeleton, TableSkeleton, PieChartSkeleton, CardSkeleton, LineChartSkeleton, FieldSkeleton };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import 'nprogress/nprogress.css';
2
2
  import { ReactHooksWrapper, getHook, setHook } from "./hookExecuter/hookExecuter";
3
- import { DynamicLoader, AlertMessage } from './hooks/hooksComp';
3
+ import { DynamicLoader, AlertMessage, FilePreview, } from './hooks/hooksComp';
4
+ import { FileSkeleton, TableSkeleton, PieChartSkeleton, CardSkeleton, LineChartSkeleton, FieldSkeleton } from './skeletons/skeletons';
4
5
  import { useAxios, useAdvReducer, useFetch, useLocalStorage, useToggle, useDebounce, useThrottle, usePrevious, useMediaQuery, useClipboard, useInterval, useWindowSize, useKeyPress, useOnlineStatus, useScrollPosition, useTimeout, useDarkMode, useForm, useArray, useStepper, useUpdateEffect, useTouch, useSound, useSessionStorage, usePreferredLanguage, useHistory, useEventListener, useBattery, useDebouncedCallback, useScrollLock, useResizeObserver, useMousePosition, useScrollDirection, useImageLoader, usePersistedState, useReducedMotion, useCookie, useFetchRetry, useDelay, useVisibilityChange, useDebouncedValue, useAsync, useScript, useIndexedDB, useGeoLocation, useTimer, useIsMounted, useCss, useSpeak, useCountUp, useCountDown, } from './hooks/hooks';
5
6
  export default ReactHooksWrapper;
6
- export { getHook, setHook, useAxios, useAdvReducer, useFetch, useLocalStorage, useToggle, useDebounce, useThrottle, usePrevious, useMediaQuery, useClipboard, useInterval, useWindowSize, useKeyPress, useOnlineStatus, useScrollPosition, useTimeout, useDarkMode, useForm, useArray, useStepper, useUpdateEffect, useTouch, useSound, useSessionStorage, usePreferredLanguage, useHistory, useEventListener, useBattery, useDebouncedCallback, useScrollLock, useResizeObserver, useMousePosition, useScrollDirection, useImageLoader, usePersistedState, useReducedMotion, useCookie, useFetchRetry, useDelay, useVisibilityChange, useDebouncedValue, useAsync, useScript, useIndexedDB, useGeoLocation, useTimer, useIsMounted, useCss, useSpeak, useCountUp, useCountDown, DynamicLoader, AlertMessage };
7
+ export { getHook, setHook, useAxios, useAdvReducer, useFetch, useLocalStorage, useToggle, useDebounce, useThrottle, usePrevious, useMediaQuery, useClipboard, useInterval, useWindowSize, useKeyPress, useOnlineStatus, useScrollPosition, useTimeout, useDarkMode, useForm, useArray, useStepper, useUpdateEffect, useTouch, useSound, useSessionStorage, usePreferredLanguage, useHistory, useEventListener, useBattery, useDebouncedCallback, useScrollLock, useResizeObserver, useMousePosition, useScrollDirection, useImageLoader, usePersistedState, useReducedMotion, useCookie, useFetchRetry, useDelay, useVisibilityChange, useDebouncedValue, useAsync, useScript, useIndexedDB, useGeoLocation, useTimer, useIsMounted, useCss, useSpeak, useCountUp, useCountDown, DynamicLoader, AlertMessage, FilePreview, FileSkeleton, TableSkeleton, PieChartSkeleton, CardSkeleton, LineChartSkeleton, FieldSkeleton };
@@ -0,0 +1,19 @@
1
+ export declare const FileSkeleton: ({ length, width, borderColor }: {
2
+ length?: number | undefined;
3
+ width?: number | undefined;
4
+ borderColor?: string | undefined;
5
+ }) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const TableSkeleton: ({ rows, columns }: {
7
+ rows?: number | undefined;
8
+ columns?: number | undefined;
9
+ }) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const LineChartSkeleton: () => import("react/jsx-runtime").JSX.Element;
11
+ export declare const CardSkeleton: () => import("react/jsx-runtime").JSX.Element;
12
+ export declare const PieChartSkeleton: React.FC;
13
+ export declare const FieldSkeleton: ({ length, width, spacing, isLabel, itemsPerRow, }: {
14
+ length?: number | undefined;
15
+ width?: string | undefined;
16
+ spacing?: number | undefined;
17
+ isLabel?: boolean | undefined;
18
+ itemsPerRow?: number | undefined;
19
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,94 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Box, Card, CardContent, CardHeader, Grid, IconButton, Skeleton, Table, TableBody, TableCell, TableHead, TableRow, Toolbar, Tooltip, } from "@mui/material";
3
+ import { Download } from "@mui/icons-material";
4
+ export var FileSkeleton = function (_a) {
5
+ var _b = _a.length, length = _b === void 0 ? 1 : _b, _c = _a.width, width = _c === void 0 ? 350 : _c, _d = _a.borderColor, borderColor = _d === void 0 ? '#dfdfdf' : _d;
6
+ return (_jsx(Grid, { container: true, spacing: 2, children: Array.from({ length: length }).map(function (_, index) { return (_jsx(Grid, { item: true, children: _jsx(Card, { variant: "outlined", sx: {
7
+ maxWidth: width,
8
+ minWidth: width,
9
+ border: "1px solid ".concat(borderColor),
10
+ borderRadius: 1,
11
+ '&:hover': { boxShadow: 2 },
12
+ marginLeft: 3,
13
+ }, children: _jsxs(CardContent, { sx: {
14
+ display: 'flex',
15
+ alignItems: 'center',
16
+ gap: 2,
17
+ padding: '8px !important',
18
+ }, children: [_jsx(Skeleton, { variant: "rectangular", width: 50, height: 40 }), _jsxs(Box, { sx: { flexGrow: 1 }, children: [_jsx(Skeleton, { variant: "text", width: width - 120, height: 20 }), _jsx(Skeleton, { variant: "text", width: 60, height: 14 })] }), _jsx(IconButton, { disabled: true, sx: { color: '#dfdfdf' }, children: _jsx(Download, { fontSize: "small", color: "disabled" }) })] }) }) }, index.toString())); }) }));
19
+ };
20
+ export var TableSkeleton = function (_a) {
21
+ var _b = _a.rows, rows = _b === void 0 ? 6 : _b, _c = _a.columns, columns = _c === void 0 ? 6 : _c;
22
+ return (_jsxs(Box, { sx: { width: '100%', overflowX: 'auto' }, children: [_jsxs(Toolbar, { sx: {
23
+ display: 'flex',
24
+ justifyContent: 'space-between',
25
+ p: 1,
26
+ borderBottom: '1px solid #dbdbdb',
27
+ }, children: [_jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: _jsx(Skeleton, { variant: "rectangular", width: 200, height: 40 }) }), _jsx(Box, { children: _jsx(Tooltip, { title: "Filter", children: _jsx(IconButton, { children: _jsx(Skeleton, { variant: "circular", width: 40, height: 40 }) }) }) })] }), _jsxs(Table, { "aria-label": "loading table", children: [_jsx(TableHead, { children: _jsx(TableRow, { children: Array.from({ length: columns }).map(function (_, index) { return (_jsx(TableCell, { children: _jsx(Skeleton, { variant: "rectangular", height: 20 }) }, "head-".concat(index))); }) }) }), _jsx(TableBody, { children: Array.from({ length: rows }).map(function (_, rowIndex) { return (_jsx(TableRow, { children: Array.from({ length: columns }).map(function (_, colIndex) { return (_jsx(TableCell, { children: _jsx(Skeleton, { animation: "wave", variant: "text", width: "100%" }) }, "cell-".concat(rowIndex, "-").concat(colIndex))); }) }, "row-".concat(rowIndex))); }) })] })] }));
28
+ };
29
+ export var LineChartSkeleton = function () {
30
+ return (_jsxs(Box, { sx: { width: '100%', height: '300px', position: 'relative', padding: '16px' }, children: [_jsx(Skeleton, { variant: "text", width: "30%", height: 30, sx: { position: 'absolute', top: 10, left: '50%', transform: 'translateX(-50%)' } }), _jsx(Skeleton, { variant: "rectangular", width: "calc(100% - 40px)", height: 4, sx: { position: 'absolute', bottom: 40, left: 20 } }), _jsx(Skeleton, { variant: "rectangular", width: 2, height: "calc(100% - 40px)", sx: { position: 'absolute', top: 0, bottom: 40, left: 20 } }), _jsx(Skeleton, { variant: "rectangular", width: 2, height: "calc(100% - 40px)", sx: { position: 'absolute', top: 0, bottom: 40, right: 20 } }), [1, 2, 3, 4].map(function (_, index) { return (_jsx(Skeleton, { variant: "rectangular", width: "calc(100% - 40px)", height: 4, sx: { position: 'absolute', bottom: "".concat(40 + index * 50, "px"), left: '20px' } }, index.toString())); }), _jsx(Skeleton, { variant: "rectangular", width: "calc(100% - 40px)", height: 2, sx: {
31
+ position: 'absolute',
32
+ left: '20px',
33
+ top: '85%',
34
+ transform: 'rotate(-7deg)',
35
+ transformOrigin: 'left center',
36
+ } })] }));
37
+ };
38
+ export var CardSkeleton = function () {
39
+ var skeletonStyles = {
40
+ boxShadow: '0px 1px 8px -2px #444444de',
41
+ borderRadius: '10px',
42
+ overflow: 'hidden',
43
+ padding: '12px',
44
+ transition: '0.3s',
45
+ background: 'linear-gradient(to top left, #fff 20%, #f5f5f5 80%)',
46
+ width: {
47
+ xs: '90%',
48
+ sm: '70%',
49
+ md: '150%',
50
+ lg: '195%',
51
+ xl: '200%',
52
+ },
53
+ maxWidth: '600px',
54
+ };
55
+ return (_jsx(Grid, { item: true, xs: 12, sm: 6, md: 6, children: _jsxs(Box, { sx: skeletonStyles, children: [_jsx(Skeleton, { variant: "rectangular", width: "100%", height: 30, sx: { marginBottom: '12px', borderRadius: '4px', background: 'linear-gradient(to left, #e0e0e0 10%, #cfcfcf 100%)', } }), _jsx(Box, { children: Array.from(new Array(4)).map(function (__, index) { return (_jsxs(Box, { sx: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: index !== 3 ? 1 : 0, }, children: [_jsx(Skeleton, { variant: "text", width: "70%", height: 20 }), _jsx(Skeleton, { variant: "text", width: "20%", height: 20 })] }, index.toString())); }) })] }) }));
56
+ };
57
+ export var PieChartSkeleton = function () {
58
+ return (_jsxs(_Fragment, { children: [_jsx(Grid, { item: true, xs: 12, sm: 6, md: 6, lg: 6, sx: { padding: '10px' }, children: _jsxs(Card, { sx: {
59
+ borderRadius: '6px',
60
+ height: '100%',
61
+ display: 'flex',
62
+ flexDirection: 'column',
63
+ justifyContent: 'space-between',
64
+ cursor: 'default',
65
+ }, children: [_jsx(CardHeader, { title: (_jsx(Skeleton, { variant: "rectangular", width: "80%", height: "20px", sx: { margin: '0 auto', borderRadius: '4px' } })), sx: {
66
+ background: '#dbe7f2',
67
+ padding: '8px',
68
+ } }), _jsx(CardContent, { sx: {
69
+ display: 'flex',
70
+ justifyContent: 'center',
71
+ alignItems: 'center',
72
+ height: '320px',
73
+ }, children: _jsx(Skeleton, { variant: "circular", width: 200, height: 200, sx: { marginBottom: '16px' } }) })] }) }), _jsx(Grid, { item: true, xs: 12, sm: 6, md: 6, lg: 6, sx: { padding: '10px' }, children: _jsxs(Card, { sx: {
74
+ borderRadius: '6px',
75
+ height: '100%',
76
+ display: 'flex',
77
+ flexDirection: 'column',
78
+ justifyContent: 'space-between',
79
+ cursor: 'default',
80
+ }, children: [_jsx(CardHeader, { title: (_jsx(Skeleton, { variant: "rectangular", width: "80%", height: "20px", sx: { margin: '0 auto', borderRadius: '4px' } })), sx: {
81
+ background: '#dbe7f2',
82
+ padding: '8px',
83
+ } }), _jsx(CardContent, { sx: {
84
+ display: 'flex',
85
+ justifyContent: 'center',
86
+ alignItems: 'center',
87
+ height: '320px',
88
+ }, children: _jsx(Skeleton, { variant: "circular", width: 200, height: 200, sx: { marginBottom: '16px' } }) })] }) })] }));
89
+ };
90
+ export var FieldSkeleton = function (_a) {
91
+ var _b = _a.length, length = _b === void 0 ? 1 : _b, _c = _a.width, width = _c === void 0 ? '100%' : _c, _d = _a.spacing, spacing = _d === void 0 ? 2 : _d, _e = _a.isLabel, isLabel = _e === void 0 ? false : _e, _f = _a.itemsPerRow, itemsPerRow = _f === void 0 ? 2 : _f;
92
+ var columnSize = Math.floor(12 / itemsPerRow);
93
+ return (_jsx(Grid, { container: true, spacing: spacing, children: Array.from({ length: length }).map(function (_, index) { return (_jsx(Grid, { item: true, xs: 12, sm: columnSize, children: _jsxs(Box, { sx: { width: '100%', margin: 2 }, children: [isLabel && _jsx(Skeleton, { variant: "text", width: "40%", height: 20, sx: { marginBottom: 1 } }), _jsx(Skeleton, { variant: "rectangular", width: width, height: 40, sx: { borderRadius: 1 } })] }) }, index.toString())); }) }));
94
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-hook-toolkit",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
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",