react-hook-toolkit 1.0.8 → 1.0.10
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 +28 -2
- package/dist/hooks/hooksComp.d.ts +9 -0
- package/dist/hooks/hooksComp.js +12 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,8 +24,9 @@ pnpm add react-hook-toolkit
|
|
|
24
24
|
## Features
|
|
25
25
|
Here's the properly structured documentation with clear purpose explanations:
|
|
26
26
|
|
|
27
|
-
---------------------------------------------------- **Custom Hooks**
|
|
28
|
-
|
|
27
|
+
---------------------------------------------------- **Custom Hooks** ------------------------------------------------
|
|
28
|
+
|
|
29
|
+
📌 **useAxios**
|
|
29
30
|
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
31
|
```ts
|
|
31
32
|
const { data, loading, error, makeRequest, cancelRequest } = useAxios({ baseURL: '/api' });
|
|
@@ -617,6 +618,31 @@ Displays a styled file card with an icon based on file type, filename with ellip
|
|
|
617
618
|
onDownload={(id) => console.log("Download:", id)}
|
|
618
619
|
/>
|
|
619
620
|
```
|
|
621
|
+
---
|
|
622
|
+
|
|
623
|
+
### ✅ **LabeledValue**
|
|
624
|
+
Displays a simple key-value label pair in a single line, with optional styling.
|
|
625
|
+
|
|
626
|
+
```tsx
|
|
627
|
+
<LabeledValue
|
|
628
|
+
label="Name"
|
|
629
|
+
value="ABC"
|
|
630
|
+
/>
|
|
631
|
+
```
|
|
632
|
+
---
|
|
633
|
+
|
|
634
|
+
### ✅ **DetailsCard**
|
|
635
|
+
Renders a card with a title and grid-based layout of labeled values. It supports custom spacing, responsive behavior, and optional card shadow.
|
|
636
|
+
|
|
637
|
+
```tsx
|
|
638
|
+
<DetailsCard
|
|
639
|
+
title="Details"
|
|
640
|
+
spacing={2}
|
|
641
|
+
details={[
|
|
642
|
+
{ label: 'Name', value: 'XYZ' },
|
|
643
|
+
]}
|
|
644
|
+
/>
|
|
645
|
+
```
|
|
620
646
|
|
|
621
647
|
---
|
|
622
648
|
✅ **AlertMessage**
|
|
@@ -6,6 +6,15 @@ interface PropsType {
|
|
|
6
6
|
duration?: number;
|
|
7
7
|
}
|
|
8
8
|
export declare const AlertMessage: FC<PropsType>;
|
|
9
|
+
interface DetailsCardProps {
|
|
10
|
+
title: string;
|
|
11
|
+
details: any;
|
|
12
|
+
spacing?: number;
|
|
13
|
+
boxShadow?: string;
|
|
14
|
+
background?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const DetailsCard: ({ title, details, spacing, boxShadow, background, }: DetailsCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const LabeledValue: ({ label, value, style }: any) => import("react/jsx-runtime").JSX.Element;
|
|
9
18
|
interface FileComponentProps {
|
|
10
19
|
primaryKey: string | number;
|
|
11
20
|
filename: string;
|
package/dist/hooks/hooksComp.js
CHANGED
|
@@ -9,14 +9,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
13
|
import { useEffect, useCallback, useRef, Suspense } from 'react';
|
|
14
|
-
import { Box, Alert, AlertTitle, IconButton, CardContent, Tooltip, Typography, Card, } from '@mui/material';
|
|
14
|
+
import { Box, Alert, AlertTitle, IconButton, CardContent, Tooltip, Typography, Card, Grid, } from '@mui/material';
|
|
15
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';
|
|
19
19
|
import { getHook } from '../hookExecuter/hookExecuter';
|
|
20
|
+
import { useWindowSize } from './hooks';
|
|
20
21
|
function Fallback(_a) {
|
|
21
22
|
var error = _a.error;
|
|
22
23
|
return (_jsxs(Box, { sx: { padding: 2 }, children: [process.env.NODE_ENV === 'production' && (_jsxs(Alert, { sx: { py: 0, borderLeft: '2px solid #00abff !important', border: '1px solid #d0cfcf' }, severity: "info", children: [_jsx(AlertTitle, { children: "Page Loading Error" }), "Please check your network connection..."] })), process.env.NODE_ENV !== 'production' && (_jsxs(Alert, { severity: "error", sx: { py: 0, borderTop: '2px solid #791212ad !important', border: '1px solid #d0cfcf' }, children: [_jsx(AlertTitle, { children: "Error" }), error.message] }))] }));
|
|
@@ -71,6 +72,15 @@ export var AlertMessage = function (_a) {
|
|
|
71
72
|
}
|
|
72
73
|
return null;
|
|
73
74
|
};
|
|
75
|
+
export var DetailsCard = function (_a) {
|
|
76
|
+
var title = _a.title, details = _a.details, _b = _a.spacing, spacing = _b === void 0 ? 2 : _b, _c = _a.boxShadow, boxShadow = _c === void 0 ? '0px 0px 2px 2px #d8d8d8' : _c, _d = _a.background, background = _d === void 0 ? '#eee' : _d;
|
|
77
|
+
var width = useWindowSize().width;
|
|
78
|
+
return (_jsx(Card, { sx: { boxShadow: boxShadow }, children: _jsxs(CardContent, { children: [_jsx(Typography, { variant: "h6", sx: { background: background, padding: '4px' }, children: title }), _jsx(Grid, { container: true, spacing: spacing, sx: { mt: 1 }, children: details.filter(Boolean).map(function (item, index) { return (_jsxs(Grid, { item: true, xs: 12, sm: 6, md: 6, lg: width < 1367 ? 6 : 4, children: [_jsxs(Typography, { fontWeight: "bold", component: "span", sx: { fontSize: '14px' }, children: [item === null || item === void 0 ? void 0 : item.label, ": \u00A0"] }), _jsx(Typography, { component: "span", sx: { fontSize: '14px' }, children: (item === null || item === void 0 ? void 0 : item.value) || 'N/A' })] }, index.toString())); }) })] }) }));
|
|
79
|
+
};
|
|
80
|
+
export var LabeledValue = function (_a) {
|
|
81
|
+
var label = _a.label, value = _a.value, _b = _a.style, style = _b === void 0 ? undefined : _b;
|
|
82
|
+
return (_jsx(_Fragment, { children: _jsx(Typography, { sx: style !== null && style !== void 0 ? style : { padding: '5px' }, children: _jsxs("span", { style: { fontSize: '13px' }, children: [_jsxs("b", { children: [label, " "] }), ": ", value !== null && value !== void 0 ? value : 'N/A'] }) }) }));
|
|
83
|
+
};
|
|
74
84
|
export var FilePreview = function (_a) {
|
|
75
85
|
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
86
|
// Icon mapping configuration
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'nprogress/nprogress.css';
|
|
2
2
|
import { ReactHooksWrapper, getHook, setHook } from "./hookExecuter/hookExecuter";
|
|
3
|
-
import { DynamicLoader, AlertMessage, FilePreview } from './hooks/hooksComp';
|
|
3
|
+
import { DynamicLoader, AlertMessage, FilePreview, LabeledValue, DetailsCard } from './hooks/hooksComp';
|
|
4
4
|
import { FileSkeleton, TableSkeleton, PieChartSkeleton, CardSkeleton, LineChartSkeleton, FieldSkeleton } from './skeletons/skeletons';
|
|
5
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';
|
|
6
6
|
export default ReactHooksWrapper;
|
|
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 };
|
|
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, LabeledValue, DetailsCard };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'nprogress/nprogress.css';
|
|
2
2
|
import { ReactHooksWrapper, getHook, setHook } from "./hookExecuter/hookExecuter";
|
|
3
|
-
import { DynamicLoader, AlertMessage, FilePreview, } from './hooks/hooksComp';
|
|
3
|
+
import { DynamicLoader, AlertMessage, FilePreview, LabeledValue, DetailsCard } from './hooks/hooksComp';
|
|
4
4
|
import { FileSkeleton, TableSkeleton, PieChartSkeleton, CardSkeleton, LineChartSkeleton, FieldSkeleton } from './skeletons/skeletons';
|
|
5
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';
|
|
6
6
|
export default ReactHooksWrapper;
|
|
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 };
|
|
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, LabeledValue, DetailsCard };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-hook-toolkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
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",
|