@cripty2001/utils 0.0.248 → 0.0.249

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.
@@ -3,5 +3,6 @@ export type ButtonProps = {
3
3
  children: React.ReactElement;
4
4
  className?: string;
5
5
  onError?: (error: unknown) => void;
6
+ loader?: React.ReactElement;
6
7
  };
7
- export default function Button({ onClick, children, className, onError }: ButtonProps): import("react").JSX.Element;
8
+ export default function Button({ onClick, children, className, onError, loader }: ButtonProps): import("react").JSX.Element;
@@ -4,7 +4,12 @@ exports.default = Button;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const lucide_react_1 = require("lucide-react");
6
6
  const react_1 = require("react");
7
- function Button({ onClick, children, className, onError }) {
7
+ function Button({ onClick, children, className, onError, loader }) {
8
+ const Loader = loader ?? (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { style: {
9
+ width: '1rem',
10
+ height: '1rem',
11
+ animation: 'spin 1s linear infinite',
12
+ } });
8
13
  const [loading, setLoading] = (0, react_1.useState)(false);
9
14
  const [error, setError] = (0, react_1.useState)(null);
10
15
  const handleClick = async () => {
@@ -33,11 +38,7 @@ function Button({ onClick, children, className, onError }) {
33
38
  textAlign: 'center',
34
39
  cursor: 'pointer',
35
40
  }, children: loading ?
36
- (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { style: {
37
- width: '1rem',
38
- height: '1rem',
39
- animation: 'spin 1s linear infinite',
40
- } }) :
41
+ Loader :
41
42
  children }), error && (0, jsx_runtime_1.jsx)("div", { style: {
42
43
  color: '#ef4444'
43
44
  }, children: error })] }) }));
@@ -211,7 +211,7 @@ function useAsyncPeriodic(data, interval, f) {
211
211
  const bundle = (0, react_1.useMemo)(() => {
212
212
  return {
213
213
  data,
214
- interval
214
+ timer
215
215
  };
216
216
  }, [data, timer]);
217
217
  return useAsync((i, p, s) => f(i.data, p, s), bundle);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.248",
3
+ "version": "0.0.249",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {