@refinedev/antd 5.37.3 → 5.37.5

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.
Files changed (172) hide show
  1. package/CHANGELOG.md +1766 -1776
  2. package/dist/components/autoSaveIndicator/index.d.ts.map +1 -1
  3. package/dist/components/breadcrumb/index.d.ts.map +1 -1
  4. package/dist/components/buttons/create/index.d.ts.map +1 -1
  5. package/dist/components/buttons/delete/index.d.ts.map +1 -1
  6. package/dist/components/buttons/import/index.d.ts.map +1 -1
  7. package/dist/components/buttons/types.d.ts.map +1 -1
  8. package/dist/components/crud/edit/index.d.ts.map +1 -1
  9. package/dist/components/crud/list/index.d.ts.map +1 -1
  10. package/dist/components/crud/show/index.d.ts.map +1 -1
  11. package/dist/components/crud/types.d.ts.map +1 -1
  12. package/dist/components/fields/date/index.d.ts.map +1 -1
  13. package/dist/components/fields/email/index.d.ts.map +1 -1
  14. package/dist/components/fields/number/index.d.ts.map +1 -1
  15. package/dist/components/fields/text/index.d.ts.map +1 -1
  16. package/dist/components/fields/types.d.ts.map +1 -1
  17. package/dist/components/fields/url/index.d.ts.map +1 -1
  18. package/dist/components/layout/header/index.d.ts.map +1 -1
  19. package/dist/components/layout/sider/index.d.ts.map +1 -1
  20. package/dist/components/layout/title/index.d.ts.map +1 -1
  21. package/dist/components/layout/types.d.ts.map +1 -1
  22. package/dist/components/pageHeader/index.d.ts.map +1 -1
  23. package/dist/components/pages/auth/components/forgotPassword/index.d.ts.map +1 -1
  24. package/dist/components/pages/auth/components/login/index.d.ts.map +1 -1
  25. package/dist/components/pages/auth/components/register/index.d.ts.map +1 -1
  26. package/dist/components/pages/auth/components/updatePassword/index.d.ts.map +1 -1
  27. package/dist/components/pages/auth/index.d.ts.map +1 -1
  28. package/dist/components/pages/error/index.d.ts.map +1 -1
  29. package/dist/components/pages/login/index.d.ts.map +1 -1
  30. package/dist/components/pages/ready/index.d.ts.map +1 -1
  31. package/dist/components/table/components/filterDropdown/index.d.ts.map +1 -1
  32. package/dist/components/themedLayout/header/index.d.ts.map +1 -1
  33. package/dist/components/themedLayout/sider/index.d.ts.map +1 -1
  34. package/dist/components/themedLayout/title/index.d.ts.map +1 -1
  35. package/dist/components/themedLayout/types.d.ts.map +1 -1
  36. package/dist/components/themedLayoutV2/header/index.d.ts.map +1 -1
  37. package/dist/components/themedLayoutV2/index.d.ts.map +1 -1
  38. package/dist/components/themedLayoutV2/sider/index.d.ts.map +1 -1
  39. package/dist/components/themedLayoutV2/title/index.d.ts.map +1 -1
  40. package/dist/components/themedLayoutV2/types.d.ts.map +1 -1
  41. package/dist/components/undoableNotification/index.d.ts.map +1 -1
  42. package/dist/contexts/index.d.ts.map +1 -1
  43. package/dist/contexts/themedLayoutContext/IThemedLayoutContext.d.ts.map +1 -1
  44. package/dist/contexts/themedLayoutContext/index.d.ts.map +1 -1
  45. package/dist/definitions/table/index.d.ts.map +1 -1
  46. package/dist/definitions/themes/index.d.ts.map +1 -1
  47. package/dist/esm/index.js +2 -1
  48. package/dist/esm/index.js.map +1 -1
  49. package/dist/hooks/fields/useCheckboxGroup/index.d.ts.map +1 -1
  50. package/dist/hooks/fields/useRadioGroup/index.d.ts.map +1 -1
  51. package/dist/hooks/fields/useSelect/index.d.ts.map +1 -1
  52. package/dist/hooks/form/index.d.ts.map +1 -1
  53. package/dist/hooks/form/useDrawerForm/index.d.ts.map +1 -1
  54. package/dist/hooks/form/useDrawerForm/useDrawerForm.d.ts.map +1 -1
  55. package/dist/hooks/form/useForm.d.ts.map +1 -1
  56. package/dist/hooks/form/useModalForm/index.d.ts.map +1 -1
  57. package/dist/hooks/form/useModalForm/useModalForm.d.ts.map +1 -1
  58. package/dist/hooks/form/useStepsForm/index.d.ts.map +1 -1
  59. package/dist/hooks/form/useStepsForm/useStepsForm.d.ts.map +1 -1
  60. package/dist/hooks/import/index.d.ts.map +1 -1
  61. package/dist/hooks/list/useSimpleList/useSimpleList.d.ts.map +1 -1
  62. package/dist/hooks/modal/useModal/index.d.ts.map +1 -1
  63. package/dist/hooks/table/useEditableTable/useEditableTable.d.ts.map +1 -1
  64. package/dist/hooks/table/useTable/paginationLink.d.ts.map +1 -1
  65. package/dist/hooks/table/useTable/useTable.d.ts.map +1 -1
  66. package/dist/hooks/useFileUploadState/index.d.ts.map +1 -1
  67. package/dist/hooks/useSiderVisible/index.d.ts.map +1 -1
  68. package/dist/iife/index.js +11 -10
  69. package/dist/iife/index.js.map +1 -1
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +2 -1
  72. package/dist/index.js.map +1 -1
  73. package/dist/interfaces/field.d.ts.map +1 -1
  74. package/dist/interfaces/index.d.ts.map +1 -1
  75. package/dist/interfaces/upload.d.ts.map +1 -1
  76. package/package.json +32 -32
  77. package/refine.config.js +497 -524
  78. package/src/components/autoSaveIndicator/index.tsx +69 -70
  79. package/src/components/breadcrumb/index.tsx +63 -65
  80. package/src/components/buttons/clone/index.tsx +86 -86
  81. package/src/components/buttons/create/index.tsx +85 -86
  82. package/src/components/buttons/delete/index.tsx +114 -119
  83. package/src/components/buttons/edit/index.tsx +86 -86
  84. package/src/components/buttons/export/index.tsx +17 -17
  85. package/src/components/buttons/import/index.tsx +19 -20
  86. package/src/components/buttons/list/index.tsx +105 -105
  87. package/src/components/buttons/refresh/index.tsx +50 -50
  88. package/src/components/buttons/save/index.tsx +17 -17
  89. package/src/components/buttons/show/index.tsx +86 -86
  90. package/src/components/buttons/types.ts +20 -20
  91. package/src/components/crud/create/index.tsx +120 -120
  92. package/src/components/crud/edit/index.tsx +205 -207
  93. package/src/components/crud/list/index.tsx +88 -90
  94. package/src/components/crud/show/index.tsx +175 -185
  95. package/src/components/crud/types.ts +41 -56
  96. package/src/components/fields/boolean/index.tsx +11 -11
  97. package/src/components/fields/date/index.tsx +13 -15
  98. package/src/components/fields/email/index.tsx +5 -7
  99. package/src/components/fields/file/index.tsx +8 -8
  100. package/src/components/fields/image/index.tsx +4 -4
  101. package/src/components/fields/markdown/index.tsx +9 -9
  102. package/src/components/fields/number/index.tsx +17 -19
  103. package/src/components/fields/tag/index.tsx +1 -1
  104. package/src/components/fields/text/index.tsx +1 -3
  105. package/src/components/fields/types.ts +18 -18
  106. package/src/components/fields/url/index.tsx +8 -10
  107. package/src/components/layout/header/index.tsx +25 -26
  108. package/src/components/layout/index.tsx +30 -30
  109. package/src/components/layout/sider/index.tsx +238 -248
  110. package/src/components/layout/sider/styles.ts +5 -5
  111. package/src/components/layout/title/index.tsx +40 -40
  112. package/src/components/layout/types.ts +6 -6
  113. package/src/components/pageHeader/index.tsx +44 -44
  114. package/src/components/pages/auth/components/forgotPassword/index.tsx +177 -183
  115. package/src/components/pages/auth/components/login/index.tsx +258 -274
  116. package/src/components/pages/auth/components/register/index.tsx +247 -266
  117. package/src/components/pages/auth/components/styles.ts +16 -16
  118. package/src/components/pages/auth/components/updatePassword/index.tsx +160 -177
  119. package/src/components/pages/auth/index.tsx +23 -23
  120. package/src/components/pages/error/index.tsx +57 -59
  121. package/src/components/pages/login/index.tsx +120 -147
  122. package/src/components/pages/login/styles.ts +12 -12
  123. package/src/components/pages/ready/index.tsx +72 -80
  124. package/src/components/pages/welcome/index.tsx +1 -1
  125. package/src/components/table/components/filterDropdown/index.tsx +89 -92
  126. package/src/components/themedLayout/header/index.tsx +28 -33
  127. package/src/components/themedLayout/index.tsx +30 -30
  128. package/src/components/themedLayout/sider/index.tsx +279 -282
  129. package/src/components/themedLayout/sider/styles.ts +5 -5
  130. package/src/components/themedLayout/title/index.tsx +66 -68
  131. package/src/components/themedLayout/types.ts +8 -8
  132. package/src/components/themedLayoutV2/header/index.tsx +43 -48
  133. package/src/components/themedLayoutV2/index.tsx +34 -36
  134. package/src/components/themedLayoutV2/sider/index.tsx +309 -316
  135. package/src/components/themedLayoutV2/sider/styles.ts +5 -5
  136. package/src/components/themedLayoutV2/title/index.tsx +66 -68
  137. package/src/components/themedLayoutV2/types.ts +9 -9
  138. package/src/components/undoableNotification/index.tsx +31 -31
  139. package/src/contexts/index.ts +2 -2
  140. package/src/contexts/themedLayoutContext/IThemedLayoutContext.ts +4 -4
  141. package/src/contexts/themedLayoutContext/index.tsx +22 -22
  142. package/src/definitions/table/index.ts +81 -82
  143. package/src/definitions/themes/index.ts +35 -35
  144. package/src/definitions/upload/index.ts +17 -17
  145. package/src/hooks/fields/useCheckboxGroup/index.ts +64 -64
  146. package/src/hooks/fields/useRadioGroup/index.ts +60 -63
  147. package/src/hooks/fields/useSelect/index.ts +30 -30
  148. package/src/hooks/form/index.ts +10 -10
  149. package/src/hooks/form/useDrawerForm/index.ts +4 -4
  150. package/src/hooks/form/useDrawerForm/useDrawerForm.ts +257 -261
  151. package/src/hooks/form/useForm.ts +256 -259
  152. package/src/hooks/form/useModalForm/index.ts +3 -3
  153. package/src/hooks/form/useModalForm/useModalForm.ts +289 -295
  154. package/src/hooks/form/useStepsForm/index.ts +3 -3
  155. package/src/hooks/form/useStepsForm/useStepsForm.ts +96 -96
  156. package/src/hooks/import/index.tsx +104 -106
  157. package/src/hooks/list/useSimpleList/useSimpleList.ts +179 -185
  158. package/src/hooks/modal/useModal/index.tsx +24 -24
  159. package/src/hooks/table/useEditableTable/useEditableTable.ts +85 -85
  160. package/src/hooks/table/useTable/paginationLink.tsx +17 -17
  161. package/src/hooks/table/useTable/useTable.ts +199 -205
  162. package/src/hooks/useFileUploadState/index.ts +20 -20
  163. package/src/hooks/useSiderVisible/index.ts +16 -16
  164. package/src/hooks/useThemedLayoutContext/index.ts +12 -12
  165. package/src/index.tsx +4 -4
  166. package/src/interfaces/field.ts +1 -1
  167. package/src/interfaces/index.ts +7 -8
  168. package/src/interfaces/upload.ts +7 -7
  169. package/src/providers/notificationProvider/index.tsx +78 -78
  170. package/src/types/index.d.ts +2 -2
  171. package/src/types/sunflower.d.ts +68 -68
  172. package/tsconfig.json +26 -26
