From f98a41b83ae7d95185dddc9020fbd1d6eca01f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Hertault?= Date: Wed, 9 Dec 2020 11:07:05 +0100 Subject: [PATCH] Add base react-admin props to components (#25) (#27) * Add base react-admin props to components (#25) Co-authored-by: Marcin Pycio * Build and bump version Co-authored-by: Marcin Pycio Co-authored-by: Marcin Pycio --- package-lock.json | 2 +- package.json | 2 +- src/components/AmplifyAdmin.tsx | 13 ++++++++++--- src/components/AmplifyFileField.tsx | 4 ++-- src/components/AmplifyFileInput.tsx | 9 +++++++-- src/components/AmplifyFilter.tsx | 13 ++++++++++--- src/components/AmplifyImageField.tsx | 4 ++-- src/components/AmplifyImageInput.tsx | 9 +++++++-- src/typings.d.ts | 1 - 9 files changed, 40 insertions(+), 17 deletions(-) delete mode 100644 src/typings.d.ts diff --git a/package-lock.json b/package-lock.json index d71107d..506ec43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-admin-amplify", - "version": "1.2.2", + "version": "1.2.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9e3442d..43e4dfd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-admin-amplify", - "version": "1.2.2", + "version": "1.2.3", "description": "AWS Amplify data provider for react-admin.", "repository": { "type": "git", diff --git a/src/components/AmplifyAdmin.tsx b/src/components/AmplifyAdmin.tsx index c75a1de..9a4a38e 100644 --- a/src/components/AmplifyAdmin.tsx +++ b/src/components/AmplifyAdmin.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { Admin } from "react-admin"; +import { Admin, AdminProps } from "react-admin"; import { buildAuthProvider, buildDataProvider } from "../providers"; import { Operations } from "../providers/DataProvider"; @@ -13,10 +13,17 @@ const defaultOptions: AmplifyAdminOptions = { authGroups: [], }; -export const AmplifyAdmin: React.FC<{ +type Props = { operations: Operations; options?: AmplifyAdminOptions; -}> = ({ children, operations, options = defaultOptions, ...propsRest }) => { +} & Omit; + +export const AmplifyAdmin: React.FC = ({ + children, + operations, + options = defaultOptions, + ...propsRest +}) => { const optionsBag = { ...defaultOptions, ...options }; const { authGroups, storageBucket, storageRegion } = optionsBag; diff --git a/src/components/AmplifyFileField.tsx b/src/components/AmplifyFileField.tsx index 70f9886..ffc2232 100644 --- a/src/components/AmplifyFileField.tsx +++ b/src/components/AmplifyFileField.tsx @@ -1,12 +1,12 @@ import React from "react"; -import { FileField } from "react-admin"; +import { FileField, FileFieldProps } from "react-admin"; import { useStorageField } from "../hooks/useStorageField"; type Props = { source?: string; record?: any; storageOptions?: any; -}; +} & FileFieldProps; export const AmplifyFileField: React.FC = ({ source, diff --git a/src/components/AmplifyFileInput.tsx b/src/components/AmplifyFileInput.tsx index 0789090..0be4fef 100644 --- a/src/components/AmplifyFileInput.tsx +++ b/src/components/AmplifyFileInput.tsx @@ -1,5 +1,9 @@ +import { + FileInputOptions, + FileInputProps, +} from "ra-ui-materialui/lib/input/FileInput"; import React from "react"; -import { FileInput } from "react-admin"; +import { FileInput, InputProps } from "react-admin"; import { useStorageInput } from "../hooks/useStorageInput"; import { AmplifyFileField } from "./AmplifyFileField"; @@ -8,7 +12,8 @@ type Props = { multiple?: boolean; options?: any; storageOptions?: any; -}; +} & FileInputProps & + InputProps; export const AmplifyFileInput: React.FC = ({ options = {}, diff --git a/src/components/AmplifyFilter.tsx b/src/components/AmplifyFilter.tsx index 1c759c9..967fd9a 100644 --- a/src/components/AmplifyFilter.tsx +++ b/src/components/AmplifyFilter.tsx @@ -1,5 +1,5 @@ import React, { useEffect } from "react"; -import { Filter } from "react-admin"; +import { Filter, FilterProps } from "react-admin"; interface Keys { [index: string]: { @@ -62,10 +62,17 @@ function getKeys(filters: React.ReactNodeArray): Keys { return keys; } -export const AmplifyFilter: React.FC<{ +type Props = { defaultQuery: string; setQuery?: React.Dispatch; -}> = ({ children, defaultQuery, setQuery = null, ...propsRest }) => { +} & FilterProps; + +export const AmplifyFilter: React.FC = ({ + children, + defaultQuery, + setQuery = null, + ...propsRest +}) => { let filters; if (children !== null && typeof children === "object") { diff --git a/src/components/AmplifyImageField.tsx b/src/components/AmplifyImageField.tsx index 73a6b43..ecbad7d 100644 --- a/src/components/AmplifyImageField.tsx +++ b/src/components/AmplifyImageField.tsx @@ -1,12 +1,12 @@ import React from "react"; -import { ImageField } from "react-admin"; +import { ImageField, ImageFieldProps } from "react-admin"; import { useStorageField } from "../hooks/useStorageField"; type Props = { source?: string; record?: any; storageOptions?: any; -}; +} & ImageFieldProps; export const AmplifyImageField: React.FC = ({ source, diff --git a/src/components/AmplifyImageInput.tsx b/src/components/AmplifyImageInput.tsx index ccdaf65..fd1b4e0 100644 --- a/src/components/AmplifyImageInput.tsx +++ b/src/components/AmplifyImageInput.tsx @@ -1,5 +1,9 @@ +import { + FileInputOptions, + FileInputProps, +} from "ra-ui-materialui/lib/input/FileInput"; import React from "react"; -import { ImageInput } from "react-admin"; +import { ImageInput, InputProps } from "react-admin"; import { useStorageInput } from "../hooks/useStorageInput"; import { AmplifyImageField } from "./AmplifyImageField"; @@ -8,7 +12,8 @@ type Props = { multiple?: boolean; options?: any; storageOptions?: any; -}; +} & FileInputProps & + InputProps; export const AmplifyImageInput: React.FC = ({ options = {}, diff --git a/src/typings.d.ts b/src/typings.d.ts deleted file mode 100644 index 4b46e42..0000000 --- a/src/typings.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module "react-admin";