@maskingtech/react-toolkit 0.0.3 → 0.0.4

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/dist/mtreact.d.ts CHANGED
@@ -19,6 +19,8 @@ export declare class ErrorBoundary extends Component<Props, State> {
19
19
  render(): ReactNode;
20
20
  }
21
21
 
22
+ declare type FormContentElement = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
23
+
22
24
  declare type FormRef = RefObject<HTMLFormElement | null>;
23
25
 
24
26
  declare type FormRef_2 = RefObject<HTMLFormElement | null>;
@@ -44,9 +46,9 @@ declare type SubmitHandler = (data: FormData) => Promise<void>;
44
46
 
45
47
  export declare function useDebouncedValue<T>(initialValue: T, onChange?: ChangeHandler<T>, delay?: number): readonly [T, Dispatch<SetStateAction<T>>];
46
48
 
47
- export declare function useFocusOnMount(ref?: RefObject<HTMLFormElement>): RefObject<HTMLFormElement>;
49
+ export declare function useFocusOnMount(ref?: RefObject<FormContentElement | null>): RefObject<FormContentElement>;
48
50
 
49
- export declare function useForm(submitData: SubmitHandler, ref?: FormRef): readonly [RefObject<HTMLFormElement>, States, () => Promise<void>];
51
+ export declare function useForm(submitData: SubmitHandler, ref?: FormRef): readonly [FormRef, States, () => Promise<void>];
50
52
 
51
53
  export declare function useFormData(handler: DataHandler, ref?: FormRef_2): readonly [RefObject<HTMLFormElement>, States_2, () => Promise<void>];
52
54
 
package/dist/mtreact.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as b } from "react/jsx-runtime";
2
- import { Component as V, useState as i, useEffect as m, useRef as w, useCallback as c } from "react";
2
+ import { Component as V, useState as c, useEffect as m, useRef as w, useCallback as p } from "react";
3
3
  class j extends V {
4
4
  #t = (t) => {
5
5
  this.setState({ error: t.reason }), t.preventDefault();
@@ -25,10 +25,10 @@ class j extends V {
25
25
  }
26
26
  }
27
27
  function k(n, t, e = 500) {
28
- const [a, u] = i(n), [s, r] = i(n);
28
+ const [a, u] = c(n), [s, o] = c(n);
29
29
  return m(() => {
30
- const l = setTimeout(() => r(a), e);
31
- return () => clearTimeout(l);
30
+ const i = setTimeout(() => o(a), e);
31
+ return () => clearTimeout(i);
32
32
  }, [a, e]), m(() => {
33
33
  t !== void 0 && t(s);
34
34
  }, [s, t]), [s, u];
@@ -40,78 +40,79 @@ function I(n) {
40
40
  }, [t]), t;
41
41
  }
42
42
  function A(n, t) {
43
- const e = t ?? w(null), [a, u] = i(new FormData()), [s, r] = i("pristine"), l = c(() => {
44
- const o = e.current;
45
- o !== null && (u(new FormData(o)), r("pristine"));
46
- }, [e]), d = c(() => {
47
- const o = e.current;
48
- if (o === null) return;
49
- const f = new FormData(o);
50
- if (a.values().toArray().length !== f.values().toArray().length) {
51
- r("dirty");
43
+ const e = t ?? w(null), [a, u] = c(new FormData()), [s, o] = c("pristine"), i = p(() => {
44
+ const r = e.current;
45
+ r !== null && (u(new FormData(r)), o("pristine"));
46
+ }, [e]), l = p(() => {
47
+ const r = e.current;
48
+ if (r === null) return;
49
+ const d = new FormData(r);
50
+ if (a.values().toArray().length !== d.values().toArray().length) {
51
+ o("dirty");
52
52
  return;
53
53
  }
54
- for (const [D, F] of f.entries())
55
- if (a.get(D) !== F) {
56
- r("dirty");
54
+ for (const [v, F] of d.entries())
55
+ if (a.get(v) !== F) {
56
+ o("dirty");
57
57
  return;
58
58
  }
59
- r("pristine");
60
- }, [e, a]), h = c(async () => {
61
- const o = e.current;
62
- o !== null && (r("submitting"), await n(new FormData(o)), l());
63
- }, [e, s, n, l]);
59
+ o("pristine");
60
+ }, [e, a]), h = p(async () => {
61
+ const r = e.current;
62
+ r !== null && (o("submitting"), await n(new FormData(r)), i());
63
+ }, [e, s, n, i]);
64
64
  return m(() => {
65
- const o = e.current;
66
- if (o === null) return;
67
- const f = () => d();
68
- return o.addEventListener("input", f), () => o.removeEventListener("input", f);
69
- }, [e, d]), m(() => l(), [l]), [e, s, h];
65
+ const r = e.current;
66
+ if (r === null) return;
67
+ const d = () => l();
68
+ return r.addEventListener("input", d), () => r.removeEventListener("input", d);
69
+ }, [e, l]), m(() => i(), [i]), [e, s, h];
70
70
  }
