@refinedev/antd 5.41.0 → 5.43.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +87 -1
  2. package/dist/components/fields/date/index.d.cts.map +1 -1
  3. package/dist/components/fields/date/index.d.ts.map +1 -1
  4. package/dist/components/pages/auth/components/forgotPassword/index.d.cts.map +1 -1
  5. package/dist/components/pages/auth/components/forgotPassword/index.d.ts.map +1 -1
  6. package/dist/components/pages/auth/components/register/index.d.cts.map +1 -1
  7. package/dist/components/pages/auth/components/register/index.d.ts.map +1 -1
  8. package/dist/hooks/fields/useCheckboxGroup/index.d.cts +4 -0
  9. package/dist/hooks/fields/useCheckboxGroup/index.d.cts.map +1 -1
  10. package/dist/hooks/fields/useCheckboxGroup/index.d.mts +4 -0
  11. package/dist/hooks/fields/useCheckboxGroup/index.d.mts.map +4 -0
  12. package/dist/hooks/fields/useCheckboxGroup/index.d.ts +4 -0
  13. package/dist/hooks/fields/useCheckboxGroup/index.d.ts.map +1 -1
  14. package/dist/hooks/fields/useRadioGroup/index.d.cts +4 -0
  15. package/dist/hooks/fields/useRadioGroup/index.d.cts.map +1 -1
  16. package/dist/hooks/fields/useRadioGroup/index.d.mts +4 -0
  17. package/dist/hooks/fields/useRadioGroup/index.d.mts.map +4 -0
  18. package/dist/hooks/fields/useRadioGroup/index.d.ts +4 -0
  19. package/dist/hooks/fields/useRadioGroup/index.d.ts.map +1 -1
  20. package/dist/hooks/fields/useSelect/index.d.cts +8 -0
  21. package/dist/hooks/fields/useSelect/index.d.cts.map +1 -1
  22. package/dist/hooks/fields/useSelect/index.d.mts +8 -0
  23. package/dist/hooks/fields/useSelect/index.d.mts.map +8 -0
  24. package/dist/hooks/fields/useSelect/index.d.ts +8 -0
  25. package/dist/hooks/fields/useSelect/index.d.ts.map +1 -1
  26. package/dist/hooks/list/useSimpleList/useSimpleList.d.cts +5 -1
  27. package/dist/hooks/list/useSimpleList/useSimpleList.d.cts.map +1 -1
  28. package/dist/hooks/list/useSimpleList/useSimpleList.d.mts +5 -1
  29. package/dist/hooks/list/useSimpleList/useSimpleList.d.mts.map +5 -1
  30. package/dist/hooks/list/useSimpleList/useSimpleList.d.ts +5 -1
  31. package/dist/hooks/list/useSimpleList/useSimpleList.d.ts.map +1 -1
  32. package/dist/hooks/table/useTable/useTable.d.cts.map +1 -1
  33. package/dist/hooks/table/useTable/useTable.d.ts.map +1 -1
  34. package/dist/index.cjs +1 -1
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.mjs +1 -1
  37. package/dist/index.mjs.map +1 -1
  38. package/package.json +4 -4
  39. package/src/components/fields/date/index.tsx +5 -3
  40. package/src/components/pages/auth/components/forgotPassword/index.tsx +9 -3
  41. package/src/components/pages/auth/components/register/index.tsx +21 -6
  42. package/src/hooks/fields/useCheckboxGroup/index.ts +7 -7
  43. package/src/hooks/fields/useRadioGroup/index.ts +7 -7
  44. package/src/hooks/fields/useSelect/index.ts +19 -5
  45. package/src/hooks/form/useForm.ts +4 -4
  46. package/src/hooks/list/useSimpleList/useSimpleList.ts +7 -1
  47. package/src/hooks/table/useTable/useTable.ts +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@refinedev/antd",
