From 40d1f08c2fa2b8b0959fe8caec036230fc4f8e4c Mon Sep 17 00:00:00 2001 From: Roshane Pascual Date: Wed, 31 May 2023 11:19:43 -0700 Subject: [PATCH] chore: add declaration snapshots (#1018) --- ...studio-ui-codegen-react-forms.test.ts.snap | 1326 ++++++++--------- .../studio-ui-codegen-react-forms.test.ts | 71 +- 2 files changed, 631 insertions(+), 766 deletions(-) diff --git a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap index eb8f8b44..f99e3880 100644 --- a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap +++ b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap @@ -9,76 +9,17 @@ import { Divider, Flex, Grid, - GridProps, Icon, ScrollView, Text, TextAreaField, - TextAreaFieldProps, TextField, - TextFieldProps, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; -import { Post } from \\"../API\\"; +import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; import { fetchByPath, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { createPost } from \\"../graphql/mutations\\"; - -export declare type ValidationResponse = { - hasError: boolean; - errorMessage?: string; -}; -export declare type ValidationFunction = ( - value: T, - validationResponse: ValidationResponse -) => ValidationResponse | Promise; -export declare type MyPostFormInputValues = { - caption?: string; - username?: string; - post_url?: string; - metadata?: string; - profile_url?: string; - nonModelField?: string; - nonModelFieldArray?: string[]; -}; -export declare type MyPostFormValidationValues = { - caption?: ValidationFunction; - username?: ValidationFunction; - post_url?: ValidationFunction; - metadata?: ValidationFunction; - profile_url?: ValidationFunction; - nonModelField?: ValidationFunction; - nonModelFieldArray?: ValidationFunction; -}; -export declare type PrimitiveOverrideProps = Partial & - React.DOMAttributes; -export declare type MyPostFormOverridesProps = { - MyPostFormGrid?: PrimitiveOverrideProps; - caption?: PrimitiveOverrideProps; - username?: PrimitiveOverrideProps; - post_url?: PrimitiveOverrideProps; - metadata?: PrimitiveOverrideProps; - profile_url?: PrimitiveOverrideProps; - nonModelField?: PrimitiveOverrideProps; - nonModelFieldArray?: PrimitiveOverrideProps; -} & EscapeHatchProps; -export type MyPostFormProps = React.PropsWithChildren< - { - overrides?: MyPostFormOverridesProps | undefined | null; - } & { - clearOnSuccess?: boolean; - onSubmit?: (fields: MyPostFormInputValues) => MyPostFormInputValues; - onSuccess?: (fields: MyPostFormInputValues) => void; - onError?: (fields: MyPostFormInputValues, errorMessage: string) => void; - onCancel?: () => void; - onChange?: (fields: MyPostFormInputValues) => MyPostFormInputValues; - onValidate?: MyPostFormValidationValues; - } & React.CSSProperties ->; function ArrayField({ items = [], onChange, @@ -237,7 +178,7 @@ function ArrayField({ ); } -export default function MyPostForm(props: MyPostFormProps): React.ReactElement { +export default function MyPostForm(props) { const { clearOnSuccess = true, onSuccess, @@ -313,13 +254,12 @@ export default function MyPostForm(props: MyPostFormProps): React.ReactElement { return validationResponse; }; return ( - /* @ts-ignore: TS2322 */ { + onSubmit={async (event) => { event.preventDefault(); let modelFields = { caption, @@ -401,7 +341,7 @@ export default function MyPostForm(props: MyPostFormProps): React.ReactElement {