@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.
- package/css/_colorPicker.css +35 -5
- package/css/_file.css +2 -2
- package/dist/cjs/builder/FileField.js +14 -11
- package/dist/cjs/builder/SchemaEditor.js +1 -1
- package/dist/cjs/builder/components/SchemaArrayForm.js +2 -4
- package/dist/cjs/builder/components/SchemaField.js +3 -3
- package/dist/cjs/form/Controller.js +1 -1
- package/dist/cjs/form/Form.js +42 -41
- package/dist/cjs/form/useForm.js +32 -0
- package/dist/cjs/hooks/useFileUploader.js +44 -32
- package/dist/cjs/hooks/useFormBuilder.js +3 -3
- package/dist/cjs/i18n/index.js +4 -4
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/input/ArrayInput.js +66 -19
- package/dist/cjs/input/AvatarInput.js +21 -16
- package/dist/cjs/input/Checkbox.js +1 -1
- package/dist/cjs/input/ColorInput.js +26 -19
- package/dist/cjs/input/ColorPicker.js +16 -9
- package/dist/cjs/input/DateInput.js +3 -3
- package/dist/cjs/input/Field.js +1 -1
- package/dist/cjs/input/File.js +1 -1
- package/dist/cjs/input/Hidden.js +2 -11
- package/dist/cjs/input/Input.js +1 -1
- package/dist/cjs/input/Number.js +1 -1
- package/dist/cjs/input/Password.js +1 -1
- package/dist/cjs/input/Radio.js +1 -1
- package/dist/cjs/input/RadioGroup.js +7 -3
- package/dist/cjs/input/RangeSlider.js +1 -1
- package/dist/cjs/input/Search.js +1 -1
- package/dist/cjs/input/Slider.js +1 -1
- package/dist/cjs/input/Switch.js +4 -4
- package/dist/cjs/input/Textarea.js +1 -1
- package/dist/cjs/internal/InputWrapper.js +2 -2
- package/dist/cjs/ranger/index.js +5 -5
- package/dist/cjs/select/AutoComplete.js +4 -2
- package/dist/cjs/select/DualList.js +3 -3
- package/dist/cjs/select/List.js +7 -4
- package/dist/cjs/select/Options.js +5 -4
- package/dist/cjs/select/Select.js +5 -3
- package/dist/cjs/select/useSelect.js +15 -13
- package/dist/esm/builder/FileField.js +14 -11
- package/dist/esm/builder/SchemaEditor.js +1 -1
- package/dist/esm/builder/components/SchemaArrayForm.js +2 -4
- package/dist/esm/builder/components/SchemaField.js +3 -3
- package/dist/esm/form/Controller.js +1 -1
- package/dist/esm/form/Form.js +45 -43
- package/dist/esm/form/useForm.js +32 -0
- package/dist/esm/hooks/useFileUploader.js +45 -33
- package/dist/esm/hooks/useFormBuilder.js +3 -3
- package/dist/esm/i18n/index.js +2 -2
- package/dist/esm/index.js +2 -1
- package/dist/esm/input/ArrayInput.js +66 -19
- package/dist/esm/input/AvatarInput.js +21 -16
- package/dist/esm/input/Checkbox.js +1 -1
- package/dist/esm/input/ColorInput.js +27 -20
- package/dist/esm/input/ColorPicker.js +17 -10
- package/dist/esm/input/DateInput.js +3 -3
- package/dist/esm/input/Field.js +1 -1
- package/dist/esm/input/File.js +1 -1
- package/dist/esm/input/Hidden.js +3 -12
- package/dist/esm/input/Input.js +1 -1
- package/dist/esm/input/Number.js +1 -1
- package/dist/esm/input/Password.js +1 -1
- package/dist/esm/input/Radio.js +1 -1
- package/dist/esm/input/RadioGroup.js +7 -3
- package/dist/esm/input/RangeSlider.js +1 -1
- package/dist/esm/input/Search.js +1 -1
- package/dist/esm/input/Slider.js +1 -1
- package/dist/esm/input/Switch.js +4 -4
- package/dist/esm/input/Textarea.js +1 -1
- package/dist/esm/internal/InputWrapper.js +2 -2
- package/dist/esm/ranger/index.js +5 -5
- package/dist/esm/select/AutoComplete.js +4 -2
- package/dist/esm/select/DualList.js +3 -3
- package/dist/esm/select/List.js +8 -5
- package/dist/esm/select/Options.js +5 -4
- package/dist/esm/select/Select.js +6 -4
- package/dist/esm/select/useSelect.js +15 -13
- package/dist/types/builder/FileField.d.ts +2 -1
- package/dist/types/builder/SchemaEditor.d.ts +1 -1
- package/dist/types/form/Controller.d.ts +1 -1
- package/dist/types/form/Form.d.ts +7 -14
- package/dist/types/form/useForm.d.ts +11 -0
- package/dist/types/hooks/useFileUploader.d.ts +4 -2
- package/dist/types/index.d.ts +3 -2
- package/dist/types/input/ArrayInput.d.ts +5 -4
- package/dist/types/input/AvatarInput.d.ts +2 -2
- package/dist/types/input/Checkbox.d.ts +2 -2
- package/dist/types/input/ColorInput.d.ts +1 -1
- package/dist/types/input/ColorPicker.d.ts +5 -1
- package/dist/types/input/DateInput.d.ts +1 -1
- package/dist/types/input/Field.d.ts +1 -1
- package/dist/types/input/File.d.ts +1 -1
- package/dist/types/input/Hidden.d.ts +4 -12
- package/dist/types/input/Input.d.ts +1 -1
- package/dist/types/input/Number.d.ts +1 -1
- package/dist/types/input/Password.d.ts +1 -1
- package/dist/types/input/Radio.d.ts +2 -2
- package/dist/types/input/RadioGroup.d.ts +7 -3
- package/dist/types/input/RangeSlider.d.ts +1 -1
- package/dist/types/input/Search.d.ts +1 -1
- package/dist/types/input/Slider.d.ts +1 -1
- package/dist/types/input/Switch.d.ts +2 -2
- package/dist/types/input/Textarea.d.ts +1 -1
- package/dist/types/select/AutoComplete.d.ts +1 -1
- package/dist/types/select/DualList.d.ts +1 -1
- package/dist/types/select/List.d.ts +1 -1
- package/dist/types/select/Select.d.ts +1 -1
- package/dist/types/types/index.d.ts +3 -3
- package/dist/types/types/schema.d.ts +1 -1
- package/package.json +14 -14
- package/src/builder/FileField.tsx +5 -3
- package/src/builder/SchemaEditor.tsx +2 -2
- package/src/builder/components/SchemaArrayForm.tsx +1 -3
- package/src/builder/components/SchemaField.tsx +3 -3
- package/src/form/Controller.tsx +1 -1
- package/src/form/Form.tsx +21 -43
- package/src/form/useForm.ts +44 -0
- package/src/hooks/useFileUploader.ts +41 -29
- package/src/i18n/index.ts +2 -2
- package/src/index.ts +3 -7
- package/src/input/ArrayInput.tsx +20 -10
- package/src/input/AvatarInput.tsx +12 -12
- package/src/input/Checkbox.tsx +2 -2
- package/src/input/ColorInput.tsx +29 -45
- package/src/input/ColorPicker.tsx +42 -49
- package/src/input/DateInput.tsx +3 -3
- package/src/input/Field.tsx +2 -2
- package/src/input/File.tsx +1 -1
- package/src/input/Hidden.tsx +5 -25
- package/src/input/Input.tsx +1 -1
- package/src/input/Number.tsx +1 -1
- package/src/input/Password.tsx +1 -1
- package/src/input/Radio.tsx +2 -2
- package/src/input/RadioGroup.tsx +11 -3
- package/src/input/RangeSlider.tsx +1 -1
- package/src/input/Search.tsx +1 -1
- package/src/input/Slider.tsx +1 -1
- package/src/input/Switch.tsx +6 -6
- package/src/input/Textarea.tsx +1 -1
- package/src/internal/InputWrapper.tsx +1 -2
- package/src/select/AutoComplete.tsx +13 -52
- package/src/select/DualList.tsx +3 -3
- package/src/select/List.tsx +31 -69
- package/src/select/Options.tsx +4 -3
- package/src/select/Select.tsx +19 -41
- package/src/select/useSelect.tsx +24 -69
- package/src/types/index.ts +3 -3
- package/src/types/schema.ts +1 -1
- /package/dist/cjs/i18n/{ar.json.js → ar/form.json.js} +0 -0
- /package/dist/cjs/i18n/{en.json.js → en/form.json.js} +0 -0
- /package/dist/esm/i18n/{ar.json.js → ar/form.json.js} +0 -0
- /package/dist/esm/i18n/{en.json.js → en/form.json.js} +0 -0
- /package/src/i18n/{ar.json → ar/form.json} +0 -0
- /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?:
|
|
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 {
|
|
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 {
|
|
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?:
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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;
|
|
@@ -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 {
|
|
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
|
|
7
|
+
* hidden input value
|
|
8
8
|
*/
|
|
9
|
-
|
|
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 {
|
|
17
|
+
* @returns {React.ReactElement} The rendered hidden input field and error icon.
|
|
26
18
|
*/
|
|
27
|
-
export declare const HiddenInput: ({
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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?:
|
|
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 {
|
|
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?:
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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?:
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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?:
|
|
42
|
+
appendLabel?: React.ReactElement | string | number | boolean;
|
|
43
43
|
/**
|
|
44
44
|
*
|
|
45
45
|
*/
|
|
46
|
-
decorateStart?:
|
|
46
|
+
decorateStart?: React.ReactElement | string | number | boolean;
|
|
47
47
|
/**
|
|
48
48
|
*
|
|
49
49
|
*/
|
|
50
|
-
decorateEnd?:
|
|
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<
|
|
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.
|
|
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.
|
|
42
|
+
"@floating-ui/react": "~0.27.19",
|
|
43
43
|
"@hookform/resolvers": "~5.2.2",
|
|
44
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
45
|
-
"@react-fabric/date": "^1.0.0-beta.
|
|
46
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
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.
|
|
50
|
+
"react-hook-form": "~7.71.2"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"i18next": "~25.
|
|
54
|
-
"react": "~19.2.
|
|
55
|
-
"react-dom": "~19.2.
|
|
56
|
-
"react-i18next": "~16.
|
|
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.
|
|
63
|
-
"npm": ">=8.
|
|
62
|
+
"node": ">=22.18.0",
|
|
63
|
+
"npm": ">=10.8.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
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,
|
|
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
|
|
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 {
|
|
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-
|
|
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
|
-
|
|
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-
|
|
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
|
|
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
|
-
|
|
287
|
+
<OptionModal />
|
|
288
288
|
</Fragment>
|
|
289
289
|
)}
|
|
290
290
|
{type === DATA_TYPES.FILE && (
|
package/src/form/Controller.tsx
CHANGED
|
@@ -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 {
|
|
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 {
|
|
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:
|
|
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
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
};
|