@applica-software-guru/react-admin 1.1.112 → 1.1.113
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/dist/components/ra-forms/Create.d.ts +3 -1
- package/dist/components/ra-forms/Create.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +5 -5
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +97 -97
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +14 -14
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ra-forms/Create.tsx +6 -4
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import { useCallback, createContext, useContext } from 'react';
|
|
2
|
+
import { useCallback, createContext, useContext, useMemo } from 'react';
|
|
3
3
|
import { CreateProps, Identifier, Create as RaCreate, RaRecord, useDataProvider, useResourceContext } from 'react-admin';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import { useLocation } from 'react-router';
|
|
6
|
-
import { useQuery } from 'react-query';
|
|
6
|
+
import { useQuery, UseQueryOptions } from 'react-query';
|
|
7
7
|
import { Stack, CircularProgress } from '@mui/material';
|
|
8
8
|
|
|
9
9
|
type ICreateProps<
|
|
@@ -12,13 +12,14 @@ type ICreateProps<
|
|
|
12
12
|
> = CreateProps<RecordType, Error, ResultRecordType> & {
|
|
13
13
|
children: React.ReactNode;
|
|
14
14
|
useDefaults?: boolean;
|
|
15
|
+
queryOptions?: UseQueryOptions
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
type IResourceDefaultValue = object;
|
|
18
19
|
const ResourceDefaultValueContext = createContext<IResourceDefaultValue>({});
|
|
19
20
|
|
|
20
21
|
function Create(props: ICreateProps) {
|
|
21
|
-
const { useDefaults = false } = props,
|
|
22
|
+
const { useDefaults = false, queryOptions = {} } = props,
|
|
22
23
|
resource = useResourceContext(),
|
|
23
24
|
dataProvider = useDataProvider(),
|
|
24
25
|
{ search } = useLocation(),
|
|
@@ -45,7 +46,8 @@ function Create(props: ICreateProps) {
|
|
|
45
46
|
}
|
|
46
47
|
});
|
|
47
48
|
}, [resource, useDefaults, search, dataProvider]),
|
|
48
|
-
|
|
49
|
+
_queryOptions = useMemo<UseQueryOptions>(() => _.chain(queryOptions).extend({ queryKey: [resource, search], queryFn: fetch }).value(), [resource, search, fetch, queryOptions]),
|
|
50
|
+
{ data, isLoading } = useQuery(_queryOptions),
|
|
49
51
|
passProps = _.omit(props, ['useDefaults']);
|
|
50
52
|
|
|
51
53
|
return isLoading ? (
|