@react-fabric/form 1.0.0-beta.51 → 1.0.0-beta.52
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/cjs/form/Controller.js +45 -0
- package/dist/cjs/form/Form.js +32 -0
- package/dist/cjs/hooks/useFileUploader.js +16 -0
- package/dist/cjs/hooks/useFormBuilder.js +30 -0
- package/dist/cjs/i18n/ar.json.js +5 -4
- package/dist/cjs/i18n/en.json.js +5 -5
- package/dist/cjs/input/ArrayInput.js +39 -0
- package/dist/cjs/input/AvatarInput.js +8 -0
- package/dist/cjs/input/Checkbox.js +9 -0
- package/dist/cjs/input/ColorInput.js +13 -0
- package/dist/cjs/input/ColorPicker.js +10 -0
- package/dist/cjs/input/DateInput.js +9 -0
- package/dist/cjs/input/Field.js +5 -0
- package/dist/cjs/input/File.js +10 -0
- package/dist/cjs/input/Hidden.js +8 -0
- package/dist/cjs/input/Input.js +8 -0
- package/dist/cjs/input/Number.js +8 -0
- package/dist/cjs/input/Password.js +6 -0
- package/dist/cjs/input/Radio.js +9 -0
- package/dist/cjs/input/RadioGroup.js +8 -0
- package/dist/cjs/input/RangeSlider.js +9 -1
- package/dist/cjs/input/Search.js +9 -0
- package/dist/cjs/input/Slider.js +7 -1
- package/dist/cjs/input/Switch.js +9 -0
- package/dist/cjs/input/Textarea.js +10 -0
- package/dist/cjs/select/AutoComplete.js +7 -0
- package/dist/cjs/select/DualList.js +11 -0
- package/dist/esm/form/Controller.js +45 -0
- package/dist/esm/form/Form.js +32 -0
- package/dist/esm/hooks/useFileUploader.js +16 -0
- package/dist/esm/hooks/useFormBuilder.js +30 -0
- package/dist/esm/i18n/ar.json.js +5 -4
- package/dist/esm/i18n/en.json.js +5 -5
- package/dist/esm/input/ArrayInput.js +39 -0
- package/dist/esm/input/AvatarInput.js +8 -0
- package/dist/esm/input/Checkbox.js +9 -0
- package/dist/esm/input/ColorInput.js +13 -0
- package/dist/esm/input/ColorPicker.js +10 -0
- package/dist/esm/input/DateInput.js +9 -0
- package/dist/esm/input/Field.js +5 -0
- package/dist/esm/input/File.js +10 -0
- package/dist/esm/input/Hidden.js +8 -0
- package/dist/esm/input/Input.js +8 -0
- package/dist/esm/input/Number.js +8 -0
- package/dist/esm/input/Password.js +6 -0
- package/dist/esm/input/Radio.js +9 -0
- package/dist/esm/input/RadioGroup.js +8 -0
- package/dist/esm/input/RangeSlider.js +9 -1
- package/dist/esm/input/Search.js +9 -0
- package/dist/esm/input/Slider.js +7 -1
- package/dist/esm/input/Switch.js +9 -0
- package/dist/esm/input/Textarea.js +10 -0
- package/dist/esm/select/AutoComplete.js +7 -0
- package/dist/esm/select/DualList.js +11 -0
- package/dist/types/builder/SchemaEditor.d.ts +7 -0
- package/dist/types/form/Controller.d.ts +45 -0
- package/dist/types/form/Form.d.ts +32 -1
- package/dist/types/hooks/useFileUploader.d.ts +16 -0
- package/dist/types/hooks/useFormBuilder.d.ts +30 -1
- package/dist/types/input/ArrayInput.d.ts +40 -1
- package/dist/types/input/AvatarInput.d.ts +8 -0
- package/dist/types/input/Checkbox.d.ts +9 -0
- package/dist/types/input/ColorInput.d.ts +13 -0
- package/dist/types/input/ColorPicker.d.ts +10 -0
- package/dist/types/input/DateInput.d.ts +9 -0
- package/dist/types/input/Field.d.ts +5 -0
- package/dist/types/input/File.d.ts +9 -0
- package/dist/types/input/Hidden.d.ts +8 -0
- package/dist/types/input/Input.d.ts +8 -0
- package/dist/types/input/Number.d.ts +8 -0
- package/dist/types/input/Password.d.ts +6 -0
- package/dist/types/input/Radio.d.ts +9 -0
- package/dist/types/input/RadioGroup.d.ts +8 -0
- package/dist/types/input/RangeSlider.d.ts +9 -1
- package/dist/types/input/Search.d.ts +9 -0
- package/dist/types/input/Slider.d.ts +7 -1
- package/dist/types/input/Switch.d.ts +9 -0
- package/dist/types/input/Textarea.d.ts +10 -0
- package/dist/types/select/AutoComplete.d.ts +7 -0
- package/dist/types/select/DualList.d.ts +12 -1
- package/dist/types/select/List.d.ts +9 -1
- package/dist/types/select/Select.d.ts +9 -1
- package/dist/types/select/useSelect.d.ts +11 -2
- package/package.json +5 -5
- package/src/builder/SchemaEditor.tsx +7 -0
- package/src/form/Controller.tsx +45 -0
- package/src/form/Form.tsx +31 -0
- package/src/hooks/useFileUploader.ts +16 -0
- package/src/hooks/useFormBuilder.tsx +29 -0
- package/src/i18n/ar.json +5 -4
- package/src/i18n/en.json +5 -5
- package/src/input/ArrayInput.tsx +39 -0
- package/src/input/AvatarInput.tsx +8 -0
- package/src/input/Checkbox.tsx +9 -0
- package/src/input/ColorInput.tsx +13 -0
- package/src/input/ColorPicker.tsx +10 -0
- package/src/input/DateInput.tsx +9 -0
- package/src/input/Field.tsx +5 -0
- package/src/input/File.tsx +9 -0
- package/src/input/Hidden.tsx +8 -0
- package/src/input/Input.tsx +8 -0
- package/src/input/Number.tsx +8 -0
- package/src/input/Password.tsx +6 -0
- package/src/input/Radio.tsx +9 -0
- package/src/input/RadioGroup.tsx +8 -0
- package/src/input/RangeSlider.tsx +9 -1
- package/src/input/Search.tsx +9 -0
- package/src/input/Slider.tsx +7 -1
- package/src/input/Switch.tsx +9 -0
- package/src/input/Textarea.tsx +10 -0
- package/src/select/AutoComplete.tsx +7 -0
- package/src/select/DualList.tsx +11 -0
- package/src/select/List.tsx +8 -0
- package/src/select/Select.tsx +8 -0
|
@@ -17,4 +17,49 @@ export interface ControllerProps {
|
|
|
17
17
|
ref?: React.Ref<HTMLInputElement>;
|
|
18
18
|
}) => ReactElement);
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* This component is used to wrap form controls
|
|
22
|
+
* and provide them with the necessary props and state management.
|
|
23
|
+
*
|
|
24
|
+
* It uses the `Controller` component from `react-hook-form`
|
|
25
|
+
* to manage the form state and validation.
|
|
26
|
+
*
|
|
27
|
+
* It accepts a `name` prop to identify the form control,
|
|
28
|
+
* and a `children` prop which can either be a React element
|
|
29
|
+
* or a function that receives the necessary props to render the control.
|
|
30
|
+
*
|
|
31
|
+
* The component will pass down the following props to the child:
|
|
32
|
+
* - `name`: the name of the form control
|
|
33
|
+
* - `error`: any validation error message
|
|
34
|
+
* - `checked`: whether the control is checked (for checkboxes/radios)
|
|
35
|
+
* - `value`: the current value of the control
|
|
36
|
+
* - `invalid`: whether the control is invalid
|
|
37
|
+
* - `readOnly`: whether the control is read-only (disabled during submission)
|
|
38
|
+
* - `disabled`: whether the control is disabled
|
|
39
|
+
* - `onBlur`: function to call when the control loses focus
|
|
40
|
+
* - `onChange`: function to call when the control value changes
|
|
41
|
+
* - `ref`: a ref to the control element
|
|
42
|
+
* * The component also handles the `ref` prop to ensure that it is passed correctly
|
|
43
|
+
* to the child component, allowing for proper focus management and DOM access.
|
|
44
|
+
*
|
|
45
|
+
* @param {ControllerProps} props - The properties for the Controller component.
|
|
46
|
+
* @returns {JSX.Element} The rendered Controller component.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```jsx
|
|
50
|
+
* <Controller
|
|
51
|
+
* name="username"
|
|
52
|
+
* children={({ name, error, checked, value, invalid, readOnly, onChange }) => (
|
|
53
|
+
* <input
|
|
54
|
+
* type="text"
|
|
55
|
+
* name={name}
|
|
56
|
+
* onChange={onChange}
|
|
57
|
+
* readOnly={readOnly}
|
|
58
|
+
* aria-invalid={invalid}
|
|
59
|
+
* value={value}
|
|
60
|
+
* />
|
|
61
|
+
* )}
|
|
62
|
+
* />
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
20
65
|
export declare const Controller: ({ name, children, ...rest }: ControllerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -33,5 +33,36 @@ export interface FormProps<K extends KeyValue = KeyValue> {
|
|
|
33
33
|
*/
|
|
34
34
|
onSubmit?: (values: K) => void;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Form component for managing form state and validation using react-hook-form and yup.
|
|
38
|
+
* It provides a simple interface for form handling, including submission, validation, and value management.
|
|
39
|
+
* It supports nested form structures and allows for custom validation schemas using Yup.
|
|
40
|
+
*
|
|
41
|
+
* @param {FormProps<K>} props - The properties for the Form component.
|
|
42
|
+
* @returns {JSX.Element} The rendered Form component.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```jsx
|
|
46
|
+
* <Form
|
|
47
|
+
* formRef={formRef}
|
|
48
|
+
* schema={yup.object().shape({
|
|
49
|
+
* name: yup.string().required("Name is required"),
|
|
50
|
+
* email: yup.string().email("Invalid email").required("Email is required"),
|
|
51
|
+
* })}
|
|
52
|
+
* defaultValues={{ name: "", email: "" }}
|
|
53
|
+
* onSubmit={(values) => {
|
|
54
|
+
* console.log("Form submitted with values:", values);
|
|
55
|
+
* }}
|
|
56
|
+
* >
|
|
57
|
+
* <input name="name" ref={form.register} placeholder="Name" />
|
|
58
|
+
* <input name="email" ref={form.register} placeholder="Email" />
|
|
59
|
+
* <button type="submit">Submit</button>
|
|
60
|
+
* </Form>
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/form-form--docs} for the properties that can be passed to this component.
|
|
64
|
+
* @see {@link https://react-hook-form.com/docs/useform} for more details on the properties.
|
|
65
|
+
* @see {@link https://github.com/jquense/yup} for more details on the Yup validation schema.
|
|
66
|
+
*/
|
|
67
|
+
export declare const Form: <K extends KeyValue>({ formRef, schema, children, defaultValues, onSubmit, onChange, ...rest }: PropsWithChildren<FormProps<K>>) => import("react/jsx-runtime").JSX.Element;
|
|
37
68
|
export {};
|
|
@@ -12,6 +12,22 @@ interface FileInfo {
|
|
|
12
12
|
progress?: number;
|
|
13
13
|
abort?: AbortController["abort"];
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* useFileUploader hook provides a way to handle file uploads
|
|
17
|
+
* with progress tracking, error handling, and file management.
|
|
18
|
+
* It uses a reducer to manage the state of uploaded files and their statuses.
|
|
19
|
+
*
|
|
20
|
+
* @param uploader - The function that handles the file upload.
|
|
21
|
+
* @param initialList - Initial list of files to be managed by the uploader.
|
|
22
|
+
* @param multiple - Whether to allow multiple file uploads or not.
|
|
23
|
+
* @returns An object containing methods to upload, remove, retry files,
|
|
24
|
+
* and the current state of the uploader including pending uploads and file list.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```jsx
|
|
28
|
+
* const { upload, remove, retry, state } = useFileUploader(uploader, initialList, multiple);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
15
31
|
export declare const useFileUploader: (uploader: UploadHandler, initialList?: string | FileInfo | FileInfo[], multiple?: boolean) => {
|
|
16
32
|
upload: (files: FileList | null) => void;
|
|
17
33
|
remove: (key: string) => void;
|
|
@@ -2,7 +2,36 @@ import { yup } from "@react-fabric/utilities";
|
|
|
2
2
|
import { type BaseSelectProps } from "../types";
|
|
3
3
|
import { type FormSchema } from "../types/schema";
|
|
4
4
|
import { type UploadHandler } from "./useFileUploader";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* useFormBuilder hook to create a form definition based on a schema.
|
|
7
|
+
* It generates a Yup validation schema and a form definition component.
|
|
8
|
+
*
|
|
9
|
+
* @param {FormSchema} schema - The schema defining the form fields.
|
|
10
|
+
* @param {Object} options - Optional parameters for the form builder.
|
|
11
|
+
* @returns An object containing the form definition and the Yup validation schema.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```jsx
|
|
15
|
+
* const { formDef, schemaDef } = useFormBuilder(schema, {
|
|
16
|
+
* prefix: "form",
|
|
17
|
+
* inline: true,
|
|
18
|
+
* fileUrl: (path) => `/files/${path}`,
|
|
19
|
+
* uploadHandler: async (file) => {
|
|
20
|
+
* // handle file upload
|
|
21
|
+
* },
|
|
22
|
+
* optionLists: {
|
|
23
|
+
* // define option lists for select fields
|
|
24
|
+
* }
|
|
25
|
+
* * });
|
|
26
|
+
* <FormBuilder
|
|
27
|
+
* schema={schemaDef}
|
|
28
|
+
* onSubmit={(data) => console.log(data)}
|
|
29
|
+
* >
|
|
30
|
+
* {formDef}
|
|
31
|
+
* </FormBuilder>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const useFormBuilder: <T extends AnyObject = string>(schema: FormSchema, options?: {
|
|
6
35
|
prefix?: string;
|
|
7
36
|
inline?: boolean;
|
|
8
37
|
fileUrl?: (path: string) => string;
|
|
@@ -94,4 +94,43 @@ export interface ArrayInputProps<T extends AnyObject = string> {
|
|
|
94
94
|
*/
|
|
95
95
|
labelWidth?: string;
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
/**
|
|
98
|
+
* ArrayInput component for managing an array of items in a form.
|
|
99
|
+
* It allows adding, removing, and sorting items within the array.
|
|
100
|
+
* It integrates with react-hook-form for form state management and validation.
|
|
101
|
+
* It supports fixed-length lists, custom add/remove handlers, and can display validation errors.
|
|
102
|
+
* It also provides options for inline display and custom button positioning.
|
|
103
|
+
*
|
|
104
|
+
* It uses the `useFieldArray` hook from `react-hook-form` to manage the array state and provides a simple interface for adding and removing items.
|
|
105
|
+
*
|
|
106
|
+
* It also supports drag-and-drop sorting using `@dnd-kit/core` and `@dnd-kit/sortable` for a better user experience when reordering items.
|
|
107
|
+
*
|
|
108
|
+
* @param {ArrayInputProps<T>} props - The properties for the ArrayInput component.
|
|
109
|
+
* @returns {JSX.Element} The rendered ArrayInput component.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```jsx
|
|
113
|
+
* <ArrayInput
|
|
114
|
+
* name="items"
|
|
115
|
+
* label="Items"
|
|
116
|
+
* addLabel="Add Item"
|
|
117
|
+
* onAdd={() => ({ name: "", value: "" })}
|
|
118
|
+
* onRemove={(item, index) => console.log("Removed item:", item, "at index:", index)}
|
|
119
|
+
* onBeforeRemove={(item, index) => confirm(`Are you sure you want to remove item at index ${index}?`)}
|
|
120
|
+
* canRemove={({ item, index, lastItem }) => !lastItem} // Prevent removing the last item
|
|
121
|
+
* >
|
|
122
|
+
* {({ index, name }) => (
|
|
123
|
+
* <Input
|
|
124
|
+
* name={name}
|
|
125
|
+
* label={`Item ${index + 1}`}
|
|
126
|
+
* placeholder="Enter item value"
|
|
127
|
+
* required={index === 0} // Make the first item required
|
|
128
|
+
* />
|
|
129
|
+
* )}
|
|
130
|
+
* </ArrayInput>
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* @see {@link https://react-hook-form.com/api/usefieldarray} for more details on `useFieldArray`.
|
|
134
|
+
* @see {@link https://react-dnd.github.io/react-dnd/about} for more details on DnD context and sorting.
|
|
135
|
+
*/
|
|
136
|
+
export declare const ArrayInput: <T extends AnyObject = string>({ name, children, addLabel, fixedList, focusName, buttonPosition, onAdd, onRemove, onBeforeRemove, canRemove, arrayRef, enableSorting, disabled, readOnly, minItems, maxItems, ...rest }: ArrayInputProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -31,4 +31,12 @@ export interface Props extends RefProp {
|
|
|
31
31
|
*/
|
|
32
32
|
onChange?: (path: string) => void;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Avatar input component for uploading and displaying user avatars.
|
|
36
|
+
* It allows users to select an image file, upload it, and display the avatar.
|
|
37
|
+
* It also provides a way to remove the uploaded file and shows upload progress.
|
|
38
|
+
*
|
|
39
|
+
* @param {Props} props - The properties for the AvatarInput component.
|
|
40
|
+
* @returns {JSX.Element} - The rendered AvatarInput component.
|
|
41
|
+
*/
|
|
34
42
|
export declare const AvatarInput: ({ size, avatarName, value, fileUrl, uploadHandler, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -42,5 +42,14 @@ interface CheckboxProps extends RefProp<HTMLInputElement> {
|
|
|
42
42
|
iconChecked?: string;
|
|
43
43
|
name?: string;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Checkbox component for rendering a checkbox input with label and error handling.
|
|
47
|
+
* It supports custom icons for checked and unchecked states, and handles disabled and invalid states.
|
|
48
|
+
* The component uses a deferred value to manage the checked state, ensuring smooth updates.
|
|
49
|
+
* It also provides an error icon to indicate validation errors.
|
|
50
|
+
*
|
|
51
|
+
* @param {CheckboxProps} props - The properties for the Checkbox component.
|
|
52
|
+
* @returns {JSX.Element} The rendered Checkbox component.
|
|
53
|
+
*/
|
|
45
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;
|
|
46
55
|
export {};
|
|
@@ -7,4 +7,17 @@ export interface ColorInputProps extends InputProps, Omit<ColorProps, "onChange"
|
|
|
7
7
|
*/
|
|
8
8
|
showPicker?: boolean;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Color input component that allows users to select a color
|
|
12
|
+
* and optionally use an eye dropper to pick a color from the screen.
|
|
13
|
+
* It uses the Floating UI library for positioning the color picker.
|
|
14
|
+
* It also provides a button to clear the selected color.
|
|
15
|
+
*
|
|
16
|
+
* This component is a wrapper around the `ColorPicker` component
|
|
17
|
+
* and provides additional functionality such as showing an eye dropper
|
|
18
|
+
* and handling the color selection state.
|
|
19
|
+
*
|
|
20
|
+
* @param {ColorInputProps} props - The properties for the ColorInput component.
|
|
21
|
+
* @returns {JSX.Element} - The rendered ColorInput component.
|
|
22
|
+
*/
|
|
10
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;
|
|
@@ -21,4 +21,14 @@ export interface ColorProps {
|
|
|
21
21
|
*/
|
|
22
22
|
onChange?: (color?: string) => void;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* ColorPicker component allows users to select a color using a color picker UI.
|
|
26
|
+
* It supports swatches, alpha transparency, and custom styles.
|
|
27
|
+
* The component uses the `react-color` library for the color picker functionality.
|
|
28
|
+
*
|
|
29
|
+
* @param {ColorProps} props - The properties for the ColorPicker component.
|
|
30
|
+
* @returns {JSX.Element} The rendered ColorPicker component.
|
|
31
|
+
*
|
|
32
|
+
* @see {@link https://react-color.github.io/react-color/} for more details on the color picker library.
|
|
33
|
+
*/
|
|
24
34
|
export declare const ColorPicker: FC<ColorProps>;
|
|
@@ -16,4 +16,13 @@ export interface DateProps extends InputProps<string>, RefProp<HTMLInputElement>
|
|
|
16
16
|
*/
|
|
17
17
|
max?: DateLike;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Date input component that allows users to select a date or datetime.
|
|
21
|
+
* It uses the Floating UI library for positioning the date picker.
|
|
22
|
+
* It also provides a button to clear the selected date.
|
|
23
|
+
* The component supports both date and datetime types, with appropriate formatting.
|
|
24
|
+
*
|
|
25
|
+
* @param {DateProps} props - The properties for the DateInput component.
|
|
26
|
+
* @returns {JSX.Element} - The rendered DateInput component.
|
|
27
|
+
*/
|
|
19
28
|
export declare const DateInput: ({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, type, onBlur, onFocus, onChange, onEnterPressed, format, min, max, ...rest }: DateProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -38,4 +38,9 @@ export interface FieldProps extends ChildrenProp, CssProp {
|
|
|
38
38
|
plain?: boolean;
|
|
39
39
|
vertical?: boolean;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Field component for rendering multiple form fields under a single label.
|
|
43
|
+
* It supports various properties for customization, including label, info, required state,
|
|
44
|
+
* and styling options.
|
|
45
|
+
*/
|
|
41
46
|
export declare const Field: ({ children, vertical, noOutline, plain, ...rest }: FieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,4 +14,13 @@ export interface FileInputProps extends InputProps<AnyObject>, RefProp<HTMLInput
|
|
|
14
14
|
*/
|
|
15
15
|
accept?: string;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* File input component that allows users to select files from their system.
|
|
19
|
+
* It supports multiple file selection and displays a list of selected files.
|
|
20
|
+
* The component also provides functionality to remove files from the list.
|
|
21
|
+
* It handles file changes, invalid states, and read-only or disabled states.
|
|
22
|
+
*
|
|
23
|
+
* @param {FileInputProps} props - The properties for the FileInput component.
|
|
24
|
+
* @returns {JSX.Element} - The rendered FileInput component.
|
|
25
|
+
*/
|
|
17
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;
|
|
@@ -12,5 +12,13 @@ interface Props {
|
|
|
12
12
|
*/
|
|
13
13
|
onChange?: (value: AnyObject) => void;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Hidden input component to handle hidden values in forms.
|
|
17
|
+
* It will trigger the onChange handler with the hidden value after a short delay.
|
|
18
|
+
* This is useful for cases where you need to update the form state without user interaction.
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} props - Component properties.
|
|
21
|
+
* @returns {JSX.Element} The rendered hidden input field and error icon.
|
|
22
|
+
*/
|
|
15
23
|
export declare const HiddenInput: ({ hiddenValue, onChange, invalid, error, value, name, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
16
24
|
export {};
|
|
@@ -6,4 +6,12 @@ export interface TextInputProps extends InputProps, RefProp<HTMLInputElement> {
|
|
|
6
6
|
*/
|
|
7
7
|
type?: "email" | "file" | "search" | "tel" | "text" | "url";
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* This component is used to render a text input field with various properties such as name, value, invalid state, read-only, disabled, required, placeholder, autoFocus, error message, monospace font option, and event handlers for blur, focus, change, and enter key press.
|
|
11
|
+
* It also includes a clear button that appears when there is a value in the input field, allowing users to clear the input easily.
|
|
12
|
+
* The component uses a wrapper to handle the clear button and styling, and it supports deferred value updates to optimize performance.
|
|
13
|
+
*
|
|
14
|
+
* @param {TextInputProps} props - The properties for the text input component.
|
|
15
|
+
* @returns {JSX.Element} - A JSX element representing the text input field.
|
|
16
|
+
*/
|
|
9
17
|
export declare const Input: ({ ref, name, value, invalid, readOnly, disabled, required, placeholder, autoFocus, error, monospace, type, onBlur, onFocus, onChange, onEnterPressed, ...rest }: TextInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,4 +14,12 @@ export interface NumberProps extends InputProps<number>, RefProp<HTMLInputElemen
|
|
|
14
14
|
*/
|
|
15
15
|
step?: number;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* This component allows users to input numeric values with optional minimum, maximum, and step constraints.
|
|
19
|
+
* It provides a clear interface for entering numbers, with support for validation and accessibility features.
|
|
20
|
+
* It also includes a clear button to reset the input value.
|
|
21
|
+
*
|
|
22
|
+
* @param {NumberProps} props - The properties for the Number input component.
|
|
23
|
+
* @returns {JSX.Element} The rendered Number input component.
|
|
24
|
+
*/
|
|
17
25
|
export declare const Number: ({ ref, value, invalid, readOnly, disabled, required, placeholder, autoFocus, name, min, max, step, onBlur, onFocus, onChange, onEnterPressed, ...rest }: NumberProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,4 +10,10 @@ export interface PasswordProps extends InputProps, RefProp<HTMLInputElement> {
|
|
|
10
10
|
*/
|
|
11
11
|
strength?: number;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Password input component with optional strength meter and toggle visibility.
|
|
15
|
+
*
|
|
16
|
+
* @param {PasswordProps} props - The properties for the Password component.
|
|
17
|
+
* @returns {JSX.Element} The rendered Password input component.
|
|
18
|
+
*/
|
|
13
19
|
export declare const Password: ({ ref, value, name, strength, invalid, readOnly, disabled, required, placeholder, autoFocus, showToggle, onBlur, onFocus, onChange, onEnterPressed, ...rest }: PasswordProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -38,4 +38,13 @@ export interface RadioProps extends RefProp<HTMLInputElement> {
|
|
|
38
38
|
*/
|
|
39
39
|
iconChecked?: string;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Radio input component with custom icons and label.
|
|
43
|
+
*
|
|
44
|
+
* This component renders a radio button with an optional label and custom icons for checked and unchecked states.
|
|
45
|
+
* It supports disabled and invalid states, and allows for custom width.
|
|
46
|
+
*
|
|
47
|
+
* @param {RadioProps} props - The properties for the Radio component.
|
|
48
|
+
* @returns {JSX.Element} The rendered Radio input component.
|
|
49
|
+
*/
|
|
41
50
|
export declare const Radio: ({ ref, name, label, value, invalid, disabled, error, width, icon, iconChecked, onChange, ...rest }: RadioProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -42,4 +42,12 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
|
|
|
42
42
|
*/
|
|
43
43
|
onChange?: (value: AnyObject) => void;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* RadioGroup component for rendering a group of radio buttons.
|
|
47
|
+
* It allows for customization of the label, options, and layout.
|
|
48
|
+
* The component supports inline and vertical orientations, and can handle change events.
|
|
49
|
+
*
|
|
50
|
+
* @param {RadioGroupProps} props - The properties for the RadioGroup component.
|
|
51
|
+
* @returns {JSX.Element} The rendered RadioGroup component.
|
|
52
|
+
*/
|
|
45
53
|
export declare const RadioGroup: ({ children, name, className, optionWidth, onChange, ...rest }: RadioGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -54,6 +54,14 @@ export interface RangeProps extends Omit<InputProps<[number, number]>, "placehol
|
|
|
54
54
|
onSlide?: (val: number) => void;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* RangeSlider component for rendering a range slider input.
|
|
58
|
+
* It supports vertical orientation, custom colors, step increments,
|
|
59
|
+
* min/max values, and display of labels and value tooltips.
|
|
60
|
+
* The component uses the Ranger library for handling the slider functionality.
|
|
61
|
+
* It also provides error handling and supports disabled and read-only states.
|
|
62
|
+
* The component is designed to be flexible and customizable, allowing for various configurations.
|
|
63
|
+
*
|
|
64
|
+
* @param {RangeProps} props - The properties for the RangeSlider component.
|
|
65
|
+
* @returns {JSX.Element} The rendered RangeSlider component.
|
|
58
66
|
*/
|
|
59
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;
|
|
@@ -18,4 +18,13 @@ export interface SearchProps extends InputProps, RefProp<HTMLInputElement> {
|
|
|
18
18
|
*/
|
|
19
19
|
onSearch?: (query?: string) => void;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Search input component with optional searching state and search handler.
|
|
23
|
+
* This component allows users to input search queries and trigger a search action.
|
|
24
|
+
* It supports features like searching on value change, showing a search handle,
|
|
25
|
+
* and handling search actions with a debounce mechanism.
|
|
26
|
+
*
|
|
27
|
+
* @param {SearchProps} props - The properties for the Search component.
|
|
28
|
+
* @returns {JSX.Element} The rendered Search input component.
|
|
29
|
+
*/
|
|
21
30
|
export declare const Search: ({ ref, value, name, invalid, readOnly, disabled, required, searching, placeholder, autoFocus, hideHandle, allowClear, searchOnChange, onBlur, onFocus, onSearch, onChange, onEnterPressed, ...rest }: SearchProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -58,6 +58,12 @@ export interface SliderProps extends Omit<InputProps<number>, "placeholder" | "a
|
|
|
58
58
|
onSlide?: (val: number) => void;
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Slider component for rendering a slider input with labels and value display.
|
|
62
|
+
* It supports vertical orientation, custom min/max labels, and step ranges.
|
|
63
|
+
* The component handles value changes, displays tooltips, and integrates with ranger for slider functionality.
|
|
64
|
+
* It also supports deferred value updates for smoother interactions.
|
|
65
|
+
*
|
|
66
|
+
* @param {SliderProps} props - The properties for the Slider component.
|
|
67
|
+
* @returns {JSX.Element} The rendered Slider component.
|
|
62
68
|
*/
|
|
63
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;
|
|
@@ -42,4 +42,13 @@ export interface SwitchProps extends RefProp<HTMLInputElement> {
|
|
|
42
42
|
offLabel?: string;
|
|
43
43
|
offLabelColor?: string | ColorType;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Switch input component with custom labels and colors.
|
|
47
|
+
* This component renders a switch input with optional labels for the "on" and "off" states,
|
|
48
|
+
* and allows for custom colors for the switch background and labels.
|
|
49
|
+
* It supports disabled and invalid states, and handles change events.
|
|
50
|
+
*
|
|
51
|
+
* @param {SwitchProps} props - The properties for the Switch component.
|
|
52
|
+
* @returns {JSX.Element} The rendered Switch input component.
|
|
53
|
+
*/
|
|
45
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;
|
|
@@ -18,4 +18,14 @@ export interface TextareaProps extends InputProps, RefProp<HTMLTextAreaElement>
|
|
|
18
18
|
*/
|
|
19
19
|
expandable?: boolean;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Textarea component that allows users to input multi-line text.
|
|
23
|
+
* It supports features like variable row count, expandable behavior,
|
|
24
|
+
* and handling of focus, blur, and change events.
|
|
25
|
+
* This component is designed to be flexible and user-friendly,
|
|
26
|
+
* providing a clear interface for text input with optional validation and accessibility features.
|
|
27
|
+
*
|
|
28
|
+
* @param {TextareaProps} props - The properties for the Textarea component.
|
|
29
|
+
* @returns {JSX.Element} The rendered Textarea component.
|
|
30
|
+
*/
|
|
21
31
|
export declare const Textarea: ({ ref, value, name, invalid, readOnly, disabled, required, placeholder, autoFocus, rows, maxRows, variableRows, expandable, onBlur, onFocus, onChange, onEnterPressed, ...rest }: TextareaProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -13,5 +13,12 @@ type AutoCompleteProps = Omit<SelectProps<string>, "options" | "allowCreate" | "
|
|
|
13
13
|
*/
|
|
14
14
|
onInput?: (query: string) => void;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* AutoComplete component for selecting or entering values with history suggestions.
|
|
18
|
+
* It supports multiple selections, history suggestions, and custom styling.
|
|
19
|
+
*
|
|
20
|
+
* @param {AutoCompleteProps} props - The properties for the AutoComplete component.
|
|
21
|
+
* @returns {JSX.Element} The rendered AutoComplete component.
|
|
22
|
+
*/
|
|
16
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;
|
|
17
24
|
export {};
|
|
@@ -39,4 +39,15 @@ export interface DualListProps<T> extends Omit<FieldProps, "children">, RefProp<
|
|
|
39
39
|
*/
|
|
40
40
|
onChange?: (value?: string[]) => void;
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
/**
|
|
43
|
+
* DualList component allows users to select items from two lists.
|
|
44
|
+
* It displays two lists side by side, one for unselected items and one for selected items.
|
|
45
|
+
* Users can move items between the lists using buttons or drag-and-drop functionality.
|
|
46
|
+
* It supports multiple selections and provides options for grouping, labeling, and rendering items.
|
|
47
|
+
* It also includes features for handling empty states and custom rendering of items.
|
|
48
|
+
* This component is useful for scenarios where users need to manage selections from a larger set of options, such as in forms or settings.
|
|
49
|
+
*
|
|
50
|
+
* @param {DualListProps<T>} props - The properties for the DualList component.
|
|
51
|
+
* @returns {JSX.Element} The rendered DualList component.
|
|
52
|
+
*/
|
|
53
|
+
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;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { type SelectProps } from "../types";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* List component for selecting items from a list.
|
|
4
|
+
* It supports single and multiple selections, searching, creating new options,
|
|
5
|
+
* and custom rendering of options.
|
|
6
|
+
*
|
|
7
|
+
* @param {SelectProps<T>} props - The properties for the List component.
|
|
8
|
+
* @returns {JSX.Element} The rendered List component.
|
|
9
|
+
*/
|
|
10
|
+
export declare const List: <T extends AnyObject = string>({ ref, name, value, readOnly, disabled, required, placeholder, autoFocus, options, height, groupProperty, labelProperty, valueProperty, 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"> & {
|
|
3
11
|
height?: string | number;
|
|
4
12
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { type SelectProps } from "../types";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Select component for selecting items from a dropdown list.
|
|
4
|
+
* It supports single and multiple selections, searching, creating new options,
|
|
5
|
+
* and custom rendering of options.
|
|
6
|
+
*
|
|
7
|
+
* @param {SelectProps<T>} props - The properties for the Select component.
|
|
8
|
+
* @returns {JSX.Element} The rendered Select component.
|
|
9
|
+
*/
|
|
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, multiple, searchable, allowCreate, emptyDisplay, createOption, matcher, renderer, onQuery, onChange, onSelect, onEnterPressed, ...rest }: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
interface State {
|
|
3
2
|
multiple: boolean;
|
|
4
3
|
emptyValue: AnyObject;
|
|
@@ -27,7 +26,17 @@ export declare const useSelect: ({ options, value, defaultOpen, autoComplete, mu
|
|
|
27
26
|
onSelect?: (item: AnyObject) => void;
|
|
28
27
|
onChange?: (value: AnyObject) => void;
|
|
29
28
|
}) => {
|
|
30
|
-
state: State
|
|
29
|
+
state: State | {
|
|
30
|
+
value: any;
|
|
31
|
+
activeIndex: null;
|
|
32
|
+
selectedIndex: any;
|
|
33
|
+
multiple: boolean;
|
|
34
|
+
emptyValue: AnyObject;
|
|
35
|
+
open: boolean;
|
|
36
|
+
loading: boolean;
|
|
37
|
+
query?: string;
|
|
38
|
+
items: AnyObject[];
|
|
39
|
+
};
|
|
31
40
|
listRef: import("react").RefObject<HTMLElement[]>;
|
|
32
41
|
focusableRef: import("react").RefObject<HTMLElement | null>;
|
|
33
42
|
listContentRef: import("react").RefObject<any[]>;
|
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.52",
|
|
4
4
|
"description": "RUF: Form package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"@dnd-kit/utilities": "^3.2.2",
|
|
42
42
|
"@floating-ui/react": "^0.27.9",
|
|
43
43
|
"@hookform/resolvers": "^3.9.0",
|
|
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.52",
|
|
45
|
+
"@react-fabric/date": "^1.0.0-beta.52",
|
|
46
|
+
"@react-fabric/utilities": "^1.0.0-beta.52",
|
|
47
47
|
"classnames": "^2.5.1",
|
|
48
48
|
"color": "^4.2.3",
|
|
49
49
|
"react-color": "^2.19.3",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"node": ">=18.12.0",
|
|
64
64
|
"npm": ">=8.19.0"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "0eabb9d88d91af93d657bcc209b226fd576e8260"
|
|
67
67
|
}
|
|
@@ -32,6 +32,13 @@ import {
|
|
|
32
32
|
} from "../types/schema";
|
|
33
33
|
import { SchemaArrayForm } from "./components/SchemaArrayForm";
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* SchemaEditor component allows users to edit a schema definition.
|
|
37
|
+
* It provides a form interface to modify schema properties dynamically.
|
|
38
|
+
*
|
|
39
|
+
* @param {SchemaEditorProps} props - The properties for the SchemaEditor component.
|
|
40
|
+
* @returns {JSX.Element} The rendered SchemaEditor component.
|
|
41
|
+
*/
|
|
35
42
|
export const SchemaEditor = ({
|
|
36
43
|
schemaDef,
|
|
37
44
|
dynamic,
|