@react-fabric/form 1.0.0-beta.61 → 1.0.0-beta.63

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.
Files changed (155) hide show
  1. package/css/_colorPicker.css +35 -5
  2. package/css/_file.css +2 -2
  3. package/dist/cjs/builder/FileField.js +14 -11
  4. package/dist/cjs/builder/SchemaEditor.js +1 -1
  5. package/dist/cjs/builder/components/SchemaArrayForm.js +2 -4
  6. package/dist/cjs/builder/components/SchemaField.js +3 -3
  7. package/dist/cjs/form/Controller.js +1 -1
  8. package/dist/cjs/form/Form.js +42 -41
  9. package/dist/cjs/form/useForm.js +32 -0
  10. package/dist/cjs/hooks/useFileUploader.js +44 -32
  11. package/dist/cjs/hooks/useFormBuilder.js +3 -3
  12. package/dist/cjs/i18n/index.js +4 -4
  13. package/dist/cjs/index.js +2 -1
  14. package/dist/cjs/input/ArrayInput.js +66 -19
  15. package/dist/cjs/input/AvatarInput.js +21 -16
  16. package/dist/cjs/input/Checkbox.js +1 -1
  17. package/dist/cjs/input/ColorInput.js +26 -19
  18. package/dist/cjs/input/ColorPicker.js +16 -9
  19. package/dist/cjs/input/DateInput.js +3 -3
  20. package/dist/cjs/input/Field.js +1 -1
  21. package/dist/cjs/input/File.js +1 -1
  22. package/dist/cjs/input/Hidden.js +2 -11
  23. package/dist/cjs/input/Input.js +1 -1
  24. package/dist/cjs/input/Number.js +1 -1
  25. package/dist/cjs/input/Password.js +1 -1
  26. package/dist/cjs/input/Radio.js +1 -1
  27. package/dist/cjs/input/RadioGroup.js +7 -3
  28. package/dist/cjs/input/RangeSlider.js +1 -1
  29. package/dist/cjs/input/Search.js +1 -1
  30. package/dist/cjs/input/Slider.js +1 -1
  31. package/dist/cjs/input/Switch.js +4 -4
  32. package/dist/cjs/input/Textarea.js +1 -1
  33. package/dist/cjs/internal/InputWrapper.js +2 -2
  34. package/dist/cjs/ranger/index.js +5 -5
  35. package/dist/cjs/select/AutoComplete.js +4 -2
  36. package/dist/cjs/select/DualList.js +3 -3
  37. package/dist/cjs/select/List.js +7 -4
  38. package/dist/cjs/select/Options.js +5 -4
  39. package/dist/cjs/select/Select.js +5 -3
  40. package/dist/cjs/select/useSelect.js +15 -13
  41. package/dist/esm/builder/FileField.js +14 -11
  42. package/dist/esm/builder/SchemaEditor.js +1 -1
  43. package/dist/esm/builder/components/SchemaArrayForm.js +2 -4
  44. package/dist/esm/builder/components/SchemaField.js +3 -3
  45. package/dist/esm/form/Controller.js +1 -1
  46. package/dist/esm/form/Form.js +45 -43
  47. package/dist/esm/form/useForm.js +32 -0
  48. package/dist/esm/hooks/useFileUploader.js +45 -33
  49. package/dist/esm/hooks/useFormBuilder.js +3 -3
  50. package/dist/esm/i18n/index.js +2 -2
  51. package/dist/esm/index.js +2 -1
  52. package/dist/esm/input/ArrayInput.js +66 -19
  53. package/dist/esm/input/AvatarInput.js +21 -16
  54. package/dist/esm/input/Checkbox.js +1 -1
  55. package/dist/esm/input/ColorInput.js +27 -20
  56. package/dist/esm/input/ColorPicker.js +17 -10
  57. package/dist/esm/input/DateInput.js +3 -3
  58. package/dist/esm/input/Field.js +1 -1
  59. package/dist/esm/input/File.js +1 -1
  60. package/dist/esm/input/Hidden.js +3 -12
  61. package/dist/esm/input/Input.js +1 -1
  62. package/dist/esm/input/Number.js +1 -1
  63. package/dist/esm/input/Password.js +1 -1
  64. package/dist/esm/input/Radio.js +1 -1
  65. package/dist/esm/input/RadioGroup.js +7 -3
  66. package/dist/esm/input/RangeSlider.js +1 -1
  67. package/dist/esm/input/Search.js +1 -1
  68. package/dist/esm/input/Slider.js +1 -1
  69. package/dist/esm/input/Switch.js +4 -4
  70. package/dist/esm/input/Textarea.js +1 -1
  71. package/dist/esm/internal/InputWrapper.js +2 -2
  72. package/dist/esm/ranger/index.js +5 -5
  73. package/dist/esm/select/AutoComplete.js +4 -2
  74. package/dist/esm/select/DualList.js +3 -3
  75. package/dist/esm/select/List.js +8 -5
  76. package/dist/esm/select/Options.js +5 -4
  77. package/dist/esm/select/Select.js +6 -4
  78. package/dist/esm/select/useSelect.js +15 -13
  79. package/dist/types/builder/FileField.d.ts +2 -1
  80. package/dist/types/builder/SchemaEditor.d.ts +1 -1
  81. package/dist/types/form/Controller.d.ts +1 -1
  82. package/dist/types/form/Form.d.ts +7 -14
  83. package/dist/types/form/useForm.d.ts +11 -0
  84. package/dist/types/hooks/useFileUploader.d.ts +4 -2
  85. package/dist/types/index.d.ts +3 -2
  86. package/dist/types/input/ArrayInput.d.ts +5 -4
  87. package/dist/types/input/AvatarInput.d.ts +2 -2
  88. package/dist/types/input/Checkbox.d.ts +2 -2
  89. package/dist/types/input/ColorInput.d.ts +1 -1
  90. package/dist/types/input/ColorPicker.d.ts +5 -1
  91. package/dist/types/input/DateInput.d.ts +1 -1
  92. package/dist/types/input/Field.d.ts +1 -1
  93. package/dist/types/input/File.d.ts +1 -1
  94. package/dist/types/input/Hidden.d.ts +4 -12
  95. package/dist/types/input/Input.d.ts +1 -1
  96. package/dist/types/input/Number.d.ts +1 -1
  97. package/dist/types/input/Password.d.ts +1 -1
  98. package/dist/types/input/Radio.d.ts +2 -2
  99. package/dist/types/input/RadioGroup.d.ts +7 -3
  100. package/dist/types/input/RangeSlider.d.ts +1 -1
  101. package/dist/types/input/Search.d.ts +1 -1
  102. package/dist/types/input/Slider.d.ts +1 -1
  103. package/dist/types/input/Switch.d.ts +2 -2
  104. package/dist/types/input/Textarea.d.ts +1 -1
  105. package/dist/types/select/AutoComplete.d.ts +1 -1
  106. package/dist/types/select/DualList.d.ts +1 -1
  107. package/dist/types/select/List.d.ts +1 -1
  108. package/dist/types/select/Select.d.ts +1 -1
  109. package/dist/types/types/index.d.ts +3 -3
  110. package/dist/types/types/schema.d.ts +1 -1
  111. package/package.json +14 -14
  112. package/src/builder/FileField.tsx +5 -3
  113. package/src/builder/SchemaEditor.tsx +2 -2
  114. package/src/builder/components/SchemaArrayForm.tsx +1 -3
  115. package/src/builder/components/SchemaField.tsx +3 -3
  116. package/src/form/Controller.tsx +1 -1
  117. package/src/form/Form.tsx +21 -43
  118. package/src/form/useForm.ts +44 -0
  119. package/src/hooks/useFileUploader.ts +41 -29
  120. package/src/i18n/index.ts +2 -2
  121. package/src/index.ts +3 -7
  122. package/src/input/ArrayInput.tsx +20 -10
  123. package/src/input/AvatarInput.tsx +12 -12
  124. package/src/input/Checkbox.tsx +2 -2
  125. package/src/input/ColorInput.tsx +29 -45
  126. package/src/input/ColorPicker.tsx +42 -49
  127. package/src/input/DateInput.tsx +3 -3
  128. package/src/input/Field.tsx +2 -2
  129. package/src/input/File.tsx +1 -1
  130. package/src/input/Hidden.tsx +5 -25
  131. package/src/input/Input.tsx +1 -1
  132. package/src/input/Number.tsx +1 -1
  133. package/src/input/Password.tsx +1 -1
  134. package/src/input/Radio.tsx +2 -2
  135. package/src/input/RadioGroup.tsx +11 -3
  136. package/src/input/RangeSlider.tsx +1 -1
  137. package/src/input/Search.tsx +1 -1
  138. package/src/input/Slider.tsx +1 -1
  139. package/src/input/Switch.tsx +6 -6
  140. package/src/input/Textarea.tsx +1 -1
  141. package/src/internal/InputWrapper.tsx +1 -2
  142. package/src/select/AutoComplete.tsx +13 -52
  143. package/src/select/DualList.tsx +3 -3
  144. package/src/select/List.tsx +31 -69
  145. package/src/select/Options.tsx +4 -3
  146. package/src/select/Select.tsx +19 -41
  147. package/src/select/useSelect.tsx +24 -69
  148. package/src/types/index.ts +3 -3
  149. package/src/types/schema.ts +1 -1
  150. /package/dist/cjs/i18n/{ar.json.js → ar/form.json.js} +0 -0
  151. /package/dist/cjs/i18n/{en.json.js → en/form.json.js} +0 -0
  152. /package/dist/esm/i18n/{ar.json.js → ar/form.json.js} +0 -0
  153. /package/dist/esm/i18n/{en.json.js → en/form.json.js} +0 -0
  154. /package/src/i18n/{ar.json → ar/form.json} +0 -0
  155. /package/src/i18n/{en.json → en/form.json} +0 -0