3
- "version": "5.41.0",
3
+ "version": "5.43.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.35",
50
- "@refinedev/core": "^4.52.0",
51
- "@refinedev/ui-tests": "^1.14.8",
49
+ "@refinedev/cli": "^2.16.37",
50
+ "@refinedev/core": "^4.54.0",
51
+ "@refinedev/ui-tests": "^1.14.9",
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",
@@ -23,9 +23,11 @@ export const DateField: React.FC<DateFieldProps> = ({
23
23
 
24
24
  return (
25
25
  <Typography.Text {...rest}>
26
- {dayjs(value)
27
- .locale(locales || defaultLocale)
28
- .format(dateFormat)}
26
+ {value
27
+ ? dayjs(value)
28
+ .locale(locales || defaultLocale)
29
+ .format(dateFormat)
30
+ : ""}
29
31
  </Typography.Text>
30
32
  );
31
33
  };
@@ -151,8 +151,11 @@ export const ForgotPasswordPage: React.FC<ResetPassworProps> = ({
151
151
  }}
152
152
  >
153
153
  {translate(
154
- "pages.register.buttons.haveAccount",
155
- "Have an account? ",
154
+ "pages.forgotPassword.buttons.haveAccount",
155
+ translate(
156
+ "pages.register.buttons.haveAccount",
157
+ "Have an account? ",
158
+ ),
156
159
  )}{" "}
157
160
  <ActiveLink
158
161
  style={{
@@ -161,7 +164,10 @@ export const ForgotPasswordPage: React.FC<ResetPassworProps> = ({
161
164
  }}
162
165
  to="/login"
163
166
  >
164
- {translate("pages.login.signin", "Sign in")}
167
+ {translate(
168
+ "pages.forgotPassword.signin",
169
+ translate("pages.login.signin", "Sign in"),
170
+ )}
165
171
  </ActiveLink>
166
172
  </Typography.Text>
167
173
  )}
@@ -123,7 +123,10 @@ export const RegisterPage: React.FC<RegisterProps> = ({
123
123
  color: token.colorTextLabel,
124
124
  }}
125
125
  >
126
- {translate("pages.login.divider", "or")}
126
+ {translate(
127
+ "pages.register.divider",
128
+ translate("pages.login.divider", "or"),
129
+ )}
127
130
  </Typography.Text>
128
131
  </Divider>
129
132
  )}
@@ -208,8 +211,11 @@ export const RegisterPage: React.FC<RegisterProps> = ({
208
211
  }}
209
212
  >
210
213
  {translate(
211
- "pages.login.buttons.haveAccount",
212
- "Have an account?",
214
+ "pages.register.buttons.haveAccount",
215
+ translate(
216
+ "pages.login.buttons.haveAccount",
217
+ "Have an account?",
218
+ ),
213
219
  )}{" "}
214
220
  <ActiveLink
215
221
  style={{
@@ -218,7 +224,10 @@ export const RegisterPage: React.FC<RegisterProps> = ({
218
224
  }}
219
225
  to="/login"
220
226
  >
221
- {translate("pages.login.signin", "Sign in")}
227
+ {translate(
228
+ "pages.register.signin",
229
+ translate("pages.login.signin", "Sign in"),
230
+ )}
222
231
  </ActiveLink>
223
232
  </Typography.Text>
224
233
  )}
@@ -251,7 +260,10 @@ export const RegisterPage: React.FC<RegisterProps> = ({
251
260
  fontSize: 12,
252
261
  }}
253
262
  >
254
- {translate("pages.login.buttons.haveAccount", "Have an account?")}{" "}
263
+ {translate(
264
+ "pages.register.buttons.haveAccount",
265
+ translate("pages.login.buttons.haveAccount", "Have an account?"),
266
+ )}{" "}
255
267
  <ActiveLink
