@refinedev/antd 5.40.0 → 5.41.0
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 +79 -0
- package/dist/components/autoSaveIndicator/index.d.mts.map +4 -1
- package/dist/components/breadcrumb/index.d.mts.map +6 -1
- package/dist/components/buttons/clone/index.d.mts.map +11 -1
- package/dist/components/buttons/create/index.d.mts.map +11 -1
- package/dist/components/buttons/delete/index.d.mts.map +10 -1
- package/dist/components/buttons/edit/index.d.mts.map +11 -1
- package/dist/components/buttons/export/index.d.mts.map +10 -1
- package/dist/components/buttons/import/index.d.mts.map +11 -1
- package/dist/components/buttons/index.d.mts.map +12 -1
- package/dist/components/buttons/list/index.d.mts.map +11 -1
- package/dist/components/buttons/refresh/index.d.mts.map +10 -1
- package/dist/components/buttons/save/index.d.mts.map +10 -1
- package/dist/components/buttons/show/index.d.mts.map +11 -1
- package/dist/components/buttons/types.d.mts.map +24 -1
- package/dist/components/crud/create/index.d.mts.map +10 -1
- package/dist/components/crud/edit/index.d.mts.map +10 -1
- package/dist/components/crud/index.d.mts.map +6 -1
- package/dist/components/crud/list/index.d.mts.map +10 -1
- package/dist/components/crud/show/index.d.mts.map +10 -1
- package/dist/components/crud/types.d.mts.map +10 -1
- package/dist/components/fields/boolean/index.d.mts.map +9 -1
- package/dist/components/fields/date/index.d.mts.map +9 -1
- package/dist/components/fields/email/index.d.mts.map +10 -1
- package/dist/components/fields/file/index.d.mts.map +9 -1
- package/dist/components/fields/image/index.d.mts.map +9 -1
- package/dist/components/fields/index.d.mts.map +12 -1
- package/dist/components/fields/markdown/index.d.mts.map +9 -1
- package/dist/components/fields/number/index.d.mts.map +9 -1
- package/dist/components/fields/tag/index.d.mts.map +9 -1
- package/dist/components/fields/text/index.d.mts.map +9 -1
- package/dist/components/fields/types.d.mts.map +20 -1
- package/dist/components/fields/url/index.d.mts.map +10 -1
- package/dist/components/index.d.mts.map +24 -1
- package/dist/components/layout/header/index.d.mts.map +4 -1
- package/dist/components/layout/index.d.mts.map +8 -1
- package/dist/components/layout/sider/index.d.mts.map +4 -1
- package/dist/components/layout/sider/styles.d.mts.map +3 -1
- package/dist/components/layout/title/index.d.mts.map +4 -1
- package/dist/components/layout/types.d.mts.map +3 -1
- package/dist/components/pageHeader/index.d.cts.map +1 -1
- package/dist/components/pageHeader/index.d.mts.map +5 -1
- package/dist/components/pageHeader/index.d.ts.map +1 -1
- package/dist/components/pages/auth/components/forgotPassword/index.d.mts.map +12 -1
- package/dist/components/pages/auth/components/index.d.mts.map +5 -1
- package/dist/components/pages/auth/components/login/index.d.mts.map +12 -1
- package/dist/components/pages/auth/components/register/index.d.mts.map +12 -1
- package/dist/components/pages/auth/components/styles.d.mts.map +7 -1
- package/dist/components/pages/auth/components/updatePassword/index.d.mts.map +12 -1
- package/dist/components/pages/auth/index.d.mts.map +14 -1
- package/dist/components/pages/error/index.d.mts.map +10 -1
- package/dist/components/pages/index.d.mts.map +7 -1
- package/dist/components/pages/login/index.d.mts.map +15 -1
- package/dist/components/pages/login/styles.d.mts.map +6 -1
- package/dist/components/pages/ready/index.d.mts.map +9 -1
- package/dist/components/pages/welcome/index.d.mts.map +7 -1
- package/dist/components/table/components/filterDropdown/index.d.mts.map +16 -1
- package/dist/components/table/components/index.d.mts.map +3 -1
- package/dist/components/table/index.d.mts.map +2 -1
- package/dist/components/themedLayout/header/index.d.mts.map +7 -1
- package/dist/components/themedLayout/index.d.mts.map +7 -1
- package/dist/components/themedLayout/sider/index.d.mts.map +7 -1
- package/dist/components/themedLayout/sider/styles.d.mts.map +3 -1
- package/dist/components/themedLayout/title/index.d.mts.map +7 -1
- package/dist/components/themedLayout/types.d.mts.map +3 -1
- package/dist/components/themedLayoutV2/header/index.d.mts.map +4 -1
- package/dist/components/themedLayoutV2/index.d.mts.map +4 -1
- package/dist/components/themedLayoutV2/sider/index.d.cts.map +1 -1
- package/dist/components/themedLayoutV2/sider/index.d.mts.map +4 -1
- package/dist/components/themedLayoutV2/sider/index.d.ts.map +1 -1
- package/dist/components/themedLayoutV2/sider/styles.d.mts.map +3 -1
- package/dist/components/themedLayoutV2/title/index.d.mts.map +4 -1
- package/dist/components/themedLayoutV2/types.d.mts.map +6 -1
- package/dist/components/undoableNotification/index.d.mts.map +10 -1
- package/dist/contexts/index.d.mts.map +2 -1
- package/dist/contexts/themedLayoutContext/IThemedLayoutContext.d.mts.map +7 -1
- package/dist/contexts/themedLayoutContext/index.d.mts.map +8 -1
- package/dist/definitions/filter-mappers/index.d.mts.map +29 -1
- package/dist/definitions/index.d.mts.map +5 -1
- package/dist/definitions/table/index.d.mts.map +13 -1
- package/dist/definitions/themes/index.d.mts.map +6 -1
- package/dist/definitions/upload/index.d.mts.map +4 -1
- package/dist/hooks/fields/index.d.mts.map +4 -1
- package/dist/hooks/fields/useCheckboxGroup/index.d.cts +1 -1
- package/dist/hooks/fields/useCheckboxGroup/index.d.cts.map +1 -1
- package/dist/hooks/fields/useCheckboxGroup/index.d.mts +1 -1
- package/dist/hooks/fields/useCheckboxGroup/index.d.mts.map +29 -1
- package/dist/hooks/fields/useCheckboxGroup/index.d.ts +1 -1
- package/dist/hooks/fields/useCheckboxGroup/index.d.ts.map +1 -1
- package/dist/hooks/fields/useRadioGroup/index.d.cts +1 -1
- package/dist/hooks/fields/useRadioGroup/index.d.cts.map +1 -1
- package/dist/hooks/fields/useRadioGroup/index.d.mts +1 -1
- package/dist/hooks/fields/useRadioGroup/index.d.mts.map +29 -1
- package/dist/hooks/fields/useRadioGroup/index.d.ts +1 -1
- package/dist/hooks/fields/useRadioGroup/index.d.ts.map +1 -1
- package/dist/hooks/fields/useSelect/index.d.mts.map +20 -1
- package/dist/hooks/form/index.d.mts.map +5 -1
- package/dist/hooks/form/useDrawerForm/index.d.mts.map +2 -1
- package/dist/hooks/form/useDrawerForm/useDrawerForm.d.cts +1 -2
- package/dist/hooks/form/useDrawerForm/useDrawerForm.d.cts.map +1 -1
- package/dist/hooks/form/useDrawerForm/useDrawerForm.d.mts +1 -2
- package/dist/hooks/form/useDrawerForm/useDrawerForm.d.mts.map +36 -1
- package/dist/hooks/form/useDrawerForm/useDrawerForm.d.ts +1 -2
- package/dist/hooks/form/useDrawerForm/useDrawerForm.d.ts.map +1 -1
- package/dist/hooks/form/useForm.d.cts +4 -3
- package/dist/hooks/form/useForm.d.cts.map +1 -1
- package/dist/hooks/form/useForm.d.mts +4 -3
- package/dist/hooks/form/useForm.d.mts.map +41 -1
- package/dist/hooks/form/useForm.d.ts +4 -3
- package/dist/hooks/form/useForm.d.ts.map +1 -1
- package/dist/hooks/form/useModalForm/index.d.mts.map +2 -1
- package/dist/hooks/form/useModalForm/useModalForm.d.mts.map +42 -1
- package/dist/hooks/form/useStepsForm/index.d.mts.map +2 -1
- package/dist/hooks/form/useStepsForm/useStepsForm.d.mts.map +35 -1
- package/dist/hooks/import/index.d.mts.map +18 -1
- package/dist/hooks/index.d.mts.map +10 -1
- package/dist/hooks/list/index.d.mts.map +2 -1
- package/dist/hooks/list/useSimpleList/index.d.mts.map +2 -1
- package/dist/hooks/list/useSimpleList/useSimpleList.d.mts.map +24 -1
- package/dist/hooks/modal/index.d.mts.map +2 -1
- package/dist/hooks/modal/useModal/index.d.mts.map +18 -1
- package/dist/hooks/table/index.d.mts.map +3 -1
- package/dist/hooks/table/useEditableTable/index.d.mts.map +2 -1
- package/dist/hooks/table/useEditableTable/useEditableTable.d.mts.map +40 -1
- package/dist/hooks/table/useTable/index.d.mts.map +2 -1
- package/dist/hooks/table/useTable/paginationLink.d.mts.map +8 -1
- package/dist/hooks/table/useTable/useTable.d.mts.map +24 -1
- package/dist/hooks/useFileUploadState/index.d.mts.map +7 -1
- package/dist/hooks/useSiderVisible/index.d.mts.map +11 -1
- package/dist/hooks/useThemedLayoutContext/index.d.mts.map +4 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts.map +9 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/interfaces/field.d.mts.map +4 -1
- package/dist/interfaces/index.d.mts.map +19 -1
- package/dist/interfaces/upload.d.mts.map +10 -1
- package/dist/providers/index.d.mts.map +2 -1
- package/dist/providers/notificationProvider/index.d.mts.map +8 -1
- package/package.json +4 -4
- package/src/components/autoSaveIndicator/index.tsx +7 -7
- package/src/components/layout/sider/index.tsx +2 -2
- package/src/components/pageHeader/index.tsx +12 -9
- package/src/components/themedLayout/sider/index.tsx +2 -2
- package/src/components/themedLayoutV2/sider/index.tsx +23 -19
- package/src/hooks/fields/useCheckboxGroup/index.ts +2 -0
- package/src/hooks/fields/useRadioGroup/index.ts +2 -0
- package/src/hooks/form/useDrawerForm/useDrawerForm.ts +1 -2
- package/src/hooks/form/useForm.ts +12 -3
@@ -1 +1,4 @@
|
|
1
|
-
{
|
1
|
+
export type FieldProps<T> = {
|
2
|
+
value: T;
|
3
|
+
};
|
4
|
+
//# sourceMappingURL=field.d.ts.map
|
@@ -1 +1,19 @@
|
|
1
|
-
{"
|
1
|
+
import type { IResourceItem } from "@refinedev/core";
|
2
|
+
export type BaseRecord = {
|
3
|
+
id?: string;
|
4
|
+
[key: string]: any;
|
5
|
+
};
|
6
|
+
export interface Option {
|
7
|
+
label: string;
|
8
|
+
value: string;
|
9
|
+
}
|
10
|
+
export type ITreeMenu = IMenuItem & {
|
11
|
+
children: ITreeMenu[];
|
12
|
+
};
|
13
|
+
export type IMenuItem = IResourceItem & {
|
14
|
+
key: string;
|
15
|
+
route: string;
|
16
|
+
};
|
17
|
+
export * from "./field";
|
18
|
+
export * from "./upload";
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1,10 @@
|
|
1
|
-
{
|
1
|
+
export interface UploadedFile {
|
2
|
+
uid: string;
|
3
|
+
name: string;
|
4
|
+
url: string;
|
5
|
+
type: string;
|
6
|
+
size: number;
|
7
|
+
percent: number;
|
8
|
+
status: "error" | "success" | "done" | "uploading" | "removed";
|
9
|
+
}
|
10
|
+
//# sourceMappingURL=upload.d.ts.map
|
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
export * from "./notificationProvider";
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1,8 @@
|
|
1
|
-
{"
|
1
|
+
import type { NotificationProvider } from "@refinedev/core";
|
2
|
+
/**
|
3
|
+
* @deprecated `notificationProvider` is deprecated due to not being compatible with theme changes in Ant Design. Please use `useNotificationProvider` export as your notification provider.
|
4
|
+
* @see https://refine.dev/docs/api-reference/antd/theming/#usenotificationprovider-compatible-with-theme
|
5
|
+
*/
|
6
|
+
export declare const notificationProvider: NotificationProvider;
|
7
|
+
export declare const useNotificationProvider: () => NotificationProvider;
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@refinedev/antd",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.41.0",
|
4
4
|
"private": false,
|
5
5
|
"description": "refine is a React-based framework for building internal tools, rapidly. It ships with Ant Design System, an enterprise-level UI toolkit.",
|
6
6
|
"repository": {
|
@@ -46,9 +46,9 @@
|
|
46
46
|
},
|
47
47
|
"devDependencies": {
|
48
48
|
"@esbuild-plugins/node-resolve": "^0.1.4",
|
49
|
-
"@refinedev/cli": "^2.16.
|
50
|
-
"@refinedev/core": "^4.
|
51
|
-
"@refinedev/ui-tests": "^1.14.
|
49
|
+
"@refinedev/cli": "^2.16.35",
|
50
|
+
"@refinedev/core": "^4.52.0",
|
51
|
+
"@refinedev/ui-tests": "^1.14.8",
|
52
52
|
"@testing-library/jest-dom": "^5.16.4",
|
53
53
|
"@testing-library/react": "^13.1.1",
|
54
54
|
"@testing-library/react-hooks": "^8.0.0",
|
@@ -17,7 +17,7 @@ export const AutoSaveIndicator: React.FC<AutoSaveIndicatorProps> = ({
|
|
17
17
|
elements: {
|
18
18
|
success = (
|
19
19
|
<Message
|
20
|
-
|
20
|
+
translationKey="autoSave.success"
|
21
21
|
defaultMessage="saved"
|
22
22
|
// @ts-expect-error Ant Design Icon's v5.0.1 has an issue with @types/react@^18.2.66
|
23
23
|
icon={<CheckCircleOutlined />}
|
@@ -25,7 +25,7 @@ export const AutoSaveIndicator: React.FC<AutoSaveIndicatorProps> = ({
|
|
25
25
|
),
|
26
26
|
error = (
|
27
27
|
<Message
|
28
|
-
|
28
|
+
translationKey="autoSave.error"
|
29
29
|
defaultMessage="auto save failure"
|
30
30
|
// @ts-expect-error Ant Design Icon's v5.0.1 has an issue with @types/react@^18.2.66
|
31
31
|
icon={<ExclamationCircleOutlined />}
|
@@ -33,7 +33,7 @@ export const AutoSaveIndicator: React.FC<AutoSaveIndicatorProps> = ({
|
|
33
33
|
),
|
34
34
|
loading = (
|
35
35
|
<Message
|
36
|
-
|
36
|
+
translationKey="autoSave.loading"
|
37
37
|
defaultMessage="saving..."
|
38
38
|
// @ts-expect-error Ant Design Icon's v5.0.1 has an issue with @types/react@^18.2.66
|
39
39
|
icon={<SyncOutlined />}
|
@@ -41,7 +41,7 @@ export const AutoSaveIndicator: React.FC<AutoSaveIndicatorProps> = ({
|
|
41
41
|
),
|
42
42
|
idle = (
|
43
43
|
<Message
|
44
|
-
|
44
|
+
translationKey="autoSave.idle"
|
45
45
|
defaultMessage="waiting for changes"
|
46
46
|
// @ts-expect-error Ant Design Icon's v5.0.1 has an issue with @types/react@^18.2.66
|
47
47
|
icon={<EllipsisOutlined />}
|
@@ -63,11 +63,11 @@ export const AutoSaveIndicator: React.FC<AutoSaveIndicatorProps> = ({
|
|
63
63
|
};
|
64
64
|
|
65
65
|
const Message = ({
|
66
|
-
|
66
|
+
translationKey,
|
67
67
|
defaultMessage,
|
68
68
|
icon,
|
69
69
|
}: {
|
70
|
-
|
70
|
+
translationKey: string;
|
71
71
|
defaultMessage: string;
|
72
72
|
icon: React.ReactNode;
|
73
73
|
}) => {
|
@@ -82,7 +82,7 @@ const Message = ({
|
|
82
82
|
fontSize: ".8rem",
|
83
83
|
}}
|
84
84
|
>
|
85
|
-
{translate(
|
85
|
+
{translate(translationKey, defaultMessage)}
|
86
86
|
<span style={{ marginLeft: ".2rem" }}>{icon}</span>
|
87
87
|
</Typography.Text>
|
88
88
|
);
|
@@ -74,7 +74,7 @@ export const Sider: React.FC<RefineLayoutSiderProps> = ({
|
|
74
74
|
return (
|
75
75
|
<CanAccess
|
76
76
|
key={item.key}
|
77
|
-
resource={name
|
77
|
+
resource={name}
|
78
78
|
action="list"
|
79
79
|
params={{
|
80
80
|
resource: item,
|
@@ -99,7 +99,7 @@ export const Sider: React.FC<RefineLayoutSiderProps> = ({
|
|
99
99
|
return (
|
100
100
|
<CanAccess
|
101
101
|
key={item.key}
|
102
|
-
resource={name
|
102
|
+
resource={name}
|
103
103
|
action="list"
|
104
104
|
params={{
|
105
105
|
resource: item,
|
@@ -1,22 +1,25 @@
|
|
1
|
-
import React, { type FC } from "react";
|
1
|
+
import React, { useContext, type FC } from "react";
|
2
2
|
import {
|
3
3
|
PageHeader as AntdPageHeader,
|
4
4
|
type PageHeaderProps as AntdPageHeaderProps,
|
5
5
|
} from "@ant-design/pro-layout";
|
6
|
-
import { Button, Typography } from "antd";
|
7
|
-
import { ArrowLeftOutlined } from "@ant-design/icons";
|
6
|
+
import { Button, ConfigProvider, Typography } from "antd";
|
7
|
+
import { ArrowLeftOutlined, ArrowRightOutlined } from "@ant-design/icons";
|
8
8
|
import { RefinePageHeaderClassNames } from "@refinedev/ui-types";
|
9
9
|
|
10
10
|
export type PageHeaderProps = AntdPageHeaderProps;
|
11
11
|
|
12
12
|
export const PageHeader: FC<AntdPageHeaderProps> = ({ children, ...props }) => {
|
13
|
+
const direction = useContext(ConfigProvider.ConfigContext)?.direction;
|
14
|
+
const renderBackButton = () => {
|
15
|
+
const BackIcon =
|
16
|
+
direction === "rtl" ? ArrowRightOutlined : ArrowLeftOutlined;
|
17
|
+
|
18
|
+
// @ts-expect-error Ant Design Icon's v5.0.1 has an issue with @types/react@^18.2.66
|
19
|
+
return <Button type="text" icon={<BackIcon />} />;
|
20
|
+
};
|
13
21
|
const backIcon =
|
14
|
-
typeof props.backIcon === "undefined" ? (
|
15
|
-
// @ts-expect-error Ant Design Icon's v5.0.1 has an issue with @types/react@^18.2.66
|
16
|
-
<Button type="text" icon={<ArrowLeftOutlined />} />
|
17
|
-
) : (
|
18
|
-
props.backIcon
|
19
|
-
);
|
22
|
+
typeof props.backIcon === "undefined" ? renderBackButton() : props.backIcon;
|
20
23
|
|
21
24
|
const title =
|
22
25
|
typeof props.title === "string" ? (
|
@@ -80,7 +80,7 @@ export const ThemedSider: React.FC<RefineThemedLayoutSiderProps> = ({
|
|
80
80
|
return (
|
81
81
|
<CanAccess
|
82
82
|
key={item.key}
|
83
|
-
resource={name
|
83
|
+
resource={name}
|
84
84
|
action="list"
|
85
85
|
params={{
|
86
86
|
resource: item,
|
@@ -106,7 +106,7 @@ export const ThemedSider: React.FC<RefineThemedLayoutSiderProps> = ({
|
|
106
106
|
return (
|
107
107
|
<CanAccess
|
108
108
|
key={item.key}
|
109
|
-
resource={name
|
109
|
+
resource={name}
|
110
110
|
action="list"
|
111
111
|
params={{
|
112
112
|
resource: item,
|
@@ -1,5 +1,13 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import {
|
1
|
+
import React, { useContext } from "react";
|
2
|
+
import {
|
3
|
+
Layout,
|
4
|
+
Menu,
|
5
|
+
Grid,
|
6
|
+
Drawer,
|
7
|
+
Button,
|
8
|
+
theme,
|
9
|
+
ConfigProvider,
|
10
|
+
} from "antd";
|
3
11
|
import {
|
4
12
|
DashboardOutlined,
|
5
13
|
LogoutOutlined,
|
@@ -46,6 +54,7 @@ export const ThemedSiderV2: React.FC<RefineThemedLayoutV2SiderProps> = ({
|
|
46
54
|
} = useThemedLayoutContext();
|
47
55
|
|
48
56
|
const isExistAuthentication = useIsExistAuthentication();
|
57
|
+
const direction = useContext(ConfigProvider.ConfigContext)?.direction;
|
49
58
|
const routerType = useRouterType();
|
50
59
|
const NewLink = useLink();
|
51
60
|
const { warnWhen, setWarnWhen } = useWarnAboutChange();
|
@@ -84,7 +93,7 @@ export const ThemedSiderV2: React.FC<RefineThemedLayoutV2SiderProps> = ({
|
|
84
93
|
return (
|
85
94
|
<CanAccess
|
86
95
|
key={item.key}
|
87
|
-
resource={name
|
96
|
+
resource={name}
|
88
97
|
action="list"
|
89
98
|
params={{
|
90
99
|
resource: item,
|
@@ -113,7 +122,7 @@ export const ThemedSiderV2: React.FC<RefineThemedLayoutV2SiderProps> = ({
|
|
113
122
|
return (
|
114
123
|
<CanAccess
|
115
124
|
key={item.key}
|
116
|
-
resource={name
|
125
|
+
resource={name}
|
117
126
|
action="list"
|
118
127
|
params={{
|
119
128
|
resource: item,
|
@@ -282,6 +291,15 @@ export const ThemedSiderV2: React.FC<RefineThemedLayoutV2SiderProps> = ({
|
|
282
291
|
siderStyles.height = "100vh";
|
283
292
|
siderStyles.zIndex = 999;
|
284
293
|
}
|
294
|
+
const renderClosingIcons = () => {
|
295
|
+
const iconProps = { style: { color: token.colorPrimary } };
|
296
|
+
const OpenIcon = direction === "rtl" ? RightOutlined : LeftOutlined;
|
297
|
+
const CollapsedIcon = direction === "rtl" ? LeftOutlined : RightOutlined;
|
298
|
+
const IconComponent = siderCollapsed ? CollapsedIcon : OpenIcon;
|
299
|
+
|
300
|
+
// @ts-expect-error Ant Design Icon's v5.0.1 has an issue with @types/react@^18.2.66
|
301
|
+
return <IconComponent {...iconProps} />;
|
302
|
+
};
|
285
303
|
|
286
304
|
return (
|
287
305
|
<>
|
@@ -314,21 +332,7 @@ export const ThemedSiderV2: React.FC<RefineThemedLayoutV2SiderProps> = ({
|
|
314
332
|
backgroundColor: token.colorBgElevated,
|
315
333
|
}}
|
316
334
|
>
|
317
|
-
{
|
318
|
-
// @ts-expect-error Ant Design Icon's v5.0.1 has an issue with @types/react@^18.2.66
|
319
|
-
<RightOutlined
|
320
|
-
style={{
|
321
|
-
color: token.colorPrimary,
|
322
|
-
}}
|
323
|
-
/>
|
324
|
-
) : (
|
325
|
-
// @ts-expect-error Ant Design Icon's v5.0.1 has an issue with @types/react@^18.2.66
|
326
|
-
<LeftOutlined
|
327
|
-
style={{
|
328
|
-
color: token.colorPrimary,
|
329
|
-
}}
|
330
|
-
/>
|
331
|
-
)}
|
335
|
+
{renderClosingIcons()}
|
332
336
|
</Button>
|
333
337
|
}
|
334
338
|
>
|
@@ -63,6 +63,7 @@ export const useCheckboxGroup = <
|
|
63
63
|
pagination,
|
64
64
|
liveMode,
|
65
65
|
defaultValue,
|
66
|
+
selectedOptionsOrder,
|
66
67
|
onLiveEvent,
|
67
68
|
liveParams,
|
68
69
|
meta,
|
@@ -90,6 +91,7 @@ export const useCheckboxGroup = <
|
|
90
91
|
pagination,
|
91
92
|
liveMode,
|
92
93
|
defaultValue,
|
94
|
+
selectedOptionsOrder,
|
93
95
|
onLiveEvent,
|
94
96
|
liveParams,
|
95
97
|
meta: pickNotDeprecated(meta, metaData),
|
@@ -60,6 +60,7 @@ export const useRadioGroup = <
|
|
60
60
|
pagination,
|
61
61
|
liveMode,
|
62
62
|
defaultValue,
|
63
|
+
selectedOptionsOrder,
|
63
64
|
onLiveEvent,
|
64
65
|
liveParams,
|
65
66
|
meta,
|
@@ -86,6 +87,7 @@ export const useRadioGroup = <
|
|
86
87
|
pagination,
|
87
88
|
liveMode,
|
88
89
|
defaultValue,
|
90
|
+
selectedOptionsOrder,
|
89
91
|
onLiveEvent,
|
90
92
|
liveParams,
|
91
93
|
meta: pickNotDeprecated(meta, metaData),
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import React, { useCallback } from "react";
|
2
|
-
import type { UseFormConfig } from "sunflower-antd";
|
3
2
|
import type { FormInstance, FormProps, DrawerProps, ButtonProps } from "antd";
|
4
3
|
import {
|
5
4
|
useTranslate,
|
@@ -20,7 +19,7 @@ import {
|
|
20
19
|
import { useForm, type UseFormProps, type UseFormReturnType } from "../useForm";
|
21
20
|
import type { DeleteButtonProps } from "../../../components";
|
22
21
|
|
23
|
-
export interface UseDrawerFormConfig
|
22
|
+
export interface UseDrawerFormConfig {
|
24
23
|
action: "show" | "edit" | "create" | "clone";
|
25
24
|
}
|
26
25
|
|
@@ -5,7 +5,7 @@ import {
|
|
5
5
|
Form,
|
6
6
|
type ButtonProps,
|
7
7
|
} from "antd";
|
8
|
-
import { useForm as useFormSF } from "sunflower-antd";
|
8
|
+
import { useForm as useFormSF, type UseFormConfig } from "sunflower-antd";
|
9
9
|
import {
|
10
10
|
type AutoSaveProps,
|
11
11
|
flattenObjectKeys,
|
@@ -52,7 +52,8 @@ export type UseFormProps<
|
|
52
52
|
* @see {@link https://refine.dev/docs/advanced-tutorials/forms/server-side-form-validation/}
|
53
53
|
*/
|
54
54
|
disableServerSideValidation?: boolean;
|
55
|
-
} & AutoSaveProps<TVariables
|
55
|
+
} & AutoSaveProps<TVariables> &
|
56
|
+
Pick<UseFormConfig, "defaultFormValues">;
|
56
57
|
|
57
58
|
export type UseFormReturnType<
|
58
59
|
TQueryFnData extends BaseRecord = BaseRecord,
|
@@ -77,7 +78,10 @@ export type UseFormReturnType<
|
|
77
78
|
onFinish: (
|
78
79
|
values?: TVariables,
|
79
80
|
) => Promise<CreateResponse<TResponse> | UpdateResponse<TResponse> | void>;
|
80
|
-
}
|
81
|
+
} & Pick<
|
82
|
+
ReturnType<typeof useFormSF<TResponse, TVariables>>,
|
83
|
+
"defaultFormValuesLoading"
|
84
|
+
>;
|
81
85
|
|
82
86
|
/**
|
83
87
|
* `useForm` is used to manage forms. It uses Ant Design {@link https://ant.design/components/form/ Form} data scope management under the hood and returns the required props for managing the form actions.
|
@@ -128,6 +132,7 @@ export const useForm = <
|
|
128
132
|
id: idFromProps,
|
129
133
|
overtimeOptions,
|
130
134
|
optimisticUpdateMap,
|
135
|
+
defaultFormValues,
|
131
136
|
disableServerSideValidation: disableServerSideValidationProp = false,
|
132
137
|
}: UseFormProps<
|
133
138
|
TQueryFnData,
|
@@ -153,6 +158,7 @@ export const useForm = <
|
|
153
158
|
const [formAnt] = Form.useForm();
|
154
159
|
const formSF = useFormSF<TResponse, TVariables>({
|
155
160
|
form: formAnt,
|
161
|
+
defaultFormValues,
|
156
162
|
});
|
157
163
|
const { form } = formSF;
|
158
164
|
|
@@ -264,6 +270,8 @@ export const useForm = <
|
|
264
270
|
const warnWhenUnsavedChanges =
|
265
271
|
warnWhenUnsavedChangesProp ?? warnWhenUnsavedChangesRefine;
|
266
272
|
|
273
|
+
// populate form with data when queryResult is ready or id changes
|
274
|
+
// form populated via initialValues prop
|
267
275
|
React.useEffect(() => {
|
268
276
|
form.resetFields();
|
269
277
|
}, [queryResult?.data?.data, id]);
|
@@ -310,6 +318,7 @@ export const useForm = <
|
|
310
318
|
initialValues: queryResult?.data?.data,
|
311
319
|
},
|
312
320
|
saveButtonProps,
|
321
|
+
defaultFormValuesLoading: formSF.defaultFormValuesLoading,
|
313
322
|
...useFormCoreResult,
|
314
323
|
onFinish: async (values?: TVariables) => {
|
315
324
|
return await onFinish(values ?? formSF.form.getFieldsValue(true));
|