@@ -2,94 +2,94 @@ import React, { useCallback } from "react";
2
2
  import { FormInstance, FormProps, ModalProps } from "antd";
3
3
 
4
4
  import {
5
- useTranslate,
6
- useWarnAboutChange,
7
- HttpError,
8
- UseFormProps as UseFormPropsCore,
9
- BaseRecord,
10
- LiveModeProps,
11
- BaseKey,
12
- useUserFriendlyName,
13
- useResource,
14
- FormWithSyncWithLocationParams,
15
- useParsed,
16
- useGo,
17
- useInvalidate,
5
+ useTranslate,
6
+ useWarnAboutChange,
7
+ HttpError,
8
+ UseFormProps as UseFormPropsCore,
9
+ BaseRecord,
10
+ LiveModeProps,
11
+ BaseKey,
12
+ useUserFriendlyName,
13
+ useResource,
14
+ FormWithSyncWithLocationParams,
15
+ useParsed,
16
+ useGo,
17
+ useInvalidate,
18
18
  } from "@refinedev/core";
19
19
  import { useForm, UseFormProps, UseFormReturnType } from "../useForm";
20
20
  import { useModal } from "@hooks/modal";
21
21
 
22
22
  export type useModalFormFromSFReturnType<TResponse, TVariables> = {
23
- open: boolean;
24
- form: FormInstance<TVariables>;
25
- show: (id?: BaseKey) => void;
26
- close: () => void;
27
- modalProps: ModalProps;
28
- formProps: FormProps<TVariables>;
29
- formLoading: boolean;
30
- defaultFormValuesLoading: boolean;
31
- formValues: {};
32
- initialValues: {};
33
- formResult: undefined;
34
- submit: (values?: TVariables) => Promise<TResponse>;
35
- /** @deprecated Please use `open` instead. */
36
- visible: boolean;
23
+ open: boolean;
24
+ form: FormInstance<TVariables>;
25
+ show: (id?: BaseKey) => void;
26
+ close: () => void;
27
+ modalProps: ModalProps;
28
+ formProps: FormProps<TVariables>;
29
+ formLoading: boolean;
30
+ defaultFormValuesLoading: boolean;
31
+ formValues: {};
32
+ initialValues: {};
33
+ formResult: undefined;
34
+ submit: (values?: TVariables) => Promise<TResponse>;
35
+ /** @deprecated Please use `open` instead. */
36
+ visible: boolean;
37
37
  };
