react-form-manage 1.0.6-beta.5 → 1.0.7-beta.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.0.7-beta.1] - 2026-01-22
6
+
7
+ - Add `FormFieldError` type export for typed error handling
8
+ - Improve `getValueFromEvent` in FormItem for custom event handler support
9
+ - Type `errors` as `FormFieldError[]` for better IDE support
10
+
11
+ ## [1.0.6] - 2026-01-22
12
+
13
+ - Promote ValidationRule typing + regex pattern support to stable
14
+ - Update README with validation examples (pattern, async validator) and remove template boilerplate
15
+ - Finalize TypeScript migration and docs for npm landing page
16
+
5
17
  ## [1.0.6-beta.5] - 2026-01-22
6
18
 
7
19
  - Update README with validation rule examples (pattern, async validator)
@@ -8,6 +8,6 @@ export interface FormItemProps {
8
8
  formItemId?: string;
9
9
  rules?: ValidationRule[];
10
10
  valuePropName?: string;
11
- getValueFromEvent?: (event: any) => any;
11
+ getValueFromEvent?: (...args: any[]) => any;
12
12
  }
13
13
  export default function FormItem({ children, name, formName, initialValue, formItemId: externalFormItemId, rules, valuePropName, getValueFromEvent, }: FormItemProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
@@ -19,12 +19,13 @@ export default function FormItem({ children, name, formName, initialValue, formI
19
19
  return cloneElement(children, {
20
20
  // ref: inputRef,
21
21
  [valuePropName]: value,
22
- onChange: (e) => {
23
- let val = e;
22
+ onChange: (...args) => {
23
+ let val = args[0];
24
24
  if (getValueFromEvent && typeof getValueFromEvent === "function") {
25
- val = getValueFromEvent(e);
25
+ val = getValueFromEvent(...args);
26
26
  }
27
27
  else {
28
+ const e = args[0];
28
29
  if (e && e.target) {
29
30
  val = e.target.value;
30
31
  }
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import Form, { useForm, useWatch, useSubmitDataWatch, useFormStateWatch, type FormProps, type ValidationRule } from "./providers/Form";
1
+ import Form, { useForm, useWatch, useSubmitDataWatch, useFormStateWatch, type FormProps, type ValidationRule, type FormFieldError } from "./providers/Form";
2
2
  import FormItem, { type FormItemProps } from "./components/Form/FormItem";
3
3
  import FormList, { type FormListProps } from "./components/Form/FormList";
4
4
  import Input from "./components/Input";
5
5
  import InputWrapper, { type InputWrapperProps } from "./components/Form/InputWrapper";
6
6
  import useFormItemControl from "./hooks/useFormItemControl";
7
7
  import useFormListControl from "./hooks/useFormListControl";
8
- export { Form, FormItem, FormList, Input, InputWrapper, useFormItemControl, useFormListControl, useForm, useWatch, useSubmitDataWatch, useFormStateWatch, type FormProps, type FormItemProps, type FormListProps, type InputWrapperProps, type ValidationRule, };
8
+ export { Form, FormItem, FormList, Input, InputWrapper, useFormItemControl, useFormListControl, useForm, useWatch, useSubmitDataWatch, useFormStateWatch, type FormProps, type FormItemProps, type FormListProps, type InputWrapperProps, type ValidationRule, type FormFieldError, };
9
9
  export default Form;
@@ -1,6 +1,6 @@
1
1
  import type { ComponentType, FormHTMLAttributes, ReactNode } from "react";
2
2
  import type { PublicFormInstance } from "../types/public";
3
- export type { ValidationRule } from "../types/public";
3
+ export type { ValidationRule, FormFieldError } from "../types/public";
4
4
  export declare const FormContext: import("react").Context<any>;
5
5
  export interface FormProps<T = any> extends Omit<FormHTMLAttributes<HTMLFormElement>, "onSubmit"> {
6
6
  children: ReactNode;
@@ -1,4 +1,8 @@
1
1
  export type FormValues<T = any> = T;
2
+ export interface FormFieldError {
3
+ ruleName: string | number;
4
+ message: string;
5
+ }
2
6
  export interface ValidationRule<T = any, TValues = any> {
3
7
  name?: string;
4
8
  message: string;
@@ -50,7 +54,7 @@ export interface UseFormItemReturn<T = any> {
50
54
  value: T | undefined;
51
55
  onChange: (value: T, options?: any) => void;
52
56
  state: any;
53
- errors: any;
57
+ errors: FormFieldError[];
54
58
  onFocus: () => void;
55
59
  isDirty?: boolean;
56
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-form-manage",
3
- "version": "1.0.6-beta.5",
3
+ "version": "1.0.7-beta.1",
4
4
  "description": "Lightweight React form management with list and listener support.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,8 +1,8 @@
1
- import { cloneElement, useRef, useState } from "react";
2
1
  import type { ReactElement } from "react";
3
- import type { ValidationRule } from "../../types/public";
2
+ import { cloneElement, useRef, useState } from "react";
4
3
  import { v4 } from "uuid";
5
4
  import useFormItemControl from "../../hooks/useFormItemControl";
5
+ import type { ValidationRule } from "../../types/public";
6
6
 
7
7
  export interface FormItemProps {
8
8
  children: ReactElement;
@@ -12,7 +12,7 @@ export interface FormItemProps {
12
12
  formItemId?: string;
13
13
  rules?: ValidationRule[];
14
14
  valuePropName?: string;
15
- getValueFromEvent?: (event: any) => any;
15
+ getValueFromEvent?: (...args: any[]) => any;
16
16
  }
17
17
 
18
18
  export default function FormItem({
@@ -46,11 +46,12 @@ export default function FormItem({
46
46
  return cloneElement(children, {
47
47
  // ref: inputRef,
48
48
  [valuePropName]: value,
49
- onChange: (e: any) => {
50
- let val = e;
49
+ onChange: (...args: any[]) => {
50
+ let val = args[0];
51
51
  if (getValueFromEvent && typeof getValueFromEvent === "function") {
52
- val = getValueFromEvent(e);
52
+ val = getValueFromEvent(...args);
53
53
  } else {
54
+ const e = args[0];
54
55
  if (e && e.target) {
55
56
  val = e.target.value;
56
57
  }
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ import Form, {
5
5
  useFormStateWatch,
6
6
  type FormProps,
7
7
  type ValidationRule,
8
+ type FormFieldError,
8
9
  } from "./providers/Form";
9
10
 
10
11
  import FormItem, { type FormItemProps } from "./components/Form/FormItem";
@@ -32,6 +33,7 @@ export {
32
33
  type FormListProps,
33
34
  type InputWrapperProps,
34
35
  type ValidationRule,
36
+ type FormFieldError,
35
37
  };
36
38
 
37
39
  export default Form;
@@ -8,7 +8,7 @@ import FormCleanUp from "../components/Form/FormCleanUp";
8
8
  import { useFormListeners, useFormStore } from "../stores/formStore";
9
9
  import type { PublicFormInstance } from "../types/public";
10
10
  import { getAllNoneObjStringPath } from "../utils/obj.util";
11
- export type { ValidationRule } from "../types/public";
11
+ export type { ValidationRule, FormFieldError } from "../types/public";
12
12
 
13
13
  export const FormContext = createContext(null);
14
14
 
@@ -1,5 +1,10 @@
1
1
  export type FormValues<T = any> = T;
2
2
 
3
+ export interface FormFieldError {
4
+ ruleName: string | number;
5
+ message: string;
6
+ }
7
+
3
8
  export interface ValidationRule<T = any, TValues = any> {
4
9
  name?: string;
5
10
  message: string;
@@ -53,7 +58,7 @@ export interface UseFormItemReturn<T = any> {
53
58
  value: T | undefined;
54
59
  onChange: (value: T, options?: any) => void;
55
60
  state: any;
56
- errors: any;
61
+ errors: FormFieldError[];
57
62
  onFocus: () => void;
58
63
  isDirty?: boolean;
59
64
  }