@refinedev/antd 5.16.2 → 5.17.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 +69 -0
- package/dist/components/buttons/clone/index.d.ts.map +1 -1
- package/dist/components/buttons/create/index.d.ts.map +1 -1
- package/dist/components/buttons/delete/index.d.ts.map +1 -1
- package/dist/components/buttons/edit/index.d.ts.map +1 -1
- package/dist/components/buttons/export/index.d.ts.map +1 -1
- package/dist/components/buttons/import/index.d.ts.map +1 -1
- package/dist/components/buttons/list/index.d.ts.map +1 -1
- package/dist/components/buttons/refresh/index.d.ts.map +1 -1
- package/dist/components/buttons/save/index.d.ts.map +1 -1
- package/dist/components/buttons/show/index.d.ts.map +1 -1
- package/dist/components/crud/create/index.d.ts.map +1 -1
- package/dist/components/crud/edit/index.d.ts.map +1 -1
- package/dist/components/crud/list/index.d.ts.map +1 -1
- package/dist/components/crud/show/index.d.ts.map +1 -1
- package/dist/components/crud/types.d.ts +3 -3
- package/dist/components/crud/types.d.ts.map +1 -1
- package/dist/components/pageHeader/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/form/useDrawerForm/useDrawerForm.d.ts.map +1 -1
- package/dist/hooks/form/useModalForm/useModalForm.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 +3 -3
- package/src/components/buttons/clone/index.tsx +5 -1
- package/src/components/buttons/create/index.tsx +5 -1
- package/src/components/buttons/delete/index.tsx +5 -1
- package/src/components/buttons/edit/index.tsx +5 -1
- package/src/components/buttons/export/index.tsx +5 -1
- package/src/components/buttons/import/index.tsx +5 -1
- package/src/components/buttons/list/index.tsx +5 -1
- package/src/components/buttons/refresh/index.tsx +5 -1
- package/src/components/buttons/save/index.tsx +5 -1
- package/src/components/buttons/show/index.tsx +5 -1
- package/src/components/crud/create/index.tsx +15 -7
- package/src/components/crud/edit/index.tsx +63 -50
- package/src/components/crud/list/index.tsx +23 -12
- package/src/components/crud/show/index.tsx +61 -52
- package/src/components/crud/types.ts +14 -3
- package/src/components/pageHeader/index.tsx +7 -1
- package/src/hooks/form/useDrawerForm/useDrawerForm.ts +18 -10
- package/src/hooks/form/useModalForm/useModalForm.ts +8 -6
@@ -2,8 +2,11 @@ import { CardProps, SpaceProps } from "antd";
|
|
2
2
|
import {
|
3
3
|
CreateButtonProps,
|
4
4
|
DeleteButtonProps,
|
5
|
+
EditButtonProps,
|
6
|
+
ListButtonProps,
|
7
|
+
RefreshButtonProps,
|
5
8
|
SaveButtonProps,
|
6
|
-
} from "
|
9
|
+
} from "../buttons/types";
|
7
10
|
import {
|
8
11
|
RefineCrudCreateProps,
|
9
12
|
RefineCrudEditProps,
|
@@ -34,7 +37,10 @@ export type EditProps = RefineCrudEditProps<
|
|
34
37
|
HTMLDivElement
|
35
38
|
>,
|
36
39
|
PageHeaderProps,
|
37
|
-
CardProps
|
40
|
+
CardProps,
|
41
|
+
{},
|
42
|
+
RefreshButtonProps,
|
43
|
+
ListButtonProps
|
38
44
|
>;
|
39
45
|
|
40
46
|
export type ListProps = RefineCrudListProps<
|
@@ -59,5 +65,10 @@ export type ShowProps = RefineCrudShowProps<
|
|
59
65
|
HTMLDivElement
|
60
66
|
>,
|
61
67
|
PageHeaderProps,
|
62
|
-
CardProps
|
68
|
+
CardProps,
|
69
|
+
{},
|
70
|
+
EditButtonProps,
|
71
|
+
DeleteButtonProps,
|
72
|
+
RefreshButtonProps,
|
73
|
+
ListButtonProps
|
63
74
|
>;
|
@@ -5,6 +5,7 @@ import {
|
|
5
5
|
} from "@ant-design/pro-layout";
|
6
6
|
import { Button, Typography } from "antd";
|
7
7
|
import { ArrowLeftOutlined } from "@ant-design/icons";
|
8
|
+
import { RefinePageHeaderClassNames } from "@refinedev/ui-types";
|
8
9
|
|
9
10
|
export type PageHeaderProps = AntdPageHeaderProps;
|
10
11
|
|
@@ -18,7 +19,11 @@ export const PageHeader: FC<AntdPageHeaderProps> = ({ children, ...props }) => {
|
|
18
19
|
|
19
20
|
const title =
|
20
21
|
typeof props.title === "string" ? (
|
21
|
-
<Typography.Title
|
22
|
+
<Typography.Title
|
23
|
+
className={RefinePageHeaderClassNames.Title}
|
24
|
+
level={4}
|
25
|
+
style={{ marginBottom: 0 }}
|
26
|
+
>
|
22
27
|
{props.title}
|
23
28
|
</Typography.Title>
|
24
29
|
) : (
|
@@ -28,6 +33,7 @@ export const PageHeader: FC<AntdPageHeaderProps> = ({ children, ...props }) => {
|
|
28
33
|
const subtitle =
|
29
34
|
typeof props.title === "string" ? (
|
30
35
|
<Typography.Title
|
36
|
+
className={RefinePageHeaderClassNames.SubTitle}
|
31
37
|
level={5}
|
32
38
|
type="secondary"
|
33
39
|
style={{ marginBottom: 0 }}
|
@@ -120,8 +120,6 @@ export const useDrawerForm = <
|
|
120
120
|
TResponse,
|
121
121
|
TResponseError
|
122
122
|
> => {
|
123
|
-
const initiallySynced = React.useRef(false);
|
124
|
-
|
125
123
|
const { visible, show, close } = useModal({
|
126
124
|
defaultVisible,
|
127
125
|
});
|
@@ -136,7 +134,7 @@ export const useDrawerForm = <
|
|
136
134
|
>({
|
137
135
|
...rest,
|
138
136
|
});
|
139
|
-
|
137
|
+
const [initiallySynced, setInitiallySynced] = React.useState(false);
|
140
138
|
const { form, formProps, formLoading, id, setId, onFinish } = useFormProps;
|
141
139
|
|
142
140
|
const { resource, action: actionFromParams } = useResource(rest.resource);
|
@@ -146,8 +144,10 @@ export const useDrawerForm = <
|
|
146
144
|
|
147
145
|
const action = rest.action ?? actionFromParams ?? "";
|
148
146
|
|
149
|
-
const syncingId =
|
150
|
-
typeof syncWithLocation === "object" &&
|
147
|
+
const syncingId = !(
|
148
|
+
typeof syncWithLocation === "object" &&
|
149
|
+
syncWithLocation?.syncId === false
|
150
|
+
);
|
151
151
|
|
152
152
|
const syncWithLocationKey =
|
153
153
|
typeof syncWithLocation === "object" && "key" in syncWithLocation
|
@@ -157,7 +157,7 @@ export const useDrawerForm = <
|
|
157
157
|
: undefined;
|
158
158
|
|
159
159
|
React.useEffect(() => {
|
160
|
-
if (initiallySynced
|
160
|
+
if (initiallySynced === false && syncWithLocationKey) {
|
161
161
|
const openStatus = parsed?.params?.[syncWithLocationKey]?.open;
|
162
162
|
if (typeof openStatus === "boolean") {
|
163
163
|
openStatus ? show() : close();
|
@@ -174,12 +174,12 @@ export const useDrawerForm = <
|
|
174
174
|
}
|
175
175
|
}
|
176
176
|
|
177
|
-
|
177
|
+
setInitiallySynced(true);
|
178
178
|
}
|
179
|
-
}, [syncWithLocationKey, parsed, syncingId, setId]);
|
179
|
+
}, [syncWithLocationKey, parsed, syncingId, setId, initiallySynced]);
|
180
180
|
|
181
181
|
React.useEffect(() => {
|
182
|
-
if (initiallySynced
|
182
|
+
if (initiallySynced === true) {
|
183
183
|
if (visible && syncWithLocationKey) {
|
184
184
|
go({
|
185
185
|
query: {
|
@@ -202,7 +202,15 @@ export const useDrawerForm = <
|
|
202
202
|
});
|
203
203
|
}
|
204
204
|
}
|
205
|
-
}, [
|
205
|
+
}, [
|
206
|
+
id,
|
207
|
+
visible,
|
208
|
+
show,
|
209
|
+
close,
|
210
|
+
syncWithLocationKey,
|
211
|
+
syncingId,
|
212
|
+
initiallySynced,
|
213
|
+
]);
|
206
214
|
|
207
215
|
const translate = useTranslate();
|
208
216
|
|
@@ -128,7 +128,7 @@ export const useModalForm = <
|
|
128
128
|
TResponse,
|
129
129
|
TResponseError
|
130
130
|
> => {
|
131
|
-
const initiallySynced = React.
|
131
|
+
const [initiallySynced, setInitiallySynced] = React.useState(false);
|
132
132
|
|
133
133
|
const useFormProps = useForm<
|
134
134
|
TQueryFnData,
|
@@ -150,8 +150,10 @@ export const useModalForm = <
|
|
150
150
|
|
151
151
|
const action = rest.action ?? actionFromParams ?? "";
|
152
152
|
|
153
|
-
const syncingId =
|
154
|
-
typeof syncWithLocation === "object" &&
|
153
|
+
const syncingId = !(
|
154
|
+
typeof syncWithLocation === "object" &&
|
155
|
+
syncWithLocation?.syncId === false
|
156
|
+
);
|
155
157
|
|
156
158
|
const syncWithLocationKey =
|
157
159
|
typeof syncWithLocation === "object" && "key" in syncWithLocation
|
@@ -191,7 +193,7 @@ export const useModalForm = <
|
|
191
193
|
};
|
192
194
|
|
193
195
|
React.useEffect(() => {
|
194
|
-
if (initiallySynced
|
196
|
+
if (initiallySynced === false && syncWithLocationKey) {
|
195
197
|
const openStatus = parsed?.params?.[syncWithLocationKey]?.open;
|
196
198
|
if (typeof openStatus === "boolean") {
|
197
199
|
if (openStatus) {
|
@@ -210,12 +212,12 @@ export const useModalForm = <
|
|
210
212
|
}
|
211
213
|
}
|
212
214
|
|
213
|
-
|
215
|
+
setInitiallySynced(true);
|
214
216
|
}
|
215
217
|
}, [syncWithLocationKey, parsed, syncingId, setId]);
|
216
218
|
|
217
219
|
React.useEffect(() => {
|
218
|
-
if (initiallySynced
|
220
|
+
if (initiallySynced === true) {
|
219
221
|
if (visible && syncWithLocationKey) {
|
220
222
|
go({
|
221
223
|
query: {
|