38
38
 
39
39
  type useModalFormConfig = {
40
- action: "show" | "edit" | "create" | "clone";
40
+ action: "show" | "edit" | "create" | "clone";
41
41
  };
42
42
 
43
43
  export type UseModalFormReturnType<
44
- TQueryFnData extends BaseRecord = BaseRecord,
45
- TError extends HttpError = HttpError,
46
- TVariables = {},
47
- TData extends BaseRecord = TQueryFnData,
48
- TResponse extends BaseRecord = TData,
49
- TResponseError extends HttpError = TError,
44
+ TQueryFnData extends BaseRecord = BaseRecord,
45
+ TError extends HttpError = HttpError,
46
+ TVariables = {},
47
+ TData extends BaseRecord = TQueryFnData,
48
+ TResponse extends BaseRecord = TData,
49
+ TResponseError extends HttpError = TError,
50
50
  > = Omit<
51
- UseFormReturnType<
52
- TQueryFnData,
53
- TError,
54
- TVariables,
55
- TData,
56
- TResponse,
57
- TResponseError
58
- >,
59
- "saveButtonProps" | "deleteButtonProps"
51
+ UseFormReturnType<
52
+ TQueryFnData,
53
+ TError,
54
+ TVariables,
55
+ TData,
56
+ TResponse,
57
+ TResponseError
58
+ >,
59
+ "saveButtonProps" | "deleteButtonProps"
60
60
  > &
