@react-fabric/form 1.0.0-beta.60 → 1.0.0-beta.62
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/builder/FileField.js +10 -7
- package/dist/cjs/builder/components/AddSchemaFields.js +2 -1
- package/dist/cjs/builder/components/SchemaArrayForm.js +4 -4
- package/dist/cjs/builder/components/SchemaField.js +4 -4
- package/dist/cjs/form/Form.js +44 -22
- package/dist/cjs/hooks/useFileUploader.js +40 -28
- package/dist/cjs/hooks/useFormBuilder.js +10 -3
- package/dist/cjs/i18n/index.js +4 -4
- package/dist/cjs/input/ArrayInput.js +3 -3
- package/dist/cjs/input/AvatarInput.js +17 -12
- package/dist/cjs/input/Checkbox.js +2 -2
- package/dist/cjs/input/ColorInput.js +2 -2
- package/dist/cjs/input/File.js +1 -1
- package/dist/cjs/input/Hidden.js +1 -10
- package/dist/cjs/input/Password.js +1 -1
- package/dist/cjs/input/Radio.js +2 -2
- package/dist/cjs/input/RadioGroup.js +3 -1
- package/dist/cjs/input/Search.js +2 -3
- package/dist/cjs/internal/ErrorIcon.js +1 -1
- package/dist/cjs/internal/InputWrapper.js +3 -3
- package/dist/cjs/select/AutoComplete.js +1 -2
- package/dist/cjs/select/DualList.js +5 -5
- package/dist/cjs/select/List.js +8 -24
- package/dist/cjs/select/Select.js +9 -28
- package/dist/esm/builder/FileField.js +11 -8
- package/dist/esm/builder/components/AddSchemaFields.js +2 -1
- package/dist/esm/builder/components/SchemaArrayForm.js +5 -5
- package/dist/esm/builder/components/SchemaField.js +5 -5
- package/dist/esm/form/Form.js +44 -22
- package/dist/esm/hooks/useFileUploader.js +41 -29
- package/dist/esm/hooks/useFormBuilder.js +10 -3
- package/dist/esm/i18n/index.js +2 -2
- package/dist/esm/input/ArrayInput.js +4 -4
- package/dist/esm/input/AvatarInput.js +18 -13
- package/dist/esm/input/Checkbox.js +3 -3
- package/dist/esm/input/ColorInput.js +3 -3
- package/dist/esm/input/File.js +2 -2
- package/dist/esm/input/Hidden.js +2 -11
- package/dist/esm/input/Password.js +2 -2
- package/dist/esm/input/Radio.js +3 -3
- package/dist/esm/input/RadioGroup.js +3 -1
- package/dist/esm/input/Search.js +3 -4
- package/dist/esm/internal/ErrorIcon.js +2 -2
- package/dist/esm/internal/InputWrapper.js +4 -4
- package/dist/esm/select/AutoComplete.js +2 -3
- package/dist/esm/select/DualList.js +6 -6
- package/dist/esm/select/List.js +8 -24
- package/dist/esm/select/Select.js +10 -29
- package/dist/types/builder/FileField.d.ts +2 -1
- package/dist/types/form/Form.d.ts +11 -10
- package/dist/types/hooks/useFileUploader.d.ts +4 -2
- package/dist/types/hooks/useFormBuilder.d.ts +6 -0
- package/dist/types/input/AvatarInput.d.ts +2 -2
- package/dist/types/input/Hidden.d.ts +3 -11
- package/dist/types/input/RadioGroup.d.ts +5 -1
- package/dist/types/select/DualList.d.ts +5 -6
- package/dist/types/select/Options.d.ts +1 -1
- package/dist/types/types/index.d.ts +7 -8
- package/package.json +5 -5
- package/src/builder/FileField.tsx +8 -12
- package/src/builder/components/AddSchemaFields.tsx +2 -1
- package/src/builder/components/SchemaArrayForm.tsx +5 -11
- package/src/builder/components/SchemaField.tsx +4 -5
- package/src/form/Form.tsx +30 -24
- package/src/hooks/useFileUploader.ts +41 -29
- package/src/hooks/useFormBuilder.tsx +12 -4
- package/src/i18n/index.ts +2 -2
- package/src/input/ArrayInput.tsx +4 -10
- package/src/input/AvatarInput.tsx +16 -16
- package/src/input/Checkbox.tsx +6 -3
- package/src/input/ColorInput.tsx +3 -7
- package/src/input/File.tsx +2 -2
- package/src/input/Hidden.tsx +4 -22
- package/src/input/Password.tsx +4 -2
- package/src/input/Radio.tsx +3 -3
- package/src/input/RadioGroup.tsx +6 -0
- package/src/input/Search.tsx +3 -3
- package/src/internal/ErrorIcon.tsx +2 -2
- package/src/internal/InputWrapper.tsx +8 -4
- package/src/select/AutoComplete.tsx +2 -3
- package/src/select/DualList.tsx +15 -12
- package/src/select/List.tsx +3 -3
- package/src/select/Options.tsx +1 -1
- package/src/select/Select.tsx +7 -8
- package/src/types/index.ts +8 -7
- /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
package/dist/esm/select/List.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
4
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
5
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
6
|
-
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
7
5
|
import { useFloating, autoUpdate, useListNavigation, useTypeahead, useInteractions, FloatingFocusManager } from '@floating-ui/react';
|
|
8
6
|
import { Chip } from '@react-fabric/core';
|
|
9
7
|
import { isArray, isEmpty } from '@react-fabric/utilities';
|
|
@@ -31,8 +29,10 @@ var List = function List(_ref) {
|
|
|
31
29
|
options = _ref.options,
|
|
32
30
|
height = _ref.height,
|
|
33
31
|
groupProperty = _ref.groupProperty,
|
|
34
|
-
labelProperty = _ref.labelProperty,
|
|
35
|
-
|
|
32
|
+
_ref$labelProperty = _ref.labelProperty,
|
|
33
|
+
labelProperty = _ref$labelProperty === void 0 ? "label" : _ref$labelProperty,
|
|
34
|
+
_ref$valueProperty = _ref.valueProperty,
|
|
35
|
+
valueProperty = _ref$valueProperty === void 0 ? "value" : _ref$valueProperty,
|
|
36
36
|
infoProperty = _ref.infoProperty,
|
|
37
37
|
sortProperty = _ref.sortProperty,
|
|
38
38
|
multiple = _ref.multiple,
|
|
@@ -259,26 +259,10 @@ var List = function List(_ref) {
|
|
|
259
259
|
itemProps: makeItemProps,
|
|
260
260
|
empty: emptyDisplay,
|
|
261
261
|
info: (_state$activeItem = state.activeItem) === null || _state$activeItem === void 0 ? void 0 : _state$activeItem[infoProperty !== null && infoProperty !== void 0 ? infoProperty : "info"],
|
|
262
|
-
children:
|
|
263
|
-
var
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
while (1) switch (_context.prev = _context.next) {
|
|
267
|
-
case 0:
|
|
268
|
-
_context.next = 2;
|
|
269
|
-
return (_renderer3 = renderer === null || renderer === void 0 ? void 0 : renderer(item)) !== null && _renderer3 !== void 0 ? _renderer3 : label;
|
|
270
|
-
case 2:
|
|
271
|
-
return _context.abrupt("return", _context.sent);
|
|
272
|
-
case 3:
|
|
273
|
-
case "end":
|
|
274
|
-
return _context.stop();
|
|
275
|
-
}
|
|
276
|
-
}, _callee);
|
|
277
|
-
}));
|
|
278
|
-
return function (_x, _x2) {
|
|
279
|
-
return _ref4.apply(this, arguments);
|
|
280
|
-
};
|
|
281
|
-
}())
|
|
262
|
+
children: function children(item, label) {
|
|
263
|
+
var _renderer3;
|
|
264
|
+
return (_renderer3 = renderer === null || renderer === void 0 ? void 0 : renderer(item)) !== null && _renderer3 !== void 0 ? _renderer3 : label;
|
|
265
|
+
}
|
|
282
266
|
}))
|
|
283
267
|
})]
|
|
284
268
|
}));
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
4
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
5
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
6
|
-
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
7
5
|
import { useFloating, autoUpdate, shift, flip, offset, useClick, useDismiss, useListNavigation, useTypeahead, useInteractions, FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
|
|
8
|
-
import { Chip, Icon
|
|
6
|
+
import { Chip, Icon } from '@react-fabric/core';
|
|
9
7
|
import { isArray, isEmpty } from '@react-fabric/utilities';
|
|
10
8
|
import classNames from 'classnames';
|
|
11
9
|
import { useId, useMemo, useCallback, useLayoutEffect } from 'react';
|
|
@@ -36,7 +34,7 @@ var Select = function Select(_ref) {
|
|
|
36
34
|
_ref$labelProperty = _ref.labelProperty,
|
|
37
35
|
labelProperty = _ref$labelProperty === void 0 ? "label" : _ref$labelProperty,
|
|
38
36
|
_ref$valueProperty = _ref.valueProperty,
|
|
39
|
-
valueProperty = _ref$valueProperty === void 0 ? "
|
|
37
|
+
valueProperty = _ref$valueProperty === void 0 ? "value" : _ref$valueProperty,
|
|
40
38
|
sortProperty = _ref.sortProperty,
|
|
41
39
|
infoProperty = _ref.infoProperty,
|
|
42
40
|
multiple = _ref.multiple,
|
|
@@ -200,7 +198,7 @@ var Select = function Select(_ref) {
|
|
|
200
198
|
} else if (!isEmpty(state.value) && !state.query) {
|
|
201
199
|
var _ref3, _renderer2;
|
|
202
200
|
return /*#__PURE__*/jsx("span", {
|
|
203
|
-
className: "self-center pointer-events-none select-none",
|
|
201
|
+
className: "self-center pointer-events-none select-none truncate leading-tight",
|
|
204
202
|
children: (_ref3 = (_renderer2 = renderer === null || renderer === void 0 ? void 0 : renderer(state.value)) !== null && _renderer2 !== void 0 ? _renderer2 : state.value[labelProperty]) !== null && _ref3 !== void 0 ? _ref3 : state.value
|
|
205
203
|
});
|
|
206
204
|
}
|
|
@@ -248,7 +246,7 @@ var Select = function Select(_ref) {
|
|
|
248
246
|
size: 1,
|
|
249
247
|
ref: ref,
|
|
250
248
|
autoFocus: autoFocus,
|
|
251
|
-
className: classNames("appearance-none bg-transparent outline-none border-none ring-0 flex-1 peer", disabled && "cursor-not-allowed pointer-events-none", multiple
|
|
249
|
+
className: classNames("appearance-none bg-transparent outline-none border-none ring-0 flex-1 peer", disabled && "cursor-not-allowed pointer-events-none", multiple ? "min-w-24" : "min-w-2"),
|
|
252
250
|
placeholder: isEmpty(state.value) ? placeholder : "",
|
|
253
251
|
onChange: function onChange(evt) {
|
|
254
252
|
return handleQuery(evt.target.value);
|
|
@@ -259,11 +257,10 @@ var Select = function Select(_ref) {
|
|
|
259
257
|
onClick: function onClick() {
|
|
260
258
|
return !disabled && openDropdown();
|
|
261
259
|
},
|
|
262
|
-
icon:
|
|
260
|
+
icon: "icon-[mdi--chevron-down]"
|
|
263
261
|
}), state.loading && /*#__PURE__*/jsx(Icon, {
|
|
264
|
-
animate: "spin",
|
|
265
262
|
className: classNames("flex-content p-2 z-0 order-9 text-muted pointer-events-none"),
|
|
266
|
-
icon:
|
|
263
|
+
icon: "icon-[svg-spinners--eclipse]"
|
|
267
264
|
}), state.open && !state.loading && /*#__PURE__*/jsx(FloatingPortal, {
|
|
268
265
|
children: /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
269
266
|
context: context,
|
|
@@ -284,26 +281,10 @@ var Select = function Select(_ref) {
|
|
|
284
281
|
itemProps: makeItemProps,
|
|
285
282
|
empty: emptyDisplay,
|
|
286
283
|
info: (_state$activeItem = state.activeItem) === null || _state$activeItem === void 0 ? void 0 : _state$activeItem[infoProperty !== null && infoProperty !== void 0 ? infoProperty : "info"],
|
|
287
|
-
children:
|
|
288
|
-
var
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
while (1) switch (_context.prev = _context.next) {
|
|
292
|
-
case 0:
|
|
293
|
-
_context.next = 2;
|
|
294
|
-
return (_renderer3 = renderer === null || renderer === void 0 ? void 0 : renderer(item)) !== null && _renderer3 !== void 0 ? _renderer3 : label;
|
|
295
|
-
case 2:
|
|
296
|
-
return _context.abrupt("return", _context.sent);
|
|
297
|
-
case 3:
|
|
298
|
-
case "end":
|
|
299
|
-
return _context.stop();
|
|
300
|
-
}
|
|
301
|
-
}, _callee);
|
|
302
|
-
}));
|
|
303
|
-
return function (_x, _x2) {
|
|
304
|
-
return _ref4.apply(this, arguments);
|
|
305
|
-
};
|
|
306
|
-
}())
|
|
284
|
+
children: function children(item, label) {
|
|
285
|
+
var _renderer3;
|
|
286
|
+
return (_renderer3 = renderer === null || renderer === void 0 ? void 0 : renderer(item)) !== null && _renderer3 !== void 0 ? _renderer3 : label;
|
|
287
|
+
}
|
|
307
288
|
}))
|
|
308
289
|
})
|
|
309
290
|
})]
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type UploadHandler } from "../hooks/useFileUploader";
|
|
2
2
|
import { type FileSchema, type ValueType } from "../types/schema";
|
|
3
|
-
export declare const FileField: ({ uploadHandler, inline, label, accept, value, fileUrl, multiple, invalid, error, ...rest }: Partial<FileSchema & ValueType> & {
|
|
3
|
+
export declare const FileField: ({ uploadHandler, inline, label, accept, value, fileUrl, onChange, multiple, invalid, error, ...rest }: Partial<FileSchema & ValueType> & {
|
|
4
4
|
value?: AnyObject;
|
|
5
5
|
inline?: boolean;
|
|
6
6
|
invalid?: boolean;
|
|
7
7
|
error?: AnyObject;
|
|
8
|
+
onChange?: (value: any) => void;
|
|
8
9
|
fileUrl?: (path: string) => string;
|
|
9
10
|
uploadHandler: UploadHandler;
|
|
10
11
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { type yup } from "@react-fabric/utilities";
|
|
2
1
|
import { type PropsWithChildren, type Ref } from "react";
|
|
3
|
-
import { type FormState } from "react-hook-form";
|
|
2
|
+
import { type FormState, type Resolver } from "react-hook-form";
|
|
4
3
|
type NestedKeyOf<T extends object> = {
|
|
5
4
|
[K in keyof T & (string | number)]: T[K] extends object ? `${K}` | `${K}.${NestedKeyOf<T[K]>}` : K;
|
|
6
5
|
}[keyof T & (string | number)];
|
|
@@ -17,13 +16,18 @@ export interface FormRef<K extends KeyValue> {
|
|
|
17
16
|
export interface FormProps<K extends KeyValue = KeyValue> {
|
|
18
17
|
formRef?: Ref<FormRef<K>>;
|
|
19
18
|
/**
|
|
20
|
-
* form
|
|
19
|
+
* react-hook-form resolver for validation
|
|
20
|
+
* @see {@link https://react-hook-form.com/ts#Resolver}
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
resolver?: Resolver<K>;
|
|
23
23
|
/**
|
|
24
24
|
* default data values
|
|
25
25
|
*/
|
|
26
|
-
defaultValues?: K
|
|
26
|
+
defaultValues?: K | Promise<K>;
|
|
27
|
+
/**
|
|
28
|
+
* reset values on defaultValues change (workaround for using fetch result)
|
|
29
|
+
*/
|
|
30
|
+
resetOnChange?: boolean;
|
|
27
31
|
/**
|
|
28
32
|
* change callback
|
|
29
33
|
*/
|
|
@@ -45,10 +49,7 @@ export interface FormProps<K extends KeyValue = KeyValue> {
|
|
|
45
49
|
* ```jsx
|
|
46
50
|
* <Form
|
|
47
51
|
* formRef={formRef}
|
|
48
|
-
*
|
|
49
|
-
* name: yup.string().required("Name is required"),
|
|
50
|
-
* email: yup.string().email("Invalid email").required("Email is required"),
|
|
51
|
-
* })}
|
|
52
|
+
* resolver={hookformResolver(schema)}
|
|
52
53
|
* defaultValues={{ name: "", email: "" }}
|
|
53
54
|
* onSubmit={(values) => {
|
|
54
55
|
* console.log("Form submitted with values:", values);
|
|
@@ -64,7 +65,7 @@ export interface FormProps<K extends KeyValue = KeyValue> {
|
|
|
64
65
|
* @see {@link https://react-hook-form.com/docs/useform} for more details on the properties.
|
|
65
66
|
* @see {@link https://github.com/jquense/yup} for more details on the Yup validation schema.
|
|
66
67
|
*/
|
|
67
|
-
export declare const Form: <K extends KeyValue>({ formRef,
|
|
68
|
+
export declare const Form: <K extends KeyValue>({ formRef, resolver, children, resetOnChange, defaultValues, onSubmit, onChange, ...rest }: PropsWithChildren<FormProps<K>>) => import("react/jsx-runtime").JSX.Element;
|
|
68
69
|
export declare const useForm: <K extends KeyValue = KeyValue>() => {
|
|
69
70
|
values: import("react-hook-form").DeepPartialSkipArrayKey<K> & K;
|
|
70
71
|
formState: FormState<K>;
|
|
@@ -28,12 +28,14 @@ interface FileInfo {
|
|
|
28
28
|
* const { upload, remove, retry, state } = useFileUploader(uploader, initialList, multiple);
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
export declare const useFileUploader: (uploader: UploadHandler, initialList?: string | FileInfo | FileInfo[], multiple
|
|
31
|
+
export declare const useFileUploader: (uploader: UploadHandler, initialList?: string | FileInfo | FileInfo[], { multiple, onChange, }?: {
|
|
32
|
+
multiple?: boolean;
|
|
33
|
+
onChange?: (files: FileInfo[] | FileInfo | null) => void;
|
|
34
|
+
}) => {
|
|
32
35
|
upload: (files: FileList | null) => void;
|
|
33
36
|
remove: (key: string) => void;
|
|
34
37
|
retry: (key: string) => void;
|
|
35
38
|
pending: number;
|
|
36
|
-
list: FileInfo[];
|
|
37
39
|
files: FileInfo[];
|
|
38
40
|
};
|
|
39
41
|
export {};
|
|
@@ -39,6 +39,12 @@ export declare const useFormBuilder: <T extends AnyObject = string>(schema: Form
|
|
|
39
39
|
optionLists?: KeyValue<BaseSelectProps<T>>;
|
|
40
40
|
}) => {
|
|
41
41
|
formDef: import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
resolver: import("react-hook-form").Resolver<{
|
|
43
|
+
[x: string]: any;
|
|
44
|
+
}, unknown, {
|
|
45
|
+
[x: string]: any;
|
|
46
|
+
[x: number]: any;
|
|
47
|
+
}>;
|
|
42
48
|
schemaDef: yup.ObjectSchema<{
|
|
43
49
|
[x: string]: any;
|
|
44
50
|
}, yup.AnyObject, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { type AvatarProps } from "@react-fabric/core/dist/types/components/avatar/Avatar";
|
|
1
2
|
import { type RefProp } from "@react-fabric/core/dist/types/types";
|
|
2
3
|
import { type UploadHandler } from "../hooks/useFileUploader";
|
|
3
|
-
import { type AvatarProps } from "@react-fabric/core/dist/types/components/avatar/Avatar";
|
|
4
4
|
export interface Props extends RefProp {
|
|
5
5
|
/**
|
|
6
6
|
* field name
|
|
@@ -48,4 +48,4 @@ export interface Props extends RefProp {
|
|
|
48
48
|
* @param {Props} props - The properties for the AvatarInput component.
|
|
49
49
|
* @returns {JSX.Element} - 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;
|
|
@@ -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.
|
|
@@ -24,5 +16,5 @@ interface Props {
|
|
|
24
16
|
* @param {Object} props - Component properties.
|
|
25
17
|
* @returns {JSX.Element} 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 {};
|
|
@@ -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
|
*/
|
|
@@ -50,4 +54,4 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
|
|
|
50
54
|
* @param {RadioGroupProps} props - The properties for the RadioGroup component.
|
|
51
55
|
* @returns {JSX.Element} 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, value, onChange, ...rest }: RadioGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type RefProp } from "@react-fabric/core/dist/types/types";
|
|
2
|
-
import { type ReactElement } from "react";
|
|
1
|
+
import { type NestedKeys, type ReactElement, type RefProp } from "@react-fabric/core/dist/types/types";
|
|
3
2
|
import { type FieldProps } from "../input/Field";
|
|
4
3
|
export interface DualListProps<T> extends Omit<FieldProps, "children">, RefProp<HTMLInputElement> {
|
|
5
4
|
/**
|
|
@@ -17,15 +16,15 @@ export interface DualListProps<T> extends Omit<FieldProps, "children">, RefProp<
|
|
|
17
16
|
/**
|
|
18
17
|
* group by property name
|
|
19
18
|
*/
|
|
20
|
-
groupProperty?:
|
|
19
|
+
groupProperty?: NestedKeys<T>;
|
|
21
20
|
/**
|
|
22
21
|
* label property name
|
|
23
22
|
*/
|
|
24
|
-
labelProperty?:
|
|
23
|
+
labelProperty?: NestedKeys<T>;
|
|
25
24
|
/**
|
|
26
25
|
* value property name
|
|
27
26
|
*/
|
|
28
|
-
valueProperty?:
|
|
27
|
+
valueProperty?: NestedKeys<T>;
|
|
29
28
|
/**
|
|
30
29
|
* empty list display
|
|
31
30
|
*/
|
|
@@ -33,7 +32,7 @@ export interface DualListProps<T> extends Omit<FieldProps, "children">, RefProp<
|
|
|
33
32
|
/**
|
|
34
33
|
* item renderer
|
|
35
34
|
*/
|
|
36
|
-
renderer?: (option: T) =>
|
|
35
|
+
renderer?: (option: T) => ReactElement;
|
|
37
36
|
/**
|
|
38
37
|
* change handler
|
|
39
38
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactElement } from "react";
|
|
1
|
+
import { type ReactElement } from "@react-fabric/core/dist/types/types";
|
|
2
2
|
export declare const Options: ({ ref, style, items, active, className, itemRef, empty, info, valueProperty, labelProperty, itemProps, children, ...rest }: {
|
|
3
3
|
ref: AnyObject;
|
|
4
4
|
info?: AnyObject;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
2
|
-
import { type ReactElement } from "react";
|
|
1
|
+
import { type NestedKeys, type ReactElement, type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
3
2
|
export interface InputProps<V = string> extends TestProps {
|
|
4
3
|
/**
|
|
5
4
|
* value
|
|
@@ -113,23 +112,23 @@ export interface BaseSelectProps<T extends AnyObject = string> {
|
|
|
113
112
|
/**
|
|
114
113
|
* group by property name
|
|
115
114
|
*/
|
|
116
|
-
groupProperty?:
|
|
115
|
+
groupProperty?: NestedKeys<T>;
|
|
117
116
|
/**
|
|
118
117
|
* label property name
|
|
119
118
|
*/
|
|
120
|
-
labelProperty?:
|
|
119
|
+
labelProperty?: NestedKeys<T>;
|
|
121
120
|
/**
|
|
122
121
|
* value property name
|
|
123
122
|
*/
|
|
124
|
-
valueProperty?:
|
|
123
|
+
valueProperty?: NestedKeys<T>;
|
|
125
124
|
/**
|
|
126
125
|
* value property name
|
|
127
126
|
*/
|
|
128
|
-
infoProperty?:
|
|
127
|
+
infoProperty?: NestedKeys<T>;
|
|
129
128
|
/**
|
|
130
129
|
* value property name
|
|
131
130
|
*/
|
|
132
|
-
sortProperty?:
|
|
131
|
+
sortProperty?: NestedKeys<T> | true;
|
|
133
132
|
/**
|
|
134
133
|
* searchable list
|
|
135
134
|
*/
|
|
@@ -153,7 +152,7 @@ export interface BaseSelectProps<T extends AnyObject = string> {
|
|
|
153
152
|
/**
|
|
154
153
|
* item renderer
|
|
155
154
|
*/
|
|
156
|
-
renderer?: (option: T) =>
|
|
155
|
+
renderer?: (option: T) => ReactElement;
|
|
157
156
|
/**
|
|
158
157
|
* item matcher
|
|
159
158
|
*/
|
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.62",
|
|
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.16",
|
|
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.62",
|
|
45
|
+
"@react-fabric/date": "^1.0.0-beta.62",
|
|
46
|
+
"@react-fabric/utilities": "^1.0.0-beta.62",
|
|
47
47
|
"classnames": "~2.5.1",
|
|
48
48
|
"color": "~5.0.2",
|
|
49
49
|
"react-color": "~2.19.3",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"node": ">=18.12.0",
|
|
63
63
|
"npm": ">=8.19.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "9dce2fd9bb753d67e3f8adbf50be257b4bc64242"
|
|
66
66
|
}
|
|
@@ -21,13 +21,7 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import {
|
|
25
|
-
Button,
|
|
26
|
-
CoreIcons,
|
|
27
|
-
Icon,
|
|
28
|
-
ProgressBar,
|
|
29
|
-
Tooltip,
|
|
30
|
-
} from "@react-fabric/core";
|
|
24
|
+
import { Button, Icon, ProgressBar, Tooltip } from "@react-fabric/core";
|
|
31
25
|
import { FileUtil, Format, isString } from "@react-fabric/utilities";
|
|
32
26
|
import { Fragment } from "react";
|
|
33
27
|
import { useTranslation } from "react-i18next";
|
|
@@ -43,6 +37,7 @@ export const FileField = ({
|
|
|
43
37
|
accept,
|
|
44
38
|
value,
|
|
45
39
|
fileUrl,
|
|
40
|
+
onChange,
|
|
46
41
|
multiple,
|
|
47
42
|
invalid,
|
|
48
43
|
error,
|
|
@@ -52,20 +47,21 @@ export const FileField = ({
|
|
|
52
47
|
inline?: boolean;
|
|
53
48
|
invalid?: boolean;
|
|
54
49
|
error?: AnyObject;
|
|
50
|
+
onChange?: (value: any) => void;
|
|
55
51
|
fileUrl?: (path: string) => string;
|
|
56
52
|
uploadHandler: UploadHandler;
|
|
57
53
|
}) => {
|
|
58
54
|
const { t } = useTranslation();
|
|
59
|
-
const { pending, files,
|
|
55
|
+
const { pending, files, upload, remove } = useFileUploader(
|
|
60
56
|
async (data, config) => await uploadHandler?.(data, config),
|
|
61
57
|
value,
|
|
62
|
-
multiple,
|
|
58
|
+
{ multiple, onChange },
|
|
63
59
|
);
|
|
64
60
|
|
|
65
61
|
return (
|
|
66
62
|
<Fragment>
|
|
67
63
|
<Field plain inline={inline} label={label}>
|
|
68
|
-
<HiddenInput
|
|
64
|
+
<HiddenInput value={multiple ? files : files?.[0]} {...rest} />
|
|
69
65
|
</Field>
|
|
70
66
|
<Tooltip
|
|
71
67
|
color="danger-200"
|
|
@@ -124,7 +120,7 @@ export const FileField = ({
|
|
|
124
120
|
</div>
|
|
125
121
|
{file.progress && (
|
|
126
122
|
<Icon
|
|
127
|
-
icon=
|
|
123
|
+
icon="icon-[mdi--stop]"
|
|
128
124
|
bg="danger"
|
|
129
125
|
color="white"
|
|
130
126
|
size="sm"
|
|
@@ -135,7 +131,7 @@ export const FileField = ({
|
|
|
135
131
|
)}
|
|
136
132
|
{!file.progress && (
|
|
137
133
|
<Icon
|
|
138
|
-
icon=
|
|
134
|
+
icon="icon-[mdi--trash-can-outline]"
|
|
139
135
|
color="danger"
|
|
140
136
|
size="sm"
|
|
141
137
|
aria-label="remove"
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
24
25
|
import {
|
|
25
26
|
Button,
|
|
26
27
|
Content,
|
|
@@ -51,7 +52,7 @@ export const AddSchemaFields = (props: ModalProps) => {
|
|
|
51
52
|
return (
|
|
52
53
|
<Modal {...props}>
|
|
53
54
|
<Form
|
|
54
|
-
|
|
55
|
+
resolver={yupResolver(fieldSchema)}
|
|
55
56
|
defaultValues={{ fields: [" "] }}
|
|
56
57
|
onSubmit={handleSubmit}
|
|
57
58
|
>
|
|
@@ -24,13 +24,7 @@
|
|
|
24
24
|
import { DndContext, type DragEndEvent } from "@dnd-kit/core";
|
|
25
25
|
import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
|
|
26
26
|
import { SortableContext } from "@dnd-kit/sortable";
|
|
27
|
-
import {
|
|
28
|
-
Button,
|
|
29
|
-
Content,
|
|
30
|
-
CoreIcons,
|
|
31
|
-
Header,
|
|
32
|
-
useOverlayService,
|
|
33
|
-
} from "@react-fabric/core";
|
|
27
|
+
import { Button, Content, Header, useOverlayService } from "@react-fabric/core";
|
|
34
28
|
import { isArray } from "@react-fabric/utilities";
|
|
35
29
|
import { useCallback, useState } from "react";
|
|
36
30
|
import { useFieldArray, useFormContext } from "react-hook-form";
|
|
@@ -118,7 +112,7 @@ export const SchemaArrayForm = ({
|
|
|
118
112
|
<Button
|
|
119
113
|
size="sm"
|
|
120
114
|
variant="link"
|
|
121
|
-
icon=
|
|
115
|
+
icon="icon-[mdi--plus-circle-outline]"
|
|
122
116
|
aria-label="add field"
|
|
123
117
|
onClick={handleAdd}
|
|
124
118
|
/>
|
|
@@ -126,14 +120,14 @@ export const SchemaArrayForm = ({
|
|
|
126
120
|
<Button
|
|
127
121
|
size="sm"
|
|
128
122
|
variant="link"
|
|
129
|
-
icon=
|
|
123
|
+
icon="icon-[mdi--arrow-collapse-vertical]"
|
|
130
124
|
aria-label="collapse all"
|
|
131
125
|
onClick={() => setDefaultOpen(false)}
|
|
132
126
|
/>
|
|
133
127
|
<Button
|
|
134
128
|
size="sm"
|
|
135
129
|
variant="link"
|
|
136
|
-
icon=
|
|
130
|
+
icon="icon-[mdi--arrow-expand-vertical]"
|
|
137
131
|
aria-label="expand all"
|
|
138
132
|
onClick={() => setDefaultOpen(true)}
|
|
139
133
|
/>
|
|
@@ -155,7 +149,7 @@ export const SchemaArrayForm = ({
|
|
|
155
149
|
/>
|
|
156
150
|
))}
|
|
157
151
|
</Content>
|
|
158
|
-
|
|
152
|
+
<AddModal />
|
|
159
153
|
</Wrapper>
|
|
160
154
|
);
|
|
161
155
|
};
|
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
Button,
|
|
28
28
|
Collapsable,
|
|
29
29
|
Content,
|
|
30
|
-
CoreIcons,
|
|
31
30
|
Footer,
|
|
32
31
|
Modal,
|
|
33
32
|
type ModalProps,
|
|
@@ -222,7 +221,7 @@ export const SchemaField = ({
|
|
|
222
221
|
variant="link"
|
|
223
222
|
aria-label="Delete"
|
|
224
223
|
stopPropagation
|
|
225
|
-
icon=
|
|
224
|
+
icon="icon-[mdi--trash-can-outline]"
|
|
226
225
|
onClick={onRemove}
|
|
227
226
|
className="invisible group-hover/field:visible"
|
|
228
227
|
/>
|
|
@@ -230,7 +229,7 @@ export const SchemaField = ({
|
|
|
230
229
|
</div>
|
|
231
230
|
<div className="flex flex-col gap-1 pb-4">
|
|
232
231
|
<Controller name={`${field}.id`}>
|
|
233
|
-
<HiddenInput
|
|
232
|
+
<HiddenInput value={id} />
|
|
234
233
|
</Controller>
|
|
235
234
|
<Controller name={`${field}.datatype`}>
|
|
236
235
|
<Select
|
|
@@ -277,7 +276,7 @@ export const SchemaField = ({
|
|
|
277
276
|
</Controller>
|
|
278
277
|
{customOptions && (
|
|
279
278
|
<Button
|
|
280
|
-
icon=
|
|
279
|
+
icon="icon-[mdi--list-box-outline]"
|
|
281
280
|
aria-label="Custom options"
|
|
282
281
|
onClick={() => {
|
|
283
282
|
void openOptionModal({ title: `${id} Options` });
|
|
@@ -285,7 +284,7 @@ export const SchemaField = ({
|
|
|
285
284
|
/>
|
|
286
285
|
)}
|
|
287
286
|
</Field>
|
|
288
|
-
|
|
287
|
+
<OptionModal />
|
|
289
288
|
</Fragment>
|
|
290
289
|
)}
|
|
291
290
|
{type === DATA_TYPES.FILE && (
|