256
268
  style={{
257
269
  fontWeight: "bold",
@@ -259,7 +271,10 @@ export const RegisterPage: React.FC<RegisterProps> = ({
259
271
  }}
260
272
  to="/login"
261
273
  >
262
- {translate("pages.login.signin", "Sign in")}
274
+ {translate(
275
+ "pages.register.signin",
276
+ translate("pages.login.signin", "Sign in"),
277
+ )}
263
278
  </ActiveLink>
264
279
  </Typography.Text>
265
280
  </div>
@@ -22,6 +22,10 @@ export type UseCheckboxGroupReturnType<
22
22
  > & {
23
23
  options: TOption[];
24
24
  };
25
+ query: QueryObserverResult<GetListResponse<TData>>;
26
+ /**
27
+ * @deprecated Use `query` instead
28
+ */
25
29
  queryResult: QueryObserverResult<GetListResponse<TData>>;
26
30
  };
27
31
 
@@ -74,12 +78,7 @@ export const useCheckboxGroup = <
74
78
  TError,
75
79
  TData
76
80
  >): UseCheckboxGroupReturnType<TData, TOption> => {
77
- const { queryResult, options } = useSelect<
78
- TQueryFnData,
79
- TError,
80
- TData,
81
- TOption
82
- >({
81
+ const { query, options } = useSelect<TQueryFnData, TError, TData, TOption>({
83
82
  resource,
84
83
  sort,
85
84
  sorters,
@@ -103,6 +102,7 @@ export const useCheckboxGroup = <
103
102
  options,
104
103
  defaultValue,
105
104
  },
106
- queryResult,
105
+ query,
106
+ queryResult: query,
107
107
  };
108
108
  };
@@ -19,6 +19,10 @@ export type UseRadioGroupReturnType<
19
19
  radioGroupProps: Omit<React.ComponentProps<typeof Radio.Group>, "options"> & {
20
20
  options: TOption[];
21
21
  };
22
+ query: QueryObserverResult<GetListResponse<TData>>;
23
+ /**
24
+ * @deprecated Use `query` instead
25
+ */
22
26
  queryResult: QueryObserverResult<GetListResponse<TData>>;
23
27
  };
24
28
 
@@ -70,12 +74,7 @@ export const useRadioGroup = <
70
74
  TData,
71
75
  TOption
72
76
  > => {
73
- const { queryResult, options } = useSelect<
74
- TQueryFnData,
75
- TError,
76
- TData,
77
- TOption
78
- >({
77
+ const { query, options } = useSelect<TQueryFnData, TError, TData, TOption>({
79
78
  resource,
80
79
  sort,
81
80
  sorters,
@@ -100,6 +99,7 @@ export const useRadioGroup = <
100
99
  options,
101
100
  defaultValue,
102
101
  },
103
- queryResult,
102
+ query,
103
+ queryResult: query,
104
104
  };
105
105
  };
@@ -16,7 +16,15 @@ export type UseSelectReturnType<
16
16
  TOption extends BaseOption = BaseOption,
17
17
  > = {
18
18
  selectProps: SelectProps<TOption>;
19
+ query: QueryObserverResult<GetListResponse<TData>>;
20
+ defaultValueQuery: QueryObserverResult<GetManyResponse<TData>>;
21
+ /**
22
+ * @deprecated Use `query` instead
23
+ */
19
24
  queryResult: QueryObserverResult<GetListResponse<TData>>;
25
+ /**
26
+ * @deprecated Use `defaultValueQuery` instead
27
+ */
20
28
  defaultValueQueryResult: QueryObserverResult<GetManyResponse<TData>>;
21
29
  };
22
30
 
@@ -39,18 +47,24 @@ export const useSelect = <
39
47
  >(
40
48
  props: UseSelectProps<TQueryFnData, TError, TData>,
41
49
  ): UseSelectReturnType<TData, TOption> => {
42
- const { queryResult, defaultValueQueryResult, onSearch, options } =
43
- useSelectCore<TQueryFnData, TError, TData, TOption>(props);
50
+ const { query, defaultValueQuery, onSearch, options } = useSelectCore<
51
+ TQueryFnData,
52
+ TError,
53
+ TData,
54
+ TOption
55
+ >(props);
44
56
 
45
57
  return {
46
58
  selectProps: {
47
59
  options,
48
60
  onSearch,
49
- loading: defaultValueQueryResult.isFetching,
61
+ loading: defaultValueQuery.isFetching,
50
62
  showSearch: true,
51
63
  filterOption: false,
52
64
  },
53
- queryResult,
54
- defaultValueQueryResult,
65
+ query,
66
+ defaultValueQuery,
67
+ queryResult: query,
68
+ defaultValueQueryResult: defaultValueQuery,
55
69
  };
56
70
  };
@@ -262,7 +262,7 @@ export const useForm = <
262
262
  autoSave,
263
263
  });
264
264
 
265
- const { formLoading, onFinish, queryResult, id, onFinishAutoSave } =
265
+ const { formLoading, onFinish, query, id, onFinishAutoSave } =
266
266
  useFormCoreResult;
267
267
 
268
268
  const { warnWhenUnsavedChanges: warnWhenUnsavedChangesRefine, setWarnWhen } =
@@ -270,11 +270,11 @@ export const useForm = <
270
270
  const warnWhenUnsavedChanges =
271
271
  warnWhenUnsavedChangesProp ?? warnWhenUnsavedChangesRefine;
272
272
 
273
- // populate form with data when queryResult is ready or id changes
273
+ // populate form with data when query is ready or id changes
274
274
  // form populated via initialValues prop
275
275
  React.useEffect(() => {
276
276
  form.resetFields();
277
- }, [queryResult?.data?.data, id]);
277
+ }, [query?.data?.data, id]);
278
278
 