61
- useModalFormFromSFReturnType<TResponse, TVariables>;
61
+ useModalFormFromSFReturnType<TResponse, TVariables>;
62
62
 
63
63
  export type UseModalFormProps<
64
- TQueryFnData extends BaseRecord = BaseRecord,
65
- TError extends HttpError = HttpError,
66
- TVariables = {},
67
- TData extends BaseRecord = TQueryFnData,
68
- TResponse extends BaseRecord = TData,
69
- TResponseError extends HttpError = TError,
64
+ TQueryFnData extends BaseRecord = BaseRecord,
65
+ TError extends HttpError = HttpError,
66
+ TVariables = {},
67
+ TData extends BaseRecord = TQueryFnData,
68
+ TResponse extends BaseRecord = TData,
69
+ TResponseError extends HttpError = TError,
70
70
  > = UseFormPropsCore<
71
+ TQueryFnData,
72
+ TError,
73
+ TVariables,
74
+ TData,
75
+ TResponse,
76
+ TResponseError
77
+ > &
78
+ UseFormProps<
71
79
  TQueryFnData,
72
80
  TError,
73
81
  TVariables,
74
82
  TData,
75
83
  TResponse,
76
84
  TResponseError
77
- > &
78
- UseFormProps<
79
- TQueryFnData,
80
- TError,
81
- TVariables,
82
- TData,
83
- TResponse,
84
- TResponseError
85
- > &
86
- useModalFormConfig &
87
- LiveModeProps &
88
- FormWithSyncWithLocationParams & {
89
- defaultVisible?: boolean;
90
- autoSubmitClose?: boolean;
91
- autoResetForm?: boolean;
92
- };
85
+ > &
86
+ useModalFormConfig &
87
+ LiveModeProps &
88
+ FormWithSyncWithLocationParams & {
89
+ defaultVisible?: boolean;
90
+ autoSubmitClose?: boolean;
91
+ autoResetForm?: boolean;
92
+ };
93
93
  /**
94
94
  * `useModalForm` hook allows you to manage a form within a modal. It returns Ant Design {@link https://ant.design/components/form/ Form} and {@link https://ant.design/components/modal/ Modal} components props.
95
95
  *
@@ -102,264 +102,258 @@ export type UseModalFormProps<
102
102
  *
103
103
  */