@@ -7,7 +7,7 @@ export interface ArrayInputProps<T extends AnyObject = string> {
7
7
  /**
8
8
  * append to label end
9
9
  */
10
- appendLabel?: JSX.Element | string | number | boolean;
10
+ appendLabel?: React.ReactElement | string | number | boolean;
11
11
  /**
12
12
  * info label at bottom
13
13
  */
@@ -48,6 +48,7 @@ export interface ArrayInputProps<T extends AnyObject = string> {
48
48
  index: number;
49
49
  name: string;
50
50
  item: T;
51
+ onChange: (val: false | undefined | T) => void;
51
52
  }) => React.ReactNode);
52
53
  /**
53
54
  * add item button label
@@ -55,13 +56,13 @@ export interface ArrayInputProps<T extends AnyObject = string> {
55
56
  addLabel?: string;
56
57
  buttonPosition?: "top" | "bottom" | "both";
57
58
  arrayRef?: Ref<{
58
- addItem: (item: T) => void;
59
+ addItem: (item: false | undefined | T | Promise<false | undefined | T>) => void;
59
60
  removeItem: (idx: number) => void;
60
61
  }>;
61
62
  /**
62
63
  * add new item
63
64
  */
64
- onAdd?: () => T;
65
+ onAdd?: () => false | undefined | T | Promise<false | undefined | T>;
65
66
  /**
66
67
  * on item remove
67
68
  */