279
279
  const onKeyUp = (event: React.KeyboardEvent<HTMLFormElement>) => {
280
280
  if (submitOnEnter && event.key === "Enter") {
@@ -315,7 +315,7 @@ export const useForm = <
315
315
  onFinish(values).catch((error) => error),
316
316
  onKeyUp,
317
317
  onValuesChange,
318
- initialValues: queryResult?.data?.data,
318
+ initialValues: query?.data?.data,
319
319
  },
320
320
  saveButtonProps,
321
321
  defaultFormValuesLoading: formSF.defaultFormValuesLoading,
@@ -23,9 +23,13 @@ export type useSimpleListReturnType<
23
23
  TQueryFnData extends BaseRecord = BaseRecord,
24
24
  TSearchVariables = unknown,
25
25
  TData extends BaseRecord = TQueryFnData,
26
- > = Omit<useTableReturnType<TData>, "tableQueryResult"> & {
26
+ > = Omit<useTableReturnType<TData>, "tableQueryResult" | "tableQuery"> & {
27
27
  listProps: ListProps<TData>;
28
+ /**
29
+ * @deprecated Use `query` instead
30
+ */
28
31
  queryResult: useTableReturnType["tableQueryResult"];
32
+ query: useTableReturnType["tableQuery"];
29
33
  searchFormProps: FormProps<TSearchVariables>;
30
34
  };
31
35
 
@@ -91,6 +95,7 @@ export const useSimpleList = <
91
95
  setSorters,
92
96
  createLinkForSyncWithLocation,
93
97
  tableQueryResult: queryResult,
98
+ tableQuery: query,
94
99
  overtime,
95
100
  } = useTableCore({
96
101
  resource,
@@ -208,6 +213,7 @@ export const useSimpleList = <
208
213
  loading: liveMode === "auto" ? isLoading : !isFetched,
209
214
  pagination: antdPagination(),
210
215
  },
216
+ query,
211
217
  queryResult,
212
218
  filters,
213
219
  setFilters,
@@ -92,6 +92,7 @@ export const useTable = <
92
92
  > = {}): useTableReturnType<TData, TError, TSearchVariables> => {
93
93
  const {
94
94
  tableQueryResult,
95
+ tableQuery,
95
96
  current,
96
97
  setCurrent,
97
98
  pageSize,
@@ -279,6 +280,7 @@ export const useTable = <
279
280
  scroll: { x: true },
280
281
  },
281
282
  tableQueryResult,
283
+ tableQuery,
282
284
  sorters,
283
285
  sorter,
284
286
  filters,