104
104
  export const useModalForm = <
105
- TQueryFnData extends BaseRecord = BaseRecord,
106
- TError extends HttpError = HttpError,
107
- TVariables = {},
108
- TData extends BaseRecord = TQueryFnData,
109
- TResponse extends BaseRecord = TData,
110
- TResponseError extends HttpError = TError,
105
+ TQueryFnData extends BaseRecord = BaseRecord,
106
+ TError extends HttpError = HttpError,
107
+ TVariables = {},
108
+ TData extends BaseRecord = TQueryFnData,
109
+ TResponse extends BaseRecord = TData,
110
+ TResponseError extends HttpError = TError,
111
111
  >({
112
- syncWithLocation,
113
- defaultVisible = false,
114
- autoSubmitClose = true,
115
- autoResetForm = true,
116
- autoSave,
117
- invalidates,
118
- ...rest
112
+ syncWithLocation,
113
+ defaultVisible = false,
114
+ autoSubmitClose = true,
115
+ autoResetForm = true,
116
+ autoSave,
117
+ invalidates,
118
+ ...rest
119
119
  }: UseModalFormProps<
120
- TQueryFnData,
121
- TError,
122
- TVariables,
123
- TData,
124
- TResponse,
125
- TResponseError
120
+ TQueryFnData,
121
+ TError,
122
+ TVariables,
123
+ TData,
124
+ TResponse,
125
+ TResponseError
126
126
  >): UseModalFormReturnType<