71
71
  function C(n, t) {
72
- const e = t ?? w(null), [a, u] = i("idle"), s = c(async () => {
73
- const r = e.current;
74
- r !== null && (u("working"), await n(new FormData(r)), u("idle"));
72
+ const e = t ?? w(null), [a, u] = c("idle"), s = p(async () => {
73
+ const o = e.current;
74
+ o !== null && (u("working"), await n(new FormData(o)), u("idle"));
75
75
  }, [e, n]);
76
76
  return [e, a, s];
77
77
  }
78
78
  function H(n, t = []) {
79
- const [e, a] = i(void 0), [u, s] = i(!1), r = c(() => {
80
- let d = !1;
79
+ const [e, a] = c(void 0), [u, s] = c(!1), o = p(() => {
80
+ let l = !1;
81
81
  const h = async () => {
82
82
  s(!0);
83
- const o = await n();
84
- s(!1), !d && a(o);
85
- }, v = () => {
86
- d = !0;
83
+ const r = await n();
84
+ s(!1), !l && a(r);
85
+ }, D = () => {
86
+ l = !0;
87
87
  };
88
- return h(), v;
89
- }, [n]), l = c(() => {
90
- a(void 0), r();
91
- }, [r]);
92
- return m(r, [n, ...t]), [e, u, l, a];
88
+ return h(), D;
89
+ }, [n]), i = () => {
90
+ a(void 0), o();
91
+ };
92
+ return m(o, [n, ...t]), [e, u, i, a];
93
93
  }
94
94
  function M(n, t, e = []) {
95
- const [a, u] = i([]), [s, r] = i(0), [l, d] = i(!1), [h, v] = i(!1), o = c(() => {
96
- let p = !1;
97
- const L = async () => {
98
- d(!0);
99
- const y = await n(s);
100
- y.length < t && v(!0), !p && (d(!1), u((S) => [...S, ...y]));
95
+ const [a, u] = c([]), [s, o] = c(0), [i, l] = c(!1), [h, D] = c(!1), r = p(() => {
96
+ let f = !1;
97
+ const y = async () => {
98
+ l(!0);
99
+ const L = await n(s);
100
+ L.length < t && D(!0), !f && (l(!1), u((S) => [...S, ...L]));
101
101
  }, E = () => {
102
- p = !0;
102
+ f = !0;
103
103
  };
104
- return L(), E;
105
- }, [n, t, s]), f = c(() => {
106
- u([]), d(!1), v(!1), r(0);
107
- }, []), D = c(() => {
108
- r((p) => p + 1);
109
- }, []), F = c(() => {
110
- r((p) => p - 1);
111
- }, []), g = c(() => {
112
- f(), o();
113
- }, []);
114
- return m(f, [f, t, ...e]), m(o, [n, o, s]), [a, l, h, D, F, g, u];
104
+ return y(), E;
105
+ }, [n, t, s]), d = () => {
106
+ u([]), l(!1), D(!1), o(0);
107
+ }, v = () => {
108
+ o((f) => f + 1);
109
+ }, F = () => {
110
+ o((f) => f - 1);
111
+ }, g = () => {
112
+ const f = s === 0;
113
+ d(), f && r();
114
+ };
115
+ return m(d, [t, ...e]), m(r, [r, s]), [a, i, h, v, F, g, u];
115
116
  }
116
117
  export {
117
118
  j as ErrorBoundary,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maskingtech/react-toolkit",
3
3
  "private": false,
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "url": "https://github.com/MaskingTechnology/react-toolkit"
@@ -10,7 +10,8 @@
10
10
  "build": "vite build",
11
11
  "clean": "rimraf dist",
12
12
  "lint": "eslint",
13
- "prepublishOnly": "npm run build"
13
+ "prepublishOnly": "npm run build",
14
+ "version": "npm version $VERSION --no-git-tag-version"
14
15
  },
15
16
  "exports": {
16
17
  ".": "./dist/mtreact.js"
@@ -20,21 +21,21 @@
20
21
  "dist"
21
22
  ],
22
23
  "peerDependencies": {
23
- "react": "^19.2.0"
24
+ "react": "^19.2.3"
24
25
  },
25
26
  "devDependencies": {
26
27
  "@eslint/js": "9.39.2",
27
- "@types/react": "19.2.7",
28
- "@types/node": "25.0.3",
28
+ "@types/react": "19.2.9",
29
+ "@types/node": "25.0.10",
29
30
  "@vitejs/plugin-react": "5.1.2",
30
31
  "eslint-plugin-react": "7.37.5",
31
32
  "rimraf": "6.1.2",
32
33
  "typescript": "5.9.3",
33
- "typescript-eslint": "8.51.0",
34
- "vite": "7.3.0",
34
+ "typescript-eslint": "8.53.1",
35
+ "vite": "7.3.1",
35
36
  "vite-plugin-dts": "4.5.4"
36
37
  },
37
38
  "optionalDependencies": {
38
- "@rollup/rollup-linux-x64-gnu": "4.54.0"
39
+ "@rollup/rollup-linux-x64-gnu": "4.56.0"
39
40
  }
40
41
  }