@@ -103,7 +104,7 @@ export interface ArrayInputProps<T extends AnyObject = string> {
103
104
  * It also supports drag-and-drop sorting using `@dnd-kit/core` and `@dnd-kit/sortable` for a better user experience when reordering items.
104
105
  *
105
106
  * @param {ArrayInputProps<T>} props - The properties for the ArrayInput component.
106
- * @returns {JSX.Element} The rendered ArrayInput component.
107
+ * @returns {React.ReactElement} The rendered ArrayInput component.
107
108
  *
108
109
  * @example
109
110
  * ```jsx
@@ -46,6 +46,6 @@ export interface Props extends RefProp {
46
46
  * It also provides a way to remove the uploaded file and shows upload progress.
47
47
  *
48
48
  * @param {Props} props - The properties for the AvatarInput component.
49
- * @returns {JSX.Element} - The rendered AvatarInput component.
49
+ * @returns {React.ReactElement} - The rendered AvatarInput component.
50
50
  */
51
- export declare const AvatarInput: ({ size, avatarName, avatarClassName, value, rounded, defaultValue, fallbackIcon, variant, fileUrl, uploadHandler, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
51
+ export declare const AvatarInput: ({ size, avatarName, avatarClassName, value, rounded, defaultValue, fallbackIcon, variant, fileUrl, uploadHandler, onChange, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ interface CheckboxProps extends RefProp<HTMLInputElement> {
3
3
  /**
4
4
  * checkbox label
5
5
  */
6
- label?: JSX.Element | string;
6
+ label?: React.ReactElement | string;
7
7
  /**
8
8
  * checked
9
9
  */
@@ -49,7 +49,7 @@ interface CheckboxProps extends RefProp<HTMLInputElement> {
49
49
  * It also provides an error icon to indicate validation errors.
50
50
  *
51
51
  * @param {CheckboxProps} props - The properties for the Checkbox component.
52
- * @returns {JSX.Element} The rendered Checkbox component.
52
+ * @returns {React.ReactElement} The rendered Checkbox component.
53
53
  */
54
54
  export declare const Checkbox: ({ ref, label, value, name, checked, invalid, disabled, error, width, icon, iconChecked, required, onChange, ...rest }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
55
55
  export {};
@@ -18,6 +18,6 @@ export interface ColorInputProps extends InputProps, Omit<ColorProps, "onChange"
18
18
  * and handling the color selection state.
19
19
  *
20
20
  * @param {ColorInputProps} props - The properties for the ColorInput component.
21
- * @returns {JSX.Element} - The rendered ColorInput component.
21
+ * @returns {React.ReactElement} - The rendered ColorInput component.
22
22
  */
23
23
  export declare const ColorInput: ({ ref, required, disabled, readOnly, invalid, error, value, showPicker, defaultColor, onBlur, onFocus, onChange, noOutline, ...rest }: ColorInputProps) => import("react/jsx-runtime").JSX.Element;
@@ -12,6 +12,10 @@ export interface ColorProps {
12
12
  * hide alpha value
13
13
  */
14
14
  hideAlpha?: boolean;
15
+ /**
16
+ * show only swatches, hide the color picker
17
+ */
18
+ picker?: "default" | "swatches";
15
19
  /**
16
20
  * color value
17
21
  */
@@ -27,7 +31,7 @@ export interface ColorProps {
27
31
  * The component uses the `react-color` library for the color picker functionality.
28
32
  *
29
33
  * @param {ColorProps} props - The properties for the ColorPicker component.
30
- * @returns {JSX.Element} The rendered ColorPicker component.
34
+ * @returns {React.ReactElement} The rendered ColorPicker component.
31
35
  *
32
36
  * @see {@link https://react-color.github.io/react-color/} for more details on the color picker library.
33
37
  */
@@ -23,6 +23,6 @@ export interface DateProps extends InputProps<string>, RefProp<HTMLInputElement>
23
23
  * The component supports both date and datetime types, with appropriate formatting.
24
24
  *
25
25
  * @param {DateProps} props - The properties for the DateInput component.
26
- * @returns {JSX.Element} - The rendered DateInput component.
26
+ * @returns {React.ReactElement} - The rendered DateInput component.
27
27
  */
28
28
  export declare const DateInput: ({ ref, name, value, invalid, readOnly, disabled, required, placeholder, defaultValue, autoFocus, error, type, onBlur, onFocus, onChange, onEnterPressed, format, min, max, ...rest }: DateProps) => import("react/jsx-runtime").JSX.Element;
@@ -7,7 +7,7 @@ export interface FieldProps extends ChildrenProp, CssProp {
7
7
  /**
8
8
  * append to label end
9
9
  */
10
- appendLabel?: JSX.Element | string | number | boolean;
10
+ appendLabel?: React.ReactElement | string | number | boolean;
11
11
  /**
12
12
  * info label at bottom
13
13
  */
@@ -21,6 +21,6 @@ export interface FileInputProps extends InputProps<AnyObject>, RefProp<HTMLInput
21
21
  * It handles file changes, invalid states, and read-only or disabled states.
22
22
  *
23
23
  * @param {FileInputProps} props - The properties for the FileInput component.
24
- * @returns {JSX.Element} - The rendered FileInput component.
24
+ * @returns {React.ReactElement} - The rendered FileInput component.
25
25
  */
26
26
  export declare const FileInput: ({ ref, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, name, accept, showList, multiple, onChange, onEnterPressed, ...rest }: FileInputProps) => import("react/jsx-runtime").JSX.Element;
@@ -4,17 +4,9 @@ interface Props {
4
4
  */
5
5
  name?: string;
6
6
  /**
7
- * hidden value will fire change for form update
7
+ * hidden input value
8
8
  */
9
- hiddenValue?: AnyObject;
10
- /**
11
- * default avatar image
12
- */
13
- defaultValue?: string;
14
- /**
15
- * form onChange handler
16
- */
17
- onChange?: (value: AnyObject) => void;
9
+ value?: AnyObject;
18
10
  }
19
11
  /**
20
12
  * Hidden input component to handle hidden values in forms.
@@ -22,7 +14,7 @@ interface Props {
22
14
  * This is useful for cases where you need to update the form state without user interaction.
23
15
  *
24
16
  * @param {Object} props - Component properties.
25
- * @returns {JSX.Element} The rendered hidden input field and error icon.
17
+ * @returns {React.ReactElement} The rendered hidden input field and error icon.
26
18
  */
27
- export declare const HiddenInput: ({ hiddenValue, defaultValue, onChange, invalid, error, value, name, }: Props) => import("react/jsx-runtime").JSX.Element;
19
+ export declare const HiddenInput: ({ invalid, error, value, name, }: Props) => import("react/jsx-runtime").JSX.Element;
28
20
  export {};
@@ -12,6 +12,6 @@ export interface TextInputProps extends InputProps, RefProp<HTMLInputElement> {
12
12
  * The component uses a wrapper to handle the clear button and styling, and it supports deferred value updates to optimize performance.
13
13
  *
14
14
  * @param {TextInputProps} props - The properties for the text input component.
15
- * @returns {JSX.Element} - A JSX element representing the text input field.
15
+ * @returns {React.ReactElement} - A JSX element representing the text input field.
16
16
  */
17
17
  export declare const Input: ({ ref, name, value, invalid, readOnly, disabled, required, placeholder, defaultValue, autoFocus, error, monospace, type, onBlur, onFocus, onChange, onEnterPressed, ...rest }: TextInputProps) => import("react/jsx-runtime").JSX.Element;
@@ -20,6 +20,6 @@ export interface NumberProps extends InputProps<number>, RefProp<HTMLInputElemen
20
20
  * It also includes a clear button to reset the input value.
21
21
  *
22
22
  * @param {NumberProps} props - The properties for the Number input component.
23
- * @returns {JSX.Element} The rendered Number input component.
23
+ * @returns {React.ReactElement} The rendered Number input component.
24
24
  */
25
25
  export declare const Number: ({ ref, value, invalid, readOnly, disabled, required, placeholder, defaultValue, autoFocus, name, min, max, step, onBlur, onFocus, onChange, onEnterPressed, ...rest }: NumberProps) => import("react/jsx-runtime").JSX.Element;
@@ -14,6 +14,6 @@ export interface PasswordProps extends InputProps, RefProp<HTMLInputElement> {
14
14
  * Password input component with optional strength meter and toggle visibility.
15
15
  *
16
16
  * @param {PasswordProps} props - The properties for the Password component.
17
- * @returns {JSX.Element} The rendered Password input component.
17
+ * @returns {React.ReactElement} The rendered Password input component.
18
18
  */
19
19
  export declare const Password: ({ ref, value, name, strength, invalid, readOnly, disabled, required, placeholder, defaultValue, autoFocus, showToggle, onBlur, onFocus, onChange, onEnterPressed, ...rest }: PasswordProps) => import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,7 @@ export interface RadioProps extends RefProp<HTMLInputElement> {
4
4
  /**
5
5
  * radio label
6
6
  */
7
- label?: JSX.Element | string;
7
+ label?: React.ReactElement | string;
8
8
  /**
9
9
  * value
10
10
  */
@@ -45,6 +45,6 @@ export interface RadioProps extends RefProp<HTMLInputElement> {
45
45
  * It supports disabled and invalid states, and allows for custom width.
46
46
  *
47
47
  * @param {RadioProps} props - The properties for the Radio component.
48
- * @returns {JSX.Element} The rendered Radio input component.
48
+ * @returns {React.ReactElement} The rendered Radio input component.
49
49
  */
50
50
  export declare const Radio: ({ ref, name, label, value, invalid, disabled, error, width, icon, iconChecked, onChange, ...rest }: RadioProps) => import("react/jsx-runtime").JSX.Element;
@@ -8,7 +8,7 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
8
8
  /**
9
9
  * append to label end
10
10
  */
11
- appendLabel?: JSX.Element | string | number | boolean;
11
+ appendLabel?: React.ReactElement | string | number | boolean;
12
12
  /**
13
13
  * field info
14
14
  */
@@ -37,6 +37,10 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
37
37
  * vertical orientation
38
38
  */
39
39
  vertical?: boolean;
40
+ /**
41
+ * value
42
+ */
43
+ value?: string | number;
40
44
  /**
41
45
  * change handler
42
46
  */
@@ -48,6 +52,6 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
48
52
  * The component supports inline and vertical orientations, and can handle change events.
49
53
  *
50
54
  * @param {RadioGroupProps} props - The properties for the RadioGroup component.
51
- * @returns {JSX.Element} The rendered RadioGroup component.
55
+ * @returns {React.ReactElement} The rendered RadioGroup component.
52
56
  */
53
- export declare const RadioGroup: ({ children, name, className, optionWidth, onChange, ...rest }: RadioGroupProps) => import("react/jsx-runtime").JSX.Element;
57
+ export declare const RadioGroup: ({ children, name, className, optionWidth, vertical, value, onChange, ...rest }: RadioGroupProps) => import("react/jsx-runtime").JSX.Element;
@@ -62,6 +62,6 @@ export interface RangeProps extends Omit<InputProps<[number, number]>, "placehol
62
62
  * The component is designed to be flexible and customizable, allowing for various configurations.
63
63
  *
64
64
  * @param {RangeProps} props - The properties for the RangeSlider component.
65
- * @returns {JSX.Element} The rendered RangeSlider component.
65
+ * @returns {React.ReactElement} The rendered RangeSlider component.
66
66
  */
67
67
  export declare const RangeSlider: ({ error, name, value, step, min, max, height, color, vertical, showLabels, showValue, minLabel, maxLabel, ranges, format, autoFocus, disabled, readOnly, onBlur, onChange, onEnterPressed, onFocus, onSlide, invalid, ...rest }: RangeProps) => import("react/jsx-runtime").JSX.Element;
@@ -25,6 +25,6 @@ export interface SearchProps extends InputProps, RefProp<HTMLInputElement> {
25
25
  * and handling search actions with a debounce mechanism.
26
26
  *
27
27
  * @param {SearchProps} props - The properties for the Search component.
28
- * @returns {JSX.Element} The rendered Search input component.
28
+ * @returns {React.ReactElement} The rendered Search input component.
29
29
  */
30
30
  export declare const Search: ({ ref, value, name, invalid, readOnly, disabled, required, searching, placeholder, defaultValue, autoFocus, hideHandle, allowClear, searchOnChange, onBlur, onFocus, onSearch, onChange, onEnterPressed, ...rest }: SearchProps) => import("react/jsx-runtime").JSX.Element;
@@ -64,6 +64,6 @@ export interface SliderProps extends Omit<InputProps<number>, "placeholder" | "a
64
64
  * It also supports deferred value updates for smoother interactions.
65
65
  *
66
66
  * @param {SliderProps} props - The properties for the Slider component.
67
- * @returns {JSX.Element} The rendered Slider component.
67
+ * @returns {React.ReactElement} The rendered Slider component.
68
68
  */
69
69
  export declare const Slider: ({ error, name, value, step, min, max, height, color, vertical, showLabels, showValue, minLabel, maxLabel, ranges, useInfinity, format, invalid, autoFocus, disabled, readOnly, onBlur, onChange, onEnterPressed, onFocus, onSlide, ...rest }: SliderProps) => import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ export interface SwitchProps extends RefProp<HTMLInputElement> {
3
3
  /**
4
4
  * Switch label
5
5
  */
6
- label?: JSX.Element | string;
6
+ label?: React.ReactElement | string;
7
7
  /**
8
8
  * checked
9
9
  */
@@ -49,6 +49,6 @@ export interface SwitchProps extends RefProp<HTMLInputElement> {
49
49
  * It supports disabled and invalid states, and handles change events.
50
50
  *
51
51
  * @param {SwitchProps} props - The properties for the Switch component.
52
- * @returns {JSX.Element} The rendered Switch input component.
52
+ * @returns {React.ReactElement} The rendered Switch input component.
53
53
  */
54
54
  export declare const Switch: ({ ref, label, checked, invalid, disabled, error, width, color, name, onLabel, offLabel, onLabelColor, offLabelColor, defaultColor, required, onChange, ...rest }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
@@ -26,6 +26,6 @@ export interface TextareaProps extends InputProps, RefProp<HTMLTextAreaElement>
26
26
  * providing a clear interface for text input with optional validation and accessibility features.
27
27
  *
28
28
  * @param {TextareaProps} props - The properties for the Textarea component.
29
- * @returns {JSX.Element} The rendered Textarea component.
29
+ * @returns {React.ReactElement} The rendered Textarea component.
30
30
  */
31
31
  export declare const Textarea: ({ ref, value, name, invalid, readOnly, disabled, required, placeholder, defaultValue, autoFocus, rows, maxRows, variableRows, expandable, onBlur, onFocus, onChange, onEnterPressed, ...rest }: TextareaProps) => import("react/jsx-runtime").JSX.Element;
@@ -18,7 +18,7 @@ type AutoCompleteProps = Omit<SelectProps<string>, "options" | "allowCreate" | "
18
18
  * It supports multiple selections, history suggestions, and custom styling.
19
19
  *
20
20
  * @param {AutoCompleteProps} props - The properties for the AutoComplete component.
21
- * @returns {JSX.Element} The rendered AutoComplete component.
21
+ * @returns {React.ReactElement} The rendered AutoComplete component.
22
22
  */
23
23
  export declare const AutoComplete: ({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, expandOnEdit, error, history, multiple, onChange, onSelect, onInput, onFocus, onBlur, onQuery, onEnterPressed, ...rest }: AutoCompleteProps) => import("react/jsx-runtime").JSX.Element;
24
24
  export {};
@@ -47,6 +47,6 @@ export interface DualListProps<T> extends Omit<FieldProps, "children">, RefProp<
47
47
  * This component is useful for scenarios where users need to manage selections from a larger set of options, such as in forms or settings.
48
48
  *
49
49
  * @param {DualListProps<T>} props - The properties for the DualList component.
50
- * @returns {JSX.Element} The rendered DualList component.
50
+ * @returns {React.ReactElement} The rendered DualList component.
51
51
  */
52
52
  export declare const DualList: <T extends AnyObject = string>({ ref, value, options, emptyDisplay, groupProperty, height, labelProperty, valueProperty, renderer, onChange, name, invalid, readOnly, disabled, placeholder, autoFocus, error, ...rest }: DualListProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,7 @@ import { type SelectProps } from "../types";
5
5
  * and custom rendering of options.
6
6
  *
7
7
  * @param {SelectProps<T>} props - The properties for the List component.
8
- * @returns {JSX.Element} The rendered List component.
8
+ * @returns {React.ReactElement} The rendered List component.
9
9
  */
10
10
  export declare const List: <T extends AnyObject = string>({ ref, name, value, readOnly, disabled, required, placeholder, autoFocus, options, height, groupProperty, labelProperty, valueProperty, infoProperty, sortProperty, multiple, allowCreate, searchable, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, emptyDisplay, invalid, error, allowClear, decorateStart, decorateEnd, "data-inner": isInner, "data-hide-selected": hideSelected, ...rest }: Omit<SelectProps<T>, "defaultOpen" | "hideHandle"> & {
11
11
  height?: string | number;
@@ -5,6 +5,6 @@ import { type SelectProps } from "../types";
5
5
  * and custom rendering of options.
6
6
  *
7
7
  * @param {SelectProps<T>} props - The properties for the Select component.
8
- * @returns {JSX.Element} The rendered Select component.
8
+ * @returns {React.ReactElement} The rendered Select component.
9
9
  */
10
10
  export declare const Select: <T extends AnyObject = string>({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, options, defaultOpen, hideHandle, groupProperty, labelProperty, valueProperty, sortProperty, infoProperty, multiple, searchable, allowCreate, emptyDisplay, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, ...rest }: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -39,15 +39,15 @@ export interface InputProps<V = string> extends TestProps {
39
39
  /**
40
40
  * append to label end
41
41
  */
42
- appendLabel?: JSX.Element | string | number | boolean;
42
+ appendLabel?: React.ReactElement | string | number | boolean;
43
43
  /**
44
44
  *
45
45
  */
46
- decorateStart?: JSX.Element | string | number | boolean;
46
+ decorateStart?: React.ReactElement | string | number | boolean;
47
47
  /**
48
48
  *
49
49
  */
50
- decorateEnd?: JSX.Element | string | number | boolean;
50
+ decorateEnd?: React.ReactElement | string | number | boolean;
51
51
  decorateEndShowWhenEmpty?: boolean;
52
52
  decorateEndHideWhenEmpty?: boolean;
53
53
  /**
@@ -97,7 +97,7 @@ export interface SchemaEditorProps {
97
97
  /**
98
98
  * footer actions
99
99
  */
100
- children?: Elements<JSX.Element> | Array<Elements<JSX.Element>>;
100
+ children?: Elements<React.ReactElement> | Array<Elements<React.ReactElement>>;
101
101
  onChange?: (schema: FormSchema) => void;
102
102
  onSubmit?: (schema: FormSchema) => void;
103
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/form",
3
- "version": "1.0.0-beta.61",
3
+ "version": "1.0.0-beta.63",
4
4
  "description": "RUF: Form package",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
@@ -39,28 +39,28 @@
39
39
  "@dnd-kit/modifiers": "~9.0.0",
40
40
  "@dnd-kit/sortable": "~10.0.0",
41
41
  "@dnd-kit/utilities": "~3.2.2",
42
- "@floating-ui/react": "~0.27.16",
42
+ "@floating-ui/react": "~0.27.19",
43
43
  "@hookform/resolvers": "~5.2.2",
44
- "@react-fabric/core": "^1.0.0-beta.61",
45
- "@react-fabric/date": "^1.0.0-beta.61",
46
- "@react-fabric/utilities": "^1.0.0-beta.61",
44
+ "@react-fabric/core": "^1.0.0-beta.63",
45
+ "@react-fabric/date": "^1.0.0-beta.63",
46
+ "@react-fabric/utilities": "^1.0.0-beta.63",
47
+ "chroma-js": "~3.2.0",
47
48
  "classnames": "~2.5.1",
48
- "color": "~5.0.2",
49
49
  "react-color": "~2.19.3",
50
- "react-hook-form": "~7.65.0"
50
+ "react-hook-form": "~7.71.2"
51
51
  },
52
52
  "peerDependencies": {
53
- "i18next": "~25.6.0",
54
- "react": "~19.2.0",
55
- "react-dom": "~19.2.0",
56
- "react-i18next": "~16.2.1"
53
+ "i18next": "~25.8.18",
54
+ "react": "~19.2.4",
55
+ "react-dom": "~19.2.4",
56
+ "react-i18next": "~16.5.8"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/react-color": "~3.0.13"
60
60
  },
61
61
  "engines": {
62
- "node": ">=18.12.0",
63
- "npm": ">=8.19.0"
62
+ "node": ">=22.18.0",
63
+ "npm": ">=10.8.0"
64
64
  },
65
- "gitHead": "a0b0c571bf9c189fa3355bbc3b896ecc4b9d6a04"
65
+ "gitHead": "6e0652b15c6384fbc316842862572e21299a5466"
66
66
  }
@@ -37,6 +37,7 @@ export const FileField = ({
37
37
  accept,
38
38
  value,
39
39
  fileUrl,
40
+ onChange,
40
41
  multiple,
41
42
  invalid,
42
43
  error,
@@ -46,20 +47,21 @@ export const FileField = ({
46
47
  inline?: boolean;
47
48
  invalid?: boolean;
48
49
  error?: AnyObject;
50
+ onChange?: (value: any) => void;
49
51
  fileUrl?: (path: string) => string;
50
52
  uploadHandler: UploadHandler;
51
53
  }) => {
52
54
  const { t } = useTranslation();
53
- const { pending, files, list, upload, remove } = useFileUploader(
55
+ const { pending, files, upload, remove } = useFileUploader(
54
56
  async (data, config) => await uploadHandler?.(data, config),
55
57
  value,
56
- multiple,
58
+ { multiple, onChange },
57
59
  );
58
60
 
59
61
  return (
60
62
  <Fragment>
61
63
  <Field plain inline={inline} label={label}>
62
- <HiddenInput hiddenValue={multiple ? list : list?.[0]} {...rest} />
64
+ <HiddenInput value={multiple ? files : files?.[0]} {...rest} />
63
65
  </Field>
64
66
  <Tooltip
65
67
  color="danger-200"
@@ -37,7 +37,7 @@ import { SchemaArrayForm } from "./components/SchemaArrayForm";
37
37
  * It provides a form interface to modify schema properties dynamically.
38
38
  *
39
39
  * @param {SchemaEditorProps} props - The properties for the SchemaEditor component.
40
- * @returns {JSX.Element} The rendered SchemaEditor component.
40
+ * @returns {React.ReactElement} The rendered SchemaEditor component.
41
41
  */
42
42
  export const SchemaEditor = ({
43
43
  schemaDef,
@@ -70,7 +70,7 @@ export const SchemaEditor = ({
70
70
  acceptableTypes={acceptableTypes ?? Object.values(DATA_TYPES)}
71
71
  />
72
72
  {children && (
73
- <Footer flex className="border-t bg-base px-6 py-2">
73
+ <Footer flex className="border-t bg-default px-6 py-2">
74
74
  {children}
75
75
  </Footer>
76
76
  )}
@@ -33,7 +33,6 @@ import { AddSchemaFields } from "./AddSchemaFields";
33
33
  import { SchemaField } from "./SchemaField";
34
34
 
35
35
  // Need to disable prop-types lint due to uknown lint error
36
- /* eslint-disable react/prop-types */
37
36
  export const SchemaArrayForm = ({
38
37
  dynamic,
39
38
  acceptableTypes,
@@ -75,7 +74,6 @@ export const SchemaArrayForm = ({
75
74
  }, []);
76
75
 
77
76
  const Wrapper = useCallback(
78
- // eslint-disable-next-line @typescript-eslint/promise-function-async
79
77
  ({ children }: { children: React.ReactNode }) => {
80
78
  if (dynamic) {
81
79
  // pass id list to dnd context
@@ -149,7 +147,7 @@ export const SchemaArrayForm = ({
149
147
  />
150
148
  ))}
151
149
  </Content>
152
- {AddModal}
150
+ <AddModal />
153
151
  </Wrapper>
154
152
  );
155
153
  };
@@ -147,7 +147,7 @@ export const SchemaField = ({
147
147
  <Footer
148
148
  flex
149
149
  justify="end"
150
- className="sticky bottom-0 border-t bg-base px-6 py-2"
150
+ className="sticky bottom-0 border-t bg-default px-6 py-2"
151
151
  >
152
152
  <Button variant="link" onClick={props.onClose}>
153
153
  Close
@@ -229,7 +229,7 @@ export const SchemaField = ({
229
229
  </div>
230
230
  <div className="flex flex-col gap-1 pb-4">
231
231
  <Controller name={`${field}.id`}>
232
- <HiddenInput hiddenValue={id} />
232
+ <HiddenInput value={id} />
233
233
  </Controller>
234
234
  <Controller name={`${field}.datatype`}>
235
235
  <Select
@@ -284,7 +284,7 @@ export const SchemaField = ({
284
284
  />
285
285
  )}
286
286
  </Field>
287
- {OptionModal}
287
+ <OptionModal />
288
288
  </Fragment>
289
289
  )}
290
290
  {type === DATA_TYPES.FILE && (
@@ -76,7 +76,7 @@ export interface ControllerProps {
76
76
  * to the child component, allowing for proper focus management and DOM access.
77
77
  *
78
78
  * @param {ControllerProps} props - The properties for the Controller component.
79
- * @returns {JSX.Element} The rendered Controller component.
79
+ * @returns {React.ReactElement} The rendered Controller component.
80
80
  *
81
81
  * @example
82
82
  * ```jsx
package/src/form/Form.tsx CHANGED
@@ -37,7 +37,6 @@ import {
37
37
  useFormContext,
38
38
  useForm as useFormHook,
39
39
  useWatch,
40
- type DefaultValues,
41
40
  type FormState,
42
41
  type Path,
43
42
  type Resolver,
@@ -70,7 +69,11 @@ export interface FormProps<K extends KeyValue = KeyValue> {
70
69
  /**
71
70
  * default data values
72
71
  */
73
- defaultValues?: K;
72
+ defaultValues?: K | Promise<K>;
73
+ /**
74
+ * reset values on defaultValues change (workaround for using fetch result)
75
+ */
76
+ resetOnChange?: boolean;
74
77
  /**
75
78
  * change callback
76
79
  */
@@ -89,7 +92,7 @@ const DEFAULT_SUBMIT = () => undefined;
89
92
  * It supports nested form structures and allows for custom validation schemas using Yup.
90
93
  *
91
94
  * @param {FormProps<K>} props - The properties for the Form component.
92
- * @returns {JSX.Element} The rendered Form component.
95
+ * @returns {React.ReactElement} The rendered Form component.
93
96
  *
94
97
  * @example
95
98
  * ```jsx
@@ -115,6 +118,7 @@ export const Form = <K extends KeyValue>({
115
118
  formRef,
116
119
  resolver,
117
120
  children,
121
+ resetOnChange,
118
122
  defaultValues = EMPTY_OBJECT as K,
119
123
  onSubmit = DEFAULT_SUBMIT,
120
124
  onChange,
@@ -124,7 +128,7 @@ export const Form = <K extends KeyValue>({
124
128
  const form = useFormHook<K>({
125
129
  shouldFocusError: true,
126
130
  resolver,
127
- defaultValues: defaultValues as DefaultValues<K>,
131
+ defaultValues: async () => await Promise.resolve(defaultValues),
128
132
  });
129
133
 
130
134
  const [, startTransition] = useTransition();
@@ -136,16 +140,19 @@ export const Form = <K extends KeyValue>({
136
140
  return () => subscription.unsubscribe();
137
141
  }, [form.watch, changeHandler]);
138
142
 
139
- const handleReset = useCallback(
140
- (reset: AnyObject = {}) => {
141
- form.reset(reset);
142
- form.clearErrors();
143
- ref.current
144
- ?.querySelector<HTMLElement>("[auto-focus], input, textarea")
145
- ?.focus();
146
- },
147
- [defaultValues],
148
- );
143
+ const handleReset = useCallback((reset: AnyObject = {}) => {
144
+ form.reset(reset);
145
+ form.clearErrors();
146
+ ref.current
147
+ ?.querySelector<HTMLElement>("[auto-focus], input, textarea")
148
+ ?.focus();
149
+ }, []);
150
+
151
+ useEffect(() => {
152
+ if (resetOnChange) {
153
+ handleReset(defaultValues);
154
+ }
155
+ }, [defaultValues, resetOnChange]);
149
156
 
150
157
  useImperativeHandle(
151
158
  formRef,
@@ -204,32 +211,3 @@ export const Form = <K extends KeyValue>({
204
211
  </FormProvider>
205
212
  );
206
213
  };
207
-
208
- export const useForm = <K extends KeyValue = KeyValue>() => {
209
- const {
210
- formState,
211
- getValues,
212
- setValue,
213
- watch,
214
- reset,
215
- resetField,
216
- setError,
217
- setFocus,
218
- } = useFormContext<K>();
219
- const values = useWatch<K>();
220
-
221
- return {
222
- values: {
223
- ...values,
224
- ...getValues(),
225
- },
226
- formState,
227
- getValues,
228
- setValue,
229
- watch,
230
- reset,
231
- resetField,
232
- setError,
233
- setFocus,
234
- };
235
- };