127
- TQueryFnData,
128
- TError,
129
- TVariables,
130
- TData,
131
- TResponse,
132
- TResponseError
127
+ TQueryFnData,
128
+ TError,
129
+ TVariables,
130
+ TData,
131
+ TResponse,
132
+ TResponseError
133
133
  > => {
134
- const [initiallySynced, setInitiallySynced] = React.useState(false);
135
- const invalidate = useInvalidate();
134
+ const [initiallySynced, setInitiallySynced] = React.useState(false);
135
+ const invalidate = useInvalidate();
136
136
 
137
- const {
138
- resource,
139
- action: actionFromParams,
140
- identifier,
141
- } = useResource(rest.resource);
137
+ const {
138
+ resource,
139
+ action: actionFromParams,
140
+ identifier,
141
+ } = useResource(rest.resource);
142
142
 
143
- const parsed = useParsed();
144
- const go = useGo();
145
- const getUserFriendlyName = useUserFriendlyName();
143
+ const parsed = useParsed();
144
+ const go = useGo();
145
+ const getUserFriendlyName = useUserFriendlyName();
146
146
 
147
- const action = rest.action ?? actionFromParams ?? "";
147
+ const action = rest.action ?? actionFromParams ?? "";
148
148
 
149
- const syncingId = !(
150
- typeof syncWithLocation === "object" &&
151
- syncWithLocation?.syncId === false
152
- );
149
+ const syncingId = !(
150
+ typeof syncWithLocation === "object" && syncWithLocation?.syncId === false
151
+ );
153
152
 
154
- const syncWithLocationKey =
155
- typeof syncWithLocation === "object" && "key" in syncWithLocation
156
- ? syncWithLocation.key
157
- : resource && action && syncWithLocation
158
- ? `modal-${identifier}-${action}`
159
- : undefined;
153
+ const syncWithLocationKey =
154
+ typeof syncWithLocation === "object" && "key" in syncWithLocation
155
+ ? syncWithLocation.key
156
+ : resource && action && syncWithLocation
157
+ ? `modal-${identifier}-${action}`
158
+ : undefined;
160
159
 
161
- const useFormProps = useForm<
162
- TQueryFnData,
163
- TError,
164
- TVariables,
165
- TData,
166
- TResponse,
167
- TResponseError
168
- >({
169
- meta: {
170
- ...(syncWithLocationKey
171
- ? { [syncWithLocationKey]: undefined }
172
- : {}),
173
- ...rest.meta,
174
- },
175
- autoSave,
176
- invalidates,
177
- ...rest,
178
- });
160
+ const useFormProps = useForm<
161
+ TQueryFnData,
162
+ TError,
163
+ TVariables,
164
+ TData,
165
+ TResponse,
166
+ TResponseError
167
+ >({
168
+ meta: {
169
+ ...(syncWithLocationKey ? { [syncWithLocationKey]: undefined } : {}),
170
+ ...rest.meta,
171
+ },
172
+ autoSave,
173
+ invalidates,
174
+ ...rest,
175
+ });
179
176
 
180
- const { form, formProps, id, setId, formLoading, onFinish, autoSaveProps } =
181
- useFormProps;
177
+ const { form, formProps, id, setId, formLoading, onFinish, autoSaveProps } =
178
+ useFormProps;
182
179
 
183
- const translate = useTranslate();
180
+ const translate = useTranslate();
184
181
 
185
- const { warnWhen, setWarnWhen } = useWarnAboutChange();
182
+ const { warnWhen, setWarnWhen } = useWarnAboutChange();
186
183
 
187
- const { show, close, modalProps } = useModal({
188
- modalProps: {
189
- open: defaultVisible,
190
- },
191
- });
184
+ const { show, close, modalProps } = useModal({
185
+ modalProps: {
186
+ open: defaultVisible,
187
+ },
188
+ });
192
189
 
193
- const visible = modalProps.open || false;
194
- const sunflowerUseModal: useModalFormFromSFReturnType<
195
- TResponse,
196
- TVariables
197
- > = {
198
- modalProps,
199
- form,
200
- formLoading,
201
- formProps,
202
- formResult: undefined,
203
- formValues: form.getFieldsValue,
204
- defaultFormValuesLoading: false,
205
- initialValues: {},
206
- submit: onFinish as any,
207
- close,
208
- open: modalProps.open || false,
209
- show,
210
- visible,
190
+ const visible = modalProps.open || false;
191
+ const sunflowerUseModal: useModalFormFromSFReturnType<TResponse, TVariables> =
192
+ {
193
+ modalProps,
194
+ form,
195
+ formLoading,
196
+ formProps,
197
+ formResult: undefined,
198
+ formValues: form.getFieldsValue,
199
+ defaultFormValuesLoading: false,
200
+ initialValues: {},
201
+ submit: onFinish as any,
202
+ close,
203
+ open: modalProps.open || false,
204
+ show,
205
+ visible,
211
206
  };
212
207
 
213
- React.useEffect(() => {
214
- if (initiallySynced === false && syncWithLocationKey) {
215
- const openStatus = parsed?.params?.[syncWithLocationKey]?.open;
216
-
217
- if (typeof openStatus === "boolean") {
218
- if (openStatus) {
219
- show();
220
- }
221
- } else if (typeof openStatus === "string") {
222
- if (openStatus === "true") {
223
- show();
224
- }
225
- }
226
-
227
- if (syncingId) {
228
- const idFromParams = parsed?.params?.[syncWithLocationKey]?.id;
229
- if (idFromParams) {
230
- setId?.(idFromParams);
231
- }
232
- }
208
+ React.useEffect(() => {
209
+ if (initiallySynced === false && syncWithLocationKey) {
210
+ const openStatus = parsed?.params?.[syncWithLocationKey]?.open;
233
211
 
234
- setInitiallySynced(true);
212
+ if (typeof openStatus === "boolean") {
213
+ if (openStatus) {
214
+ show();
235
215
  }
236
- }, [syncWithLocationKey, parsed, syncingId, setId]);
216
+ } else if (typeof openStatus === "string") {
217
+ if (openStatus === "true") {
218
+ show();
219
+ }
220
+ }
237
221
 
238
- React.useEffect(() => {
239
- if (initiallySynced === true) {
240
- if (visible && syncWithLocationKey) {
241
- go({
242
- query: {
243
- [syncWithLocationKey]: {
244
- ...parsed?.params?.[syncWithLocationKey],
245
- open: true,
246
- ...(syncingId && id && { id }),
247
- },
248
- },
249
- options: { keepQuery: true },
250
- type: "replace",
251
- });
252
- } else if (syncWithLocationKey && !visible) {
253
- go({
254
- query: {
255
- [syncWithLocationKey]: undefined,
256
- },
257
- options: { keepQuery: true },
258
- type: "replace",
259
- });
260
- }
222
+ if (syncingId) {
223
+ const idFromParams = parsed?.params?.[syncWithLocationKey]?.id;
224
+ if (idFromParams) {
225
+ setId?.(idFromParams);
261
226
  }
262
- }, [id, visible, show, syncWithLocationKey, syncingId]);
227
+ }
263
228
 
264
- const saveButtonPropsSF = {
265
- disabled: formLoading,
266
- loading: formLoading,
267
- onClick: () => {
268
- form.submit();
269
- },
270
- };
229
+ setInitiallySynced(true);
230
+ }
231
+ }, [syncWithLocationKey, parsed, syncingId, setId]);
271
232
 
272
- const handleClose = useCallback(() => {
273
- if (autoSaveProps.status === "success" && autoSave?.invalidateOnClose) {
274
- invalidate({
275
- id,
276
- invalidates: invalidates || ["list", "many", "detail"],
277
- dataProviderName: rest.dataProviderName,
278
- resource: identifier,
279
- });
280
- }
233
+ React.useEffect(() => {
234
+ if (initiallySynced === true) {
235
+ if (visible && syncWithLocationKey) {
236
+ go({
237
+ query: {
238
+ [syncWithLocationKey]: {
239
+ ...parsed?.params?.[syncWithLocationKey],
240
+ open: true,
241
+ ...(syncingId && id && { id }),
242
+ },
243
+ },
244
+ options: { keepQuery: true },
245
+ type: "replace",
246
+ });
247
+ } else if (syncWithLocationKey && !visible) {
248
+ go({
249
+ query: {
250
+ [syncWithLocationKey]: undefined,
251
+ },
252
+ options: { keepQuery: true },
253
+ type: "replace",
254
+ });
255
+ }
256
+ }
257
+ }, [id, visible, show, syncWithLocationKey, syncingId]);
281
258
 
282
- if (warnWhen) {
283
- const warnWhenConfirm = window.confirm(
284
- translate(
285
- "warnWhenUnsavedChanges",
286
- "Are you sure you want to leave? You have unsaved changes.",
287
- ),
288
- );
259
+ const saveButtonPropsSF = {
260
+ disabled: formLoading,
261
+ loading: formLoading,
262
+ onClick: () => {
263
+ form.submit();
264
+ },
265
+ };
289
266
 
290
- if (warnWhenConfirm) {
291
- setWarnWhen(false);
292
- } else {
293
- return;
294
- }
295
- }
267
+ const handleClose = useCallback(() => {
268
+ if (autoSaveProps.status === "success" && autoSave?.invalidateOnClose) {
269
+ invalidate({
270
+ id,
271
+ invalidates: invalidates || ["list", "many", "detail"],
272
+ dataProviderName: rest.dataProviderName,
273
+ resource: identifier,
274
+ });
275
+ }
296
276
 
297
- setId?.(undefined);
298
- sunflowerUseModal.close();
299
- }, [warnWhen, autoSaveProps.status]);
277
+ if (warnWhen) {
278
+ const warnWhenConfirm = window.confirm(
279
+ translate(
280
+ "warnWhenUnsavedChanges",
281
+ "Are you sure you want to leave? You have unsaved changes.",
282
+ ),
283
+ );
300
284
 
301
- const handleShow = useCallback(
302
- (showId?: BaseKey) => {
303
- if (typeof showId !== "undefined") {
304
- setId?.(showId);
305
- }
306
- const needsIdToOpen = action === "edit" || action === "clone";
307
- const hasId =
308
- typeof showId !== "undefined" || typeof id !== "undefined";
309
- if (needsIdToOpen ? hasId : true) {
310
- sunflowerUseModal.show();
311
- }
312
- },
313
- [id],
314
- );
285
+ if (warnWhenConfirm) {
286
+ setWarnWhen(false);
287
+ } else {
288
+ return;
289
+ }
290
+ }
315
291
 
316
- const { visible: _visible, ...otherModalProps } = modalProps;
317
- const newModalProps = { open: _visible, ...otherModalProps };
292
+ setId?.(undefined);
293
+ sunflowerUseModal.close();
294
+ }, [warnWhen, autoSaveProps.status]);
318
295
 
319
- return {
320
- ...useFormProps,
321
- ...sunflowerUseModal,
322
- show: handleShow,
323
- close: handleClose,
324
- open: visible,
325
- formProps: {
326
- ...formProps,
327
- ...useFormProps.formProps,
328
- onValuesChange: formProps?.onValuesChange,
329
- onKeyUp: formProps?.onKeyUp,
330
- onFinish: async (values) => {
331
- await onFinish(values);
296
+ const handleShow = useCallback(
297
+ (showId?: BaseKey) => {
298
+ if (typeof showId !== "undefined") {
299
+ setId?.(showId);
300
+ }
301
+ const needsIdToOpen = action === "edit" || action === "clone";
302
+ const hasId = typeof showId !== "undefined" || typeof id !== "undefined";
303
+ if (needsIdToOpen ? hasId : true) {
304
+ sunflowerUseModal.show();
305
+ }
306
+ },
307
+ [id],
308
+ );
332
309
 
333
- if (autoSubmitClose) {
334
- close();
335
- }
310
+ const { visible: _visible, ...otherModalProps } = modalProps;
311
+ const newModalProps = { open: _visible, ...otherModalProps };
336
312
 
337
- if (autoResetForm) {
338
- form.resetFields();
339
- }
340
- },
341
- },
342
- modalProps: {
343
- ...newModalProps,
344
- width: "1000px",
345
- okButtonProps: saveButtonPropsSF,
346
- title: translate(
347
- `${identifier}.titles.${rest.action}`,
348
- `${getUserFriendlyName(
349
- `${rest.action} ${
350
- resource?.meta?.label ??
351
- resource?.options?.label ??
352
- resource?.label ??
353
- identifier
354
- }`,
355
- "singular",
356
- )}`,
357
- ),
358
- okText: translate("buttons.save", "Save"),
359
- cancelText: translate("buttons.cancel", "Cancel"),
360
- onCancel: handleClose,
361
- forceRender: true,
362
- },
363
- formLoading,
364
- };
313
+ return {
314
+ ...useFormProps,
315
+ ...sunflowerUseModal,
316
+ show: handleShow,
317
+ close: handleClose,
318
+ open: visible,
319
+ formProps: {
320
+ ...formProps,
321
+ ...useFormProps.formProps,
322
+ onValuesChange: formProps?.onValuesChange,
323
+ onKeyUp: formProps?.onKeyUp,
324
+ onFinish: async (values) => {
325
+ await onFinish(values);
326
+
327
+ if (autoSubmitClose) {
328
+ close();
329
+ }
330
+
331
+ if (autoResetForm) {
332
+ form.resetFields();
333
+ }
334
+ },
335
+ },
336
+ modalProps: {
337
+ ...newModalProps,
338
+ width: "1000px",
339
+ okButtonProps: saveButtonPropsSF,
340
+ title: translate(
341
+ `${identifier}.titles.${rest.action}`,
342
+ `${getUserFriendlyName(
343
+ `${rest.action} ${
344
+ resource?.meta?.label ??
345
+ resource?.options?.label ??
346
+ resource?.label ??
347
+ identifier
348
+ }`,
349
+ "singular",
350
+ )}`,
351
+ ),
352
+ okText: translate("buttons.save", "Save"),
353
+ cancelText: translate("buttons.cancel", "Cancel"),
354
+ onCancel: handleClose,
355
+ forceRender: true,
356
+ },
357
+ formLoading,
358
+ };
365
359
  };
@@ -1,5 +1,5 @@
1
1
  export {
2
- useStepsForm,
3
- UseStepsFormProps,
4
- UseStepsFormReturnType,
2
+ useStepsForm,
3
+ UseStepsFormProps,
4
+ UseStepsFormReturnType,
5
5
  } from "./useStepsForm";