@refinedev/antd 5.36.15 → 5.36.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/fields/useCheckboxGroup/index.d.ts +8 -5
- package/dist/hooks/fields/useCheckboxGroup/index.d.ts.map +1 -1
- package/dist/hooks/fields/useRadioGroup/index.d.ts +8 -5
- package/dist/hooks/fields/useRadioGroup/index.d.ts.map +1 -1
- package/dist/hooks/fields/useSelect/index.d.ts +4 -7
- package/dist/hooks/fields/useSelect/index.d.ts.map +1 -1
- package/dist/hooks/form/useForm.d.ts.map +1 -1
- package/dist/iife/index.js +6 -6
- package/dist/iife/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/hooks/fields/useCheckboxGroup/index.ts +21 -7
- package/src/hooks/fields/useRadioGroup/index.ts +23 -9
- package/src/hooks/fields/useSelect/index.ts +9 -4
- package/src/hooks/form/useForm.ts +11 -14
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@refinedev/antd",
|
3
|
-
"version": "5.36.
|
3
|
+
"version": "5.36.17",
|
4
4
|
"description": "refine is a React-based framework for building internal tools, rapidly. It ships with Ant Design System, an enterprise-level UI toolkit.",
|
5
5
|
"private": false,
|
6
6
|
"sideEffects": [
|
@@ -28,7 +28,7 @@
|
|
28
28
|
"devDependencies": {
|
29
29
|
"@refinedev/cli": "^2.16.6",
|
30
30
|
"@refinedev/ui-tests": "^1.13.0",
|
31
|
-
"@refinedev/core": "^4.
|
31
|
+
"@refinedev/core": "^4.44.10",
|
32
32
|
"@esbuild-plugins/node-resolve": "^0.1.4",
|
33
33
|
"@testing-library/jest-dom": "^5.16.4",
|
34
34
|
"@testing-library/react": "^13.1.1",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { QueryObserverResult } from "@tanstack/react-query";
|
2
|
+
import type { Checkbox } from "antd";
|
2
3
|
|
3
|
-
import { CheckboxGroupProps } from "antd/lib/checkbox";
|
4
4
|
import {
|
5
5
|
BaseRecord,
|
6
6
|
GetListResponse,
|
@@ -9,13 +9,21 @@ import {
|
|
9
9
|
useSelect,
|
10
10
|
BaseKey,
|
11
11
|
pickNotDeprecated,
|
12
|
+
BaseOption,
|
12
13
|
} from "@refinedev/core";
|
13
14
|
|
14
|
-
export type UseCheckboxGroupReturnType<
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
export type UseCheckboxGroupReturnType<
|
16
|
+
TData extends BaseRecord = BaseRecord,
|
17
|
+
TOption extends BaseOption = BaseOption,
|
18
|
+
> = {
|
19
|
+
checkboxGroupProps: Omit<
|
20
|
+
React.ComponentProps<typeof Checkbox.Group>,
|
21
|
+
"options"
|
22
|
+
> & {
|
23
|
+
options: TOption[];
|
18
24
|
};
|
25
|
+
queryResult: QueryObserverResult<GetListResponse<TData>>;
|
26
|
+
};
|
19
27
|
|
20
28
|
type UseCheckboxGroupProps<TQueryFnData, TError, TData> = Omit<
|
21
29
|
UseSelectProps<TQueryFnData, TError, TData>,
|
@@ -42,6 +50,7 @@ export const useCheckboxGroup = <
|
|
42
50
|
TQueryFnData extends BaseRecord = BaseRecord,
|
43
51
|
TError extends HttpError = HttpError,
|
44
52
|
TData extends BaseRecord = TQueryFnData,
|
53
|
+
TOption extends BaseOption = BaseOption,
|
45
54
|
>({
|
46
55
|
resource,
|
47
56
|
sort,
|
@@ -63,8 +72,13 @@ export const useCheckboxGroup = <
|
|
63
72
|
TQueryFnData,
|
64
73
|
TError,
|
65
74
|
TData
|
66
|
-
>): UseCheckboxGroupReturnType<TData> => {
|
67
|
-
const { queryResult, options } = useSelect
|
75
|
+
>): UseCheckboxGroupReturnType<TData, TOption> => {
|
76
|
+
const { queryResult, options } = useSelect<
|
77
|
+
TQueryFnData,
|
78
|
+
TError,
|
79
|
+
TData,
|
80
|
+
TOption
|
81
|
+
>({
|
68
82
|
resource,
|
69
83
|
sort,
|
70
84
|
sorters,
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import { QueryObserverResult } from "@tanstack/react-query";
|
2
|
+
import type { Radio } from "antd";
|
2
3
|
|
3
|
-
import { RadioGroupProps } from "antd/lib/radio";
|
4
4
|
import {
|
5
5
|
BaseKey,
|
6
|
+
BaseOption,
|
6
7
|
BaseRecord,
|
7
8
|
GetListResponse,
|
8
9
|
HttpError,
|
@@ -11,8 +12,16 @@ import {
|
|
11
12
|
UseSelectProps,
|
12
13
|
} from "@refinedev/core";
|
13
14
|
|
14
|
-
export type UseRadioGroupReturnType<
|
15
|
-
|
15
|
+
export type UseRadioGroupReturnType<
|
16
|
+
TData extends BaseRecord = BaseRecord,
|
17
|
+
TOption extends BaseOption = BaseOption,
|
18
|
+
> = {
|
19
|
+
radioGroupProps: Omit<
|
20
|
+
React.ComponentProps<typeof Radio.Group>,
|
21
|
+
"options"
|
22
|
+
> & {
|
23
|
+
options: TOption[];
|
24
|
+
};
|
16
25
|
queryResult: QueryObserverResult<GetListResponse<TData>>;
|
17
26
|
};
|
18
27
|
|
@@ -41,6 +50,7 @@ export const useRadioGroup = <
|
|
41
50
|
TQueryFnData extends BaseRecord = BaseRecord,
|
42
51
|
TError extends HttpError = HttpError,
|
43
52
|
TData extends BaseRecord = TQueryFnData,
|
53
|
+
TOption extends BaseOption = BaseOption,
|
44
54
|
>({
|
45
55
|
resource,
|
46
56
|
sort,
|
@@ -58,12 +68,16 @@ export const useRadioGroup = <
|
|
58
68
|
meta,
|
59
69
|
metaData,
|
60
70
|
dataProviderName,
|
61
|
-
}: UseRadioGroupProps<
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
71
|
+
}: UseRadioGroupProps<TQueryFnData, TError, TData>): UseRadioGroupReturnType<
|
72
|
+
TData,
|
73
|
+
TOption
|
74
|
+
> => {
|
75
|
+
const { queryResult, options } = useSelect<
|
76
|
+
TQueryFnData,
|
77
|
+
TError,
|
78
|
+
TData,
|
79
|
+
TOption
|
80
|
+
>({
|
67
81
|
resource,
|
68
82
|
sort,
|
69
83
|
sorters,
|
@@ -8,10 +8,14 @@ import {
|
|
8
8
|
GetListResponse,
|
9
9
|
HttpError,
|
10
10
|
UseSelectProps,
|
11
|
+
BaseOption,
|
11
12
|
} from "@refinedev/core";
|
12
13
|
|
13
|
-
export type UseSelectReturnType<
|
14
|
-
|
14
|
+
export type UseSelectReturnType<
|
15
|
+
TData extends BaseRecord = BaseRecord,
|
16
|
+
TOption extends BaseOption = BaseOption,
|
17
|
+
> = {
|
18
|
+
selectProps: SelectProps<TOption>;
|
15
19
|
queryResult: QueryObserverResult<GetListResponse<TData>>;
|
16
20
|
defaultValueQueryResult: QueryObserverResult<GetManyResponse<TData>>;
|
17
21
|
};
|
@@ -31,11 +35,12 @@ export const useSelect = <
|
|
31
35
|
TQueryFnData extends BaseRecord = BaseRecord,
|
32
36
|
TError extends HttpError = HttpError,
|
33
37
|
TData extends BaseRecord = TQueryFnData,
|
38
|
+
TOption extends BaseOption = BaseOption,
|
34
39
|
>(
|
35
40
|
props: UseSelectProps<TQueryFnData, TError, TData>,
|
36
|
-
): UseSelectReturnType<TData> => {
|
41
|
+
): UseSelectReturnType<TData, TOption> => {
|
37
42
|
const { queryResult, defaultValueQueryResult, onSearch, options } =
|
38
|
-
useSelectCore(props);
|
43
|
+
useSelectCore<TQueryFnData, TError, TData, TOption>(props);
|
39
44
|
|
40
45
|
return {
|
41
46
|
selectProps: {
|
@@ -1,7 +1,11 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import { FormInstance, FormProps, Form, ButtonProps } from "antd";
|
3
3
|
import { useForm as useFormSF } from "sunflower-antd";
|
4
|
-
import {
|
4
|
+
import {
|
5
|
+
AutoSaveProps,
|
6
|
+
flattenObjectKeys,
|
7
|
+
propertyPathToArray,
|
8
|
+
} from "@refinedev/core";
|
5
9
|
|
6
10
|
import {
|
7
11
|
HttpError,
|
@@ -172,13 +176,16 @@ export const useForm = <
|
|
172
176
|
|
173
177
|
// reset antd errors before setting new errors
|
174
178
|
const fieldsValue = form.getFieldsValue() as unknown as object;
|
175
|
-
|
179
|
+
|
180
|
+
const fields = Object.keys(flattenObjectKeys(fieldsValue));
|
181
|
+
|
176
182
|
parsedErrors = fields.map((field) => {
|
177
183
|
return {
|
178
|
-
name: field,
|
184
|
+
name: propertyPathToArray(field),
|
179
185
|
errors: undefined,
|
180
186
|
};
|
181
187
|
});
|
188
|
+
|
182
189
|
form.setFields(parsedErrors);
|
183
190
|
|
184
191
|
const errors = error?.errors;
|
@@ -209,18 +216,8 @@ export const useForm = <
|
|
209
216
|
newError = [translatedMessage];
|
210
217
|
}
|
211
218
|
|
212
|
-
// antd form expects the key to be an array.
|
213
|
-
// if the key is a number, it will be parsed to a number because.
|
214
|
-
const newKey = key.split(".").map((item) => {
|
215
|
-
// check if item is a number
|
216
|
-
if (!isNaN(Number(item))) {
|
217
|
-
return Number(item);
|
218
|
-
}
|
219
|
-
return item;
|
220
|
-
});
|
221
|
-
|
222
219
|
parsedErrors.push({
|
223
|
-
name:
|
220
|
+
name: propertyPathToArray(key),
|
224
221
|
errors: newError,
|
225
222
|
});
|
226
223
|
}
|